@lightdash/common 0.1464.2 → 0.1465.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
  import { type DbtRawModelNode, type SupportedDbtAdapter } from '../types/dbt';
2
2
  import { type CompiledExploreJoin, type CompiledTable, type Explore, type ExploreJoin, type Table } from '../types/explore';
3
3
  import { type CompiledCustomDimension, type CompiledCustomSqlDimension, type CompiledDimension, type CompiledMetric, type CustomDimension, type CustomSqlDimension, type Dimension, type Metric } from '../types/field';
4
- import { type WarehouseClient } from '../types/warehouse';
5
4
  import { type LightdashProjectConfig } from '../types/lightdashProjectConfig';
6
5
  import { type DateGranularity } from '../types/timeFrames';
6
+ import { type WarehouseClient } from '../types/warehouse';
7
7
  export declare const lightdashVariablePattern: RegExp;
8
8
  type Reference = {
9
9
  refTable: string;
@@ -7,6 +7,7 @@ const timeFrames_1 = require("../types/timeFrames");
7
7
  const timeFrames_2 = require("../utils/timeFrames");
8
8
  const warehouse_1 = require("../utils/warehouse");
9
9
  const filtersCompiler_1 = require("./filtersCompiler");
10
+ const lightdashProjectConfig_1 = require("./lightdashProjectConfig");
10
11
  // exclude lightdash prefix from variable pattern
11
12
  exports.lightdashVariablePattern = /\$\{((?!(lightdash|ld)\.)[a-zA-Z0-9_.]+)\}/g;
12
13
  const getParsedReference = (ref, currentTable) => {
@@ -119,14 +120,8 @@ class ExploreCompiler {
119
120
  }), {});
120
121
  const compiledJoins = joinedTables.map((j) => this.compileJoin(j, includedTables));
121
122
  const spotlightVisibility = meta.spotlight?.visibility ?? spotlightConfig?.default_visibility;
123
+ const spotlightCategories = (0, lightdashProjectConfig_1.getCategoriesFromResource)('explore', name, spotlightConfig, meta.spotlight?.categories);
122
124
  return {
123
- ...(spotlightVisibility !== undefined
124
- ? {
125
- spotlight: {
126
- visibility: spotlightVisibility,
127
- },
128
- }
129
- : {}),
130
125
  name,
131
126
  label,
132
127
  tags,
@@ -138,6 +133,7 @@ class ExploreCompiler {
138
133
  warehouse,
139
134
  ymlPath,
140
135
  sqlPath,
136
+ ...(0, lightdashProjectConfig_1.getSpotlightConfigurationForResource)(spotlightVisibility, spotlightCategories),
141
137
  };
142
138
  }
