@deepnote/database-integrations 1.3.1 → 1.3.3
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 +36 -8
- package/dist/index.d.cts +406 -102
- package/dist/index.d.ts +406 -102
- package/dist/index.js +36 -9
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,10 @@ const BigQueryAuthMethods = {
|
|
|
41
41
|
ServiceAccount: "service-account",
|
|
42
42
|
GoogleOauth: "google-oauth"
|
|
43
43
|
};
|
|
44
|
+
const TrinoAuthMethods = {
|
|
45
|
+
Password: "password",
|
|
46
|
+
Oauth: "oauth"
|
|
47
|
+
};
|
|
44
48
|
const DatabaseAuthMethods = {
|
|
45
49
|
UsernameAndPassword: "username-and-password",
|
|
46
50
|
IndividualCredentials: "individual-credentials"
|
|
@@ -51,7 +55,8 @@ const federatedAuthMethods = [
|
|
|
51
55
|
SnowflakeAuthMethods.AzureAd,
|
|
52
56
|
SnowflakeAuthMethods.KeyPair,
|
|
53
57
|
BigQueryAuthMethods.GoogleOauth,
|
|
54
|
-
DatabaseAuthMethods.IndividualCredentials
|
|
58
|
+
DatabaseAuthMethods.IndividualCredentials,
|
|
59
|
+
TrinoAuthMethods.Oauth
|
|
55
60
|
];
|
|
56
61
|
function isFederatedAuthMethod(authMethod) {
|
|
57
62
|
return federatedAuthMethods.includes(authMethod);
|
|
@@ -145,9 +150,15 @@ const commonRedshiftMetadataSchema = zod.z.object({
|
|
|
145
150
|
caCertificateName: zod.z.string().optional(),
|
|
146
151
|
caCertificateText: zod.z.string().optional()
|
|
147
152
|
});
|
|
148
|
-
const redshiftMetadataSchema = zod.z.
|
|
153
|
+
const redshiftMetadataSchema = zod.z.preprocess((data) => {
|
|
154
|
+
if (typeof data === "object" && data !== null && (!("authMethod" in data) || !data.authMethod)) return {
|
|
155
|
+
...data,
|
|
156
|
+
authMethod: DatabaseAuthMethods.UsernameAndPassword
|
|
157
|
+
};
|
|
158
|
+
return data;
|
|
159
|
+
}, zod.z.union([
|
|
149
160
|
commonRedshiftMetadataSchema.extend({
|
|
150
|
-
authMethod: zod.z.literal(DatabaseAuthMethods.UsernameAndPassword),
|
|
161
|
+
authMethod: zod.z.literal(DatabaseAuthMethods.UsernameAndPassword).optional(),
|
|
151
162
|
user: zod.z.string(),
|
|
152
163
|
password: zod.z.string()
|
|
153
164
|
}),
|
|
@@ -158,7 +169,7 @@ const redshiftMetadataSchema = zod.z.discriminatedUnion("authMethod", [
|
|
|
158
169
|
roleNonce: zod.z.string()
|
|
159
170
|
}),
|
|
160
171
|
commonRedshiftMetadataSchema.extend({ authMethod: zod.z.literal(DatabaseAuthMethods.IndividualCredentials) })
|
|
161
|
-
]);
|
|
172
|
+
]));
|
|
162
173
|
const commonSnowflakeMetadataSchema = zod.z.object({
|
|
163
174
|
accountName: zod.z.string(),
|
|
164
175
|
warehouse: zod.z.string().optional(),
|
|
@@ -205,12 +216,10 @@ const spannerMetadataSchema = zod.z.object({
|
|
|
205
216
|
instance: zod.z.string(),
|
|
206
217
|
database: zod.z.string()
|
|
207
218
|
});
|
|
208
|
-
const
|
|
219
|
+
const trinoBaseMetadataSchema = zod.z.object({
|
|
209
220
|
host: zod.z.string(),
|
|
210
|
-
|
|
211
|
-
password: zod.z.string(),
|
|
221
|
+
port: zod.z.string().optional(),
|
|
212
222
|
database: zod.z.string(),
|
|
213
|
-
port: zod.z.string(),
|
|
214
223
|
sshEnabled: zod.z.boolean().optional(),
|
|
215
224
|
sshHost: zod.z.string().optional(),
|
|
216
225
|
sshPort: zod.z.string().optional(),
|
|
@@ -219,6 +228,22 @@ const trinoMetadataSchema = zod.z.object({
|
|
|
219
228
|
caCertificateName: zod.z.string().optional(),
|
|
220
229
|
caCertificateText: zod.z.string().optional()
|
|
221
230
|
});
|
|
231
|
+
const trinoUsernamePasswordMetadataSchema = trinoBaseMetadataSchema.extend({
|
|
232
|
+
user: zod.z.string(),
|
|
233
|
+
password: zod.z.string()
|
|
234
|
+
});
|
|
235
|
+
const trinoOAuthMetadataSchema = trinoBaseMetadataSchema.extend({
|
|
236
|
+
authMethod: zod.z.literal(TrinoAuthMethods.Oauth),
|
|
237
|
+
clientId: zod.z.string(),
|
|
238
|
+
clientSecret: zod.z.string(),
|
|
239
|
+
authUrl: zod.z.string().url(),
|
|
240
|
+
tokenUrl: zod.z.string().url()
|
|
241
|
+
});
|
|
242
|
+
const trinoMetadataSchema = zod.z.discriminatedUnion("authMethod", [
|
|
243
|
+
trinoUsernamePasswordMetadataSchema.extend({ authMethod: zod.z.literal(null) }),
|
|
244
|
+
trinoUsernamePasswordMetadataSchema.extend({ authMethod: zod.z.literal(TrinoAuthMethods.Password) }),
|
|
245
|
+
trinoOAuthMetadataSchema
|
|
246
|
+
]);
|
|
222
247
|
const commonDatabaseSchema = zod.z.object({
|
|
223
248
|
host: zod.z.string(),
|
|
224
249
|
user: zod.z.string(),
|
|
@@ -628,6 +653,7 @@ const getPostgresSqlAlchemyInput = (integrationId, projectRootDirectory, { user,
|
|
|
628
653
|
};
|
|
629
654
|
};
|
|
630
655
|
const getRedshiftSqlAlchemyInput = (integrationId, projectRootDirectory, metadata) => {
|
|
656
|
+
if (!metadata.authMethod) metadata.authMethod = DatabaseAuthMethods.UsernameAndPassword;
|
|
631
657
|
if (isFederatedAuthMethod(metadata.authMethod)) return null;
|
|
632
658
|
const portSuffix = metadata.port ? `:${metadata.port}` : "";
|
|
633
659
|
const mode = getPostgresStyleMode(metadata.caCertificateName, metadata.sslEnabled);
|
|
@@ -688,6 +714,7 @@ const getMaterializePostgresSqlAlchemyInput = (integrationId, projectRootDirecto
|
|
|
688
714
|
};
|
|
689
715
|
};
|
|
690
716
|
const getTrinoEnvVars = (integrationId, metadata, projectRootDirectory) => {
|
|
717
|
+
if (metadata.authMethod === TrinoAuthMethods.Oauth) return null;
|
|
691
718
|
return {
|
|
692
719
|
url: `trino://${encodeURIComponent(metadata.user)}:${encodeURIComponent(metadata.password)}@${metadata.host}:${metadata.port}/${encodeURIComponent(metadata.database)}`,
|
|
693
720
|
params: { connect_args: {
|
|
@@ -870,6 +897,7 @@ exports.BigQueryServiceAccountParseError = BigQueryServiceAccountParseError;
|
|
|
870
897
|
exports.DatabaseAuthMethods = DatabaseAuthMethods;
|
|
871
898
|
exports.SnowflakeAuthMethods = SnowflakeAuthMethods;
|
|
872
899
|
exports.SpannerServiceAccountParseError = SpannerServiceAccountParseError;
|
|
900
|
+
exports.TrinoAuthMethods = TrinoAuthMethods;
|
|
873
901
|
exports.databaseIntegrationConfigSchema = databaseIntegrationConfigSchema;
|
|
874
902
|
exports.databaseIntegrationTypes = databaseIntegrationTypes;
|
|
875
903
|
exports.databaseIntegrationTypesWithSslSupport = databaseIntegrationTypesWithSslSupport;
|