@claryai/cli 0.1.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/LICENSE +25 -0
- package/README.md +197 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/ajv.d.ts +3 -0
- package/dist/ajv.d.ts.map +1 -0
- package/dist/ajv.js +13 -0
- package/dist/analytics/analytics.d.ts +370 -0
- package/dist/analytics/analytics.d.ts.map +1 -0
- package/dist/analytics/analytics.js +143 -0
- package/dist/config.d.ts +34 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +134 -0
- package/dist/dbt/context.d.ts +14 -0
- package/dist/dbt/context.d.ts.map +1 -0
- package/dist/dbt/context.js +76 -0
- package/dist/dbt/context.test.d.ts +2 -0
- package/dist/dbt/context.test.d.ts.map +1 -0
- package/dist/dbt/context.test.js +152 -0
- package/dist/dbt/manifest.d.ts +7 -0
- package/dist/dbt/manifest.d.ts.map +1 -0
- package/dist/dbt/manifest.js +23 -0
- package/dist/dbt/models.d.ts +43 -0
- package/dist/dbt/models.d.ts.map +1 -0
- package/dist/dbt/models.js +256 -0
- package/dist/dbt/models.test.d.ts +2 -0
- package/dist/dbt/models.test.d.ts.map +1 -0
- package/dist/dbt/models.test.js +19 -0
- package/dist/dbt/profile.d.ts +9 -0
- package/dist/dbt/profile.d.ts.map +1 -0
- package/dist/dbt/profile.js +86 -0
- package/dist/dbt/profiles.test.d.ts +2 -0
- package/dist/dbt/profiles.test.d.ts.map +1 -0
- package/dist/dbt/profiles.test.js +50 -0
- package/dist/dbt/schema.d.ts +31 -0
- package/dist/dbt/schema.d.ts.map +1 -0
- package/dist/dbt/schema.js +49 -0
- package/dist/dbt/targets/Bigquery/index.d.ts +18 -0
- package/dist/dbt/targets/Bigquery/index.d.ts.map +1 -0
- package/dist/dbt/targets/Bigquery/index.js +105 -0
- package/dist/dbt/targets/Bigquery/oauth.d.ts +2 -0
- package/dist/dbt/targets/Bigquery/oauth.d.ts.map +1 -0
- package/dist/dbt/targets/Bigquery/oauth.js +43 -0
- package/dist/dbt/targets/Bigquery/serviceAccount.d.ts +35 -0
- package/dist/dbt/targets/Bigquery/serviceAccount.d.ts.map +1 -0
- package/dist/dbt/targets/Bigquery/serviceAccount.js +149 -0
- package/dist/dbt/targets/Databricks/oauth.d.ts +21 -0
- package/dist/dbt/targets/Databricks/oauth.d.ts.map +1 -0
- package/dist/dbt/targets/Databricks/oauth.js +184 -0
- package/dist/dbt/targets/athena.d.ts +21 -0
- package/dist/dbt/targets/athena.d.ts.map +1 -0
- package/dist/dbt/targets/athena.js +91 -0
- package/dist/dbt/targets/athena.test.d.ts +2 -0
- package/dist/dbt/targets/athena.test.d.ts.map +1 -0
- package/dist/dbt/targets/athena.test.js +60 -0
- package/dist/dbt/targets/clickhouse.d.ts +24 -0
- package/dist/dbt/targets/clickhouse.d.ts.map +1 -0
- package/dist/dbt/targets/clickhouse.js +90 -0
- package/dist/dbt/targets/databricks.d.ts +27 -0
- package/dist/dbt/targets/databricks.d.ts.map +1 -0
- package/dist/dbt/targets/databricks.js +138 -0
- package/dist/dbt/targets/duckdb.d.ts +16 -0
- package/dist/dbt/targets/duckdb.d.ts.map +1 -0
- package/dist/dbt/targets/duckdb.js +63 -0
- package/dist/dbt/targets/duckdb.test.d.ts +2 -0
- package/dist/dbt/targets/duckdb.test.d.ts.map +1 -0
- package/dist/dbt/targets/duckdb.test.js +37 -0
- package/dist/dbt/targets/postgres.d.ts +26 -0
- package/dist/dbt/targets/postgres.d.ts.map +1 -0
- package/dist/dbt/targets/postgres.js +142 -0
- package/dist/dbt/targets/redshift.d.ts +23 -0
- package/dist/dbt/targets/redshift.d.ts.map +1 -0
- package/dist/dbt/targets/redshift.js +96 -0
- package/dist/dbt/targets/snowflake.d.ts +4 -0
- package/dist/dbt/targets/snowflake.d.ts.map +1 -0
- package/dist/dbt/targets/snowflake.js +134 -0
- package/dist/dbt/targets/trino.d.ts +16 -0
- package/dist/dbt/targets/trino.d.ts.map +1 -0
- package/dist/dbt/targets/trino.js +65 -0
- package/dist/dbt/templating.d.ts +15 -0
- package/dist/dbt/templating.d.ts.map +1 -0
- package/dist/dbt/templating.js +50 -0
- package/dist/dbt/templating.test.d.ts +2 -0
- package/dist/dbt/templating.test.d.ts.map +1 -0
- package/dist/dbt/templating.test.js +51 -0
- package/dist/dbt/types.d.ts +17 -0
- package/dist/dbt/types.d.ts.map +1 -0
- package/dist/dbt/types.js +2 -0
- package/dist/dbt/validation.d.ts +9 -0
- package/dist/dbt/validation.d.ts.map +1 -0
- package/dist/dbt/validation.js +54 -0
- package/dist/env.d.ts +12 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +40 -0
- package/dist/error.d.ts +2 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +12 -0
- package/dist/globalState.d.ts +29 -0
- package/dist/globalState.d.ts.map +1 -0
- package/dist/globalState.js +67 -0
- package/dist/handlers/asyncQuery.d.ts +7 -0
- package/dist/handlers/asyncQuery.d.ts.map +1 -0
- package/dist/handlers/asyncQuery.js +50 -0
- package/dist/handlers/compile.d.ts +16 -0
- package/dist/handlers/compile.d.ts.map +1 -0
- package/dist/handlers/compile.js +277 -0
- package/dist/handlers/compile.test.d.ts +2 -0
- package/dist/handlers/compile.test.d.ts.map +1 -0
- package/dist/handlers/compile.test.js +201 -0
- package/dist/handlers/createProject.d.ts +37 -0
- package/dist/handlers/createProject.d.ts.map +1 -0
- package/dist/handlers/createProject.js +272 -0
- package/dist/handlers/dbt/apiClient.d.ts +14 -0
- package/dist/handlers/dbt/apiClient.d.ts.map +1 -0
- package/dist/handlers/dbt/apiClient.js +167 -0
- package/dist/handlers/dbt/compile.d.ts +35 -0
- package/dist/handlers/dbt/compile.d.ts.map +1 -0
- package/dist/handlers/dbt/compile.js +220 -0
- package/dist/handlers/dbt/getDbtProfileTargetName.d.ts +9 -0
- package/dist/handlers/dbt/getDbtProfileTargetName.d.ts.map +1 -0
- package/dist/handlers/dbt/getDbtProfileTargetName.js +44 -0
- package/dist/handlers/dbt/getDbtVersion.d.ts +16 -0
- package/dist/handlers/dbt/getDbtVersion.d.ts.map +1 -0
- package/dist/handlers/dbt/getDbtVersion.js +141 -0
- package/dist/handlers/dbt/getDbtVersion.mocks.d.ts +11 -0
- package/dist/handlers/dbt/getDbtVersion.mocks.d.ts.map +1 -0
- package/dist/handlers/dbt/getDbtVersion.mocks.js +70 -0
- package/dist/handlers/dbt/getDbtVersion.test.d.ts +2 -0
- package/dist/handlers/dbt/getDbtVersion.test.d.ts.map +1 -0
- package/dist/handlers/dbt/getDbtVersion.test.js +97 -0
- package/dist/handlers/dbt/getWarehouseClient.d.ts +24 -0
- package/dist/handlers/dbt/getWarehouseClient.d.ts.map +1 -0
- package/dist/handlers/dbt/getWarehouseClient.js +312 -0
- package/dist/handlers/dbt/refresh.d.ts +11 -0
- package/dist/handlers/dbt/refresh.d.ts.map +1 -0
- package/dist/handlers/dbt/refresh.js +114 -0
- package/dist/handlers/dbt/run.d.ts +14 -0
- package/dist/handlers/dbt/run.d.ts.map +1 -0
- package/dist/handlers/dbt/run.js +67 -0
- package/dist/handlers/deploy.d.ts +26 -0
- package/dist/handlers/deploy.d.ts.map +1 -0
- package/dist/handlers/deploy.js +377 -0
- package/dist/handlers/diagnostics.d.ts +11 -0
- package/dist/handlers/diagnostics.d.ts.map +1 -0
- package/dist/handlers/diagnostics.js +194 -0
- package/dist/handlers/download.d.ts +29 -0
- package/dist/handlers/download.d.ts.map +1 -0
- package/dist/handlers/download.js +955 -0
- package/dist/handlers/exportChartImage.d.ts +7 -0
- package/dist/handlers/exportChartImage.d.ts.map +1 -0
- package/dist/handlers/exportChartImage.js +33 -0
- package/dist/handlers/generate.d.ts +13 -0
- package/dist/handlers/generate.d.ts.map +1 -0
- package/dist/handlers/generate.js +159 -0
- package/dist/handlers/generateExposures.d.ts +8 -0
- package/dist/handlers/generateExposures.d.ts.map +1 -0
- package/dist/handlers/generateExposures.js +100 -0
- package/dist/handlers/getProject.d.ts +6 -0
- package/dist/handlers/getProject.d.ts.map +1 -0
- package/dist/handlers/getProject.js +43 -0
- package/dist/handlers/installSkills.d.ts +12 -0
- package/dist/handlers/installSkills.d.ts.map +1 -0
- package/dist/handlers/installSkills.js +321 -0
- package/dist/handlers/lint/ajvToSarif.d.ts +66 -0
- package/dist/handlers/lint/ajvToSarif.d.ts.map +1 -0
- package/dist/handlers/lint/ajvToSarif.js +222 -0
- package/dist/handlers/lint/sarifFormatter.d.ts +14 -0
- package/dist/handlers/lint/sarifFormatter.d.ts.map +1 -0
- package/dist/handlers/lint/sarifFormatter.js +111 -0
- package/dist/handlers/lint.d.ts +8 -0
- package/dist/handlers/lint.d.ts.map +1 -0
- package/dist/handlers/lint.js +308 -0
- package/dist/handlers/listProjects.d.ts +6 -0
- package/dist/handlers/listProjects.d.ts.map +1 -0
- package/dist/handlers/listProjects.js +53 -0
- package/dist/handlers/login/oauth.d.ts +2 -0
- package/dist/handlers/login/oauth.d.ts.map +1 -0
- package/dist/handlers/login/oauth.js +27 -0
- package/dist/handlers/login/pat.d.ts +2 -0
- package/dist/handlers/login/pat.d.ts.map +1 -0
- package/dist/handlers/login/pat.js +31 -0
- package/dist/handlers/login.d.ts +15 -0
- package/dist/handlers/login.d.ts.map +1 -0
- package/dist/handlers/login.js +239 -0
- package/dist/handlers/metadataFile.d.ts +9 -0
- package/dist/handlers/metadataFile.d.ts.map +1 -0
- package/dist/handlers/metadataFile.js +34 -0
- package/dist/handlers/oauthLogin.d.ts +6 -0
- package/dist/handlers/oauthLogin.d.ts.map +1 -0
- package/dist/handlers/oauthLogin.js +191 -0
- package/dist/handlers/preview.d.ts +29 -0
- package/dist/handlers/preview.d.ts.map +1 -0
- package/dist/handlers/preview.js +415 -0
- package/dist/handlers/renameHandler.d.ts +16 -0
- package/dist/handlers/renameHandler.d.ts.map +1 -0
- package/dist/handlers/renameHandler.js +160 -0
- package/dist/handlers/runChart.d.ts +10 -0
- package/dist/handlers/runChart.d.ts.map +1 -0
- package/dist/handlers/runChart.js +105 -0
- package/dist/handlers/selectProject.d.ts +20 -0
- package/dist/handlers/selectProject.d.ts.map +1 -0
- package/dist/handlers/selectProject.js +91 -0
- package/dist/handlers/setProject.d.ts +14 -0
- package/dist/handlers/setProject.d.ts.map +1 -0
- package/dist/handlers/setProject.js +131 -0
- package/dist/handlers/setWarehouse.d.ts +14 -0
- package/dist/handlers/setWarehouse.d.ts.map +1 -0
- package/dist/handlers/setWarehouse.js +94 -0
- package/dist/handlers/sql.d.ts +9 -0
- package/dist/handlers/sql.d.ts.map +1 -0
- package/dist/handlers/sql.js +89 -0
- package/dist/handlers/utils.d.ts +11 -0
- package/dist/handlers/utils.d.ts.map +1 -0
- package/dist/handlers/utils.js +36 -0
- package/dist/handlers/validate.d.ts +22 -0
- package/dist/handlers/validate.d.ts.map +1 -0
- package/dist/handlers/validate.js +201 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +581 -0
- package/dist/lightdash/loader.d.ts +21 -0
- package/dist/lightdash/loader.d.ts.map +1 -0
- package/dist/lightdash/loader.js +122 -0
- package/dist/lightdash/projectType.d.ts +84 -0
- package/dist/lightdash/projectType.d.ts.map +1 -0
- package/dist/lightdash/projectType.js +75 -0
- package/dist/lightdash-config/index.d.ts +2 -0
- package/dist/lightdash-config/index.d.ts.map +1 -0
- package/dist/lightdash-config/index.js +41 -0
- package/dist/lightdash-config/lightdash-config.test.d.ts +2 -0
- package/dist/lightdash-config/lightdash-config.test.d.ts.map +1 -0
- package/dist/lightdash-config/lightdash-config.test.js +70 -0
- package/dist/styles.d.ts +10 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +14 -0
- package/entitlements.plist +33 -0
- package/package.json +71 -0
- package/track.sh +116 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../src/handlers/validate.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,OAAO,EACP,YAAY,EAOZ,kBAAkB,EAGlB,gBAAgB,EACnB,MAAM,mBAAmB,CAAC;AAO3B,OAAO,EAAW,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAG3D,eAAO,MAAM,iBAAiB,GAC1B,aAAa,MAAM,EACnB,UAAU,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,EACpC,mBAAmB,gBAAgB,EAAE;;EAMnC,CAAC;AAEP,eAAO,MAAM,WAAW,GAAU,SAAS,MAAM;;;EAK3C,CAAC;AAEP,eAAO,MAAM,aAAa,GAAU,aAAa,MAAM,EAAE,OAAO,MAAM,8DAKhE,CAAC;AAEP,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAI/B;AAWD,KAAK,sBAAsB,GAAG,qBAAqB,GAAG;IAClD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,gBAAgB,EAAE,CAAC;IACzB,8BAA8B,EAAE,OAAO,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAU,SAAS,MAAM,KAAG,OAAO,CAAC,MAAM,CAYvE,CAAC;AAEF,eAAO,MAAM,eAAe,GAAU,SAAS,sBAAsB,kBAyOpE,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateHandler = exports.waitUntilFinished = exports.getValidation = exports.getJobState = exports.requestValidation = void 0;
|
|
4
|
+
exports.delay = delay;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const common_1 = require("@lightdash/common");
|
|
7
|
+
const columnify_1 = tslib_1.__importDefault(require("columnify"));
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
const analytics_1 = require("../analytics/analytics");
|
|
10
|
+
const config_1 = require("../config");
|
|
11
|
+
const globalState_1 = tslib_1.__importDefault(require("../globalState"));
|
|
12
|
+
const styles = tslib_1.__importStar(require("../styles"));
|
|
13
|
+
const compile_1 = require("./compile");
|
|
14
|
+
const apiClient_1 = require("./dbt/apiClient");
|
|
15
|
+
const requestValidation = async (projectUuid, explores, validationTargets) => (0, apiClient_1.lightdashApi)({
|
|
16
|
+
method: 'POST',
|
|
17
|
+
url: `/api/v1/projects/${projectUuid}/validate`,
|
|
18
|
+
body: JSON.stringify({ explores, validationTargets }),
|
|
19
|
+
});
|
|
20
|
+
exports.requestValidation = requestValidation;
|
|
21
|
+
const getJobState = async (jobUuid) => (0, apiClient_1.lightdashApi)({
|
|
22
|
+
method: 'GET',
|
|
23
|
+
url: `/api/v1/schedulers/job/${jobUuid}/status`,
|
|
24
|
+
body: undefined,
|
|
25
|
+
});
|
|
26
|
+
exports.getJobState = getJobState;
|
|
27
|
+
const getValidation = async (projectUuid, jobId) => (0, apiClient_1.lightdashApi)({
|
|
28
|
+
method: 'GET',
|
|
29
|
+
url: `/api/v1/projects/${projectUuid}/validate?jobId=${jobId}`,
|
|
30
|
+
body: undefined,
|
|
31
|
+
});
|
|
32
|
+
exports.getValidation = getValidation;
|
|
33
|
+
function delay(ms) {
|
|
34
|
+
return new Promise((resolve) => {
|
|
35
|
+
setTimeout(resolve, ms);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function styleTotalErrors(total) {
|
|
39
|
+
if (total > 0) {
|
|
40
|
+
return styles.error(`${styles.bold(total)} errors`);
|
|
41
|
+
}
|
|
42
|
+
return styles.success(`${styles.bold(total)} errors`);
|
|
43
|
+
}
|
|
44
|
+
const REFETCH_JOB_INTERVAL = 3000;
|
|
45
|
+
const waitUntilFinished = async (jobUuid) => {
|
|
46
|
+
const job = await (0, exports.getJobState)(jobUuid);
|
|
47
|
+
if (job.status === common_1.SchedulerJobStatus.COMPLETED) {
|
|
48
|
+
return job.status;
|
|
49
|
+
}
|
|
50
|
+
if (job.status === common_1.SchedulerJobStatus.ERROR) {
|
|
51
|
+
throw new common_1.UnexpectedServerError(`\nValidation failed: ${job.details?.error || 'unknown error'}`);
|
|
52
|
+
}
|
|
53
|
+
return delay(REFETCH_JOB_INTERVAL).then(() => (0, exports.waitUntilFinished)(jobUuid));
|
|
54
|
+
};
|
|
55
|
+
exports.waitUntilFinished = waitUntilFinished;
|
|
56
|
+
const validateHandler = async (options) => {
|
|
57
|
+
globalState_1.default.setVerbose(options.verbose);
|
|
58
|
+
await (0, apiClient_1.checkLightdashVersion)();
|
|
59
|
+
const executionId = (0, uuid_1.v4)();
|
|
60
|
+
const startTime = Date.now();
|
|
61
|
+
const config = await (0, config_1.getConfig)();
|
|
62
|
+
// Log current project info
|
|
63
|
+
globalState_1.default.logProjectInfo(config);
|
|
64
|
+
const selectedProject = options.preview
|
|
65
|
+
? config.context?.previewProject
|
|
66
|
+
: config.context?.project;
|
|
67
|
+
const projectUuid = options.project || selectedProject;
|
|
68
|
+
if (projectUuid === undefined) {
|
|
69
|
+
throw new common_1.ParameterError(`No project specified, select a project to validate using ${styles.bold(`--project <projectUuid>`)} or create a preview environment using ${styles.bold(`clary start-preview`)} or configure your default project using ${styles.bold(`clary config set-project`)}`);
|
|
70
|
+
}
|
|
71
|
+
const isPreview = projectUuid === config.context?.previewProject;
|
|
72
|
+
if (isPreview) {
|
|
73
|
+
console.error(`Validating preview project ${styles.bold(config.context?.previewName)}\n`);
|
|
74
|
+
}
|
|
75
|
+
else if (projectUuid === config.context?.project) {
|
|
76
|
+
console.error(`Validating default project ${styles.bold(config.context?.projectName || projectUuid)}\n`);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
console.error(`Validating project ${projectUuid}\n`);
|
|
80
|
+
}
|
|
81
|
+
const validationTargets = options.only ? options.only : [];
|
|
82
|
+
await analytics_1.LightdashAnalytics.track({
|
|
83
|
+
event: 'validate.started',
|
|
84
|
+
properties: {
|
|
85
|
+
executionId,
|
|
86
|
+
projectId: projectUuid,
|
|
87
|
+
isPreview,
|
|
88
|
+
validationTargets,
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
let shouldExitWithError = false;
|
|
92
|
+
try {
|
|
93
|
+
const explores = await (0, compile_1.compile)(options);
|
|
94
|
+
globalState_1.default.debug(`> Compiled ${explores.length} explores`);
|
|
95
|
+
const validationJob = await (0, exports.requestValidation)(projectUuid, explores, validationTargets);
|
|
96
|
+
const { jobId } = validationJob;
|
|
97
|
+
const spinner = globalState_1.default.startSpinner(` Waiting for validation to finish`);
|
|
98
|
+
await (0, exports.waitUntilFinished)(jobId);
|
|
99
|
+
const allValidation = await (0, exports.getValidation)(projectUuid, jobId);
|
|
100
|
+
// Filter out chart configuration warnings unless explicitly requested
|
|
101
|
+
const validation = options.showChartConfigurationWarnings
|
|
102
|
+
? allValidation
|
|
103
|
+
: allValidation.filter((v) => !(0, common_1.isChartValidationError)(v) ||
|
|
104
|
+
v.errorType !== common_1.ValidationErrorType.ChartConfiguration);
|
|
105
|
+
const hiddenWarningsCount = allValidation.length - validation.length;
|
|
106
|
+
const tableErrors = validation.filter(common_1.isTableValidationError);
|
|
107
|
+
const chartErrors = validation.filter(common_1.isChartValidationError);
|
|
108
|
+
const dashboardErrors = validation.filter(common_1.isDashboardValidationError);
|
|
109
|
+
await analytics_1.LightdashAnalytics.track({
|
|
110
|
+
event: 'validate.completed',
|
|
111
|
+
properties: {
|
|
112
|
+
executionId,
|
|
113
|
+
projectId: projectUuid,
|
|
114
|
+
isPreview,
|
|
115
|
+
validationTargets,
|
|
116
|
+
durationMs: Date.now() - startTime,
|
|
117
|
+
success: validation.length === 0,
|
|
118
|
+
totalErrors: validation.length,
|
|
119
|
+
tableErrors: tableErrors.length,
|
|
120
|
+
chartErrors: chartErrors.length,
|
|
121
|
+
dashboardErrors: dashboardErrors.length,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
if (validation.length === 0) {
|
|
125
|
+
const elapsedMs = Date.now() - startTime;
|
|
126
|
+
const hiddenMessage = hiddenWarningsCount > 0
|
|
127
|
+
? ` (${hiddenWarningsCount} chart configuration warning${hiddenWarningsCount > 1 ? 's' : ''} hidden, use --show-chart-configuration-warnings to show)`
|
|
128
|
+
: '';
|
|
129
|
+
spinner?.succeed(` Validation finished without errors in ${Math.trunc(elapsedMs / 1000)}s${hiddenMessage}`);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
const elapsedMs = Date.now() - startTime;
|
|
133
|
+
spinner?.fail(` Validation finished in ${Math.trunc(elapsedMs / 1000)}s with ${validation.length} errors`);
|
|
134
|
+
const validationTargetsSet = new Set(validationTargets);
|
|
135
|
+
const hasValidationTargets = validationTargetsSet.size > 0;
|
|
136
|
+
console.error('\n');
|
|
137
|
+
if (!hasValidationTargets ||
|
|
138
|
+
validationTargetsSet.has(common_1.ValidationTarget.TABLES)) {
|
|
139
|
+
console.error(`- Tables: ${styleTotalErrors(tableErrors.length)}`);
|
|
140
|
+
}
|
|
141
|
+
if (!hasValidationTargets ||
|
|
142
|
+
validationTargetsSet.has(common_1.ValidationTarget.CHARTS)) {
|
|
143
|
+
console.error(`- Charts: ${styleTotalErrors(chartErrors.length)}`);
|
|
144
|
+
}
|
|
145
|
+
if (!hasValidationTargets ||
|
|
146
|
+
validationTargetsSet.has(common_1.ValidationTarget.DASHBOARDS)) {
|
|
147
|
+
console.error(`- Dashboards: ${styleTotalErrors(dashboardErrors.length)}`);
|
|
148
|
+
}
|
|
149
|
+
console.error('\n');
|
|
150
|
+
const validationOutput = validation.map((v) => ({
|
|
151
|
+
name: styles.error(v.name),
|
|
152
|
+
error: styles.warning((0, common_1.isChartValidationError)(v) &&
|
|
153
|
+
v.errorType ===
|
|
154
|
+
common_1.ValidationErrorType.ChartConfiguration &&
|
|
155
|
+
v.fieldName
|
|
156
|
+
? `Chart configuration warning: '${v.fieldName}' - ${v.error}`
|
|
157
|
+
: v.error),
|
|
158
|
+
'last updated by': (0, common_1.isChartValidationError)(v) || (0, common_1.isDashboardValidationError)(v)
|
|
159
|
+
? styles.secondary(v.lastUpdatedBy)
|
|
160
|
+
: '',
|
|
161
|
+
'last updated at': (0, common_1.isChartValidationError)(v) || (0, common_1.isDashboardValidationError)(v)
|
|
162
|
+
? styles.secondary((0, common_1.formatDate)(v.lastUpdatedAt))
|
|
163
|
+
: '',
|
|
164
|
+
}));
|
|
165
|
+
const columns = (0, columnify_1.default)(validationOutput, {
|
|
166
|
+
columns: [
|
|
167
|
+
'name',
|
|
168
|
+
'last updated by',
|
|
169
|
+
'last updated at',
|
|
170
|
+
'error',
|
|
171
|
+
],
|
|
172
|
+
config: {
|
|
173
|
+
'last updated at': {
|
|
174
|
+
align: 'center',
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
console.error(columns);
|
|
179
|
+
console.error(`\n--> To see these errors in Clary, run ${styles.bold(`clary preview`)}`);
|
|
180
|
+
if (hiddenWarningsCount > 0) {
|
|
181
|
+
console.error(`\n${styles.secondary(`Note: ${hiddenWarningsCount} chart configuration warning${hiddenWarningsCount > 1 ? 's' : ''} hidden. Use --show-chart-configuration-warnings to show.`)}`);
|
|
182
|
+
}
|
|
183
|
+
shouldExitWithError = true;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (e) {
|
|
187
|
+
await analytics_1.LightdashAnalytics.track({
|
|
188
|
+
event: 'validate.error',
|
|
189
|
+
properties: {
|
|
190
|
+
executionId,
|
|
191
|
+
error: (0, common_1.getErrorMessage)(e),
|
|
192
|
+
errorCategory: (0, analytics_1.categorizeError)(e),
|
|
193
|
+
},
|
|
194
|
+
});
|
|
195
|
+
throw e;
|
|
196
|
+
}
|
|
197
|
+
if (shouldExitWithError) {
|
|
198
|
+
process.exit(1);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
exports.validateHandler = validateHandler;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|