@ai-sdk/provider-utils
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -161,3 +161,3 @@ "use strict"; | ||
function isAbortError(error) { | ||
return error instanceof DOMException && (error.name === "AbortError" || error.name === "TimeoutError"); | ||
return error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError"); | ||
} | ||
@@ -164,0 +164,0 @@ |
@@ -39,3 +39,3 @@ import { JSONParseError, TypeValidationError, APICallError } from '@ai-sdk/provider'; | ||
declare function isAbortError(error: unknown): error is DOMException; | ||
declare function isAbortError(error: unknown): error is Error; | ||
@@ -42,0 +42,0 @@ declare function loadApiKey({ apiKey, environmentVariableName, apiKeyParameterName, description, }: { |
@@ -161,3 +161,3 @@ "use strict"; | ||
function isAbortError(error) { | ||
return error instanceof DOMException && (error.name === "AbortError" || error.name === "TimeoutError"); | ||
return error instanceof Error && (error.name === "AbortError" || error.name === "TimeoutError"); | ||
} | ||
@@ -164,0 +164,0 @@ |
{ | ||
"name": "@ai-sdk/provider-utils", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "Apache-2.0", | ||
@@ -35,3 +35,3 @@ "sideEffects": false, | ||
"@types/node": "^18", | ||
"msw": "2.0.9", | ||
"msw": "2.3.1", | ||
"tsup": "^8", | ||
@@ -38,0 +38,0 @@ "typescript": "5.1.3", |
import { SetupServer } from 'msw/node'; | ||
import { JsonBodyType } from 'msw'; | ||
declare function convertArrayToAsyncIterable<T>(values: T[]): AsyncIterable<T>; | ||
declare function convertArrayToReadableStream<T>(values: T[]): ReadableStream<T>; | ||
declare function convertArrayToAsyncIterable<T>(values: T[]): AsyncIterable<T>; | ||
declare function convertAsyncIterableToArray<T>(iterable: AsyncIterable<T>): Promise<T[]>; | ||
@@ -19,2 +20,3 @@ | ||
getRequestHeaders(): Promise<Record<string, string>>; | ||
getRequestUrlSearchParams(): Promise<URLSearchParams>; | ||
setupTestEnvironment(): void; | ||
@@ -31,5 +33,44 @@ } | ||
getRequestHeaders(): Promise<Record<string, string>>; | ||
getRequestUrlSearchParams(): Promise<URLSearchParams>; | ||
setupTestEnvironment(): void; | ||
} | ||
type TestServerJsonBodyType = JsonBodyType; | ||
type TestServerResponse = { | ||
url: string; | ||
headers?: Record<string, string>; | ||
} & ({ | ||
type: 'json-value'; | ||
content: TestServerJsonBodyType; | ||
} | { | ||
type: 'stream-values'; | ||
content: Array<string>; | ||
} | { | ||
type: 'controlled-stream'; | ||
id?: string; | ||
} | { | ||
type: 'error'; | ||
status: number; | ||
content?: string; | ||
}); | ||
declare class TestServerCall { | ||
private request; | ||
constructor(request: Request); | ||
getRequestBodyJson(): Promise<any>; | ||
getRequestHeaders(): Record<string, string>; | ||
getRequestUrlSearchParams(): URLSearchParams; | ||
} | ||
declare function withTestServer(responses: Array<TestServerResponse> | TestServerResponse, testFunction: (options: { | ||
calls: () => Array<TestServerCall>; | ||
call: (index: number) => TestServerCall; | ||
getStreamController: (id: string) => ReadableStreamDefaultController<string>; | ||
streamController: ReadableStreamDefaultController<string>; | ||
}) => Promise<void>): () => Promise<void>; | ||
declare function describeWithTestServer(description: string, responses: Array<TestServerResponse> | TestServerResponse, testFunction: (options: { | ||
calls: () => Array<TestServerCall>; | ||
call: (index: number) => TestServerCall; | ||
getStreamController: (id: string) => ReadableStreamDefaultController<string>; | ||
streamController: ReadableStreamDefaultController<string>; | ||
}) => void): void; | ||
/** | ||
@@ -40,2 +81,2 @@ * @deprecated Use `convertReadableStreamToArray` instead. | ||
export { JsonTestServer, StreamingTestServer, convertArrayToAsyncIterable, convertArrayToReadableStream, convertAsyncIterableToArray, convertReadableStreamToArray, convertStreamToArray }; | ||
export { JsonTestServer, StreamingTestServer, type TestServerJsonBodyType, type TestServerResponse, convertArrayToAsyncIterable, convertArrayToReadableStream, convertAsyncIterableToArray, convertReadableStreamToArray, convertStreamToArray, describeWithTestServer, withTestServer }; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1264749
12839
10