From b74edef1a541ab50596522de3f439f377c72a25b Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 11 Dec 2024 12:25:16 +1030 Subject: [PATCH] chore: Update sdk-react --- sdk-react/README.md | 6 +++--- sdk-react/demo/TestPage.tsx | 4 ++-- sdk-react/src/contract.ts | 8 ++------ sdk-react/src/createClient.ts | 6 +++--- sdk-react/src/hooks/useRun.ts | 2 +- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/sdk-react/README.md b/sdk-react/README.md index 1d3772cc..6d450f39 100644 --- a/sdk-react/README.md +++ b/sdk-react/README.md @@ -52,7 +52,7 @@ It can be used to interact with an existing run by specifying the `runId`: const { messages, run, createMessage, start } = useRun({ clusterId: 'your-cluster-id', apiSecret: 'your-api-secret', - authType: 'customer', // or 'cluster' + authType: 'custom', // or 'cluster' // pollInterval: 1000, // Optional: defaults to 1000ms }); @@ -70,7 +70,7 @@ It can be used to create a new run by specifying an `initialPrompt`: const { messages, run, createMessage, start } = useRun({ clusterId: 'your-cluster-id', apiSecret: 'your-api-secret', - authType: 'customer', // or 'cluster' + authType: 'custom', // or 'cluster' // pollInterval: 1000, // Optional: defaults to 1000ms }); @@ -99,7 +99,7 @@ You can handle errors by providing an `onError` callback: const { messages, run, createMessage } = useRun({ clusterId: 'your-cluster-id', apiSecret: 'your-api-secret', - authType: 'customer', // or 'cluster' + authType: 'custom', // or 'cluster' configId: 'your-config-id', onError: (error) => { console.error('Run error:', error); diff --git a/sdk-react/demo/TestPage.tsx b/sdk-react/demo/TestPage.tsx index 1baacb79..93d2bb6e 100644 --- a/sdk-react/demo/TestPage.tsx +++ b/sdk-react/demo/TestPage.tsx @@ -3,8 +3,8 @@ import { useRun } from '../src'; type TestPageProps = { baseUrl?: string; - customerProvidedSecret?: string; - apiSecret?: string; + apiSecret: string; + authType?: 'custom' | 'cluster'; clusterId: string; configId: string; initialPrompt?: string; diff --git a/sdk-react/src/contract.ts b/sdk-react/src/contract.ts index f8d3410a..a54080f7 100644 --- a/sdk-react/src/contract.ts +++ b/sdk-react/src/contract.ts @@ -340,7 +340,7 @@ export const definition = { .describe( "Enable additional logging (Including prompts and results) for use by Inferable support", ), - enableCustomerAuth: z.boolean().optional(), + enableCustomAuth: z.boolean().optional(), enableRunConfigs: z.boolean().optional(), enableKnowledgebase: z.boolean().optional(), }), @@ -359,7 +359,7 @@ export const definition = { additionalContext: VersionedTextsSchema.nullable(), createdAt: z.date(), debug: z.boolean(), - enableCustomerAuth: z.boolean(), + enableCustomAuth: z.boolean(), enableRunConfigs: z.boolean(), enableKnowledgebase: z.boolean(), lastPingAt: z.date().nullable(), @@ -1092,7 +1092,6 @@ export const definition = { attachedFunctions: z.array(z.string()), resultSchema: anyObject.nullable(), inputSchema: anyObject.nullable(), - public: z.boolean(), createdAt: z.date(), updatedAt: z.date(), versions: z.array( @@ -1104,7 +1103,6 @@ export const definition = { attachedFunctions: z.array(z.string()), resultSchema: anyObject.nullable(), inputSchema: anyObject.nullable(), - public: z.boolean(), }), ), }), @@ -1133,7 +1131,6 @@ export const definition = { attachedFunctions: z.array(z.string()).optional(), resultSchema: anyObject.optional(), inputSchema: z.object({}).passthrough().optional().nullable(), - public: z.boolean(), }), responses: { 201: z.object({ id: z.string() }), @@ -1161,7 +1158,6 @@ export const definition = { attachedFunctions: z.array(z.string()).optional(), resultSchema: z.object({}).passthrough().optional().nullable(), inputSchema: z.object({}).passthrough().optional().nullable(), - public: z.boolean(), }), responses: { 200: z.object({ diff --git a/sdk-react/src/createClient.ts b/sdk-react/src/createClient.ts index 51896aed..dc7fedee 100644 --- a/sdk-react/src/createClient.ts +++ b/sdk-react/src/createClient.ts @@ -12,11 +12,11 @@ export const createApiClient = ({ }: { baseUrl?: string; clientAbortController?: AbortController; - authType?: 'customer' | 'cluster'; + authType?: 'custom' | 'cluster'; apiSecret?: string }) => { - const baseHeaders = authType === 'customer' ? { - Authorization: `customer ${apiSecret}` + const baseHeaders = authType === 'custom' ? { + Authorization: `custom ${apiSecret}` } : { Authorization: `bearer ${apiSecret}` }; diff --git a/sdk-react/src/hooks/useRun.ts b/sdk-react/src/hooks/useRun.ts index eaf520f2..f0968060 100644 --- a/sdk-react/src/hooks/useRun.ts +++ b/sdk-react/src/hooks/useRun.ts @@ -7,7 +7,7 @@ import { ClientInferRequest, ClientInferResponseBody } from '@ts-rest/core'; type UseRunOptions = { clusterId: string; apiSecret: string; - authType?: 'customer' | 'cluster'; + authType?: 'custom' | 'cluster'; baseUrl?: string; pollInterval?: number; onError?: (error: Error) => void;