diff --git a/types/src/oauth/client/credentials.ts b/types/src/oauth/client/credentials.ts index 71e4fe6b888e..f377ab30961e 100644 --- a/types/src/oauth/client/credentials.ts +++ b/types/src/oauth/client/credentials.ts @@ -1,6 +1,7 @@ import { LoggerInterface } from "../../shared/logger"; import { Result } from "../../shared/result"; import { + ApiKeyCredentials, ConnectionCredentials, CredentialsProvider, OauthAPIGetCredentialsResponse, @@ -21,7 +22,7 @@ export async function postConnectionCredentials({ provider: CredentialsProvider; workspaceId: string; userId: string; - credentials: ConnectionCredentials; + credentials: ConnectionCredentials | ApiKeyCredentials; }): Promise<Result<OauthAPIPostCredentialsResponse, OAuthAPIError>> { const res = await new OAuthAPI(config, logger).postCredentials({ provider, diff --git a/types/src/oauth/lib.ts b/types/src/oauth/lib.ts index c133db1e32a3..dee9afd9ab6f 100644 --- a/types/src/oauth/lib.ts +++ b/types/src/oauth/lib.ts @@ -56,7 +56,7 @@ export function isValidZendeskSubdomain(s: unknown): s is string { // Credentials Providers -export const CREDENTIALS_PROVIDERS = ["snowflake"] as const; +export const CREDENTIALS_PROVIDERS = ["snowflake", "modjo"] as const; export type CredentialsProvider = (typeof CREDENTIALS_PROVIDERS)[number]; export function isCredentialProvider(obj: unknown): obj is CredentialsProvider { @@ -75,6 +75,11 @@ export const SnowflakeCredentialsSchema = t.type({ export type SnowflakeCredentials = t.TypeOf<typeof SnowflakeCredentialsSchema>; export type ConnectionCredentials = SnowflakeCredentials; +export const ApiCredentialsSchema = t.type({ + apiKey: t.string, +}); +export type ApiKeyCredentials = t.TypeOf<typeof ApiCredentialsSchema>; + // POST Credentials export const PostSnowflakeCredentialsBodySchema = t.type({ @@ -101,6 +106,6 @@ export type OauthAPIGetCredentialsResponse = { workspace_id: string; user_id: string; }; - content: ConnectionCredentials; + content: ConnectionCredentials | ApiKeyCredentials; }; }; diff --git a/types/src/oauth/oauth_api.ts b/types/src/oauth/oauth_api.ts index 2aad77cb4dcc..f0d2eedb5632 100644 --- a/types/src/oauth/oauth_api.ts +++ b/types/src/oauth/oauth_api.ts @@ -1,4 +1,5 @@ import { + ApiKeyCredentials, ConnectionCredentials, CredentialsProvider, OauthAPIGetCredentialsResponse, @@ -152,7 +153,7 @@ export class OAuthAPI { provider: CredentialsProvider; userId: string; workspaceId: string; - credentials: ConnectionCredentials; + credentials: ConnectionCredentials | ApiKeyCredentials; }): Promise<OAuthAPIResponse<OauthAPIPostCredentialsResponse>> { const response = await this._fetchWithError(`${this._url}/credentials`, { method: "POST",