@ai-sdk/provider-utils 5.0.51 → 5.0.52
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 +8 -0
- package/dist/experimental-evaluation/index.d.ts +23 -22
- package/dist/experimental-evaluation/index.d.ts.map +1 -0
- package/dist/experimental-evaluation/index.js +1216 -1506
- package/dist/experimental-evaluation/index.js.map +1 -1
- package/dist/index.d.ts +1738 -1644
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4350 -4716
- package/dist/index.js.map +1 -1
- package/dist/test/index.d.ts +24 -17
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +48 -73
- package/dist/test/index.js.map +1 -1
- package/package.json +6 -6
package/dist/test/index.d.ts
CHANGED
|
@@ -1,18 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
declare function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
declare function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
declare function
|
|
15
|
-
|
|
1
|
+
//#region src/test/convert-array-to-async-iterable.d.ts
|
|
2
|
+
export declare function convertArrayToAsyncIterable<T>(values: T[]): AsyncIterable<T>;
|
|
3
|
+
//#endregion
|
|
4
|
+
//#region src/test/convert-array-to-readable-stream.d.ts
|
|
5
|
+
export declare function convertArrayToReadableStream<T>(values: T[]): ReadableStream<T>;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/test/convert-async-iterable-to-array.d.ts
|
|
8
|
+
export declare function convertAsyncIterableToArray<T>(iterable: AsyncIterable<T>): Promise<T[]>;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/test/convert-readable-stream-to-array.d.ts
|
|
11
|
+
export declare function convertReadableStreamToArray<T>(stream: ReadableStream<T>): Promise<T[]>;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/test/convert-response-stream-to-array.d.ts
|
|
14
|
+
export declare function convertResponseStreamToArray(response: Response): Promise<string[]>;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/test/is-node-version.d.ts
|
|
17
|
+
export declare function isNodeVersion(version: number): boolean;
|
|
18
|
+
export declare function isNodeVersionAtLeast(major: number, minor?: number, patch?: number): boolean;
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region src/test/mock-id.d.ts
|
|
21
|
+
export declare function mockId({ prefix }?: {
|
|
22
|
+
prefix?: string;
|
|
16
23
|
}): () => string;
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
//#endregion
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/test/convert-array-to-async-iterable.ts","../../src/test/convert-array-to-readable-stream.ts","../../src/test/convert-async-iterable-to-array.ts","../../src/test/convert-readable-stream-to-array.ts","../../src/test/convert-response-stream-to-array.ts","../../src/test/is-node-version.ts","../../src/test/mock-id.ts"],"mappings":";wBAAgB,4BAA4B,GAAG,QAAQ,MAAM,cAAc;;;wBCA3D,6BAA6B,GAC3C,QAAQ,MACP,eAAe;;;wBCFI,4BAA4B,GAChD,UAAU,cAAc,KACvB,QAAQ;;;wBCFW,6BAA6B,GACjD,QAAQ,eAAe,KACtB,QAAQ;;;wBCAW,6BACpB,UAAU,WACT;;;wBCEa,cAAc;wBAKd,qBAAqB,eAAe,gBAAW;;;wBCX/C,SACd;EAEA"}
|
package/dist/test/index.js
CHANGED
|
@@ -1,91 +1,66 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/test/convert-array-to-async-iterable.ts
|
|
2
2
|
function convertArrayToAsyncIterable(values) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
yield value;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
};
|
|
3
|
+
return { async *[Symbol.asyncIterator]() {
|
|
4
|
+
for (const value of values) yield value;
|
|
5
|
+
} };
|
|
10
6
|
}
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/test/convert-array-to-readable-stream.ts
|
|
13
9
|
function convertArrayToReadableStream(values) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
controller.close();
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
});
|
|
10
|
+
return new ReadableStream({ start(controller) {
|
|
11
|
+
try {
|
|
12
|
+
for (const value of values) controller.enqueue(value);
|
|
13
|
+
} finally {
|
|
14
|
+
controller.close();
|
|
15
|
+
}
|
|
16
|
+
} });
|
|
25
17
|
}
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
//#endregion
|
|
19
|
+
//#region src/test/convert-async-iterable-to-array.ts
|
|
28
20
|
async function convertAsyncIterableToArray(iterable) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
return result;
|
|
21
|
+
const result = [];
|
|
22
|
+
for await (const item of iterable) result.push(item);
|
|
23
|
+
return result;
|
|
34
24
|
}
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
//#endregion
|
|
26
|
+
//#region src/test/convert-readable-stream-to-array.ts
|
|
37
27
|
async function convertReadableStreamToArray(stream) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
const reader = stream.getReader();
|
|
29
|
+
const result = [];
|
|
30
|
+
while (true) {
|
|
31
|
+
const { done, value } = await reader.read();
|
|
32
|
+
if (done) break;
|
|
33
|
+
result.push(value);
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
46
36
|
}
|
|
47
|
-
|
|
48
|
-
|
|
37
|
+
//#endregion
|
|
38
|
+
//#region src/test/convert-response-stream-to-array.ts
|
|
49
39
|
async function convertResponseStreamToArray(response) {
|
|
50
|
-
|
|
51
|
-
response.body.pipeThrough(new TextDecoderStream())
|
|
52
|
-
);
|
|
40
|
+
return await convertReadableStreamToArray(response.body.pipeThrough(new TextDecoderStream()));
|
|
53
41
|
}
|
|
54
|
-
|
|
55
|
-
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/test/is-node-version.ts
|
|
56
44
|
function getNodeVersionParts() {
|
|
57
|
-
|
|
45
|
+
return process.versions.node.split(".").map((version) => Number.parseInt(version, 10));
|
|
58
46
|
}
|
|
59
47
|
function isNodeVersion(version) {
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
const [nodeMajorVersion] = getNodeVersionParts();
|
|
49
|
+
return nodeMajorVersion === version;
|
|
62
50
|
}
|
|
63
51
|
function isNodeVersionAtLeast(major, minor = 0, patch = 0) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
if (nodeMinorVersion !== minor) {
|
|
69
|
-
return nodeMinorVersion > minor;
|
|
70
|
-
}
|
|
71
|
-
return nodePatchVersion >= patch;
|
|
52
|
+
const [nodeMajorVersion, nodeMinorVersion, nodePatchVersion] = getNodeVersionParts();
|
|
53
|
+
if (nodeMajorVersion !== major) return nodeMajorVersion > major;
|
|
54
|
+
if (nodeMinorVersion !== minor) return nodeMinorVersion > minor;
|
|
55
|
+
return nodePatchVersion >= patch;
|
|
72
56
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
function mockId({
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
let counter = 0;
|
|
79
|
-
return () => `${prefix}-${counter++}`;
|
|
57
|
+
//#endregion
|
|
58
|
+
//#region src/test/mock-id.ts
|
|
59
|
+
function mockId({ prefix = "id" } = {}) {
|
|
60
|
+
let counter = 0;
|
|
61
|
+
return () => `${prefix}-${counter++}`;
|
|
80
62
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
convertAsyncIterableToArray,
|
|
85
|
-
convertReadableStreamToArray,
|
|
86
|
-
convertResponseStreamToArray,
|
|
87
|
-
isNodeVersion,
|
|
88
|
-
isNodeVersionAtLeast,
|
|
89
|
-
mockId
|
|
90
|
-
};
|
|
63
|
+
//#endregion
|
|
64
|
+
export { convertArrayToAsyncIterable, convertArrayToReadableStream, convertAsyncIterableToArray, convertReadableStreamToArray, convertResponseStreamToArray, isNodeVersion, isNodeVersionAtLeast, mockId };
|
|
65
|
+
|
|
91
66
|
//# sourceMappingURL=index.js.map
|
package/dist/test/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/test/convert-array-to-async-iterable.ts","../../src/test/convert-array-to-readable-stream.ts","../../src/test/convert-async-iterable-to-array.ts","../../src/test/convert-readable-stream-to-array.ts","../../src/test/convert-response-stream-to-array.ts","../../src/test/is-node-version.ts","../../src/test/mock-id.ts"],"sourcesContent":["export function convertArrayToAsyncIterable<T>(values: T[]): AsyncIterable<T> {\n return {\n async *[Symbol.asyncIterator]() {\n for (const value of values) {\n yield value;\n }\n },\n };\n}\n","export function convertArrayToReadableStream<T>(\n values: T[],\n): ReadableStream<T> {\n return new ReadableStream({\n start(controller) {\n try {\n for (const value of values) {\n controller.enqueue(value);\n }\n } finally {\n controller.close();\n }\n },\n });\n}\n","export async function convertAsyncIterableToArray<T>(\n iterable: AsyncIterable<T>,\n): Promise<T[]> {\n const result: T[] = [];\n for await (const item of iterable) {\n result.push(item);\n }\n return result;\n}\n","export async function convertReadableStreamToArray<T>(\n stream: ReadableStream<T>,\n): Promise<T[]> {\n const reader = stream.getReader();\n const result: T[] = [];\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n result.push(value);\n }\n\n return result;\n}\n","import { convertReadableStreamToArray } from './convert-readable-stream-to-array';\n\nexport async function convertResponseStreamToArray(\n response: Response,\n): Promise<string[]> {\n return await convertReadableStreamToArray(\n response.body!.pipeThrough(new TextDecoderStream()),\n );\n}\n","function getNodeVersionParts() {\n return process.versions.node\n .split('.')\n .map(version => Number.parseInt(version, 10));\n}\n\nexport function isNodeVersion(version: number) {\n const [nodeMajorVersion] = getNodeVersionParts();\n return nodeMajorVersion === version;\n}\n\nexport function isNodeVersionAtLeast(major: number, minor = 0, patch = 0) {\n const [nodeMajorVersion, nodeMinorVersion, nodePatchVersion] =\n getNodeVersionParts();\n\n if (nodeMajorVersion !== major) {\n return nodeMajorVersion > major;\n }\n\n if (nodeMinorVersion !== minor) {\n return nodeMinorVersion > minor;\n }\n\n return nodePatchVersion >= patch;\n}\n","export function mockId({\n prefix = 'id',\n}: {\n prefix?: string;\n} = {}): () => string {\n let counter = 0;\n return () => `${prefix}-${counter++}`;\n}\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/test/convert-array-to-async-iterable.ts","../../src/test/convert-array-to-readable-stream.ts","../../src/test/convert-async-iterable-to-array.ts","../../src/test/convert-readable-stream-to-array.ts","../../src/test/convert-response-stream-to-array.ts","../../src/test/is-node-version.ts","../../src/test/mock-id.ts"],"sourcesContent":["export function convertArrayToAsyncIterable<T>(values: T[]): AsyncIterable<T> {\n return {\n async *[Symbol.asyncIterator]() {\n for (const value of values) {\n yield value;\n }\n },\n };\n}\n","export function convertArrayToReadableStream<T>(\n values: T[],\n): ReadableStream<T> {\n return new ReadableStream({\n start(controller) {\n try {\n for (const value of values) {\n controller.enqueue(value);\n }\n } finally {\n controller.close();\n }\n },\n });\n}\n","export async function convertAsyncIterableToArray<T>(\n iterable: AsyncIterable<T>,\n): Promise<T[]> {\n const result: T[] = [];\n for await (const item of iterable) {\n result.push(item);\n }\n return result;\n}\n","export async function convertReadableStreamToArray<T>(\n stream: ReadableStream<T>,\n): Promise<T[]> {\n const reader = stream.getReader();\n const result: T[] = [];\n\n while (true) {\n const { done, value } = await reader.read();\n if (done) break;\n result.push(value);\n }\n\n return result;\n}\n","import { convertReadableStreamToArray } from './convert-readable-stream-to-array';\n\nexport async function convertResponseStreamToArray(\n response: Response,\n): Promise<string[]> {\n return await convertReadableStreamToArray(\n response.body!.pipeThrough(new TextDecoderStream()),\n );\n}\n","function getNodeVersionParts() {\n return process.versions.node\n .split('.')\n .map(version => Number.parseInt(version, 10));\n}\n\nexport function isNodeVersion(version: number) {\n const [nodeMajorVersion] = getNodeVersionParts();\n return nodeMajorVersion === version;\n}\n\nexport function isNodeVersionAtLeast(major: number, minor = 0, patch = 0) {\n const [nodeMajorVersion, nodeMinorVersion, nodePatchVersion] =\n getNodeVersionParts();\n\n if (nodeMajorVersion !== major) {\n return nodeMajorVersion > major;\n }\n\n if (nodeMinorVersion !== minor) {\n return nodeMinorVersion > minor;\n }\n\n return nodePatchVersion >= patch;\n}\n","export function mockId({\n prefix = 'id',\n}: {\n prefix?: string;\n} = {}): () => string {\n let counter = 0;\n return () => `${prefix}-${counter++}`;\n}\n"],"mappings":";AAAA,SAAgB,4BAA+B,QAA+B;CAC5E,OAAO,EACL,QAAQ,OAAO,iBAAiB;EAC9B,KAAK,MAAM,SAAS,QAClB,MAAM;CAEV,EACF;AACF;;;ACRA,SAAgB,6BACd,QACmB;CACnB,OAAO,IAAI,eAAe,EACxB,MAAM,YAAY;EAChB,IAAI;GACF,KAAK,MAAM,SAAS,QAClB,WAAW,QAAQ,KAAK;EAE5B,UAAU;GACR,WAAW,MAAM;EACnB;CACF,EACF,CAAC;AACH;;;ACdA,eAAsB,4BACpB,UACc;CACd,MAAM,SAAc,CAAC;CACrB,WAAW,MAAM,QAAQ,UACvB,OAAO,KAAK,IAAI;CAElB,OAAO;AACT;;;ACRA,eAAsB,6BACpB,QACc;CACd,MAAM,SAAS,OAAO,UAAU;CAChC,MAAM,SAAc,CAAC;CAErB,OAAO,MAAM;EACX,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,KAAK;EAC1C,IAAI,MAAM;EACV,OAAO,KAAK,KAAK;CACnB;CAEA,OAAO;AACT;;;ACXA,eAAsB,6BACpB,UACmB;CACnB,OAAO,MAAM,6BACX,SAAS,KAAM,YAAY,IAAI,kBAAkB,CAAC,CACpD;AACF;;;ACRA,SAAS,sBAAsB;CAC7B,OAAO,QAAQ,SAAS,KACrB,MAAM,GAAG,CAAC,CACV,KAAI,YAAW,OAAO,SAAS,SAAS,EAAE,CAAC;AAChD;AAEA,SAAgB,cAAc,SAAiB;CAC7C,MAAM,CAAC,oBAAoB,oBAAoB;CAC/C,OAAO,qBAAqB;AAC9B;AAEA,SAAgB,qBAAqB,OAAe,QAAQ,GAAG,QAAQ,GAAG;CACxE,MAAM,CAAC,kBAAkB,kBAAkB,oBACzC,oBAAoB;CAEtB,IAAI,qBAAqB,OACvB,OAAO,mBAAmB;CAG5B,IAAI,qBAAqB,OACvB,OAAO,mBAAmB;CAG5B,OAAO,oBAAoB;AAC7B;;;ACxBA,SAAgB,OAAO,EACrB,SAAS,SAGP,CAAC,GAAiB;CACpB,IAAI,UAAU;CACd,aAAa,GAAG,OAAO,GAAG;AAC5B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/provider-utils",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.52",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@ai-sdk/provider": "4.0.
|
|
40
|
+
"@ai-sdk/provider": "4.0.20",
|
|
41
41
|
"@standard-schema/spec": "^1.1.0",
|
|
42
42
|
"@workflow/serde": "4.1.0",
|
|
43
43
|
"eventsource-parser": "^3.0.8",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"@types/node": "22.19.19",
|
|
48
48
|
"@vercel/ai-tsconfig": "0.0.0",
|
|
49
49
|
"msw": "2.7.0",
|
|
50
|
-
"
|
|
50
|
+
"tsdown": "^0.23.0",
|
|
51
51
|
"typescript": "5.8.3",
|
|
52
52
|
"zod": "3.25.76"
|
|
53
53
|
},
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"ai"
|
|
75
75
|
],
|
|
76
76
|
"scripts": {
|
|
77
|
-
"build": "pnpm clean &&
|
|
78
|
-
"build:watch": "pnpm clean &&
|
|
79
|
-
"clean": "del-cli
|
|
77
|
+
"build": "pnpm clean && tsdown",
|
|
78
|
+
"build:watch": "pnpm clean && tsdown --watch",
|
|
79
|
+
"clean": "del-cli *.tsbuildinfo",
|
|
80
80
|
"type-check": "tsc --build",
|
|
81
81
|
"test": "pnpm test:node && pnpm test:edge",
|
|
82
82
|
"test:update": "pnpm test:node -u",
|