Skip to content

Commit

Permalink
chore: Print .data if exist in cli
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyxiao committed Nov 3, 2023
1 parent 03ced9f commit 7e8e59f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
6 changes: 5 additions & 1 deletion apps/cli/cli-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ export async function printResult(
})
} else {
console.log(res)
const out = opts?.json ? JSON.stringify(await res) : await res
let out = opts?.json ? JSON.stringify(await res) : await res
if (out && typeof out === 'object' && 'data' in out) {
out = out.data
}

if (opts?.minimal || process.env['SILENT']) {
// console.log('[printResult]')
process.stdout.write(`${out}\n`)
Expand Down
21 changes: 14 additions & 7 deletions packages/airbyte/airbyte-sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,39 @@ 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 paths {
interface PublicPaths {
connections: connections
destinations: destinations
health: health
jobs: jobs
sources: sources
streams: streams
workspaces: workspaces
}

interface PrivatePaths {
health: health
internal: internal
}

export interface AirbyteSDKOptions {
accessToken: string
}

export function AirbytePublicSDK<T extends keyof paths>(
export function AirbytePublicSDK<T extends keyof PublicPaths>(
opts: AirbyteSDKOptions,
) {
return createClient<paths[T]>({
baseUrl: 'https://api.airbyte.com',
return createClient<PublicPaths[T]>({
baseUrl: 'https://api.airbyte.com/v1',
headers: {Authorization: `Bearer ${opts.accessToken}`},
})
}

export function AirbytePrivateSDK() {
return createClient<internal>({
export function AirbytePrivateSDK<T extends keyof PrivatePaths>(
opts: AirbyteSDKOptions,
) {
return createClient<PrivatePaths[T]>({
// TODO: Figure out the right path to the private api
baseUrl: 'https://api.airbyte.com',
headers: {Authorization: `Bearer ${opts.accessToken}`},
})
}

0 comments on commit 7e8e59f

Please sign in to comment.