143
139
  compileTable(table, tables) {
@@ -81,6 +81,7 @@ exports.exploreBase = {
81
81
  tags: [],
82
82
  spotlight: {
83
83
  visibility: 'show',
84
+ categories: [],
84
85
  },
85
86
  baseTable: 'a',
86
87
  joinedTables: [],
@@ -1423,6 +1424,7 @@ exports.exploreWithMetricNumberCompiled = {
1423
1424
  groupLabel: exports.exploreWithMetricNumber.groupLabel,
1424
1425
  spotlight: {
1425
1426
  visibility: 'show',
1427
+ categories: [],
1426
1428
  },
1427
1429
  joinedTables: [],
1428
1430
  tables: {
@@ -0,0 +1,19 @@
1
+ import type { Explore } from '../types/explore';
2
+ import type { Metric } from '../types/field';
3
+ import type { LightdashProjectConfig } from '../types/lightdashProjectConfig';
4
+ /**
5
+ * Get the spotlight configuration for a resource
6
+ * @param visibility - The visibility of the resource
7
+ * @param categories - The categories of the resource
8
+ * @returns The spotlight configuration for the resource
9
+ */
10
+ export declare const getSpotlightConfigurationForResource: (visibility?: LightdashProjectConfig['spotlight']['default_visibility'], categories?: string[]) => Pick<Explore, 'spotlight'> | Pick<Metric, 'spotlight'>;
11
+ /**
12
+ * Get the categories from the resource and validate them against the project config
13
+ * @param resourceType - The type of the resource
14
+ * @param resourceName - The name of the resource
15
+ * @param spotlightConfig - The spotlight config
16
+ * @param resourceCategories - The categories from the resource
17
+ * @returns The categories from the resource
18
+ */
19
+ export declare const getCategoriesFromResource: (resourceType: 'metric' | 'explore', resourceName: string, spotlightConfig: LightdashProjectConfig['spotlight'] | undefined, resourceCategories?: string[] | undefined) => string[];
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCategoriesFromResource = exports.getSpotlightConfigurationForResource = void 0;
4
+ const errors_1 = require("../types/errors");
5
+ /**
6
+ * Get the spotlight configuration for a resource
7
+ * @param visibility - The visibility of the resource
8
+ * @param categories - The categories of the resource
9
+ * @returns The spotlight configuration for the resource
10
+ */
11
+ const getSpotlightConfigurationForResource = (visibility, categories) => {
12
+ if (visibility === undefined) {
13
+ return {};
14
+ }
15
+ return {
16
+ spotlight: {
17
+ visibility,
18
+ categories,
19
+ },
20
+ };
21
+ };
22
+ exports.getSpotlightConfigurationForResource = getSpotlightConfigurationForResource;
23
+ /**
24
+ * Get the categories from the resource and validate them against the project config
25
+ * @param resourceType - The type of the resource
26
+ * @param resourceName - The name of the resource
27
+ * @param spotlightConfig - The spotlight config
28
+ * @param resourceCategories - The categories from the resource
29
+ * @returns The categories from the resource
30
+ */
31
+ const getCategoriesFromResource = (resourceType, resourceName, spotlightConfig, resourceCategories = []) => {
32
+ // Get all valid category references from the global spotlight config
33
+ const categoriesDefinedInProjectConfig = Object.keys(spotlightConfig?.categories || {}) || [];
34
+ // Check if any metric categories aren't defined in the global config
35
+ const invalidCategories = resourceCategories.filter((category) => !categoriesDefinedInProjectConfig.includes(category));
36
+ if (invalidCategories.length > 0) {
37
+ throw new errors_1.ParseError(`Invalid spotlight categories found in ${resourceType} '${resourceName}': ${invalidCategories.join(', ')}. Categories must be defined in project config.`);
38
+ }
39
+ return resourceCategories;
40
+ };
41
+ exports.getCategoriesFromResource = getCategoriesFromResource;
@@ -11,6 +11,7 @@ const table_1 = require("../types/table");
11
11
  const assertUnreachable_1 = tslib_1.__importDefault(require("../utils/assertUnreachable"));
12
12
  const timeFrames_1 = require("../utils/timeFrames");
13
13
  const exploreCompiler_1 = require("./exploreCompiler");
14
+ const lightdashProjectConfig_1 = require("./lightdashProjectConfig");
14
15
  const convertTimezone = (timestampSql, default_source_tz, target_tz, adapterType) => {
15
16
  // todo: implement default_source_tz
16
17
  // todo: implement target_tz
@@ -118,7 +119,7 @@ const generateTableLineage = (model, depGraph) => {
118
119
  .map((d) => depGraph.getNodeData(d)),
119
120
  }), {});
120
121
  };
121
- const convertDbtMetricToLightdashMetric = (metric, tableName, tableLabel, spotlightConfig) => {
122
+ const convertDbtMetricToLightdashMetric = (metric, tableName, tableLabel, spotlightConfig, modelCategories) => {
122
123
  let sql;
123
124
  let type;
124
125
  if (metric.calculation_method === 'derived') {
@@ -161,7 +162,8 @@ const convertDbtMetricToLightdashMetric = (metric, tableName, tableLabel, spotli
161
162
  sql = `CASE WHEN ${filterSql} THEN ${sql} ELSE NULL END`;
162
163
  }
163
164
  const groups = (0, dbt_1.convertToGroups)(metric.meta?.groups, metric.meta?.group_label);
164
- const spotlightVisibility = spotlightConfig?.default_visibility;
165
+ const spotlightVisibility = spotlightConfig.default_visibility;
166
+ const spotlightCategories = (0, lightdashProjectConfig_1.getCategoriesFromResource)('metric', metric.name, spotlightConfig, Array.from(new Set([...(modelCategories || [])])));
165
167
  return {
166
168
  fieldType: field_1.FieldType.METRIC,
167
169
  type,
@@ -189,13 +191,7 @@ const convertDbtMetricToLightdashMetric = (metric, tableName, tableLabel, spotli
189
191
  : [metric.meta.tags],
190
192
  }
191
193
  : {}),
192
- ...(spotlightVisibility !== undefined
193
- ? {
194
- spotlight: {
195
- visibility: spotlightVisibility,
196
- },
197
- }
198
- : {}),
194
+ ...(0, lightdashProjectConfig_1.getSpotlightConfigurationForResource)(spotlightVisibility, spotlightCategories),
199
195
  };
200
196
  };
201
197
  const convertTable = (adapterType, model, dbtMetrics, spotlightConfig, startOfWeek) => {
@@ -278,6 +274,7 @@ const convertTable = (adapterType, model, dbtMetrics, spotlightConfig, startOfWe
278
274
  default_visibility: model.meta.spotlight?.visibility ??
279
275
  spotlightConfig.default_visibility,
280
276
  },
277
+ modelCategories: model.meta.spotlight?.categories,
281
278
  }),
282
279
  ]));
