@deepnote/database-integrations 1.0.0 → 1.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 +201 -0
- package/README.md +4 -4
- package/dist/index.cjs +35 -42
- package/dist/index.d.cts +564 -31
- package/dist/index.d.ts +564 -31
- package/dist/index.js +35 -42
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -42,27 +42,21 @@ function isFederatedAuthMetadata(metadata) {
|
|
|
42
42
|
function getSnowflakeSqlAlchemyInput(metadata, params) {
|
|
43
43
|
if (isFederatedAuthMetadata(metadata)) return null;
|
|
44
44
|
const { username, accountName, database, authMethod } = metadata;
|
|
45
|
-
if (authMethod === SnowflakeAuthMethods.ServiceAccountKeyPair) {
|
|
46
|
-
const url$1 = buildUrl(`snowflake://${encodeURIComponent(username)}@${encodeURIComponent(accountName)}`, {
|
|
47
|
-
path: database,
|
|
48
|
-
queryParams: {
|
|
49
|
-
...createBaseQueryParams(metadata, params.snowflakePartnerIdentifier),
|
|
50
|
-
authenticator: "snowflake_jwt"
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
if (!url$1) throw new Error("getSnowflakeEnvVar URL must be defined");
|
|
54
|
-
return createSqlAlchemyInputFromUrl(url$1, {
|
|
55
|
-
privateKey: metadata.privateKey,
|
|
56
|
-
password: metadata.privateKeyPassphrase,
|
|
57
|
-
username: metadata.username
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
const url = buildUrl(`snowflake://${encodeURIComponent(username)}:${encodeURIComponent(metadata.password)}@${encodeURIComponent(accountName)}`, {
|
|
45
|
+
if (authMethod === SnowflakeAuthMethods.ServiceAccountKeyPair) return createSqlAlchemyInputFromUrl(buildUrl(`snowflake://${encodeURIComponent(username)}@${encodeURIComponent(accountName)}`, {
|
|
61
46
|
path: database,
|
|
62
|
-
queryParams: {
|
|
47
|
+
queryParams: {
|
|
48
|
+
...createBaseQueryParams(metadata, params.snowflakePartnerIdentifier),
|
|
49
|
+
authenticator: "snowflake_jwt"
|
|
50
|
+
}
|
|
51
|
+
}), {
|
|
52
|
+
privateKey: metadata.privateKey,
|
|
53
|
+
password: metadata.privateKeyPassphrase,
|
|
54
|
+
username: metadata.username
|
|
63
55
|
});
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
return createSqlAlchemyInputFromUrl(buildUrl(`snowflake://${encodeURIComponent(username)}:${encodeURIComponent(metadata.password)}@${encodeURIComponent(accountName)}`, {
|
|
57
|
+
path: database,
|
|
58
|
+
queryParams: { ...createBaseQueryParams(metadata, params.snowflakePartnerIdentifier) }
|
|
59
|
+
}));
|
|
66
60
|
}
|
|
67
61
|
function createBaseQueryParams(metadata, snowflakePartnerIdentifier) {
|
|
68
62
|
return {
|
|
@@ -75,8 +69,8 @@ function createSqlAlchemyInputFromUrl(url, keyPair) {
|
|
|
75
69
|
return {
|
|
76
70
|
url,
|
|
77
71
|
params: keyPair ? {
|
|
78
|
-
snowflake_private_key:
|
|
79
|
-
snowflake_private_key_passphrase: keyPair.password
|
|
72
|
+
snowflake_private_key: btoa(keyPair.privateKey),
|
|
73
|
+
...keyPair.password ? { snowflake_private_key_passphrase: keyPair.password } : {}
|
|
80
74
|
} : {},
|
|
81
75
|
param_style: "pyformat"
|
|
82
76
|
};
|
|
@@ -84,10 +78,10 @@ function createSqlAlchemyInputFromUrl(url, keyPair) {
|
|
|
84
78
|
|
|
85
79
|
//#endregion
|
|
86
80
|
//#region src/database-integration-env-vars.ts
|
|
87
|
-
function
|
|
81
|
+
function getEnvironmentVariablesForIntegrations(integrations, params) {
|
|
88
82
|
const envVars = [];
|
|
89
83
|
const errors = [];
|
|
90
|
-
|
|
84
|
+
integrations.forEach((integration) => {
|
|
91
85
|
const namePrefix = convertToEnvironmentVariableName(integration.name);
|
|
92
86
|
const envVarsForThisIntegration = Object.entries(integration.metadata).map(([key, rawValue]) => {
|
|
93
87
|
const name = `${namePrefix}_${key.toUpperCase()}`;
|
|
@@ -114,11 +108,6 @@ function getIntegrationListEnv(sqlIntegrations, params) {
|
|
|
114
108
|
errors
|
|
115
109
|
};
|
|
116
110
|
}
|
|
117
|
-
const duckDbEnvVar = {
|
|
118
|
-
url: `deepnote+duckdb:///:memory:`,
|
|
119
|
-
params: {},
|
|
120
|
-
param_style: "qmark"
|
|
121
|
-
};
|
|
122
111
|
function addSslOptionsToMongoConnectionString(projectRoot, connectionString, integrationId, metadata) {
|
|
123
112
|
const [base, paramString] = connectionString.split("?");
|
|
124
113
|
const params = new URLSearchParams(paramString);
|
|
@@ -137,7 +126,7 @@ function getEnvVarForSqlCells(integration, params) {
|
|
|
137
126
|
const sqlAlchemyInput = getSqlAlchemyInput(integration, params);
|
|
138
127
|
if (!sqlAlchemyInput) return null;
|
|
139
128
|
return {
|
|
140
|
-
name:
|
|
129
|
+
name: getSqlEnvVarName(integration.id),
|
|
141
130
|
value: JSON.stringify({
|
|
142
131
|
integration_id: integration.id,
|
|
143
132
|
...sqlAlchemyInput
|
|
@@ -168,7 +157,11 @@ function getSqlAlchemyInput(integration, params) {
|
|
|
168
157
|
case "mindsdb":
|
|
169
158
|
case "mysql": return getMySqlSqlAlchemyInput(integration.id, params.projectRootDirectory, integration.metadata);
|
|
170
159
|
case "materialize": return getMaterializePostgresSqlAlchemyInput(integration.id, params.projectRootDirectory, integration.metadata);
|
|
171
|
-
case "pandas-dataframe": return {
|
|
160
|
+
case "pandas-dataframe": return {
|
|
161
|
+
url: `deepnote+duckdb:///:memory:`,
|
|
162
|
+
params: {},
|
|
163
|
+
param_style: "qmark"
|
|
164
|
+
};
|
|
172
165
|
case "redshift": return getRedshiftSqlAlchemyInput(integration.id, params.projectRootDirectory, integration.metadata);
|
|
173
166
|
case "snowflake": return getSnowflakeSqlAlchemyInput(integration.metadata, { snowflakePartnerIdentifier: params.snowflakePartnerIdentifier });
|
|
174
167
|
case "spanner": return getSpannerSqlAlchemyInput(integration.metadata);
|
|
@@ -187,7 +180,7 @@ const getDatabricksSqlAlchemyInput = ({ httpPath, host, token, port, schema, cat
|
|
|
187
180
|
} },
|
|
188
181
|
param_style: "pyformat",
|
|
189
182
|
ssh_options: {
|
|
190
|
-
enabled: String(sshEnabled),
|
|
183
|
+
enabled: sshEnabled == null ? void 0 : String(sshEnabled),
|
|
191
184
|
host: sshHost,
|
|
192
185
|
port: sshPort,
|
|
193
186
|
user: sshUser
|
|
@@ -195,7 +188,7 @@ const getDatabricksSqlAlchemyInput = ({ httpPath, host, token, port, schema, cat
|
|
|
195
188
|
};
|
|
196
189
|
};
|
|
197
190
|
const getDremioSqlAlchemyInput = ({ port, host, token, schema, sshEnabled, sshHost, sshPort, sshUser }) => {
|
|
198
|
-
const url = new URL(`dremio+flight://${host}:${port}${schema ?
|
|
191
|
+
const url = new URL(`dremio+flight://${host}:${port}${schema ? `/${schema}` : ""}`);
|
|
199
192
|
url.searchParams.set("UseEncryption", "true");
|
|
200
193
|
url.searchParams.set("Token", token);
|
|
201
194
|
return {
|
|
@@ -203,7 +196,7 @@ const getDremioSqlAlchemyInput = ({ port, host, token, schema, sshEnabled, sshHo
|
|
|
203
196
|
params: {},
|
|
204
197
|
param_style: "pyformat",
|
|
205
198
|
ssh_options: {
|
|
206
|
-
enabled: String(sshEnabled),
|
|
199
|
+
enabled: sshEnabled == null ? void 0 : String(sshEnabled),
|
|
207
200
|
host: sshHost,
|
|
208
201
|
port: sshPort,
|
|
209
202
|
user: sshUser
|
|
@@ -217,7 +210,7 @@ const getSQLServerVar = ({ user, password, host, port, database, sshEnabled, ssh
|
|
|
217
210
|
params: {},
|
|
218
211
|
param_style: "pyformat",
|
|
219
212
|
ssh_options: {
|
|
220
|
-
enabled: String(sshEnabled),
|
|
213
|
+
enabled: sshEnabled == null ? void 0 : String(sshEnabled),
|
|
221
214
|
host: sshHost,
|
|
222
215
|
port: sshPort,
|
|
223
216
|
user: sshUser
|
|
@@ -243,7 +236,7 @@ const getPostgresSqlAlchemyInput = (integrationId, projectRootDirectory, { user,
|
|
|
243
236
|
} },
|
|
244
237
|
param_style: "pyformat",
|
|
245
238
|
ssh_options: {
|
|
246
|
-
enabled: String(sshEnabled),
|
|
239
|
+
enabled: sshEnabled == null ? void 0 : String(sshEnabled),
|
|
247
240
|
host: sshHost,
|
|
248
241
|
port: sshPort,
|
|
249
242
|
user: sshUser
|
|
@@ -271,7 +264,7 @@ const getRedshiftSqlAlchemyInput = (integrationId, projectRootDirectory, metadat
|
|
|
271
264
|
} },
|
|
272
265
|
param_style: "pyformat",
|
|
273
266
|
ssh_options: {
|
|
274
|
-
enabled: String(metadata.sshEnabled),
|
|
267
|
+
enabled: metadata.sshEnabled == null ? void 0 : String(metadata.sshEnabled),
|
|
275
268
|
host: metadata.sshHost,
|
|
276
269
|
port: metadata.sshPort,
|
|
277
270
|
user: metadata.sshUser
|
|
@@ -303,7 +296,7 @@ const getMaterializePostgresSqlAlchemyInput = (integrationId, projectRootDirecto
|
|
|
303
296
|
} },
|
|
304
297
|
param_style: "pyformat",
|
|
305
298
|
ssh_options: {
|
|
306
|
-
enabled: String(sshEnabled),
|
|
299
|
+
enabled: sshEnabled == null ? void 0 : String(sshEnabled),
|
|
307
300
|
host: sshHost,
|
|
308
301
|
port: sshPort,
|
|
309
302
|
user: sshUser
|
|
@@ -356,7 +349,7 @@ const getClickHouseSqlAlchemyInput = (integrationId, projectRootDirectory, { use
|
|
|
356
349
|
params: {},
|
|
357
350
|
param_style: "pyformat",
|
|
358
351
|
ssh_options: {
|
|
359
|
-
enabled: String(sshEnabled),
|
|
352
|
+
enabled: sshEnabled == null ? void 0 : String(sshEnabled),
|
|
360
353
|
host: sshHost,
|
|
361
354
|
port: sshPort,
|
|
362
355
|
user: sshUser
|
|
@@ -422,7 +415,7 @@ const getMySqlSqlAlchemyInput = (integrationId, projectRootDirectory, { user, pa
|
|
|
422
415
|
params: { connect_args: { ssl } },
|
|
423
416
|
param_style: "pyformat",
|
|
424
417
|
ssh_options: {
|
|
425
|
-
enabled: String(sshEnabled),
|
|
418
|
+
enabled: sshEnabled == null ? void 0 : String(sshEnabled),
|
|
426
419
|
host: sshHost,
|
|
427
420
|
port: sshPort,
|
|
428
421
|
user: sshUser
|
|
@@ -430,13 +423,13 @@ const getMySqlSqlAlchemyInput = (integrationId, projectRootDirectory, { user, pa
|
|
|
430
423
|
};
|
|
431
424
|
};
|
|
432
425
|
function getCACertificatePath({ projectRoot, integrationId, caCertificateName }) {
|
|
433
|
-
return `${projectRoot
|
|
426
|
+
return `${projectRoot}/.deepnote/${integrationId}/${caCertificateName}`;
|
|
434
427
|
}
|
|
435
428
|
function convertToEnvironmentVariableName(str) {
|
|
436
429
|
return (/^\d/.test(str) ? `_${str}` : str).toUpperCase().replace(/[^\w]/g, "_");
|
|
437
430
|
}
|
|
438
431
|
function getSqlEnvVarName(integrationId) {
|
|
439
|
-
return `SQL_${integrationId}
|
|
432
|
+
return convertToEnvironmentVariableName(`SQL_${integrationId}`);
|
|
440
433
|
}
|
|
441
434
|
function assertNever(value) {
|
|
442
435
|
throw new Error(`Unexpected value: ${value}`);
|
|
@@ -693,4 +686,4 @@ const databaseIntegrationTypesWithSslSupport = [
|
|
|
693
686
|
];
|
|
694
687
|
|
|
695
688
|
//#endregion
|
|
696
|
-
export { AwsAuthMethods, BigQueryAuthMethods, BigQueryServiceAccountParseError, DatabaseAuthMethods, SnowflakeAuthMethods, SpannerServiceAccountParseError, databaseIntegrationTypes, databaseIntegrationTypesWithSslSupport, databaseMetadataSchemasByType,
|
|
689
|
+
export { AwsAuthMethods, BigQueryAuthMethods, BigQueryServiceAccountParseError, DatabaseAuthMethods, SnowflakeAuthMethods, SpannerServiceAccountParseError, databaseIntegrationTypes, databaseIntegrationTypesWithSslSupport, databaseMetadataSchemasByType, getEnvironmentVariablesForIntegrations, getSqlAlchemyInput, isFederatedAuthMetadata, isFederatedAuthMethod, sqlIntegrationTypes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepnote/database-integrations",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Deepnote database integration definitions",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -26,17 +26,17 @@
|
|
|
26
26
|
"LICENSE",
|
|
27
27
|
"package.json"
|
|
28
28
|
],
|
|
29
|
-
"scripts": {
|
|
30
|
-
"build": "tsdown --format esm --format cjs --dts",
|
|
31
|
-
"test": "vitest",
|
|
32
|
-
"watch": "tsdown --watch --format esm --format cjs --dts"
|
|
33
|
-
},
|
|
34
29
|
"dependencies": {
|
|
35
30
|
"build-url-ts": "^6.1.7",
|
|
36
|
-
"zod": "
|
|
31
|
+
"zod": "3.25.76"
|
|
37
32
|
},
|
|
38
33
|
"publishConfig": {
|
|
39
34
|
"access": "public",
|
|
40
35
|
"registry": "https://registry.npmjs.org"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsdown --format esm --format cjs --dts",
|
|
39
|
+
"test": "vitest",
|
|
40
|
+
"watch": "tsdown --watch --format esm --format cjs --dts"
|
|
41
41
|
}
|
|
42
|
-
}
|
|
42
|
+
}
|