@lightdash/cli 1.51.0 → 1.52.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/README.md +1 -1
- package/dist/.tsbuildinfo +1 -1
- package/dist/analytics/analytics.d.ts +1 -1
- package/dist/analytics/analytics.d.ts.map +1 -1
- package/dist/analytics/analytics.js +1 -2
- package/dist/dbt/manifest.d.ts +0 -3
- package/dist/dbt/manifest.d.ts.map +1 -1
- package/dist/dbt/manifest.js +5 -8
- package/dist/dbt/targets/Bigquery/index.d.ts +0 -14
- package/dist/dbt/targets/Bigquery/index.d.ts.map +1 -1
- package/dist/dbt/targets/Bigquery/index.js +4 -4
- package/dist/dbt/targets/Bigquery/serviceAccount.d.ts +0 -3
- package/dist/dbt/targets/Bigquery/serviceAccount.d.ts.map +1 -1
- package/dist/dbt/targets/Bigquery/serviceAccount.js +5 -5
- package/dist/dbt/targets/athena.d.ts +0 -2
- package/dist/dbt/targets/athena.d.ts.map +1 -1
- package/dist/dbt/targets/athena.js +4 -4
- package/dist/dbt/targets/clickhouse.d.ts +0 -2
- package/dist/dbt/targets/clickhouse.d.ts.map +1 -1
- package/dist/dbt/targets/clickhouse.js +4 -4
- package/dist/dbt/targets/databricks.d.ts +0 -2
- package/dist/dbt/targets/databricks.d.ts.map +1 -1
- package/dist/dbt/targets/databricks.js +4 -4
- package/dist/dbt/targets/postgres.d.ts +0 -2
- package/dist/dbt/targets/postgres.d.ts.map +1 -1
- package/dist/dbt/targets/postgres.js +4 -4
- package/dist/dbt/targets/redshift.d.ts +0 -2
- package/dist/dbt/targets/redshift.d.ts.map +1 -1
- package/dist/dbt/targets/redshift.js +4 -4
- package/dist/dbt/targets/trino.d.ts +0 -2
- package/dist/dbt/targets/trino.d.ts.map +1 -1
- package/dist/dbt/targets/trino.js +4 -4
- package/dist/handlers/apps/scaffolding.d.ts +0 -4
- package/dist/handlers/apps/scaffolding.d.ts.map +1 -1
- package/dist/handlers/apps/scaffolding.js +2 -3
- package/dist/handlers/contentAsCode/fileNames.d.ts +0 -1
- package/dist/handlers/contentAsCode/fileNames.d.ts.map +1 -1
- package/dist/handlers/contentAsCode/fileNames.js +4 -4
- package/dist/handlers/dbt/compile.d.ts +0 -1
- package/dist/handlers/dbt/compile.d.ts.map +1 -1
- package/dist/handlers/dbt/compile.js +2 -4
- package/dist/handlers/dbt/getDbtVersion.d.ts +0 -1
- package/dist/handlers/dbt/getDbtVersion.d.ts.map +1 -1
- package/dist/handlers/dbt/getDbtVersion.js +5 -5
- package/dist/handlers/dbt/getWarehouseClient.d.ts +1 -8
- package/dist/handlers/dbt/getWarehouseClient.d.ts.map +1 -1
- package/dist/handlers/dbt/getWarehouseClient.js +2 -3
- package/dist/handlers/dbt/refresh.d.ts +1 -3
- package/dist/handlers/dbt/refresh.d.ts.map +1 -1
- package/dist/handlers/dbt/refresh.js +3 -5
- package/dist/handlers/deploy.d.ts +1 -2
- package/dist/handlers/deploy.d.ts.map +1 -1
- package/dist/handlers/deploy.js +3 -4
- package/dist/handlers/renameHandler.d.ts.map +1 -1
- package/dist/handlers/renameHandler.js +25 -16
- package/dist/handlers/renameHandler.test.d.ts +2 -0
- package/dist/handlers/renameHandler.test.d.ts.map +1 -0
- package/dist/handlers/renameHandler.test.js +148 -0
- package/dist/handlers/renameProject.d.ts +0 -1
- package/dist/handlers/renameProject.d.ts.map +1 -1
- package/dist/handlers/renameProject.js +2 -3
- package/dist/handlers/setProject.d.ts +0 -1
- package/dist/handlers/setProject.d.ts.map +1 -1
- package/dist/handlers/setProject.js +2 -3
- package/dist/handlers/validate.d.ts +6 -3
- package/dist/handlers/validate.d.ts.map +1 -1
- package/dist/handlers/validate.js +10 -8
- package/dist/index.js +11 -14
- package/dist/terminal/contentAsCodeOutput.d.ts +0 -3
- package/dist/terminal/contentAsCodeOutput.d.ts.map +1 -1
- package/dist/terminal/contentAsCodeOutput.js +7 -10
- package/dist/vendor/authoring/AGENTS.md.tmpl +1 -1
- package/dist/vendor/authoring/README.md.tmpl +1 -1
- package/dist/vendor/authoring/developing-data-apps-locally/SKILL.md +1 -1
- package/package.json +3 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildStaticAuthoringFiles = exports.loadVendoredStarterSource = exports.
|
|
3
|
+
exports.buildStaticAuthoringFiles = exports.loadVendoredStarterSource = exports.loadTemplateDependencies = exports.rewriteWorkspaceDeps = void 0;
|
|
4
4
|
exports.firstExistingDir = firstExistingDir;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const fs_1 = require("fs");
|
|
@@ -88,7 +88,6 @@ const loadVendoredTemplate = () => {
|
|
|
88
88
|
const SKIP = new Set(['skill.md', 'scripts', 'src']);
|
|
89
89
|
return walkDir(templateDir, templateDir, SKIP);
|
|
90
90
|
};
|
|
91
|
-
exports.loadVendoredTemplate = loadVendoredTemplate;
|
|
92
91
|
const loadVendoredStarterSource = () => {
|
|
93
92
|
const { templateDir } = resolveVendorDirs();
|
|
94
93
|
return walkDir(path.join(templateDir, 'src'), templateDir, new Set());
|
|
@@ -102,7 +101,7 @@ const buildStaticAuthoringFiles = (args) => {
|
|
|
102
101
|
const { templateDir, authoringDir } = resolveVendorDirs();
|
|
103
102
|
const files = [];
|
|
104
103
|
// 1. Template scaffold files (src/, scripts/, skill.md excluded)
|
|
105
|
-
for (const file of
|
|
104
|
+
for (const file of loadVendoredTemplate()) {
|
|
106
105
|
if (file.path === 'package.json') {
|
|
107
106
|
const rewritten = (0, exports.rewriteWorkspaceDeps)(Buffer.from(file.contentBase64, 'base64').toString('utf-8'), sdkVersion);
|
|
108
107
|
files.push({
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const CODE_FILENAME_MAX_STEM_LENGTH = 200;
|
|
2
|
-
export declare const CODE_FILENAME_HASH_LENGTH = 8;
|
|
3
2
|
export declare const getStableCodeHash: (value: string, length?: number) => string;
|
|
4
3
|
export declare const getContentFileNameStem: ({ value, fallbackPrefix, fallbackHashValue, maxLength, }: {
|
|
5
4
|
value: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fileNames.d.ts","sourceRoot":"","sources":["../../../src/handlers/contentAsCode/fileNames.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"fileNames.d.ts","sourceRoot":"","sources":["../../../src/handlers/contentAsCode/fileNames.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,6BAA6B,MAAM,CAAC;AAGjD,eAAO,MAAM,iBAAiB,UACnB,MAAM,WACL,MAAM,KACf,MAA2E,CAAC;AAE/E,eAAO,MAAM,sBAAsB,6DAKhC;IACC,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB,KAAG,MASH,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,wBAAwB,wGAOlC;IACC,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,0BAA0B,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzD,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;CACxC,KAAG,MAAM,EAgET,CAAC;AAEF,eAAO,MAAM,yBAAyB,iBAAkB,MAAM,KAAG,IAUhE,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.assertSafeContentFilePath = exports.allocateContentFileNames = exports.getContentFileNameStem = exports.getStableCodeHash = exports.
|
|
3
|
+
exports.assertSafeContentFilePath = exports.allocateContentFileNames = exports.getContentFileNameStem = exports.getStableCodeHash = exports.CODE_FILENAME_MAX_STEM_LENGTH = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@lightdash/common");
|
|
6
6
|
const crypto_1 = require("crypto");
|
|
7
7
|
const path = tslib_1.__importStar(require("path"));
|
|
8
8
|
exports.CODE_FILENAME_MAX_STEM_LENGTH = 200;
|
|
9
|
-
|
|
10
|
-
const getStableCodeHash = (value, length =
|
|
9
|
+
const CODE_FILENAME_HASH_LENGTH = 8;
|
|
10
|
+
const getStableCodeHash = (value, length = CODE_FILENAME_HASH_LENGTH) => (0, crypto_1.createHash)('sha256').update(value).digest('hex').slice(0, length);
|
|
11
11
|
exports.getStableCodeHash = getStableCodeHash;
|
|
12
12
|
const getContentFileNameStem = ({ value, fallbackPrefix, fallbackHashValue = value, maxLength = exports.CODE_FILENAME_MAX_STEM_LENGTH, }) => {
|
|
13
13
|
const normalizedValue = value
|
|
@@ -40,7 +40,7 @@ const allocateContentFileNames = ({ items, fallbackPrefix, extension = '.yml', m
|
|
|
40
40
|
const candidateFileName = preferredFileName ??
|
|
41
41
|
((counts.get(stem.toLowerCase()) ?? 0) === 1
|
|
42
42
|
? `${stem}${extension}`
|
|
43
|
-
: `${stem.slice(0, maxStemLength -
|
|
43
|
+
: `${stem.slice(0, maxStemLength - CODE_FILENAME_HASH_LENGTH - 1)}-${(0, exports.getStableCodeHash)(identity)}${extension}`);
|
|
44
44
|
if (!usedFileNames.has(candidateFileName.toLowerCase())) {
|
|
45
45
|
usedFileNames.add(candidateFileName.toLowerCase());
|
|
46
46
|
return candidateFileName;
|
|
@@ -21,7 +21,6 @@ export type DbtCompileOptions = {
|
|
|
21
21
|
favorState: boolean | undefined;
|
|
22
22
|
combineManifest: string | undefined;
|
|
23
23
|
};
|
|
24
|
-
export declare const dbtCompile: (options: DbtCompileOptions) => Promise<void>;
|
|
25
24
|
export declare function dbtList(options: DbtCompileOptions): Promise<string[]>;
|
|
26
25
|
export type CompileModelsResult = {
|
|
27
26
|
compiledModelIds: string[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/compile.ts"],"names":[],"mappings":"AAYA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAIpE,MAAM,MAAM,iBAAiB,GAAG;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,oBAAoB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1C,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,CAAC;
|
|
1
|
+
{"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/compile.ts"],"names":[],"mappings":"AAYA,OAAO,EAAgB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAIpE,MAAM,MAAM,iBAAiB,GAAG;IAC5B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC7B,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,OAAO,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC;IACjC,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,oBAAoB,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1C,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,KAAK,EAAE,OAAO,GAAG,SAAS,CAAC;IAC3B,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,UAAU,EAAE,OAAO,GAAG,SAAS,CAAC;IAChC,eAAe,EAAE,MAAM,GAAG,SAAS,CAAC;CACvC,CAAC;AAyHF,wBAAsB,OAAO,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAyC3E;AAED,MAAM,MAAM,mBAAmB,GAAG;IAC9B,gBAAgB,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;IACvC;;;;OAIG;IACH,0BAA0B,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACpD,CAAC;AAEF,wBAAsB,0BAA0B,CAC5C,gBAAgB,EAAE,gBAAgB,EAClC,cAAc,EAAE,iBAAiB,GAClC,OAAO,CAAC,mBAAmB,CAAC,CA0G9B"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dbtCompile = void 0;
|
|
4
3
|
exports.dbtList = dbtList;
|
|
5
4
|
exports.maybeCompileModelsAndJoins = maybeCompileModelsAndJoins;
|
|
6
5
|
const tslib_1 = require("tslib");
|
|
@@ -58,7 +57,6 @@ const dbtCompile = async (options) => {
|
|
|
58
57
|
throw new common_1.ParseError(`Failed to run dbt compile:\n ${msg}`);
|
|
59
58
|
}
|
|
60
59
|
};
|
|
61
|
-
exports.dbtCompile = dbtCompile;
|
|
62
60
|
/**
|
|
63
61
|
* Reads run_results.json written by dbt after each compile/run to get the
|
|
64
62
|
* unique_ids of models that were actually processed in THIS run.
|
|
@@ -173,7 +171,7 @@ async function maybeCompileModelsAndJoins(loadManifestOpts, initialOptions) {
|
|
|
173
171
|
compiledModelIds = await dbtList(options);
|
|
174
172
|
}
|
|
175
173
|
else {
|
|
176
|
-
await
|
|
174
|
+
await dbtCompile(options);
|
|
177
175
|
compiledModelIds = await getCompiledModelIdsFromRunResults(loadManifestOpts.targetDir);
|
|
178
176
|
}
|
|
179
177
|
// If no models are explicitly selected or excluded, we don't need to explicitly find joined models
|
|
@@ -207,7 +205,7 @@ async function maybeCompileModelsAndJoins(loadManifestOpts, initialOptions) {
|
|
|
207
205
|
originallySelectedModelIds,
|
|
208
206
|
};
|
|
209
207
|
}
|
|
210
|
-
await
|
|
208
|
+
await dbtCompile({
|
|
211
209
|
...options,
|
|
212
210
|
select: requiredModelsNames,
|
|
213
211
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDbtVersion.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/getDbtVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAMnB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"getDbtVersion.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/getDbtVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,gBAAgB,EAMnB,MAAM,mBAAmB,CAAC;AAqE3B,MAAM,MAAM,UAAU,GAAG;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,gBAAgB,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,eAAO,MAAM,aAAa,QAAa,OAAO,CAAC,UAAU,CA+CxD,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAC7C;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAc9E,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.tryGetDbtVersion = exports.getDbtVersion =
|
|
3
|
+
exports.tryGetDbtVersion = exports.getDbtVersion = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@lightdash/common");
|
|
6
6
|
const execa_1 = tslib_1.__importDefault(require("execa"));
|
|
@@ -8,7 +8,7 @@ const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
|
8
8
|
const globalState_1 = tslib_1.__importDefault(require("../../globalState"));
|
|
9
9
|
const styles = tslib_1.__importStar(require("../../styles"));
|
|
10
10
|
const DBT_CORE_VERSION_REGEX = /installed:.*/;
|
|
11
|
-
|
|
11
|
+
const DBT_CLOUD_CLI_REGEX = /dbt Cloud CLI.*/;
|
|
12
12
|
const DBT_FUSION_VERSION_REGEX = /dbt-fusion.*/;
|
|
13
13
|
const getDbtCLIVersion = async () => {
|
|
14
14
|
try {
|
|
@@ -17,7 +17,7 @@ const getDbtCLIVersion = async () => {
|
|
|
17
17
|
stdio: ['pipe', 'pipe', 'pipe'],
|
|
18
18
|
});
|
|
19
19
|
const logs = all || '';
|
|
20
|
-
const cloudVersion = logs.match(
|
|
20
|
+
const cloudVersion = logs.match(DBT_CLOUD_CLI_REGEX);
|
|
21
21
|
if (cloudVersion) {
|
|
22
22
|
return cloudVersion[0];
|
|
23
23
|
}
|
|
@@ -35,10 +35,10 @@ const getDbtCLIVersion = async () => {
|
|
|
35
35
|
throw new common_1.ParseError(`Failed to get dbt --version:\n ${msg}`);
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
|
-
const isDbtCloudCLI = (version) => version.match(
|
|
38
|
+
const isDbtCloudCLI = (version) => version.match(DBT_CLOUD_CLI_REGEX) !== null;
|
|
39
39
|
const isDbtFusion = (version) => version.match(DBT_FUSION_VERSION_REGEX) !== null;
|
|
40
40
|
const getSupportedDbtVersionOption = (version) => {
|
|
41
|
-
if (version.match(
|
|
41
|
+
if (version.match(DBT_CLOUD_CLI_REGEX))
|
|
42
42
|
return common_1.DbtVersionOptionLatest.LATEST;
|
|
43
43
|
if (version.match(DBT_FUSION_VERSION_REGEX))
|
|
44
44
|
return common_1.DbtVersionOptionLatest.LATEST;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import { CreateSnowflakeCredentials, CreateWarehouseCredentials
|
|
1
|
+
import { CreateSnowflakeCredentials, CreateWarehouseCredentials } from '@lightdash/common';
|
|
2
2
|
import { warehouseClientFromCredentials } from '@lightdash/warehouses';
|
|
3
|
-
type GetTableCatalogProps = {
|
|
4
|
-
projectUuid: string;
|
|
5
|
-
tableName: string;
|
|
6
|
-
schemaName: string;
|
|
7
|
-
databaseName?: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const getTableSchema: ({ projectUuid, tableName, schemaName, databaseName, }: GetTableCatalogProps) => Promise<WarehouseTableSchema>;
|
|
10
3
|
type GetWarehouseClientOptions = {
|
|
11
4
|
isDbtCloudCLI: boolean;
|
|
12
5
|
profilesDir: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getWarehouseClient.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/getWarehouseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,0BAA0B,EAC1B,0BAA0B,
|
|
1
|
+
{"version":3,"file":"getWarehouseClient.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/getWarehouseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAGH,0BAA0B,EAC1B,0BAA0B,EAW7B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAGH,8BAA8B,EACjC,MAAM,uBAAuB,CAAC;AAgN/B,KAAK,yBAAyB,GAAG;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AASF,eAAO,MAAM,iCAAiC,gBAC7B,0BAA0B,KACxC,OAAO,CAAC,MAAM,CAwBhB,CAAC;AAEF,KAAK,wBAAwB,GAAG;IAC5B,eAAe,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAC;IACnE,WAAW,EAAE,0BAA0B,CAAC;CAC3C,CAAC;AAEF,wBAA8B,kBAAkB,CAC5C,OAAO,EAAE,yBAAyB,GACnC,OAAO,CAAC,wBAAwB,CAAC,CAgLnC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createProgramaticallySnowflakePat =
|
|
3
|
+
exports.createProgramaticallySnowflakePat = void 0;
|
|
4
4
|
exports.default = getWarehouseClient;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
const common_1 = require("@lightdash/common");
|
|
@@ -38,7 +38,6 @@ const getTableSchema = async ({ projectUuid, tableName, schemaName, databaseName
|
|
|
38
38
|
url: `/api/v1/projects/${projectUuid}/sqlRunner/fields?tableName=${tableName}&schemaName=${schemaName}&databaseName=${databaseName}`,
|
|
39
39
|
body: undefined,
|
|
40
40
|
});
|
|
41
|
-
exports.getTableSchema = getTableSchema;
|
|
42
41
|
const DBT_CLOUD_CONNECTION_TYPE_REGEX = /Connection type\s+(\w+)/;
|
|
43
42
|
const getDbtCloudConnectionType = async () => {
|
|
44
43
|
try {
|
|
@@ -216,7 +215,7 @@ async function getWarehouseClient(options) {
|
|
|
216
215
|
}
|
|
217
216
|
try {
|
|
218
217
|
globalState_1.default.debug(`> Warehouse schema information is not available in dbt Cloud CLI. The schema ${ref.database}.${ref.schema}.${ref.table} will be fetched from the active project.`);
|
|
219
|
-
const fields = await
|
|
218
|
+
const fields = await getTableSchema({
|
|
220
219
|
projectUuid: config.context.project,
|
|
221
220
|
tableName: ref.table,
|
|
222
221
|
schemaName: ref.schema,
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { Job,
|
|
1
|
+
import { Job, Project } from '@lightdash/common';
|
|
2
2
|
export declare const getProject: (projectUuid: string) => Promise<Project>;
|
|
3
|
-
export declare const getRunningStepsMessage: (steps: JobStep[]) => string;
|
|
4
|
-
export declare const getErrorStepsMessage: (steps: JobStep[]) => string;
|
|
5
3
|
export declare const getFinalJobState: (jobUuid: string, spinnerPrefix?: string) => Promise<Job>;
|
|
6
4
|
type RefreshHandlerOptions = {
|
|
7
5
|
verbose: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,GAAG,
|
|
1
|
+
{"version":3,"file":"refresh.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/refresh.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,GAAG,EAKH,OAAO,EACV,MAAM,mBAAmB,CAAC;AAQ3B,eAAO,MAAM,UAAU,gBAAuB,MAAM,qBAK9C,CAAC;AAgDP,eAAO,MAAM,gBAAgB,YAChB,MAAM,kBACA,MAAM,KACtB,OAAO,CAAC,GAAG,CAcb,CAAC;AAEF,KAAK,qBAAqB,GAAG;IACzB,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,cAAc,YAAmB,qBAAqB,kBAgElE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.refreshHandler = exports.getFinalJobState = exports.
|
|
3
|
+
exports.refreshHandler = exports.getFinalJobState = exports.getProject = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@lightdash/common");
|
|
6
6
|
const uuid_1 = require("uuid");
|
|
@@ -35,13 +35,11 @@ const getRunningStepsMessage = (steps) => {
|
|
|
35
35
|
const numberOfCompletedSteps = steps.filter((step) => step.stepStatus === common_1.JobStepStatusType.DONE).length;
|
|
36
36
|
return `step ${Math.min(numberOfCompletedSteps + 1, steps.length)}/${steps.length}: ${runningStep?.stepLabel || ''}`;
|
|
37
37
|
};
|
|
38
|
-
exports.getRunningStepsMessage = getRunningStepsMessage;
|
|
39
38
|
const getErrorStepsMessage = (steps) => {
|
|
40
39
|
const errorStep = steps.find((step) => step.stepStatus === common_1.JobStepStatusType.ERROR);
|
|
41
40
|
const numberOfCompletedSteps = steps.filter((step) => step.stepStatus === common_1.JobStepStatusType.DONE).length;
|
|
42
41
|
return `step ${Math.min(numberOfCompletedSteps + 1, steps.length)}/${steps.length}: ${errorStep?.stepLabel || ''} error ${errorStep?.stepError}`;
|
|
43
42
|
};
|
|
44
|
-
exports.getErrorStepsMessage = getErrorStepsMessage;
|
|
45
43
|
const REFETCH_JOB_INTERVAL = 3000;
|
|
46
44
|
const getFinalJobState = async (jobUuid, spinnerPrefix = 'Refreshing dbt project') => {
|
|
47
45
|
const job = await getJobState(jobUuid);
|
|
@@ -49,10 +47,10 @@ const getFinalJobState = async (jobUuid, spinnerPrefix = 'Refreshing dbt project
|
|
|
49
47
|
return job;
|
|
50
48
|
}
|
|
51
49
|
if (job.jobStatus === common_1.JobStatusType.ERROR) {
|
|
52
|
-
throw new Error(
|
|
50
|
+
throw new Error(getErrorStepsMessage(job.steps));
|
|
53
51
|
}
|
|
54
52
|
const spinner = globalState_1.default.getActiveSpinner();
|
|
55
|
-
spinner?.start(` ${spinnerPrefix}, ${
|
|
53
|
+
spinner?.start(` ${spinnerPrefix}, ${getRunningStepsMessage(job.steps)}`);
|
|
56
54
|
return delay(REFETCH_JOB_INTERVAL).then(() => (0, exports.getFinalJobState)(jobUuid, spinnerPrefix));
|
|
57
55
|
};
|
|
58
56
|
exports.getFinalJobState = getFinalJobState;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Explore, ExploreError } from '@lightdash/common';
|
|
2
2
|
import { DbtCompileOptions } from './dbt/compile';
|
|
3
3
|
type DeployHandlerOptions = DbtCompileOptions & {
|
|
4
4
|
projectDir: string;
|
|
@@ -24,7 +24,6 @@ type DeployHandlerOptions = DbtCompileOptions & {
|
|
|
24
24
|
type DeployArgs = DeployHandlerOptions & {
|
|
25
25
|
projectUuid: string;
|
|
26
26
|
};
|
|
27
|
-
export declare const logDeployWarnings: (warningResults: ApiDeployExploresResults['warnings'] | undefined) => void;
|
|
28
27
|
export declare const deploy: (explores: (Explore | ExploreError)[], options: DeployArgs) => Promise<void>;
|
|
29
28
|
export declare const deployHandler: (originalOptions: DeployHandlerOptions) => Promise<void>;
|
|
30
29
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/handlers/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/handlers/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,OAAO,EACP,YAAY,EASf,MAAM,mBAAmB,CAAC;AA2B3B,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AASlD,KAAK,oBAAoB,GAAG,iBAAiB,GAAG;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,0BAA0B,CAAC,EAAE,OAAO,CAAC;IACrC,wBAAwB,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAChC,CAAC;AAEF,KAAK,UAAU,GAAG,oBAAoB,GAAG;IACrC,WAAW,EAAE,MAAM,CAAC;CACvB,CAAC;AA8QF,eAAO,MAAM,MAAM,aACL,CAAC,OAAO,GAAG,YAAY,CAAC,EAAE,WAC3B,UAAU,KACpB,OAAO,CAAC,IAAI,CA6Id,CAAC;AAiGF,eAAO,MAAM,aAAa,oBAA2B,oBAAoB,kBAmKxE,CAAC"}
|
package/dist/handlers/deploy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.deployHandler = exports.deploy =
|
|
3
|
+
exports.deployHandler = exports.deploy = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@lightdash/common");
|
|
6
6
|
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
@@ -35,7 +35,6 @@ const logDeployWarnings = (warningResults) => {
|
|
|
35
35
|
});
|
|
36
36
|
console.error('');
|
|
37
37
|
};
|
|
38
|
-
exports.logDeployWarnings = logDeployWarnings;
|
|
39
38
|
const replaceProjectYamlTags = async (projectUuid, lightdashProjectConfig) => {
|
|
40
39
|
const yamlTags = Object.entries(lightdashProjectConfig.spotlight?.categories ?? {}).map(([yamlReference, category]) => ({
|
|
41
40
|
yamlReference,
|
|
@@ -177,7 +176,7 @@ const deployBatched = async (explores, options) => {
|
|
|
177
176
|
body: JSON.stringify({}),
|
|
178
177
|
});
|
|
179
178
|
globalState_1.default.log(styles.success(`Deploy completed! ${finalizeResponse.exploreCount} explores deployed.`));
|
|
180
|
-
|
|
179
|
+
logDeployWarnings(finalizeResponse.warnings);
|
|
181
180
|
await analytics_1.LightdashAnalytics.track({
|
|
182
181
|
event: 'deploy.triggered',
|
|
183
182
|
properties: {
|
|
@@ -242,7 +241,7 @@ const deploy = async (explores, options) => {
|
|
|
242
241
|
body: deployPayload,
|
|
243
242
|
});
|
|
244
243
|
if (deployResponse) {
|
|
245
|
-
|
|
244
|
+
logDeployWarnings(deployResponse.warnings);
|
|
246
245
|
}
|
|
247
246
|
await analytics_1.LightdashAnalytics.track({
|
|
248
247
|
event: 'deploy.triggered',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renameHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/renameHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,UAAU,EAEb,MAAM,mBAAmB,CAAC;AAkB3B,KAAK,oBAAoB,GAAG;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;
|
|
1
|
+
{"version":3,"file":"renameHandler.d.ts","sourceRoot":"","sources":["../../src/handlers/renameHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,UAAU,EAEb,MAAM,mBAAmB,CAAC;AAkB3B,KAAK,oBAAoB,GAAG;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;CACrB,CAAC;AAwCF,eAAO,MAAM,aAAa,YAAmB,oBAAoB,kBAoNhE,CAAC"}
|
|
@@ -15,16 +15,16 @@ const apiClient_1 = require("./dbt/apiClient");
|
|
|
15
15
|
const refresh_1 = require("./dbt/refresh");
|
|
16
16
|
const validate_1 = require("./validate");
|
|
17
17
|
const REFETCH_JOB_INTERVAL = 2000;
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
18
|
+
const waitUntilRenameFinished = (jobUuid) => (0, validate_1.waitUntilFinished)({
|
|
19
|
+
jobUuid,
|
|
20
|
+
refetchIntervalMs: REFETCH_JOB_INTERVAL,
|
|
21
|
+
createError: (jobError) => new Error(`\nRename failed: ${jobError}`),
|
|
22
|
+
});
|
|
23
|
+
const waitUntilValidationFinished = (jobUuid) => (0, validate_1.waitUntilFinished)({
|
|
24
|
+
jobUuid,
|
|
25
|
+
refetchIntervalMs: REFETCH_JOB_INTERVAL,
|
|
26
|
+
createError: (jobError) => new common_1.UnexpectedServerError(`\nValidation failed: ${jobError}`),
|
|
27
|
+
});
|
|
28
28
|
const listResources = (resources, type, list) => {
|
|
29
29
|
if (resources.length === 0)
|
|
30
30
|
return;
|
|
@@ -87,7 +87,7 @@ const renameHandler = async (options) => {
|
|
|
87
87
|
body: JSON.stringify(options),
|
|
88
88
|
});
|
|
89
89
|
globalState_1.default.debug(`Rename job scheduled with id: ${jobResponse.jobId}`);
|
|
90
|
-
const status = await
|
|
90
|
+
const status = await waitUntilRenameFinished(jobResponse.jobId);
|
|
91
91
|
globalState_1.default.debug(`Rename job finished with status: ${status}`);
|
|
92
92
|
const job = await (0, validate_1.getJobState)(jobResponse.jobId);
|
|
93
93
|
const results = job.details?.results;
|
|
@@ -117,12 +117,20 @@ const renameHandler = async (options) => {
|
|
|
117
117
|
fs_1.default.writeFileSync(filePath, JSON.stringify(results, null, 2), 'utf-8');
|
|
118
118
|
console.info(`Rename changes saved to: ${styles.success(` ${filePath}`)}`);
|
|
119
119
|
}
|
|
120
|
+
let validationStatus = 'skipped';
|
|
120
121
|
if (options.validate && !options.dryRun) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
try {
|
|
123
|
+
const validationJob = await (0, validate_1.requestValidation)(projectUuid, [], []);
|
|
124
|
+
const { jobId } = validationJob;
|
|
125
|
+
await waitUntilValidationFinished(jobId);
|
|
126
|
+
const validation = await (0, validate_1.getValidation)(projectUuid, jobId);
|
|
127
|
+
console.info(validation);
|
|
128
|
+
validationStatus = 'passed';
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
validationStatus = 'failed';
|
|
132
|
+
console.error(`Rename completed, but the follow-up validation failed: ${(0, common_1.getErrorMessage)(e)}`);
|
|
133
|
+
}
|
|
126
134
|
}
|
|
127
135
|
await analytics_1.LightdashAnalytics.track({
|
|
128
136
|
event: 'rename.completed',
|
|
@@ -134,6 +142,7 @@ const renameHandler = async (options) => {
|
|
|
134
142
|
chartsUpdated: results.charts.length,
|
|
135
143
|
dashboardsUpdated: results.dashboards.length,
|
|
136
144
|
durationMs: Date.now() - startTime,
|
|
145
|
+
validationStatus,
|
|
137
146
|
},
|
|
138
147
|
});
|
|
139
148
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renameHandler.test.d.ts","sourceRoot":"","sources":["../../src/handlers/renameHandler.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const common_1 = require("@lightdash/common");
|
|
4
|
+
const analytics_1 = require("../analytics/analytics");
|
|
5
|
+
const config_1 = require("../config");
|
|
6
|
+
const apiClient_1 = require("./dbt/apiClient");
|
|
7
|
+
const refresh_1 = require("./dbt/refresh");
|
|
8
|
+
const renameHandler_1 = require("./renameHandler");
|
|
9
|
+
vi.mock('../analytics/analytics');
|
|
10
|
+
vi.mock('../config');
|
|
11
|
+
vi.mock('./dbt/apiClient');
|
|
12
|
+
vi.mock('./dbt/refresh');
|
|
13
|
+
const baseOptions = {
|
|
14
|
+
verbose: false,
|
|
15
|
+
type: common_1.RenameType.FIELD,
|
|
16
|
+
project: 'test-project-uuid',
|
|
17
|
+
from: 'old_name',
|
|
18
|
+
to: 'new_name',
|
|
19
|
+
dryRun: false,
|
|
20
|
+
assumeYes: true,
|
|
21
|
+
list: false,
|
|
22
|
+
validate: true,
|
|
23
|
+
};
|
|
24
|
+
const emptyResults = {
|
|
25
|
+
charts: [],
|
|
26
|
+
dashboards: [],
|
|
27
|
+
alerts: [],
|
|
28
|
+
dashboardSchedulers: [],
|
|
29
|
+
};
|
|
30
|
+
const RENAME_JOB_ID = 'rename-job-id';
|
|
31
|
+
const VALIDATION_JOB_ID = 'validation-job-id';
|
|
32
|
+
describe('renameHandler follow-up validation', () => {
|
|
33
|
+
let errorOutput;
|
|
34
|
+
const mockApi = (failingJobId) => {
|
|
35
|
+
vi.mocked(apiClient_1.lightdashApi).mockImplementation(async ({ method, url }) => {
|
|
36
|
+
if (method === 'POST' && url.endsWith('/rename')) {
|
|
37
|
+
return { jobId: RENAME_JOB_ID };
|
|
38
|
+
}
|
|
39
|
+
if (method === 'POST' && url.endsWith('/validate')) {
|
|
40
|
+
return { jobId: VALIDATION_JOB_ID };
|
|
41
|
+
}
|
|
42
|
+
if (url.includes(`/schedulers/job/${failingJobId}/status`)) {
|
|
43
|
+
return {
|
|
44
|
+
status: common_1.SchedulerJobStatus.ERROR,
|
|
45
|
+
details: { error: 'job blew up' },
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (url.includes('/schedulers/job/')) {
|
|
49
|
+
return {
|
|
50
|
+
status: common_1.SchedulerJobStatus.COMPLETED,
|
|
51
|
+
details: { results: emptyResults },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (url.includes('/validate?jobId=')) {
|
|
55
|
+
return [];
|
|
56
|
+
}
|
|
57
|
+
throw new Error(`Unexpected API call: ${method} ${url}`);
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
vi.clearAllMocks();
|
|
62
|
+
vi.mocked(apiClient_1.checkLightdashVersion).mockResolvedValue(undefined);
|
|
63
|
+
vi.mocked(config_1.getConfig).mockResolvedValue({
|
|
64
|
+
context: {
|
|
65
|
+
apiKey: 'test-key',
|
|
66
|
+
serverUrl: 'http://localhost',
|
|
67
|
+
project: 'test-project-uuid',
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
vi.mocked(refresh_1.getProject).mockResolvedValue({
|
|
71
|
+
name: 'test project',
|
|
72
|
+
});
|
|
73
|
+
errorOutput = [];
|
|
74
|
+
vi.spyOn(console, 'error').mockImplementation((...args) => {
|
|
75
|
+
errorOutput.push(args.map(String).join(' '));
|
|
76
|
+
});
|
|
77
|
+
vi.spyOn(console, 'info').mockImplementation(() => { });
|
|
78
|
+
});
|
|
79
|
+
afterEach(() => {
|
|
80
|
+
vi.restoreAllMocks();
|
|
81
|
+
});
|
|
82
|
+
const trackedEvents = () => vi.mocked(analytics_1.LightdashAnalytics.track).mock.calls.map(([payload]) => ({
|
|
83
|
+
event: payload.event,
|
|
84
|
+
properties: payload.properties,
|
|
85
|
+
}));
|
|
86
|
+
test('reports a failed validation job as a validation failure, not a rename failure', async () => {
|
|
87
|
+
mockApi(VALIDATION_JOB_ID);
|
|
88
|
+
await (0, renameHandler_1.renameHandler)({ ...baseOptions });
|
|
89
|
+
const output = errorOutput.join('\n');
|
|
90
|
+
expect(output).toContain('Rename completed');
|
|
91
|
+
expect(output).toContain('Validation failed: job blew up');
|
|
92
|
+
expect(output).not.toContain('Rename failed');
|
|
93
|
+
expect(output).not.toContain('unexpected error');
|
|
94
|
+
});
|
|
95
|
+
test('counts a rename whose follow-up validation failed as completed', async () => {
|
|
96
|
+
mockApi(VALIDATION_JOB_ID);
|
|
97
|
+
await (0, renameHandler_1.renameHandler)({ ...baseOptions });
|
|
98
|
+
expect(trackedEvents()).toEqual([
|
|
99
|
+
{
|
|
100
|
+
event: 'rename.completed',
|
|
101
|
+
properties: expect.objectContaining({
|
|
102
|
+
validationStatus: 'failed',
|
|
103
|
+
}),
|
|
104
|
+
},
|
|
105
|
+
]);
|
|
106
|
+
});
|
|
107
|
+
test('still reports a failed rename job as a rename failure', async () => {
|
|
108
|
+
mockApi(RENAME_JOB_ID);
|
|
109
|
+
await (0, renameHandler_1.renameHandler)({ ...baseOptions });
|
|
110
|
+
const output = errorOutput.join('\n');
|
|
111
|
+
expect(output).toContain('Rename failed: job blew up');
|
|
112
|
+
expect(output).not.toContain('Validation failed');
|
|
113
|
+
expect(trackedEvents()).toEqual([
|
|
114
|
+
{ event: 'rename.error', properties: expect.anything() },
|
|
115
|
+
]);
|
|
116
|
+
});
|
|
117
|
+
test('records a passing validation on the completed event', async () => {
|
|
118
|
+
mockApi(null);
|
|
119
|
+
await (0, renameHandler_1.renameHandler)({ ...baseOptions });
|
|
120
|
+
expect(trackedEvents()).toEqual([
|
|
121
|
+
{
|
|
122
|
+
event: 'rename.completed',
|
|
123
|
+
properties: expect.objectContaining({
|
|
124
|
+
validationStatus: 'passed',
|
|
125
|
+
}),
|
|
126
|
+
},
|
|
127
|
+
]);
|
|
128
|
+
});
|
|
129
|
+
test('does not run the validation job when --validate is not set', async () => {
|
|
130
|
+
mockApi(null);
|
|
131
|
+
await (0, renameHandler_1.renameHandler)({ ...baseOptions, validate: false });
|
|
132
|
+
const validationCalls = vi
|
|
133
|
+
.mocked(apiClient_1.lightdashApi)
|
|
134
|
+
.mock.calls.filter(([{ url }]) => url.endsWith('/validate'));
|
|
135
|
+
expect(validationCalls).toEqual([]);
|
|
136
|
+
const output = errorOutput.join('\n');
|
|
137
|
+
expect(output).not.toContain('failed');
|
|
138
|
+
expect(output).not.toContain('unexpected error');
|
|
139
|
+
expect(trackedEvents()).toEqual([
|
|
140
|
+
{
|
|
141
|
+
event: 'rename.completed',
|
|
142
|
+
properties: expect.objectContaining({
|
|
143
|
+
validationStatus: 'skipped',
|
|
144
|
+
}),
|
|
145
|
+
},
|
|
146
|
+
]);
|
|
147
|
+
});
|
|
148
|
+
});
|
|
@@ -2,7 +2,6 @@ type RenameProjectOptions = {
|
|
|
2
2
|
name: string;
|
|
3
3
|
verbose: boolean;
|
|
4
4
|
};
|
|
5
|
-
export declare const renameProjectCommand: (name: string) => Promise<void>;
|
|
6
5
|
export declare const renameProjectHandler: (options: RenameProjectOptions) => Promise<void>;
|
|
7
6
|
export {};
|
|
8
7
|
//# sourceMappingURL=renameProject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renameProject.d.ts","sourceRoot":"","sources":["../../src/handlers/renameProject.ts"],"names":[],"mappings":"AAMA,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;
|
|
1
|
+
{"version":3,"file":"renameProject.d.ts","sourceRoot":"","sources":["../../src/handlers/renameProject.ts"],"names":[],"mappings":"AAMA,KAAK,oBAAoB,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CACpB,CAAC;AA2BF,eAAO,MAAM,oBAAoB,YAAmB,oBAAoB,kBAoBvE,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.renameProjectHandler =
|
|
3
|
+
exports.renameProjectHandler = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const common_1 = require("@lightdash/common");
|
|
6
6
|
const analytics_1 = require("../analytics/analytics");
|
|
@@ -25,13 +25,12 @@ const renameProjectCommand = async (name) => {
|
|
|
25
25
|
await (0, config_1.setProject)(project.projectUuid, project.name);
|
|
26
26
|
console.error(`\n ✅️ Renamed project to: ${project.name}\n`);
|
|
27
27
|
};
|
|
28
|
-
exports.renameProjectCommand = renameProjectCommand;
|
|
29
28
|
const renameProjectHandler = async (options) => {
|
|
30
29
|
const startTime = Date.now();
|
|
31
30
|
let success = true;
|
|
32
31
|
globalState_1.default.setVerbose(options.verbose);
|
|
33
32
|
try {
|
|
34
|
-
await
|
|
33
|
+
await renameProjectCommand(options.name);
|
|
35
34
|
}
|
|
36
35
|
catch (e) {
|
|
37
36
|
success = false;
|
|
@@ -6,7 +6,6 @@ type SetProjectOptions = {
|
|
|
6
6
|
export declare const setProjectCommand: (name?: string, uuid?: string) => Promise<'selected' | 'skipped' | 'empty'>;
|
|
7
7
|
export declare const setFirstProject: () => Promise<void>;
|
|
8
8
|
export declare const setProjectHandler: (options: SetProjectOptions) => Promise<void>;
|
|
9
|
-
export declare const unsetProjectCommand: () => Promise<void>;
|
|
10
9
|
export declare const unsetProjectHandler: (options: {
|
|
11
10
|
verbose: boolean;
|
|
12
11
|
}) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setProject.d.ts","sourceRoot":"","sources":["../../src/handlers/setProject.ts"],"names":[],"mappings":"AAQA,KAAK,iBAAiB,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,iBAAiB,UACnB,MAAM,SACN,MAAM,KACd,OAAO,CAAC,UAAU,GAAG,SAAS,GAAG,OAAO,CAiF1C,CAAC;AAEF,eAAO,MAAM,eAAe,qBAmB3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAmB,iBAAiB,kBAsBjE,CAAC;
|
|
1
|
+
{"version":3,"file":"setProject.d.ts","sourceRoot":"","sources":["../../src/handlers/setProject.ts"],"names":[],"mappings":"AAQA,KAAK,iBAAiB,GAAG;IACrB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,eAAO,MAAM,iBAAiB,UACnB,MAAM,SACN,MAAM,KACd,OAAO,CAAC,UAAU,GAAG,SAAS,GAAG,OAAO,CAiF1C,CAAC;AAEF,eAAO,MAAM,eAAe,qBAmB3B,CAAC;AAEF,eAAO,MAAM,iBAAiB,YAAmB,iBAAiB,kBAsBjE,CAAC;AAOF,eAAO,MAAM,mBAAmB,YAAmB;IAAE,OAAO,EAAE,OAAO,CAAA;CAAE,kBAmBtE,CAAC"}
|