283
280
  return [
@@ -299,13 +296,14 @@ const convertTable = (adapterType, model, dbtMetrics, spotlightConfig, startOfWe
299
296
  spotlightConfig: {
300
297
  ...spotlightConfig,
301
298
  default_visibility: model.meta.spotlight?.visibility ??
302
- spotlightConfig?.default_visibility,
299
+ spotlightConfig.default_visibility,
303
300
  },
301
+ modelCategories: model.meta.spotlight?.categories,
304
302
  }),
305
303
  ]));
306
304
  const convertedDbtMetrics = Object.fromEntries(dbtMetrics.map((metric) => [
307
305
  metric.name,
308
- convertDbtMetricToLightdashMetric(metric, model.name, tableLabel, spotlightConfig),
306
+ convertDbtMetricToLightdashMetric(metric, model.name, tableLabel, spotlightConfig, model.meta.spotlight?.categories),
309
307
  ]));
310
308
  const allMetrics = Object.values({
311
309
  ...convertedDbtMetrics,
@@ -319,6 +319,7 @@ exports.LIGHTDASH_TABLE_WITH_GROUP_BLOCK = {
319
319
  type: field_1.MetricType.COUNT_DISTINCT,
320
320
  spotlight: {
321
321
  visibility: 'show',
322
+ categories: [],
322
323
  },
323
324
  },
324
325
  },
@@ -399,6 +400,7 @@ exports.LIGHTDASH_TABLE_WITH_DBT_METRICS = {
399
400
  index: 0,
400
401
  spotlight: {
401
402
  visibility: 'show',
403
+ categories: [],
402
404
  },
403
405
  },
404
406
  dbt_metric_2: {
@@ -423,6 +425,7 @@ exports.LIGHTDASH_TABLE_WITH_DBT_METRICS = {
423
425
  index: 1,
424
426
  spotlight: {
425
427
  visibility: 'show',
428
+ categories: [],
426
429
  },
427
430
  },
428
431
  dbt_metric_3: {
@@ -447,6 +450,7 @@ exports.LIGHTDASH_TABLE_WITH_DBT_METRICS = {
447
450
  index: 2,
448
451
  spotlight: {
449
452
  visibility: 'show',
453
+ categories: [],
450
454
  },
451
455
  },
452
456
  dbt_metric_4: {
@@ -471,6 +475,7 @@ exports.LIGHTDASH_TABLE_WITH_DBT_METRICS = {
471
475
  index: 3,
472
476
  spotlight: {
473
477
  visibility: 'show',
478
+ categories: [],
474
479
  },
475
480
  },
476
481
  dbt_metric_5: {
@@ -495,6 +500,7 @@ exports.LIGHTDASH_TABLE_WITH_DBT_METRICS = {
495
500
  index: 4,
496
501
  spotlight: {
497
502
  visibility: 'show',
503
+ categories: [],
498
504
  },
499
505
  },
500
506
  },
@@ -524,6 +530,7 @@ exports.LIGHTDASH_TABLE_WITH_DBT_V9_METRICS = {
524
530
  index: 0,
525
531
  spotlight: {
526
532
  visibility: 'show',
533
+ categories: [],
527
534
  },
528
535
  },
529
536
  },
@@ -649,6 +656,7 @@ exports.LIGHTDASH_TABLE_WITH_METRICS = {
649
656
  requiredAttributes: undefined,
650
657
  spotlight: {
651
658
  visibility: 'show',
659
+ categories: [],
652
660
  },
653
661
  },
654
662
  total_num_participating_athletes: {
@@ -675,6 +683,7 @@ exports.LIGHTDASH_TABLE_WITH_METRICS = {
675
683
  requiredAttributes: undefined,
676
684
  spotlight: {
677
685
  visibility: 'show',
686
+ categories: [],
678
687
  },
679
688
  },
680
689
  },
@@ -190,11 +190,18 @@
190
190
  },
191
191
  "spotlight": {
192
192
  "type": "object",
193
- "description": "Set the visibility of a metric in Spotlight",
193
+ "description": "Set the visibility and/or categories of a metric in Spotlight",
194
194
  "properties": {
195
195
  "visibility": {
196
196
  "type": "string",
197
197
  "enum": ["show", "hide"]
198
+ },
199
+ "categories": {
200
+ "type": "array",
201
+ "items": {
202
+ "type": "string"
203
+ },
204
+ "description": "An array of categories for the metric in Spotlight"
198
205
  }
199
206
  },
200
207
  "anyOf": [
@@ -202,6 +209,11 @@
202
209
  "required": [
203
210
  "visibility"
204
211
  ]
212
+ },
213
+ {
214
+ "required": [
215
+ "categories"
216
+ ]
205
217
  }
206
218
  ]
207
219
  }
@@ -233,14 +245,24 @@
233
245
  },
