@ai-sdk/provider-utils 2.0.4 → 2.0.6
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 +18 -0
- package/package.json +2 -2
- package/test/dist/index.d.mts +15 -1
- package/test/dist/index.d.ts +15 -1
- package/test/dist/index.js +110 -55
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +109 -55
- package/test/dist/index.mjs.map +1 -1
package/test/dist/index.mjs
CHANGED
@@ -7,61 +7,6 @@ import {
|
|
7
7
|
__require
|
8
8
|
} from "./chunk-D6YTI3O5.mjs";
|
9
9
|
|
10
|
-
// src/test/convert-array-to-async-iterable.ts
|
11
|
-
function convertArrayToAsyncIterable(values) {
|
12
|
-
return {
|
13
|
-
async *[Symbol.asyncIterator]() {
|
14
|
-
for (const value of values) {
|
15
|
-
yield value;
|
16
|
-
}
|
17
|
-
}
|
18
|
-
};
|
19
|
-
}
|
20
|
-
|
21
|
-
// src/test/convert-array-to-readable-stream.ts
|
22
|
-
function convertArrayToReadableStream(values) {
|
23
|
-
return new ReadableStream({
|
24
|
-
start(controller) {
|
25
|
-
try {
|
26
|
-
for (const value of values) {
|
27
|
-
controller.enqueue(value);
|
28
|
-
}
|
29
|
-
} finally {
|
30
|
-
controller.close();
|
31
|
-
}
|
32
|
-
}
|
33
|
-
});
|
34
|
-
}
|
35
|
-
|
36
|
-
// src/test/convert-async-iterable-to-array.ts
|
37
|
-
async function convertAsyncIterableToArray(iterable) {
|
38
|
-
const result = [];
|
39
|
-
for await (const item of iterable) {
|
40
|
-
result.push(item);
|
41
|
-
}
|
42
|
-
return result;
|
43
|
-
}
|
44
|
-
|
45
|
-
// src/test/convert-readable-stream-to-array.ts
|
46
|
-
async function convertReadableStreamToArray(stream) {
|
47
|
-
const reader = stream.getReader();
|
48
|
-
const result = [];
|
49
|
-
while (true) {
|
50
|
-
const { done, value } = await reader.read();
|
51
|
-
if (done)
|
52
|
-
break;
|
53
|
-
result.push(value);
|
54
|
-
}
|
55
|
-
return result;
|
56
|
-
}
|
57
|
-
|
58
|
-
// src/test/convert-response-stream-to-array.ts
|
59
|
-
async function convertResponseStreamToArray(response) {
|
60
|
-
return convertReadableStreamToArray(
|
61
|
-
response.body.pipeThrough(new TextDecoderStream())
|
62
|
-
);
|
63
|
-
}
|
64
|
-
|
65
10
|
// ../../node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
|
66
11
|
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
|
67
12
|
function serializePositional(positional, flag) {
|
@@ -18358,6 +18303,114 @@ var setupServer = (...handlers) => {
|
|
18358
18303
|
return new SetupServerApi(handlers);
|
18359
18304
|
};
|
18360
18305
|
|
18306
|
+
// src/test/binary-test-server.ts
|
18307
|
+
var BinaryTestServer = class {
|
18308
|
+
constructor(url) {
|
18309
|
+
this.responseBody = null;
|
18310
|
+
this.responseHeaders = {};
|
18311
|
+
this.responseStatus = 200;
|
18312
|
+
this.server = setupServer(
|
18313
|
+
http.post(url, ({ request }) => {
|
18314
|
+
this.request = request;
|
18315
|
+
if (this.responseBody === null) {
|
18316
|
+
return new HttpResponse(null, { status: this.responseStatus });
|
18317
|
+
}
|
18318
|
+
return new HttpResponse(this.responseBody, {
|
18319
|
+
status: this.responseStatus,
|
18320
|
+
headers: this.responseHeaders
|
18321
|
+
});
|
18322
|
+
})
|
18323
|
+
);
|
18324
|
+
}
|
18325
|
+
async getRequestBodyJson() {
|
18326
|
+
expect(this.request).toBeDefined();
|
18327
|
+
return JSON.parse(await this.request.text());
|
18328
|
+
}
|
18329
|
+
async getRequestHeaders() {
|
18330
|
+
expect(this.request).toBeDefined();
|
18331
|
+
const requestHeaders = this.request.headers;
|
18332
|
+
const headersObject = {};
|
18333
|
+
requestHeaders.forEach((value, key) => {
|
18334
|
+
headersObject[key] = value;
|
18335
|
+
});
|
18336
|
+
return headersObject;
|
18337
|
+
}
|
18338
|
+
async getRequestUrlSearchParams() {
|
18339
|
+
expect(this.request).toBeDefined();
|
18340
|
+
return new URL(this.request.url).searchParams;
|
18341
|
+
}
|
18342
|
+
async getRequestUrl() {
|
18343
|
+
expect(this.request).toBeDefined();
|
18344
|
+
return new URL(this.request.url).toString();
|
18345
|
+
}
|
18346
|
+
setupTestEnvironment() {
|
18347
|
+
beforeAll(() => this.server.listen());
|
18348
|
+
beforeEach(() => {
|
18349
|
+
this.responseBody = null;
|
18350
|
+
this.request = void 0;
|
18351
|
+
this.responseHeaders = {};
|
18352
|
+
this.responseStatus = 200;
|
18353
|
+
});
|
18354
|
+
afterEach(() => this.server.resetHandlers());
|
18355
|
+
afterAll(() => this.server.close());
|
18356
|
+
}
|
18357
|
+
};
|
18358
|
+
|
18359
|
+
// src/test/convert-array-to-async-iterable.ts
|
18360
|
+
function convertArrayToAsyncIterable(values) {
|
18361
|
+
return {
|
18362
|
+
async *[Symbol.asyncIterator]() {
|
18363
|
+
for (const value of values) {
|
18364
|
+
yield value;
|
18365
|
+
}
|
18366
|
+
}
|
18367
|
+
};
|
18368
|
+
}
|
18369
|
+
|
18370
|
+
// src/test/convert-array-to-readable-stream.ts
|
18371
|
+
function convertArrayToReadableStream(values) {
|
18372
|
+
return new ReadableStream({
|
18373
|
+
start(controller) {
|
18374
|
+
try {
|
18375
|
+
for (const value of values) {
|
18376
|
+
controller.enqueue(value);
|
18377
|
+
}
|
18378
|
+
} finally {
|
18379
|
+
controller.close();
|
18380
|
+
}
|
18381
|
+
}
|
18382
|
+
});
|
18383
|
+
}
|
18384
|
+
|
18385
|
+
// src/test/convert-async-iterable-to-array.ts
|
18386
|
+
async function convertAsyncIterableToArray(iterable) {
|
18387
|
+
const result = [];
|
18388
|
+
for await (const item of iterable) {
|
18389
|
+
result.push(item);
|
18390
|
+
}
|
18391
|
+
return result;
|
18392
|
+
}
|
18393
|
+
|
18394
|
+
// src/test/convert-readable-stream-to-array.ts
|
18395
|
+
async function convertReadableStreamToArray(stream) {
|
18396
|
+
const reader = stream.getReader();
|
18397
|
+
const result = [];
|
18398
|
+
while (true) {
|
18399
|
+
const { done, value } = await reader.read();
|
18400
|
+
if (done)
|
18401
|
+
break;
|
18402
|
+
result.push(value);
|
18403
|
+
}
|
18404
|
+
return result;
|
18405
|
+
}
|
18406
|
+
|
18407
|
+
// src/test/convert-response-stream-to-array.ts
|
18408
|
+
async function convertResponseStreamToArray(response) {
|
18409
|
+
return convertReadableStreamToArray(
|
18410
|
+
response.body.pipeThrough(new TextDecoderStream())
|
18411
|
+
);
|
18412
|
+
}
|
18413
|
+
|
18361
18414
|
// src/test/json-test-server.ts
|
18362
18415
|
var JsonTestServer = class {
|
18363
18416
|
constructor(url) {
|
@@ -18641,6 +18694,7 @@ function describeWithTestServer(description, responses, testFunction) {
|
|
18641
18694
|
});
|
18642
18695
|
}
|
18643
18696
|
export {
|
18697
|
+
BinaryTestServer,
|
18644
18698
|
JsonTestServer,
|
18645
18699
|
StreamingTestServer,
|
18646
18700
|
convertArrayToAsyncIterable,
|