@deepnote/database-integrations 1.1.0 → 1.2.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/index.cjs +374 -221
- package/dist/index.d.cts +1761 -47
- package/dist/index.d.ts +1761 -47
- package/dist/index.js +368 -220
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { z } from "zod";
|
|
1
|
+
import z$1, { z } from "zod";
|
|
3
2
|
|
|
4
3
|
//#region src/sql-integration-auth-methods.ts
|
|
5
4
|
const AwsAuthMethods = {
|
|
@@ -37,8 +36,345 @@ function isFederatedAuthMetadata(metadata) {
|
|
|
37
36
|
return isFederatedAuthMethod(metadata.authMethod);
|
|
38
37
|
}
|
|
39
38
|
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region src/database-integration-metadata-schemas.ts
|
|
41
|
+
const athenaMetadataSchema = z.object({
|
|
42
|
+
access_key_id: z.string(),
|
|
43
|
+
region: z.string(),
|
|
44
|
+
s3_output_path: z.string(),
|
|
45
|
+
secret_access_key: z.string(),
|
|
46
|
+
workgroup: z.string().optional()
|
|
47
|
+
});
|
|
48
|
+
const bigqueryMetadataSchema = z.discriminatedUnion("authMethod", [z.object({
|
|
49
|
+
authMethod: z.literal(BigQueryAuthMethods.ServiceAccount),
|
|
50
|
+
service_account: z.string()
|
|
51
|
+
}), z.object({
|
|
52
|
+
authMethod: z.literal(BigQueryAuthMethods.GoogleOauth),
|
|
53
|
+
project: z.string(),
|
|
54
|
+
clientId: z.string(),
|
|
55
|
+
clientSecret: z.string()
|
|
56
|
+
})]);
|
|
57
|
+
const clickhouseMetadataSchema = z.object({
|
|
58
|
+
host: z.string(),
|
|
59
|
+
user: z.string(),
|
|
60
|
+
password: z.string().optional(),
|
|
61
|
+
database: z.string(),
|
|
62
|
+
port: z.string().optional(),
|
|
63
|
+
sshEnabled: z.boolean().optional(),
|
|
64
|
+
sshHost: z.string().optional(),
|
|
65
|
+
sshPort: z.string().optional(),
|
|
66
|
+
sshUser: z.string().optional(),
|
|
67
|
+
sslEnabled: z.boolean().optional(),
|
|
68
|
+
caCertificateName: z.string().optional(),
|
|
69
|
+
caCertificateText: z.string().optional()
|
|
70
|
+
});
|
|
71
|
+
const databricksMetadataSchema = z.object({
|
|
72
|
+
host: z.string(),
|
|
73
|
+
httpPath: z.string(),
|
|
74
|
+
token: z.string(),
|
|
75
|
+
port: z.string(),
|
|
76
|
+
schema: z.string().optional(),
|
|
77
|
+
catalog: z.string().optional(),
|
|
78
|
+
sshEnabled: z.boolean().optional(),
|
|
79
|
+
sshHost: z.string().optional(),
|
|
80
|
+
sshPort: z.string().optional(),
|
|
81
|
+
sshUser: z.string().optional()
|
|
82
|
+
});
|
|
83
|
+
const dremioMetadataSchema = z.object({
|
|
84
|
+
schema: z.string(),
|
|
85
|
+
host: z.string(),
|
|
86
|
+
port: z.string(),
|
|
87
|
+
token: z.string(),
|
|
88
|
+
sshEnabled: z.boolean().optional(),
|
|
89
|
+
sshHost: z.string().optional(),
|
|
90
|
+
sshPort: z.string().optional(),
|
|
91
|
+
sshUser: z.string().optional()
|
|
92
|
+
});
|
|
93
|
+
const mongodbMetadataSchema = z.object({
|
|
94
|
+
connection_string: z.string(),
|
|
95
|
+
rawConnectionString: z.string().optional(),
|
|
96
|
+
prefix: z.string().optional(),
|
|
97
|
+
host: z.string().optional(),
|
|
98
|
+
port: z.string().optional(),
|
|
99
|
+
user: z.string().optional(),
|
|
100
|
+
password: z.string().optional(),
|
|
101
|
+
database: z.string().optional(),
|
|
102
|
+
options: z.string().optional(),
|
|
103
|
+
sshEnabled: z.boolean().optional(),
|
|
104
|
+
sshHost: z.string().optional(),
|
|
105
|
+
sshPort: z.string().optional(),
|
|
106
|
+
sshUser: z.string().optional(),
|
|
107
|
+
sslEnabled: z.boolean().optional(),
|
|
108
|
+
caCertificateName: z.string().optional(),
|
|
109
|
+
caCertificateText: z.string().optional()
|
|
110
|
+
});
|
|
111
|
+
const pandasDataframeMetadataSchema = z.object({});
|
|
112
|
+
const commonRedshiftMetadataSchema = z.object({
|
|
113
|
+
database: z.string(),
|
|
114
|
+
host: z.string(),
|
|
115
|
+
port: z.string().optional(),
|
|
116
|
+
sshEnabled: z.boolean().optional(),
|
|
117
|
+
sshHost: z.string().optional(),
|
|
118
|
+
sshPort: z.string().optional(),
|
|
119
|
+
sshUser: z.string().optional(),
|
|
120
|
+
sslEnabled: z.boolean().optional(),
|
|
121
|
+
caCertificateName: z.string().optional(),
|
|
122
|
+
caCertificateText: z.string().optional()
|
|
123
|
+
});
|
|
124
|
+
const redshiftMetadataSchema = z.discriminatedUnion("authMethod", [
|
|
125
|
+
commonRedshiftMetadataSchema.extend({
|
|
126
|
+
authMethod: z.literal(DatabaseAuthMethods.UsernameAndPassword),
|
|
127
|
+
user: z.string(),
|
|
128
|
+
password: z.string()
|
|
129
|
+
}),
|
|
130
|
+
commonRedshiftMetadataSchema.extend({
|
|
131
|
+
authMethod: z.literal(AwsAuthMethods.IamRole),
|
|
132
|
+
roleArn: z.string(),
|
|
133
|
+
roleExternalId: z.string(),
|
|
134
|
+
roleNonce: z.string()
|
|
135
|
+
}),
|
|
136
|
+
commonRedshiftMetadataSchema.extend({ authMethod: z.literal(DatabaseAuthMethods.IndividualCredentials) })
|
|
137
|
+
]);
|
|
138
|
+
const commonSnowflakeMetadataSchema = z.object({
|
|
139
|
+
accountName: z.string(),
|
|
140
|
+
warehouse: z.string().optional(),
|
|
141
|
+
database: z.string().optional(),
|
|
142
|
+
role: z.string().optional()
|
|
143
|
+
});
|
|
144
|
+
const snowflakeMetadataSchema = z.discriminatedUnion("authMethod", [
|
|
145
|
+
commonSnowflakeMetadataSchema.extend({
|
|
146
|
+
authMethod: z.literal(SnowflakeAuthMethods.Password),
|
|
147
|
+
username: z.string(),
|
|
148
|
+
password: z.string()
|
|
149
|
+
}),
|
|
150
|
+
commonSnowflakeMetadataSchema.extend({
|
|
151
|
+
authMethod: z.literal(SnowflakeAuthMethods.Okta),
|
|
152
|
+
clientId: z.string(),
|
|
153
|
+
clientSecret: z.string(),
|
|
154
|
+
oktaSubdomain: z.string(),
|
|
155
|
+
identityProvider: z.string(),
|
|
156
|
+
authorizationServer: z.string()
|
|
157
|
+
}),
|
|
158
|
+
commonSnowflakeMetadataSchema.extend({
|
|
159
|
+
authMethod: z.literal(SnowflakeAuthMethods.NativeSnowflake),
|
|
160
|
+
clientId: z.string(),
|
|
161
|
+
clientSecret: z.string()
|
|
162
|
+
}),
|
|
163
|
+
commonSnowflakeMetadataSchema.extend({
|
|
164
|
+
authMethod: z.literal(SnowflakeAuthMethods.AzureAd),
|
|
165
|
+
clientId: z.string(),
|
|
166
|
+
clientSecret: z.string(),
|
|
167
|
+
resource: z.string(),
|
|
168
|
+
tenant: z.string()
|
|
169
|
+
}),
|
|
170
|
+
commonSnowflakeMetadataSchema.extend({ authMethod: z.literal(SnowflakeAuthMethods.KeyPair) }),
|
|
171
|
+
commonSnowflakeMetadataSchema.extend({
|
|
172
|
+
authMethod: z.literal(SnowflakeAuthMethods.ServiceAccountKeyPair),
|
|
173
|
+
username: z.string(),
|
|
174
|
+
privateKey: z.string(),
|
|
175
|
+
privateKeyPassphrase: z.string().optional()
|
|
176
|
+
})
|
|
177
|
+
]);
|
|
178
|
+
const spannerMetadataSchema = z.object({
|
|
179
|
+
service_account: z.string(),
|
|
180
|
+
dataBoostEnabled: z.boolean(),
|
|
181
|
+
instance: z.string(),
|
|
182
|
+
database: z.string()
|
|
183
|
+
});
|
|
184
|
+
const trinoMetadataSchema = z.object({
|
|
185
|
+
host: z.string(),
|
|
186
|
+
user: z.string(),
|
|
187
|
+
password: z.string(),
|
|
188
|
+
database: z.string(),
|
|
189
|
+
port: z.string(),
|
|
190
|
+
sshEnabled: z.boolean().optional(),
|
|
191
|
+
sshHost: z.string().optional(),
|
|
192
|
+
sshPort: z.string().optional(),
|
|
193
|
+
sshUser: z.string().optional(),
|
|
194
|
+
sslEnabled: z.boolean().optional(),
|
|
195
|
+
caCertificateName: z.string().optional(),
|
|
196
|
+
caCertificateText: z.string().optional()
|
|
197
|
+
});
|
|
198
|
+
const commonDatabaseSchema = z.object({
|
|
199
|
+
host: z.string(),
|
|
200
|
+
user: z.string(),
|
|
201
|
+
password: z.string(),
|
|
202
|
+
database: z.string(),
|
|
203
|
+
sshEnabled: z.boolean().optional(),
|
|
204
|
+
sshHost: z.string().optional(),
|
|
205
|
+
sshPort: z.string().optional(),
|
|
206
|
+
sshUser: z.string().optional()
|
|
207
|
+
});
|
|
208
|
+
const alloydbMetadataSchema = commonDatabaseSchema.extend({
|
|
209
|
+
port: z.string().optional(),
|
|
210
|
+
sslEnabled: z.boolean().optional(),
|
|
211
|
+
caCertificateName: z.string().optional(),
|
|
212
|
+
caCertificateText: z.string().optional()
|
|
213
|
+
});
|
|
214
|
+
const mariadbMetadataSchema = commonDatabaseSchema.extend({
|
|
215
|
+
port: z.string().optional(),
|
|
216
|
+
sslEnabled: z.boolean().optional(),
|
|
217
|
+
caCertificateName: z.string().optional(),
|
|
218
|
+
caCertificateText: z.string().optional()
|
|
219
|
+
});
|
|
220
|
+
const mindsdbMetadataSchema = commonDatabaseSchema.extend({
|
|
221
|
+
port: z.string().optional(),
|
|
222
|
+
sslEnabled: z.boolean().optional(),
|
|
223
|
+
caCertificateName: z.string().optional(),
|
|
224
|
+
caCertificateText: z.string().optional()
|
|
225
|
+
});
|
|
226
|
+
const mysqlMetadataSchema = commonDatabaseSchema.extend({
|
|
227
|
+
port: z.string().optional(),
|
|
228
|
+
sslEnabled: z.boolean().optional(),
|
|
229
|
+
caCertificateName: z.string().optional(),
|
|
230
|
+
caCertificateText: z.string().optional()
|
|
231
|
+
});
|
|
232
|
+
const pgsqlMetadataSchema = commonDatabaseSchema.extend({
|
|
233
|
+
port: z.string().optional(),
|
|
234
|
+
sslEnabled: z.boolean().optional(),
|
|
235
|
+
caCertificateName: z.string().optional(),
|
|
236
|
+
caCertificateText: z.string().optional()
|
|
237
|
+
});
|
|
238
|
+
const materializeMetadataSchema = pgsqlMetadataSchema.extend({ cluster: z.string() });
|
|
239
|
+
const sqlServerMetadataSchema = commonDatabaseSchema.extend({ port: z.string() });
|
|
240
|
+
const databaseMetadataSchemasByType = {
|
|
241
|
+
"alloydb": alloydbMetadataSchema,
|
|
242
|
+
"athena": athenaMetadataSchema,
|
|
243
|
+
"big-query": bigqueryMetadataSchema,
|
|
244
|
+
"clickhouse": clickhouseMetadataSchema,
|
|
245
|
+
"databricks": databricksMetadataSchema,
|
|
246
|
+
"dremio": dremioMetadataSchema,
|
|
247
|
+
"mariadb": mariadbMetadataSchema,
|
|
248
|
+
"materialize": materializeMetadataSchema,
|
|
249
|
+
"mindsdb": mindsdbMetadataSchema,
|
|
250
|
+
"mongodb": mongodbMetadataSchema,
|
|
251
|
+
"mysql": mysqlMetadataSchema,
|
|
252
|
+
"pandas-dataframe": pandasDataframeMetadataSchema,
|
|
253
|
+
"pgsql": pgsqlMetadataSchema,
|
|
254
|
+
"redshift": redshiftMetadataSchema,
|
|
255
|
+
"snowflake": snowflakeMetadataSchema,
|
|
256
|
+
"spanner": spannerMetadataSchema,
|
|
257
|
+
"sql-server": sqlServerMetadataSchema,
|
|
258
|
+
"trino": trinoMetadataSchema
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
//#region src/database-integration-config.ts
|
|
263
|
+
const commonIntegrationConfig = z$1.object({
|
|
264
|
+
id: z$1.string(),
|
|
265
|
+
name: z$1.string()
|
|
266
|
+
});
|
|
267
|
+
const databaseIntegrationConfigSchema = z$1.discriminatedUnion("type", [
|
|
268
|
+
commonIntegrationConfig.extend({
|
|
269
|
+
type: z$1.literal("alloydb"),
|
|
270
|
+
metadata: databaseMetadataSchemasByType["alloydb"],
|
|
271
|
+
federated_auth_method: z$1.null().optional()
|
|
272
|
+
}),
|
|
273
|
+
commonIntegrationConfig.extend({
|
|
274
|
+
type: z$1.literal("athena"),
|
|
275
|
+
metadata: databaseMetadataSchemasByType["athena"],
|
|
276
|
+
federated_auth_method: z$1.null().optional()
|
|
277
|
+
}),
|
|
278
|
+
commonIntegrationConfig.extend({
|
|
279
|
+
type: z$1.literal("big-query"),
|
|
280
|
+
metadata: databaseMetadataSchemasByType["big-query"],
|
|
281
|
+
federated_auth_method: z$1.enum(["google-oauth"]).optional().nullable()
|
|
282
|
+
}),
|
|
283
|
+
commonIntegrationConfig.extend({
|
|
284
|
+
type: z$1.literal("clickhouse"),
|
|
285
|
+
metadata: databaseMetadataSchemasByType["clickhouse"],
|
|
286
|
+
federated_auth_method: z$1.null().optional()
|
|
287
|
+
}),
|
|
288
|
+
commonIntegrationConfig.extend({
|
|
289
|
+
type: z$1.literal("databricks"),
|
|
290
|
+
metadata: databaseMetadataSchemasByType["databricks"],
|
|
291
|
+
federated_auth_method: z$1.null().optional()
|
|
292
|
+
}),
|
|
293
|
+
commonIntegrationConfig.extend({
|
|
294
|
+
type: z$1.literal("dremio"),
|
|
295
|
+
metadata: databaseMetadataSchemasByType["dremio"],
|
|
296
|
+
federated_auth_method: z$1.null().optional()
|
|
297
|
+
}),
|
|
298
|
+
commonIntegrationConfig.extend({
|
|
299
|
+
type: z$1.literal("mariadb"),
|
|
300
|
+
metadata: databaseMetadataSchemasByType["mariadb"],
|
|
301
|
+
federated_auth_method: z$1.null().optional()
|
|
302
|
+
}),
|
|
303
|
+
commonIntegrationConfig.extend({
|
|
304
|
+
type: z$1.literal("materialize"),
|
|
305
|
+
metadata: databaseMetadataSchemasByType["materialize"],
|
|
306
|
+
federated_auth_method: z$1.null().optional()
|
|
307
|
+
}),
|
|
308
|
+
commonIntegrationConfig.extend({
|
|
309
|
+
type: z$1.literal("mindsdb"),
|
|
310
|
+
metadata: databaseMetadataSchemasByType["mindsdb"],
|
|
311
|
+
federated_auth_method: z$1.null().optional()
|
|
312
|
+
}),
|
|
313
|
+
commonIntegrationConfig.extend({
|
|
314
|
+
type: z$1.literal("mongodb"),
|
|
315
|
+
metadata: databaseMetadataSchemasByType["mongodb"],
|
|
316
|
+
federated_auth_method: z$1.null().optional()
|
|
317
|
+
}),
|
|
318
|
+
commonIntegrationConfig.extend({
|
|
319
|
+
type: z$1.literal("mysql"),
|
|
320
|
+
metadata: databaseMetadataSchemasByType["mysql"],
|
|
321
|
+
federated_auth_method: z$1.null().optional()
|
|
322
|
+
}),
|
|
323
|
+
commonIntegrationConfig.extend({
|
|
324
|
+
type: z$1.literal("pandas-dataframe"),
|
|
325
|
+
metadata: databaseMetadataSchemasByType["pandas-dataframe"],
|
|
326
|
+
federated_auth_method: z$1.null().optional()
|
|
327
|
+
}),
|
|
328
|
+
commonIntegrationConfig.extend({
|
|
329
|
+
type: z$1.literal("pgsql"),
|
|
330
|
+
metadata: databaseMetadataSchemasByType["pgsql"],
|
|
331
|
+
federated_auth_method: z$1.null().optional()
|
|
332
|
+
}),
|
|
333
|
+
commonIntegrationConfig.extend({
|
|
334
|
+
type: z$1.literal("redshift"),
|
|
335
|
+
metadata: databaseMetadataSchemasByType["redshift"],
|
|
336
|
+
federated_auth_method: z$1.enum(["individual-credentials"]).optional().nullable()
|
|
337
|
+
}),
|
|
338
|
+
commonIntegrationConfig.extend({
|
|
339
|
+
type: z$1.literal("snowflake"),
|
|
340
|
+
metadata: databaseMetadataSchemasByType["snowflake"],
|
|
341
|
+
federated_auth_method: z$1.enum([
|
|
342
|
+
"okta",
|
|
343
|
+
"snowflake",
|
|
344
|
+
"azure",
|
|
345
|
+
"key-pair"
|
|
346
|
+
]).optional().nullable()
|
|
347
|
+
}),
|
|
348
|
+
commonIntegrationConfig.extend({
|
|
349
|
+
type: z$1.literal("spanner"),
|
|
350
|
+
metadata: databaseMetadataSchemasByType["spanner"],
|
|
351
|
+
federated_auth_method: z$1.null().optional()
|
|
352
|
+
}),
|
|
353
|
+
commonIntegrationConfig.extend({
|
|
354
|
+
type: z$1.literal("sql-server"),
|
|
355
|
+
metadata: databaseMetadataSchemasByType["sql-server"],
|
|
356
|
+
federated_auth_method: z$1.null().optional()
|
|
357
|
+
}),
|
|
358
|
+
commonIntegrationConfig.extend({
|
|
359
|
+
type: z$1.literal("trino"),
|
|
360
|
+
metadata: databaseMetadataSchemasByType["trino"],
|
|
361
|
+
federated_auth_method: z$1.null().optional()
|
|
362
|
+
})
|
|
363
|
+
]);
|
|
364
|
+
|
|
40
365
|
//#endregion
|
|
41
366
|
//#region src/snowflake-integration-env-vars.ts
|
|
367
|
+
/**
|
|
368
|
+
* Build a URL with path and query parameters using native URL API
|
|
369
|
+
*/
|
|
370
|
+
function buildUrl(baseUrl, options) {
|
|
371
|
+
const url = new URL(baseUrl.replace(/^(\w+):\/\//, "http://"));
|
|
372
|
+
if (options.path) url.pathname = options.path;
|
|
373
|
+
if (options.queryParams) {
|
|
374
|
+
for (const [key, value] of Object.entries(options.queryParams)) if (value !== void 0) url.searchParams.set(key, value);
|
|
375
|
+
}
|
|
376
|
+
return url.href.replace(/^http:\/\//, baseUrl.match(/^(\w+):\/\//)?.[0] || "http://");
|
|
377
|
+
}
|
|
42
378
|
function getSnowflakeSqlAlchemyInput(metadata, params) {
|
|
43
379
|
if (isFederatedAuthMetadata(metadata)) return null;
|
|
44
380
|
const { username, accountName, database, authMethod } = metadata;
|
|
@@ -58,6 +394,22 @@ function getSnowflakeSqlAlchemyInput(metadata, params) {
|
|
|
58
394
|
queryParams: { ...createBaseQueryParams(metadata, params.snowflakePartnerIdentifier) }
|
|
59
395
|
}));
|
|
60
396
|
}
|
|
397
|
+
function getSnowflakeFederatedAuthSqlAlchemyInput(metadata, options = {}) {
|
|
398
|
+
return createSqlAlchemyInputFromUrl(buildSnowflakeUrlForFederatedAuth(metadata, options), options.keyPair);
|
|
399
|
+
}
|
|
400
|
+
function buildSnowflakeUrlForFederatedAuth(metadata, options) {
|
|
401
|
+
const queryParams = { ...createBaseQueryParams(metadata, options.snowflakePartnerIdentifier) };
|
|
402
|
+
if (options.role) queryParams.role = options.role;
|
|
403
|
+
if (options.accessToken) {
|
|
404
|
+
queryParams.token = options.accessToken;
|
|
405
|
+
queryParams.authenticator = "oauth";
|
|
406
|
+
}
|
|
407
|
+
const accountIdentifier = metadata.accountName.replace(".privatelink", "");
|
|
408
|
+
return buildUrl(options.keyPair?.username ? `snowflake://${encodeURIComponent(options.keyPair.username)}@${encodeURIComponent(accountIdentifier)}` : `snowflake://:@${encodeURIComponent(accountIdentifier)}`, {
|
|
409
|
+
path: metadata.database,
|
|
410
|
+
queryParams
|
|
411
|
+
});
|
|
412
|
+
}
|
|
61
413
|
function createBaseQueryParams(metadata, snowflakePartnerIdentifier) {
|
|
62
414
|
return {
|
|
63
415
|
warehouse: metadata.warehouse,
|
|
@@ -83,7 +435,9 @@ function getEnvironmentVariablesForIntegrations(integrations, params) {
|
|
|
83
435
|
const errors = [];
|
|
84
436
|
integrations.forEach((integration) => {
|
|
85
437
|
const namePrefix = convertToEnvironmentVariableName(integration.name);
|
|
86
|
-
const envVarsForThisIntegration = Object.entries(integration.metadata).
|
|
438
|
+
const envVarsForThisIntegration = Object.entries(integration.metadata).filter(([key]) => {
|
|
439
|
+
return key !== "caCertificateText";
|
|
440
|
+
}).map(([key, rawValue]) => {
|
|
87
441
|
const name = `${namePrefix}_${key.toUpperCase()}`;
|
|
88
442
|
const value = String(rawValue);
|
|
89
443
|
if (integration.type === "mongodb" && integration.metadata.sslEnabled && key === "connection_string") return {
|
|
@@ -435,222 +789,6 @@ function assertNever(value) {
|
|
|
435
789
|
throw new Error(`Unexpected value: ${value}`);
|
|
436
790
|
}
|
|
437
791
|
|
|
438
|
-
//#endregion
|
|
439
|
-
//#region src/database-integration-metadata-schemas.ts
|
|
440
|
-
const athenaMetadataSchema = z.object({
|
|
441
|
-
access_key_id: z.string(),
|
|
442
|
-
region: z.string(),
|
|
443
|
-
s3_output_path: z.string(),
|
|
444
|
-
secret_access_key: z.string(),
|
|
445
|
-
workgroup: z.string().optional()
|
|
446
|
-
});
|
|
447
|
-
const bigqueryMetadataSchema = z.discriminatedUnion("authMethod", [z.object({
|
|
448
|
-
authMethod: z.literal(BigQueryAuthMethods.ServiceAccount),
|
|
449
|
-
service_account: z.string()
|
|
450
|
-
}), z.object({
|
|
451
|
-
authMethod: z.literal(BigQueryAuthMethods.GoogleOauth),
|
|
452
|
-
project: z.string(),
|
|
453
|
-
clientId: z.string(),
|
|
454
|
-
clientSecret: z.string()
|
|
455
|
-
})]);
|
|
456
|
-
const clickhouseMetadataSchema = z.object({
|
|
457
|
-
host: z.string(),
|
|
458
|
-
user: z.string(),
|
|
459
|
-
password: z.string().optional(),
|
|
460
|
-
database: z.string(),
|
|
461
|
-
port: z.string().optional(),
|
|
462
|
-
sshEnabled: z.boolean().optional(),
|
|
463
|
-
sshHost: z.string().optional(),
|
|
464
|
-
sshPort: z.string().optional(),
|
|
465
|
-
sshUser: z.string().optional(),
|
|
466
|
-
sslEnabled: z.boolean().optional(),
|
|
467
|
-
caCertificateName: z.string().optional(),
|
|
468
|
-
caCertificateText: z.string().optional()
|
|
469
|
-
});
|
|
470
|
-
const databricksMetadataSchema = z.object({
|
|
471
|
-
host: z.string(),
|
|
472
|
-
httpPath: z.string(),
|
|
473
|
-
token: z.string(),
|
|
474
|
-
port: z.string(),
|
|
475
|
-
schema: z.string().optional(),
|
|
476
|
-
catalog: z.string().optional(),
|
|
477
|
-
sshEnabled: z.boolean().optional(),
|
|
478
|
-
sshHost: z.string().optional(),
|
|
479
|
-
sshPort: z.string().optional(),
|
|
480
|
-
sshUser: z.string().optional()
|
|
481
|
-
});
|
|
482
|
-
const dremioMetadataSchema = z.object({
|
|
483
|
-
schema: z.string(),
|
|
484
|
-
host: z.string(),
|
|
485
|
-
port: z.string(),
|
|
486
|
-
token: z.string(),
|
|
487
|
-
sshEnabled: z.boolean().optional(),
|
|
488
|
-
sshHost: z.string().optional(),
|
|
489
|
-
sshPort: z.string().optional(),
|
|
490
|
-
sshUser: z.string().optional()
|
|
491
|
-
});
|
|
492
|
-
const mongodbMetadataSchema = z.object({
|
|
493
|
-
connection_string: z.string(),
|
|
494
|
-
rawConnectionString: z.string().optional(),
|
|
495
|
-
prefix: z.string().optional(),
|
|
496
|
-
host: z.string().optional(),
|
|
497
|
-
port: z.string().optional(),
|
|
498
|
-
user: z.string().optional(),
|
|
499
|
-
password: z.string().optional(),
|
|
500
|
-
database: z.string().optional(),
|
|
501
|
-
options: z.string().optional(),
|
|
502
|
-
sshEnabled: z.boolean().optional(),
|
|
503
|
-
sshHost: z.string().optional(),
|
|
504
|
-
sshPort: z.string().optional(),
|
|
505
|
-
sshUser: z.string().optional(),
|
|
506
|
-
sslEnabled: z.boolean().optional(),
|
|
507
|
-
caCertificateName: z.string().optional(),
|
|
508
|
-
caCertificateText: z.string().optional()
|
|
509
|
-
});
|
|
510
|
-
const pandasDataframeMetadataSchema = z.object({});
|
|
511
|
-
const commonRedshiftMetadataSchema = z.object({
|
|
512
|
-
database: z.string(),
|
|
513
|
-
host: z.string(),
|
|
514
|
-
port: z.string().optional(),
|
|
515
|
-
sshEnabled: z.boolean().optional(),
|
|
516
|
-
sshHost: z.string().optional(),
|
|
517
|
-
sshPort: z.string().optional(),
|
|
518
|
-
sshUser: z.string().optional(),
|
|
519
|
-
sslEnabled: z.boolean().optional(),
|
|
520
|
-
caCertificateName: z.string().optional(),
|
|
521
|
-
caCertificateText: z.string().optional()
|
|
522
|
-
});
|
|
523
|
-
const redshiftMetadataSchema = z.discriminatedUnion("authMethod", [
|
|
524
|
-
commonRedshiftMetadataSchema.extend({
|
|
525
|
-
authMethod: z.literal(DatabaseAuthMethods.UsernameAndPassword),
|
|
526
|
-
user: z.string(),
|
|
527
|
-
password: z.string()
|
|
528
|
-
}),
|
|
529
|
-
commonRedshiftMetadataSchema.extend({
|
|
530
|
-
authMethod: z.literal(AwsAuthMethods.IamRole),
|
|
531
|
-
roleArn: z.string(),
|
|
532
|
-
roleExternalId: z.string(),
|
|
533
|
-
roleNonce: z.string()
|
|
534
|
-
}),
|
|
535
|
-
commonRedshiftMetadataSchema.extend({ authMethod: z.literal(DatabaseAuthMethods.IndividualCredentials) })
|
|
536
|
-
]);
|
|
537
|
-
const commonSnowflakeMetadataSchema = z.object({
|
|
538
|
-
accountName: z.string(),
|
|
539
|
-
warehouse: z.string().optional(),
|
|
540
|
-
database: z.string().optional(),
|
|
541
|
-
role: z.string().optional()
|
|
542
|
-
});
|
|
543
|
-
const snowflakeMetadataSchema = z.discriminatedUnion("authMethod", [
|
|
544
|
-
commonSnowflakeMetadataSchema.extend({
|
|
545
|
-
authMethod: z.literal(SnowflakeAuthMethods.Password),
|
|
546
|
-
username: z.string(),
|
|
547
|
-
password: z.string()
|
|
548
|
-
}),
|
|
549
|
-
commonSnowflakeMetadataSchema.extend({
|
|
550
|
-
authMethod: z.literal(SnowflakeAuthMethods.Okta),
|
|
551
|
-
clientId: z.string(),
|
|
552
|
-
clientSecret: z.string(),
|
|
553
|
-
oktaSubdomain: z.string(),
|
|
554
|
-
identityProvider: z.string(),
|
|
555
|
-
authorizationServer: z.string()
|
|
556
|
-
}),
|
|
557
|
-
commonSnowflakeMetadataSchema.extend({
|
|
558
|
-
authMethod: z.literal(SnowflakeAuthMethods.NativeSnowflake),
|
|
559
|
-
clientId: z.string(),
|
|
560
|
-
clientSecret: z.string()
|
|
561
|
-
}),
|
|
562
|
-
commonSnowflakeMetadataSchema.extend({
|
|
563
|
-
authMethod: z.literal(SnowflakeAuthMethods.AzureAd),
|
|
564
|
-
clientId: z.string(),
|
|
565
|
-
clientSecret: z.string(),
|
|
566
|
-
resource: z.string(),
|
|
567
|
-
tenant: z.string()
|
|
568
|
-
}),
|
|
569
|
-
commonSnowflakeMetadataSchema.extend({ authMethod: z.literal(SnowflakeAuthMethods.KeyPair) }),
|
|
570
|
-
commonSnowflakeMetadataSchema.extend({
|
|
571
|
-
authMethod: z.literal(SnowflakeAuthMethods.ServiceAccountKeyPair),
|
|
572
|
-
username: z.string(),
|
|
573
|
-
privateKey: z.string(),
|
|
574
|
-
privateKeyPassphrase: z.string().optional()
|
|
575
|
-
})
|
|
576
|
-
]);
|
|
577
|
-
const spannerMetadataSchema = z.object({
|
|
578
|
-
service_account: z.string(),
|
|
579
|
-
dataBoostEnabled: z.boolean(),
|
|
580
|
-
instance: z.string(),
|
|
581
|
-
database: z.string()
|
|
582
|
-
});
|
|
583
|
-
const trinoMetadataSchema = z.object({
|
|
584
|
-
host: z.string(),
|
|
585
|
-
user: z.string(),
|
|
586
|
-
password: z.string(),
|
|
587
|
-
database: z.string(),
|
|
588
|
-
port: z.string(),
|
|
589
|
-
sshEnabled: z.boolean().optional(),
|
|
590
|
-
sshHost: z.string().optional(),
|
|
591
|
-
sshPort: z.string().optional(),
|
|
592
|
-
sshUser: z.string().optional(),
|
|
593
|
-
sslEnabled: z.boolean().optional(),
|
|
594
|
-
caCertificateName: z.string().optional(),
|
|
595
|
-
caCertificateText: z.string().optional()
|
|
596
|
-
});
|
|
597
|
-
const commonDatabaseSchema = z.object({
|
|
598
|
-
host: z.string(),
|
|
599
|
-
user: z.string(),
|
|
600
|
-
password: z.string(),
|
|
601
|
-
database: z.string(),
|
|
602
|
-
sshEnabled: z.boolean().optional(),
|
|
603
|
-
sshHost: z.string().optional(),
|
|
604
|
-
sshPort: z.string().optional(),
|
|
605
|
-
sshUser: z.string().optional()
|
|
606
|
-
});
|
|
607
|
-
const alloydbMetadataSchema = commonDatabaseSchema.extend({
|
|
608
|
-
port: z.string().optional(),
|
|
609
|
-
sslEnabled: z.boolean().optional(),
|
|
610
|
-
caCertificateName: z.string().optional(),
|
|
611
|
-
caCertificateText: z.string().optional()
|
|
612
|
-
});
|
|
613
|
-
const mariadbMetadataSchema = commonDatabaseSchema.extend({
|
|
614
|
-
port: z.string().optional(),
|
|
615
|
-
caCertificateName: z.string().optional()
|
|
616
|
-
});
|
|
617
|
-
const mindsdbMetadataSchema = commonDatabaseSchema.extend({
|
|
618
|
-
port: z.string().optional(),
|
|
619
|
-
caCertificateName: z.string().optional()
|
|
620
|
-
});
|
|
621
|
-
const mysqlMetadataSchema = commonDatabaseSchema.extend({
|
|
622
|
-
port: z.string().optional(),
|
|
623
|
-
caCertificateName: z.string().optional()
|
|
624
|
-
});
|
|
625
|
-
const pgsqlMetadataSchema = commonDatabaseSchema.extend({
|
|
626
|
-
port: z.string().optional(),
|
|
627
|
-
sslEnabled: z.boolean().optional(),
|
|
628
|
-
caCertificateName: z.string().optional(),
|
|
629
|
-
caCertificateText: z.string().optional()
|
|
630
|
-
});
|
|
631
|
-
const materializeMetadataSchema = pgsqlMetadataSchema.extend({ cluster: z.string() });
|
|
632
|
-
const sqlServerMetadataSchema = commonDatabaseSchema.extend({ port: z.string() });
|
|
633
|
-
const databaseMetadataSchemasByType = {
|
|
634
|
-
"alloydb": alloydbMetadataSchema,
|
|
635
|
-
"athena": athenaMetadataSchema,
|
|
636
|
-
"big-query": bigqueryMetadataSchema,
|
|
637
|
-
"clickhouse": clickhouseMetadataSchema,
|
|
638
|
-
"databricks": databricksMetadataSchema,
|
|
639
|
-
"dremio": dremioMetadataSchema,
|
|
640
|
-
"mariadb": mariadbMetadataSchema,
|
|
641
|
-
"materialize": materializeMetadataSchema,
|
|
642
|
-
"mindsdb": mindsdbMetadataSchema,
|
|
643
|
-
"mongodb": mongodbMetadataSchema,
|
|
644
|
-
"mysql": mysqlMetadataSchema,
|
|
645
|
-
"pandas-dataframe": pandasDataframeMetadataSchema,
|
|
646
|
-
"pgsql": pgsqlMetadataSchema,
|
|
647
|
-
"redshift": redshiftMetadataSchema,
|
|
648
|
-
"snowflake": snowflakeMetadataSchema,
|
|
649
|
-
"spanner": spannerMetadataSchema,
|
|
650
|
-
"sql-server": sqlServerMetadataSchema,
|
|
651
|
-
"trino": trinoMetadataSchema
|
|
652
|
-
};
|
|
653
|
-
|
|
654
792
|
//#endregion
|
|
655
793
|
//#region src/database-integration-types.ts
|
|
656
794
|
const sqlIntegrationTypes = [
|
|
@@ -674,6 +812,7 @@ const sqlIntegrationTypes = [
|
|
|
674
812
|
];
|
|
675
813
|
const databaseIntegrationTypes = [...sqlIntegrationTypes, "mongodb"];
|
|
676
814
|
const databaseIntegrationTypesWithSslSupport = [
|
|
815
|
+
"alloydb",
|
|
677
816
|
"clickhouse",
|
|
678
817
|
"dremio",
|
|
679
818
|
"mariadb",
|
|
@@ -684,6 +823,15 @@ const databaseIntegrationTypesWithSslSupport = [
|
|
|
684
823
|
"redshift",
|
|
685
824
|
"trino"
|
|
686
825
|
];
|
|
826
|
+
function isDatabaseIntegrationType(type) {
|
|
827
|
+
return databaseIntegrationTypes.includes(type);
|
|
828
|
+
}
|
|
829
|
+
function isSqlIntegrationType(type) {
|
|
830
|
+
return sqlIntegrationTypes.includes(type);
|
|
831
|
+
}
|
|
832
|
+
function isDatabaseIntegrationTypeWithSslSupport(type) {
|
|
833
|
+
return databaseIntegrationTypesWithSslSupport.includes(type);
|
|
834
|
+
}
|
|
687
835
|
|
|
688
836
|
//#endregion
|
|
689
|
-
export { AwsAuthMethods, BigQueryAuthMethods, BigQueryServiceAccountParseError, DatabaseAuthMethods, SnowflakeAuthMethods, SpannerServiceAccountParseError, databaseIntegrationTypes, databaseIntegrationTypesWithSslSupport, databaseMetadataSchemasByType, getEnvironmentVariablesForIntegrations, getSqlAlchemyInput, isFederatedAuthMetadata, isFederatedAuthMethod, sqlIntegrationTypes };
|
|
837
|
+
export { AwsAuthMethods, BigQueryAuthMethods, BigQueryServiceAccountParseError, DatabaseAuthMethods, SnowflakeAuthMethods, SpannerServiceAccountParseError, databaseIntegrationConfigSchema, databaseIntegrationTypes, databaseIntegrationTypesWithSslSupport, databaseMetadataSchemasByType, federatedAuthMethods, getEnvironmentVariablesForIntegrations, getSnowflakeFederatedAuthSqlAlchemyInput, getSqlAlchemyInput, isDatabaseIntegrationType, isDatabaseIntegrationTypeWithSslSupport, isFederatedAuthMetadata, isFederatedAuthMethod, isSqlIntegrationType, sqlIntegrationTypes };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deepnote/database-integrations",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Deepnote database integration definitions",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"repository": {
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"package.json"
|
|
28
28
|
],
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"build-url-ts": "^6.1.7",
|
|
31
30
|
"zod": "3.25.76"
|
|
32
31
|
},
|
|
33
32
|
"publishConfig": {
|