Skip to content

Commit

Permalink
Add ApiKeyCredentials to postCredentials and getCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
albandum committed Dec 11, 2024
1 parent c678d5f commit 25e599d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 2 additions & 1 deletion types/src/oauth/client/credentials.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LoggerInterface } from "../../shared/logger";
import { Result } from "../../shared/result";
import {
ApiKeyCredentials,
ConnectionCredentials,
CredentialsProvider,
OauthAPIGetCredentialsResponse,
Expand All @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions types/src/oauth/lib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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({
Expand All @@ -101,6 +106,6 @@ export type OauthAPIGetCredentialsResponse = {
workspace_id: string;
user_id: string;
};
content: ConnectionCredentials;
content: ConnectionCredentials | ApiKeyCredentials;
};
};
3 changes: 2 additions & 1 deletion types/src/oauth/oauth_api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ApiKeyCredentials,
ConnectionCredentials,
CredentialsProvider,
OauthAPIGetCredentialsResponse,
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 25e599d

Please sign in to comment.