From b022dcba77fbc56ee017fa36d54e98b505b50de0 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 11 May 2023 10:58:50 +0200 Subject: [PATCH] Types --- packages/server/src/integrations/index.ts | 6 ++---- packages/server/src/integrations/postgres.ts | 2 +- .../server/src/sdk/tests/datasources/validators.spec.ts | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/server/src/integrations/index.ts b/packages/server/src/integrations/index.ts index 5a2271de25..076c9fdcb5 100644 --- a/packages/server/src/integrations/index.ts +++ b/packages/server/src/integrations/index.ts @@ -121,9 +121,7 @@ export async function getIntegration(integration: SourceName) { throw new Error("No datasource implementation found.") } -const VALIDATORS: Partial< - Record Promise> -> = { +const VALIDATORS = { [SourceName.POSTGRES]: postgres.validateConnection, } @@ -134,5 +132,5 @@ function getValidators(integration: SourceName) { export default { getDefinitions, getIntegration, - getValidators, + getValidator: VALIDATORS, } diff --git a/packages/server/src/integrations/postgres.ts b/packages/server/src/integrations/postgres.ts index c452b8afc7..da678854b4 100644 --- a/packages/server/src/integrations/postgres.ts +++ b/packages/server/src/integrations/postgres.ts @@ -31,7 +31,7 @@ if (types) { const JSON_REGEX = /'{.*}'::json/s -interface PostgresConfig { +export interface PostgresConfig { host: string port: number database: string diff --git a/packages/server/src/sdk/tests/datasources/validators.spec.ts b/packages/server/src/sdk/tests/datasources/validators.spec.ts index 677ff8b59c..9664c6c8fc 100644 --- a/packages/server/src/sdk/tests/datasources/validators.spec.ts +++ b/packages/server/src/sdk/tests/datasources/validators.spec.ts @@ -6,7 +6,7 @@ jest.unmock("pg") describe("datasource validators", () => { describe("postgres", () => { - const validator = integrations.getValidators(SourceName.POSTGRES)! + const validator = integrations.getValidator[SourceName.POSTGRES]! let host: string let port: number @@ -31,7 +31,6 @@ describe("datasource validators", () => { schema: "public", ssl: false, rejectUnauthorized: false, - ca: false, }) expect(result).toBeTruthy() }) @@ -46,7 +45,6 @@ describe("datasource validators", () => { schema: "public", ssl: false, rejectUnauthorized: false, - ca: false, }) expect(result).toEqual({ error: 'password authentication failed for user "wrong"',