@lightdash/common 0.1462.2 → 0.1464.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.
- package/dist/compiler/exploreCompiler.d.ts +5 -2
- package/dist/compiler/exploreCompiler.js +9 -1
- package/dist/compiler/exploreCompiler.mock.js +40 -1
- package/dist/compiler/translator.d.ts +3 -2
- package/dist/compiler/translator.js +26 -6
- package/dist/compiler/translator.mock.js +27 -0
- package/dist/compiler/translator.test.js +19 -20
- package/dist/dbt/schemas/lightdashMetadata.json +1 -1
- package/dist/dbt/validation.d.ts +2 -1
- package/dist/index.d.ts +12 -7
- package/dist/index.js +8 -3
- package/dist/schemas/json/lightdash-dbt-2.0.json +63 -0
- package/dist/schemas/json/lightdash-project-config-1.0.json +17 -0
- package/dist/types/any.d.ts +7 -0
- package/dist/types/any.js +2 -0
- package/dist/types/api/errors.d.ts +2 -1
- package/dist/types/dbt.d.ts +21 -11
- package/dist/types/dbt.js +14 -3
- package/dist/types/errors.d.ts +18 -17
- package/dist/types/explore.d.ts +4 -0
- package/dist/types/field.d.ts +11 -6
- package/dist/types/field.js +3 -1
- package/dist/types/field.test.js +1 -0
- package/dist/types/filter.d.ts +4 -3
- package/dist/types/filterGrammar.d.ts +3 -2
- package/dist/types/lightdashProjectConfig.d.ts +8 -0
- package/dist/types/lightdashProjectConfig.js +6 -0
- package/dist/types/metricQuery.d.ts +8 -7
- package/dist/types/scheduler.d.ts +3 -2
- package/dist/types/user.d.ts +3 -2
- package/dist/types/warehouse.d.ts +5 -4
- package/dist/utils/filters.d.ts +6 -5
- package/dist/utils/formatting.js +2 -1
- package/dist/utils/formatting.test.js +5 -1
- package/dist/utils/item.d.ts +3 -0
- package/dist/utils/loadLightdashProjectConfig.d.ts +2 -0
- package/dist/utils/loadLightdashProjectConfig.js +26 -0
- package/dist/utils/metricsExplorer.d.ts +3 -2
- package/dist/utils/virtualView.js +1 -0
- package/dist/visualizations/CartesianChartDataModel.d.ts +4 -3
- package/dist/visualizations/PieChartDataModel.d.ts +2 -1
- package/dist/visualizations/TableDataModel.d.ts +2 -1
- package/package.json +4 -1
package/dist/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.getProjectDirectory = exports.deepEqual = exports.removeEmptyProperties = exports.formatRows = exports.itemsInMetricQuery = exports.getTableCalculationsFromItemsMap = exports.getMetricsFromItemsMap = exports.getFilterableDimensionsFromItemsMap = exports.getDimensionsFromItemsMap = exports.getItemMap = exports.getFieldMap = exports.getAxisName = exports.getDateGroupLabel = exports.getResultValueArray = exports.DbtProjectTypeLabels = exports.sensitiveDbtCredentialsFieldNames = exports.DBFieldTypes = exports.LightdashInstallType = exports.isLightdashMode = exports.LightdashMode = exports.isApiError = exports.hasInviteCode = exports.TableSelectionType = exports.hasSpecialCharacters = exports.snakeCaseName = exports.findFieldByIdInExplore = exports.getVisibleFields = exports.SEED_GROUP = exports.SEED_SPACE = exports.SEED_PROJECT = exports.SEED_ORG_2_ADMIN_PASSWORD = exports.SEED_ORG_2_ADMIN_EMAIL = exports.SEED_ORG_2_ADMIN = exports.SEED_ORG_2 = exports.SEED_ORG_1_ADMIN_PASSWORD = exports.SEED_ORG_1_ADMIN_EMAIL = exports.SEED_ORG_1_ADMIN = exports.SEED_ORG_1 = exports.hexToRGB = exports.replaceStringInArray = exports.toggleArrayValue = exports.hasIntersection = exports.validatePassword = exports.getPasswordSchema = exports.getEmailSchema = exports.validateEmail = exports.assertUnreachable = exports.lightdashDbtYamlSchema = void 0;
|
3
|
+
exports.getProjectDirectory = exports.deepEqual = exports.removeEmptyProperties = exports.formatRows = exports.itemsInMetricQuery = exports.getTableCalculationsFromItemsMap = exports.getMetricsFromItemsMap = exports.getFilterableDimensionsFromItemsMap = exports.getDimensionsFromItemsMap = exports.getItemMap = exports.getFieldMap = exports.getAxisName = exports.getDateGroupLabel = exports.getResultValueArray = exports.DbtProjectTypeLabels = exports.sensitiveDbtCredentialsFieldNames = exports.DBFieldTypes = exports.LightdashInstallType = exports.isLightdashMode = exports.LightdashMode = exports.isApiError = exports.hasInviteCode = exports.TableSelectionType = exports.hasSpecialCharacters = exports.snakeCaseName = exports.findFieldByIdInExplore = exports.getVisibleFields = exports.SEED_GROUP = exports.SEED_SPACE = exports.SEED_PROJECT = exports.SEED_ORG_2_ADMIN_PASSWORD = exports.SEED_ORG_2_ADMIN_EMAIL = exports.SEED_ORG_2_ADMIN = exports.SEED_ORG_2 = exports.SEED_ORG_1_ADMIN_PASSWORD = exports.SEED_ORG_1_ADMIN_EMAIL = exports.SEED_ORG_1_ADMIN = exports.SEED_ORG_1 = exports.hexToRGB = exports.replaceStringInArray = exports.toggleArrayValue = exports.hasIntersection = exports.validatePassword = exports.getPasswordSchema = exports.getEmailSchema = exports.validateEmail = exports.assertUnreachable = exports.lightdashProjectConfigSchema = exports.lightdashDbtYamlSchema = void 0;
|
4
4
|
const tslib_1 = require("tslib");
|
5
5
|
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
|
6
6
|
const utc_1 = tslib_1.__importDefault(require("dayjs/plugin/utc"));
|
@@ -22,17 +22,20 @@ tslib_1.__exportStar(require("./dbt/validation"), exports);
|
|
22
22
|
tslib_1.__exportStar(require("./pivotTable/pivotQueryResults"), exports);
|
23
23
|
var lightdash_dbt_2_0_json_1 = require("./schemas/json/lightdash-dbt-2.0.json");
|
24
24
|
Object.defineProperty(exports, "lightdashDbtYamlSchema", { enumerable: true, get: function () { return tslib_1.__importDefault(lightdash_dbt_2_0_json_1).default; } });
|
25
|
+
var lightdash_project_config_1_0_json_1 = require("./schemas/json/lightdash-project-config-1.0.json");
|
26
|
+
Object.defineProperty(exports, "lightdashProjectConfigSchema", { enumerable: true, get: function () { return tslib_1.__importDefault(lightdash_project_config_1_0_json_1).default; } });
|
25
27
|
tslib_1.__exportStar(require("./templating/template"), exports);
|
26
28
|
tslib_1.__exportStar(require("./types/analytics"), exports);
|
29
|
+
tslib_1.__exportStar(require("./types/any"), exports);
|
27
30
|
tslib_1.__exportStar(require("./types/api"), exports);
|
28
31
|
tslib_1.__exportStar(require("./types/api/comments"), exports);
|
29
32
|
tslib_1.__exportStar(require("./types/api/errors"), exports);
|
30
33
|
tslib_1.__exportStar(require("./types/api/notifications"), exports);
|
31
34
|
tslib_1.__exportStar(require("./types/api/share"), exports);
|
32
35
|
tslib_1.__exportStar(require("./types/api/sort"), exports);
|
36
|
+
tslib_1.__exportStar(require("./types/api/spotlight"), exports);
|
33
37
|
tslib_1.__exportStar(require("./types/api/success"), exports);
|
34
38
|
tslib_1.__exportStar(require("./types/api/uuid"), exports);
|
35
|
-
tslib_1.__exportStar(require("./types/api/spotlight"), exports);
|
36
39
|
tslib_1.__exportStar(require("./types/catalog"), exports);
|
37
40
|
tslib_1.__exportStar(require("./types/coder"), exports);
|
38
41
|
tslib_1.__exportStar(require("./types/comments"), exports);
|
@@ -56,6 +59,7 @@ tslib_1.__exportStar(require("./types/gitIntegration"), exports);
|
|
56
59
|
tslib_1.__exportStar(require("./types/groups"), exports);
|
57
60
|
tslib_1.__exportStar(require("./types/job"), exports);
|
58
61
|
tslib_1.__exportStar(require("./types/knex-paginate"), exports);
|
62
|
+
tslib_1.__exportStar(require("./types/lightdashProjectConfig"), exports);
|
59
63
|
tslib_1.__exportStar(require("./types/metricQuery"), exports);
|
60
64
|
tslib_1.__exportStar(require("./types/metricsExplorer"), exports);
|
61
65
|
tslib_1.__exportStar(require("./types/notifications"), exports);
|
@@ -80,6 +84,7 @@ tslib_1.__exportStar(require("./types/share"), exports);
|
|
80
84
|
tslib_1.__exportStar(require("./types/slack"), exports);
|
81
85
|
tslib_1.__exportStar(require("./types/slackSettings"), exports);
|
82
86
|
tslib_1.__exportStar(require("./types/space"), exports);
|
87
|
+
tslib_1.__exportStar(require("./types/spotlightTableConfig"), exports);
|
83
88
|
tslib_1.__exportStar(require("./types/sqlRunner"), exports);
|
84
89
|
tslib_1.__exportStar(require("./types/SshKeyPair"), exports);
|
85
90
|
tslib_1.__exportStar(require("./types/table"), exports);
|
@@ -105,6 +110,7 @@ tslib_1.__exportStar(require("./utils/filters"), exports);
|
|
105
110
|
tslib_1.__exportStar(require("./utils/formatting"), exports);
|
106
111
|
tslib_1.__exportStar(require("./utils/github"), exports);
|
107
112
|
tslib_1.__exportStar(require("./utils/item"), exports);
|
113
|
+
tslib_1.__exportStar(require("./utils/loadLightdashProjectConfig"), exports);
|
108
114
|
tslib_1.__exportStar(require("./utils/metricsExplorer"), exports);
|
109
115
|
tslib_1.__exportStar(require("./utils/projectMemberRole"), exports);
|
110
116
|
tslib_1.__exportStar(require("./utils/sanitizeHtml"), exports);
|
@@ -120,7 +126,6 @@ tslib_1.__exportStar(require("./visualizations/PieChartDataModel"), exports);
|
|
120
126
|
tslib_1.__exportStar(require("./visualizations/TableDataModel"), exports);
|
121
127
|
tslib_1.__exportStar(require("./visualizations/types"), exports);
|
122
128
|
tslib_1.__exportStar(require("./visualizations/types/IResultsRunner"), exports);
|
123
|
-
tslib_1.__exportStar(require("./types/spotlightTableConfig"), exports);
|
124
129
|
const validateEmail = (email) => {
|
125
130
|
if (/\s/.test(email)) {
|
126
131
|
return false;
|
@@ -146,6 +146,7 @@
|
|
146
146
|
"usd",
|
147
147
|
"gbp",
|
148
148
|
"jpy",
|
149
|
+
"dkk",
|
149
150
|
"eur",
|
150
151
|
"percent",
|
151
152
|
"id"
|
@@ -186,6 +187,23 @@
|
|
186
187
|
"field",
|
187
188
|
"interval"
|
188
189
|
]
|
190
|
+
},
|
191
|
+
"spotlight": {
|
192
|
+
"type": "object",
|
193
|
+
"description": "Set the visibility of a metric in Spotlight",
|
194
|
+
"properties": {
|
195
|
+
"visibility": {
|
196
|
+
"type": "string",
|
197
|
+
"enum": ["show", "hide"]
|
198
|
+
}
|
199
|
+
},
|
200
|
+
"anyOf": [
|
201
|
+
{
|
202
|
+
"required": [
|
203
|
+
"visibility"
|
204
|
+
]
|
205
|
+
}
|
206
|
+
]
|
189
207
|
}
|
190
208
|
},
|
191
209
|
"required": ["type", "sql"]
|
@@ -212,6 +230,17 @@
|
|
212
230
|
}
|
213
231
|
},
|
214
232
|
"required": ["field", "interval"]
|
233
|
+
},
|
234
|
+
"spotlight": {
|
235
|
+
"type": "object",
|
236
|
+
"description": "Set the visibility of all metrics in this model in Spotlight",
|
237
|
+
"properties": {
|
238
|
+
"visibility": {
|
239
|
+
"type": "string",
|
240
|
+
"enum": ["show", "hide"]
|
241
|
+
}
|
242
|
+
},
|
243
|
+
"anyOf": [{ "required": ["visibility"] }]
|
215
244
|
}
|
216
245
|
}
|
217
246
|
},
|
@@ -313,6 +342,7 @@
|
|
313
342
|
"mi",
|
314
343
|
"usd",
|
315
344
|
"jpy",
|
345
|
+
"dkk",
|
316
346
|
"gbp",
|
317
347
|
"eur",
|
318
348
|
"percent",
|
@@ -354,6 +384,26 @@
|
|
354
384
|
"field",
|
355
385
|
"interval"
|
356
386
|
]
|
387
|
+
},
|
388
|
+
"spotlight": {
|
389
|
+
"type": "object",
|
390
|
+
"description": "Set the visibility of a metric in Spotlight",
|
391
|
+
"properties": {
|
392
|
+
"visibility": {
|
393
|
+
"type": "string",
|
394
|
+
"enum": [
|
395
|
+
"show",
|
396
|
+
"hide"
|
397
|
+
]
|
398
|
+
}
|
399
|
+
},
|
400
|
+
"anyOf": [
|
401
|
+
{
|
402
|
+
"required": [
|
403
|
+
"visibility"
|
404
|
+
]
|
405
|
+
}
|
406
|
+
]
|
357
407
|
}
|
358
408
|
},
|
359
409
|
"required": ["type"]
|
@@ -399,6 +449,7 @@
|
|
399
449
|
"mi",
|
400
450
|
"usd",
|
401
451
|
"jpy",
|
452
|
+
"dkk",
|
402
453
|
"gbp",
|
403
454
|
"eur",
|
404
455
|
"percent",
|
@@ -600,6 +651,7 @@
|
|
600
651
|
"mi",
|
601
652
|
"usd",
|
602
653
|
"jpy",
|
654
|
+
"dkk",
|
603
655
|
"gbp",
|
604
656
|
"eur",
|
605
657
|
"percent",
|
@@ -626,6 +678,17 @@
|
|
626
678
|
}
|
627
679
|
},
|
628
680
|
"required": ["field", "interval"]
|
681
|
+
},
|
682
|
+
"spotlight": {
|
683
|
+
"type": "object",
|
684
|
+
"description": "Set the visibility of a metric in Spotlight",
|
685
|
+
"properties": {
|
686
|
+
"visibility": {
|
687
|
+
"type": "string",
|
688
|
+
"enum": ["show", "hide"]
|
689
|
+
}
|
690
|
+
},
|
691
|
+
"anyOf": [{ "required": ["visibility"] }]
|
629
692
|
}
|
630
693
|
}
|
631
694
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
{
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
3
|
+
"$id": "https://schemas.lightdash.com/lightdash/config.json",
|
4
|
+
"type": ["object", "null"],
|
5
|
+
"properties": {
|
6
|
+
"spotlight": {
|
7
|
+
"type": ["object", "null"],
|
8
|
+
"properties": {
|
9
|
+
"default_visibility": {
|
10
|
+
"type": "string",
|
11
|
+
"enum": ["show", "hide"],
|
12
|
+
"default": "show"
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/** This AnyType is an alias for any
|
2
|
+
* The goal is to make it easier to identify any type in the codebase
|
3
|
+
* without having to eslint-disable all the time
|
4
|
+
* These are only used on legacy `any` types, don't use it for new types.
|
5
|
+
* This is added on a separate file to avoid circular dependencies.
|
6
|
+
*/
|
7
|
+
export type AnyType = any;
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { type AnyType } from '../any';
|
1
2
|
/**
|
2
3
|
* The Error object is returned from the api any time there is an error.
|
3
4
|
* The message contains
|
@@ -21,6 +22,6 @@ export type ApiErrorPayload = {
|
|
21
22
|
/**
|
22
23
|
* Optional data containing details of the error
|
23
24
|
*/
|
24
|
-
data?:
|
25
|
+
data?: AnyType;
|
25
26
|
};
|
26
27
|
};
|
package/dist/types/dbt.d.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import { DepGraph } from 'dependency-graph';
|
2
|
+
import { type AnyType } from './any';
|
2
3
|
import { type ColumnInfo, type CompiledModelNode, type ParsedMetric } from './dbtFromSchema';
|
3
4
|
import { type CompactOrAlias, type DimensionType, type FieldUrl, type Format, type Metric, type MetricType, type Source } from './field';
|
5
|
+
import { type LightdashProjectConfig } from './lightdashProjectConfig';
|
4
6
|
import { type OrderFieldsByStrategy } from './table';
|
5
7
|
import { type DefaultTimeDimension, type TimeFrames } from './timeFrames';
|
6
8
|
export declare enum SupportedDbtAdapter {
|
@@ -56,7 +58,7 @@ type DbtModelLightdashConfig = {
|
|
56
58
|
sql_filter?: string;
|
57
59
|
sql_where?: string;
|
58
60
|
required_filters?: {
|
59
|
-
[key: string]:
|
61
|
+
[key: string]: AnyType;
|
60
62
|
}[];
|
61
63
|
required_attributes?: Record<string, string | string[]>;
|
62
64
|
group_details?: Record<string, DbtModelGroup>;
|
@@ -64,6 +66,9 @@ type DbtModelLightdashConfig = {
|
|
64
66
|
field: string;
|
65
67
|
interval: TimeFrames;
|
66
68
|
};
|
69
|
+
spotlight?: {
|
70
|
+
visibility?: NonNullable<LightdashProjectConfig['spotlight']>['default_visibility'];
|
71
|
+
};
|
67
72
|
};
|
68
73
|
export type DbtModelGroup = {
|
69
74
|
label: string;
|
@@ -122,10 +127,13 @@ export type DbtColumnLightdashMetric = {
|
|
122
127
|
urls?: FieldUrl[];
|
123
128
|
show_underlying_values?: string[];
|
124
129
|
filters?: {
|
125
|
-
[key: string]:
|
130
|
+
[key: string]: AnyType;
|
126
131
|
}[];
|
127
132
|
percentile?: number;
|
128
133
|
default_time_dimension?: DefaultTimeDimension;
|
134
|
+
spotlight?: {
|
135
|
+
visibility?: NonNullable<LightdashProjectConfig['spotlight']>['default_visibility'];
|
136
|
+
};
|
129
137
|
} & DbtLightdashFieldTags;
|
130
138
|
export type DbtModelLightdashMetric = DbtColumnLightdashMetric & Required<Pick<DbtColumnLightdashMetric, 'sql'>>;
|
131
139
|
export declare const normaliseModelDatabase: (model: DbtRawModelNode, targetWarehouse: SupportedDbtAdapter) => DbtModelNode;
|
@@ -164,7 +172,7 @@ export interface DbtRpcDocsGenerateResults {
|
|
164
172
|
[k: string]: DbtCatalogNode;
|
165
173
|
};
|
166
174
|
}
|
167
|
-
export declare const isDbtRpcDocsGenerateResults: (results: Record<string,
|
175
|
+
export declare const isDbtRpcDocsGenerateResults: (results: Record<string, AnyType>) => results is DbtRpcDocsGenerateResults;
|
168
176
|
export interface DbtPackage {
|
169
177
|
package: string;
|
170
178
|
version: string;
|
@@ -172,7 +180,7 @@ export interface DbtPackage {
|
|
172
180
|
export interface DbtPackages {
|
173
181
|
packages: DbtPackage[];
|
174
182
|
}
|
175
|
-
export declare const isDbtPackages: (results: Record<string,
|
183
|
+
export declare const isDbtPackages: (results: Record<string, AnyType>) => results is DbtPackages;
|
176
184
|
export type V9MetricRef = {
|
177
185
|
name: string;
|
178
186
|
package?: string | null;
|
@@ -180,7 +188,7 @@ export type V9MetricRef = {
|
|
180
188
|
};
|
181
189
|
export declare const isV9MetricRef: (x: string[] | V9MetricRef) => x is V9MetricRef;
|
182
190
|
export type DbtMetric = Omit<ParsedMetric, 'refs'> & {
|
183
|
-
meta?: Record<string,
|
191
|
+
meta?: Record<string, AnyType> & DbtMetricLightdashMetadata;
|
184
192
|
refs?: string[][] | V9MetricRef[];
|
185
193
|
};
|
186
194
|
export type DbtMetricLightdashMetadata = {
|
@@ -188,7 +196,7 @@ export type DbtMetricLightdashMetadata = {
|
|
188
196
|
group_label?: string;
|
189
197
|
groups?: string[];
|
190
198
|
show_underlying_values?: string[];
|
191
|
-
filters: Record<string,
|
199
|
+
filters: Record<string, AnyType>[];
|
192
200
|
};
|
193
201
|
export type DbtDoc = {
|
194
202
|
unique_id: string;
|
@@ -214,18 +222,18 @@ export declare const isSupportedDbtAdapterType: (x: string) => x is SupportedDbt
|
|
214
222
|
export interface DbtRpcGetManifestResults {
|
215
223
|
manifest: DbtManifest;
|
216
224
|
}
|
217
|
-
export declare const isDbtRpcManifestResults: (results: Record<string,
|
225
|
+
export declare const isDbtRpcManifestResults: (results: Record<string, AnyType>) => results is DbtRpcGetManifestResults;
|
218
226
|
export interface DbtRpcCompileResults {
|
219
227
|
results: {
|
220
228
|
node: DbtNode;
|
221
229
|
}[];
|
222
230
|
}
|
223
|
-
export declare const isDbtRpcCompileResults: (results: Record<string,
|
231
|
+
export declare const isDbtRpcCompileResults: (results: Record<string, AnyType>) => results is DbtRpcCompileResults;
|
224
232
|
export interface DbtRpcRunSqlResults {
|
225
233
|
results: {
|
226
234
|
table: {
|
227
235
|
column_names: string[];
|
228
|
-
rows:
|
236
|
+
rows: AnyType[][];
|
229
237
|
};
|
230
238
|
}[];
|
231
239
|
}
|
@@ -239,15 +247,17 @@ type ConvertModelMetricArgs = {
|
|
239
247
|
tableLabel: string;
|
240
248
|
dimensionReference?: string;
|
241
249
|
requiredAttributes?: Record<string, string | string[]>;
|
250
|
+
spotlightConfig?: LightdashProjectConfig['spotlight'];
|
242
251
|
};
|
243
|
-
export declare const convertModelMetric: ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, }: ConvertModelMetricArgs) => Metric;
|
252
|
+
export declare const convertModelMetric: ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, spotlightConfig, }: ConvertModelMetricArgs) => Metric;
|
244
253
|
type ConvertColumnMetricArgs = Omit<ConvertModelMetricArgs, 'metric'> & {
|
245
254
|
metric: DbtColumnLightdashMetric;
|
246
255
|
dimensionName?: string;
|
247
256
|
dimensionSql: string;
|
248
257
|
requiredAttributes?: Record<string, string | string[]>;
|
258
|
+
modelCategories?: string[];
|
249
259
|
};
|
250
|
-
export declare const convertColumnMetric: ({ modelName, dimensionName, dimensionSql, name, metric, source, tableLabel, requiredAttributes, }: ConvertColumnMetricArgs) => Metric;
|
260
|
+
export declare const convertColumnMetric: ({ modelName, dimensionName, dimensionSql, name, metric, source, tableLabel, requiredAttributes, spotlightConfig, }: ConvertColumnMetricArgs) => Metric;
|
251
261
|
export declare enum DbtManifestVersion {
|
252
262
|
V7 = "v7",
|
253
263
|
V8 = "v8",
|
package/dist/types/dbt.js
CHANGED
@@ -122,7 +122,9 @@ const convertToGroups = (dbtGroups, dbtGroupLabel) => {
|
|
122
122
|
return groups;
|
123
123
|
};
|
124
124
|
exports.convertToGroups = convertToGroups;
|
125
|
-
const isDbtRpcRunSqlResults = (
|
125
|
+
const isDbtRpcRunSqlResults = (
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
127
|
+
results) => 'results' in results &&
|
126
128
|
Array.isArray(results.results) &&
|
127
129
|
results.results.every((result) => typeof result === 'object' &&
|
128
130
|
result !== null &&
|
@@ -134,8 +136,9 @@ const isDbtRpcRunSqlResults = (results) => 'results' in results &&
|
|
134
136
|
'rows' in result.table &&
|
135
137
|
Array.isArray(result.table.rows));
|
136
138
|
exports.isDbtRpcRunSqlResults = isDbtRpcRunSqlResults;
|
137
|
-
const convertModelMetric = ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, }) => {
|
139
|
+
const convertModelMetric = ({ modelName, name, metric, source, tableLabel, dimensionReference, requiredAttributes, spotlightConfig, }) => {
|
138
140
|
const groups = (0, exports.convertToGroups)(metric.groups, metric.group_label);
|
141
|
+
const spotlightVisibility = metric.spotlight?.visibility ?? spotlightConfig?.default_visibility;
|
139
142
|
return {
|
140
143
|
fieldType: field_1.FieldType.METRIC,
|
141
144
|
name,
|
@@ -173,10 +176,17 @@ const convertModelMetric = ({ modelName, name, metric, source, tableLabel, dimen
|
|
173
176
|
},
|
174
177
|
}
|
175
178
|
: null),
|
179
|
+
...(spotlightVisibility !== undefined
|
180
|
+
? {
|
181
|
+
spotlight: {
|
182
|
+
visibility: spotlightVisibility,
|
183
|
+
},
|
184
|
+
}
|
185
|
+
: {}),
|
176
186
|
};
|
177
187
|
};
|
178
188
|
exports.convertModelMetric = convertModelMetric;
|
179
|
-
const convertColumnMetric = ({ modelName, dimensionName, dimensionSql, name, metric, source, tableLabel, requiredAttributes, }) => (0, exports.convertModelMetric)({
|
189
|
+
const convertColumnMetric = ({ modelName, dimensionName, dimensionSql, name, metric, source, tableLabel, requiredAttributes, spotlightConfig, }) => (0, exports.convertModelMetric)({
|
180
190
|
modelName,
|
181
191
|
name,
|
182
192
|
metric: {
|
@@ -201,6 +211,7 @@ const convertColumnMetric = ({ modelName, dimensionName, dimensionSql, name, met
|
|
201
211
|
},
|
202
212
|
}
|
203
213
|
: null),
|
214
|
+
spotlightConfig,
|
204
215
|
});
|
205
216
|
exports.convertColumnMetric = convertColumnMetric;
|
206
217
|
var DbtManifestVersion;
|
package/dist/types/errors.d.ts
CHANGED
@@ -1,32 +1,33 @@
|
|
1
|
+
import { type AnyType } from './any';
|
1
2
|
import { type DbtLog } from './job';
|
2
3
|
type LightdashErrorParams = {
|
3
4
|
message: string;
|
4
5
|
name: string;
|
5
6
|
statusCode: number;
|
6
7
|
data: {
|
7
|
-
[key: string]:
|
8
|
+
[key: string]: AnyType;
|
8
9
|
};
|
9
10
|
};
|
10
11
|
export declare class LightdashError extends Error {
|
11
12
|
statusCode: number;
|
12
13
|
data: {
|
13
|
-
[key: string]:
|
14
|
+
[key: string]: AnyType;
|
14
15
|
};
|
15
16
|
constructor({ message, name, statusCode, data }: LightdashErrorParams);
|
16
17
|
}
|
17
18
|
export declare class ForbiddenError extends LightdashError {
|
18
19
|
constructor(message?: string, data?: {
|
19
|
-
[key: string]:
|
20
|
+
[key: string]: AnyType;
|
20
21
|
});
|
21
22
|
}
|
22
23
|
export declare class DeactivatedAccountError extends LightdashError {
|
23
24
|
constructor(message?: string, data?: {
|
24
|
-
[key: string]:
|
25
|
+
[key: string]: AnyType;
|
25
26
|
});
|
26
27
|
}
|
27
28
|
export declare class AuthorizationError extends LightdashError {
|
28
29
|
constructor(message?: string, data?: {
|
29
|
-
[key: string]:
|
30
|
+
[key: string]: AnyType;
|
30
31
|
});
|
31
32
|
}
|
32
33
|
export declare class NotExistsError extends LightdashError {
|
@@ -36,16 +37,16 @@ export declare class ExpiredError extends LightdashError {
|
|
36
37
|
constructor(message: string);
|
37
38
|
}
|
38
39
|
export declare class ParameterError extends LightdashError {
|
39
|
-
constructor(message?: string, data?: Record<string,
|
40
|
+
constructor(message?: string, data?: Record<string, AnyType>);
|
40
41
|
}
|
41
42
|
export declare class NonCompiledModelError extends LightdashError {
|
42
43
|
constructor(message: string, data?: {
|
43
|
-
[key: string]:
|
44
|
+
[key: string]: AnyType;
|
44
45
|
});
|
45
46
|
}
|
46
47
|
export declare class MissingCatalogEntryError extends LightdashError {
|
47
48
|
constructor(message: string, data: {
|
48
|
-
[key: string]:
|
49
|
+
[key: string]: AnyType;
|
49
50
|
});
|
50
51
|
}
|
51
52
|
export declare class MissingWarehouseCredentialsError extends LightdashError {
|
@@ -53,29 +54,29 @@ export declare class MissingWarehouseCredentialsError extends LightdashError {
|
|
53
54
|
}
|
54
55
|
export declare class UnexpectedServerError extends LightdashError {
|
55
56
|
constructor(message?: string, data?: {
|
56
|
-
[key: string]:
|
57
|
+
[key: string]: AnyType;
|
57
58
|
});
|
58
59
|
}
|
59
60
|
export declare class UnexpectedGitError extends LightdashError {
|
60
61
|
constructor(message?: string, data?: {
|
61
|
-
[key: string]:
|
62
|
+
[key: string]: AnyType;
|
62
63
|
});
|
63
64
|
}
|
64
65
|
export declare class UnexpectedDatabaseError extends LightdashError {
|
65
66
|
constructor(message?: string, data?: {
|
66
|
-
[key: string]:
|
67
|
+
[key: string]: AnyType;
|
67
68
|
});
|
68
69
|
}
|
69
70
|
export declare class ParseError extends LightdashError {
|
70
71
|
constructor(message?: string, data?: {
|
71
|
-
[key: string]:
|
72
|
+
[key: string]: AnyType;
|
72
73
|
});
|
73
74
|
}
|
74
75
|
export declare class CompileError extends LightdashError {
|
75
|
-
constructor(message?: string, data?: Record<string,
|
76
|
+
constructor(message?: string, data?: Record<string, AnyType>);
|
76
77
|
}
|
77
78
|
export declare class FieldReferenceError extends LightdashError {
|
78
|
-
constructor(message?: string, data?: Record<string,
|
79
|
+
constructor(message?: string, data?: Record<string, AnyType>);
|
79
80
|
}
|
80
81
|
export declare class DbtError extends LightdashError {
|
81
82
|
logs: DbtLog[] | undefined;
|
@@ -92,12 +93,12 @@ export declare class WarehouseConnectionError extends LightdashError {
|
|
92
93
|
}
|
93
94
|
export declare class WarehouseQueryError extends LightdashError {
|
94
95
|
constructor(message: string, data?: {
|
95
|
-
[key: string]:
|
96
|
+
[key: string]: AnyType;
|
96
97
|
});
|
97
98
|
}
|
98
99
|
export declare class SmptError extends LightdashError {
|
99
100
|
constructor(message: string, data?: {
|
100
|
-
[key: string]:
|
101
|
+
[key: string]: AnyType;
|
101
102
|
});
|
102
103
|
}
|
103
104
|
export declare class AlreadyProcessingError extends LightdashError {
|
@@ -120,7 +121,7 @@ export declare class SlackInstallationNotFoundError extends LightdashError {
|
|
120
121
|
}
|
121
122
|
export declare class UnexpectedGoogleSheetsError extends LightdashError {
|
122
123
|
constructor(message?: string, data?: {
|
123
|
-
[key: string]:
|
124
|
+
[key: string]: AnyType;
|
124
125
|
});
|
125
126
|
}
|
126
127
|
export declare const getErrorMessage: (e: unknown) => string;
|
package/dist/types/explore.d.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import { type DbtModelJoinType, type LineageGraph, type SupportedDbtAdapter } from './dbt';
|
2
2
|
import { type CompiledDimension, type CompiledMetric, type Dimension, type Metric, type Source } from './field';
|
3
|
+
import { type LightdashProjectConfig } from './lightdashProjectConfig';
|
3
4
|
import { type TableBase } from './table';
|
4
5
|
export type ExploreJoin = {
|
5
6
|
table: string;
|
@@ -43,6 +44,9 @@ export type Explore = {
|
|
43
44
|
ymlPath?: string;
|
44
45
|
sqlPath?: string;
|
45
46
|
type?: ExploreType;
|
47
|
+
spotlight?: {
|
48
|
+
visibility: Required<NonNullable<LightdashProjectConfig['spotlight']>>['default_visibility'];
|
49
|
+
};
|
46
50
|
};
|
47
51
|
export declare enum InlineErrorType {
|
48
52
|
METADATA_PARSE_ERROR = "METADATA_PARSE_ERROR",
|
package/dist/types/field.d.ts
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
import type { AdditionalMetric, currencies, DefaultTimeDimension } from '..';
|
1
|
+
import type { AdditionalMetric, currencies, DefaultTimeDimension, LightdashProjectConfig } from '..';
|
2
|
+
import { type AnyType } from './any';
|
2
3
|
import { type MetricFilterRule } from './filter';
|
3
4
|
import { type TimeFrames } from './timeFrames';
|
4
5
|
export declare enum Compact {
|
@@ -58,15 +59,15 @@ export interface CustomSqlDimension extends BaseCustomDimension {
|
|
58
59
|
dimensionType: DimensionType;
|
59
60
|
}
|
60
61
|
export type CustomDimension = CustomBinDimension | CustomSqlDimension;
|
61
|
-
export declare const isCustomDimension: (value:
|
62
|
-
export declare const isCustomBinDimension: (value:
|
63
|
-
export declare const isCustomSqlDimension: (value:
|
62
|
+
export declare const isCustomDimension: (value: AnyType) => value is CustomDimension;
|
63
|
+
export declare const isCustomBinDimension: (value: AnyType) => value is CustomBinDimension;
|
64
|
+
export declare const isCustomSqlDimension: (value: AnyType) => value is CustomSqlDimension;
|
64
65
|
export type CompiledCustomSqlDimension = CustomSqlDimension & {
|
65
66
|
compiledSql: string;
|
66
67
|
tablesReferences: Array<string>;
|
67
68
|
};
|
68
69
|
export type CompiledCustomDimension = CustomBinDimension | CompiledCustomSqlDimension;
|
69
|
-
export declare const isCompiledCustomSqlDimension: (value:
|
70
|
+
export declare const isCompiledCustomSqlDimension: (value: AnyType) => value is CompiledCustomSqlDimension;
|
70
71
|
export type ItemsMap = Record<string, Field | TableCalculation | CustomDimension | Metric>;
|
71
72
|
export type Item = ItemsMap[string];
|
72
73
|
export interface CustomFormat {
|
@@ -142,7 +143,7 @@ export interface Field {
|
|
142
143
|
index?: number;
|
143
144
|
tags?: string[];
|
144
145
|
}
|
145
|
-
export declare const isField: (field:
|
146
|
+
export declare const isField: (field: AnyType) => field is Field;
|
146
147
|
export type FieldId = string;
|
147
148
|
export declare const convertFieldRefToFieldId: (fieldRef: string, fallbackTableName?: string) => string;
|
148
149
|
export type Source = {
|
@@ -222,6 +223,7 @@ export declare enum Format {
|
|
222
223
|
GBP = "gbp",
|
223
224
|
EUR = "eur",
|
224
225
|
JPY = "jpy",
|
226
|
+
DKK = "dkk",
|
225
227
|
ID = "id",
|
226
228
|
PERCENT = "percent"
|
227
229
|
}
|
@@ -240,6 +242,9 @@ export interface Metric extends Field {
|
|
240
242
|
dimensionReference?: string;
|
241
243
|
requiredAttributes?: Record<string, string | string[]>;
|
242
244
|
defaultTimeDimension?: DefaultTimeDimension;
|
245
|
+
spotlight?: {
|
246
|
+
visibility: Required<NonNullable<LightdashProjectConfig['spotlight']>>['default_visibility'];
|
247
|
+
};
|
243
248
|
}
|
244
249
|
export declare const isFilterableDimension: (dimension: Dimension) => dimension is FilterableDimension;
|
245
250
|
export type FilterableField = TableCalculation | Metric | FilterableDimension | CustomSqlDimension;
|
package/dist/types/field.js
CHANGED
@@ -58,7 +58,8 @@ exports.CompactConfigMap = {
|
|
58
58
|
},
|
59
59
|
};
|
60
60
|
function findCompactConfig(compactOrAlias) {
|
61
|
-
return Object.values(exports.CompactConfigMap).find(({ compact, alias }) => compact === compactOrAlias ||
|
61
|
+
return Object.values(exports.CompactConfigMap).find(({ compact, alias }) => compact === compactOrAlias ||
|
62
|
+
alias.includes(compactOrAlias));
|
62
63
|
}
|
63
64
|
exports.findCompactConfig = findCompactConfig;
|
64
65
|
var BinType;
|
@@ -170,6 +171,7 @@ var Format;
|
|
170
171
|
Format["GBP"] = "gbp";
|
171
172
|
Format["EUR"] = "eur";
|
172
173
|
Format["JPY"] = "jpy";
|
174
|
+
Format["DKK"] = "dkk";
|
173
175
|
Format["ID"] = "id";
|
174
176
|
Format["PERCENT"] = "percent";
|
175
177
|
})(Format = exports.Format || (exports.Format = {}));
|
package/dist/types/field.test.js
CHANGED
@@ -78,6 +78,7 @@ describe('field util functions', () => {
|
|
78
78
|
expect((0, field_1.isFormat)('gbp')).toBe(true);
|
79
79
|
expect((0, field_1.isFormat)('eur')).toBe(true);
|
80
80
|
expect((0, field_1.isFormat)('jpy')).toBe(true);
|
81
|
+
expect((0, field_1.isFormat)('dkk')).toBe(true);
|
81
82
|
expect((0, field_1.isFormat)('id')).toBe(true);
|
82
83
|
expect((0, field_1.isFormat)('percent')).toBe(true);
|
83
84
|
});
|
package/dist/types/filter.d.ts
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
import { type AnyType } from './any';
|
1
2
|
import { ConditionalOperator, type ConditionalRule } from './conditionalRule';
|
2
3
|
import type { SchedulerFilterRule } from './scheduler';
|
3
4
|
export declare enum FilterType {
|
@@ -22,7 +23,7 @@ export declare const getUnitsOfTimeGreaterOrEqual: (unit: UnitOfTime) => UnitOfT
|
|
22
23
|
export type FieldTarget = {
|
23
24
|
fieldId: string;
|
24
25
|
};
|
25
|
-
export interface FilterRule<O = ConditionalOperator, T = FieldTarget, V =
|
26
|
+
export interface FilterRule<O = ConditionalOperator, T = FieldTarget, V = AnyType, S = AnyType> extends ConditionalRule<O, V> {
|
26
27
|
id: string;
|
27
28
|
target: T;
|
28
29
|
settings?: S;
|
@@ -38,7 +39,7 @@ export type DashboardFieldTarget = {
|
|
38
39
|
tableName: string;
|
39
40
|
};
|
40
41
|
export type DashboardTileTarget = DashboardFieldTarget | false;
|
41
|
-
export type DashboardFilterRule<O = ConditionalOperator, T extends DashboardFieldTarget = DashboardFieldTarget, V =
|
42
|
+
export type DashboardFilterRule<O = ConditionalOperator, T extends DashboardFieldTarget = DashboardFieldTarget, V = AnyType, S = AnyType> = FilterRule<O, T, V, S> & {
|
42
43
|
tileTargets?: Record<string, DashboardTileTarget>;
|
43
44
|
label: undefined | string;
|
44
45
|
};
|
@@ -52,7 +53,7 @@ export type DateFilterSettings = {
|
|
52
53
|
unitOfTime?: UnitOfTime;
|
53
54
|
completed?: boolean;
|
54
55
|
};
|
55
|
-
export type DateFilterRule = FilterRule<ConditionalOperator, unknown,
|
56
|
+
export type DateFilterRule = FilterRule<ConditionalOperator, unknown, AnyType, DateFilterSettings>;
|
56
57
|
export type FilterGroupItem = FilterGroup | FilterRule;
|
57
58
|
export type OrFilterGroup = {
|
58
59
|
id: string;
|