@gooddata/code-cli 0.50.0-alpha.0 → 0.50.0-alpha.1

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.
@@ -15,6 +15,7 @@ GoodData Analytics as Code allows you to represent metadata for analytical works
15
15
  - **Attribute label** is a non-numeric field in a dataset. It is always linked to an attribute.
16
16
  - **Date instance** (Date Dataset) is a representation of a date dimension.
17
17
  - **Metric** is an aggregation on top of facts and attribute labels. A single number that can be sliced ad-hoc when building a visualization.
18
+ - **Parameter** is a named, typed value that metrics reference instead of hardcoding a literal. Changing the parameter's default changes every metric that references it. Textual parameters can be defined as code.
18
19
  - **Multidimensional Analytical Query Language (MAQL)** a proprietary language used by GoodData for metrics definition.
19
20
  - **Semantic Layer** is LDM and Metrics combined.
20
21
  - **Visualization** - a data visualization built on top of Semantic Layer. I.e. a chart, graph or a table.
@@ -35,5 +36,6 @@ A typical folder structure for GoodData analytics project looks like this:
35
36
  - `{{ANALYTICS}}` - the root folder for the project
36
37
  - `{{ANALYTICS}}/datasets` - a folder with all datasets and date instances
37
38
  - `{{ANALYTICS}}/metrics` - a folder with all metrics
39
+ - `{{ANALYTICS}}/parameters` - a folder with all parameters
38
40
  - `{{ANALYTICS}}/visualisations` - a folder with all visualizations
39
41
  - `{{ANALYTICS}}/dashboards` - a folder with all dashboards