234
246
  "spotlight": {
235
247
  "type": "object",
236
- "description": "Set the visibility of all metrics in this model in Spotlight",
248
+ "description": "Set the visibility and/or categories of a metric in Spotlight",
237
249
  "properties": {
238
250
  "visibility": {
239
251
  "type": "string",
240
252
  "enum": ["show", "hide"]
253
+ },
254
+ "categories": {
255
+ "type": "array",
256
+ "items": {
257
+ "type": "string"
258
+ },
259
+ "description": "An optional array of categories for all metrics in this model in Spotlight"
241
260
  }
242
261
  },
243
- "anyOf": [{ "required": ["visibility"] }]
262
+ "anyOf": [
263
+ { "required": ["visibility"] },
264
+ { "required": ["categories"] }
265
+ ]
244
266
  }
245
267
  }
246
268
  },
@@ -387,7 +409,7 @@
387
409
  },
388
410
  "spotlight": {
389
411
  "type": "object",
390
- "description": "Set the visibility of a metric in Spotlight",
412
+ "description": "Set the visibility and/or categories of a metric in Spotlight",
391
413
  "properties": {
392
414
  "visibility": {
393
415
  "type": "string",
@@ -395,6 +417,13 @@
395
417
  "show",
396
418
  "hide"
397
419
  ]
420
+ },
421
+ "categories": {
422
+ "type": "array",
423
+ "items": {
424
+ "type": "string"
425
+ },
426
+ "description": "An array of categories for the metric in Spotlight"
398
427
  }
399
428
  },
400
429
  "anyOf": [
@@ -402,6 +431,11 @@
402
431
  "required": [
403
432
  "visibility"
404
433
  ]
434
+ },
435
+ {
436
+ "required": [
437
+ "categories"
438
+ ]
405
439
  }
406
440
  ]
407
441
  }
@@ -681,14 +715,24 @@
681
715
  },
