@gooddata/code-cli 0.47.0-alpha.2 → 0.47.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/dist/fixtures/rules/dashboards.mdc +6 -0
- package/dist/index.js +596 -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.4";
|
|
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
|
});
|
|
@@ -139981,11 +140005,13 @@ function yamlDashboardToDeclarative(entities, input) {
|
|
|
139981
140005
|
const yamlVersion = input.version ?? "2";
|
|
139982
140006
|
const { layout, filterContext, dateFilterConfig, dateFilterConfigs, attributeFilterConfigs, measureValueFilterConfigs, tabs, tabFilterContexts } = yamlVersion === "3" ? hasTabs ? processDashboardWithTabsV3(entities, input) : processDashboardWithoutTabsV3(entities, input) : hasTabs ? processDashboardWithTabsV2(entities, input) : processDashboardWithoutTabsV2(entities, input);
|
|
139983
140007
|
const plugins = yamlPluginsToDeclarative(input.plugins);
|
|
140008
|
+
const timezoneConfig = yamlTimezoneConfigToDeclarative(input.timezone_config);
|
|
139984
140009
|
const [, permissions] = toDeclarativePermissions(input.permissions);
|
|
139985
140010
|
const content = yamlVersion === "3" ? {
|
|
139986
140011
|
version: "3",
|
|
139987
140012
|
plugins,
|
|
139988
140013
|
tabs,
|
|
140014
|
+
...timezoneConfig ? { timezoneConfig } : {},
|
|
139989
140015
|
...input.cross_filtering === false ? { disableCrossFiltering: true } : {},
|
|
139990
140016
|
...input.user_filters_save === false ? { disableUserFilterSave: true } : {},
|
|
139991
140017
|
...input.user_filters_reset === false ? { disableUserFilterReset: true } : {},
|
|
@@ -139999,6 +140025,7 @@ function yamlDashboardToDeclarative(entities, input) {
|
|
|
139999
140025
|
measureValueFilterConfigs,
|
|
140000
140026
|
dateFilterConfig,
|
|
140001
140027
|
dateFilterConfigs,
|
|
140028
|
+
...timezoneConfig ? { timezoneConfig } : {},
|
|
140002
140029
|
...tabs ? { tabs } : {},
|
|
140003
140030
|
...input.cross_filtering === false ? { disableCrossFiltering: true } : {},
|
|
140004
140031
|
...input.user_filters_save === false ? { disableUserFilterSave: true } : {},
|
|
@@ -140277,6 +140304,14 @@ function yamlPluginToDeclarative$1(input) {
|
|
|
140277
140304
|
parameters: serialiseParameters(input.parameters ?? "")
|
|
140278
140305
|
};
|
|
140279
140306
|
}
|
|
140307
|
+
function yamlTimezoneConfigToDeclarative(input) {
|
|
140308
|
+
if (!input) return;
|
|
140309
|
+
return {
|
|
140310
|
+
...input.timezone_id ? { timezoneId: input.timezone_id } : {},
|
|
140311
|
+
...input.show_timezone_info === void 0 ? {} : { showTimezoneInfo: input.show_timezone_info },
|
|
140312
|
+
...input.allow_user_override_in_view_mode === void 0 ? {} : { allowUserOverrideInViewMode: input.allow_user_override_in_view_mode }
|
|
140313
|
+
};
|
|
140314
|
+
}
|
|
140280
140315
|
function isFilterGroup$1(filter) {
|
|
140281
140316
|
return typeof filter === "object" && filter !== null && "type" in filter && filter.type === "filter_group" && "filters" in filter;
|
|
140282
140317
|
}
|
|
@@ -140774,6 +140809,374 @@ function declarativeMetricToYaml(metric) {
|
|
|
140774
140809
|
};
|
|
140775
140810
|
}
|
|
140776
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
|
|
140777
141180
|
//#region ../../../sdk/libs/sdk-code-convertors/src/from/declarativeVisualisationToYaml.ts
|
|
140778
141181
|
/** @public */
|
|
140779
141182
|
function declarativeVisualisationToYaml(entities, visualisation, context) {
|
|
@@ -140796,11 +141199,31 @@ function declarativeVisualisationToYaml(entities, visualisation, context) {
|
|
|
140796
141199
|
const report = declarativeReportToYaml(entities, insight.insight, updateErrorContext(errorContext, { path: ["insight"] }));
|
|
140797
141200
|
doc.add(entryWithSpace("query", report.report));
|
|
140798
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"] }));
|
|
140799
141204
|
return {
|
|
140800
141205
|
content: doc.toString({ lineWidth: 0 }),
|
|
140801
141206
|
json: doc.toJSON()
|
|
140802
141207
|
};
|
|
140803
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
|
+
}
|
|
140804
141227
|
function declarativeReportToYaml(entities, def, errorContext) {
|
|
140805
141228
|
const report = new import_dist.YAMLMap();
|
|
140806
141229
|
const { fieldsMap, postProcessors, groups: derivedBuckets } = declarativeBucketsToYaml(entities, def.buckets, updateErrorContext(errorContext, { path: ["buckets"] }));
|
|
@@ -140818,7 +141241,7 @@ function declarativeReportToYaml(entities, def, errorContext) {
|
|
|
140818
141241
|
});
|
|
140819
141242
|
return {
|
|
140820
141243
|
report,
|
|
140821
|
-
derivedBuckets
|
|
141244
|
+
buckets: bucketRegistry(derivedBuckets)
|
|
140822
141245
|
};
|
|
140823
141246
|
}
|
|
140824
141247
|
function appendLayerFieldsToReport(fieldsMap, postProcessors, entities, layers, errorContext) {
|
|
@@ -140958,6 +141381,7 @@ function declarativeBucketsToYaml(entities, buckets, errorContext) {
|
|
|
140958
141381
|
const groups = [];
|
|
140959
141382
|
const postProcessors = { filters: [] };
|
|
140960
141383
|
const addField = (local, def, group, { format, axis } = {}) => {
|
|
141384
|
+
if (fullFieldsMap.has(local)) throw newError("core.duplicateFieldName", [local], errorContext);
|
|
140961
141385
|
fullFieldsMap.add(new import_dist.Pair(local, def));
|
|
140962
141386
|
group.items.push(createBucketGroupItem(local, format, axis));
|
|
140963
141387
|
};
|
|
@@ -141127,333 +141551,6 @@ function getShortenedBucket(def) {
|
|
|
141127
141551
|
}
|
|
141128
141552
|
return false;
|
|
141129
141553
|
}
|
|
141130
|
-
function detectEmptyValuesFilterType(filter) {
|
|
141131
|
-
const attributeElements = filterAttributeElements(filter);
|
|
141132
|
-
const items = attributeElements ? getAttributeElementsItems(attributeElements) : [];
|
|
141133
|
-
if (items.length !== 1 || items[0] !== "") return;
|
|
141134
|
-
return isPositiveAttributeFilter$1(filter) ? "only" : "exclude";
|
|
141135
|
-
}
|
|
141136
|
-
function getObjRefGroupingKey(objRef) {
|
|
141137
|
-
if (!objRef || typeof objRef !== "object") return;
|
|
141138
|
-
if ("identifier" in objRef) {
|
|
141139
|
-
const identifier = objRef.identifier;
|
|
141140
|
-
if (typeof identifier === "string") return identifier;
|
|
141141
|
-
if (identifier && typeof identifier === "object" && "id" in identifier) {
|
|
141142
|
-
const id = identifier.id;
|
|
141143
|
-
if (typeof id === "string") return id;
|
|
141144
|
-
}
|
|
141145
|
-
}
|
|
141146
|
-
if ("uri" in objRef) {
|
|
141147
|
-
const uri = objRef.uri;
|
|
141148
|
-
if (typeof uri === "string") return uri;
|
|
141149
|
-
}
|
|
141150
|
-
if ("localIdentifier" in objRef) {
|
|
141151
|
-
const localIdentifier = objRef.localIdentifier;
|
|
141152
|
-
if (typeof localIdentifier === "string") return localIdentifier;
|
|
141153
|
-
}
|
|
141154
|
-
return serializeObjRef(objRef);
|
|
141155
|
-
}
|
|
141156
|
-
/**
|
|
141157
|
-
* Groups date filters with their associated attribute filters. Leaves the rest alone.
|
|
141158
|
-
* @param filters
|
|
141159
|
-
*/
|
|
141160
|
-
function groupFiltersByDateFilter(filters) {
|
|
141161
|
-
const dateFilters = [...filters].filter(isDateFilter$1);
|
|
141162
|
-
const nonDateFilters = [...filters].filter((f) => !isDateFilter$1(f));
|
|
141163
|
-
const result = {
|
|
141164
|
-
grouped: {},
|
|
141165
|
-
rest: []
|
|
141166
|
-
};
|
|
141167
|
-
const getFilterRefDetails = (filter) => {
|
|
141168
|
-
const objRef = filterObjRef(filter);
|
|
141169
|
-
if (!objRef) return {
|
|
141170
|
-
objRef: void 0,
|
|
141171
|
-
filterRef: void 0
|
|
141172
|
-
};
|
|
141173
|
-
return {
|
|
141174
|
-
objRef,
|
|
141175
|
-
filterRef: getObjRefGroupingKey(objRef)
|
|
141176
|
-
};
|
|
141177
|
-
};
|
|
141178
|
-
dateFilters.forEach((dateFilter) => {
|
|
141179
|
-
const { filterRef: datasetId } = getFilterRefDetails(dateFilter);
|
|
141180
|
-
const fi = filters.indexOf(dateFilter);
|
|
141181
|
-
if (datasetId === void 0) {
|
|
141182
|
-
result.rest.push([dateFilter, fi]);
|
|
141183
|
-
return;
|
|
141184
|
-
}
|
|
141185
|
-
if (result.grouped[datasetId]) result.rest.push([dateFilter, fi]);
|
|
141186
|
-
else result.grouped[datasetId] = {
|
|
141187
|
-
dateFilter: [dateFilter, fi],
|
|
141188
|
-
attributeFilters: []
|
|
141189
|
-
};
|
|
141190
|
-
});
|
|
141191
|
-
nonDateFilters.forEach((filter) => {
|
|
141192
|
-
const { filterRef: filterId } = getFilterRefDetails(filter);
|
|
141193
|
-
const fi = filters.indexOf(filter);
|
|
141194
|
-
if (filterId === void 0) {
|
|
141195
|
-
result.rest.push([filter, fi]);
|
|
141196
|
-
return;
|
|
141197
|
-
}
|
|
141198
|
-
const datasetId = filterId.split(".")[0];
|
|
141199
|
-
const group = result.grouped[datasetId];
|
|
141200
|
-
if (group) group.attributeFilters.push([filter, fi]);
|
|
141201
|
-
else result.rest.push([filter, fi]);
|
|
141202
|
-
});
|
|
141203
|
-
return result;
|
|
141204
|
-
}
|
|
141205
|
-
/** @internal */
|
|
141206
|
-
function declarativeFiltersToYaml(entities, filters, errorContext) {
|
|
141207
|
-
const filtersArray = [];
|
|
141208
|
-
const filtersMap = {};
|
|
141209
|
-
const usedKeys = /* @__PURE__ */ new Set();
|
|
141210
|
-
const getUniqueKey = (baseKey) => {
|
|
141211
|
-
let key = baseKey;
|
|
141212
|
-
let suffix = 2;
|
|
141213
|
-
while (usedKeys.has(key)) {
|
|
141214
|
-
key = `${baseKey}_${suffix}`;
|
|
141215
|
-
suffix += 1;
|
|
141216
|
-
}
|
|
141217
|
-
usedKeys.add(key);
|
|
141218
|
-
return key;
|
|
141219
|
-
};
|
|
141220
|
-
const filtersGroupedByDateFilter = groupFiltersByDateFilter(filters);
|
|
141221
|
-
filtersGroupedByDateFilter.rest.forEach(([filter, fi]) => {
|
|
141222
|
-
const result = declarativeFilterToYaml(entities, filter, getUniqueKey, void 0, updateErrorContext(errorContext, { path: [fi.toString()] }));
|
|
141223
|
-
if (!result) return;
|
|
141224
|
-
const { key, yaml, filter: originalFilter } = result;
|
|
141225
|
-
filtersArray.push(new import_dist.Pair(key, yaml));
|
|
141226
|
-
filtersMap[key] = {
|
|
141227
|
-
yaml,
|
|
141228
|
-
filter: originalFilter
|
|
141229
|
-
};
|
|
141230
|
-
});
|
|
141231
|
-
Object.values(filtersGroupedByDateFilter.grouped).forEach(({ dateFilter, attributeFilters }) => {
|
|
141232
|
-
const result = declarativeFilterToYaml(entities, dateFilter[0], getUniqueKey, attributeFilters.map(([f]) => f), updateErrorContext(errorContext, { path: [dateFilter[1].toString()] }));
|
|
141233
|
-
if (!result) return;
|
|
141234
|
-
const { key, yaml, filter: originalFilter } = result;
|
|
141235
|
-
filtersArray.push(new import_dist.Pair(key, yaml));
|
|
141236
|
-
filtersMap[key] = {
|
|
141237
|
-
yaml,
|
|
141238
|
-
filter: originalFilter
|
|
141239
|
-
};
|
|
141240
|
-
});
|
|
141241
|
-
return {
|
|
141242
|
-
filtersMap,
|
|
141243
|
-
filtersArray: filtersArray.reduce((map, filter) => {
|
|
141244
|
-
map.add(filter);
|
|
141245
|
-
return map;
|
|
141246
|
-
}, new import_dist.YAMLMap())
|
|
141247
|
-
};
|
|
141248
|
-
}
|
|
141249
|
-
function declarativeFilterToYaml(entities, filter, getUniqueKey, connectedAttributeFilters, errorContext) {
|
|
141250
|
-
if (!isFilter(filter)) return null;
|
|
141251
|
-
const key = getUniqueKey(createFilterItemKeyName(filter, "date", updateErrorContext(errorContext, { path: ["date"] })));
|
|
141252
|
-
if (isAbsoluteDateFilter$1(filter)) return {
|
|
141253
|
-
key,
|
|
141254
|
-
yaml: declarativeAbsoluteDateFilterToYaml(filter.absoluteDateFilter, connectedAttributeFilters, entities, getUniqueKey, updateErrorContext(errorContext, { path: ["absoluteDateFilter"] })),
|
|
141255
|
-
filter
|
|
141256
|
-
};
|
|
141257
|
-
if (isRelativeDateFilter$1(filter)) return {
|
|
141258
|
-
key,
|
|
141259
|
-
yaml: declarativeRelativeDateFilterToYaml(filter.relativeDateFilter, connectedAttributeFilters, entities, getUniqueKey, updateErrorContext(errorContext, { path: ["relativeDateFilter"] })),
|
|
141260
|
-
filter
|
|
141261
|
-
};
|
|
141262
|
-
if (isPositiveAttributeFilter$1(filter)) return {
|
|
141263
|
-
key,
|
|
141264
|
-
yaml: declarativePositiveAttributeFilterToYaml(entities, filter.positiveAttributeFilter, updateErrorContext(errorContext, { path: ["positiveAttributeFilter"] })),
|
|
141265
|
-
filter
|
|
141266
|
-
};
|
|
141267
|
-
if (isNegativeAttributeFilter$1(filter)) return {
|
|
141268
|
-
key,
|
|
141269
|
-
yaml: declarativeNegativeAttributeFilterToYaml(entities, filter.negativeAttributeFilter, updateErrorContext(errorContext, { path: ["negativeAttributeFilter"] })),
|
|
141270
|
-
filter
|
|
141271
|
-
};
|
|
141272
|
-
if (isArbitraryAttributeFilter(filter)) return {
|
|
141273
|
-
key,
|
|
141274
|
-
yaml: declarativeArbitraryAttributeFilterToYaml(filter.arbitraryAttributeFilter, updateErrorContext(errorContext, { path: ["arbitraryAttributeFilter"] })),
|
|
141275
|
-
filter
|
|
141276
|
-
};
|
|
141277
|
-
if (isMatchAttributeFilter(filter)) return {
|
|
141278
|
-
key,
|
|
141279
|
-
yaml: declarativeMatchAttributeFilterToYaml(filter.matchAttributeFilter, updateErrorContext(errorContext, { path: ["matchAttributeFilter"] })),
|
|
141280
|
-
filter
|
|
141281
|
-
};
|
|
141282
|
-
if (isMeasureValueFilter(filter)) return {
|
|
141283
|
-
key,
|
|
141284
|
-
yaml: declarativeMeasureValueFilterToYaml$1(filter.measureValueFilter, updateErrorContext(errorContext, { path: ["measureValueFilter"] })),
|
|
141285
|
-
filter
|
|
141286
|
-
};
|
|
141287
|
-
if (isRankingFilter$1(filter)) return {
|
|
141288
|
-
key,
|
|
141289
|
-
yaml: declarativeRankingFilterToYaml(filter.rankingFilter, updateErrorContext(errorContext, { path: ["rankingFilter"] })),
|
|
141290
|
-
filter
|
|
141291
|
-
};
|
|
141292
|
-
throw newError("core.filterItemTypeNotSupported", [JSON.stringify(filter)], errorContext);
|
|
141293
|
-
}
|
|
141294
|
-
/**
|
|
141295
|
-
* Modifies `map`, adding `empty_filters` and `with` keys, populated from connectedAttributeFilters.
|
|
141296
|
-
*/
|
|
141297
|
-
function processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey, errorContext) {
|
|
141298
|
-
const emptyValuesFilter = connectedAttributeFilters.find((filter) => detectEmptyValuesFilterType(filter));
|
|
141299
|
-
if (emptyValuesFilter) map.add(new import_dist.Pair("empty_values", detectEmptyValuesFilterType(emptyValuesFilter)));
|
|
141300
|
-
const additionalAttributeFilters = connectedAttributeFilters.filter((filter) => filter !== emptyValuesFilter);
|
|
141301
|
-
if (additionalAttributeFilters.length === 0) return;
|
|
141302
|
-
const withMap = new import_dist.YAMLMap();
|
|
141303
|
-
map.add(new import_dist.Pair("with", withMap));
|
|
141304
|
-
additionalAttributeFilters?.forEach((filter) => {
|
|
141305
|
-
const converted = declarativeFilterToYaml(entities, filter, getUniqueKey, void 0, errorContext);
|
|
141306
|
-
if (!converted) return;
|
|
141307
|
-
withMap.add(new import_dist.Pair(converted.key, converted.yaml));
|
|
141308
|
-
});
|
|
141309
|
-
}
|
|
141310
|
-
/** @internal */
|
|
141311
|
-
function declarativeAbsoluteDateFilterToYaml(absoluteDateFilter, connectedAttributeFilters = [], entities, getUniqueKey, errorContext) {
|
|
141312
|
-
const map = new import_dist.YAMLMap();
|
|
141313
|
-
map.add(new import_dist.Pair("type", "date_filter"));
|
|
141314
|
-
map.add(new import_dist.Pair("from", absoluteDateFilter.from));
|
|
141315
|
-
map.add(new import_dist.Pair("to", absoluteDateFilter.to));
|
|
141316
|
-
const id = getIdentifier(absoluteDateFilter.dataSet, true, updateErrorContext(errorContext, { path: ["dateSet"] }));
|
|
141317
|
-
map.add(new import_dist.Pair("using", id));
|
|
141318
|
-
processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey, errorContext);
|
|
141319
|
-
return map;
|
|
141320
|
-
}
|
|
141321
|
-
function isRelativeDateFilterAllTime(relativeDateFilter) {
|
|
141322
|
-
const { granularity, from, to } = relativeDateFilter;
|
|
141323
|
-
if (granularity === "ALL_TIME_GRANULARITY") return true;
|
|
141324
|
-
return granularity === "GDC.time.year" && from === void 0 && to === void 0;
|
|
141325
|
-
}
|
|
141326
|
-
/** @internal */
|
|
141327
|
-
function declarativeRelativeDateFilterToYaml(relativeDateFilter, connectedAttributeFilters = [], entities, getUniqueKey, errorContext) {
|
|
141328
|
-
const map = new import_dist.YAMLMap();
|
|
141329
|
-
map.add(new import_dist.Pair("type", "date_filter"));
|
|
141330
|
-
if (isRelativeDateFilterAllTime(relativeDateFilter)) {} else {
|
|
141331
|
-
if (relativeDateFilter.granularity) map.add(new import_dist.Pair("granularity", parseGranularity(relativeDateFilter.granularity)));
|
|
141332
|
-
if (relativeDateFilter.from !== void 0 && relativeDateFilter.to !== void 0) {
|
|
141333
|
-
map.add(new import_dist.Pair("from", relativeDateFilter.from));
|
|
141334
|
-
map.add(new import_dist.Pair("to", relativeDateFilter.to));
|
|
141335
|
-
}
|
|
141336
|
-
}
|
|
141337
|
-
const id = getIdentifier(relativeDateFilter.dataSet, true, updateErrorContext(errorContext, { path: ["dataSet"] }));
|
|
141338
|
-
map.add(new import_dist.Pair("using", id));
|
|
141339
|
-
processConnectedAttributeFilters(map, connectedAttributeFilters, entities, getUniqueKey, errorContext);
|
|
141340
|
-
return map;
|
|
141341
|
-
}
|
|
141342
|
-
/** @internal */
|
|
141343
|
-
function declarativePositiveAttributeFilterToYaml(entities, attributeFilter, errorContext) {
|
|
141344
|
-
const map = new import_dist.YAMLMap();
|
|
141345
|
-
map.add(new import_dist.Pair("type", "attribute_filter"));
|
|
141346
|
-
const id = getIdentifier(attributeFilter.displayForm, void 0, updateErrorContext(errorContext, { path: ["displayForm"] }));
|
|
141347
|
-
map.add(new import_dist.Pair("using", id));
|
|
141348
|
-
if (isAttributeElementsByValue(attributeFilter.in)) {
|
|
141349
|
-
const values = attributeFilter.in.values.filter((v) => v !== null && v !== void 0);
|
|
141350
|
-
map.add(new import_dist.Pair("state", new import_dist.Pair("include", parseDateValues(entities, id, values))));
|
|
141351
|
-
}
|
|
141352
|
-
return map;
|
|
141353
|
-
}
|
|
141354
|
-
/** @internal */
|
|
141355
|
-
function declarativeNegativeAttributeFilterToYaml(entities, attributeFilter, errorContext) {
|
|
141356
|
-
const map = new import_dist.YAMLMap();
|
|
141357
|
-
map.add(new import_dist.Pair("type", "attribute_filter"));
|
|
141358
|
-
const id = getIdentifier(attributeFilter.displayForm, void 0, updateErrorContext(errorContext, { path: ["displayForm"] }));
|
|
141359
|
-
map.add(new import_dist.Pair("using", id));
|
|
141360
|
-
if (isAttributeElementsByValue(attributeFilter.notIn)) {
|
|
141361
|
-
const values = attributeFilter.notIn.values.filter((v) => v !== null && v !== void 0);
|
|
141362
|
-
if (values.length > 0) map.add(new import_dist.Pair("state", new import_dist.Pair("exclude", parseDateValues(entities, id, values))));
|
|
141363
|
-
}
|
|
141364
|
-
return map;
|
|
141365
|
-
}
|
|
141366
|
-
function declarativeArbitraryAttributeFilterToYaml(attributeFilter, errorContext) {
|
|
141367
|
-
const map = new import_dist.YAMLMap();
|
|
141368
|
-
map.add(new import_dist.Pair("type", "text_filter"));
|
|
141369
|
-
map.add(new import_dist.Pair("using", getIdentifier(attributeFilter.label, void 0, updateErrorContext(errorContext, { path: ["label"] }))));
|
|
141370
|
-
map.add(new import_dist.Pair("condition", attributeFilter.negativeSelection ? "isNot" : "is"));
|
|
141371
|
-
map.add(new import_dist.Pair("values", attributeFilter.values));
|
|
141372
|
-
return map;
|
|
141373
|
-
}
|
|
141374
|
-
function declarativeMatchAttributeFilterToYaml(attributeFilter, errorContext) {
|
|
141375
|
-
const map = new import_dist.YAMLMap();
|
|
141376
|
-
map.add(new import_dist.Pair("type", "text_filter"));
|
|
141377
|
-
map.add(new import_dist.Pair("using", getIdentifier(attributeFilter.label, void 0, updateErrorContext(errorContext, { path: ["label"] }))));
|
|
141378
|
-
map.add(new import_dist.Pair("condition", matchConditionToYaml(attributeFilter.operator, attributeFilter.negativeSelection)));
|
|
141379
|
-
map.add(new import_dist.Pair("value", attributeFilter.literal));
|
|
141380
|
-
if (attributeFilter.caseSensitive !== void 0) map.add(new import_dist.Pair("case_sensitive", attributeFilter.caseSensitive));
|
|
141381
|
-
return map;
|
|
141382
|
-
}
|
|
141383
|
-
function addSingleConditionToYaml(map, condition) {
|
|
141384
|
-
if (isComparisonCondition(condition)) {
|
|
141385
|
-
const comp = condition.comparison;
|
|
141386
|
-
map.add(new import_dist.Pair("condition", comp.operator.toUpperCase()));
|
|
141387
|
-
map.add(new import_dist.Pair("value", comp.value));
|
|
141388
|
-
map.add(new import_dist.Pair("null_values_as_zero", comp.treatNullValuesAs !== void 0));
|
|
141389
|
-
} else if (isRangeCondition(condition)) {
|
|
141390
|
-
const range = condition.range;
|
|
141391
|
-
map.add(new import_dist.Pair("condition", range.operator.toUpperCase()));
|
|
141392
|
-
map.add(new import_dist.Pair("from", range.from));
|
|
141393
|
-
map.add(new import_dist.Pair("to", range.to));
|
|
141394
|
-
map.add(new import_dist.Pair("null_values_as_zero", range.treatNullValuesAs !== void 0));
|
|
141395
|
-
}
|
|
141396
|
-
}
|
|
141397
|
-
function addConditionToYamlMap(conditionMap, condition) {
|
|
141398
|
-
let hasTreatNullValues = false;
|
|
141399
|
-
if (isComparisonCondition(condition)) {
|
|
141400
|
-
const comp = condition.comparison;
|
|
141401
|
-
conditionMap.add(new import_dist.Pair("condition", comp.operator.toUpperCase()));
|
|
141402
|
-
conditionMap.add(new import_dist.Pair("value", comp.value));
|
|
141403
|
-
if (comp.treatNullValuesAs !== void 0) hasTreatNullValues = true;
|
|
141404
|
-
} else if (isRangeCondition(condition)) {
|
|
141405
|
-
const range = condition.range;
|
|
141406
|
-
conditionMap.add(new import_dist.Pair("condition", range.operator.toUpperCase()));
|
|
141407
|
-
conditionMap.add(new import_dist.Pair("from", range.from));
|
|
141408
|
-
conditionMap.add(new import_dist.Pair("to", range.to));
|
|
141409
|
-
if (range.treatNullValuesAs !== void 0) hasTreatNullValues = true;
|
|
141410
|
-
}
|
|
141411
|
-
return hasTreatNullValues;
|
|
141412
|
-
}
|
|
141413
|
-
/** @internal */
|
|
141414
|
-
function declarativeMeasureValueFilterToYaml$1(measureValueFilter, errorContext) {
|
|
141415
|
-
const map = new import_dist.YAMLMap();
|
|
141416
|
-
map.add(new import_dist.Pair("type", "metric_value_filter"));
|
|
141417
|
-
if (isLocalIdRef(measureValueFilter.measure)) map.add(new import_dist.Pair("using", measureValueFilter.measure.localIdentifier));
|
|
141418
|
-
else map.add(new import_dist.Pair("using", getIdentifier(measureValueFilter.measure, void 0, updateErrorContext(errorContext, { path: ["measure"] }))));
|
|
141419
|
-
if (measureValueFilter.conditions && measureValueFilter.conditions.length > 1) {
|
|
141420
|
-
const conditionsSeq = new import_dist.YAMLSeq();
|
|
141421
|
-
let treatNullValuesAsZero = false;
|
|
141422
|
-
measureValueFilter.conditions.forEach((cond) => {
|
|
141423
|
-
const conditionMap = new import_dist.YAMLMap();
|
|
141424
|
-
if (addConditionToYamlMap(conditionMap, cond)) treatNullValuesAsZero = true;
|
|
141425
|
-
conditionsSeq.add(conditionMap);
|
|
141426
|
-
});
|
|
141427
|
-
map.add(new import_dist.Pair("conditions", conditionsSeq));
|
|
141428
|
-
if (treatNullValuesAsZero) map.add(new import_dist.Pair("null_values_as_zero", true));
|
|
141429
|
-
} else if (measureValueFilter.conditions?.length === 1) addSingleConditionToYaml(map, measureValueFilter.conditions[0]);
|
|
141430
|
-
else if (measureValueFilter.condition) addSingleConditionToYaml(map, measureValueFilter.condition);
|
|
141431
|
-
if (measureValueFilter.dimensionality && Array.isArray(measureValueFilter.dimensionality)) {
|
|
141432
|
-
const dimensionalitySeq = new import_dist.YAMLSeq();
|
|
141433
|
-
measureValueFilter.dimensionality.forEach((item) => {
|
|
141434
|
-
if (isLocalIdRef(item)) dimensionalitySeq.add(item.localIdentifier);
|
|
141435
|
-
else dimensionalitySeq.add(getIdentifier(item));
|
|
141436
|
-
});
|
|
141437
|
-
map.add(new import_dist.Pair("dimensionality", dimensionalitySeq));
|
|
141438
|
-
}
|
|
141439
|
-
return map;
|
|
141440
|
-
}
|
|
141441
|
-
/** @internal */
|
|
141442
|
-
function declarativeRankingFilterToYaml(rankingFilter, errorContext) {
|
|
141443
|
-
const map = new import_dist.YAMLMap();
|
|
141444
|
-
map.add(new import_dist.Pair("type", "ranking_filter"));
|
|
141445
|
-
if (isLocalIdRef(rankingFilter.measure)) map.add(new import_dist.Pair("using", rankingFilter.measure.localIdentifier));
|
|
141446
|
-
else map.add(new import_dist.Pair("using", getIdentifier(rankingFilter.measure, void 0, updateErrorContext(errorContext, { path: ["measure"] }))));
|
|
141447
|
-
if (rankingFilter.operator === "TOP") map.add(new import_dist.Pair("top", rankingFilter.value));
|
|
141448
|
-
if (rankingFilter.operator === "BOTTOM") map.add(new import_dist.Pair("bottom", rankingFilter.value));
|
|
141449
|
-
if (rankingFilter.attributes?.[0]) {
|
|
141450
|
-
const first = rankingFilter.attributes[0];
|
|
141451
|
-
if (isLocalIdRef(first)) map.add(new import_dist.Pair("attribute", first.localIdentifier));
|
|
141452
|
-
else map.add(new import_dist.Pair("attribute", getIdentifier(first)));
|
|
141453
|
-
}
|
|
141454
|
-
if (rankingFilter.strictLimitOfRows !== void 0) map.add(new import_dist.Pair("strict_limit_of_rows", rankingFilter.strictLimitOfRows));
|
|
141455
|
-
return map;
|
|
141456
|
-
}
|
|
141457
141554
|
/** @internal */
|
|
141458
141555
|
function declarativeSortsToYaml(sorts, _errorContext) {
|
|
141459
141556
|
const sortsArray = [];
|
|
@@ -141498,151 +141595,151 @@ function declarativeMeasureSortToYaml(sort) {
|
|
|
141498
141595
|
return map;
|
|
141499
141596
|
}
|
|
141500
141597
|
function declarativeVisTableToYaml(doc, def, report, _context) {
|
|
141501
|
-
const metrics = report.
|
|
141598
|
+
const metrics = report.buckets.consume("measures");
|
|
141502
141599
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141503
|
-
const attribute = report.
|
|
141600
|
+
const attribute = report.buckets.consume("attribute");
|
|
141504
141601
|
if (attribute && attribute.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(attribute)));
|
|
141505
|
-
const columns = report.
|
|
141602
|
+
const columns = report.buckets.consume("columns");
|
|
141506
141603
|
if (columns && columns.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(columns)));
|
|
141507
141604
|
const config = table.load(def.properties);
|
|
141508
141605
|
if (config) doc.add(config);
|
|
141509
141606
|
}
|
|
141510
141607
|
function declarativeVisBarToYaml(doc, def, report, _errorContext) {
|
|
141511
|
-
const metrics = report.
|
|
141608
|
+
const metrics = report.buckets.consume("measures");
|
|
141512
141609
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141513
|
-
const view = report.
|
|
141610
|
+
const view = report.buckets.consume("view");
|
|
141514
141611
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141515
|
-
const stack = report.
|
|
141612
|
+
const stack = report.buckets.consume("stack");
|
|
141516
141613
|
if (stack && stack.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(stack)));
|
|
141517
141614
|
const config = barChart.load(def.properties);
|
|
141518
141615
|
if (config) doc.add(config);
|
|
141519
141616
|
}
|
|
141520
141617
|
function declarativeVisColumnToYaml(doc, def, report, _errorContext) {
|
|
141521
|
-
const metrics = report.
|
|
141618
|
+
const metrics = report.buckets.consume("measures");
|
|
141522
141619
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141523
|
-
const view = report.
|
|
141620
|
+
const view = report.buckets.consume("view");
|
|
141524
141621
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141525
|
-
const stack = report.
|
|
141622
|
+
const stack = report.buckets.consume("stack");
|
|
141526
141623
|
if (stack && stack.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(stack)));
|
|
141527
141624
|
const config = columnChart.load(def.properties);
|
|
141528
141625
|
if (config) doc.add(config);
|
|
141529
141626
|
}
|
|
141530
141627
|
function declarativeVisLineToYaml(doc, def, report, _errorContext) {
|
|
141531
|
-
const metrics = report.
|
|
141628
|
+
const metrics = report.buckets.consume("measures");
|
|
141532
141629
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141533
|
-
const trend = report.
|
|
141630
|
+
const trend = report.buckets.consume("trend");
|
|
141534
141631
|
if (trend && trend.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(trend)));
|
|
141535
|
-
const segment = report.
|
|
141632
|
+
const segment = report.buckets.consume("segment");
|
|
141536
141633
|
if (segment && segment.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141537
141634
|
const config = lineChart.load(def.properties);
|
|
141538
141635
|
if (config) doc.add(config);
|
|
141539
141636
|
}
|
|
141540
141637
|
function declarativeVisRadarToYaml(doc, def, report, _errorContext) {
|
|
141541
|
-
const metrics = report.
|
|
141638
|
+
const metrics = report.buckets.consume("measures");
|
|
141542
141639
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141543
|
-
const trend = report.
|
|
141640
|
+
const trend = report.buckets.consume("trend");
|
|
141544
141641
|
if (trend && trend.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(trend)));
|
|
141545
|
-
const segment = report.
|
|
141642
|
+
const segment = report.buckets.consume("segment");
|
|
141546
141643
|
if (segment && segment.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141547
141644
|
const config = radarChart.load(def.properties);
|
|
141548
141645
|
if (config) doc.add(config);
|
|
141549
141646
|
}
|
|
141550
141647
|
function declarativeVisAreaToYaml(doc, def, report, _errorContext) {
|
|
141551
|
-
const metrics = report.
|
|
141648
|
+
const metrics = report.buckets.consume("measures");
|
|
141552
141649
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141553
|
-
const view = report.
|
|
141650
|
+
const view = report.buckets.consume("view");
|
|
141554
141651
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141555
|
-
const stack = report.
|
|
141652
|
+
const stack = report.buckets.consume("stack");
|
|
141556
141653
|
if (stack && stack.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(stack)));
|
|
141557
141654
|
const config = areaChart.load(def.properties);
|
|
141558
141655
|
if (config) doc.add(config);
|
|
141559
141656
|
}
|
|
141560
141657
|
function declarativeVisScatterToYaml(doc, def, report, _errorContext) {
|
|
141561
|
-
const metrics1 = report.
|
|
141562
|
-
const metrics2 = report.
|
|
141658
|
+
const metrics1 = report.buckets.consume("measures");
|
|
141659
|
+
const metrics2 = report.buckets.consume("secondary_measures");
|
|
141563
141660
|
const metrics = {
|
|
141564
141661
|
items: cleanUpItems([...metrics1?.items.length ? metrics1.items : [null], ...metrics2?.items.length ? metrics2.items : [null]]),
|
|
141565
141662
|
type: "measures"
|
|
141566
141663
|
};
|
|
141567
141664
|
if (metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141568
|
-
const attributes = report.
|
|
141665
|
+
const attributes = report.buckets.consume("attribute");
|
|
141569
141666
|
if (attributes && attributes.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(attributes)));
|
|
141570
|
-
const segments = report.
|
|
141667
|
+
const segments = report.buckets.consume("segment");
|
|
141571
141668
|
if (segments && segments.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(segments)));
|
|
141572
141669
|
const config = scatterChart.load(def.properties);
|
|
141573
141670
|
if (config) doc.add(config);
|
|
141574
141671
|
}
|
|
141575
141672
|
function declarativeVisBubbleToYaml(doc, def, report, _errorContext) {
|
|
141576
|
-
const metrics1 = report.
|
|
141577
|
-
const metrics2 = report.
|
|
141673
|
+
const metrics1 = report.buckets.consume("measures");
|
|
141674
|
+
const metrics2 = report.buckets.consume("secondary_measures");
|
|
141578
141675
|
const metrics = {
|
|
141579
141676
|
items: cleanUpItems([...metrics1?.items.length ? metrics1.items : [null], ...metrics2?.items.length ? metrics2.items : [null]]),
|
|
141580
141677
|
type: "measures"
|
|
141581
141678
|
};
|
|
141582
141679
|
if (metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141583
|
-
const view = report.
|
|
141680
|
+
const view = report.buckets.consume("view");
|
|
141584
141681
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141585
|
-
const tertiaryMetrics = report.
|
|
141682
|
+
const tertiaryMetrics = report.buckets.consume("tertiary_measures");
|
|
141586
141683
|
if (tertiaryMetrics && tertiaryMetrics.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(tertiaryMetrics)));
|
|
141587
141684
|
const config = bubbleChart.load(def.properties);
|
|
141588
141685
|
if (config) doc.add(config);
|
|
141589
141686
|
}
|
|
141590
141687
|
function declarativeVisPieToYaml(doc, def, report, _errorContext) {
|
|
141591
|
-
const metrics = report.
|
|
141688
|
+
const metrics = report.buckets.consume("measures");
|
|
141592
141689
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141593
|
-
const view = report.
|
|
141690
|
+
const view = report.buckets.consume("view");
|
|
141594
141691
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141595
141692
|
const config = pieChart.load(def.properties);
|
|
141596
141693
|
if (config) doc.add(config);
|
|
141597
141694
|
}
|
|
141598
141695
|
function declarativeVisDonutToYaml(doc, def, report, _errorContext) {
|
|
141599
|
-
const metrics = report.
|
|
141696
|
+
const metrics = report.buckets.consume("measures");
|
|
141600
141697
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141601
|
-
const view = report.
|
|
141698
|
+
const view = report.buckets.consume("view");
|
|
141602
141699
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141603
141700
|
const config = donutChart.load(def.properties);
|
|
141604
141701
|
if (config) doc.add(config);
|
|
141605
141702
|
}
|
|
141606
141703
|
function declarativeVisTreemapToYaml(doc, def, report, _errorContext) {
|
|
141607
|
-
const metrics = report.
|
|
141704
|
+
const metrics = report.buckets.consume("measures");
|
|
141608
141705
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141609
|
-
const view = report.
|
|
141706
|
+
const view = report.buckets.consume("view");
|
|
141610
141707
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141611
|
-
const segment = report.
|
|
141708
|
+
const segment = report.buckets.consume("segment");
|
|
141612
141709
|
if (segment && segment.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141613
141710
|
const config = treemapChart.load(def.properties);
|
|
141614
141711
|
if (config) doc.add(config);
|
|
141615
141712
|
}
|
|
141616
141713
|
function declarativeVisPyramidToYaml(doc, def, report, _errorContext) {
|
|
141617
|
-
const metrics = report.
|
|
141714
|
+
const metrics = report.buckets.consume("measures");
|
|
141618
141715
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141619
|
-
const view = report.
|
|
141716
|
+
const view = report.buckets.consume("view");
|
|
141620
141717
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141621
141718
|
const config = pyramidChart.load(def.properties);
|
|
141622
141719
|
if (config) doc.add(config);
|
|
141623
141720
|
}
|
|
141624
141721
|
function declarativeVisFunnelToYaml(doc, def, report, _errorContext) {
|
|
141625
|
-
const metrics = report.
|
|
141722
|
+
const metrics = report.buckets.consume("measures");
|
|
141626
141723
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141627
|
-
const view = report.
|
|
141724
|
+
const view = report.buckets.consume("view");
|
|
141628
141725
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141629
141726
|
const config = funnelChart.load(def.properties);
|
|
141630
141727
|
if (config) doc.add(config);
|
|
141631
141728
|
}
|
|
141632
141729
|
function declarativeVisHeatmapToYaml(doc, def, report, _errorContext) {
|
|
141633
|
-
const metrics = report.
|
|
141730
|
+
const metrics = report.buckets.consume("measures");
|
|
141634
141731
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141635
|
-
const view = report.
|
|
141732
|
+
const view = report.buckets.consume("view");
|
|
141636
141733
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141637
|
-
const stack = report.
|
|
141734
|
+
const stack = report.buckets.consume("stack");
|
|
141638
141735
|
if (stack && stack.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(stack)));
|
|
141639
141736
|
const config = heatmapChart.load(def.properties);
|
|
141640
141737
|
if (config) doc.add(config);
|
|
141641
141738
|
}
|
|
141642
141739
|
function declarativeVisBulletToYaml(doc, def, report, _errorContext) {
|
|
141643
|
-
const metrics1 = report.
|
|
141644
|
-
const metrics2 = report.
|
|
141645
|
-
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");
|
|
141646
141743
|
const metrics = {
|
|
141647
141744
|
items: cleanUpItems([
|
|
141648
141745
|
...metrics1?.items.length ? metrics1.items : [null],
|
|
@@ -141652,24 +141749,24 @@ function declarativeVisBulletToYaml(doc, def, report, _errorContext) {
|
|
|
141652
141749
|
type: "measures"
|
|
141653
141750
|
};
|
|
141654
141751
|
if (metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141655
|
-
const view = report.
|
|
141752
|
+
const view = report.buckets.consume("view");
|
|
141656
141753
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141657
141754
|
const config = bulletChart.load(def.properties);
|
|
141658
141755
|
if (config) doc.add(config);
|
|
141659
141756
|
}
|
|
141660
141757
|
function declarativeVisWaterfallToYaml(doc, def, report, _errorContext) {
|
|
141661
|
-
const metrics = report.
|
|
141758
|
+
const metrics = report.buckets.consume("measures");
|
|
141662
141759
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141663
|
-
const view = report.
|
|
141760
|
+
const view = report.buckets.consume("view");
|
|
141664
141761
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141665
141762
|
const config = waterfallChart.load(def.properties);
|
|
141666
141763
|
if (config) doc.add(config);
|
|
141667
141764
|
}
|
|
141668
141765
|
function declarativeVisDependencyWheelToYaml(doc, def, report, _errorContext) {
|
|
141669
|
-
const metrics = report.
|
|
141766
|
+
const metrics = report.buckets.consume("measures");
|
|
141670
141767
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141671
|
-
const from = report.
|
|
141672
|
-
const to = report.
|
|
141768
|
+
const from = report.buckets.consume("attribute_from");
|
|
141769
|
+
const to = report.buckets.consume("attribute_to");
|
|
141673
141770
|
const view = {
|
|
141674
141771
|
items: cleanUpItems([...from?.items.length ? from.items : [null], ...to?.items.length ? to.items : [null]]),
|
|
141675
141772
|
type: "view"
|
|
@@ -141679,10 +141776,10 @@ function declarativeVisDependencyWheelToYaml(doc, def, report, _errorContext) {
|
|
|
141679
141776
|
if (config) doc.add(config);
|
|
141680
141777
|
}
|
|
141681
141778
|
function declarativeVisSankeyToYaml(doc, def, report, _errorContext) {
|
|
141682
|
-
const metrics = report.
|
|
141779
|
+
const metrics = report.buckets.consume("measures");
|
|
141683
141780
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141684
|
-
const from = report.
|
|
141685
|
-
const to = report.
|
|
141781
|
+
const from = report.buckets.consume("attribute_from");
|
|
141782
|
+
const to = report.buckets.consume("attribute_to");
|
|
141686
141783
|
const view = {
|
|
141687
141784
|
items: cleanUpItems([...from?.items.length ? from.items : [null], ...to?.items.length ? to.items : [null]]),
|
|
141688
141785
|
type: "view"
|
|
@@ -141692,8 +141789,8 @@ function declarativeVisSankeyToYaml(doc, def, report, _errorContext) {
|
|
|
141692
141789
|
if (config) doc.add(config);
|
|
141693
141790
|
}
|
|
141694
141791
|
function declarativeVisHeadlineToYaml(doc, def, report, _errorContext) {
|
|
141695
|
-
const metrics1 = report.
|
|
141696
|
-
const metrics2 = report.
|
|
141792
|
+
const metrics1 = report.buckets.consume("measures");
|
|
141793
|
+
const metrics2 = report.buckets.consume("secondary_measures");
|
|
141697
141794
|
const metrics = {
|
|
141698
141795
|
items: [...metrics1?.items ?? [null], ...metrics2?.items ?? []],
|
|
141699
141796
|
type: "measures"
|
|
@@ -141703,51 +141800,51 @@ function declarativeVisHeadlineToYaml(doc, def, report, _errorContext) {
|
|
|
141703
141800
|
if (config) doc.add(config);
|
|
141704
141801
|
}
|
|
141705
141802
|
function declarativeVisComboToYaml(doc, def, report, _errorContext) {
|
|
141706
|
-
const metrics1 = addAxisTypeToGroup(report.
|
|
141707
|
-
const metrics2 = addAxisTypeToGroup(report.
|
|
141803
|
+
const metrics1 = addAxisTypeToGroup(report.buckets.consume("measures"), "primary");
|
|
141804
|
+
const metrics2 = addAxisTypeToGroup(report.buckets.consume("secondary_measures"), "secondary");
|
|
141708
141805
|
const metrics = {
|
|
141709
141806
|
items: [...metrics1?.items ?? [], ...metrics2?.items ?? []],
|
|
141710
141807
|
type: "measures"
|
|
141711
141808
|
};
|
|
141712
141809
|
if (metrics && metrics.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141713
|
-
const view = report.
|
|
141810
|
+
const view = report.buckets.consume("view");
|
|
141714
141811
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141715
141812
|
const config = comboChart.load(def.properties);
|
|
141716
141813
|
if (config) doc.add(config);
|
|
141717
141814
|
}
|
|
141718
|
-
function addPushpinBucketsToYaml(target,
|
|
141719
|
-
const sizeBucket =
|
|
141720
|
-
const colorBucket =
|
|
141815
|
+
function addPushpinBucketsToYaml(target, buckets) {
|
|
141816
|
+
const sizeBucket = buckets.consume("size");
|
|
141817
|
+
const colorBucket = buckets.consume("color");
|
|
141721
141818
|
const metrics = {
|
|
141722
141819
|
items: cleanUpItems([...sizeBucket?.items.length ? sizeBucket.items : [null], ...colorBucket?.items ? colorBucket.items : [null]]),
|
|
141723
141820
|
type: "measures"
|
|
141724
141821
|
};
|
|
141725
141822
|
if (metrics.items.length > 0) target.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141726
|
-
const location =
|
|
141823
|
+
const location = buckets.consume("location");
|
|
141727
141824
|
if (location && location.items.length > 0) target.add(entryWithSpace("view_by", groupToYaml(location)));
|
|
141728
|
-
const segment =
|
|
141825
|
+
const segment = buckets.consume("segment");
|
|
141729
141826
|
if (segment && segment.items.length > 0) target.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141730
141827
|
}
|
|
141731
|
-
function addGeoAreaBucketsToYaml(target,
|
|
141732
|
-
const colorBucket =
|
|
141828
|
+
function addGeoAreaBucketsToYaml(target, buckets) {
|
|
141829
|
+
const colorBucket = buckets.consume("color");
|
|
141733
141830
|
const metrics = {
|
|
141734
141831
|
items: cleanUpItems([...colorBucket?.items.length ? colorBucket.items : [null]]),
|
|
141735
141832
|
type: "measures"
|
|
141736
141833
|
};
|
|
141737
141834
|
if (metrics.items.length > 0) target.add(entryWithSpace("metrics", groupToYaml(metrics)));
|
|
141738
|
-
const area =
|
|
141835
|
+
const area = buckets.consume("area");
|
|
141739
141836
|
if (area && area.items.length > 0) target.add(entryWithSpace("view_by", groupToYaml(area)));
|
|
141740
|
-
const segment =
|
|
141837
|
+
const segment = buckets.consume("segment");
|
|
141741
141838
|
if (segment && segment.items.length > 0) target.add(entryWithSpace("segment_by", groupToYaml(segment)));
|
|
141742
141839
|
}
|
|
141743
141840
|
function declarativeVisGeoToYaml(doc, def, report, entities, errorContext) {
|
|
141744
|
-
addPushpinBucketsToYaml(doc, report.
|
|
141841
|
+
addPushpinBucketsToYaml(doc, report.buckets);
|
|
141745
141842
|
const config = geoChart.load(def.properties);
|
|
141746
141843
|
if (config) doc.add(config);
|
|
141747
141844
|
appendLayers(doc, def, entities, errorContext);
|
|
141748
141845
|
}
|
|
141749
141846
|
function declarativeVisGeoAreaToYaml(doc, def, report, entities, errorContext) {
|
|
141750
|
-
addGeoAreaBucketsToYaml(doc, report.
|
|
141847
|
+
addGeoAreaBucketsToYaml(doc, report.buckets);
|
|
141751
141848
|
const config = geoAreaChart.load(def.properties);
|
|
141752
141849
|
if (config) doc.add(config);
|
|
141753
141850
|
appendLayers(doc, def, entities, errorContext);
|
|
@@ -141759,11 +141856,11 @@ function appendLayers(doc, def, entities, errorContext) {
|
|
|
141759
141856
|
if (layers.items.length > 0) doc.add(entryWithSpace("layers", layers));
|
|
141760
141857
|
}
|
|
141761
141858
|
function declarativeVisRepeaterToYaml(doc, def, report, _errorContext) {
|
|
141762
|
-
const columnsMapped = addChartTypeToGroup(report.
|
|
141859
|
+
const columnsMapped = addChartTypeToGroup(report.buckets.consume("columns"), def.properties);
|
|
141763
141860
|
if (columnsMapped && columnsMapped.items.length > 0) doc.add(entryWithSpace("metrics", groupToYaml(columnsMapped)));
|
|
141764
|
-
const view = report.
|
|
141861
|
+
const view = report.buckets.consume("view");
|
|
141765
141862
|
if (view && view.items.length > 0) doc.add(entryWithSpace("view_by", groupToYaml(view)));
|
|
141766
|
-
const attribute = report.
|
|
141863
|
+
const attribute = report.buckets.consume("attribute");
|
|
141767
141864
|
if (attribute && attribute.items.length > 0) doc.add(entryWithSpace("segment_by", groupToYaml(attribute)));
|
|
141768
141865
|
const config = repeaterChart.load(def.properties);
|
|
141769
141866
|
if (config) doc.add(config);
|
|
@@ -141820,16 +141917,25 @@ function addChartTypeToGroup(group, config) {
|
|
|
141820
141917
|
})
|
|
141821
141918
|
};
|
|
141822
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
|
+
}
|
|
141823
141925
|
function declarativeLayersToYaml(entities, layersDefinition, errorContext) {
|
|
141824
141926
|
const layers = new import_dist.YAMLSeq();
|
|
141825
141927
|
layersDefinition.forEach((layer, li) => {
|
|
141826
|
-
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);
|
|
141827
141932
|
const layerKind = resolveLayerExportKind(layer.type, updateErrorContext(errorContext, { path: [li.toString(), "type"] }));
|
|
141828
141933
|
const layerMap = new import_dist.YAMLMap();
|
|
141829
141934
|
layerMap.add(new import_dist.Pair("id", layer.id));
|
|
141830
141935
|
if (layer.name) layerMap.add(new import_dist.Pair("title", layer.name));
|
|
141831
141936
|
if (layer.type) layerMap.add(new import_dist.Pair("type", layer.type));
|
|
141832
|
-
appendLayerBucketsForKind(layerMap,
|
|
141937
|
+
appendLayerBucketsForKind(layerMap, buckets, layerKind, updateErrorContext(errorContext, { path: [li.toString()] }));
|
|
141938
|
+
buckets.assertAllConsumed(updateErrorContext(errorContext, { path: [li.toString()] }));
|
|
141833
141939
|
addLayerConfig(layerMap, layerKind, layer.properties);
|
|
141834
141940
|
layers.add(layerMap);
|
|
141835
141941
|
});
|
|
@@ -141840,13 +141946,13 @@ function resolveLayerExportKind(rawLayerType, errorContext) {
|
|
|
141840
141946
|
if (rawLayerType === "area") return "area";
|
|
141841
141947
|
throw newError("core.layerTypeNotSupported", [rawLayerType ?? "<missing>"], errorContext);
|
|
141842
141948
|
}
|
|
141843
|
-
function appendLayerBucketsForKind(layerMap,
|
|
141949
|
+
function appendLayerBucketsForKind(layerMap, buckets, kind, errorContext) {
|
|
141844
141950
|
if (kind === "pushpin") {
|
|
141845
|
-
addPushpinBucketsToYaml(layerMap,
|
|
141951
|
+
addPushpinBucketsToYaml(layerMap, buckets);
|
|
141846
141952
|
return;
|
|
141847
141953
|
}
|
|
141848
141954
|
if (kind === "area") {
|
|
141849
|
-
addGeoAreaBucketsToYaml(layerMap,
|
|
141955
|
+
addGeoAreaBucketsToYaml(layerMap, buckets);
|
|
141850
141956
|
return;
|
|
141851
141957
|
}
|
|
141852
141958
|
throw newError("core.layerTypeNotSupported", [kind], errorContext);
|
|
@@ -141881,6 +141987,7 @@ function declarativeDashboardToYaml(entities, dashboard, filterContexts, context
|
|
|
141881
141987
|
if (content.disableUserFilterSave) doc.add(entryWithSpace("user_filters_save", false));
|
|
141882
141988
|
if (content.disableFilterViews) doc.add(entryWithSpace("filter_views", false));
|
|
141883
141989
|
if (content.disablePersistentFiltersAcrossTabs) doc.add(entryWithSpace("persistent_filters_across_tabs", false));
|
|
141990
|
+
if (content.timezoneConfig) doc.add(entryWithSpace("timezone_config", declarativeTimezoneConfigToYaml(content.timezoneConfig)));
|
|
141884
141991
|
const hasMultipleTabs = content.tabs && content.tabs.length > 1;
|
|
141885
141992
|
const hasSingleTabWithTitle = content.tabs?.length === 1 && content.tabs[0].title;
|
|
141886
141993
|
const shouldUseTabs = hasMultipleTabs || hasSingleTabWithTitle;
|
|
@@ -142035,6 +142142,13 @@ function declarativeRichTextWidgetToYaml(widget, size) {
|
|
|
142035
142142
|
if (size?.xl?.gridHeight) yamlWidget.add(new import_dist.Pair("rows", size.xl.gridHeight));
|
|
142036
142143
|
return yamlWidget;
|
|
142037
142144
|
}
|
|
142145
|
+
function declarativeTimezoneConfigToYaml(config) {
|
|
142146
|
+
return {
|
|
142147
|
+
...config.timezoneId ? { timezone_id: config.timezoneId } : {},
|
|
142148
|
+
...config.showTimezoneInfo === void 0 ? {} : { show_timezone_info: config.showTimezoneInfo },
|
|
142149
|
+
...config.allowUserOverrideInViewMode === void 0 ? {} : { allow_user_override_in_view_mode: config.allowUserOverrideInViewMode }
|
|
142150
|
+
};
|
|
142151
|
+
}
|
|
142038
142152
|
function declarativeVisualizationSwitcherWidgetToYaml(widget, size, entities, errorContext) {
|
|
142039
142153
|
const yamlWidget = new import_dist.YAMLMap();
|
|
142040
142154
|
if (widget.localIdentifier) yamlWidget.add(new import_dist.Pair("id", widget.localIdentifier));
|
|
@@ -146526,6 +146640,10 @@ const metadata_v1 = {
|
|
|
146526
146640
|
"type": "boolean",
|
|
146527
146641
|
"description": "Whether persistent filters across tabs are enabled for this dashboard. Defaults to true."
|
|
146528
146642
|
},
|
|
146643
|
+
"timezone_config": {
|
|
146644
|
+
"$ref": "#/$defs/timezoneConfig",
|
|
146645
|
+
"description": "Dashboard-level timezone configuration. If omitted, the workspace or organization timezone setting is used."
|
|
146646
|
+
},
|
|
146529
146647
|
"enable_section_headers": {
|
|
146530
146648
|
"type": "boolean",
|
|
146531
146649
|
"description": "Applies to the root layout. Whether all sections headers are enabled. Defaults to true."
|
|
@@ -151498,6 +151616,10 @@ const metadata_v1 = {
|
|
|
151498
151616
|
"type": "boolean",
|
|
151499
151617
|
"description": "Whether persistent filters across tabs are enabled for this dashboard. Defaults to true."
|
|
151500
151618
|
},
|
|
151619
|
+
"timezone_config": {
|
|
151620
|
+
"$ref": "#/$defs/timezoneConfig",
|
|
151621
|
+
"description": "Dashboard-level timezone configuration. If omitted, the workspace or organization timezone setting is used."
|
|
151622
|
+
},
|
|
151501
151623
|
"enable_section_headers": {
|
|
151502
151624
|
"type": "boolean",
|
|
151503
151625
|
"description": "Applies to the root layout. Whether all sections headers are enabled. Defaults to true."
|
|
@@ -151557,6 +151679,24 @@ const metadata_v1 = {
|
|
|
151557
151679
|
},
|
|
151558
151680
|
"required": ["id", "type"]
|
|
151559
151681
|
},
|
|
151682
|
+
"timezoneConfig": {
|
|
151683
|
+
"type": "object",
|
|
151684
|
+
"additionalProperties": false,
|
|
151685
|
+
"properties": {
|
|
151686
|
+
"timezone_id": {
|
|
151687
|
+
"$ref": "#/$defs/timezoneId",
|
|
151688
|
+
"description": "Dashboard default timezone. Use an IANA timezone ID or $browserDetected. If omitted, the workspace or organization timezone setting is used."
|
|
151689
|
+
},
|
|
151690
|
+
"show_timezone_info": {
|
|
151691
|
+
"type": "boolean",
|
|
151692
|
+
"description": "Whether the dashboard timezone indicator is visible."
|
|
151693
|
+
},
|
|
151694
|
+
"allow_user_override_in_view_mode": {
|
|
151695
|
+
"type": "boolean",
|
|
151696
|
+
"description": "Whether viewers can override the dashboard timezone for their current session."
|
|
151697
|
+
}
|
|
151698
|
+
}
|
|
151699
|
+
},
|
|
151560
151700
|
"section": {
|
|
151561
151701
|
"type": "object",
|
|
151562
151702
|
"additionalProperties": false,
|
|
@@ -151610,6 +151750,16 @@ const metadata_v1 = {
|
|
|
151610
151750
|
"sections"
|
|
151611
151751
|
]
|
|
151612
151752
|
},
|
|
151753
|
+
"timezoneId": {
|
|
151754
|
+
"description": "An IANA timezone ID (for example, Europe/Prague or UTC) or $browserDetected to use the viewer browser timezone.",
|
|
151755
|
+
"oneOf": [{
|
|
151756
|
+
"type": "string",
|
|
151757
|
+
"const": "$browserDetected"
|
|
151758
|
+
}, {
|
|
151759
|
+
"type": "string",
|
|
151760
|
+
"pattern": "^[A-Za-z][A-Za-z0-9_+.-]*(?:/[A-Za-z0-9_+.-]+)*$"
|
|
151761
|
+
}]
|
|
151762
|
+
},
|
|
151613
151763
|
"widget": {
|
|
151614
151764
|
"title": "Widget",
|
|
151615
151765
|
"type": "object",
|
|
@@ -159814,7 +159964,7 @@ async function open(state, emitter, file) {
|
|
|
159814
159964
|
//#endregion
|
|
159815
159965
|
//#region ../code/package.json
|
|
159816
159966
|
var name = "@gooddata/code";
|
|
159817
|
-
var version = "0.47.0-alpha.
|
|
159967
|
+
var version = "0.47.0-alpha.4";
|
|
159818
159968
|
//#endregion
|
|
159819
159969
|
//#region ../../../sdk/libs/api-client-tiger/src/axios.ts
|
|
159820
159970
|
/**
|
|
@@ -159836,7 +159986,7 @@ const _CONFIG = {
|
|
|
159836
159986
|
common: {
|
|
159837
159987
|
"X-Requested-With": "XMLHttpRequest",
|
|
159838
159988
|
"X-GDC-JS-PACKAGE": "@gooddata/api-client-tiger",
|
|
159839
|
-
"X-GDC-JS-PACKAGE-VERSION": "11.51.0-alpha.
|
|
159989
|
+
"X-GDC-JS-PACKAGE-VERSION": "11.51.0-alpha.4"
|
|
159840
159990
|
},
|
|
159841
159991
|
post: { "Content-Type": "application/json;charset=utf8" },
|
|
159842
159992
|
put: { "Content-Type": "application/json;charset=utf8" }
|