@lightdash/cli 0.2141.1 → 0.2142.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/.tsbuildinfo +1 -1
- package/dist/dbt/targets/databricks.d.ts +4 -1
- package/dist/dbt/targets/databricks.d.ts.map +1 -1
- package/dist/dbt/targets/databricks.js +45 -6
- package/dist/handlers/dbt/getWarehouseClient.d.ts.map +1 -1
- package/dist/handlers/dbt/getWarehouseClient.js +11 -0
- package/package.json +3 -3
|
@@ -12,7 +12,10 @@ export type DatabricksTarget = {
|
|
|
12
12
|
schema: string;
|
|
13
13
|
host: string;
|
|
14
14
|
http_path: string;
|
|
15
|
-
token
|
|
15
|
+
token?: string;
|
|
16
|
+
auth_type?: 'token' | 'oauth';
|
|
17
|
+
client_id?: string;
|
|
18
|
+
client_secret?: string;
|
|
16
19
|
threads?: number;
|
|
17
20
|
compute?: DatabricksComputeConfig;
|
|
18
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"databricks.d.ts","sourceRoot":"","sources":["../../../src/dbt/targets/databricks.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,2BAA2B,
|
|
1
|
+
{"version":3,"file":"databricks.d.ts","sourceRoot":"","sources":["../../../src/dbt/targets/databricks.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,2BAA2B,EAI9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAGrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,KAAK,uBAAuB,GAAG;IAC3B,CAAC,IAAI,EAAE,MAAM,GAAG;QACZ,SAAS,EAAE,MAAM,CAAC;KACrB,CAAC;CACL,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,EAAE,YAAY,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAElB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,SAAS,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IAC9B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,uBAAuB,CAAC;CACrC,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,cAAc,CAAC,gBAAgB,CAyD7D,CAAC;AAEF,eAAO,MAAM,uBAAuB,WACxB,MAAM,KACf,2BA+DF,CAAC"}
|
|
@@ -27,6 +27,20 @@ exports.databricksSchema = {
|
|
|
27
27
|
},
|
|
28
28
|
token: {
|
|
29
29
|
type: 'string',
|
|
30
|
+
nullable: true,
|
|
31
|
+
},
|
|
32
|
+
auth_type: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
enum: ['token', 'oauth'],
|
|
35
|
+
nullable: true,
|
|
36
|
+
},
|
|
37
|
+
client_id: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
nullable: true,
|
|
40
|
+
},
|
|
41
|
+
client_secret: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
nullable: true,
|
|
30
44
|
},
|
|
31
45
|
threads: {
|
|
32
46
|
type: 'number',
|
|
@@ -47,26 +61,51 @@ exports.databricksSchema = {
|
|
|
47
61
|
},
|
|
48
62
|
},
|
|
49
63
|
},
|
|
50
|
-
required: ['type', 'schema', 'host', 'http_path'
|
|
64
|
+
required: ['type', 'schema', 'host', 'http_path'],
|
|
51
65
|
};
|
|
52
66
|
const convertDatabricksSchema = (target) => {
|
|
53
67
|
const validate = ajv_1.ajv.compile(exports.databricksSchema);
|
|
54
|
-
if (validate(target)) {
|
|
68
|
+
if (!validate(target)) {
|
|
69
|
+
const errs = (0, better_ajv_errors_1.default)(exports.databricksSchema, target, validate.errors || []);
|
|
70
|
+
throw new common_1.ParseError(`Couldn't read profiles.yml file for ${target.type}:\n${errs}`);
|
|
71
|
+
}
|
|
72
|
+
const authType = target.auth_type || 'token';
|
|
73
|
+
// OAuth M2M authentication
|
|
74
|
+
if (authType === 'oauth') {
|
|
75
|
+
if (!target.client_id || !target.client_secret) {
|
|
76
|
+
throw new common_1.ParseError('Databricks OAuth authentication requires client_id and client_secret in profiles.yml');
|
|
77
|
+
}
|
|
55
78
|
return {
|
|
56
79
|
type: common_1.WarehouseTypes.DATABRICKS,
|
|
80
|
+
authenticationType: common_1.DatabricksAuthenticationType.OAUTH_M2M,
|
|
57
81
|
catalog: target.catalog,
|
|
58
|
-
// this supposed to be a `schema` but changing it will break for existing customers
|
|
59
82
|
database: target.schema,
|
|
60
83
|
serverHostName: target.host,
|
|
61
84
|
httpPath: target.http_path,
|
|
62
|
-
|
|
85
|
+
oauthClientId: target.client_id,
|
|
86
|
+
oauthClientSecret: target.client_secret,
|
|
63
87
|
compute: Object.entries(target.compute || {}).map(([name, compute]) => ({
|
|
64
88
|
name,
|
|
65
89
|
httpPath: compute.http_path,
|
|
66
90
|
})),
|
|
67
91
|
};
|
|
68
92
|
}
|
|
69
|
-
|
|
70
|
-
|
|
93
|
+
// Personal Access Token authentication (default)
|
|
94
|
+
if (!target.token) {
|
|
95
|
+
throw new common_1.ParseError('Databricks token is required when not using OAuth authentication');
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
type: common_1.WarehouseTypes.DATABRICKS,
|
|
99
|
+
authenticationType: common_1.DatabricksAuthenticationType.PERSONAL_ACCESS_TOKEN,
|
|
100
|
+
catalog: target.catalog,
|
|
101
|
+
database: target.schema,
|
|
102
|
+
serverHostName: target.host,
|
|
103
|
+
httpPath: target.http_path,
|
|
104
|
+
personalAccessToken: target.token,
|
|
105
|
+
compute: Object.entries(target.compute || {}).map(([name, compute]) => ({
|
|
106
|
+
name,
|
|
107
|
+
httpPath: compute.http_path,
|
|
108
|
+
})),
|
|
109
|
+
};
|
|
71
110
|
};
|
|
72
111
|
exports.convertDatabricksSchema = convertDatabricksSchema;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getWarehouseClient.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/getWarehouseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,0BAA0B,
|
|
1
|
+
{"version":3,"file":"getWarehouseClient.d.ts","sourceRoot":"","sources":["../../../src/handlers/dbt/getWarehouseClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,0BAA0B,EAQ1B,oBAAoB,EAEvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEH,8BAA8B,EACjC,MAAM,uBAAuB,CAAC;AAsC/B,KAAK,oBAAoB,GAAG;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,cAAc,0DAKxB,oBAAoB,kCAKjB,CAAC;AA8HP,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;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,CAsInC"}
|
|
@@ -217,6 +217,17 @@ async function getWarehouseClient(options) {
|
|
|
217
217
|
});
|
|
218
218
|
globalState_1.default.debug(`> Using target ${target.type}`);
|
|
219
219
|
credentials = await (0, profile_1.warehouseCredentialsFromDbtTarget)(target);
|
|
220
|
+
// Exchange Databricks OAuth credentials for access token if needed
|
|
221
|
+
if (credentials.type === common_1.WarehouseTypes.DATABRICKS &&
|
|
222
|
+
credentials.authenticationType ===
|
|
223
|
+
common_1.DatabricksAuthenticationType.OAUTH_M2M &&
|
|
224
|
+
credentials.oauthClientId &&
|
|
225
|
+
credentials.oauthClientSecret &&
|
|
226
|
+
!credentials.token) {
|
|
227
|
+
globalState_1.default.debug(`> Exchanging Databricks OAuth credentials for access token`);
|
|
228
|
+
const { accessToken } = await (0, warehouses_1.exchangeDatabricksOAuthCredentials)(credentials.serverHostName, credentials.oauthClientId, credentials.oauthClientSecret);
|
|
229
|
+
credentials.token = accessToken;
|
|
230
|
+
}
|
|
220
231
|
// Check if we should use cached client (e.g., for auth methods requiring user interaction)
|
|
221
232
|
const cacheKey = getWarehouseClientCacheKey(credentials);
|
|
222
233
|
if (warehouseClientCache.has(cacheKey)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lightdash/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2142.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"bin": {
|
|
6
6
|
"lightdash": "dist/index.js"
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"parse-node-version": "^2.0.0",
|
|
34
34
|
"unique-names-generator": "^4.7.1",
|
|
35
35
|
"uuid": "^11.0.3",
|
|
36
|
-
"@lightdash/common": "0.
|
|
37
|
-
"@lightdash/warehouses": "0.
|
|
36
|
+
"@lightdash/common": "0.2142.0",
|
|
37
|
+
"@lightdash/warehouses": "0.2142.0"
|
|
38
38
|
},
|
|
39
39
|
"description": "Lightdash CLI tool",
|
|
40
40
|
"devDependencies": {
|