@lightdash/common 0.1390.1 → 0.1392.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -134,6 +134,7 @@
134
134
  "type": "boolean"
135
135
  },
136
136
  "round": {
137
+ "description": "Rounds the metric to the specified number of decimal places",
137
138
  "type": "number",
138
139
  "minimum": 0
139
140
  },
@@ -160,6 +161,30 @@
160
161
  "minLength": 1
161
162
  },
162
163
  "maxItems": 3
164
+ },
165
+ "default_time_dimension": {
166
+ "type": "object",
167
+ "description": "Specifies the default time dimension field and interval to use for time-based analysis on this metric. If specified, both field and interval are required. If there is already a default time dimension set in the model, this will override it.",
168
+ "properties": {
169
+ "field": {
170
+ "type": "string",
171
+ "description": "The name of the field to use as the default time dimension"
172
+ },
173
+ "interval": {
174
+ "type": "string",
175
+ "enum": [
176
+ "DAY",
177
+ "WEEK",
178
+ "MONTH",
179
+ "YEAR"
180
+ ],
181
+ "description": "The default time interval to use when analyzing this time dimension"
182
+ }
183
+ },
184
+ "required": [
185
+ "field",
186
+ "interval"
187
+ ]
163
188
  }
164
189
  },
165
190
  "required": ["type", "sql"]
@@ -303,6 +328,30 @@
303
328
  "minLength": 1
304
329
  },
305
330
  "maxItems": 3
331
+ },
332
+ "default_time_dimension": {
333
+ "type": "object",
334
+ "description": "Specifies the default time dimension field and interval to use for time-based analysis on this metric. If specified, both field and interval are required. If there is already a default time dimension set in the model, this will override it.",
335
+ "properties": {
336
+ "field": {
337
+ "type": "string",
338
+ "description": "The name of the field to use as the default time dimension"
339
+ },
340
+ "interval": {
341
+ "type": "string",
342
+ "enum": [
343
+ "DAY",
344
+ "WEEK",
345
+ "MONTH",
346
+ "YEAR"
347
+ ],
348
+ "description": "The default time interval to use when analyzing this time dimension"
349
+ }
350
+ },
351
+ "required": [
352
+ "field",
353
+ "interval"
354
+ ]
306
355
  }
307
356
  },
308
357
  "required": ["type"]
@@ -552,6 +601,27 @@
552
601
  "percent",
553
602
  "id"
554
603
  ]
604
+ },
605
+ "default_time_dimension": {
606
+ "type": "object",
607
+ "description": "Specifies the default time dimension field and interval to use for time-based analysis on this metric. If specified, both field and interval are required. If there is already a default time dimension set in the model, this will override it.",
608
+ "properties": {
609
+ "field": {
610
+ "type": "string",
611
+ "description": "The name of the field to use as the default time dimension"
612
+ },
613
+ "interval": {
614
+ "type": "string",
615
+ "enum": [
616
+ "DAY",
617
+ "WEEK",
618
+ "MONTH",
619
+ "YEAR"
620
+ ],
621
+ "description": "The default time interval to use when analyzing this time dimension"
622
+ }
623
+ },
624
+ "required": ["field", "interval"]
555
625
  }
556
626
  }
557
627
  }
@@ -1,4 +1,4 @@
1
- import type { PromotionChanges, SavedChart } from '..';
1
+ import type { Dashboard, DashboardTile, PromotionChanges, SavedChart } from '..';
2
2
  export declare const currentVersion = 1;
3
3
  export type ChartAsCode = Pick<SavedChart, 'name' | 'description' | 'tableName' | 'metricQuery' | 'chartConfig' | 'tableConfig' | 'slug' | 'dashboardUuid' | 'updatedAt'> & {
4
4
  version: number;
@@ -13,3 +13,20 @@ export type ApiChartAsCodeUpsertResponse = {
13
13
  status: 'ok';
14
14
  results: PromotionChanges;
15
15
  };
16
+ export type DashboardTileWithoutUuids = Omit<DashboardTile, 'properties'> & {
17
+ properties: Omit<DashboardTile['properties'], 'savedChartUuid' | 'savedSqlUuid' | 'savedSemanticViewerChartUuid'>;
18
+ };
19
+ export type DashboardAsCode = Pick<Dashboard, 'name' | 'description' | 'updatedAt' | 'filters' | 'tabs' | 'slug'> & {
20
+ tiles: DashboardTileWithoutUuids[];
21
+ version: number;
22
+ spaceSlug: string;
23
+ downloadedAt?: Date;
24
+ };
25
+ export type ApiDashboardAsCodeListResponse = {
26
+ status: 'ok';
27
+ results: DashboardAsCode[];
28
+ };
29
+ export type ApiDashboardAsCodeUpsertResponse = {
30
+ status: 'ok';
31
+ results: PromotionChanges;
32
+ };
@@ -45,6 +45,7 @@ export type DashboardChartTileProperties = {
45
45
  belongsToDashboard?: boolean;
46
46
  chartName?: string | null;
47
47
  lastVersionChartKind?: ChartKind | null;
48
+ chartSlug?: string;
48
49
  };
49
50
  };
50
51
  export type DashboardSqlChartTileProperties = {
@@ -54,6 +55,7 @@ export type DashboardSqlChartTileProperties = {
54
55
  savedSqlUuid: string | null;
55
56
  chartName: string;
56
57
  hideTitle?: boolean;
58
+ chartSlug?: string;
57
59
  };
58
60
  };
59
61
  export type DashboardSemanticViewerChartTileProperties = {
@@ -63,6 +65,7 @@ export type DashboardSemanticViewerChartTileProperties = {
63
65
  savedSemanticViewerChartUuid: string | null;
64
66
  chartName: string;
65
67
  hideTitle?: boolean;
68
+ chartSlug?: string;
66
69
  };
67
70
  };
