@deepnote/database-integrations 1.3.0 → 1.3.2

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 CHANGED
@@ -145,9 +145,15 @@ const commonRedshiftMetadataSchema = zod.z.object({
145
145
  caCertificateName: zod.z.string().optional(),
146
146
  caCertificateText: zod.z.string().optional()
147
147
  });
148
- const redshiftMetadataSchema = zod.z.discriminatedUnion("authMethod", [
148
+ const redshiftMetadataSchema = zod.z.preprocess((data) => {
149
+ if (typeof data === "object" && data !== null && (!("authMethod" in data) || !data.authMethod)) return {
150
+ ...data,
151
+ authMethod: DatabaseAuthMethods.UsernameAndPassword
152
+ };
153
+ return data;
154
+ }, zod.z.union([
149
155
  commonRedshiftMetadataSchema.extend({
150
- authMethod: zod.z.literal(DatabaseAuthMethods.UsernameAndPassword),
156
+ authMethod: zod.z.literal(DatabaseAuthMethods.UsernameAndPassword).optional(),
151
157
  user: zod.z.string(),
152
158
  password: zod.z.string()
153
159
  }),
@@ -158,7 +164,7 @@ const redshiftMetadataSchema = zod.z.discriminatedUnion("authMethod", [
158
164
  roleNonce: zod.z.string()
159
165
  }),
160
166
  commonRedshiftMetadataSchema.extend({ authMethod: zod.z.literal(DatabaseAuthMethods.IndividualCredentials) })
161
- ]);
167
+ ]));
162
168
  const commonSnowflakeMetadataSchema = zod.z.object({
163
169
  accountName: zod.z.string(),
164
170
  warehouse: zod.z.string().optional(),
@@ -528,7 +534,7 @@ function getEnvVarForSqlCells(integration, params) {
528
534
  * https://github.com/deepnote/deepnote-toolkit/blob/main/deepnote_toolkit/sql/sql_execution.py#L321
529
535
  */
530
536
  function getSqlAlchemyInput(integration, params) {
531
- if (integration.federated_auth_method) return null;
537
+ if (integration.federated_auth_method != null && isFederatedAuthMethod(integration.federated_auth_method)) return null;
532
538
  switch (integration.type) {
533
539
  case "alloydb":
534
540
  case "pgsql": return getPostgresSqlAlchemyInput(integration.id, params.projectRootDirectory, integration.metadata);
@@ -628,6 +634,7 @@ const getPostgresSqlAlchemyInput = (integrationId, projectRootDirectory, { user,
628
634
  };
629
635
  };
630
636
  const getRedshiftSqlAlchemyInput = (integrationId, projectRootDirectory, metadata) => {
637
+ if (!metadata.authMethod) metadata.authMethod = DatabaseAuthMethods.UsernameAndPassword;
631
638
  if (isFederatedAuthMethod(metadata.authMethod)) return null;
632
639
  const portSuffix = metadata.port ? `:${metadata.port}` : "";
633
640
  const mode = getPostgresStyleMode(metadata.caCertificateName, metadata.sslEnabled);