682
716
  "spotlight": {
683
717
  "type": "object",
684
- "description": "Set the visibility of a metric in Spotlight",
718
+ "description": "Set the visibility and/or categories of a metric in Spotlight",
685
719
  "properties": {
686
720
  "visibility": {
687
721
  "type": "string",
688
722
  "enum": ["show", "hide"]
723
+ },
724
+ "categories": {
725
+ "type": "array",
726
+ "items": {
727
+ "type": "string"
728
+ },
729
+ "description": "An array of categories for the metric in Spotlight"
689
730
  }
690
731
  },
691
- "anyOf": [{ "required": ["visibility"] }]
732
+ "anyOf": [
733
+ { "required": ["visibility"] },
734
+ { "required": ["categories"] }
735
+ ]
692
736
  }
693
737
  }
694
738
  }
@@ -9,7 +9,39 @@
9
9
  "default_visibility": {
10
10
  "type": "string",
11
11
  "enum": ["show", "hide"],
12
- "default": "show"
12
+ "default": "show",
13
+ "description": "The visibility of Spotlight metrics by default - if not provided, it will be set to 'show'"
14
+ },
15
+ "categories": {
16
+ "type": "object",
17
+ "description": "Define the categories that can be used in Spotlight on your model yml files",
18
+ "patternProperties": {
19
+ "^[a-zA-Z0-9_-]+$": {
20
+ "type": "object",
21
+ "properties": {
22
+ "label": {
23
+ "description": "The label of the category as it will be displayed in Spotlight",
24
+ "type": "string"
25
+ },
26
+ "color": {
27
+ "description": "The color of the category, if not provided, it will be set to gray",
28
+ "type": "string",
29
+ "enum": [
30
+ "gray",
31
+ "violet",
32
+ "red",
33
+ "orange",
34
+ "green",
35
+ "blue",
36
+ "indigo",
37
+ "pink",
38
+ "yellow"
39
+ ]
40
+ }
41
+ },
42
+ "required": ["label"]
43
+ }
44
+ }
13
45
  }
14
46
  }
15
47
  }
@@ -41,7 +41,7 @@ export type CatalogField = Pick<Field, 'name' | 'label' | 'fieldType' | 'tableLa
41
41
  tableName: string;
42
42
  tableGroupLabel?: string;
43
43
  tags?: string[];
44
- categories: Pick<Tag, 'name' | 'color' | 'tagUuid'>[];
44
+ categories: Pick<Tag, 'name' | 'color' | 'tagUuid' | 'yamlReference'>[];
45
45
  chartUsage: number | undefined;
46
46
  icon: CatalogItemIcon | null;
47
47
  };
@@ -51,7 +51,7 @@ export type CatalogTable = Pick<TableBase, 'name' | 'label' | 'groupLabel' | 'de
51
51
  type: CatalogType.Table;
52
52
  groupLabel?: string;
53
53
  tags?: string[];
54
- categories: Pick<Tag, 'name' | 'color' | 'tagUuid'>[];
54
+ categories: Pick<Tag, 'name' | 'color' | 'tagUuid' | 'yamlReference'>[];
55
55
  joinedTables?: CompiledExploreJoin[];
56
56
  chartUsage: number | undefined;
57
57
  icon: CatalogItemIcon | null;
@@ -129,6 +129,7 @@ export type CatalogItemWithTagUuids = CatalogItemSummary & {
129
129
  tagUuid: string;
130
130
  createdByUserUuid: string | null;
131
131
  createdAt: Date;
132
+ taggedViaYaml: boolean;
132
133
  }[];
133
134
  };
134
135
  export type CatalogItemsWithIcons = CatalogItemSummary & Pick<CatalogItem, 'icon'>;
@@ -68,6 +68,7 @@ type DbtModelLightdashConfig = {
68
68
  };
69
69
  spotlight?: {
70
70
  visibility?: NonNullable<LightdashProjectConfig['spotlight']>['default_visibility'];
71
+ categories?: string[];
71
72
  };
72
73
  };
