@gooddata/code-cli 0.50.0-alpha.7 → 0.51.0-alpha.0

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.
Files changed (2) hide show
  1. package/dist/index.js +174 -26
  2. 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.50.0-alpha.7";
37373
+ var version$1 = "0.51.0-alpha.0";
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) => {
@@ -87456,6 +87456,7 @@ var LabelElementsFinder = class extends LabelContextMarker {
87456
87456
  };
87457
87457
  //#endregion
87458
87458
  //#region ../../../common/temp/aac/node_modules/.pnpm/gdc-maql-language-server@file+..+..+..+libs+gdc-maql-language-server/node_modules/gdc-maql-language-server/esm/metadata/parameters.js
87459
+ const { escapeString: escapeString$1 } = import_dist$7.default;
87459
87460
  function parameterTypeLabel(definition) {
87460
87461
  return definition.type.toLowerCase();
87461
87462
  }
@@ -87465,6 +87466,26 @@ function parameterDefaultLabel(definition) {
87465
87466
  function parameterSummary(definition) {
87466
87467
  return `${parameterTypeLabel(definition)}, default: ${parameterDefaultLabel(definition)}`;
87467
87468
  }
87469
+ /**
87470
+ * Whether a definition describes a default that can be written into MAQL. A parameter file being
87471
+ * edited reaches us with a type it has not finished, or a default of the wrong kind for the type it
87472
+ * declares, neither of which the declared type admits.
87473
+ */
87474
+ function isRenderableDefinition(definition) {
87475
+ const candidate = definition;
87476
+ switch (candidate?.type) {
87477
+ case "STRING": return typeof candidate.defaultValue === "string";
87478
+ case "NUMBER": return typeof candidate.defaultValue === "number";
87479
+ default: return false;
87480
+ }
87481
+ }
87482
+ /**
87483
+ * The parameter's default as it would be written in MAQL: string defaults quoted and escaped,
87484
+ * numeric ones bare.
87485
+ */
87486
+ function parameterMaqlLiteral(definition) {
87487
+ return isStringParameterDefinition(definition) ? escapeString$1(definition.defaultValue, "\"") : String(definition.defaultValue);
87488
+ }
87468
87489
  //#endregion
87469
87490
  //#region ../../../common/temp/aac/node_modules/.pnpm/gdc-maql-language-server@file+..+..+..+libs+gdc-maql-language-server/node_modules/gdc-maql-language-server/esm/parseMaql.js
87470
87491
  var import_antlr4ts = require_antlr4ts();
@@ -87540,6 +87561,10 @@ var MaqlMetric = class MaqlMetric extends MaqlQuery {
87540
87561
  static offset(offset) {
87541
87562
  return MaqlMetric.prefix.length + offset;
87542
87563
  }
87564
+ /** Inverse of {@link MaqlMetric.offset}: a parser offset back into the metric's own text. */
87565
+ static rawOffset(parserOffset) {
87566
+ return parserOffset - MaqlMetric.prefix.length;
87567
+ }
87543
87568
  constructor(raw, addDefaultErrorListener = false) {
87544
87569
  super(MaqlMetric.prefix + raw);
87545
87570
  if (!addDefaultErrorListener) super.removeErrorListeners();
@@ -87757,7 +87782,7 @@ var ObjectFinder = class {
87757
87782
  const rbrace = ctx.tryGetToken(MaqlParser$4.RBRACE, 0);
87758
87783
  if (lbrace === void 0 || lbrace.symbol.tokenIndex === -1 || sep === void 0 || sep.symbol.tokenIndex === -1 || id === void 0 || id.symbol.tokenIndex === -1 || rbrace === void 0 || rbrace.symbol.tokenIndex === -1 || type === void 0) return;
87759
87784
  const range = antlrContextRange(ctx.start, ctx.stop);
87760
- const tigerType = normalizeMaqlObjectType(type);
87785
+ const tigerType = normalizeMaqlObjectType(type.toLowerCase());
87761
87786
  this.objects.push({
87762
87787
  tigerType: isTigerType(tigerType) ? tigerType : void 0,
87763
87788
  actualType: type,
@@ -87766,7 +87791,11 @@ var ObjectFinder = class {
87766
87791
  type: tigerIdTypeToObjectType[tigerType],
87767
87792
  identifier: ctx.ID().text
87768
87793
  },
87769
- range
87794
+ range,
87795
+ offsets: {
87796
+ start: MaqlMetric.rawOffset(ctx.start.startIndex),
87797
+ end: MaqlMetric.rawOffset((ctx.stop?.stopIndex ?? ctx.start.stopIndex) + 1)
87798
+ }
87770
87799
  });
87771
87800
  }
87772
87801
  exitAttribute(ctx) {
@@ -93543,6 +93572,35 @@ var MaqlLanguageService = class {
93543
93572
  handleMetadataServiceError(_reason) {}
93544
93573
  };
93545
93574
  //#endregion
93575
+ //#region ../../../common/temp/aac/node_modules/.pnpm/gdc-maql-language-server@file+..+..+..+libs+gdc-maql-language-server/node_modules/gdc-maql-language-server/esm/renderParameters.js
93576
+ /**
93577
+ * Replaces every `{parameter/id}` reference in `maql` with its default value, so the template can be
93578
+ * previewed as the MAQL that would actually execute. String defaults are rendered as quoted literals
93579
+ * and numeric ones bare. Unresolvable references are reported and left in place rather than guessed.
93580
+ *
93581
+ * Returns undefined when the template references no parameter at all.
93582
+ */
93583
+ function renderParameterDefaults(maql, ldmObjects) {
93584
+ const parameters = findAllObjects(new MaqlMetric(maql)).filter((object) => object.tigerType === "parameter");
93585
+ if (parameters.length === 0) return;
93586
+ const unresolved = [];
93587
+ let rendered = "";
93588
+ let cursor = 0;
93589
+ for (const parameter of parameters) {
93590
+ const found = ldmObjects.findObject(parameter);
93591
+ if (!found || !isITigerParameter(found) || !isRenderableDefinition(found.definition)) {
93592
+ unresolved.push(parameter.id);
93593
+ continue;
93594
+ }
93595
+ rendered += maql.slice(cursor, parameter.offsets.start) + parameterMaqlLiteral(found.definition);
93596
+ cursor = parameter.offsets.end;
93597
+ }
93598
+ return {
93599
+ maql: rendered + maql.slice(cursor),
93600
+ unresolved
93601
+ };
93602
+ }
93603
+ //#endregion
93546
93604
  //#region ../code-ast/esm/yaml/types.js
93547
93605
  /**
93548
93606
  * @public
@@ -102938,6 +102996,11 @@ var CoreErrorCode;
102938
102996
  CoreErrorCode["DuplicateFilterLocalIdentifier"] = "core.duplicateFilterLocalIdentifier";
102939
102997
  CoreErrorCode["DuplicateTabIdentifier"] = "core.duplicateTabIdentifier";
102940
102998
  CoreErrorCode["InvalidIanaTimezoneId"] = "core.invalidIanaTimezoneId";
102999
+ CoreErrorCode["ParameterDefaultNotAllowed"] = "core.parameter.defaultNotAllowed";
103000
+ CoreErrorCode["ParameterDuplicateAllowedValue"] = "core.parameter.duplicateAllowedValue";
103001
+ CoreErrorCode["ParameterDuplicateAllowedTitle"] = "core.parameter.duplicateAllowedTitle";
103002
+ CoreErrorCode["ParameterLengthRange"] = "core.parameter.lengthRange";
103003
+ CoreErrorCode["ParameterDefaultOutOfBounds"] = "core.parameter.defaultOutOfBounds";
102941
103004
  CoreErrorCode["MissingDataSourceId"] = "core.missingDataSourceId";
102942
103005
  CoreErrorCode["NonExistingRemoteReference"] = "core.nonExistingRemoteReference";
102943
103006
  CoreErrorCode["NonExistingRemoteReferences"] = "core.nonExistingRemoteReferences";
@@ -103032,6 +103095,11 @@ const CoreErrorMessages$1 = {
103032
103095
  [CoreErrorCode.DuplicateFilterLocalIdentifier]: `Duplicate filter local identifier "{0}". Each filter must have a unique local identifier across a dashboard tab, including filters in groups.`,
103033
103096
  [CoreErrorCode.DuplicateTabIdentifier]: `Duplicate tab identifier "{0}". Each tab must have a unique identifier within the dashboard.`,
103034
103097
  [CoreErrorCode.InvalidIanaTimezoneId]: `"{0}" is not a valid IANA timezone ID. Use a real timezone such as Europe/Prague or $browserDetected.`,
103098
+ [CoreErrorCode.ParameterDefaultNotAllowed]: `Default "{0}" is not in the allowed_values list. Choose a value from: {1}.`,
103099
+ [CoreErrorCode.ParameterDuplicateAllowedValue]: `allowed_values contains duplicate value "{0}". Each value must be unique.`,
103100
+ [CoreErrorCode.ParameterDuplicateAllowedTitle]: `allowed_values contains duplicate title "{0}". Each title must be unique.`,
103101
+ [CoreErrorCode.ParameterLengthRange]: `minLength {0} is greater than maxLength {1}. The bounds must describe a non-empty range.`,
103102
+ [CoreErrorCode.ParameterDefaultOutOfBounds]: `Default "{0}" has length {1}, which is outside the declared bounds {2}.`,
103035
103103
  [CoreErrorCode.MissingDataSourceId]: `Missing data source. Data source must be specified in profile or directly on dataset. Use "data_source" property in profile or "data_source" property in current dataset definition.`,
103036
103104
  [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.`,
103037
103105
  [SpecificCoreErrorCode.UniquenessDatasetsId]: `There are more datasets with id "{0}". Use unique names for datasets.`,
@@ -103112,6 +103180,11 @@ const CoreErrorTypes$1 = {
103112
103180
  [CoreErrorCode.DuplicateFilterLocalIdentifier]: "DuplicateFilterLocalIdentifier",
103113
103181
  [CoreErrorCode.DuplicateTabIdentifier]: "DuplicateTabIdentifier",
103114
103182
  [CoreErrorCode.InvalidIanaTimezoneId]: "InvalidIanaTimezoneId",
103183
+ [CoreErrorCode.ParameterDefaultNotAllowed]: "ParameterDefaultNotAllowed",
103184
+ [CoreErrorCode.ParameterDuplicateAllowedValue]: "ParameterDuplicateAllowedValue",
103185
+ [CoreErrorCode.ParameterDuplicateAllowedTitle]: "ParameterDuplicateAllowedTitle",
103186
+ [CoreErrorCode.ParameterLengthRange]: "ParameterLengthRange",
103187
+ [CoreErrorCode.ParameterDefaultOutOfBounds]: "ParameterDefaultOutOfBounds",
103115
103188
  [CoreErrorCode.MissingDataSourceId]: "MissingDataSourceId",
103116
103189
  [SpecificCoreErrorCode.UniquenessDatasetsId]: "UniquenessDatasetsId",
103117
103190
  [SpecificCoreErrorCode.UniquenessMetricsId]: "UniquenessMetricsId",
@@ -154141,7 +154214,8 @@ const metadata_v1 = {
154141
154214
  "not": { "anyOf": [{ "required": ["allowedValues", "minLength"] }, { "required": ["allowedValues", "maxLength"] }] }
154142
154215
  }
154143
154216
  },
154144
- "required": ["type", "defaultValue"]
154217
+ "required": ["type", "defaultValue"],
154218
+ "$semantic": { "type": "parameter_constraints" }
154145
154219
  },
154146
154220
  "parameterAllowedValue": {
154147
154221
  "title": "Parameter Allowed Value",
@@ -157159,6 +157233,73 @@ async function validateMaql(state, resolvedReferences, file) {
157159
157233
  return [];
157160
157234
  }
157161
157235
  //#endregion
157236
+ //#region ../code/esm/features/validations/validator/languages/yaml/semantic/duplicates.js
157237
+ /**
157238
+ * The entries that appear more than once, each reported once, in the order they first repeat.
157239
+ */
157240
+ function findDuplicates(entries) {
157241
+ const seen = /* @__PURE__ */ new Set();
157242
+ const duplicates = /* @__PURE__ */ new Set();
157243
+ for (const entry of entries) {
157244
+ if (seen.has(entry)) duplicates.add(entry);
157245
+ seen.add(entry);
157246
+ }
157247
+ return [...duplicates];
157248
+ }
157249
+ /**
157250
+ * The entries with a distinct key, keeping the first of each.
157251
+ */
157252
+ function uniqueBy(entries, key) {
157253
+ const seen = /* @__PURE__ */ new Set();
157254
+ return entries.filter((entry) => {
157255
+ const value = key(entry);
157256
+ const isNew = !seen.has(value);
157257
+ seen.add(value);
157258
+ return isNew;
157259
+ });
157260
+ }
157261
+ //#endregion
157262
+ //#region ../code/esm/features/validations/validator/languages/yaml/semantic/parameterConstraints.js
157263
+ /**
157264
+ * Checks the parameter rules JSON Schema cannot express: that the declared bounds describe a
157265
+ * non-empty range, that the default satisfies whatever the constraints declare, and that no
157266
+ * allowed value or title repeats.
157267
+ */
157268
+ function validateYamlSemanticForParameterConstraints(schemas, schema, node) {
157269
+ return mergeSchemaValidatorDiagnostics(...getSemanticItems(schema.$semantic).map((semantic) => {
157270
+ const currentDiagnostics = createSchemaValidatorDiagnostics([]);
157271
+ if (semantic.type !== "parameter_constraints" || !node.position) return currentDiagnostics;
157272
+ const definition = getNodeValue(node);
157273
+ if (!definition || typeof definition !== "object") return currentDiagnostics;
157274
+ const report = (code, params) => {
157275
+ currentDiagnostics.diagnostics.push(createDiagnostic$1(SchemaDiagnosticSeverity.Error, node.position, getSchemaArray(schemas, schema), code, CoreErrorMessages$1[code], params));
157276
+ };
157277
+ const { defaultValue, constraints } = definition;
157278
+ const { minLength, maxLength, allowedValues } = constraints ?? {};
157279
+ if (minLength !== void 0 && maxLength !== void 0 && minLength > maxLength) report(CoreErrorCode.ParameterLengthRange, [String(minLength), String(maxLength)]);
157280
+ const declared = Array.isArray(allowedValues) ? allowedValues.filter((allowed) => typeof allowed?.value === "string") : [];
157281
+ for (const value of findDuplicates(declared.map((allowed) => allowed.value))) report(CoreErrorCode.ParameterDuplicateAllowedValue, [value]);
157282
+ const distinct = uniqueBy(declared, (allowed) => allowed.value);
157283
+ for (const title of findDuplicates(distinct.map((allowed) => allowed.title ?? allowed.value))) report(CoreErrorCode.ParameterDuplicateAllowedTitle, [title]);
157284
+ if (typeof defaultValue !== "string") return currentDiagnostics;
157285
+ const values = distinct.map((allowed) => allowed.value);
157286
+ if (values.length > 0 && !values.includes(defaultValue)) report(CoreErrorCode.ParameterDefaultNotAllowed, [defaultValue, values.join(", ")]);
157287
+ const tooShort = minLength !== void 0 && defaultValue.length < minLength;
157288
+ const tooLong = maxLength !== void 0 && defaultValue.length > maxLength;
157289
+ if (tooShort || tooLong) report(CoreErrorCode.ParameterDefaultOutOfBounds, [
157290
+ defaultValue,
157291
+ String(defaultValue.length),
157292
+ describeBounds(minLength, maxLength)
157293
+ ]);
157294
+ return currentDiagnostics;
157295
+ }));
157296
+ }
157297
+ function describeBounds(minLength, maxLength) {
157298
+ if (minLength === void 0) return `at most ${maxLength}`;
157299
+ if (maxLength === void 0) return `at least ${minLength}`;
157300
+ return `${minLength}-${maxLength}`;
157301
+ }
157302
+ //#endregion
157162
157303
  //#region ../code/esm/features/validations/validator/languages/yaml/semantic.js
157163
157304
  async function validateYamlSemantic(state, resolvedReferences, textDocument, schemas, schema, root, node) {
157164
157305
  const results = [];
@@ -157178,6 +157319,7 @@ async function validateYamlSemantic(state, resolvedReferences, textDocument, sch
157178
157319
  results.push(validateYamlSemanticForUniqueFilterLocalIdentifiers(schemas, schema, node));
157179
157320
  results.push(validateYamlSemanticForUniqueTabIdentifiers(schemas, schema, node));
157180
157321
  results.push(validateYamlSemanticForIanaTimezone(schemas, schema, node));
157322
+ results.push(validateYamlSemanticForParameterConstraints(schemas, schema, node));
157181
157323
  return mergeSchemaValidatorDiagnostics(diagnostics, ...results);
157182
157324
  }
157183
157325
  async function validateYamlSemanticForMaql(state, resolvedReferences, textDocument, schema, root, node) {
@@ -157484,13 +157626,7 @@ function validateYamlSemanticForUniqueFilterLocalIdentifiers(schemas, schema, no
157484
157626
  if (semantic.type === "unique_filter_local_identifiers" && node.position) {
157485
157627
  const filters = getNodeValue(node);
157486
157628
  if (filters && typeof filters === "object") {
157487
- const allFilterIds = collectFilterLocalIdentifiers(filters);
157488
- const seen = /* @__PURE__ */ new Set();
157489
- const duplicates = /* @__PURE__ */ new Set();
157490
- for (const id of allFilterIds) {
157491
- if (seen.has(id)) duplicates.add(id);
157492
- seen.add(id);
157493
- }
157629
+ const duplicates = findDuplicates(collectFilterLocalIdentifiers(filters));
157494
157630
  for (const duplicate of duplicates) {
157495
157631
  const params = [duplicate];
157496
157632
  currentDiagnostics.diagnostics.push(createDiagnostic$1(SchemaDiagnosticSeverity.Error, node.position, getSchemaArray(schemas, schema), CoreErrorCode.DuplicateFilterLocalIdentifier, CoreErrorMessages$1[CoreErrorCode.DuplicateFilterLocalIdentifier], params));
@@ -157516,12 +157652,7 @@ function validateYamlSemanticForUniqueTabIdentifiers(schemas, schema, node) {
157516
157652
  if (tabs && Array.isArray(tabs)) {
157517
157653
  const tabIds = [];
157518
157654
  for (const tab of tabs) if (tab && typeof tab === "object" && tab.id) tabIds.push(tab.id);
157519
- const seen = /* @__PURE__ */ new Set();
157520
- const duplicates = /* @__PURE__ */ new Set();
157521
- for (const id of tabIds) {
157522
- if (seen.has(id)) duplicates.add(id);
157523
- seen.add(id);
157524
- }
157655
+ const duplicates = findDuplicates(tabIds);
157525
157656
  for (const duplicate of duplicates) {
157526
157657
  const params = [duplicate];
157527
157658
  currentDiagnostics.diagnostics.push(createDiagnostic$1(SchemaDiagnosticSeverity.Error, node.position, getSchemaArray(schemas, schema), CoreErrorCode.DuplicateTabIdentifier, CoreErrorMessages$1[CoreErrorCode.DuplicateTabIdentifier], params));
@@ -159953,6 +160084,7 @@ function referencesFindYamlByType(references, document, parents, nodeItem, seman
159953
160084
  case "unique_filter_local_identifiers":
159954
160085
  case "unique_tab_identifiers":
159955
160086
  case "iana_timezone":
160087
+ case "parameter_constraints":
159956
160088
  case void 0: return [];
159957
160089
  default: assertUnreachable$1(semanticItem.type);
159958
160090
  }
@@ -161079,7 +161211,7 @@ async function open(state, emitter, file) {
161079
161211
  //#endregion
161080
161212
  //#region ../code/package.json
161081
161213
  var name = "@gooddata/code";
161082
- var version = "0.50.0-alpha.7";
161214
+ var version = "0.51.0-alpha.0";
161083
161215
  //#endregion
161084
161216
  //#region ../../../sdk/libs/api-client-tiger/src/axios.ts
161085
161217
  /**
@@ -161101,7 +161233,7 @@ const _CONFIG = {
161101
161233
  common: {
161102
161234
  "X-Requested-With": "XMLHttpRequest",
161103
161235
  "X-GDC-JS-PACKAGE": "@gooddata/api-client-tiger",
161104
- "X-GDC-JS-PACKAGE-VERSION": "11.54.0-alpha.7"
161236
+ "X-GDC-JS-PACKAGE-VERSION": "11.55.0-alpha.0"
161105
161237
  },
161106
161238
  post: { "Content-Type": "application/json;charset=utf8" },
161107
161239
  put: { "Content-Type": "application/json;charset=utf8" }
@@ -200432,13 +200564,16 @@ async function metricPreview(state, emitter, file, metricId, columns) {
200432
200564
  const metric = resolveObject(file, metricId);
200433
200565
  if (metric && manifestContent && server) {
200434
200566
  const { profile } = resolveUsingProfile(state, manifestContent);
200435
- if (profile) return await runServiceMethod(state, {
200436
- data: {
200437
- columns: [],
200438
- rows: []
200439
- },
200440
- diagnostics: [offlineDiagnostic()]
200441
- }, () => server.loadMetricPreview(profile, metric, columns));
200567
+ if (profile) return {
200568
+ ...await runServiceMethod(state, {
200569
+ data: {
200570
+ columns: [],
200571
+ rows: []
200572
+ },
200573
+ diagnostics: [offlineDiagnostic()]
200574
+ }, () => server.loadMetricPreview(profile, metric, columns)),
200575
+ rendered: renderMetricMaql(state, emitter, file, metric)
200576
+ };
200442
200577
  }
200443
200578
  return null;
200444
200579
  } catch (err) {
@@ -200545,6 +200680,19 @@ async function schemaPreview(state, emitter, file, datasetId) {
200545
200680
  return null;
200546
200681
  }
200547
200682
  }
200683
+ /**
200684
+ * Renders the metric's MAQL with its parameters' defaults substituted. Returns undefined when the
200685
+ * template names no parameters, so the preview only shows a rendered form when it differs.
200686
+ */
200687
+ function renderMetricMaql(state, emitter, file, metric) {
200688
+ if (!metric.maql) return;
200689
+ try {
200690
+ return renderParameterDefaults(metric.maql, resolvedReferences(state, file).objects);
200691
+ } catch (err) {
200692
+ emitter.emit("core.error", err);
200693
+ return;
200694
+ }
200695
+ }
200548
200696
  //#endregion
200549
200697
  //#region ../code/esm/store/textDocument/load.js
200550
200698
  function loadTextDocument(file) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gooddata/code-cli",
3
- "version": "0.50.0-alpha.7",
3
+ "version": "0.51.0-alpha.0",
4
4
  "description": "GoodData CLI",
5
5
  "keywords": [
6
6
  "analytics",