@ai-sdk/provider-utils 2.2.8 → 3.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +237 -14
- package/dist/index.d.mts +156 -72
- package/dist/index.d.ts +156 -72
- package/dist/index.js +243 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +215 -61
- package/dist/index.mjs.map +1 -1
- package/dist/test/index.d.mts +87 -0
- package/dist/test/index.d.ts +87 -0
- package/{test/dist → dist/test}/index.js +66 -358
- package/dist/test/index.js.map +1 -0
- package/{test/dist → dist/test}/index.mjs +64 -353
- package/dist/test/index.mjs.map +1 -0
- package/package.json +19 -17
- package/test.d.ts +1 -0
- package/test/dist/index.d.mts +0 -162
- package/test/dist/index.d.ts +0 -162
- package/test/dist/index.js.map +0 -1
- package/test/dist/index.mjs.map +0 -1
- /package/{test/dist → dist/test}/chunk-D6YTI3O5.mjs +0 -0
- /package/{test/dist → dist/test}/chunk-D6YTI3O5.mjs.map +0 -0
- /package/{test/dist → dist/test}/graphql-6JDEV3ML.mjs +0 -0
- /package/{test/dist → dist/test}/graphql-6JDEV3ML.mjs.map +0 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@ai-sdk/provider-utils",
|
3
|
-
"version": "
|
3
|
+
"version": "3.0.0-alpha.10",
|
4
4
|
"license": "Apache-2.0",
|
5
5
|
"sideEffects": false,
|
6
6
|
"main": "./dist/index.js",
|
@@ -8,8 +8,8 @@
|
|
8
8
|
"types": "./dist/index.d.ts",
|
9
9
|
"files": [
|
10
10
|
"dist/**/*",
|
11
|
-
"
|
12
|
-
"
|
11
|
+
"CHANGELOG.md",
|
12
|
+
"test.d.ts"
|
13
13
|
],
|
14
14
|
"exports": {
|
15
15
|
"./package.json": "./package.json",
|
@@ -19,27 +19,27 @@
|
|
19
19
|
"require": "./dist/index.js"
|
20
20
|
},
|
21
21
|
"./test": {
|
22
|
-
"types": "./test/
|
23
|
-
"import": "./test/
|
24
|
-
"module": "./test/
|
25
|
-
"require": "./test/
|
22
|
+
"types": "./dist/test/index.d.ts",
|
23
|
+
"import": "./dist/test/index.mjs",
|
24
|
+
"module": "./dist/test/index.mjs",
|
25
|
+
"require": "./dist/test/index.js"
|
26
26
|
}
|
27
27
|
},
|
28
28
|
"dependencies": {
|
29
|
-
"@
|
30
|
-
"
|
31
|
-
"
|
29
|
+
"@standard-schema/spec": "^1.0.0",
|
30
|
+
"zod-to-json-schema": "^3.24.1",
|
31
|
+
"@ai-sdk/provider": "2.0.0-alpha.10"
|
32
32
|
},
|
33
33
|
"devDependencies": {
|
34
34
|
"@types/node": "20.17.24",
|
35
35
|
"msw": "2.7.0",
|
36
36
|
"tsup": "^8",
|
37
|
-
"typescript": "5.
|
38
|
-
"zod": "3.
|
37
|
+
"typescript": "5.8.3",
|
38
|
+
"zod": "3.25.49",
|
39
39
|
"@vercel/ai-tsconfig": "0.0.0"
|
40
40
|
},
|
41
41
|
"peerDependencies": {
|
42
|
-
"zod": "^3.
|
42
|
+
"zod": "^3.25.49"
|
43
43
|
},
|
44
44
|
"engines": {
|
45
45
|
"node": ">=18"
|
@@ -59,13 +59,15 @@
|
|
59
59
|
"ai"
|
60
60
|
],
|
61
61
|
"scripts": {
|
62
|
-
"build": "tsup",
|
63
|
-
"build:watch": "tsup --watch",
|
64
|
-
"clean": "rm -rf dist
|
62
|
+
"build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
|
63
|
+
"build:watch": "pnpm clean && tsup --watch",
|
64
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
65
65
|
"lint": "eslint \"./**/*.ts*\"",
|
66
|
-
"type-check": "tsc --
|
66
|
+
"type-check": "tsc --build",
|
67
67
|
"prettier-check": "prettier --check \"./**/*.ts*\"",
|
68
68
|
"test": "pnpm test:node && pnpm test:edge",
|
69
|
+
"test:update": "pnpm test:node -u",
|
70
|
+
"test:watch": "vitest --config vitest.node.config.js",
|
69
71
|
"test:edge": "vitest --config vitest.edge.config.js --run",
|
70
72
|
"test:node": "vitest --config vitest.node.config.js --run"
|
71
73
|
}
|
package/test.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
export * from './dist/test';
|
package/test/dist/index.d.mts
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
import { SetupServer } from 'msw/node';
|
2
|
-
import { JsonBodyType } from 'msw';
|
3
|
-
|
4
|
-
declare function convertArrayToAsyncIterable<T>(values: T[]): AsyncIterable<T>;
|
5
|
-
|
6
|
-
declare function convertArrayToReadableStream<T>(values: T[]): ReadableStream<T>;
|
7
|
-
|
8
|
-
declare function convertAsyncIterableToArray<T>(iterable: AsyncIterable<T>): Promise<T[]>;
|
9
|
-
|
10
|
-
declare function convertReadableStreamToArray<T>(stream: ReadableStream<T>): Promise<T[]>;
|
11
|
-
|
12
|
-
declare function convertResponseStreamToArray(response: Response): Promise<string[]>;
|
13
|
-
|
14
|
-
/**
|
15
|
-
* @deprecated Use createTestServer instead
|
16
|
-
*/
|
17
|
-
declare class JsonTestServer {
|
18
|
-
readonly server: SetupServer;
|
19
|
-
responseHeaders: Record<string, string>;
|
20
|
-
responseBodyJson: any;
|
21
|
-
request: Request | undefined;
|
22
|
-
/**
|
23
|
-
* @deprecated Use createTestServer instead
|
24
|
-
*/
|
25
|
-
constructor(url: string);
|
26
|
-
getRequestBodyJson(): Promise<any>;
|
27
|
-
getRequestHeaders(): Promise<Record<string, string>>;
|
28
|
-
getRequestUrlSearchParams(): Promise<URLSearchParams>;
|
29
|
-
getRequestUrl(): Promise<string>;
|
30
|
-
setupTestEnvironment(): void;
|
31
|
-
}
|
32
|
-
|
33
|
-
declare function mockId({ prefix, }?: {
|
34
|
-
prefix?: string;
|
35
|
-
}): () => string;
|
36
|
-
|
37
|
-
/**
|
38
|
-
* @deprecated Use createTestServer instead
|
39
|
-
*/
|
40
|
-
declare class StreamingTestServer {
|
41
|
-
readonly server: SetupServer;
|
42
|
-
responseHeaders: Record<string, string>;
|
43
|
-
responseChunks: any[];
|
44
|
-
request: Request | undefined;
|
45
|
-
/**
|
46
|
-
* @deprecated Use createTestServer instead
|
47
|
-
*/
|
48
|
-
constructor(url: string);
|
49
|
-
getRequestBodyJson(): Promise<any>;
|
50
|
-
getRequestHeaders(): Promise<Record<string, string>>;
|
51
|
-
getRequestUrlSearchParams(): Promise<URLSearchParams>;
|
52
|
-
setupTestEnvironment(): void;
|
53
|
-
}
|
54
|
-
|
55
|
-
type TestServerJsonBodyType = JsonBodyType;
|
56
|
-
type TestServerResponse = {
|
57
|
-
url: string;
|
58
|
-
headers?: Record<string, string>;
|
59
|
-
} & ({
|
60
|
-
type: 'json-value';
|
61
|
-
content: TestServerJsonBodyType;
|
62
|
-
} | {
|
63
|
-
type: 'stream-values';
|
64
|
-
content: Array<string>;
|
65
|
-
} | {
|
66
|
-
type: 'controlled-stream';
|
67
|
-
id?: string;
|
68
|
-
} | {
|
69
|
-
type: 'error';
|
70
|
-
status: number;
|
71
|
-
content?: string;
|
72
|
-
});
|
73
|
-
declare class TestServerCall$1 {
|
74
|
-
private request;
|
75
|
-
constructor(request: Request);
|
76
|
-
getRequestBodyJson(): Promise<any>;
|
77
|
-
getRequestCredentials(): RequestCredentials;
|
78
|
-
getRequestHeaders(): Record<string, string>;
|
79
|
-
getRequestUrlSearchParams(): URLSearchParams;
|
80
|
-
}
|
81
|
-
declare function withTestServer(responses: Array<TestServerResponse> | TestServerResponse, testFunction: (options: {
|
82
|
-
calls: () => Array<TestServerCall$1>;
|
83
|
-
call: (index: number) => TestServerCall$1;
|
84
|
-
getStreamController: (id: string) => ReadableStreamDefaultController<string>;
|
85
|
-
streamController: ReadableStreamDefaultController<string>;
|
86
|
-
}) => Promise<void>): () => Promise<void>;
|
87
|
-
declare function describeWithTestServer(description: string, responses: Array<TestServerResponse> | TestServerResponse, testFunction: (options: {
|
88
|
-
calls: () => Array<TestServerCall$1>;
|
89
|
-
call: (index: number) => TestServerCall$1;
|
90
|
-
getStreamController: (id: string) => ReadableStreamDefaultController<string>;
|
91
|
-
streamController: ReadableStreamDefaultController<string>;
|
92
|
-
}) => void): void;
|
93
|
-
|
94
|
-
type UrlResponse = {
|
95
|
-
type: 'json-value';
|
96
|
-
headers?: Record<string, string>;
|
97
|
-
body: JsonBodyType;
|
98
|
-
} | {
|
99
|
-
type: 'stream-chunks';
|
100
|
-
headers?: Record<string, string>;
|
101
|
-
chunks: Array<string>;
|
102
|
-
} | {
|
103
|
-
type: 'binary';
|
104
|
-
headers?: Record<string, string>;
|
105
|
-
body: Buffer;
|
106
|
-
} | {
|
107
|
-
type: 'empty';
|
108
|
-
headers?: Record<string, string>;
|
109
|
-
status?: number;
|
110
|
-
} | {
|
111
|
-
type: 'error';
|
112
|
-
headers?: Record<string, string>;
|
113
|
-
status?: number;
|
114
|
-
body?: string;
|
115
|
-
} | {
|
116
|
-
type: 'controlled-stream';
|
117
|
-
headers?: Record<string, string>;
|
118
|
-
controller: TestResponseController;
|
119
|
-
} | undefined;
|
120
|
-
type UrlResponseParameter = UrlResponse | UrlResponse[] | ((options: {
|
121
|
-
callNumber: number;
|
122
|
-
}) => UrlResponse);
|
123
|
-
type UrlHandler = {
|
124
|
-
response: UrlResponseParameter;
|
125
|
-
};
|
126
|
-
type UrlHandlers<URLS extends {
|
127
|
-
[url: string]: {
|
128
|
-
response?: UrlResponseParameter;
|
129
|
-
};
|
130
|
-
}> = {
|
131
|
-
[url in keyof URLS]: UrlHandler;
|
132
|
-
};
|
133
|
-
declare class TestServerCall {
|
134
|
-
private request;
|
135
|
-
constructor(request: Request);
|
136
|
-
get requestBody(): Promise<any>;
|
137
|
-
get requestBodyMultipart(): Promise<Record<string, any>> | null;
|
138
|
-
get requestCredentials(): RequestCredentials;
|
139
|
-
get requestHeaders(): Record<string, string>;
|
140
|
-
get requestUrlSearchParams(): URLSearchParams;
|
141
|
-
get requestUrl(): string;
|
142
|
-
get requestMethod(): string;
|
143
|
-
}
|
144
|
-
declare function createTestServer<URLS extends {
|
145
|
-
[url: string]: {
|
146
|
-
response?: UrlResponseParameter;
|
147
|
-
};
|
148
|
-
}>(routes: URLS): {
|
149
|
-
urls: UrlHandlers<URLS>;
|
150
|
-
calls: TestServerCall[];
|
151
|
-
};
|
152
|
-
declare class TestResponseController {
|
153
|
-
private readonly transformStream;
|
154
|
-
private readonly writer;
|
155
|
-
constructor();
|
156
|
-
get stream(): ReadableStream;
|
157
|
-
write(chunk: string): Promise<void>;
|
158
|
-
error(error: Error): Promise<void>;
|
159
|
-
close(): Promise<void>;
|
160
|
-
}
|
161
|
-
|
162
|
-
export { JsonTestServer, StreamingTestServer, TestResponseController, type TestServerJsonBodyType, type TestServerResponse, type UrlHandler, type UrlHandlers, type UrlResponse, convertArrayToAsyncIterable, convertArrayToReadableStream, convertAsyncIterableToArray, convertReadableStreamToArray, convertResponseStreamToArray, createTestServer, describeWithTestServer, mockId, withTestServer };
|
package/test/dist/index.d.ts
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
import { SetupServer } from 'msw/node';
|
2
|
-
import { JsonBodyType } from 'msw';
|
3
|
-
|
4
|
-
declare function convertArrayToAsyncIterable<T>(values: T[]): AsyncIterable<T>;
|
5
|
-
|
6
|
-
declare function convertArrayToReadableStream<T>(values: T[]): ReadableStream<T>;
|
7
|
-
|
8
|
-
declare function convertAsyncIterableToArray<T>(iterable: AsyncIterable<T>): Promise<T[]>;
|
9
|
-
|
10
|
-
declare function convertReadableStreamToArray<T>(stream: ReadableStream<T>): Promise<T[]>;
|
11
|
-
|
12
|
-
declare function convertResponseStreamToArray(response: Response): Promise<string[]>;
|
13
|
-
|
14
|
-
/**
|
15
|
-
* @deprecated Use createTestServer instead
|
16
|
-
*/
|
17
|
-
declare class JsonTestServer {
|
18
|
-
readonly server: SetupServer;
|
19
|
-
responseHeaders: Record<string, string>;
|
20
|
-
responseBodyJson: any;
|
21
|
-
request: Request | undefined;
|
22
|
-
/**
|
23
|
-
* @deprecated Use createTestServer instead
|
24
|
-
*/
|
25
|
-
constructor(url: string);
|
26
|
-
getRequestBodyJson(): Promise<any>;
|
27
|
-
getRequestHeaders(): Promise<Record<string, string>>;
|
28
|
-
getRequestUrlSearchParams(): Promise<URLSearchParams>;
|
29
|
-
getRequestUrl(): Promise<string>;
|
30
|
-
setupTestEnvironment(): void;
|
31
|
-
}
|
32
|
-
|
33
|
-
declare function mockId({ prefix, }?: {
|
34
|
-
prefix?: string;
|
35
|
-
}): () => string;
|
36
|
-
|
37
|
-
/**
|
38
|
-
* @deprecated Use createTestServer instead
|
39
|
-
*/
|
40
|
-
declare class StreamingTestServer {
|
41
|
-
readonly server: SetupServer;
|
42
|
-
responseHeaders: Record<string, string>;
|
43
|
-
responseChunks: any[];
|
44
|
-
request: Request | undefined;
|
45
|
-
/**
|
46
|
-
* @deprecated Use createTestServer instead
|
47
|
-
*/
|
48
|
-
constructor(url: string);
|
49
|
-
getRequestBodyJson(): Promise<any>;
|
50
|
-
getRequestHeaders(): Promise<Record<string, string>>;
|
51
|
-
getRequestUrlSearchParams(): Promise<URLSearchParams>;
|
52
|
-
setupTestEnvironment(): void;
|
53
|
-
}
|
54
|
-
|
55
|
-
type TestServerJsonBodyType = JsonBodyType;
|
56
|
-
type TestServerResponse = {
|
57
|
-
url: string;
|
58
|
-
headers?: Record<string, string>;
|
59
|
-
} & ({
|
60
|
-
type: 'json-value';
|
61
|
-
content: TestServerJsonBodyType;
|
62
|
-
} | {
|
63
|
-
type: 'stream-values';
|
64
|
-
content: Array<string>;
|
65
|
-
} | {
|
66
|
-
type: 'controlled-stream';
|
67
|
-
id?: string;
|
68
|
-
} | {
|
69
|
-
type: 'error';
|
70
|
-
status: number;
|
71
|
-
content?: string;
|
72
|
-
});
|
73
|
-
declare class TestServerCall$1 {
|
74
|
-
private request;
|
75
|
-
constructor(request: Request);
|
76
|
-
getRequestBodyJson(): Promise<any>;
|
77
|
-
getRequestCredentials(): RequestCredentials;
|
78
|
-
getRequestHeaders(): Record<string, string>;
|
79
|
-
getRequestUrlSearchParams(): URLSearchParams;
|
80
|
-
}
|
81
|
-
declare function withTestServer(responses: Array<TestServerResponse> | TestServerResponse, testFunction: (options: {
|
82
|
-
calls: () => Array<TestServerCall$1>;
|
83
|
-
call: (index: number) => TestServerCall$1;
|
84
|
-
getStreamController: (id: string) => ReadableStreamDefaultController<string>;
|
85
|
-
streamController: ReadableStreamDefaultController<string>;
|
86
|
-
}) => Promise<void>): () => Promise<void>;
|
87
|
-
declare function describeWithTestServer(description: string, responses: Array<TestServerResponse> | TestServerResponse, testFunction: (options: {
|
88
|
-
calls: () => Array<TestServerCall$1>;
|
89
|
-
call: (index: number) => TestServerCall$1;
|
90
|
-
getStreamController: (id: string) => ReadableStreamDefaultController<string>;
|
91
|
-
streamController: ReadableStreamDefaultController<string>;
|
92
|
-
}) => void): void;
|
93
|
-
|
94
|
-
type UrlResponse = {
|
95
|
-
type: 'json-value';
|
96
|
-
headers?: Record<string, string>;
|
97
|
-
body: JsonBodyType;
|
98
|
-
} | {
|
99
|
-
type: 'stream-chunks';
|
100
|
-
headers?: Record<string, string>;
|
101
|
-
chunks: Array<string>;
|
102
|
-
} | {
|
103
|
-
type: 'binary';
|
104
|
-
headers?: Record<string, string>;
|
105
|
-
body: Buffer;
|
106
|
-
} | {
|
107
|
-
type: 'empty';
|
108
|
-
headers?: Record<string, string>;
|
109
|
-
status?: number;
|
110
|
-
} | {
|
111
|
-
type: 'error';
|
112
|
-
headers?: Record<string, string>;
|
113
|
-
status?: number;
|
114
|
-
body?: string;
|
115
|
-
} | {
|
116
|
-
type: 'controlled-stream';
|
117
|
-
headers?: Record<string, string>;
|
118
|
-
controller: TestResponseController;
|
119
|
-
} | undefined;
|
120
|
-
type UrlResponseParameter = UrlResponse | UrlResponse[] | ((options: {
|
121
|
-
callNumber: number;
|
122
|
-
}) => UrlResponse);
|
123
|
-
type UrlHandler = {
|
124
|
-
response: UrlResponseParameter;
|
125
|
-
};
|
126
|
-
type UrlHandlers<URLS extends {
|
127
|
-
[url: string]: {
|
128
|
-
response?: UrlResponseParameter;
|
129
|
-
};
|
130
|
-
}> = {
|
131
|
-
[url in keyof URLS]: UrlHandler;
|
132
|
-
};
|
133
|
-
declare class TestServerCall {
|
134
|
-
private request;
|
135
|
-
constructor(request: Request);
|
136
|
-
get requestBody(): Promise<any>;
|
137
|
-
get requestBodyMultipart(): Promise<Record<string, any>> | null;
|
138
|
-
get requestCredentials(): RequestCredentials;
|
139
|
-
get requestHeaders(): Record<string, string>;
|
140
|
-
get requestUrlSearchParams(): URLSearchParams;
|
141
|
-
get requestUrl(): string;
|
142
|
-
get requestMethod(): string;
|
143
|
-
}
|
144
|
-
declare function createTestServer<URLS extends {
|
145
|
-
[url: string]: {
|
146
|
-
response?: UrlResponseParameter;
|
147
|
-
};
|
148
|
-
}>(routes: URLS): {
|
149
|
-
urls: UrlHandlers<URLS>;
|
150
|
-
calls: TestServerCall[];
|
151
|
-
};
|
152
|
-
declare class TestResponseController {
|
153
|
-
private readonly transformStream;
|
154
|
-
private readonly writer;
|
155
|
-
constructor();
|
156
|
-
get stream(): ReadableStream;
|
157
|
-
write(chunk: string): Promise<void>;
|
158
|
-
error(error: Error): Promise<void>;
|
159
|
-
close(): Promise<void>;
|
160
|
-
}
|
161
|
-
|
162
|
-
export { JsonTestServer, StreamingTestServer, TestResponseController, type TestServerJsonBodyType, type TestServerResponse, type UrlHandler, type UrlHandlers, type UrlResponse, convertArrayToAsyncIterable, convertArrayToReadableStream, convertAsyncIterableToArray, convertReadableStreamToArray, convertResponseStreamToArray, createTestServer, describeWithTestServer, mockId, withTestServer };
|