73
74
  export type DbtModelGroup = {
@@ -133,6 +134,7 @@ export type DbtColumnLightdashMetric = {
133
134
  default_time_dimension?: DefaultTimeDimension;
134
135
  spotlight?: {
135
136
  visibility?: NonNullable<LightdashProjectConfig['spotlight']>['default_visibility'];
137
+ categories?: string[];
136
138
  };
137
139
  } & DbtLightdashFieldTags;
138
140
  export type DbtModelLightdashMetric = DbtColumnLightdashMetric & Required<Pick<DbtColumnLightdashMetric, 'sql'>>;
@@ -248,8 +250,9 @@ type ConvertModelMetricArgs = {
248
250
  dimensionReference?: string;
249
251
  requiredAttributes?: Record<string, string | string[]>;
250
252
  spotlightConfig?: LightdashProjectConfig['spotlight'];
253
+ modelCategories?: string[];
251
254
  };
252
- export declare const convertModelMetric: ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, spotlightConfig, }: ConvertModelMetricArgs) => Metric;
255
+ export declare const convertModelMetric: ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, spotlightConfig, modelCategories, }: ConvertModelMetricArgs) => Metric;
253
256
  type ConvertColumnMetricArgs = Omit<ConvertModelMetricArgs, 'metric'> & {
254
257
  metric: DbtColumnLightdashMetric;
255
258
  dimensionName?: string;
@@ -257,7 +260,7 @@ type ConvertColumnMetricArgs = Omit<ConvertModelMetricArgs, 'metric'> & {
257
260
  requiredAttributes?: Record<string, string | string[]>;
258
261
  modelCategories?: string[];
259
262
  };
260
- export declare const convertColumnMetric: ({ modelName, dimensionName, dimensionSql, name, metric, source, tableLabel, requiredAttributes, spotlightConfig, }: ConvertColumnMetricArgs) => Metric;
263
+ export declare const convertColumnMetric: ({ modelName, dimensionName, dimensionSql, name, metric, source, tableLabel, requiredAttributes, spotlightConfig, modelCategories, }: ConvertColumnMetricArgs) => Metric;
261
264
  export declare enum DbtManifestVersion {
262
265
  V7 = "v7",
263
266
  V8 = "v8",
package/dist/types/dbt.js CHANGED
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCompiledModels = exports.getModelsFromManifest = exports.DbtExposureType = exports.getLatestSupportedDbtManifestVersion = exports.getDbtManifestVersion = exports.DbtManifestVersion = exports.convertColumnMetric = exports.convertModelMetric = exports.isDbtRpcRunSqlResults = exports.convertToGroups = exports.isDbtRpcCompileResults = exports.isDbtRpcManifestResults = exports.isSupportedDbtAdapterType = exports.isSupportedDbtAdapter = exports.isV9MetricRef = exports.isDbtPackages = exports.isDbtRpcDocsGenerateResults = exports.buildModelGraph = exports.patchPathParts = exports.normaliseModelDatabase = exports.SupportedDbtAdapter = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const dependency_graph_1 = require("dependency-graph");
6
+ const lightdashProjectConfig_1 = require("../compiler/lightdashProjectConfig");
6
7
  const assertUnreachable_1 = tslib_1.__importDefault(require("../utils/assertUnreachable"));
7
8
  const item_1 = require("../utils/item");
8
9
  const errors_1 = require("./errors");
@@ -136,9 +137,11 @@ results) => 'results' in results &&
136
137
  'rows' in result.table &&
137
138
  Array.isArray(result.table.rows));
138
139
  exports.isDbtRpcRunSqlResults = isDbtRpcRunSqlResults;
139
- const convertModelMetric = ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, spotlightConfig, }) => {
140
+ const convertModelMetric = ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, spotlightConfig, modelCategories = [], }) => {
140
141
  const groups = (0, exports.convertToGroups)(metric.groups, metric.group_label);
141
142
  const spotlightVisibility = metric.spotlight?.visibility ?? spotlightConfig?.default_visibility;
143
+ const metricCategories = Array.from(new Set([...modelCategories, ...(metric.spotlight?.categories || [])]));
144
+ const spotlightCategories = (0, lightdashProjectConfig_1.getCategoriesFromResource)('metric', name, spotlightConfig, metricCategories);
142
145
  return {
143
146
  fieldType: field_1.FieldType.METRIC,
144
147
  name,
@@ -176,17 +179,11 @@ const convertModelMetric = ({ modelName, name, metric, source, tableLabel, dimen
176
179
  },
177
180
  }
178
181
  : null),
179
- ...(spotlightVisibility !== undefined
180
- ? {
181
- spotlight: {
182
- visibility: spotlightVisibility,
183
- },
184
- }
185
- : {}),
182
+ ...(0, lightdashProjectConfig_1.getSpotlightConfigurationForResource)(spotlightVisibility, spotlightCategories),
186
183
  };
