diff --git a/src/index.ts b/src/index.ts index 65c0bc20..0976766d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from './core'; import * as Errors from './error'; -import { type Agent } from './_shims/index'; import * as Uploads from './uploads'; +import { type Agent } from './_shims/index'; +import * as Core from '@anthropic-ai/sdk/core'; import * as API from '@anthropic-ai/sdk/resources/index'; export interface ClientOptions { @@ -74,7 +74,9 @@ export interface ClientOptions { defaultQuery?: Core.DefaultQuery; } -/** API Client for interfacing with the Anthropic API. */ +/** + * API Client for interfacing with the Anthropic API. + */ export class Anthropic extends Core.APIClient { apiKey: string | null; authToken: string | null; @@ -114,6 +116,7 @@ export class Anthropic extends Core.APIClient { maxRetries: options.maxRetries, fetch: options.fetch, }); + this._options = options; this.apiKey = apiKey; diff --git a/src/resources/completions.ts b/src/resources/completions.ts index d8e810e2..fb3479a2 100644 --- a/src/resources/completions.ts +++ b/src/resources/completions.ts @@ -1,8 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '@anthropic-ai/sdk/core'; -import { APIPromise } from '@anthropic-ai/sdk/core'; import { APIResource } from '@anthropic-ai/sdk/resource'; +import { APIPromise } from '@anthropic-ai/sdk/core'; +import * as Core from '@anthropic-ai/sdk/core'; import * as CompletionsAPI from '@anthropic-ai/sdk/resources/completions'; import { Stream } from '@anthropic-ai/sdk/streaming'; diff --git a/src/resources/messages.ts b/src/resources/messages.ts index 03497af4..6ce8623d 100644 --- a/src/resources/messages.ts +++ b/src/resources/messages.ts @@ -1,13 +1,14 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Core from '@anthropic-ai/sdk/core'; -import { APIPromise } from '@anthropic-ai/sdk/core'; import { APIResource } from '@anthropic-ai/sdk/resource'; +import { APIPromise } from '@anthropic-ai/sdk/core'; +import * as Core from '@anthropic-ai/sdk/core'; import { MessageStream } from '@anthropic-ai/sdk/lib/MessageStream'; -export { MessageStream } from '@anthropic-ai/sdk/lib/MessageStream'; import * as MessagesAPI from '@anthropic-ai/sdk/resources/messages'; import { Stream } from '@anthropic-ai/sdk/streaming'; +export { MessageStream } from '@anthropic-ai/sdk/lib/MessageStream'; + export class Messages extends APIResource { /** * Create a Message. diff --git a/tests/stringifyQuery.test.ts b/tests/stringifyQuery.test.ts index 82320845..1fef3436 100644 --- a/tests/stringifyQuery.test.ts +++ b/tests/stringifyQuery.test.ts @@ -1,8 +1,10 @@ -import { APIClient } from '@anthropic-ai/sdk/core'; +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -const { stringifyQuery } = APIClient.prototype as any; +import { Anthropic } from '@anthropic-ai/sdk'; -describe('APIClient.stringifyQuery', () => { +const { stringifyQuery } = Anthropic.prototype as any; + +describe(stringifyQuery, () => { for (const [input, expected] of [ [{ a: '1', b: 2, c: true }, 'a=1&b=2&c=true'], [{ a: null, b: false, c: undefined }, 'a=&b=false'], @@ -18,6 +20,7 @@ describe('APIClient.stringifyQuery', () => { expect(stringifyQuery(input)).toEqual(expected); }); } + for (const value of [[], {}, new Date()]) { it(`${JSON.stringify(value)} -> `, () => { expect(() => stringifyQuery({ value })).toThrow(`Cannot stringify type ${typeof value}`);