@@ -0,0 +1,40 @@
1
+ ---
2
+ description: Detailed information about GoodData parameters definition.
3
+ alwaysApply: false
4
+ ---
5
+ # Fields
6
+
7
+ On top of generic fields like `id`, `type` (always "parameter"), `title`, `description` and `tags`,
8
+ parameters support:
9
+ - `definition`: (object, required) the typed definition of the parameter.
10
+
11
+ # Definition
12
+
13
+ - `type`: (string, required) always "STRING". Only textual parameters can be defined as code.
14
+ - `defaultValue`: (string, required) the value used whenever the parameter is not overridden.
15
+ - `constraints`: (object) optional restrictions on the accepted values.
16
+
17
+ `constraints` accepts `minLength` and `maxLength` (both inclusive), or `allowedValues` - a non-empty
18
+ list of `{ value, title }` entries where `title` is optional and defaults to `value`. Length bounds
19
+ and `allowedValues` are mutually exclusive. Without `constraints`, the parameter accepts any
20
+ free-text value.
21
+
22
+ # Example
23
+
24
+ ```yaml
25
+ id: scenario
26
+ type: parameter
27
+
28
+ title: Scenario
29
+ description: Selects the planning scenario used in metric computation.
30
+
31
+ definition:
32
+ type: STRING
33
+ defaultValue: Actual
34
+ ```
35
+
36
+ # Usage
37
+
38
+ Metrics reference a parameter instead of hardcoding a literal, so changing the parameter's default
39
+ changes every metric that references it. A parameter cannot be deleted while a metric still
40
+ references it - remove the references first.
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.50.0-alpha.0";
37373
+ var version$1 = "0.50.0-alpha.1";
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) => {
@@ -102866,6 +102866,7 @@ var SpecificCoreErrorCode;
102866
102866
  (function(SpecificCoreErrorCode) {
102867
102867
  SpecificCoreErrorCode["UniquenessDatasetsId"] = "core.uniqueness.datasets.id";
102868
102868
  SpecificCoreErrorCode["UniquenessMetricsId"] = "core.uniqueness.metrics.id";
102869
+ SpecificCoreErrorCode["UniquenessParametersId"] = "core.uniqueness.parameters.id";
102869
102870
  SpecificCoreErrorCode["UniquenessVisualisationsId"] = "core.uniqueness.visualisations.id";
102870
102871
  SpecificCoreErrorCode["UniquenessDashboardsId"] = "core.uniqueness.dashboards.id";
102871
102872
  SpecificCoreErrorCode["UniquenessPluginId"] = "core.uniqueness.plugins.id";
@@ -103009,6 +103010,7 @@ const CoreErrorMessages$1 = {
103009
103010
  [CoreErrorCode.SqlIsNotRefreshedFromServer]: `SQL statement not loaded from server and need to be refreshed. Use "Run" button over the SQL statement to force retrieve new definition.`,
103010
103011
  [SpecificCoreErrorCode.UniquenessDatasetsId]: `There are more datasets with id "{0}". Use unique names for datasets.`,
103011
103012
  [SpecificCoreErrorCode.UniquenessMetricsId]: `There are more metrics with id "{0}". Use unique names for metrics.`,
103013
+ [SpecificCoreErrorCode.UniquenessParametersId]: `There are more parameters with id "{0}". Use unique names for parameters.`,
103012
103014
  [SpecificCoreErrorCode.UniquenessVisualisationsId]: `There are more visualisations with id "{0}". Use unique names for visualisations.`,
103013
103015
  [SpecificCoreErrorCode.UniquenessDashboardsId]: `There are more dashboards with id "{0}". Use unique names for dashboards.`,
103014
103016
  [SpecificCoreErrorCode.UniquenessPluginId]: `There are more plugins with id "{0}". Use unique names for plugins.`,
@@ -103085,6 +103087,7 @@ const CoreErrorTypes$1 = {
103085
103087
  [CoreErrorCode.MissingDataSourceId]: "MissingDataSourceId",
103086
103088
  [SpecificCoreErrorCode.UniquenessDatasetsId]: "UniquenessDatasetsId",
103087
103089
  [SpecificCoreErrorCode.UniquenessMetricsId]: "UniquenessMetricsId",
103090
+ [SpecificCoreErrorCode.UniquenessParametersId]: "UniquenessParametersId",
103088
103091
  [SpecificCoreErrorCode.UniquenessPluginId]: "UniquenessPluginId",
103089
103092
  [SpecificCoreErrorCode.UniquenessAttributeHierarchyId]: "UniquenessAttributeHierarchyId",
103090
103093
  [SpecificCoreErrorCode.UniquenessDashboardWidgetLocalId]: "UniquenessDashboardWidgetLocalId",
@@ -106494,10 +106497,14 @@ const SupportedReferenceTypes$1 = [
106494
106497
  "dataset",
106495
106498
  "attribute"
106496
106499
  ];
106497
- function parseReferenceObject$1(obj) {
106500
+ /** MAQL can additionally name a parameter; custom URLs and shorthand fields cannot. */
106501
+ const SupportedMaqlReferenceTypes = [...SupportedReferenceTypes$1, "parameter"];
106502
+ /** The id fragment of a `type/id` reference, shared by every pattern that matches one. */
106503
+ const REFERENCE_ID_PATTERN = "(?!\\.)[.A-Za-z0-9_-]{1,255}";
106504
+ function parseReferenceObject$1(obj, supported = SupportedReferenceTypes$1) {
106498
106505
  const [t, identifier] = obj?.split("/") ?? [];
106499
106506
  const type = t;
106500
- if (Boolean(type && identifier) && SupportedReferenceTypes$1.includes(type)) return {
106507
+ if (Boolean(type && identifier) && supported.includes(type)) return {
106501
106508
  identifier,
106502
106509
  type
106503
106510
  };
@@ -106572,6 +106579,7 @@ function referencePathResolve(obj, { resolved, match }) {
106572
106579
  const DatasetTypes$2 = ["dataset"];
106573
106580
  const DateDatasetTypes$2 = ["date"];
106574
106581
  const MetricTypes$1 = ["metric"];
106582
+ const ParameterTypes$1 = ["parameter"];
106575
106583
  const AttrTypes$1 = ["attribute"];
106576
106584
  const FactTypes$1 = ["fact"];
106577
106585
  const AggregatedFactTypes = ["aggregated_fact"];
@@ -106611,6 +106619,7 @@ const TypesAll = allReferenceTypes([
106611
106619
  "date",
106612
106620
  "dataset",
106613
106621
  "metric",
106622
+ "parameter",
106614
106623
  "area_chart",
106615
106624
  "bubble_chart",
106616
106625
  "bar_chart",
@@ -106668,6 +106677,10 @@ function isMetric(obj) {
106668
106677
  if (typeof obj === "object" && obj && "id" in obj && "type" in obj) return MetricTypes$1.includes(obj.type);
106669
106678
  return false;
106670
106679
  }
106680
+ function isParameter(obj) {
106681
+ if (typeof obj === "object" && obj && "id" in obj && "type" in obj) return ParameterTypes$1.includes(obj.type);
106682
+ return false;
106683
+ }
106671
106684
  function isManifest(obj) {
106672
106685
  return !!(typeof obj === "object" && obj && "profiles" in obj && "source_dir" in obj);
106673
106686
  }
@@ -135273,6 +135286,51 @@ function yamlMetricToDeclarative(input) {
135273
135286
  return output;
135274
135287
  }
135275
135288
  //#endregion
135289
+ //#region ../../../sdk/libs/sdk-code-convertors/src/utils/parameterUtils.ts
135290
+ /** @public */
135291
+ function isDeclarativeStringParameter(parameter) {
135292
+ return parameter.content.type === "STRING";
135293
+ }
135294
+ /**
135295
+ * Spreadable `constraints` entry for a parameter definition: present only when at least one
135296
+ * restriction is set, and never carrying a key whose value is undefined.
135297
+ */
135298
+ function optionalConstraints(constraints) {
135299
+ const defined = Object.fromEntries(Object.entries(constraints).filter(([, value]) => value !== void 0));
135300
+ return Object.keys(defined).length === 0 ? {} : { constraints: defined };
135301
+ }
135302
+ /** An allowed value as authored: `title` is optional and defaults to `value`, so it is only carried when set. */
135303
+ function toAllowedValue({ value, title }) {
135304
+ return title === void 0 ? { value } : {
135305
+ value,
135306
+ title
135307
+ };
135308
+ }
135309
+ //#endregion
135310
+ //#region ../../../sdk/libs/sdk-code-convertors/src/to/yamlParameterToDeclarative.ts
135311
+ /** @public */
135312
+ function yamlParameterToDeclarative(input) {
135313
+ return {
135314
+ id: input.id,
135315
+ title: input.title ?? convertIdToTitle$1(input.id),
135316
+ description: input.description ?? "",
135317
+ tags: input.tags ?? [],
135318
+ content: yamlParameterDefinitionToDeclarative(input.definition)
135319
+ };
135320
+ }
135321
+ function yamlParameterDefinitionToDeclarative(definition) {
135322
+ const { minLength, maxLength, allowedValues } = definition.constraints ?? {};
135323
+ return {
135324
+ type: "STRING",
135325
+ defaultValue: definition.defaultValue,
135326
+ ...optionalConstraints({
135327
+ minLength,
135328
+ maxLength,
135329
+ allowedValues: allowedValues?.length ? allowedValues.map(toAllowedValue) : void 0
135330
+ })
135331
+ };
135332
+ }
135333
+ //#endregion
135276
135334
  //#region ../../../sdk/libs/sdk-code-convertors/src/configs/utils.ts
135277
135335
  /** @public */
135278
135336
  function getValueOrDefault(value, defaultValue, type = "string", undefinedAsDefault = false) {
@@ -140179,6 +140237,8 @@ const DateDatasetTypes = ["date"];
140179
140237
  /** @internal */
140180
140238
  const MetricTypes = ["metric"];
140181
140239
  /** @internal */
140240
+ const ParameterTypes = ["parameter"];
140241
+ /** @internal */
140182
140242
  const DashboardTypes = ["dashboard"];
140183
140243
  /** @internal */
140184
140244
  const PluginTypes = ["plugin"];
@@ -140215,6 +140275,7 @@ const AllTypes = [
140215
140275
  ...DatasetTypes,
140216
140276
  ...DateDatasetTypes,
140217
140277
  ...MetricTypes,
140278
+ ...ParameterTypes,
140218
140279
  ...DashboardTypes,
140219
140280
  ...PluginTypes,
140220
140281
  ...VisualisationsTypes,
@@ -140741,7 +140802,7 @@ function yamlTimezoneConfigToDeclarative(input) {
140741
140802
  return {
140742
140803
  ...input.timezone_id ? { timezoneId: input.timezone_id } : {},
140743
140804
  ...input.show_timezone_info ? { showTimezoneInfo: input.show_timezone_info } : {},
140744
- ...typeof input.allow_user_override_in_view_mode === "boolean" ? { allowUserOverrideInViewMode: input.allow_user_override_in_view_mode } : {}
140805
+ ...input.allow_user_override_in_view_mode ? { allowUserOverrideInViewMode: input.allow_user_override_in_view_mode } : {}
140745
140806
  };
140746
140807
  }
140747
140808
  function isFilterGroup$1(filter) {
@@ -141028,6 +141089,12 @@ const METRIC_COMMENT = [
141028
141089
  " Read more about MAQL:",
141029
141090
  " https://www.gooddata.com/developers/cloud-native/doc/cloud/create-metrics/maql/"
141030
141091
  ].join("\n");
141092
+ const PARAMETER_COMMENT = [
141093
+ " A parameter is a named, typed value that metrics reference instead of hardcoding a literal.",
141094
+ " Changing the parameter's default changes every metric that references it, without editing their MAQL.",
141095
+ " Read more about parameters:",
141096
+ " https://www.gooddata.ai/docs/cloud/experimental-features/numeric-parameters/"
141097
+ ].join("\n");
141031
141098
  const VISUALISATION_COMMENT = [
141032
141099
  " A visualization is a visual representation of a user's analytical view of the data.",
141033
141100
  " You build visualizations from metrics, attributes, and optionally filters that are combined in a way to visualize a particular aspect of your data.",
@@ -141241,6 +141308,35 @@ function declarativeMetricToYaml(metric) {
141241
141308
  };
141242
141309
  }
141243
141310
  //#endregion
141311
+ //#region ../../../sdk/libs/sdk-code-convertors/src/from/declarativeParameterToYaml.ts
141312
+ /** @public */
141313
+ function declarativeParameterToYaml(parameter) {
141314
+ const doc = new import_dist.Document({
141315
+ type: "parameter",
141316
+ id: parameter.id
141317
+ });
141318
+ doc.commentBefore = PARAMETER_COMMENT;
141319
+ fillOptionalMetaFields(doc, parameter);
141320
+ doc.add(entryWithSpace("definition", doc.createNode(declarativeParameterDefinitionToYaml(parameter.content))));
141321
+ return {
141322
+ content: doc.toString({ lineWidth: 0 }),
141323
+ json: doc.toJSON()
141324
+ };
141325
+ }
141326
+ function declarativeParameterDefinitionToYaml(definition) {
141327
+ const { minLength, maxLength, allowedValues } = definition.constraints ?? {};
141328
+ const [first, ...rest] = allowedValues ?? [];
141329
+ return {
141330
+ type: "STRING",
141331
+ defaultValue: definition.defaultValue,
141332
+ ...optionalConstraints({
141333
+ minLength,
141334
+ maxLength,
141335
+ allowedValues: first ? [toAllowedValue(first), ...rest.map(toAllowedValue)] : void 0
141336
+ })
141337
+ };
141338
+ }
141339
+ //#endregion
141244
141340
  //#region ../../../sdk/libs/sdk-code-convertors/src/from/filtersToYaml.ts
141245
141341
  function detectEmptyValuesFilterType(filter) {
141246
141342
  const attributeElements = filterAttributeElements(filter);
@@ -142578,7 +142674,7 @@ function declarativeTimezoneConfigToYaml(config) {
142578
142674
  return {
142579
142675
  ...config.timezoneId ? { timezone_id: config.timezoneId } : {},
142580
142676
  ...config.showTimezoneInfo ? { show_timezone_info: config.showTimezoneInfo } : { show_timezone_info: false },
142581
- ...typeof config.allowUserOverrideInViewMode === "boolean" ? { allow_user_override_in_view_mode: config.allowUserOverrideInViewMode } : {}
142677
+ ...config.allowUserOverrideInViewMode ? { allow_user_override_in_view_mode: config.allowUserOverrideInViewMode } : { allow_user_override_in_view_mode: false }
142582
142678
  };
142583
142679
  }
142584
142680
  function declarativeVisualizationSwitcherWidgetToYaml(widget, size, entities, errorContext) {
@@ -143608,7 +143704,7 @@ function resolveAttributeHierarchyReferences(item) {
143608
143704
  }
143609
143705
  //#endregion
143610
143706
  //#region ../code/esm/features/references/resolve/metric.js
143611
- const ID_PATTERN = /(fact|label|metric|dataset|attribute)\/((?!\.)[.A-Za-z0-9_-]{1,255})/g;
143707
+ const ID_PATTERN = new RegExp(`(${SupportedMaqlReferenceTypes.join("|")})\\/(${REFERENCE_ID_PATTERN})`, "g");
143612
143708
  function resolveMetricReferences(item) {
143613
143709
  return resolveMaqlReferences(item.maql ?? "");
143614
143710
  }
@@ -143867,6 +143963,7 @@ function containsReference(item, ref) {
143867
143963
  ...isDashboard(item) ? [createReferenceObject(item.id, "dashboard")] : [],
143868
143964
  ...isPlugin(item) ? [createReferenceObject(item.id, "plugin")] : [],
143869
143965
  ...isMetric(item) ? [createReferenceObject(item.id, "metric")] : [],
143966
+ ...isParameter(item) ? [createReferenceObject(item.id, "parameter")] : [],
143870
143967
  ...isAttributeHierarchy(item) ? [createReferenceObject(item.id, "attribute_hierarchy")] : []
143871
143968
  ].some((item) => item.type === ref.type && item.identifier === ref.identifier);
143872
143969
  }
@@ -143876,7 +143973,8 @@ function collectItemReferences(item) {
143876
143973
  case "date": return resolveDatasetReferences$1(item);
143877
143974
  case "metric": return resolveMetricReferences(item);
143878
143975
  case "dashboard": return resolveDashboardReferences(item);
143879
- case "plugin": return [];
143976
+ case "plugin":
143977
+ case "parameter": return [];
143880
143978
  case "table":
143881
143979
  case "bar_chart":
143882
143980
  case "column_chart":
@@ -144155,18 +144253,20 @@ function convertDateTitle(item, gran) {
144155
144253
  //#endregion
144156
144254
  //#region ../code/esm/features/references/resolve/objects.js
144157
144255
  function resolveLdmObjects(files) {
144158
- const { metrics, datasets, dates } = files.reduce((prev, item) => {
144256
+ const { metrics, parameters, datasets, dates } = files.reduce((prev, item) => {
144159
144257
  if (isDataset$1(item)) prev.datasets.push(buildDataset(item));
144160
144258
  if (isDateDataset$1(item)) prev.dates.push(buildDate(item));
144161
144259
  if (isMetric(item)) prev.metrics.push(buildMetric(item));
144260
+ if (isParameter(item)) prev.parameters.push(buildParameter(item));
144162
144261
  return prev;
144163
144262
  }, {
144164
144263
  metrics: [],
144264
+ parameters: [],
144165
144265
  dates: [],
144166
144266
  datasets: []
144167
144267
  });
144168
144268
  const { attributes, facts } = extractFromDatasets(datasets);
144169
- return new LdmObjects(attributes, facts, metrics, [], dates, datasets);
144269
+ return new LdmObjects(attributes, facts, metrics, parameters, dates, datasets);
144170
144270
  }
144171
144271
  function extractFromDatasets(datasets) {
144172
144272
  const attributes = [];
@@ -144291,6 +144391,19 @@ function buildMetric(item) {
144291
144391
  groups: []
144292
144392
  };
144293
144393
  }
144394
+ function buildParameter(item) {
144395
+ return {
144396
+ type: "parameter",
144397
+ ...buildUriRef("parameter", item.id),
144398
+ id: item.id,
144399
+ description: item.description ?? "",
144400
+ title: item.title ?? convertIdToTitle(item.id),
144401
+ definition: item.definition,
144402
+ production: true,
144403
+ deprecated: false,
144404
+ unlisted: false
144405
+ };
144406
+ }
144294
144407
  function buildDate(item) {
144295
144408
  return {
144296
144409
  type: "dateDataset",
@@ -145658,6 +145771,15 @@ function resolveReferencesByObjectSource(references, source, opts) {
145658
145771
  remote: false
145659
145772
  };
145660
145773
  }
145774
+ case "parameter.id": {
145775
+ const [available, diagnostics] = resolveReferencesIds(references, ["parameter"]);
145776
+ return {
145777
+ available: withPrefix(isParameter(references.self) ? available.filter(filterBySelf(references.self?.id)) : available, "parameter", opts.typePrefix),
145778
+ ambiguous: getAmbiguous(available),
145779
+ diagnostics,
145780
+ remote: false
145781
+ };
145782
+ }
145661
145783
  case "dataset.field": {
145662
145784
  const [available, diagnostics] = resolveFieldsIds(references, ["dataset"]);
145663
145785
  return {
@@ -146109,62 +146231,22 @@ function getAffectedFiles(file, before, after) {
146109
146231
  //#region ../code/esm/features/references/update/objects.js
146110
146232
  function addObjectReferences(state, file, fileMode, json) {
146111
146233
  const refs = state.references;
146112
- if (isDataset$1(json)) {
146113
- const dataset = buildObj(file, json);
146114
- handleType(fileMode, () => {
146115
- updateVirtual(state, [...refs.virtual, dataset]);
146116
- }, () => {
146117
- updatePhysical(state, [...refs.physical, dataset]);
146118
- });
146119
- }
146120
- if (isDateDataset$1(json)) {
146121
- const dataset = buildObj(file, json);
146122
- handleType(fileMode, () => {
146123
- updateVirtual(state, [...refs.virtual, dataset]);
146124
- }, () => {
146125
- updatePhysical(state, [...refs.physical, dataset]);
146126
- });
146127
- }
146128
- if (isMetric(json)) {
146129
- const metric = buildObj(file, json);
146130
- handleType(fileMode, () => {
146131
- updateVirtual(state, [...refs.virtual, metric]);
146132
- }, () => {
146133
- updatePhysical(state, [...refs.physical, metric]);
146134
- });
146135
- }
146136
- if (isVisualisation(json)) {
146137
- const visualisation = buildObj(file, json);
146138
- handleType(fileMode, () => {
146139
- updateVirtual(state, [...refs.virtual, visualisation]);
146140
- }, () => {
146141
- updatePhysical(state, [...refs.physical, visualisation]);
146142
- });
146143
- }
146144
- if (isDashboard(json)) {
146145
- const dashboard = buildObj(file, json);
146146
- handleType(fileMode, () => {
146147
- updateVirtual(state, [...refs.virtual, dashboard]);
146148
- }, () => {
146149
- updatePhysical(state, [...refs.physical, dashboard]);
146150
- });
146151
- }
146152
- if (isPlugin(json)) {
146153
- const plugin = buildObj(file, json);
146154
- handleType(fileMode, () => {
146155
- updateVirtual(state, [...refs.virtual, plugin]);
146156
- }, () => {
146157
- updatePhysical(state, [...refs.physical, plugin]);
146158
- });
146159
- }
146160
- if (isAttributeHierarchy(json)) {
146161
- const hierarchy = buildObj(file, json);
146162
- handleType(fileMode, () => {
146163
- updateVirtual(state, [...refs.virtual, hierarchy]);
146164
- }, () => {
146165
- updatePhysical(state, [...refs.physical, hierarchy]);
146166
- });
146167
- }
146234
+ if (![
146235
+ isDataset$1,
146236
+ isDateDataset$1,
146237
+ isMetric,
146238
+ isParameter,
146239
+ isVisualisation,
146240
+ isDashboard,
146241
+ isPlugin,
146242
+ isAttributeHierarchy
146243
+ ].some((isType) => isType(json))) return;
146244
+ const object = buildObj(file, json);
146245
+ handleType(fileMode, () => {
146246
+ updateVirtual(state, [...refs.virtual, object]);
146247
+ }, () => {
146248
+ updatePhysical(state, [...refs.physical, object]);
146249
+ });
146168
146250
  }
146169
146251
  function buildObj(file, obj) {
146170
146252
  return {
@@ -146600,6 +146682,13 @@ const metadata_v1 = {
146600
146682
  },
146601
146683
  "then": { "$ref": "#/$global/gaac/attribute_hierarchy" }
146602
146684
  },
146685
+ {
146686
+ "if": {
146687
+ "properties": { "type": { "const": "parameter" } },
146688
+ "required": ["type"]
146689
+ },
146690
+ "then": { "$ref": "#/$global/gaac/parameter" }
146691
+ },
146603
146692
  {
146604
146693
  "if": {
146605
146694
  "properties": { "type": { "enum": [
@@ -146667,7 +146756,8 @@ const metadata_v1 = {
146667
146756
  "geo_area_chart",
146668
146757
  "repeater_chart",
146669
146758
  "radar_chart",
146670
- "attribute_hierarchy"
146759
+ "attribute_hierarchy",
146760
+ "parameter"
146671
146761
  ]
146672
146762
  } }
146673
146763
  }
@@ -146703,7 +146793,8 @@ const metadata_v1 = {
146703
146793
  "geo_area_chart",
146704
146794
  "repeater_chart",
146705
146795
  "radar_chart",
146706
- "attribute_hierarchy"
146796
+ "attribute_hierarchy",
146797
+ "parameter"
146707
146798
  ]
146708
146799
  } },
146709
146800
  required: ["type"],
@@ -147226,6 +147317,54 @@ const metadata_v1 = {
147226
147317
  "attributes"
147227
147318
  ]
147228
147319
  },
147320
+ "parameter": {
147321
+ "title": "Parameter",
147322
+ "type": "object",
147323
+ "additionalProperties": false,
147324
+ "properties": {
147325
+ "id": {
147326
+ "$ref": "#/$global/gaac/identifier",
147327
+ "description": "A unique identifier of the parameter.",
147328
+ "$semantic": [{
147329
+ "type": "uniqueness",
147330
+ "source": "parameter.id",
147331
+ "code": "core.uniqueness.parameters.id"
147332
+ }, {
147333
+ "type": "definition",
147334
+ "source": "parameter.id"
147335
+ }]
147336
+ },
147337
+ "type": {
147338
+ "type": "string",
147339
+ "enum": ["parameter"]
147340
+ },
147341
+ "title": {
147342
+ "$ref": "#/$global/gaac/title",
147343
+ "description": "An optional human readable title for the parameter. Will be derived from id if not provided explicitly."
147344
+ },
147345
+ "description": {
147346
+ "$ref": "#/$global/gaac/description",
147347
+ "description": "An optional description of the parameter."
147348
+ },
147349
+ "tags": {
147350
+ "$ref": "#/$global/gaac/tags",
147351
+ "description": "A list of strings - metadata tags of this parameter."
147352
+ },
147353
+ "definition": {
147354
+ "$ref": "#/$defs/parameterDefinition",
147355
+ "description": "The typed definition of the parameter - its data type, default value and constraints."
147356
+ }
147357
+ },
147358
+ "$semantic": {
147359
+ "type": "snippet",
147360
+ "snippets": ["parameter"]
147361
+ },
147362
+ "required": [
147363
+ "id",
147364
+ "type",
147365
+ "definition"
147366
+ ]
147367
+ },
147229
147368
  "visualisation": {
147230
147369
  "$schema": "http://json-schema.org/draft-07/schema#",
147231
147370
  "title": "Visualisation",
@@ -153590,6 +153729,129 @@ const metadata_v1 = {
153590
153729
  "maql"
153591
153730
  ]
153592
153731
  },
153732
+ "parameter": {
153733
+ "title": "Parameter",
153734
+ "type": "object",
153735
+ "additionalProperties": false,
153736
+ "properties": {
153737
+ "id": {
153738
+ "$ref": "#/$global/gaac/identifier",
153739
+ "description": "A unique identifier of the parameter.",
153740
+ "$semantic": [{
153741
+ "type": "uniqueness",
153742
+ "source": "parameter.id",
153743
+ "code": "core.uniqueness.parameters.id"
153744
+ }, {
153745
+ "type": "definition",
153746
+ "source": "parameter.id"
153747
+ }]
153748
+ },
153749
+ "type": {
153750
+ "type": "string",
153751
+ "enum": ["parameter"]
153752
+ },
153753
+ "title": {
153754
+ "$ref": "#/$global/gaac/title",
153755
+ "description": "An optional human readable title for the parameter. Will be derived from id if not provided explicitly."
153756
+ },
153757
+ "description": {
153758
+ "$ref": "#/$global/gaac/description",
153759
+ "description": "An optional description of the parameter."
153760
+ },
153761
+ "tags": {
153762
+ "$ref": "#/$global/gaac/tags",
153763
+ "description": "A list of strings - metadata tags of this parameter."
153764
+ },
153765
+ "definition": {
153766
+ "$ref": "#/$defs/parameterDefinition",
153767
+ "description": "The typed definition of the parameter - its data type, default value and constraints."
153768
+ }
153769
+ },
153770
+ "$semantic": {
153771
+ "type": "snippet",
153772
+ "snippets": ["parameter"]
153773
+ },
153774
+ "required": [
153775
+ "id",
153776
+ "type",
153777
+ "definition"
153778
+ ]
153779
+ },
153780
+ "parameterDefinition": {
153781
+ "title": "Parameter Definition",
153782
+ "description": "A typed parameter definition. Only textual parameters are supported as code.",
153783
+ "allOf": [{
153784
+ "if": {
153785
+ "properties": { "type": { "const": "STRING" } },
153786
+ "required": ["type"]
153787
+ },
153788
+ "then": { "$ref": "#/$defs/stringParameterDefinition" }
153789
+ }],
153790
+ "properties": { "type": {
153791
+ "type": "string",
153792
+ "enum": ["STRING"]
153793
+ } },
153794
+ "required": ["type"]
153795
+ },
153796
+ "stringParameterDefinition": {
153797
+ "title": "String Parameter Definition",
153798
+ "description": "A textual parameter definition. Without 'constraints' the parameter accepts any free-text value.",
153799
+ "type": "object",
153800
+ "additionalProperties": false,
153801
+ "properties": {
153802
+ "type": {
153803
+ "type": "string",
153804
+ "enum": ["STRING"]
153805
+ },
153806
+ "defaultValue": {
153807
+ "type": "string",
153808
+ "description": "The value used whenever the parameter is not overridden."
153809
+ },
153810
+ "constraints": {
153811
+ "title": "String Parameter Constraints",
153812
+ "type": "object",
153813
+ "additionalProperties": false,
153814
+ "description": "Optional restrictions the parameter value must satisfy. Length bounds and 'allowedValues' are mutually exclusive.",
153815
+ "properties": {
153816
+ "minLength": {
153817
+ "type": "integer",
153818
+ "minimum": 0,
153819
+ "description": "The shortest accepted value length, inclusive."
153820
+ },
153821
+ "maxLength": {
153822
+ "type": "integer",
153823
+ "minimum": 0,
153824
+ "description": "The longest accepted value length, inclusive."
153825
+ },
153826
+ "allowedValues": {
153827
+ "type": "array",
153828
+ "minItems": 1,
153829
+ "description": "When present, the parameter value must equal one of the listed values.",
153830
+ "items": { "$ref": "#/$defs/parameterAllowedValue" }
153831
+ }
153832
+ },
153833
+ "not": { "anyOf": [{ "required": ["allowedValues", "minLength"] }, { "required": ["allowedValues", "maxLength"] }] }
153834
+ }
153835
+ },
153836
+ "required": ["type", "defaultValue"]
153837
+ },
153838
+ "parameterAllowedValue": {
153839
+ "title": "Parameter Allowed Value",
153840
+ "type": "object",
153841
+ "additionalProperties": false,
153842
+ "properties": {
153843
+ "value": {
153844
+ "type": "string",
153845
+ "minLength": 1,
153846
+ "description": "The accepted parameter value."
153847
+ },
153848
+ "title": {
153849
+ "type": "string",
153850
+ "description": "An optional human readable title shown instead of the raw value. Defaults to the value."
153851
+ }
153852
+ },
153853
+ "required": ["value"]
153854
+ },
153593
153855
  "plugin": {
153594
153856
  "title": "Plugin",
153595
153857
  "type": "object",
@@ -157994,6 +158256,7 @@ function buildSnippet(definition, type) {
157994
158256
  case "dataset": return buildSnippetForDataset(definition);
157995
158257
  case "date": return buildSnippetForDateDataset(definition);
157996
158258
  case "metric": return buildSnippetForMetric(definition);
158259
+ case "parameter": return buildSnippetForParameter(definition);
157997
158260
  case "attribute": return buildSnippetForAttribute(definition);
157998
158261
  case "fact": return buildSnippetForFact(definition);
157999
158262
  case "color": return buildSnippetForColor();
@@ -158041,6 +158304,19 @@ function buildSnippetForMetric(definition) {
158041
158304
  lines.push(``);
158042
158305
  return lines.join("\n");
158043
158306
  }
158307
+ function buildSnippetForParameter(definition) {
158308
+ const lines = [];
158309
+ const tb = tabStopBuilder();
158310
+ if (!definition.id) lines.push(`id: ${tb()}`);
158311
+ if (!definition.type) lines.push(`type: parameter`);
158312
+ if (!definition.definition) {
158313
+ lines.push(`definition:`);
158314
+ lines.push(` type: STRING`);
158315
+ lines.push(` defaultValue: ${tb()}`);
158316
+ }
158317
+ lines.push(``);
158318
+ return lines.join("\n");
158319
+ }
158044
158320
  function buildSnippetForAttribute(definition) {
158045
158321
  const lines = [];
158046
158322
  const tb = tabStopBuilder();
@@ -159147,7 +159423,7 @@ function findTransitiveReferences(file, references, point) {
159147
159423
  }
159148
159424
  //#endregion
159149
159425
  //#region ../code/esm/shared/maql/index.js
159150
- const referenceRegex = new RegExp(`\\{((?:${SupportedReferenceTypes$1.join("|")})\\/(?!\\.)[.A-Za-z0-9_-]{1,255})\\}`);
159426
+ const referenceRegex = new RegExp(`\\{((?:${SupportedMaqlReferenceTypes.join("|")})\\/${REFERENCE_ID_PATTERN})\\}`);
159151
159427
  function loadMaqlReferencesWithPositions(document, offset, data) {
159152
159428
  const items = parseMaqlObjects(data);
159153
159429
  const results = [];
@@ -159170,7 +159446,7 @@ function parseMaqlObjects(data) {
159170
159446
  const item = parsed[i];
159171
159447
  if (i % 2 === 0) result.push(item);
159172
159448
  else {
159173
- const identifier = parseReferenceObject$1(item);
159449
+ const identifier = parseReferenceObject$1(item, SupportedMaqlReferenceTypes);
159174
159450
  identifier && result.push({
159175
159451
  ...identifier,
159176
159452
  text: `{${item}}`,
@@ -159295,6 +159571,7 @@ const REFERENCED_OBJECT_TYPES = {
159295
159571
  "dashboard.id": "dashboard",
159296
159572
  "dataSource.id": "dataSource",
159297
159573
  "metric.id": "metric",
159574
+ "parameter.id": "parameter",
159298
159575
  "table.id": "table",
159299
159576
  "fact.id": "fact",
159300
159577
  "aggregated_fact.id": "aggregated_fact",
@@ -159317,6 +159594,7 @@ function referencesFindYamlForReferences(references, nodeItem, semanticItem, typ
159317
159594
  case "dashboard.id":
159318
159595
  case "dataSource.id":
159319
159596
  case "metric.id":
159597
+ case "parameter.id":
159320
159598
  case "table.id":
159321
159599
  case "fact.id":
159322
159600
  case "aggregated_fact.id":
@@ -159424,6 +159702,9 @@ function referencesFindYamlForDefinition(references, parents, nodeItem, semantic
159424
159702
  case "metric.id":
159425
159703
  prev.push(...createDefinitionForMainType(references, isMetric, value, "metric"));
159426
159704
  break;
159705
+ case "parameter.id":
159706
+ prev.push(...createDefinitionForMainType(references, isParameter, value, "parameter"));
159707
+ break;
159427
159708
  case "visualisation.id":
159428
159709
  prev.push(...createDefinitionForMainType(references, isVisualisation, value, "visualisation"));
159429
159710
  break;
@@ -159888,6 +160169,7 @@ const MAIN_OBJECTS = [
159888
160169
  ...PluginTypes$1,
159889
160170
  ...DashboardTypes$1,
159890
160171
  ...MetricTypes$1,
160172
+ ...ParameterTypes$1,
159891
160173
  ...VisualisationType,
159892
160174
  ...AttributeHierarchyTypes$1
159893
160175
  ];
@@ -159942,6 +160224,7 @@ function createTextEdit(item, name) {
159942
160224
  case "dashboard":
159943
160225
  case "dataSource":
159944
160226
  case "metric":
160227
+ case "parameter":
159945
160228
  case "attribute_hierarchy":
159946
160229
  case "label": {
159947
160230
  const prefix = `${item.type}/`;
@@ -160397,7 +160680,7 @@ async function open(state, emitter, file) {
160397
160680
  //#endregion
160398
160681
  //#region ../code/package.json
160399
160682
  var name = "@gooddata/code";
160400
- var version = "0.50.0-alpha.0";
160683
+ var version = "0.50.0-alpha.1";
160401
160684
  //#endregion
160402
160685
  //#region ../../../sdk/libs/api-client-tiger/src/axios.ts
160403
160686
  /**
@@ -160419,7 +160702,7 @@ const _CONFIG = {
160419
160702
  common: {
160420
160703
  "X-Requested-With": "XMLHttpRequest",
160421
160704
  "X-GDC-JS-PACKAGE": "@gooddata/api-client-tiger",
160422
- "X-GDC-JS-PACKAGE-VERSION": "11.54.0-alpha.0"
160705
+ "X-GDC-JS-PACKAGE-VERSION": "11.54.0-alpha.1"
160423
160706
  },
160424
160707
  post: { "Content-Type": "application/json;charset=utf8" },
160425
160708
  put: { "Content-Type": "application/json;charset=utf8" }
@@ -198928,6 +199211,10 @@ async function makeRequest(func) {
198928
199211
  throw e;
198929
199212
  }
198930
199213
  }
199214
+ function mergeParameters(current, fromFiles) {
199215
+ const authored = new Set(fromFiles.map((parameter) => parameter.id));
199216
+ return [...(current ?? []).filter((parameter) => !isDeclarativeStringParameter(parameter) && !authored.has(parameter.id)), ...fromFiles];
199217
+ }
198931
199218
  function updateDeclarativeLayout(currentWs, newWs) {
198932
199219
  return {
198933
199220
  ...currentWs,
@@ -198939,7 +199226,8 @@ function updateDeclarativeLayout(currentWs, newWs) {
198939
199226
  ...newWs.analytics?.analyticalDashboards ? { analyticalDashboards: newWs.analytics?.analyticalDashboards } : {},
198940
199227
  ...newWs.analytics?.filterContexts ? { filterContexts: newWs.analytics?.filterContexts } : {},
198941
199228
  ...newWs.analytics?.dashboardPlugins ? { dashboardPlugins: newWs.analytics?.dashboardPlugins } : {},
198942
- ...newWs.analytics?.attributeHierarchies ? { attributeHierarchies: newWs.analytics?.attributeHierarchies } : {}
199229
+ ...newWs.analytics?.attributeHierarchies ? { attributeHierarchies: newWs.analytics?.attributeHierarchies } : {},
199230
+ ...newWs.analytics?.parameters ? { parameters: mergeParameters(currentWs.analytics?.parameters, newWs.analytics.parameters) } : {}
198943
199231
  }
198944
199232
  };
198945
199233
  }
@@ -199110,6 +199398,11 @@ function createDeclarativeWorkspaceModel(entities, profile) {
199110
199398
  return data;
199111
199399
  });
199112
199400
  ws.analytics.metrics = metricsEntities.map((d) => d.declarative);
199401
+ const parameterEntities = entities.filter((e) => ParameterTypes.includes(e.type)).map((data) => {
199402
+ data.declarative = yamlParameterToDeclarative(data.data);
199403
+ return data;
199404
+ });
199405
+ ws.analytics.parameters = parameterEntities.map((d) => d.declarative);
199113
199406
  const visualisationsEntities = entities.filter((e) => VisualisationsTypes.includes(e.type)).map((data) => {
199114
199407
  data.declarative = yamlVisualisationToDeclarative(entities, data.data);
199115
199408
  return data;
@@ -199418,6 +199711,7 @@ async function fromDeclarative(workspace, basePath, profile, { tables = {}, stor
199418
199711
  const entitiesLoaded = [];
199419
199712
  const datasetsPath = [...basePath, "datasets"];
199420
199713
  const metricsPath = [...basePath, "metrics"];
199714
+ const parametersPath = [...basePath, "parameters"];
199421
199715
  const visualisationsPath = [...basePath, "visualisations"];
199422
199716
  const dashboardsPath = [...basePath, "dashboards"];
199423
199717
  const pluginPath = [...basePath, "plugins"];
@@ -199464,6 +199758,17 @@ async function fromDeclarative(workspace, basePath, profile, { tables = {}, stor
199464
199758
  });
199465
199759
  return createNewFile(store, filePath, createFileContent({ content: Buffer.from(content, "utf8") }), { mode: "remote" });
199466
199760
  }) ?? []);
199761
+ if (workspace?.analytics?.parameters) mergeResults(update, workspace.analytics.parameters.filter(isDeclarativeStringParameter).map((parameter) => {
199762
+ const { content, json } = declarativeParameterToYaml(parameter);
199763
+ const filePath = generateFileName(files, parametersPath, parameter.id, parameter.title);
199764
+ if (json && content) entitiesLoaded.push({
199765
+ type: "parameter",
199766
+ id: parameter.id,
199767
+ data: json,
199768
+ path: filePath
199769
+ });
199770
+ return createNewFile(store, filePath, createFileContent({ content: Buffer.from(content, "utf8") }), { mode: "remote" });
199771
+ }) ?? []);
199467
199772
  if (workspace?.analytics?.visualizationObjects) mergeResults(update, workspace.analytics.visualizationObjects.map((visualisation) => {
199468
199773
  const { content, json } = declarativeVisualisationToYaml(entitiesLoaded, visualisation);
199469
199774
  const filePath = generateFileName(files, visualisationsPath, visualisation.id, visualisation.title);
@@ -201865,6 +202170,7 @@ const ruleFiles = [
201865
202170
  "datasets.mdc",
201866
202171
  "gooddata.mdc",
201867
202172
  "metrics.mdc",
202173
+ "parameters.mdc",
201868
202174
  "visualizations.mdc"
201869
202175
  ];
201870
202176
  async function prepareCursorRulesFile() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddata/code-cli",
3
- "version": "0.50.0-alpha.0",
3
+ "version": "0.50.0-alpha.1",
4
4
  "description": "GoodData CLI",
5
5
  "keywords": [
6
6
  "analytics",