68
71
  export type CreateDashboardMarkdownTile = CreateDashboardTileBase & DashboardMarkdownTileProperties;
@@ -2,7 +2,7 @@ import { DepGraph } from 'dependency-graph';
2
2
  import { type ColumnInfo, type CompiledModelNode, type ParsedMetric } from './dbtFromSchema';
3
3
  import { type CompactOrAlias, type DimensionType, type FieldUrl, type Format, type Metric, type MetricType, type Source } from './field';
4
4
  import { type OrderFieldsByStrategy } from './table';
5
- import { type TimeFrames } from './timeFrames';
5
+ import { type DefaultTimeDimension, type TimeFrames } from './timeFrames';
6
6
  export declare enum SupportedDbtAdapter {
7
7
  BIGQUERY = "bigquery",
8
8
  DATABRICKS = "databricks",
@@ -125,6 +125,7 @@ export type DbtColumnLightdashMetric = {
125
125
  [key: string]: any;
126
126
  }[];
127
127
  percentile?: number;
128
+ default_time_dimension?: DefaultTimeDimension;
128
129
  } & DbtLightdashFieldTags;
129
130
  export type DbtModelLightdashMetric = DbtColumnLightdashMetric & Required<Pick<DbtColumnLightdashMetric, 'sql'>>;
130
131
  export declare const normaliseModelDatabase: (model: DbtRawModelNode, targetWarehouse: SupportedDbtAdapter) => DbtModelNode;
package/dist/types/dbt.js CHANGED
@@ -165,6 +165,14 @@ const convertModelMetric = ({ modelName, name, metric, source, tableLabel, dimen
165
165
  : [metric.tags],
166
166
  }
167
167
  : {}),
168
+ ...(metric.default_time_dimension
169
+ ? {
170
+ defaultTimeDimension: {
171
+ field: metric.default_time_dimension.field,
172
+ interval: metric.default_time_dimension.interval,
173
+ },
174
+ }
175
+ : {}),
168
176
  };
169
177
  };
170
178
  exports.convertModelMetric = convertModelMetric;
@@ -185,6 +193,14 @@ const convertColumnMetric = ({ modelName, dimensionName, dimensionSql, name, met
185
193
  ? (0, item_1.getItemId)({ table: modelName, name: dimensionName })
186
194
  : undefined,
187
195
  requiredAttributes,
196
+ ...(metric.default_time_dimension
197
+ ? {
198
+ defaultTimeDimension: {
199
+ field: metric.default_time_dimension.field,
200
+ interval: metric.default_time_dimension.interval,
201
+ },
202
+ }
203
+ : {}),
188
204
  });
189
205
  exports.convertColumnMetric = convertColumnMetric;
190
206
  var DbtManifestVersion;
@@ -1,4 +1,4 @@
1
- import type { AdditionalMetric, currencies } from '..';
1
+ import type { AdditionalMetric, currencies, DefaultTimeDimension } from '..';
2
2
  import { type MetricFilterRule } from './filter';
3
3
  import { type TimeFrames } from './timeFrames';
4
4
  export declare enum Compact {
@@ -238,6 +238,7 @@ export interface Metric extends Field {
238
238
  formatOptions?: CustomFormat;
239
239
  dimensionReference?: string;
240
240
  requiredAttributes?: Record<string, string | string[]>;
241
+ defaultTimeDimension?: DefaultTimeDimension;
241
242
  }
242
243
  export declare const isFilterableDimension: (dimension: Dimension) => dimension is FilterableDimension;
243
244
  export type FilterableField = TableCalculation | Metric | FilterableDimension | CustomSqlDimension;
@@ -1,5 +1,5 @@
1
1
  import { type MetricFilterRule } from './filter';
2
- import type { TimeFrames } from './timeFrames';
2
+ import type { DefaultTimeDimension } from './timeFrames';
3
3
  export declare enum OrderFieldsByStrategy {
4
4
  LABEL = "LABEL",
5
5
  INDEX = "INDEX"
@@ -23,8 +23,5 @@ export type TableBase = {
23
23
  hidden?: boolean;
24
24
  requiredAttributes?: Record<string, string | string[]>;
25
25
  groupDetails?: Record<string, GroupType>;
26
- defaultTimeDimension?: {
27
- field: string;
28
- interval: TimeFrames;
29
- };
26
+ defaultTimeDimension?: DefaultTimeDimension;
30
27
  };
@@ -30,3 +30,7 @@ export declare enum DateGranularity {
30
30
  YEAR = "Year"
31
31
  }
32
32
  export declare const dateGranularityToTimeFrameMap: Record<DateGranularity, TimeFrames>;
33
+ export type DefaultTimeDimension = {
34
+ field: string;
35
+ interval: TimeFrames;
36
+ };
@@ -30,10 +30,7 @@ export declare const replaceDimensionInExplore: (explore: Explore, dimension: Co
30
30
  hidden?: boolean | undefined;
31
31
  requiredAttributes?: Record<string, string | string[]> | undefined;
32
32
  groupDetails?: Record<string, import("..").GroupType> | undefined;
33
- defaultTimeDimension?: {
34
- field: string;
35
- interval: import("..").TimeFrames;
36
- } | undefined;
33
+ defaultTimeDimension?: import("..").DefaultTimeDimension | undefined;
37
34
  metrics: Record<string, import("../types/field").CompiledMetric>;
38
35
  lineageGraph: import("..").LineageGraph;
39
36
  source?: import("../types/field").Source | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lightdash/common",
3
- "version": "0.1390.1",
3
+ "version": "0.1392.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [