From 6ce45eee6b13b8c9577b79f89ccc745b32ab12da Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Fri, 3 Nov 2023 00:31:41 -0700 Subject: [PATCH] chore: Improve airbyte sdk ergonomics --- packages/airbyte/airbyte-sdk.ts | 41 +++++++++++++++------------------ 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/packages/airbyte/airbyte-sdk.ts b/packages/airbyte/airbyte-sdk.ts index 8287ca1f..de1d5c90 100644 --- a/packages/airbyte/airbyte-sdk.ts +++ b/packages/airbyte/airbyte-sdk.ts @@ -9,39 +9,34 @@ import type {paths as streams} from './api/airbyte-api-streams.gen' import type {paths as workspaces} from './api/airbyte-api-workspaces.gen' import type {paths as internal} from './api/airbyte-private-api.gen' -interface PublicPaths { - connections: connections - destinations: destinations - jobs: jobs - sources: sources - streams: streams - workspaces: workspaces -} - -interface PrivatePaths { - health: health - internal: internal -} - export interface AirbyteSDKOptions { accessToken: string } -export function AirbytePublicSDK( - opts: AirbyteSDKOptions, -) { - return createClient({ +export function AirbytePublicSDK(opts: AirbyteSDKOptions) { + const client = createClient({ baseUrl: 'https://api.airbyte.com/v1', headers: {Authorization: `Bearer ${opts.accessToken}`}, }) + return { + ...client, + connections: client as ReturnType>, + destinations: client as ReturnType>, + jobs: client as ReturnType>, + sources: client as ReturnType>, + streams: client as ReturnType>, + workspaces: client as ReturnType>, + } } -export function AirbytePrivateSDK( - opts: AirbyteSDKOptions, -) { - return createClient({ - // TODO: Figure out the right path to the private api +export function AirbytePrivateSDK(opts: AirbyteSDKOptions) { + const client = createClient({ baseUrl: 'https://api.airbyte.com', headers: {Authorization: `Bearer ${opts.accessToken}`}, }) + return { + ...client, + health: client as ReturnType>, + internal: client as ReturnType>, + } }