@@ -6,17 +6,13 @@ import { IAsyncDisposableRegistry } from '../../common/types';
66import { logger } from '../../logging' ;
77import { IIntegrationStorage } from './types' ;
88import { upgradeLegacyIntegrationConfig } from './legacyIntegrationConfigUtils' ;
9- import {
10- DatabaseIntegrationConfig ,
11- databaseIntegrationTypes ,
12- databaseMetadataSchemasByType
13- } from '@deepnote/database-integrations' ;
14- import { DATAFRAME_SQL_INTEGRATION_ID } from './integrationTypes' ;
9+ import { databaseIntegrationTypes , databaseMetadataSchemasByType } from '@deepnote/database-integrations' ;
10+ import { ConfigurableDatabaseIntegrationConfig , DATAFRAME_SQL_INTEGRATION_ID } from './integrationTypes' ;
1511
1612const INTEGRATION_SERVICE_NAME = 'deepnote-integrations' ;
1713
1814// NOTE: We need a way to upgrade existing configurations to the new format of deepnote/database-integrations.
19- type VersionedDatabaseIntegrationConfig = DatabaseIntegrationConfig & { version : 1 } ;
15+ type VersionedDatabaseIntegrationConfig = ConfigurableDatabaseIntegrationConfig & { version : 1 } ;
2016
2117function storeEncryptedIntegrationConfig (
2218 encryptedStorage : IEncryptedStorage ,
@@ -33,7 +29,7 @@ function storeEncryptedIntegrationConfig(
3329 */
3430@injectable ( )
3531export class IntegrationStorage implements IIntegrationStorage {
36- private readonly cache : Map < string , DatabaseIntegrationConfig > = new Map ( ) ;
32+ private readonly cache : Map < string , ConfigurableDatabaseIntegrationConfig > = new Map ( ) ;
3733
3834 private cacheLoaded = false ;
3935
@@ -52,15 +48,15 @@ export class IntegrationStorage implements IIntegrationStorage {
5248 /**
5349 * Get all stored integration configurations.
5450 */
55- async getAll ( ) : Promise < DatabaseIntegrationConfig [ ] > {
51+ async getAll ( ) : Promise < ConfigurableDatabaseIntegrationConfig [ ] > {
5652 await this . ensureCacheLoaded ( ) ;
5753 return Array . from ( this . cache . values ( ) ) ;
5854 }
5955
6056 /**
6157 * Get a specific integration configuration by ID
6258 */
63- async getIntegrationConfig ( integrationId : string ) : Promise < DatabaseIntegrationConfig | undefined > {
59+ async getIntegrationConfig ( integrationId : string ) : Promise < ConfigurableDatabaseIntegrationConfig | undefined > {
6460 await this . ensureCacheLoaded ( ) ;
6561 return this . cache . get ( integrationId ) ;
6662 }
@@ -73,15 +69,15 @@ export class IntegrationStorage implements IIntegrationStorage {
7369 async getProjectIntegrationConfig (
7470 _projectId : string ,
7571 integrationId : string
76- ) : Promise < DatabaseIntegrationConfig | undefined > {
72+ ) : Promise < ConfigurableDatabaseIntegrationConfig | undefined > {
7773 return this . getIntegrationConfig ( integrationId ) ;
7874 }
7975
8076 /**
8177 * Save or update an integration configuration
8278 */
83- async save ( config : DatabaseIntegrationConfig ) : Promise < void > {
84- if ( config . type === 'pandas-dataframe' || config . id === DATAFRAME_SQL_INTEGRATION_ID ) {
79+ async save ( config : ConfigurableDatabaseIntegrationConfig ) : Promise < void > {
80+ if ( ( config . type as string ) === 'pandas-dataframe' || config . id === DATAFRAME_SQL_INTEGRATION_ID ) {
8581 logger . warn ( `IntegrationStorage: Skipping save for internal DuckDB integration ${ config . id } ` ) ;
8682 return ;
8783 }
@@ -210,7 +206,7 @@ export class IntegrationStorage implements IIntegrationStorage {
210206 const config =
211207 databaseIntegrationTypes . includes ( rawConfig . type ) &&
212208 rawConfig . type !== 'pandas-dataframe'
213- ? ( rawConfig as DatabaseIntegrationConfig )
209+ ? ( rawConfig as ConfigurableDatabaseIntegrationConfig )
214210 : null ;
215211 const validMetadata = config
216212 ? databaseMetadataSchemasByType [ config . type ] . safeParse ( config . metadata ) . data
@@ -219,7 +215,7 @@ export class IntegrationStorage implements IIntegrationStorage {
219215 this . cache . set (
220216 id ,
221217 // NOTE: We must cast here because there is no union-wide schema parser at the moment.
222- { ...config , metadata : validMetadata } as DatabaseIntegrationConfig
218+ { ...config , metadata : validMetadata } as ConfigurableDatabaseIntegrationConfig
223219 ) ;
224220 } else {
225221 logger . warn ( `Invalid integration config for ${ id } , marking for deletion` ) ;
0 commit comments