@ai-sdk/provider-utils 4.0.29 → 4.0.30
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/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +15 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/cancel-response-body.ts +19 -0
- package/src/download-blob.ts +4 -0
- package/src/fetch-with-validated-redirects.ts +5 -0
- package/src/index.ts +1 -0
- package/src/read-response-with-size-limit.ts +4 -0
package/dist/index.mjs
CHANGED
|
@@ -208,6 +208,15 @@ function convertToFormData(input, options = {}) {
|
|
|
208
208
|
return formData;
|
|
209
209
|
}
|
|
210
210
|
|
|
211
|
+
// src/cancel-response-body.ts
|
|
212
|
+
async function cancelResponseBody(response) {
|
|
213
|
+
var _a2;
|
|
214
|
+
try {
|
|
215
|
+
await ((_a2 = response.body) == null ? void 0 : _a2.cancel());
|
|
216
|
+
} catch (e) {
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
211
220
|
// src/download-error.ts
|
|
212
221
|
import { AISDKError } from "@ai-sdk/provider";
|
|
213
222
|
var name = "AI_DownloadError";
|
|
@@ -407,6 +416,7 @@ async function fetchWithValidatedRedirects({
|
|
|
407
416
|
}
|
|
408
417
|
const location = response.headers.get("location");
|
|
409
418
|
if (response.status >= 300 && response.status < 400 && location) {
|
|
419
|
+
await cancelResponseBody(response);
|
|
410
420
|
currentUrl = new URL(location, currentUrl).toString();
|
|
411
421
|
continue;
|
|
412
422
|
}
|
|
@@ -429,6 +439,7 @@ async function readResponseWithSizeLimit({
|
|
|
429
439
|
if (contentLength != null) {
|
|
430
440
|
const length = parseInt(contentLength, 10);
|
|
431
441
|
if (!isNaN(length) && length > maxBytes) {
|
|
442
|
+
await cancelResponseBody(response);
|
|
432
443
|
throw new DownloadError({
|
|
433
444
|
url,
|
|
434
445
|
message: `Download of ${url} exceeded maximum size of ${maxBytes} bytes (Content-Length: ${length}).`
|
|
@@ -482,6 +493,7 @@ async function downloadBlob(url, options) {
|
|
|
482
493
|
abortSignal: options == null ? void 0 : options.abortSignal
|
|
483
494
|
});
|
|
484
495
|
if (!response.ok) {
|
|
496
|
+
await cancelResponseBody(response);
|
|
485
497
|
throw new DownloadError({
|
|
486
498
|
url,
|
|
487
499
|
statusCode: response.status,
|
|
@@ -665,7 +677,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
665
677
|
}
|
|
666
678
|
|
|
667
679
|
// src/version.ts
|
|
668
|
-
var VERSION = true ? "4.0.
|
|
680
|
+
var VERSION = true ? "4.0.30" : "0.0.0-test";
|
|
669
681
|
|
|
670
682
|
// src/get-from-api.ts
|
|
671
683
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -2797,6 +2809,7 @@ export {
|
|
|
2797
2809
|
EventSourceParserStream2 as EventSourceParserStream,
|
|
2798
2810
|
VERSION,
|
|
2799
2811
|
asSchema,
|
|
2812
|
+
cancelResponseBody,
|
|
2800
2813
|
combineHeaders,
|
|
2801
2814
|
convertAsyncIteratorToReadableStream,
|
|
2802
2815
|
convertBase64ToUint8Array,
|