187
184
  };
188
185
  exports.convertModelMetric = convertModelMetric;
189
- const convertColumnMetric = ({ modelName, dimensionName, dimensionSql, name, metric, source, tableLabel, requiredAttributes, spotlightConfig, }) => (0, exports.convertModelMetric)({
186
+ const convertColumnMetric = ({ modelName, dimensionName, dimensionSql, name, metric, source, tableLabel, requiredAttributes, spotlightConfig, modelCategories = [], }) => (0, exports.convertModelMetric)({
190
187
  modelName,
191
188
  name,
192
189
  metric: {
@@ -212,6 +209,7 @@ const convertColumnMetric = ({ modelName, dimensionName, dimensionSql, name, met
212
209
  }
213
210
  : null),
214
211
  spotlightConfig,
212
+ modelCategories,
215
213
  });
216
214
  exports.convertColumnMetric = convertColumnMetric;
217
215
  var DbtManifestVersion;
@@ -45,7 +45,8 @@ export type Explore = {
45
45
  sqlPath?: string;
46
46
  type?: ExploreType;
47
47
  spotlight?: {
48
- visibility: Required<NonNullable<LightdashProjectConfig['spotlight']>>['default_visibility'];
48
+ visibility: LightdashProjectConfig['spotlight']['default_visibility'];
49
+ categories?: string[];
49
50
  };
50
51
  };
51
52
  export declare enum InlineErrorType {
@@ -243,7 +243,8 @@ export interface Metric extends Field {
243
243
  requiredAttributes?: Record<string, string | string[]>;
244
244
  defaultTimeDimension?: DefaultTimeDimension;
245
245
  spotlight?: {
246
- visibility: Required<NonNullable<LightdashProjectConfig['spotlight']>>['default_visibility'];
246
+ visibility: LightdashProjectConfig['spotlight']['default_visibility'];
247
+ categories?: string[];
247
248
  };
248
249
  }
249
250
  export declare const isFilterableDimension: (dimension: Dimension) => dimension is FilterableDimension;
@@ -1,8 +1,15 @@
1
+ type SpotlightCategory = {
2
+ label: string;
3
+ color?: string;
4
+ };
1
5
  type SpotlightConfig = {
2
6
  default_visibility: 'show' | 'hide';
7
+ categories?: {
8
+ [yaml_reference: string]: SpotlightCategory;
9
+ };
3
10
  };
4
11
  export type LightdashProjectConfig = {
5
12
  spotlight: SpotlightConfig;
6
13
  };
7
- export declare const DEFAULT_SPOTLIGHT_CONFIG: Required<SpotlightConfig>;
14
+ export declare const DEFAULT_SPOTLIGHT_CONFIG: SpotlightConfig;
8
15
  export {};
@@ -5,6 +5,7 @@ export type Tag = {
5
5
  name: string;
6
6
  color: string;
7
7
  createdAt: Date;
8
+ yamlReference: string | null;
8
9
  createdBy: Pick<LightdashUser, 'userUuid' | 'firstName' | 'lastName'> | null;
9
10
  };
10
11
  export type ApiGetTagsResponse = {
@@ -17,3 +18,7 @@ export type ApiCreateTagResponse = {
17
18
  tagUuid: string;
18
19
  };
19
20
  };
21
+ export type ApiReplaceYamlTagsResponse = {
22
+ status: 'ok';
23
+ results: undefined;
24
+ };
@@ -53,6 +53,7 @@ export declare const replaceDimensionInExplore: (explore: Explore, dimension: Co
53
53
  type?: import("../types/explore").ExploreType | undefined;
54
54
  spotlight?: {
55
55
  visibility: "show" | "hide";
56
+ categories?: string[] | undefined;
56
57
  } | undefined;
57
58
  };
58
59
  export declare const canApplyFormattingToCustomMetric: (item: Dimension, customMetricType: MetricType) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/common",
3
- "version": "0.1464.2",
3
+ "version": "0.1465.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [