Skip to content

Commit ccb2196

Browse files
committed
refactor: righten integration type mappings
1 parent 3533e26 commit ccb2196

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/notebooks/deepnote/integrations/integrationDetector.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ export class IntegrationDetector implements IIntegrationDetector {
5353
logger.debug(`IntegrationDetector: Found integration: ${integrationId} (${projectIntegration.type})`);
5454

5555
// Map the Deepnote integration type to our IntegrationType
56-
const integrationType = DEEPNOTE_TO_INTEGRATION_TYPE[projectIntegration.type];
56+
const integrationType =
57+
DEEPNOTE_TO_INTEGRATION_TYPE[projectIntegration.type as keyof typeof DEEPNOTE_TO_INTEGRATION_TYPE];
5758

5859
// Skip unknown integration types
5960
if (!integrationType) {

src/notebooks/deepnote/sqlCellStatusBarProvider.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,8 @@ export class SqlCellStatusBarProvider implements NotebookCellStatusBarItemProvid
334334
continue;
335335
}
336336

337-
const integrationType = DEEPNOTE_TO_INTEGRATION_TYPE[projectIntegration.type];
337+
const integrationType =
338+
DEEPNOTE_TO_INTEGRATION_TYPE[projectIntegration.type as keyof typeof DEEPNOTE_TO_INTEGRATION_TYPE];
338339
const typeLabel = integrationType ? this.getIntegrationTypeLabel(integrationType) : projectIntegration.type;
339340

340341
const item: LocalQuickPickItem = {

src/platform/notebooks/deepnote/integrationTypes.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ export enum IntegrationType {
1212
BigQuery = 'bigquery'
1313
}
1414

15-
/**
16-
* Map Deepnote integration type strings to our IntegrationType enum
17-
*/
18-
export const DEEPNOTE_TO_INTEGRATION_TYPE: { [type: string]: IntegrationType } = {
19-
pgsql: IntegrationType.Postgres,
20-
'big-query': IntegrationType.BigQuery
21-
};
22-
2315
/**
2416
* Map our IntegrationType enum to Deepnote integration type strings
2517
*/
26-
export const INTEGRATION_TYPE_TO_DEEPNOTE: { [type in IntegrationType]: string } = {
18+
export const INTEGRATION_TYPE_TO_DEEPNOTE = {
2719
[IntegrationType.Postgres]: 'pgsql',
2820
[IntegrationType.BigQuery]: 'big-query'
21+
} as const satisfies { [type in IntegrationType]: string };
22+
23+
type RawIntegrationType = (typeof INTEGRATION_TYPE_TO_DEEPNOTE)[keyof typeof INTEGRATION_TYPE_TO_DEEPNOTE];
24+
25+
/**
26+
* Map Deepnote integration type strings to our IntegrationType enum
27+
*/
28+
export const DEEPNOTE_TO_INTEGRATION_TYPE: Record<RawIntegrationType, IntegrationType> = {
29+
pgsql: IntegrationType.Postgres,
30+
'big-query': IntegrationType.BigQuery
2931
};
3032

3133
/**

0 commit comments

Comments
 (0)