@gooddata/code-cli 0.47.0-alpha.3 → 0.47.0-alpha.5
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/dist/index.js +541 -446
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -37370,7 +37370,7 @@ function isPromise(value) {
|
|
|
37370
37370
|
//#endregion
|
|
37371
37371
|
//#region package.json
|
|
37372
37372
|
var name$1 = "@gooddata/code-cli";
|
|
37373
|
-
var version$1 = "0.47.0-alpha.
|
|
37373
|
+
var version$1 = "0.47.0-alpha.5";
|
|
37374
37374
|
//#endregion
|
|
37375
37375
|
//#region ../../../common/temp/aac/node_modules/.pnpm/vscode-languageserver@8.1.0/node_modules/vscode-languageserver/lib/common/utils/is.js
|
|
37376
37376
|
var require_is$2 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
@@ -134404,6 +134404,9 @@ const CoreErrorMessages = {
|
|
|
134404
134404
|
["core.onlyOneAttributeItemAllowed"]: `Dashboard filters contains more filters with same attribute or label "{0}".`,
|
|
134405
134405
|
["core.multipleCommonDateFilters"]: `Multiple usage of common date filters in dashboard. Define exactly one date filter that has no date dataset defined.`,
|
|
134406
134406
|
["core.duplicateFilterLocalIdentifier"]: `Duplicate filter local identifier "{0}". Each filter must have a unique local identifier across a dashboard tab, including filters in groups.`,
|
|
134407
|
+
["core.duplicateFieldName"]: `Duplicate field name "{0}". Each field a query declares must have a unique name.`,
|
|
134408
|
+
["core.duplicateFilterName"]: `Duplicate filter name "{0}". Each filter in a query must have a unique name, including the filters a date filter carries.`,
|
|
134409
|
+
["core.duplicateLayerIdentifier"]: `Duplicate layer id "{0}". Each layer of a visualisation must have a unique id.`,
|
|
134407
134410
|
["core.duplicateTabIdentifier"]: `Duplicate tab identifier "{0}". Each tab must have a unique identifier within the dashboard.`,
|
|
134408
134411
|
["core.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.`
|
|
134409
134412
|
};
|
|
@@ -134422,6 +134425,9 @@ const CoreErrorTypes = {
|
|
|
134422
134425
|
["core.onlyOneAttributeItemAllowed"]: "OnlyOneAttributeItemAllowed",
|
|
134423
134426
|
["core.multipleCommonDateFilters"]: "MultipleCommonDateFilters",
|
|
134424
134427
|
["core.duplicateFilterLocalIdentifier"]: "DuplicateFilterLocalIdentifier",
|
|
134428
|
+
["core.duplicateFieldName"]: "DuplicateFieldName",
|
|
134429
|
+
["core.duplicateFilterName"]: "DuplicateFilterName",
|
|
134430
|
+
["core.duplicateLayerIdentifier"]: "DuplicateLayerIdentifier",
|
|
134425
134431
|
["core.duplicateTabIdentifier"]: "DuplicateTabIdentifier",
|
|
134426
134432
|
["core.tabsAndRootContentMutuallyExclusive"]: "TabsAndRootContentMutuallyExclusive"
|
|
134427
134433
|
};
|
|
@@ -135122,6 +135128,7 @@ function loadColorMapping(mappings) {
|
|
|
135122
135128
|
const map = new import_dist.YAMLMap();
|
|
135123
135129
|
mappings.forEach((mapping) => {
|
|
135124
135130
|
const { color, id } = mapping;
|
|
135131
|
+
if (id === null) throw newError("core.itemNotSupported", ["color mapping of the empty element"]);
|
|
135125
135132
|
const col = loadColor(id, color);
|
|
135126
135133
|
if (col) map.add(col);
|
|
135127
135134
|
});
|
|
@@ -135136,18 +135143,29 @@ function loadColorDefinitions(mappings) {
|
|
|
135136
135143
|
});
|
|
135137
135144
|
return map;
|
|
135138
135145
|
}
|
|
135139
|
-
|
|
135146
|
+
const COMPARISON_GUIDS = {
|
|
135147
|
+
positive: 1,
|
|
135148
|
+
negative: -1,
|
|
135149
|
+
equals: 0
|
|
135150
|
+
};
|
|
135151
|
+
/**
|
|
135152
|
+
* Only `/^\d+$/` guids resolve against a workspace palette (see `guidEquals` in sdk-ui-vis-commons), and
|
|
135153
|
+
* the schema admits no colour string but `rgb(...)`, so anything else has no code form.
|
|
135154
|
+
*/
|
|
135155
|
+
function loadColor(key, color, mode = "number") {
|
|
135140
135156
|
if (!color) return;
|
|
135141
|
-
|
|
135142
|
-
|
|
135143
|
-
|
|
135144
|
-
|
|
135145
|
-
|
|
135157
|
+
const { type } = color;
|
|
135158
|
+
if (type === "guid") {
|
|
135159
|
+
const comparison = COMPARISON_GUIDS[color.value];
|
|
135160
|
+
if (mode === "enum") {
|
|
135161
|
+
if (comparison === void 0) throw newError("core.itemNotSupported", [`comparison color "${color.value}"`]);
|
|
135162
|
+
return new import_dist.Pair(key, comparison);
|
|
135146
135163
|
}
|
|
135147
|
-
|
|
135164
|
+
if (!/^\d+$/.test(color.value)) throw newError("core.itemNotSupported", [`color "${color.value}"`]);
|
|
135165
|
+
return new import_dist.Pair(key, Number.parseInt(color.value, 10));
|
|
135148
135166
|
}
|
|
135149
|
-
if (
|
|
135150
|
-
throw
|
|
135167
|
+
if (type === "rgb") return new import_dist.Pair(key, `rgb(${color.value.r},${color.value.g},${color.value.b})`);
|
|
135168
|
+
throw newError("core.itemNotSupported", [`color of type "${type}"`]);
|
|
135151
135169
|
}
|
|
135152
135170
|
/** @public */
|
|
135153
135171
|
function saveColorMapping(mapping) {
|
|
@@ -135196,7 +135214,7 @@ function getDefById(id) {
|
|
|
135196
135214
|
case "properties.color.total": return "total";
|
|
135197
135215
|
case "properties.color.positive": return "positive";
|
|
135198
135216
|
case "properties.color.negative": return "negative";
|
|
135199
|
-
default: throw
|
|
135217
|
+
default: throw newError("core.itemNotSupported", [`color definition "${id}"`]);
|
|
135200
135218
|
}
|
|
135201
135219
|
}
|
|
135202
135220
|
function getIdByDef(def) {
|
|
@@ -137011,9 +137029,9 @@ function headlineChartLoad(props) {
|
|
|
137011
137029
|
["position", getValueOrDefault(val.position, DEFAULTS$11.comparison.position)],
|
|
137012
137030
|
["indicator_arrow", getValueOrDefault(val.isArrowEnabled, DEFAULTS$11.comparison.isArrowEnabled, "bool")],
|
|
137013
137031
|
["indicator_colors", val.colorConfig?.disabled === void 0 ? void 0 : !val.colorConfig.disabled],
|
|
137014
|
-
["indicator_color_equals", loadColor("equals", val.colorConfig?.equals)?.value],
|
|
137015
|
-
["indicator_color_negative", loadColor("negative", val.colorConfig?.negative)?.value],
|
|
137016
|
-
["indicator_color_positive", loadColor("positive", val.colorConfig?.positive)?.value],
|
|
137032
|
+
["indicator_color_equals", loadColor("equals", val.colorConfig?.equals, "enum")?.value],
|
|
137033
|
+
["indicator_color_negative", loadColor("negative", val.colorConfig?.negative, "enum")?.value],
|
|
137034
|
+
["indicator_color_positive", loadColor("positive", val.colorConfig?.positive, "enum")?.value],
|
|
137017
137035
|
["label_default", getValueOrDefault(val.labelConfig?.unconditionalValue, DEFAULTS$11.comparison.labelConfig.unconditionalValue)],
|
|
137018
137036
|
["label_conditional", getValueOrDefault(val.labelConfig?.isConditional, DEFAULTS$11.comparison.labelConfig.isConditional, "bool")],
|
|
137019
137037
|
["label_equals", getValueOrDefault(val.labelConfig?.equals, DEFAULTS$11.comparison.labelConfig.equals)],
|
|
@@ -139278,14 +139296,14 @@ function convertYamlConditionsToSdk(yamlConditions, nullValuesAsZero) {
|
|
|
139278
139296
|
});
|
|
139279
139297
|
return sdkConditions;
|
|
139280
139298
|
}
|
|
139281
|
-
function yamlAbsoluteDateFilterToDeclarative(entities, filter) {
|
|
139299
|
+
function yamlAbsoluteDateFilterToDeclarative(entities, filter, assignFilterLocalId) {
|
|
139282
139300
|
let result = { filters: [{ absoluteDateFilter: {
|
|
139283
139301
|
dataSet: createIdentifier(filter.using, { forceType: "dataset" }),
|
|
139284
139302
|
from: filter.from,
|
|
139285
139303
|
to: filter.to
|
|
139286
139304
|
} }] };
|
|
139287
139305
|
result = mergeDeclarativeResults(result, dateFilterEmptyValuesToDeclarative(filter));
|
|
139288
|
-
result = mergeDeclarativeResults(result, dateFilterWithFieldToDeclarative(entities, filter));
|
|
139306
|
+
result = mergeDeclarativeResults(result, dateFilterWithFieldToDeclarative(entities, filter, assignFilterLocalId));
|
|
139289
139307
|
return result;
|
|
139290
139308
|
}
|
|
139291
139309
|
function dateFilterEmptyValuesToDeclarative(filter) {
|
|
@@ -139303,11 +139321,11 @@ function dateFilterEmptyValuesToDeclarative(filter) {
|
|
|
139303
139321
|
}
|
|
139304
139322
|
return { filters: [] };
|
|
139305
139323
|
}
|
|
139306
|
-
function dateFilterWithFieldToDeclarative(entities, filter) {
|
|
139324
|
+
function dateFilterWithFieldToDeclarative(entities, filter, assignFilterLocalId) {
|
|
139307
139325
|
if (!filter.with) return { filters: [] };
|
|
139308
|
-
return mergeDeclarativeResults(...Object.entries(filter.with).map(([key, withFilter]) => yamlFilterToDeclarative(entities, key, withFilter)));
|
|
139326
|
+
return mergeDeclarativeResults(...Object.entries(filter.with).map(([key, withFilter]) => yamlFilterToDeclarative(entities, key, withFilter, assignFilterLocalId)));
|
|
139309
139327
|
}
|
|
139310
|
-
function yamlRelativeDateFilterToDeclarative(entities, filter) {
|
|
139328
|
+
function yamlRelativeDateFilterToDeclarative(entities, filter, assignFilterLocalId) {
|
|
139311
139329
|
const identifier = createIdentifier(filter.using, { forceType: "dataset" });
|
|
139312
139330
|
if (!identifier) throw new Error(`Could not find dataset ${filter.using} to use in relative date filter`);
|
|
139313
139331
|
let result = {
|
|
@@ -139325,7 +139343,7 @@ function yamlRelativeDateFilterToDeclarative(entities, filter) {
|
|
|
139325
139343
|
granularity: convertGranularity$1("YEAR")
|
|
139326
139344
|
} }] });
|
|
139327
139345
|
result = mergeDeclarativeResults(result, dateFilterEmptyValuesToDeclarative(filter));
|
|
139328
|
-
result = mergeDeclarativeResults(result, dateFilterWithFieldToDeclarative(entities, filter));
|
|
139346
|
+
result = mergeDeclarativeResults(result, dateFilterWithFieldToDeclarative(entities, filter, assignFilterLocalId));
|
|
139329
139347
|
return result;
|
|
139330
139348
|
}
|
|
139331
139349
|
function yamlPositiveAttributeFilterToDeclarative(entities, key, filter, assignFilterLocalId = false) {
|
|
@@ -139412,9 +139430,9 @@ function yamlRankingFilterToDeclarative(filter) {
|
|
|
139412
139430
|
...filter.strict_limit_of_rows === void 0 ? {} : { strictLimitOfRows: filter.strict_limit_of_rows }
|
|
139413
139431
|
} }] };
|
|
139414
139432
|
}
|
|
139415
|
-
function yamlFilterToDeclarative(entities, key, filter, assignFilterLocalId
|
|
139416
|
-
if (isAbsoluteDateFilter(filter)) return yamlAbsoluteDateFilterToDeclarative(entities, filter);
|
|
139417
|
-
if (isRelativeDateFilter(filter)) return yamlRelativeDateFilterToDeclarative(entities, filter);
|
|
139433
|
+
function yamlFilterToDeclarative(entities, key, filter, assignFilterLocalId) {
|
|
139434
|
+
if (isAbsoluteDateFilter(filter)) return yamlAbsoluteDateFilterToDeclarative(entities, filter, assignFilterLocalId);
|
|
139435
|
+
if (isRelativeDateFilter(filter)) return yamlRelativeDateFilterToDeclarative(entities, filter, assignFilterLocalId);
|
|
139418
139436
|
if (isPositiveAttributeFilter(filter)) return yamlPositiveAttributeFilterToDeclarative(entities, key, filter, assignFilterLocalId);
|
|
139419
139437
|
if (isNegativeAttributeFilter(filter)) return yamlNegativeAttributeFilterToDeclarative(entities, key, filter, assignFilterLocalId);
|
|
139420
139438
|
if (isArbitraryTextFilter(filter)) return yamlTextFilterToDeclarative(key, filter);
|
|
@@ -139432,6 +139450,19 @@ function mergeDeclarativeResults(...results) {
|
|
|
139432
139450
|
attributeFilterConfig: Object.assign({}, ...results.map((result) => result.attributeFilterConfig ?? {}))
|
|
139433
139451
|
};
|
|
139434
139452
|
}
|
|
139453
|
+
/**
|
|
139454
|
+
* A filter's key becomes its local identifier, and the whole query shares one namespace for them across
|
|
139455
|
+
* nested blocks — a name reused between blocks would leave two filters indistinguishable.
|
|
139456
|
+
*/
|
|
139457
|
+
function assertDistinctLocalIdentifiers(filters) {
|
|
139458
|
+
const seen = /* @__PURE__ */ new Set();
|
|
139459
|
+
for (const filter of filters) {
|
|
139460
|
+
const localIdentifier = filterLocalIdentifier(filter);
|
|
139461
|
+
if (!localIdentifier) continue;
|
|
139462
|
+
if (seen.has(localIdentifier)) throw newError("core.duplicateFilterName", [localIdentifier]);
|
|
139463
|
+
seen.add(localIdentifier);
|
|
139464
|
+
}
|
|
139465
|
+
}
|
|
139435
139466
|
/** @internal */
|
|
139436
139467
|
function yamlFiltersToDeclarative(entities, filters_by, attributeFilterConfigs = {}, assignFilterLocalId = false) {
|
|
139437
139468
|
const isArray = Array.isArray(filters_by);
|
|
@@ -139439,6 +139470,7 @@ function yamlFiltersToDeclarative(entities, filters_by, attributeFilterConfigs =
|
|
|
139439
139470
|
filters: [],
|
|
139440
139471
|
attributeFilterConfig: attributeFilterConfigs
|
|
139441
139472
|
}, ...filters_by && !isArray ? Object.entries(filters_by).map(([key, filter]) => yamlFilterToDeclarative(entities, key, filter, assignFilterLocalId)) : [], ...filters_by && isArray ? filters_by.map((filter, i) => yamlFilterToDeclarative(entities, i.toString(), filter, assignFilterLocalId)) : []);
|
|
139473
|
+
assertDistinctLocalIdentifiers(filters);
|
|
139442
139474
|
return {
|
|
139443
139475
|
filters,
|
|
139444
139476
|
attributeFilterConfigs: Object.keys(attributeFilterConfig ?? {}).length > 0 ? attributeFilterConfig : void 0
|
|
@@ -139610,20 +139642,20 @@ function createGeoAreaBuckets({ viewBy, metrics, segmentBy }) {
|
|
|
139610
139642
|
}
|
|
139611
139643
|
function yamlLayersToDeclarative(entities, input, _positions) {
|
|
139612
139644
|
if (!("layers" in input) || !Array.isArray(input.layers) || input.layers.length === 0) return [];
|
|
139613
|
-
|
|
139645
|
+
const layers = input.layers;
|
|
139646
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
139647
|
+
for (const { id } of layers) {
|
|
139648
|
+
if (claimed.has(id)) throw newError("core.duplicateLayerIdentifier", [id]);
|
|
139649
|
+
claimed.add(id);
|
|
139650
|
+
}
|
|
139651
|
+
return layers.map((layer) => {
|
|
139614
139652
|
if (layer.type !== "pushpin" && layer.type !== "area") throw newError("core.layerTypeNotSupported", [layer.type ?? "<missing>"]);
|
|
139615
139653
|
const layerVisualizationType = layer.type === "pushpin" ? "geo_chart" : "geo_area_chart";
|
|
139616
|
-
const baseQuery = layer.query;
|
|
139617
139654
|
const resolvedQuery = {
|
|
139618
139655
|
...input.query,
|
|
139619
|
-
|
|
139620
|
-
fields: {
|
|
139621
|
-
...input.query?.fields ?? {},
|
|
139622
|
-
...baseQuery?.fields ?? {}
|
|
139623
|
-
}
|
|
139656
|
+
fields: input.query?.fields ?? {}
|
|
139624
139657
|
};
|
|
139625
139658
|
const positions = [];
|
|
139626
|
-
let attrFilterConfig = {};
|
|
139627
139659
|
const buckets = (layer.type === "pushpin" ? createPushpinBuckets({
|
|
139628
139660
|
viewBy: layer.view_by,
|
|
139629
139661
|
metrics: layer.metrics,
|
|
@@ -139639,22 +139671,17 @@ function yamlLayersToDeclarative(entities, input, _positions) {
|
|
|
139639
139671
|
return {
|
|
139640
139672
|
localIdentifier,
|
|
139641
139673
|
items: bucket.items.map((item) => {
|
|
139642
|
-
const { bucketItem, bucketTotals, longitude, latitude
|
|
139674
|
+
const { bucketItem, bucketTotals, longitude, latitude } = yamlBucketItemToDeclarative(entities, resolvedQuery, item, resolvedQuery.fields || {}, localIdentifier);
|
|
139643
139675
|
if (longitude && latitude) positions.push({
|
|
139644
139676
|
longitude,
|
|
139645
139677
|
latitude
|
|
139646
139678
|
});
|
|
139647
|
-
if (filterConfig) attrFilterConfig = {
|
|
139648
|
-
...attrFilterConfig,
|
|
139649
|
-
...filterConfig
|
|
139650
|
-
};
|
|
139651
139679
|
bucketTotals.forEach((total) => totals.push(total));
|
|
139652
139680
|
return bucketItem;
|
|
139653
139681
|
}).filter(Boolean),
|
|
139654
139682
|
totals
|
|
139655
139683
|
};
|
|
139656
139684
|
}).filter(Boolean);
|
|
139657
|
-
const { filters: layerFilters, attributeFilterConfigs } = yamlFiltersToDeclarative(entities, baseQuery?.filter_by, attrFilterConfig, true);
|
|
139658
139685
|
const layerProperties = layer.config || layer.type === "pushpin" && positions.length > 0 ? yamlConfigToDeclarative({
|
|
139659
139686
|
...input,
|
|
139660
139687
|
type: layerVisualizationType,
|
|
@@ -139669,9 +139696,6 @@ function yamlLayersToDeclarative(entities, input, _positions) {
|
|
|
139669
139696
|
name: layer.title,
|
|
139670
139697
|
type: layer.type,
|
|
139671
139698
|
buckets,
|
|
139672
|
-
filters: layerFilters,
|
|
139673
|
-
...attributeFilterConfigs ? { attributeFilterConfigs } : {},
|
|
139674
|
-
sorts: yamlSortsToDeclarative(baseQuery?.sort_by, baseQuery?.fields ?? resolvedQuery.fields ?? {}),
|
|
139675
139699
|
properties: layerProperties && Object.keys(layerProperties).length > 0 ? layerProperties : void 0
|
|
139676
139700
|
};
|
|
139677
139701
|
});
|
|
@@ -140785,6 +140809,374 @@ function declarativeMetricToYaml(metric) {
|
|
|
140785
140809
|
};
|
|
140786
140810
|
}
|
|
140787
140811
|
//#endregion
|
|
140812
|
+
//#region ../../../sdk/libs/sdk-code-convertors/src/from/filtersToYaml.ts
|
|
140813
|
+
function detectEmptyValuesFilterType(filter) {
|
|
140814
|
+
const attributeElements = filterAttributeElements(filter);
|
|
140815
|
+
const items = attributeElements ? getAttributeElementsItems(attributeElements) : [];
|
|
140816
|
+
if (items.length !== 1 || items[0] !== "") return;
|
|
140817
|
+
return isPositiveAttributeFilter$1(filter) ? "only" : "exclude";
|
|
140818
|
+
}
|
|
140819
|
+
function getObjRefGroupingKey(objRef) {
|
|
140820
|
+
if (!objRef || typeof objRef !== "object") return;
|
|
140821
|
+
if ("identifier" in objRef) {
|
|
140822
|
+
const identifier = objRef.identifier;
|
|
140823
|
+
if (typeof identifier === "string") return identifier;
|
|
140824
|
+
if (identifier && typeof identifier === "object" && "id" in identifier) {
|
|
140825
|
+
const id = identifier.id;
|
|
140826
|
+
if (typeof id === "string") return id;
|
|
140827
|
+
}
|
|
140828
|
+
}
|
|
140829
|
+
if ("uri" in objRef) {
|
|
140830
|
+
const uri = objRef.uri;
|
|
140831
|
+
if (typeof uri === "string") return uri;
|
|
140832
|
+
}
|
|
140833
|
+
if ("localIdentifier" in objRef) {
|
|
140834
|
+
const localIdentifier = objRef.localIdentifier;
|
|
140835
|
+
if (typeof localIdentifier === "string") return localIdentifier;
|
|
140836
|
+
}
|
|
140837
|
+
return serializeObjRef(objRef);
|
|
140838
|
+
}
|
|
140839
|
+
/**
|
|
140840
|
+
* Groups date filters with their associated attribute filters. Leaves the rest alone.
|
|
140841
|
+
*/
|
|
140842
|
+
function groupFiltersByDateFilter(filters) {
|
|
140843
|
+
const dateFilters = [...filters].filter(isDateFilter$1);
|
|
140844
|
+
const nonDateFilters = [...filters].filter((f) => !isDateFilter$1(f));
|
|
140845
|
+
const result = {
|
|
140846
|
+
grouped: {},
|
|
140847
|
+
rest: []
|
|
140848
|
+
};
|
|
140849
|
+
const getFilterRefDetails = (filter) => {
|
|
140850
|
+
const objRef = filterObjRef(filter);
|
|
140851
|
+
if (!objRef) return {
|
|
140852
|
+
objRef: void 0,
|
|
140853
|
+
filterRef: void 0
|
|
140854
|
+
};
|
|
140855
|
+
return {
|
|
140856
|
+
objRef,
|
|
140857
|
+
filterRef: getObjRefGroupingKey(objRef)
|
|
140858
|
+
};
|
|
140859
|
+
};
|
|
140860
|
+
dateFilters.forEach((dateFilter) => {
|
|
140861
|
+
const { filterRef: datasetId } = getFilterRefDetails(dateFilter);
|
|
140862
|
+
const fi = filters.indexOf(dateFilter);
|
|
140863
|
+
if (datasetId === void 0) {
|
|
140864
|
+
result.rest.push([dateFilter, fi]);
|
|
140865
|
+
return;
|
|
140866
|
+
}
|
|
140867
|
+
if (result.grouped[datasetId]) result.rest.push([dateFilter, fi]);
|
|
140868
|
+
else result.grouped[datasetId] = {
|
|
140869
|
+
dateFilter: [dateFilter, fi],
|
|
140870
|
+
attributeFilters: []
|
|
140871
|
+
};
|
|
140872
|
+
});
|
|
140873
|
+
nonDateFilters.forEach((filter) => {
|
|
140874
|
+
const { filterRef: filterId } = getFilterRefDetails(filter);
|
|
140875
|
+
const fi = filters.indexOf(filter);
|
|
140876
|
+
if (filterId === void 0) {
|
|
140877
|
+
result.rest.push([filter, fi]);
|
|
140878
|
+
return;
|
|
140879
|
+
}
|
|
140880
|
+
const datasetId = filterId.split(".")[0];
|
|
140881
|
+
const group = result.grouped[datasetId];
|
|
140882
|
+
if (group) group.attributeFilters.push([filter, fi]);
|
|
140883
|
+
else result.rest.push([filter, fi]);
|
|
140884
|
+
});
|
|
140885
|
+
return result;
|
|
140886
|
+
}
|
|
140887
|
+
/** @internal */
|
|
140888
|
+
function declarativeFiltersToYaml(entities, filters, errorContext) {
|
|
140889
|
+
const filtersArray = [];
|
|
140890
|
+
const filtersMap = {};
|
|
140891
|
+
const usedKeys = /* @__PURE__ */ new Set();
|
|
140892
|
+
const claimKey = (baseKey) => {
|
|
140893
|
+
let key = baseKey;
|
|
140894
|
+
let suffix = 2;
|
|
140895
|
+
while (usedKeys.has(key)) {
|
|
140896
|
+
key = `${baseKey}_${suffix}`;
|
|
140897
|
+
suffix += 1;
|
|
140898
|
+
}
|
|
140899
|
+
usedKeys.add(key);
|
|
140900
|
+
return key;
|
|
140901
|
+
};
|
|
140902
|
+
const fold = ({ carried = [], ...written }) => {
|
|
140903
|
+
filtersArray.push(new import_dist.Pair(written.key, written.yaml));
|
|
140904
|
+
[written, ...carried].forEach(({ key, yaml, filter }) => {
|
|
140905
|
+
filtersMap[key] = {
|
|
140906
|
+
yaml,
|
|
140907
|
+
filter
|
|
140908
|
+
};
|
|
140909
|
+
});
|
|
140910
|
+
};
|
|
140911
|
+
const filtersGroupedByDateFilter = groupFiltersByDateFilter(filters);
|
|
140912
|
+
filtersGroupedByDateFilter.rest.forEach(([filter, fi]) => {
|
|
140913
|
+
const result = declarativeFilterToYaml(entities, filter, claimKey, void 0, updateErrorContext(errorContext, { path: [fi.toString()] }));
|
|
140914
|
+
if (!result) return;
|
|
140915
|
+
fold(result);
|
|
140916
|
+
});
|
|
140917
|
+
Object.values(filtersGroupedByDateFilter.grouped).forEach(({ dateFilter, attributeFilters }) => {
|
|
140918
|
+
const result = declarativeFilterToYaml(entities, dateFilter[0], claimKey, attributeFilters.map(([f]) => f), updateErrorContext(errorContext, { path: [dateFilter[1].toString()] }));
|
|
140919
|
+
if (!result) return;
|
|
140920
|
+
fold(result);
|
|
140921
|
+
});
|
|
140922
|
+
return {
|
|
140923
|
+
filtersMap,
|
|
140924
|
+
filtersArray: filtersArray.reduce((map, filter) => {
|
|
140925
|
+
map.add(filter);
|
|
140926
|
+
return map;
|
|
140927
|
+
}, new import_dist.YAMLMap())
|
|
140928
|
+
};
|
|
140929
|
+
}
|
|
140930
|
+
function declarativeFilterToYaml(entities, filter, claimKey, connectedAttributeFilters, errorContext) {
|
|
140931
|
+
if (!isFilter(filter)) return null;
|
|
140932
|
+
const key = claimKey(createFilterItemKeyName(filter, "date", updateErrorContext(errorContext, { path: ["date"] })));
|
|
140933
|
+
if (isAbsoluteDateFilter$1(filter)) {
|
|
140934
|
+
const { yaml, carried } = declarativeAbsoluteDateFilterToYaml(filter.absoluteDateFilter, {
|
|
140935
|
+
entities,
|
|
140936
|
+
claimKey,
|
|
140937
|
+
connectedAttributeFilters,
|
|
140938
|
+
errorContext: updateErrorContext(errorContext, { path: ["absoluteDateFilter"] })
|
|
140939
|
+
});
|
|
140940
|
+
return {
|
|
140941
|
+
key,
|
|
140942
|
+
yaml,
|
|
140943
|
+
filter,
|
|
140944
|
+
carried
|
|
140945
|
+
};
|
|
140946
|
+
}
|
|
140947
|
+
if (isRelativeDateFilter$1(filter)) {
|
|
140948
|
+
const { yaml, carried } = declarativeRelativeDateFilterToYaml(filter.relativeDateFilter, {
|
|
140949
|
+
entities,
|
|
140950
|
+
claimKey,
|
|
140951
|
+
connectedAttributeFilters,
|
|
140952
|
+
errorContext: updateErrorContext(errorContext, { path: ["relativeDateFilter"] })
|
|
140953
|
+
});
|
|
140954
|
+
return {
|
|
140955
|
+
key,
|
|
140956
|
+
yaml,
|
|
140957
|
+
filter,
|
|
140958
|
+
carried
|
|
140959
|
+
};
|
|
140960
|
+
}
|
|
140961
|
+
if (isPositiveAttributeFilter$1(filter)) return {
|
|
140962
|
+
key,
|
|
140963
|
+
yaml: declarativePositiveAttributeFilterToYaml(entities, filter.positiveAttributeFilter, updateErrorContext(errorContext, { path: ["positiveAttributeFilter"] })),
|
|
140964
|
+
filter
|
|
140965
|
+
};
|
|
140966
|
+
if (isNegativeAttributeFilter$1(filter)) return {
|
|
140967
|
+
key,
|
|
140968
|
+
yaml: declarativeNegativeAttributeFilterToYaml(entities, filter.negativeAttributeFilter, updateErrorContext(errorContext, { path: ["negativeAttributeFilter"] })),
|
|
140969
|
+
filter
|
|
140970
|
+
};
|
|
140971
|
+
if (isArbitraryAttributeFilter(filter)) return {
|
|
140972
|
+
key,
|
|
140973
|
+
yaml: declarativeArbitraryAttributeFilterToYaml(filter.arbitraryAttributeFilter, updateErrorContext(errorContext, { path: ["arbitraryAttributeFilter"] })),
|
|
140974
|
+
filter
|
|
140975
|
+
};
|
|
140976
|
+
if (isMatchAttributeFilter(filter)) return {
|
|
140977
|
+
key,
|
|
140978
|
+
yaml: declarativeMatchAttributeFilterToYaml(filter.matchAttributeFilter, updateErrorContext(errorContext, { path: ["matchAttributeFilter"] })),
|
|
140979
|
+
filter
|
|
140980
|
+
};
|
|
140981
|
+
if (isMeasureValueFilter(filter)) return {
|
|
140982
|
+
key,
|
|
140983
|
+
yaml: declarativeMeasureValueFilterToYaml$1(filter.measureValueFilter, updateErrorContext(errorContext, { path: ["measureValueFilter"] })),
|
|
140984
|
+
filter
|
|
140985
|
+
};
|
|
140986
|
+
if (isRankingFilter$1(filter)) return {
|
|
140987
|
+
key,
|
|
140988
|
+
yaml: declarativeRankingFilterToYaml(filter.rankingFilter, updateErrorContext(errorContext, { path: ["rankingFilter"] })),
|
|
140989
|
+
filter
|
|
140990
|
+
};
|
|
140991
|
+
throw newError("core.filterItemTypeNotSupported", [JSON.stringify(filter)], errorContext);
|
|
140992
|
+
}
|
|
140993
|
+
/** Adds `empty_values` and `with` to `map`, returning the filters written under the latter. */
|
|
140994
|
+
function processConnectedAttributeFilters(map, connectedAttributeFilters, entities, claimKey, errorContext) {
|
|
140995
|
+
const emptyValuesFilter = connectedAttributeFilters.find((filter) => detectEmptyValuesFilterType(filter));
|
|
140996
|
+
if (emptyValuesFilter) map.add(new import_dist.Pair("empty_values", detectEmptyValuesFilterType(emptyValuesFilter)));
|
|
140997
|
+
const additionalAttributeFilters = connectedAttributeFilters.filter((filter) => filter !== emptyValuesFilter);
|
|
140998
|
+
if (additionalAttributeFilters.length === 0) return [];
|
|
140999
|
+
const withMap = new import_dist.YAMLMap();
|
|
141000
|
+
map.add(new import_dist.Pair("with", withMap));
|
|
141001
|
+
return additionalAttributeFilters.flatMap((filter) => {
|
|
141002
|
+
const written = declarativeFilterToYaml(entities, filter, claimKey, void 0, errorContext);
|
|
141003
|
+
if (!written) return [];
|
|
141004
|
+
withMap.add(new import_dist.Pair(written.key, written.yaml));
|
|
141005
|
+
return [written, ...written.carried ?? []];
|
|
141006
|
+
});
|
|
141007
|
+
}
|
|
141008
|
+
/** @internal */
|
|
141009
|
+
function declarativeAbsoluteDateFilterToYaml(absoluteDateFilter, { entities, claimKey, connectedAttributeFilters = [], errorContext }) {
|
|
141010
|
+
const map = new import_dist.YAMLMap();
|
|
141011
|
+
map.add(new import_dist.Pair("type", "date_filter"));
|
|
141012
|
+
map.add(new import_dist.Pair("from", absoluteDateFilter.from));
|
|
141013
|
+
map.add(new import_dist.Pair("to", absoluteDateFilter.to));
|
|
141014
|
+
const id = getIdentifier(absoluteDateFilter.dataSet, true, updateErrorContext(errorContext, { path: ["dateSet"] }));
|
|
141015
|
+
map.add(new import_dist.Pair("using", id));
|
|
141016
|
+
return {
|
|
141017
|
+
yaml: map,
|
|
141018
|
+
carried: processConnectedAttributeFilters(map, connectedAttributeFilters, entities, claimKey, errorContext)
|
|
141019
|
+
};
|
|
141020
|
+
}
|
|
141021
|
+
function isRelativeDateFilterAllTime(relativeDateFilter) {
|
|
141022
|
+
const { granularity, from, to } = relativeDateFilter;
|
|
141023
|
+
if (granularity === "ALL_TIME_GRANULARITY") return true;
|
|
141024
|
+
return granularity === "GDC.time.year" && from === void 0 && to === void 0;
|
|
141025
|
+
}
|
|
141026
|
+
/** @internal */
|
|
141027
|
+
function declarativeRelativeDateFilterToYaml(relativeDateFilter, { entities, claimKey, connectedAttributeFilters = [], errorContext }) {
|
|
141028
|
+
const map = new import_dist.YAMLMap();
|
|
141029
|
+
map.add(new import_dist.Pair("type", "date_filter"));
|
|
141030
|
+
if (isRelativeDateFilterAllTime(relativeDateFilter)) {} else {
|
|
141031
|
+
if (relativeDateFilter.granularity) map.add(new import_dist.Pair("granularity", parseGranularity(relativeDateFilter.granularity)));
|
|
141032
|
+
if (relativeDateFilter.from !== void 0 && relativeDateFilter.to !== void 0) {
|
|
141033
|
+
map.add(new import_dist.Pair("from", relativeDateFilter.from));
|
|
141034
|
+
map.add(new import_dist.Pair("to", relativeDateFilter.to));
|
|
141035
|
+
}
|
|
141036
|
+
}
|
|
141037
|
+
const id = getIdentifier(relativeDateFilter.dataSet, true, updateErrorContext(errorContext, { path: ["dataSet"] }));
|
|
141038
|
+
map.add(new import_dist.Pair("using", id));
|
|
141039
|
+
return {
|
|
141040
|
+
yaml: map,
|
|
141041
|
+
carried: processConnectedAttributeFilters(map, connectedAttributeFilters, entities, claimKey, errorContext)
|
|
141042
|
+
};
|
|
141043
|
+
}
|
|
141044
|
+
/**
|
|
141045
|
+
* A selection given by uri has no form here: written without any `state` it reads back as listing none,
|
|
141046
|
+
* which an attribute filter takes to mean every element.
|
|
141047
|
+
*/
|
|
141048
|
+
function attributeElementValues(elements, field, errorContext) {
|
|
141049
|
+
if (!isAttributeElementsByValue(elements)) throw newError("core.itemNotSupported", ["attribute elements not given by value"], updateErrorContext(errorContext, { path: [field] }));
|
|
141050
|
+
return elements.values.filter((v) => v !== null && v !== void 0);
|
|
141051
|
+
}
|
|
141052
|
+
/** @internal */
|
|
141053
|
+
function declarativePositiveAttributeFilterToYaml(entities, attributeFilter, errorContext) {
|
|
141054
|
+
const map = new import_dist.YAMLMap();
|
|
141055
|
+
map.add(new import_dist.Pair("type", "attribute_filter"));
|
|
141056
|
+
const id = getIdentifier(attributeFilter.displayForm, void 0, updateErrorContext(errorContext, { path: ["displayForm"] }));
|
|
141057
|
+
map.add(new import_dist.Pair("using", id));
|
|
141058
|
+
const values = attributeElementValues(attributeFilter.in, "in", errorContext);
|
|
141059
|
+
map.add(new import_dist.Pair("state", new import_dist.Pair("include", parseDateValues(entities, id, values))));
|
|
141060
|
+
return map;
|
|
141061
|
+
}
|
|
141062
|
+
/** @internal */
|
|
141063
|
+
function declarativeNegativeAttributeFilterToYaml(entities, attributeFilter, errorContext) {
|
|
141064
|
+
const map = new import_dist.YAMLMap();
|
|
141065
|
+
map.add(new import_dist.Pair("type", "attribute_filter"));
|
|
141066
|
+
const id = getIdentifier(attributeFilter.displayForm, void 0, updateErrorContext(errorContext, { path: ["displayForm"] }));
|
|
141067
|
+
map.add(new import_dist.Pair("using", id));
|
|
141068
|
+
const values = isAttributeElementsByRef(attributeFilter.notIn) && attributeFilter.notIn.uris.length === 0 ? [] : attributeElementValues(attributeFilter.notIn, "notIn", errorContext);
|
|
141069
|
+
if (values.length > 0) map.add(new import_dist.Pair("state", new import_dist.Pair("exclude", parseDateValues(entities, id, values))));
|
|
141070
|
+
return map;
|
|
141071
|
+
}
|
|
141072
|
+
function declarativeArbitraryAttributeFilterToYaml(attributeFilter, errorContext) {
|
|
141073
|
+
const map = new import_dist.YAMLMap();
|
|
141074
|
+
map.add(new import_dist.Pair("type", "text_filter"));
|
|
141075
|
+
map.add(new import_dist.Pair("using", getIdentifier(attributeFilter.label, void 0, updateErrorContext(errorContext, { path: ["label"] }))));
|
|
141076
|
+
map.add(new import_dist.Pair("condition", attributeFilter.negativeSelection ? "isNot" : "is"));
|
|
141077
|
+
map.add(new import_dist.Pair("values", attributeFilter.values));
|
|
141078
|
+
return map;
|
|
141079
|
+
}
|
|
141080
|
+
function declarativeMatchAttributeFilterToYaml(attributeFilter, errorContext) {
|
|
141081
|
+
const map = new import_dist.YAMLMap();
|
|
141082
|
+
map.add(new import_dist.Pair("type", "text_filter"));
|
|
141083
|
+
map.add(new import_dist.Pair("using", getIdentifier(attributeFilter.label, void 0, updateErrorContext(errorContext, { path: ["label"] }))));
|
|
141084
|
+
map.add(new import_dist.Pair("condition", matchConditionToYaml(attributeFilter.operator, attributeFilter.negativeSelection)));
|
|
141085
|
+
map.add(new import_dist.Pair("value", attributeFilter.literal));
|
|
141086
|
+
if (attributeFilter.caseSensitive !== void 0) map.add(new import_dist.Pair("case_sensitive", attributeFilter.caseSensitive));
|
|
141087
|
+
return map;
|
|
141088
|
+
}
|
|
141089
|
+
function asCompoundCondition(condition) {
|
|
141090
|
+
const { compound } = condition;
|
|
141091
|
+
return Array.isArray(compound?.conditions) ? compound : null;
|
|
141092
|
+
}
|
|
141093
|
+
function addConditionsToYaml(map, conditions, options) {
|
|
141094
|
+
const { nullsCountAsZero, errorContext } = options;
|
|
141095
|
+
const conditionsSeq = new import_dist.YAMLSeq();
|
|
141096
|
+
let treatNullValuesAsZero = nullsCountAsZero;
|
|
141097
|
+
conditions.forEach((condition) => {
|
|
141098
|
+
const conditionMap = new import_dist.YAMLMap();
|
|
141099
|
+
if (addConditionToYamlMap(conditionMap, condition, errorContext)) treatNullValuesAsZero = true;
|
|
141100
|
+
conditionsSeq.add(conditionMap);
|
|
141101
|
+
});
|
|
141102
|
+
map.add(new import_dist.Pair("conditions", conditionsSeq));
|
|
141103
|
+
if (treatNullValuesAsZero) map.add(new import_dist.Pair("null_values_as_zero", true));
|
|
141104
|
+
}
|
|
141105
|
+
/** Nulls are recorded only as counting for zero or not, so any other stand-in has no form here. */
|
|
141106
|
+
function assertNullsCountAsZero(treatNullValuesAs, errorContext) {
|
|
141107
|
+
if (treatNullValuesAs !== void 0 && treatNullValuesAs !== 0) throw newError("core.itemNotSupported", [`null values treated as ${treatNullValuesAs}`], updateErrorContext(errorContext, { path: ["treatNullValuesAs"] }));
|
|
141108
|
+
}
|
|
141109
|
+
function addSingleConditionToYaml(map, condition, errorContext) {
|
|
141110
|
+
const nullsCountAsZero = addConditionToYamlMap(map, condition, errorContext);
|
|
141111
|
+
map.add(new import_dist.Pair("null_values_as_zero", nullsCountAsZero));
|
|
141112
|
+
}
|
|
141113
|
+
function addConditionToYamlMap(conditionMap, condition, errorContext) {
|
|
141114
|
+
let hasTreatNullValues = false;
|
|
141115
|
+
if (isComparisonCondition(condition)) {
|
|
141116
|
+
const comp = condition.comparison;
|
|
141117
|
+
assertNullsCountAsZero(comp.treatNullValuesAs, errorContext);
|
|
141118
|
+
conditionMap.add(new import_dist.Pair("condition", comp.operator.toUpperCase()));
|
|
141119
|
+
conditionMap.add(new import_dist.Pair("value", comp.value));
|
|
141120
|
+
if (comp.treatNullValuesAs !== void 0) hasTreatNullValues = true;
|
|
141121
|
+
} else if (isRangeCondition(condition)) {
|
|
141122
|
+
const range = condition.range;
|
|
141123
|
+
assertNullsCountAsZero(range.treatNullValuesAs, errorContext);
|
|
141124
|
+
conditionMap.add(new import_dist.Pair("condition", range.operator.toUpperCase()));
|
|
141125
|
+
conditionMap.add(new import_dist.Pair("from", range.from));
|
|
141126
|
+
conditionMap.add(new import_dist.Pair("to", range.to));
|
|
141127
|
+
if (range.treatNullValuesAs !== void 0) hasTreatNullValues = true;
|
|
141128
|
+
} else throw newError("core.itemNotSupported", [`condition ${JSON.stringify(condition)}`], errorContext);
|
|
141129
|
+
return hasTreatNullValues;
|
|
141130
|
+
}
|
|
141131
|
+
/** @internal */
|
|
141132
|
+
function declarativeMeasureValueFilterToYaml$1(measureValueFilter, errorContext) {
|
|
141133
|
+
const map = new import_dist.YAMLMap();
|
|
141134
|
+
map.add(new import_dist.Pair("type", "metric_value_filter"));
|
|
141135
|
+
if (isLocalIdRef(measureValueFilter.measure)) map.add(new import_dist.Pair("using", measureValueFilter.measure.localIdentifier));
|
|
141136
|
+
else map.add(new import_dist.Pair("using", getIdentifier(measureValueFilter.measure, void 0, updateErrorContext(errorContext, { path: ["measure"] }))));
|
|
141137
|
+
const conditionContext = updateErrorContext(errorContext, { path: ["condition"] });
|
|
141138
|
+
const compound = measureValueFilter.condition ? asCompoundCondition(measureValueFilter.condition) : null;
|
|
141139
|
+
if (compound) {
|
|
141140
|
+
assertNullsCountAsZero(compound.treatNullValuesAs, conditionContext);
|
|
141141
|
+
if (compound.conditions.length > 0) addConditionsToYaml(map, compound.conditions, {
|
|
141142
|
+
nullsCountAsZero: compound.treatNullValuesAs !== void 0,
|
|
141143
|
+
errorContext: conditionContext
|
|
141144
|
+
});
|
|
141145
|
+
} else if (measureValueFilter.conditions && measureValueFilter.conditions.length > 1) addConditionsToYaml(map, measureValueFilter.conditions, {
|
|
141146
|
+
nullsCountAsZero: false,
|
|
141147
|
+
errorContext: conditionContext
|
|
141148
|
+
});
|
|
141149
|
+
else if (measureValueFilter.conditions?.length === 1) addSingleConditionToYaml(map, measureValueFilter.conditions[0], conditionContext);
|
|
141150
|
+
else if (measureValueFilter.condition) addSingleConditionToYaml(map, measureValueFilter.condition, conditionContext);
|
|
141151
|
+
if (measureValueFilter.dimensionality && Array.isArray(measureValueFilter.dimensionality)) {
|
|
141152
|
+
const dimensionalitySeq = new import_dist.YAMLSeq();
|
|
141153
|
+
measureValueFilter.dimensionality.forEach((item) => {
|
|
141154
|
+
if (isLocalIdRef(item)) dimensionalitySeq.add(item.localIdentifier);
|
|
141155
|
+
else dimensionalitySeq.add(getIdentifier(item));
|
|
141156
|
+
});
|
|
141157
|
+
map.add(new import_dist.Pair("dimensionality", dimensionalitySeq));
|
|
141158
|
+
}
|
|
141159
|
+
return map;
|
|
141160
|
+
}
|
|
141161
|
+
/** @internal */
|
|
141162
|
+
function declarativeRankingFilterToYaml(rankingFilter, errorContext) {
|
|
141163
|
+
const map = new import_dist.YAMLMap();
|
|
141164
|
+
map.add(new import_dist.Pair("type", "ranking_filter"));
|
|
141165
|
+
if (isLocalIdRef(rankingFilter.measure)) map.add(new import_dist.Pair("using", rankingFilter.measure.localIdentifier));
|
|
141166
|
+
else map.add(new import_dist.Pair("using", getIdentifier(rankingFilter.measure, void 0, updateErrorContext(errorContext, { path: ["measure"] }))));
|
|
141167
|
+
if (rankingFilter.operator === "TOP") map.add(new import_dist.Pair("top", rankingFilter.value));
|
|
141168
|
+
if (rankingFilter.operator === "BOTTOM") map.add(new import_dist.Pair("bottom", rankingFilter.value));
|
|
141169
|
+
const rankedBy = (rankingFilter.attributes ?? []).filter(Boolean);
|
|
141170
|
+
if (rankedBy.length > 1) throw newError("core.itemNotSupported", [`ranking over ${rankedBy.length} attributes`], updateErrorContext(errorContext, { path: ["attributes"] }));
|
|
141171
|
+
if (rankedBy[0]) {
|
|
141172
|
+
const first = rankedBy[0];
|
|
141173
|
+
if (isLocalIdRef(first)) map.add(new import_dist.Pair("attribute", first.localIdentifier));
|
|
141174
|
+
else map.add(new import_dist.Pair("attribute", getIdentifier(first)));
|
|
141175
|
+
}
|
|
141176
|
+
if (rankingFilter.strictLimitOfRows !== void 0) map.add(new import_dist.Pair("strict_limit_of_rows", rankingFilter.strictLimitOfRows));
|
|
141177
|
+
return map;
|
|
141178
|
+
}
|
|
141179
|
+
//#endregion
|
|
140788
141180
|
//#region ../../../sdk/libs/sdk-code-convertors/src/from/declarativeVisualisationToYaml.ts
|
|
140789
141181
|
/** @public */
|
|
140790
141182
|
function declarativeVisualisationToYaml(entities, visualisation, context) {
|
|
@@ -140807,11 +141199,31 @@ function declarativeVisualisationToYaml(entities, visualisation, context) {
|
|
|
140807
141199
|
const report = declarativeReportToYaml(entities, insight.insight, updateErrorContext(errorContext, { path: ["insight"] }));
|
|
140808
141200
|
doc.add(entryWithSpace("query", report.report));
|
|
140809
141201
|
declarativeVisToYaml(doc, insight.insight, report, entities, updateErrorContext(errorContext, { path: ["insight"] }));
|
|
141202
|
+
report.buckets.assertAllConsumed(errorContext);
|
|
141203
|
+
if ((insight.insight.layers ?? []).length > 0 && doc.get("layers") === void 0) throw newError("core.itemNotSupported", ["layers"], updateErrorContext(errorContext, { path: ["layers"] }));
|
|
140810
141204
|
return {
|
|
140811
141205
|
content: doc.toString({ lineWidth: 0 }),
|
|
140812
141206
|
json: doc.toJSON()
|
|
140813
141207
|
};
|
|
140814
141208
|
}
|
|
141209
|
+
/**
|
|
141210
|
+
* Every type reads the buckets it writes by looking them up, so one it never looks up is dropped whole,
|
|
141211
|
+
* taking its items with it.
|
|
141212
|
+
*/
|
|
141213
|
+
function bucketRegistry(groups) {
|
|
141214
|
+
const consumed = /* @__PURE__ */ new Set();
|
|
141215
|
+
return {
|
|
141216
|
+
consume(type) {
|
|
141217
|
+
const found = groups.find((group) => group.type === type);
|
|
141218
|
+
if (found) consumed.add(found);
|
|
141219
|
+
return found;
|
|
141220
|
+
},
|
|
141221
|
+
assertAllConsumed(errorContext) {
|
|
141222
|
+
const dropped = groups.find((group) => group.items.length > 0 && !consumed.has(group));
|
|
141223
|
+
if (dropped) throw newError("core.itemNotSupported", [`bucket "${dropped.type}"`], updateErrorContext(errorContext, { path: ["buckets", dropped.type] }));
|
|
141224
|
+
}
|
|
141225
|
+
};
|
|
141226
|
+
}
|
|
140815
141227
|
function declarativeReportToYaml(entities, def, errorContext) {
|
|
140816
141228
|
const report = new import_dist.YAMLMap();
|
|
140817
141229
|
const { fieldsMap, postProcessors, groups: derivedBuckets } = declarativeBucketsToYaml(entities, def.buckets, updateErrorContext(errorContext, { path: ["buckets"] }));
|
|
@@ -140829,7 +141241,7 @@ function declarativeReportToYaml(entities, def, errorContext) {
|
|
|
140829
141241
|
});
|
|
140830
141242
|
return {
|
|
140831
141243
|
report,
|
|
140832
|
-
derivedBuckets
|
|
141244
|
+
buckets: bucketRegistry(derivedBuckets)
|
|
140833
141245
|
};
|
|
140834
141246
|
}
|
|
140835
141247
|
function appendLayerFieldsToReport(fieldsMap, postProcessors, entities, layers, errorContext) {
|
|
@@ -140969,6 +141381,7 @@ function declarativeBucketsToYaml(entities, buckets, errorContext) {
|
|
|
140969
141381
|
const groups = [];
|
|
140970
141382
|
const postProcessors = { filters: [] };
|
|
140971
141383
|
const addField = (local, def, group, { format, axis } = {}) => {
|
|
141384
|
+
if (fullFieldsMap.has(local)) throw newError("core.duplicateFieldName", [local], errorContext);
|
|
140972
141385
|
fullFieldsMap.add(new import_dist.Pair(local, def));
|
|
140973
141386
|
group.items.push(createBucketGroupItem(local, format, axis));
|
|
140974
141387
|
};
|
|
@@ -141138,333 +141551,6 @@ function getShortenedBucket(def) {
|
|
|
141138
141551
|
}
|
|
141139
141552
|
return false;
|
|
141140
141553
|
}
|
|
141141
|
-
function detectEmptyValuesFilterType(filter) {
|
|
141142
|
-
const attributeElements = filterAttributeElements(filter);
|
|
141143
|
-
const items = attributeElements ? getAttributeElementsItems(attributeElements) : [];
|
|
141144
|
-
if (items.length !== 1 || items[0] !== "") return;
|
|
141145
|
-
return isPositiveAttributeFilter$1(filter) ? "only" : "exclude";
|
|
141146
|
-
}
|
|
141147
|
-
function getObjRefGroupingKey(objRef) {
|
|
141148
|
-
if (!objRef || typeof objRef !== "object") return;
|
|
141149
|
-
if ("identifier" in objRef) {
|
|
141150
|
-
const identifier = objRef.identifier;
|
|
141151
|
-
if (typeof identifier === "string") return identifier;
|
|
141152
|
-
if (identifier && typeof identifier === "object" && "id" in identifier) {
|
|
141153
|
-
const id = identifier.id;
|
|
141154
|
-
if (typeof id === "string") return id;
|
|
141155
|
-
}
|
|
141156
|
-
}
|
|
141157
|
-
if ("uri" in objRef) {
|
|
141158
|
-
const uri = objRef.uri;
|
|
141159
|
-
if (typeof uri === "string") return uri;
|
|
141160
|
-
}
|
|
141161
|
-
if ("localIdentifier" in objRef) {
|
|
141162
|
-
const localIdentifier = objRef.localIdentifier;
|
|
141163
|
-
if (typeof localIdentifier === "string") return localIdentifier;
|
|
141164
|
-
}
|
|
141165
|
-
return serializeObjRef(objRef);
|
|
141166
|
-
}
|
|
141167
|
-
/**
|
|
141168
|
-
* Groups date filters with their associated attribute filters. Leaves the rest alone.
|
|
141169
|
-
* @param filters
|
|
141170
|
-
*/
|
|
141171
|
-
function groupFiltersByDateFilter(filters) {
|
|
141172
|
-
const dateFilters = [...filters].filter(isDateFilter$1);
|
|
141173
|
-
const nonDateFilters = [...filters].filter((f) => !isDateFilter$1(f));
|
|
141174
|
-
const result = {
|
|
141175
|
-
grouped: {},
|
|
141176
|
-
rest: []
|
|
141177
|
-
};
|
|
141178
|
-
const getFilterRefDetails = (filter) => {
|
|
141179
|
-
const objRef = filterObjRef(filter);
|
|
141180
|
-
if (!objRef) return {
|
|
141181
|
-
objRef: void 0,
|
|
141182
|
-
filterRef: void 0
|
|
141183
|
-
};
|
|
141184
|
-
return {
|
|
141185
|
-
objRef,
|
|
141186
|
-
filterRef: getObjRefGroupingKey(objRef)
|
|
141187
|
-
};
|
|
141188
|
-
};
|
|
141189
|
-
dateFilters.forEach((dateFilter) => {
|
|
141190
|
-
const { filterRef: datasetId } = getFilterRefDetails(dateFilter);
|
|
141191
|
-
const fi = filters.indexOf(dateFilter);
|
|
141192
|
-
if (datasetId === void 0) {
|
|
141193
|
-
result.rest.push([dateFilter, fi]);
|
|
141194
|
-
return;
|
|
141195
|
-
}
|
|
141196
|
-
if (result.grouped[datasetId]) result.rest.push([dateFilter, fi]);
|
|
141197
|
-
else result.grouped[datasetId] = {
|
|
141198
|
-
dateFilter: [dateFilter, fi],
|
|
141199
|
-
attributeFilters: []
|
|
141200
|
-
};
|
|
141201
|
-
});
|
|
141202
|
-
nonDateFilters.forEach((filter) => {
|
|
141203
|
-
const { filterRef: filterId } = getFilterRefDetails(filter);
|
|
141204
|
-
const fi = filters.indexOf(filter);
|
|
141205
|
-
if (filterId === void 0) {
|
|
141206
|
-
result.rest.push([filter, fi]);
|
|
141207
|
-
return;
|
|
141208
|
-
}
|
|
141209
|
-
const datasetId = filterId.split(".")[0];
|
|
141210
|
-
const group = result.grouped[datasetId];
|
|
141211
|
-
if (group) group.attributeFilters.push([filter, fi]);
|
|
141212
|
-
else result.rest.push([filter, fi]);
|
|
141213
|
-
});
|
|
141214
|
-
return result;
|
|
141215
|
-
}
|
|
141216
|
-
/** @internal */
|
|
141217
|
-
function declarativeFiltersToYaml(entities, filters, errorContext) {
|
|
141218
|
-
const filtersArray = [];
|
|
141219
|
-
const filtersMap = {};
|
|
141220
|
-
const usedKeys = /* @__PURE__ */ new Set();
|
|
141221
|
-
const getUniqueKey = (baseKey) => {
|
|
141222
|
-
let key = baseKey;
|
|
141223
|
-
let suffix = 2;
|
|
141224
|
-
while (usedKeys.has(key)) {
|
|
141225
|
-
key = `${baseKey}_${suffix}`;
|
|
141226
|
-
suffix += 1;
|
|
141227
|
-
}
|
|
141228
|
-
usedKeys.add(key);
|
|
141229
|
-
return key;
|
|
141230
|
-
};
|
|
141231
|
-
const filtersGroupedByDateFilter = groupFiltersByDateFilter(filters);
|
|
141232
|
-
filtersGroupedByDateFilter.rest.forEach(([filter, fi]) => {
|
|
141233
|
-
const result = declarativeFilterToYaml(entities, filter, getUniqueKey, void 0, updateErrorContext(errorContext, { path: [fi.toString()] }));
|
|
141234
|
-
if (!result) return;
|
|
141235
|
-
const { key, yaml, filter: originalFilter } = result;
|
|
141236
|
-
filtersArray.push(new import_dist.Pair(key, yaml));
|
|
141237
|
-
filtersMap[key] = {
|
|
141238
|
-
yaml,
|
|
141239
|
-
filter: originalFilter
|
|
141240
|
-
};
|
|
141241
|
-
});
|
|
141242
|
-
Object.values(filtersGroupedByDateFilter.grouped).forEach(({ dateFilter, attributeFilters }) => {
|
|
141243
|
-
const result = declarativeFilterToYaml(entities, dateFilter[0], getUniqueKey, attributeFilters.map(([f]) => f), updateErrorContext(errorContext, { path: [dateFilter[1].toString()] }));
|
|
141244
|
-
if (!result) return;
|
|
141245
|
-
const { key, yaml, filter: originalFilter } = result;
|
|
141246
|
-
filtersArray.push(new import_dist.Pair(key, yaml));
|
|
141247
|
-
filtersMap[key] = {
|
|
141248
|
-
yaml,
|
|
141249
|
-
filter: originalFilter
|
|
141250
|
-
};
|
|
141251
|
-
});
|
|
141252
|
-
return {
|
|
141253
|
-
filtersMap,
|
|
141254
|
-
filtersArray: filtersArray.reduce((map, filter) => {
|
|
141255
|
-
map.add(filter);
|
|
141256
|
-
return map;
|
|
141257
|
-
}, new import_dist.YAMLMap())
|
|
141258
|
-
};
|
|
141259
|
-
}
|
|
141260
|
-
function declarativeFilterToYaml(entities, filter, getUniqueKey, connectedAttributeFilters, errorContext) {
|
|
141261
|
-
if (!isFilter(filter)) return null;
|
|
141262
|
-
const key = getUniqueKey(createFilterItemKeyName(filter, "date", updateErrorContext(errorContext, { path: ["date"] })));
|
|
141263
|
-
if (isAbsoluteDateFilter$1(filter)) return {
|
|
141264
|
-
key,
|
|
141265
|
-
yaml: declarativeAbsoluteDateFilterToYaml(filter.absoluteDateFilter, connectedAttributeFilters, entities, getUniqueKey, updateErrorContext(errorContext, { path: ["absoluteDateFilter"] })),
|
|
141266
|
-
filter
|
|
141267
|
-
};
|
|
141268
|
-
if (isRelativeDateFilter$1(filter)) return {
|
|
141269
|
-
key,
|
|
141270
|
-
yaml: declarativeRelativeDateFilterToYaml(filter.relativeDateFilter, connectedAttributeFilters, entities, getUniqueKey, updateErrorContext(errorContext, { path: ["relativeDateFilter"] })),
|
|
141271
|
-
filter
|
|
141272
|
-
};
|
|
141273
|
-
if (isPositiveAttributeFilter$1(filter)) return {
|
|
141274
|
-
key,
|
|
141275
|
-
yaml: declarativePositiveAttributeFilterToYaml(entities, filter.positiveAttributeFilter, updateErrorContext(errorContext, { path: ["positiveAttributeFilter"] })),
|
|
141276
|
-
filter
|
|
141277
|
-
};
|
|
141278
|
-
if (isNegativeAttributeFilter$1(filter)) return {
|
|
141279
|
-
key,
|
|
141280
|
-
yaml: declarativeNegativeAttributeFilterToYaml(entities, filter.negativeAttributeFilter, updateErrorContext(errorContext, { path: ["negativeAttributeFilter"] })),
|
|
141281
|
-
filter
|
|
141282
|
-
};
|
|
141283
|
-
if (isArbitraryAttributeFilter(filter)) return {
|
|
141284
|
-
key,
|
|
141285
|
-
yaml: declarativeArbitraryAttributeFilterToYaml(filter.arbitraryAttributeFilter, updateErrorContext(errorContext, { path: ["arbitraryAttributeFilter"] })),
|
|
141286
|
-
filter
|
|
141287
|
-
};
|
|
141288
|
-
if (isMatchAttributeFilter(filter)) return {
|
|
141289
|
-
key,
|
|
141290
|
-
yaml: declarativeMatchAttributeFilterToYaml(filter.matchAttributeFilter, updateErrorContext(errorContext, { path: ["matchAttributeFilter"] })),
|
|
141291
|
-
filter
|
|
141292
|
-
};
|
|
141293
|
-
if (isMeasureValueFilter(filter)) return {
|
|
141294
|
-
key,
|
|
141295
|
-
yaml: declarativeMeasureValueFilterToYaml$1(filter.measureValueFilter, updateErrorContext(errorContext, { path: ["measureValueFilter"] })),
|
|
141296
|
-
filter
|
|
141297
|
-
};
|
|
141298
|
-
if (isRankingFilter$1(filter)) return {
|
|
141299
|
-
key,
|
|
141300
|
-
yaml: declarativeRankingFilterToYaml(filter.rankingFilter, updateErrorContext(errorContext, { path: ["rankingFilter"] })),
|
|
141301
|
-
filter
|
|
141302
|
-
};
|
|
141303
|
-
throw newError("core.filterItemTypeNotSupported", [JSON.stringify(filter)], errorContext);
|
|
141304
|
-
}
|
|
141305
|
-
/**
|
|
141306
|
-
* Modifies `map`, adding `empty_filters` and `with` keys, populated from connectedAttributeFilters.
|
|
141307
|
-
*/
|
|
141308
|
-
function processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey, errorContext) {
|
|
141309
|
-
const emptyValuesFilter = connectedAttributeFilters.find((filter) => detectEmptyValuesFilterType(filter));
|
|
141310
|
-
if (emptyValuesFilter) map.add(new import_dist.Pair("empty_values", detectEmptyValuesFilterType(emptyValuesFilter)));
|
|
141311
|
-
const additionalAttributeFilters = connectedAttributeFilters.filter((filter) => filter !== emptyValuesFilter);
|
|
141312
|
-
if (additionalAttributeFilters.length === 0) return;
|
|
141313
|
-
const withMap = new import_dist.YAMLMap();
|
|
141314
|
-
map.add(new import_dist.Pair("with", withMap));
|
|
141315
|
-
additionalAttributeFilters?.forEach((filter) => {
|
|
141316
|
-
const converted = declarativeFilterToYaml(entities, filter, getUniqueKey, void 0, errorContext);
|
|
141317
|
-
if (!converted) return;
|
|
141318
|
-
withMap.add(new import_dist.Pair(converted.key, converted.yaml));
|
|
141319
|
-
});
|
|
141320
|
-
}
|
|
141321
|
-
/** @internal */
|
|
141322
|
-
function declarativeAbsoluteDateFilterToYaml(absoluteDateFilter, connectedAttributeFilters = [], entities, getUniqueKey, errorContext) {
|
|
141323
|
-
const map = new import_dist.YAMLMap();
|
|
141324
|
-
map.add(new import_dist.Pair("type", "date_filter"));
|
|
141325
|
-
map.add(new import_dist.Pair("from", absoluteDateFilter.from));
|
|
141326
|
-
map.add(new import_dist.Pair("to", absoluteDateFilter.to));
|
|
141327
|
-
const id = getIdentifier(absoluteDateFilter.dataSet, true, updateErrorContext(errorContext, { path: ["dateSet"] }));
|
|
141328
|
-
map.add(new import_dist.Pair("using", id));
|
|
141329
|
-
processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey, errorContext);
|
|
141330
|
-
return map;
|
|
141331
|
-
}
|
|
141332
|
-
function isRelativeDateFilterAllTime(relativeDateFilter) {
|
|
141333
|
-
const { granularity, from, to } = relativeDateFilter;
|
|
141334
|
-
if (granularity === "ALL_TIME_GRANULARITY") return true;
|
|
141335
|
-
return granularity === "GDC.time.year" && from === void 0 && to === void 0;
|
|
141336
|
-
}
|
|
141337
|
-
/** @internal */
|
|
141338
|
-
function declarativeRelativeDateFilterToYaml(relativeDateFilter, connectedAttributeFilters = [], entities, getUniqueKey, errorContext) {
|
|
141339
|
-
const map = new import_dist.YAMLMap();
|
|
141340
|
-
map.add(new import_dist.Pair("type", "date_filter"));
|
|
141341
|
-
if (isRelativeDateFilterAllTime(relativeDateFilter)) {} else {
|
|
141342
|
-
if (relativeDateFilter.granularity) map.add(new import_dist.Pair("granularity", parseGranularity(relativeDateFilter.granularity)));
|
|
141343
|
-
if (relativeDateFilter.from !== void 0 && relativeDateFilter.to !== void 0) {
|
|
141344
|
-
map.add(new import_dist.Pair("from", relativeDateFilter.from));
|
|
141345
|
-
map.add(new import_dist.Pair("to", relativeDateFilter.to));
|
|
141346
|
-
}
|
|
141347
|
-
}
|
|
141348
|
-
const id = getIdentifier(relativeDateFilter.dataSet, true, updateErrorContext(errorContext, { path: ["dataSet"] }));
|
|
141349
|
-
map.add(new import_dist.Pair("using", id));
|
|
141350
|
-
processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey, errorContext);
|
|
141351
|
-
return map;
|
|
141352
|
-
}
|
|
141353
|
-
/** @internal */
|
|
141354
|
-
function declarativePositiveAttributeFilterToYaml(entities, attributeFilter, errorContext) {
|
|
141355
|
-
const map = new import_dist.YAMLMap();
|
|
141356
|
-
map.add(new import_dist.Pair("type", "attribute_filter"));
|
|
141357
|
-
const id = getIdentifier(attributeFilter.displayForm, void 0, updateErrorContext(errorContext, { path: ["displayForm"] }));
|
|
141358
|
-
map.add(new import_dist.Pair("using", id));
|
|
141359
|
-
if (isAttributeElementsByValue(attributeFilter.in)) {
|
|
141360
|
-
const values = attributeFilter.in.values.filter((v) => v !== null && v !== void 0);
|
|
141361
|
-
map.add(new import_dist.Pair("state", new import_dist.Pair("include", parseDateValues(entities, id, values))));
|
|
141362
|
-
}
|
|
141363
|
-
return map;
|
|
141364
|
-
}
|
|
141365
|
-
/** @internal */
|
|
141366
|
-
function declarativeNegativeAttributeFilterToYaml(entities, attributeFilter, errorContext) {
|
|
141367
|
-
const map = new import_dist.YAMLMap();
|
|
141368
|
-
map.add(new import_dist.Pair("type", "attribute_filter"));
|
|
141369
|
-
const id = getIdentifier(attributeFilter.displayForm, void 0, updateErrorContext(errorContext, { path: ["displayForm"] }));
|
|
141370
|
-
map.add(new import_dist.Pair("using", id));
|
|
141371
|
-
if (isAttributeElementsByValue(attributeFilter.notIn)) {
|
|
141372
|
-
const values = attributeFilter.notIn.values.filter((v) => v !== null && v !== void 0);
|
|
141373
|
-
if (values.length > 0) map.add(new import_dist.Pair("state", new import_dist.Pair("exclude", parseDateValues(entities, id, values))));
|
|
141374
|
-
}
|
|
141375
|
-
return map;
|
|
141376
|
-
}
|
|
141377
|
-
function declarativeArbitraryAttributeFilterToYaml(attributeFilter, errorContext) {
|
|
141378
|
-
const map = new import_dist.YAMLMap();
|
|
141379
|
-
map.add(new import_dist.Pair("type", "text_filter"));
|
|
141380
|
-
map.add(new import_dist.Pair("using", getIdentifier(attributeFilter.label, void 0, updateErrorContext(errorContext, { path: ["label"] }))));
|
|
141381
|
-
map.add(new import_dist.Pair("condition", attributeFilter.negativeSelection ? "isNot" : "is"));
|
|
141382
|
-
map.add(new import_dist.Pair("values", attributeFilter.values));
|
|
141383
|
-
return map;
|
|
141384
|
-
}
|
|
141385
|
-
function declarativeMatchAttributeFilterToYaml(attributeFilter, errorContext) {
|
|
141386
|
-
const map = new import_dist.YAMLMap();
|
|
141387
|
-
map.add(new import_dist.Pair("type", "text_filter"));
|
|
141388
|
-
map.add(new import_dist.Pair("using", getIdentifier(attributeFilter.label, void 0, updateErrorContext(errorContext, { path: ["label"] }))));
|
|
141389
|
-
map.add(new import_dist.Pair("condition", matchConditionToYaml(attributeFilter.operator, attributeFilter.negativeSelection)));
|
|
141390
|
-
map.add(new import_dist.Pair("value", attributeFilter.literal));
|
|
141391
|
-
if (attributeFilter.caseSensitive !== void 0) map.add(new import_dist.Pair("case_sensitive", attributeFilter.caseSensitive));
|
|
141392
|
-
return map;
|
|
141393
|
-
}
|
|
141394
|
-
function addSingleConditionToYaml(map, condition) {
|
|
141395
|
-
if (isComparisonCondition(condition)) {
|
|
141396
|
-
const comp = condition.comparison;
|
|
141397
|
-
map.add(new import_dist.Pair("condition", comp.operator.toUpperCase()));
|
|
141398
|
-
map.add(new import_dist.Pair("value", comp.value));
|
|
141399
|
-
map.add(new import_dist.Pair("null_values_as_zero", comp.treatNullValuesAs !== void 0));
|
|
141400
|
-
} else if (isRangeCondition(condition)) {
|
|
141401
|
-
const range = condition.range;
|
|
141402
|
-
map.add(new import_dist.Pair("condition", range.operator.toUpperCase()));
|
|
141403
|
-
map.add(new import_dist.Pair("from", range.from));
|
|
141404
|
-
map.add(new import_dist.Pair("to", range.to));
|
|
141405
|
-
map.add(new import_dist.Pair("null_values_as_zero", range.treatNullValuesAs !== void 0));
|
|
141406
|
-
}
|
|
141407
|
-
}
|
|
141408
|
-
function addConditionToYamlMap(conditionMap, condition) {
|
|
141409
|
-
let hasTreatNullValues = false;
|
|
141410
|
-
if (isComparisonCondition(condition)) {
|
|
141411
|
-
const comp = condition.comparison;
|
|
141412
|
-
conditionMap.add(new import_dist.Pair("condition", comp.operator.toUpperCase()));
|
|
141413
|
-
conditionMap.add(new import_dist.Pair("value", comp.value));
|
|
141414
|
-
if (comp.treatNullValuesAs !== void 0) hasTreatNullValues = true;
|
|
141415
|
-
} else if (isRangeCondition(condition)) {
|
|
141416
|
-
const range = condition.range;
|
|
141417
|
-
conditionMap.add(new import_dist.Pair("condition", range.operator.toUpperCase()));
|
|
141418
|
-
conditionMap.add(new import_dist.Pair("from", range.from));
|
|
141419
|
-
conditionMap.add(new import_dist.Pair("to", range.to));
|
|
141420
|
-
if (range.treatNullValuesAs !== void 0) hasTreatNullValues = true;
|
|
141421
|
-
}
|
|
141422
|
-
return hasTreatNullValues;
|
|
141423
|
-
}
|
|
141424
|
-
/** @internal */
|
|
141425
|
-
function declarativeMeasureValueFilterToYaml$1(measureValueFilter, errorContext) {
|
|
141426
|
-
const map = new import_dist.YAMLMap();
|
|
141427
|
-
map.add(new import_dist.Pair("type", "metric_value_filter"));
|
|
141428
|
-
if (isLocalIdRef(measureValueFilter.measure)) map.add(new import_dist.Pair("using", measureValueFilter.measure.localIdentifier));
|
|
141429
|
-
else map.add(new import_dist.Pair("using", getIdentifier(measureValueFilter.measure, void 0, updateErrorContext(errorContext, { path: ["measure"] }))));
|
|
141430
|
-
if (measureValueFilter.conditions && measureValueFilter.conditions.length > 1) {
|
|
141431
|
-
const conditionsSeq = new import_dist.YAMLSeq();
|
|
141432
|
-
let treatNullValuesAsZero = false;
|
|
141433
|
-
measureValueFilter.conditions.forEach((cond) => {
|
|
141434
|
-
const conditionMap = new import_dist.YAMLMap();
|
|
141435
|
-
if (addConditionToYamlMap(conditionMap, cond)) treatNullValuesAsZero = true;
|
|
141436
|
-
conditionsSeq.add(conditionMap);
|
|
141437
|
-
});
|
|
141438
|
-
map.add(new import_dist.Pair("conditions", conditionsSeq));
|
|
141439
|
-
if (treatNullValuesAsZero) map.add(new import_dist.Pair("null_values_as_zero", true));
|
|
141440
|
-
} else if (measureValueFilter.conditions?.length === 1) addSingleConditionToYaml(map, measureValueFilter.conditions[0]);
|
|
141441
|
-
else if (measureValueFilter.condition) addSingleConditionToYaml(map, measureValueFilter.condition);
|
|
141442
|
-
if (measureValueFilter.dimensionality && Array.isArray(measureValueFilter.dimensionality)) {
|
|
141443
|
-
const dimensionalitySeq = new import_dist.YAMLSeq();
|
|
141444
|
-
measureValueFilter.dimensionality.forEach((item) => {
|
|
141445
|
-
if (isLocalIdRef(item)) dimensionalitySeq.add(item.localIdentifier);
|
|
141446
|
-
else dimensionalitySeq.add(getIdentifier(item));
|
|
141447
|
-
});
|
|
141448
|
-
map.add(new import_dist.Pair("dimensionality", dimensionalitySeq));
|
|
141449
|
-
}
|
|
141450
|
-
return map;
|
|
141451
|
-
}
|
|
141452
|
-
/** @internal */
|
|
141453
|
-
function declarativeRankingFilterToYaml(rankingFilter, errorContext) {
|
|
141454
|
-
const map = new import_dist.YAMLMap();
|
|
141455
|
-
map.add(new import_dist.Pair("type", "ranking_filter"));
|
|
141456
|
-
if (isLocalIdRef(rankingFilter.measure)) map.add(new import_dist.Pair("using", rankingFilter.measure.localIdentifier));
|
|
141457
|
-
else map.add(new import_dist.Pair("using", getIdentifier(rankingFilter.measure, void 0, updateErrorContext(errorContext, { path: ["measure"] }))));
|
|
141458
|
-
if (rankingFilter.operator === "TOP") map.add(new import_dist.Pair("top", rankingFilter.value));
|
|
141459
|
-
if (rankingFilter.operator === "BOTTOM") map.add(new import_dist.Pair("bottom", rankingFilter.value));
|
|
141460
|
-
if (rankingFilter.attributes?.[0]) {
|
|
141461
|
-
const first = rankingFilter.attributes[0];
|
|
141462
|
-
if (isLocalIdRef(first)) map.add(new import_dist.Pair("attribute", first.localIdentifier));
|
|
141463
|
-
else map.add(new import_dist.Pair("attribute", getIdentifier(first)));
|
|
141464
|
-
}
|
|
141465
|
-
if (rankingFilter.strictLimitOfRows !== void 0) map.add(new import_dist.Pair("strict_limit_of_rows", rankingFilter.strictLimitOfRows));
|
|
141466
|
-
return map;
|
|
141467
|
-
}
|
|
141468
141554
|
/** @internal */
|
|
141469
141555
|
function declarativeSortsToYaml(sorts, _errorContext) {
|
|
141470
141556
|
const sortsArray = [];
|
|
@@ -141509,151 +141595,151 @@ function declarativeMeasureSortToYaml(sort) {
|
|
|
141509
141595
|
return map;
|
|
141510
141596
|
}
|
|
141511
141597
|
function declarativeVisTableToYaml(doc, def, report, _context) {
|
|
141512
|
-
const metrics = report.
|
|
141598
|
+
const metrics = report.buckets.consume("measures");
|
|
141513
141599
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141514
|
-
const attribute = report.
|
|
141600
|
+
const attribute = report.buckets.consume("attribute");
|
|
141515
141601
|
if (attribute && attribute.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(attribute)));
|
|
141516
|
-
const columns = report.
|
|
141602
|
+
const columns = report.buckets.consume("columns");
|
|
141517
141603
|
if (columns && columns.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(columns)));
|
|
141518
141604
|
const config = table.load(def.properties);
|
|
141519
141605
|
if (config) doc.add(config);
|
|
141520
141606
|
}
|
|
141521
141607
|
function declarativeVisBarToYaml(doc, def, report, _errorContext) {
|
|
141522
|
-
const metrics = report.
|
|
141608
|
+
const metrics = report.buckets.consume("measures");
|
|
141523
141609
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141524
|
-
const view = report.
|
|
141610
|
+
const view = report.buckets.consume("view");
|
|
141525
141611
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141526
|
-
const stack = report.
|
|
141612
|
+
const stack = report.buckets.consume("stack");
|
|
141527
141613
|
if (stack && stack.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(stack)));
|
|
141528
141614
|
const config = barChart.load(def.properties);
|
|
141529
141615
|
if (config) doc.add(config);
|
|
141530
141616
|
}
|
|
141531
141617
|
function declarativeVisColumnToYaml(doc, def, report, _errorContext) {
|
|
141532
|
-
const metrics = report.
|
|
141618
|
+
const metrics = report.buckets.consume("measures");
|
|
141533
141619
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141534
|
-
const view = report.
|
|
141620
|
+
const view = report.buckets.consume("view");
|
|
141535
141621
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141536
|
-
const stack = report.
|
|
141622
|
+
const stack = report.buckets.consume("stack");
|
|
141537
141623
|
if (stack && stack.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(stack)));
|
|
141538
141624
|
const config = columnChart.load(def.properties);
|
|
141539
141625
|
if (config) doc.add(config);
|
|
141540
141626
|
}
|
|
141541
141627
|
function declarativeVisLineToYaml(doc, def, report, _errorContext) {
|
|
141542
|
-
const metrics = report.
|
|
141628
|
+
const metrics = report.buckets.consume("measures");
|
|
141543
141629
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141544
|
-
const trend = report.
|
|
141630
|
+
const trend = report.buckets.consume("trend");
|
|
141545
141631
|
if (trend && trend.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(trend)));
|
|
141546
|
-
const segment = report.
|
|
141632
|
+
const segment = report.buckets.consume("segment");
|
|
141547
141633
|
if (segment && segment.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141548
141634
|
const config = lineChart.load(def.properties);
|
|
141549
141635
|
if (config) doc.add(config);
|
|
141550
141636
|
}
|
|
141551
141637
|
function declarativeVisRadarToYaml(doc, def, report, _errorContext) {
|
|
141552
|
-
const metrics = report.
|
|
141638
|
+
const metrics = report.buckets.consume("measures");
|
|
141553
141639
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141554
|
-
const trend = report.
|
|
141640
|
+
const trend = report.buckets.consume("trend");
|
|
141555
141641
|
if (trend && trend.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(trend)));
|
|
141556
|
-
const segment = report.
|
|
141642
|
+
const segment = report.buckets.consume("segment");
|
|
141557
141643
|
if (segment && segment.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141558
141644
|
const config = radarChart.load(def.properties);
|
|
141559
141645
|
if (config) doc.add(config);
|
|
141560
141646
|
}
|
|
141561
141647
|
function declarativeVisAreaToYaml(doc, def, report, _errorContext) {
|
|
141562
|
-
const metrics = report.
|
|
141648
|
+
const metrics = report.buckets.consume("measures");
|
|
141563
141649
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141564
|
-
const view = report.
|
|
141650
|
+
const view = report.buckets.consume("view");
|
|
141565
141651
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141566
|
-
const stack = report.
|
|
141652
|
+
const stack = report.buckets.consume("stack");
|
|
141567
141653
|
if (stack && stack.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(stack)));
|
|
141568
141654
|
const config = areaChart.load(def.properties);
|
|
141569
141655
|
if (config) doc.add(config);
|
|
141570
141656
|
}
|
|
141571
141657
|
function declarativeVisScatterToYaml(doc, def, report, _errorContext) {
|
|
141572
|
-
const metrics1 = report.
|
|
141573
|
-
const metrics2 = report.
|
|
141658
|
+
const metrics1 = report.buckets.consume("measures");
|
|
141659
|
+
const metrics2 = report.buckets.consume("secondary_measures");
|
|
141574
141660
|
const metrics = {
|
|
141575
141661
|
items: cleanUpItems([...metrics1?.items.length ? metrics1.items : [null], ...metrics2?.items.length ? metrics2.items : [null]]),
|
|
141576
141662
|
type: "measures"
|
|
141577
141663
|
};
|
|
141578
141664
|
if (metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141579
|
-
const attributes = report.
|
|
141665
|
+
const attributes = report.buckets.consume("attribute");
|
|
141580
141666
|
if (attributes && attributes.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(attributes)));
|
|
141581
|
-
const segments = report.
|
|
141667
|
+
const segments = report.buckets.consume("segment");
|
|
141582
141668
|
if (segments && segments.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(segments)));
|
|
141583
141669
|
const config = scatterChart.load(def.properties);
|
|
141584
141670
|
if (config) doc.add(config);
|
|
141585
141671
|
}
|
|
141586
141672
|
function declarativeVisBubbleToYaml(doc, def, report, _errorContext) {
|
|
141587
|
-
const metrics1 = report.
|
|
141588
|
-
const metrics2 = report.
|
|
141673
|
+
const metrics1 = report.buckets.consume("measures");
|
|
141674
|
+
const metrics2 = report.buckets.consume("secondary_measures");
|
|
141589
141675
|
const metrics = {
|
|
141590
141676
|
items: cleanUpItems([...metrics1?.items.length ? metrics1.items : [null], ...metrics2?.items.length ? metrics2.items : [null]]),
|
|
141591
141677
|
type: "measures"
|
|
141592
141678
|
};
|
|
141593
141679
|
if (metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141594
|
-
const view = report.
|
|
141680
|
+
const view = report.buckets.consume("view");
|
|
141595
141681
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141596
|
-
const tertiaryMetrics = report.
|
|
141682
|
+
const tertiaryMetrics = report.buckets.consume("tertiary_measures");
|
|
141597
141683
|
if (tertiaryMetrics && tertiaryMetrics.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(tertiaryMetrics)));
|
|
141598
141684
|
const config = bubbleChart.load(def.properties);
|
|
141599
141685
|
if (config) doc.add(config);
|
|
141600
141686
|
}
|
|
141601
141687
|
function declarativeVisPieToYaml(doc, def, report, _errorContext) {
|
|
141602
|
-
const metrics = report.
|
|
141688
|
+
const metrics = report.buckets.consume("measures");
|
|
141603
141689
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141604
|
-
const view = report.
|
|
141690
|
+
const view = report.buckets.consume("view");
|
|
141605
141691
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141606
141692
|
const config = pieChart.load(def.properties);
|
|
141607
141693
|
if (config) doc.add(config);
|
|
141608
141694
|
}
|
|
141609
141695
|
function declarativeVisDonutToYaml(doc, def, report, _errorContext) {
|
|
141610
|
-
const metrics = report.
|
|
141696
|
+
const metrics = report.buckets.consume("measures");
|
|
141611
141697
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141612
|
-
const view = report.
|
|
141698
|
+
const view = report.buckets.consume("view");
|
|
141613
141699
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141614
141700
|
const config = donutChart.load(def.properties);
|
|
141615
141701
|
if (config) doc.add(config);
|
|
141616
141702
|
}
|
|
141617
141703
|
function declarativeVisTreemapToYaml(doc, def, report, _errorContext) {
|
|
141618
|
-
const metrics = report.
|
|
141704
|
+
const metrics = report.buckets.consume("measures");
|
|
141619
141705
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141620
|
-
const view = report.
|
|
141706
|
+
const view = report.buckets.consume("view");
|
|
141621
141707
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141622
|
-
const segment = report.
|
|
141708
|
+
const segment = report.buckets.consume("segment");
|
|
141623
141709
|
if (segment && segment.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141624
141710
|
const config = treemapChart.load(def.properties);
|
|
141625
141711
|
if (config) doc.add(config);
|
|
141626
141712
|
}
|
|
141627
141713
|
function declarativeVisPyramidToYaml(doc, def, report, _errorContext) {
|
|
141628
|
-
const metrics = report.
|
|
141714
|
+
const metrics = report.buckets.consume("measures");
|
|
141629
141715
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141630
|
-
const view = report.
|
|
141716
|
+
const view = report.buckets.consume("view");
|
|
141631
141717
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141632
141718
|
const config = pyramidChart.load(def.properties);
|
|
141633
141719
|
if (config) doc.add(config);
|
|
141634
141720
|
}
|
|
141635
141721
|
function declarativeVisFunnelToYaml(doc, def, report, _errorContext) {
|
|
141636
|
-
const metrics = report.
|
|
141722
|
+
const metrics = report.buckets.consume("measures");
|
|
141637
141723
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141638
|
-
const view = report.
|
|
141724
|
+
const view = report.buckets.consume("view");
|
|
141639
141725
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141640
141726
|
const config = funnelChart.load(def.properties);
|
|
141641
141727
|
if (config) doc.add(config);
|
|
141642
141728
|
}
|
|
141643
141729
|
function declarativeVisHeatmapToYaml(doc, def, report, _errorContext) {
|
|
141644
|
-
const metrics = report.
|
|
141730
|
+
const metrics = report.buckets.consume("measures");
|
|
141645
141731
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141646
|
-
const view = report.
|
|
141732
|
+
const view = report.buckets.consume("view");
|
|
141647
141733
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141648
|
-
const stack = report.
|
|
141734
|
+
const stack = report.buckets.consume("stack");
|
|
141649
141735
|
if (stack && stack.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(stack)));
|
|
141650
141736
|
const config = heatmapChart.load(def.properties);
|
|
141651
141737
|
if (config) doc.add(config);
|
|
141652
141738
|
}
|
|
141653
141739
|
function declarativeVisBulletToYaml(doc, def, report, _errorContext) {
|
|
141654
|
-
const metrics1 = report.
|
|
141655
|
-
const metrics2 = report.
|
|
141656
|
-
const metrics3 = report.
|
|
141740
|
+
const metrics1 = report.buckets.consume("measures");
|
|
141741
|
+
const metrics2 = report.buckets.consume("secondary_measures");
|
|
141742
|
+
const metrics3 = report.buckets.consume("tertiary_measures");
|
|
141657
141743
|
const metrics = {
|
|
141658
141744
|
items: cleanUpItems([
|
|
141659
141745
|
...metrics1?.items.length ? metrics1.items : [null],
|
|
@@ -141663,24 +141749,24 @@ function declarativeVisBulletToYaml(doc, def, report, _errorContext) {
|
|
|
141663
141749
|
type: "measures"
|
|
141664
141750
|
};
|
|
141665
141751
|
if (metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141666
|
-
const view = report.
|
|
141752
|
+
const view = report.buckets.consume("view");
|
|
141667
141753
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141668
141754
|
const config = bulletChart.load(def.properties);
|
|
141669
141755
|
if (config) doc.add(config);
|
|
141670
141756
|
}
|
|
141671
141757
|
function declarativeVisWaterfallToYaml(doc, def, report, _errorContext) {
|
|
141672
|
-
const metrics = report.
|
|
141758
|
+
const metrics = report.buckets.consume("measures");
|
|
141673
141759
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141674
|
-
const view = report.
|
|
141760
|
+
const view = report.buckets.consume("view");
|
|
141675
141761
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141676
141762
|
const config = waterfallChart.load(def.properties);
|
|
141677
141763
|
if (config) doc.add(config);
|
|
141678
141764
|
}
|
|
141679
141765
|
function declarativeVisDependencyWheelToYaml(doc, def, report, _errorContext) {
|
|
141680
|
-
const metrics = report.
|
|
141766
|
+
const metrics = report.buckets.consume("measures");
|
|
141681
141767
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141682
|
-
const from = report.
|
|
141683
|
-
const to = report.
|
|
141768
|
+
const from = report.buckets.consume("attribute_from");
|
|
141769
|
+
const to = report.buckets.consume("attribute_to");
|
|
141684
141770
|
const view = {
|
|
141685
141771
|
items: cleanUpItems([...from?.items.length ? from.items : [null], ...to?.items.length ? to.items : [null]]),
|
|
141686
141772
|
type: "view"
|
|
@@ -141690,10 +141776,10 @@ function declarativeVisDependencyWheelToYaml(doc, def, report, _errorContext) {
|
|
|
141690
141776
|
if (config) doc.add(config);
|
|
141691
141777
|
}
|
|
141692
141778
|
function declarativeVisSankeyToYaml(doc, def, report, _errorContext) {
|
|
141693
|
-
const metrics = report.
|
|
141779
|
+
const metrics = report.buckets.consume("measures");
|
|
141694
141780
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141695
|
-
const from = report.
|
|
141696
|
-
const to = report.
|
|
141781
|
+
const from = report.buckets.consume("attribute_from");
|
|
141782
|
+
const to = report.buckets.consume("attribute_to");
|
|
141697
141783
|
const view = {
|
|
141698
141784
|
items: cleanUpItems([...from?.items.length ? from.items : [null], ...to?.items.length ? to.items : [null]]),
|
|
141699
141785
|
type: "view"
|
|
@@ -141703,8 +141789,8 @@ function declarativeVisSankeyToYaml(doc, def, report, _errorContext) {
|
|
|
141703
141789
|
if (config) doc.add(config);
|
|
141704
141790
|
}
|
|
141705
141791
|
function declarativeVisHeadlineToYaml(doc, def, report, _errorContext) {
|
|
141706
|
-
const metrics1 = report.
|
|
141707
|
-
const metrics2 = report.
|
|
141792
|
+
const metrics1 = report.buckets.consume("measures");
|
|
141793
|
+
const metrics2 = report.buckets.consume("secondary_measures");
|
|
141708
141794
|
const metrics = {
|
|
141709
141795
|
items: [...metrics1?.items ?? [null], ...metrics2?.items ?? []],
|
|
141710
141796
|
type: "measures"
|
|
@@ -141714,51 +141800,51 @@ function declarativeVisHeadlineToYaml(doc, def, report, _errorContext) {
|
|
|
141714
141800
|
if (config) doc.add(config);
|
|
141715
141801
|
}
|
|
141716
141802
|
function declarativeVisComboToYaml(doc, def, report, _errorContext) {
|
|
141717
|
-
const metrics1 = addAxisTypeToGroup(report.
|
|
141718
|
-
const metrics2 = addAxisTypeToGroup(report.
|
|
141803
|
+
const metrics1 = addAxisTypeToGroup(report.buckets.consume("measures"), "primary");
|
|
141804
|
+
const metrics2 = addAxisTypeToGroup(report.buckets.consume("secondary_measures"), "secondary");
|
|
141719
141805
|
const metrics = {
|
|
141720
141806
|
items: [...metrics1?.items ?? [], ...metrics2?.items ?? []],
|
|
141721
141807
|
type: "measures"
|
|
141722
141808
|
};
|
|
141723
141809
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141724
|
-
const view = report.
|
|
141810
|
+
const view = report.buckets.consume("view");
|
|
141725
141811
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141726
141812
|
const config = comboChart.load(def.properties);
|
|
141727
141813
|
if (config) doc.add(config);
|
|
141728
141814
|
}
|
|
141729
|
-
function addPushpinBucketsToYaml(target,
|
|
141730
|
-
const sizeBucket =
|
|
141731
|
-
const colorBucket =
|
|
141815
|
+
function addPushpinBucketsToYaml(target, buckets) {
|
|
141816
|
+
const sizeBucket = buckets.consume("size");
|
|
141817
|
+
const colorBucket = buckets.consume("color");
|
|
141732
141818
|
const metrics = {
|
|
141733
141819
|
items: cleanUpItems([...sizeBucket?.items.length ? sizeBucket.items : [null], ...colorBucket?.items ? colorBucket.items : [null]]),
|
|
141734
141820
|
type: "measures"
|
|
141735
141821
|
};
|
|
141736
141822
|
if (metrics.items.length > 0) target.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141737
|
-
const location =
|
|
141823
|
+
const location = buckets.consume("location");
|
|
141738
141824
|
if (location && location.items.length > 0) target.add(entryWithSpace("view_by", groupToYaml(location)));
|
|
141739
|
-
const segment =
|
|
141825
|
+
const segment = buckets.consume("segment");
|
|
141740
141826
|
if (segment && segment.items.length > 0) target.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141741
141827
|
}
|
|
141742
|
-
function addGeoAreaBucketsToYaml(target,
|
|
141743
|
-
const colorBucket =
|
|
141828
|
+
function addGeoAreaBucketsToYaml(target, buckets) {
|
|
141829
|
+
const colorBucket = buckets.consume("color");
|
|
141744
141830
|
const metrics = {
|
|
141745
141831
|
items: cleanUpItems([...colorBucket?.items.length ? colorBucket.items : [null]]),
|
|
141746
141832
|
type: "measures"
|
|
141747
141833
|
};
|
|
141748
141834
|
if (metrics.items.length > 0) target.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141749
|
-
const area =
|
|
141835
|
+
const area = buckets.consume("area");
|
|
141750
141836
|
if (area && area.items.length > 0) target.add(entryWithSpace("view_by", groupToYaml(area)));
|
|
141751
|
-
const segment =
|
|
141837
|
+
const segment = buckets.consume("segment");
|
|
141752
141838
|
if (segment && segment.items.length > 0) target.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141753
141839
|
}
|
|
141754
141840
|
function declarativeVisGeoToYaml(doc, def, report, entities, errorContext) {
|
|
141755
|
-
addPushpinBucketsToYaml(doc, report.
|
|
141841
|
+
addPushpinBucketsToYaml(doc, report.buckets);
|
|
141756
141842
|
const config = geoChart.load(def.properties);
|
|
141757
141843
|
if (config) doc.add(config);
|
|
141758
141844
|
appendLayers(doc, def, entities, errorContext);
|
|
141759
141845
|
}
|
|
141760
141846
|
function declarativeVisGeoAreaToYaml(doc, def, report, entities, errorContext) {
|
|
141761
|
-
addGeoAreaBucketsToYaml(doc, report.
|
|
141847
|
+
addGeoAreaBucketsToYaml(doc, report.buckets);
|
|
141762
141848
|
const config = geoAreaChart.load(def.properties);
|
|
141763
141849
|
if (config) doc.add(config);
|
|
141764
141850
|
appendLayers(doc, def, entities, errorContext);
|
|
@@ -141770,11 +141856,11 @@ function appendLayers(doc, def, entities, errorContext) {
|
|
|
141770
141856
|
if (layers.items.length > 0) doc.add(entryWithSpace("layers", layers));
|
|
141771
141857
|
}
|
|
141772
141858
|
function declarativeVisRepeaterToYaml(doc, def, report, _errorContext) {
|
|
141773
|
-
const columnsMapped = addChartTypeToGroup(report.
|
|
141859
|
+
const columnsMapped = addChartTypeToGroup(report.buckets.consume("columns"), def.properties);
|
|
141774
141860
|
if (columnsMapped && columnsMapped.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(columnsMapped)));
|
|
141775
|
-
const view = report.
|
|
141861
|
+
const view = report.buckets.consume("view");
|
|
141776
141862
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141777
|
-
const attribute = report.
|
|
141863
|
+
const attribute = report.buckets.consume("attribute");
|
|
141778
141864
|
if (attribute && attribute.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(attribute)));
|
|
141779
141865
|
const config = repeaterChart.load(def.properties);
|
|
141780
141866
|
if (config) doc.add(config);
|
|
@@ -141831,16 +141917,25 @@ function addChartTypeToGroup(group, config) {
|
|
|
141831
141917
|
})
|
|
141832
141918
|
};
|
|
141833
141919
|
}
|
|
141920
|
+
function unrepresentableLayerField(layer) {
|
|
141921
|
+
if (layer.filters?.some(isFilter)) return "filters";
|
|
141922
|
+
if (layer.sorts?.length) return "sorts";
|
|
141923
|
+
return Object.values(layer.attributeFilterConfigs ?? {}).some((config) => config?.displayAsLabel) ? "attributeFilterConfigs" : null;
|
|
141924
|
+
}
|
|
141834
141925
|
function declarativeLayersToYaml(entities, layersDefinition, errorContext) {
|
|
141835
141926
|
const layers = new import_dist.YAMLSeq();
|
|
141836
141927
|
layersDefinition.forEach((layer, li) => {
|
|
141837
|
-
const
|
|
141928
|
+
const unrepresentable = unrepresentableLayerField(layer);
|
|
141929
|
+
if (unrepresentable !== null) throw newError("core.itemNotSupported", [`layer "${layer.id}" own ${unrepresentable}`], updateErrorContext(errorContext, { path: [li.toString(), unrepresentable] }));
|
|
141930
|
+
const { groups: layerGroups } = declarativeBucketsToYaml(entities, layer.buckets ?? [], updateErrorContext(errorContext, { path: [li.toString(), "buckets"] }));
|
|
141931
|
+
const buckets = bucketRegistry(layerGroups);
|
|
141838
141932
|
const layerKind = resolveLayerExportKind(layer.type, updateErrorContext(errorContext, { path: [li.toString(), "type"] }));
|
|
141839
141933
|
const layerMap = new import_dist.YAMLMap();
|
|
141840
141934
|
layerMap.add(new import_dist.Pair("id", layer.id));
|
|
141841
141935
|
if (layer.name) layerMap.add(new import_dist.Pair("title", layer.name));
|
|
141842
141936
|
if (layer.type) layerMap.add(new import_dist.Pair("type", layer.type));
|
|
141843
|
-
appendLayerBucketsForKind(layerMap,
|
|
141937
|
+
appendLayerBucketsForKind(layerMap, buckets, layerKind, updateErrorContext(errorContext, { path: [li.toString()] }));
|
|
141938
|
+
buckets.assertAllConsumed(updateErrorContext(errorContext, { path: [li.toString()] }));
|
|
141844
141939
|
addLayerConfig(layerMap, layerKind, layer.properties);
|
|
141845
141940
|
layers.add(layerMap);
|
|
141846
141941
|
});
|
|
@@ -141851,13 +141946,13 @@ function resolveLayerExportKind(rawLayerType, errorContext) {
|
|
|
141851
141946
|
if (rawLayerType === "area") return "area";
|
|
141852
141947
|
throw newError("core.layerTypeNotSupported", [rawLayerType ?? "<missing>"], errorContext);
|
|
141853
141948
|
}
|
|
141854
|
-
function appendLayerBucketsForKind(layerMap,
|
|
141949
|
+
function appendLayerBucketsForKind(layerMap, buckets, kind, errorContext) {
|
|
141855
141950
|
if (kind === "pushpin") {
|
|
141856
|
-
addPushpinBucketsToYaml(layerMap,
|
|
141951
|
+
addPushpinBucketsToYaml(layerMap, buckets);
|
|
141857
141952
|
return;
|
|
141858
141953
|
}
|
|
141859
141954
|
if (kind === "area") {
|
|
141860
|
-
addGeoAreaBucketsToYaml(layerMap,
|
|
141955
|
+
addGeoAreaBucketsToYaml(layerMap, buckets);
|
|
141861
141956
|
return;
|
|
141862
141957
|
}
|
|
141863
141958
|
throw newError("core.layerTypeNotSupported", [kind], errorContext);
|
|
@@ -159869,7 +159964,7 @@ async function open(state, emitter, file) {
|
|
|
159869
159964
|
//#endregion
|
|
159870
159965
|
//#region ../code/package.json
|
|
159871
159966
|
var name = "@gooddata/code";
|
|
159872
|
-
var version = "0.47.0-alpha.
|
|
159967
|
+
var version = "0.47.0-alpha.5";
|
|
159873
159968
|
//#endregion
|
|
159874
159969
|
//#region ../../../sdk/libs/api-client-tiger/src/axios.ts
|
|
159875
159970
|
/**
|
|
@@ -159891,7 +159986,7 @@ const _CONFIG = {
|
|
|
159891
159986
|
common: {
|
|
159892
159987
|
"X-Requested-With": "XMLHttpRequest",
|
|
159893
159988
|
"X-GDC-JS-PACKAGE": "@gooddata/api-client-tiger",
|
|
159894
|
-
"X-GDC-JS-PACKAGE-VERSION": "11.51.0-alpha.
|
|
159989
|
+
"X-GDC-JS-PACKAGE-VERSION": "11.51.0-alpha.5"
|
|
159895
159990
|
},
|
|
159896
159991
|
post: { "Content-Type": "application/json;charset=utf8" },
|
|
159897
159992
|
put: { "Content-Type": "application/json;charset=utf8" }
|