From b27f12f5a6c7b420c671a7edd9c7b9e78b73a0e2 Mon Sep 17 00:00:00 2001 From: Tony Xiao Date: Sun, 26 Nov 2023 02:30:45 -0800 Subject: [PATCH] chore: Fix up sdk --- kits/connect/package.json | 4 ++-- kits/sdk/index.ts | 10 +++++++++- kits/sdk/package.json | 6 +++--- pnpm-lock.yaml | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/kits/connect/package.json b/kits/connect/package.json index ced3598b..517a2058 100644 --- a/kits/connect/package.json +++ b/kits/connect/package.json @@ -1,6 +1,6 @@ { "name": "@usevenice/connect", - "version": "0.0.6", + "version": "0.1.4", "sideEffects": false, "main": "./dist/index.js", "module": "./dist/index.mjs", @@ -8,7 +8,7 @@ "scripts": { "build": "tsc -p ./tsconfig.json", "clean": "rm -rf ./dist", - "prepack": "pnpm run build" + "pub": "pnpm publish --no-git-checks" }, "dependencies": { "@usevenice/sdk": "workspace:*", diff --git a/kits/sdk/index.ts b/kits/sdk/index.ts index ad1faafc..ca0e6200 100644 --- a/kits/sdk/index.ts +++ b/kits/sdk/index.ts @@ -7,6 +7,10 @@ export interface VeniceClientOptions { apiKey?: string /** `reso_xxx` */ resourceId?: string + /** For end user authentication */ + accessToken?: string + /** For using things like self hosting and staging env */ + apiHost?: string } // This is necessary because we cannot publish inferred type otherwise @@ -19,11 +23,15 @@ export type VeniceClient = ReturnType> & { export function createVeniceClient(opts: VeniceClientOptions): VeniceClient { const client = createClient({ - baseUrl: 'https://app.venice.is/api/v0', + baseUrl: new URL( + '/api/v0', + opts.apiHost ?? 'https://app.venice.is', + ).toString(), headers: { // NOTE: Centralize reference to these headers ...(opts.apiKey && {'x-apikey': opts.apiKey}), ...(opts.resourceId && {'x-resource-id': opts.resourceId}), + ...(opts.accessToken && {Authorization: `Bearer ${opts.accessToken}`}), }, }) return {...client, oas} diff --git a/kits/sdk/package.json b/kits/sdk/package.json index fe4a8d3b..88131d4e 100644 --- a/kits/sdk/package.json +++ b/kits/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@usevenice/sdk", - "version": "0.0.0", + "version": "0.0.3", "private": false, "sideEffects": false, "module": "./index.ts", @@ -12,10 +12,10 @@ "pub": "pnpm publish --no-git-checks --access public" }, "dependencies": { - "@usevenice/openapi-client": "workspace:*", - "@usevenice/zod": "workspace:*" + "@usevenice/openapi-client": "workspace:*" }, "devDependencies": { + "@usevenice/zod": "workspace:*", "openapi-typescript": "7.0.0-next.3" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e60e200d..ed1010a0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1205,10 +1205,10 @@ importers: '@usevenice/openapi-client': specifier: workspace:* version: link:../../utils/openapi-client + devDependencies: '@usevenice/zod': specifier: workspace:* version: link:../../utils/zod - devDependencies: openapi-typescript: specifier: 7.0.0-next.3 version: 7.0.0-next.3