@ai-sdk/provider-utils 1.0.4 → 1.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/dist/index.d.mts +4 -12
- package/dist/index.d.ts +4 -12
- package/dist/index.js +32 -63
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -31
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/dist/index.js +107 -20
- package/test/dist/index.js.map +1 -1
- package/test/dist/index.mjs +107 -20
- package/test/dist/index.mjs.map +1 -1
package/test/dist/index.mjs
CHANGED
@@ -82,7 +82,7 @@ async function convertResponseStreamToArray(response) {
|
|
82
82
|
);
|
83
83
|
}
|
84
84
|
|
85
|
-
// ../../node_modules/.pnpm/outvariant@1.4.
|
85
|
+
// ../../node_modules/.pnpm/outvariant@1.4.3/node_modules/outvariant/lib/index.mjs
|
86
86
|
var POSITIONALS_EXP = /(%?)(%([sdijo]))/g;
|
87
87
|
function serializePositional(positional, flag) {
|
88
88
|
switch (flag) {
|
@@ -153,10 +153,12 @@ var invariant = (predicate, message3, ...positionals) => {
|
|
153
153
|
};
|
154
154
|
invariant.as = (ErrorConstructor, predicate, message3, ...positionals) => {
|
155
155
|
if (!predicate) {
|
156
|
-
const formatMessage2 = positionals.length === 0 ? message3 : format(message3, positionals);
|
156
|
+
const formatMessage2 = positionals.length === 0 ? message3 : format(message3, ...positionals);
|
157
157
|
let error3;
|
158
158
|
try {
|
159
|
-
error3 = Reflect.construct(ErrorConstructor, [
|
159
|
+
error3 = Reflect.construct(ErrorConstructor, [
|
160
|
+
formatMessage2
|
161
|
+
]);
|
160
162
|
} catch (err) {
|
161
163
|
error3 = ErrorConstructor(formatMessage2);
|
162
164
|
}
|
@@ -873,7 +875,7 @@ async function serializeResponse(response) {
|
|
873
875
|
};
|
874
876
|
}
|
875
877
|
|
876
|
-
// ../../node_modules/.pnpm/path-to-regexp@6.2.
|
878
|
+
// ../../node_modules/.pnpm/path-to-regexp@6.2.2/node_modules/path-to-regexp/dist.es2015/index.js
|
877
879
|
function lexer(str) {
|
878
880
|
var tokens = [];
|
879
881
|
var i = 0;
|
@@ -1113,7 +1115,7 @@ function tokensToRegexp(tokens, keys, options) {
|
|
1113
1115
|
if (options === void 0) {
|
1114
1116
|
options = {};
|
1115
1117
|
}
|
1116
|
-
var _a3 = options.strict, strict = _a3 === void 0 ? false : _a3, _b2 = options.start, start = _b2 === void 0 ? true : _b2,
|
1118
|
+
var _a3 = options.strict, strict = _a3 === void 0 ? false : _a3, _b2 = options.start, start = _b2 === void 0 ? true : _b2, _c2 = options.end, end = _c2 === void 0 ? true : _c2, _d = options.encode, encode = _d === void 0 ? function(x) {
|
1117
1119
|
return x;
|
1118
1120
|
} : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
|
1119
1121
|
var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
|
@@ -1187,6 +1189,88 @@ function isNodeProcess() {
|
|
1187
1189
|
return false;
|
1188
1190
|
}
|
1189
1191
|
|
1192
|
+
// ../../node_modules/.pnpm/outvariant@1.4.2/node_modules/outvariant/lib/index.mjs
|
1193
|
+
var POSITIONALS_EXP2 = /(%?)(%([sdijo]))/g;
|
1194
|
+
function serializePositional2(positional, flag) {
|
1195
|
+
switch (flag) {
|
1196
|
+
case "s":
|
1197
|
+
return positional;
|
1198
|
+
case "d":
|
1199
|
+
case "i":
|
1200
|
+
return Number(positional);
|
1201
|
+
case "j":
|
1202
|
+
return JSON.stringify(positional);
|
1203
|
+
case "o": {
|
1204
|
+
if (typeof positional === "string") {
|
1205
|
+
return positional;
|
1206
|
+
}
|
1207
|
+
const json = JSON.stringify(positional);
|
1208
|
+
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) {
|
1209
|
+
return positional;
|
1210
|
+
}
|
1211
|
+
return json;
|
1212
|
+
}
|
1213
|
+
}
|
1214
|
+
}
|
1215
|
+
function format2(message3, ...positionals) {
|
1216
|
+
if (positionals.length === 0) {
|
1217
|
+
return message3;
|
1218
|
+
}
|
1219
|
+
let positionalIndex = 0;
|
1220
|
+
let formattedMessage = message3.replace(
|
1221
|
+
POSITIONALS_EXP2,
|
1222
|
+
(match2, isEscaped, _, flag) => {
|
1223
|
+
const positional = positionals[positionalIndex];
|
1224
|
+
const value = serializePositional2(positional, flag);
|
1225
|
+
if (!isEscaped) {
|
1226
|
+
positionalIndex++;
|
1227
|
+
return value;
|
1228
|
+
}
|
1229
|
+
return match2;
|
1230
|
+
}
|
1231
|
+
);
|
1232
|
+
if (positionalIndex < positionals.length) {
|
1233
|
+
formattedMessage += ` ${positionals.slice(positionalIndex).join(" ")}`;
|
1234
|
+
}
|
1235
|
+
formattedMessage = formattedMessage.replace(/%{2,2}/g, "%");
|
1236
|
+
return formattedMessage;
|
1237
|
+
}
|
1238
|
+
var STACK_FRAMES_TO_IGNORE2 = 2;
|
1239
|
+
function cleanErrorStack2(error3) {
|
1240
|
+
if (!error3.stack) {
|
1241
|
+
return;
|
1242
|
+
}
|
1243
|
+
const nextStack = error3.stack.split("\n");
|
1244
|
+
nextStack.splice(1, STACK_FRAMES_TO_IGNORE2);
|
1245
|
+
error3.stack = nextStack.join("\n");
|
1246
|
+
}
|
1247
|
+
var InvariantError2 = class extends Error {
|
1248
|
+
constructor(message3, ...positionals) {
|
1249
|
+
super(message3);
|
1250
|
+
this.message = message3;
|
1251
|
+
this.name = "Invariant Violation";
|
1252
|
+
this.message = format2(message3, ...positionals);
|
1253
|
+
cleanErrorStack2(this);
|
1254
|
+
}
|
1255
|
+
};
|
1256
|
+
var invariant2 = (predicate, message3, ...positionals) => {
|
1257
|
+
if (!predicate) {
|
1258
|
+
throw new InvariantError2(message3, ...positionals);
|
1259
|
+
}
|
1260
|
+
};
|
1261
|
+
invariant2.as = (ErrorConstructor, predicate, message3, ...positionals) => {
|
1262
|
+
if (!predicate) {
|
1263
|
+
const formatMessage2 = positionals.length === 0 ? message3 : format2(message3, positionals);
|
1264
|
+
let error3;
|
1265
|
+
try {
|
1266
|
+
error3 = Reflect.construct(ErrorConstructor, [formatMessage2]);
|
1267
|
+
} catch (err) {
|
1268
|
+
error3 = ErrorConstructor(formatMessage2);
|
1269
|
+
}
|
1270
|
+
throw error3;
|
1271
|
+
}
|
1272
|
+
};
|
1273
|
+
|
1190
1274
|
// ../../node_modules/.pnpm/@open-draft+logger@0.3.0/node_modules/@open-draft/logger/lib/index.mjs
|
1191
1275
|
var __defProp3 = Object.defineProperty;
|
1192
1276
|
var __export = (target, all) => {
|
@@ -1415,21 +1499,21 @@ var PerformanceEntry = class {
|
|
1415
1499
|
var noop = () => void 0;
|
1416
1500
|
function log(message3, ...positionals) {
|
1417
1501
|
if (IS_NODE) {
|
1418
|
-
process.stdout.write(
|
1502
|
+
process.stdout.write(format2(message3, ...positionals) + "\n");
|
1419
1503
|
return;
|
1420
1504
|
}
|
1421
1505
|
console.log(message3, ...positionals);
|
1422
1506
|
}
|
1423
1507
|
function warn2(message3, ...positionals) {
|
1424
1508
|
if (IS_NODE) {
|
1425
|
-
process.stderr.write(
|
1509
|
+
process.stderr.write(format2(message3, ...positionals) + "\n");
|
1426
1510
|
return;
|
1427
1511
|
}
|
1428
1512
|
console.warn(message3, ...positionals);
|
1429
1513
|
}
|
1430
1514
|
function error2(message3, ...positionals) {
|
1431
1515
|
if (IS_NODE) {
|
1432
|
-
process.stderr.write(
|
1516
|
+
process.stderr.write(format2(message3, ...positionals) + "\n");
|
1433
1517
|
return;
|
1434
1518
|
}
|
1435
1519
|
console.error(message3, ...positionals);
|
@@ -1966,7 +2050,7 @@ var require_cookie = __commonJS2({
|
|
1966
2050
|
var import_cookie = __toESM2(require_cookie(), 1);
|
1967
2051
|
var source_default2 = import_cookie.default;
|
1968
2052
|
|
1969
|
-
// ../../node_modules/.pnpm/@mswjs+cookies@1.1.
|
2053
|
+
// ../../node_modules/.pnpm/@mswjs+cookies@1.1.1/node_modules/@mswjs/cookies/lib/index.mjs
|
1970
2054
|
var __create3 = Object.create;
|
1971
2055
|
var __defProp5 = Object.defineProperty;
|
1972
2056
|
var __getOwnPropDesc3 = Object.getOwnPropertyDescriptor;
|
@@ -2170,6 +2254,7 @@ function supportsLocalStorage() {
|
|
2170
2254
|
return false;
|
2171
2255
|
}
|
2172
2256
|
}
|
2257
|
+
var hasLocalStorageSupport = supportsLocalStorage();
|
2173
2258
|
function isPropertyAccessible2(object, method) {
|
2174
2259
|
try {
|
2175
2260
|
object[method];
|
@@ -2241,7 +2326,7 @@ var CookieStore = class {
|
|
2241
2326
|
this.store.clear();
|
2242
2327
|
}
|
2243
2328
|
hydrate() {
|
2244
|
-
if (!
|
2329
|
+
if (!hasLocalStorageSupport) {
|
2245
2330
|
return;
|
2246
2331
|
}
|
2247
2332
|
const persistedCookies = localStorage.getItem(PERSISTENCY_KEY);
|
@@ -2276,7 +2361,7 @@ Invalid value has been removed from localStorage to prevent subsequent failed pa
|
|
2276
2361
|
}
|
2277
2362
|
}
|
2278
2363
|
persist() {
|
2279
|
-
if (!
|
2364
|
+
if (!hasLocalStorageSupport) {
|
2280
2365
|
return;
|
2281
2366
|
}
|
2282
2367
|
const serializedCookies = Array.from(this.store.entries()).map(
|
@@ -2452,7 +2537,7 @@ var http = {
|
|
2452
2537
|
options: createHttpHandler(HttpMethods.OPTIONS)
|
2453
2538
|
};
|
2454
2539
|
|
2455
|
-
// ../../node_modules/.pnpm/headers-polyfill@4.0.
|
2540
|
+
// ../../node_modules/.pnpm/headers-polyfill@4.0.3/node_modules/headers-polyfill/lib/index.mjs
|
2456
2541
|
var __create4 = Object.create;
|
2457
2542
|
var __defProp6 = Object.defineProperty;
|
2458
2543
|
var __getOwnPropDesc4 = Object.getOwnPropertyDescriptor;
|
@@ -2728,10 +2813,12 @@ var RAW_HEADER_NAMES = Symbol("rawHeaderNames");
|
|
2728
2813
|
var HEADER_VALUE_DELIMITER = ", ";
|
2729
2814
|
var _a;
|
2730
2815
|
var _b;
|
2816
|
+
var _c;
|
2731
2817
|
var Headers2 = class _Headers {
|
2732
2818
|
constructor(init) {
|
2733
2819
|
this[_a] = {};
|
2734
2820
|
this[_b] = /* @__PURE__ */ new Map();
|
2821
|
+
this[_c] = "Headers";
|
2735
2822
|
if (["Headers", "HeadersPolyfill"].includes(init == null ? void 0 : init.constructor.name) || init instanceof _Headers || typeof globalThis.Headers !== "undefined" && init instanceof globalThis.Headers) {
|
2736
2823
|
const initialHeaders = init;
|
2737
2824
|
initialHeaders.forEach((value, name) => {
|
@@ -2754,7 +2841,7 @@ var Headers2 = class _Headers {
|
|
2754
2841
|
});
|
2755
2842
|
}
|
2756
2843
|
}
|
2757
|
-
[(_a = NORMALIZED_HEADERS, _b = RAW_HEADER_NAMES, Symbol.iterator)]() {
|
2844
|
+
[(_a = NORMALIZED_HEADERS, _b = RAW_HEADER_NAMES, _c = Symbol.toStringTag, Symbol.iterator)]() {
|
2758
2845
|
return this.entries();
|
2759
2846
|
}
|
2760
2847
|
*keys() {
|
@@ -2960,7 +3047,7 @@ function readResponseCookies(request2, response) {
|
|
2960
3047
|
|
2961
3048
|
// ../../node_modules/.pnpm/msw@2.3.1_typescript@5.1.3/node_modules/msw/lib/core/utils/handleRequest.mjs
|
2962
3049
|
async function handleRequest(request2, requestId, handlers, options, emitter, handleRequestOptions) {
|
2963
|
-
var _a3, _b2,
|
3050
|
+
var _a3, _b2, _c2, _d, _e, _f;
|
2964
3051
|
emitter.emit("request:start", { request: request2, requestId });
|
2965
3052
|
if (request2.headers.get("x-msw-intention") === "bypass") {
|
2966
3053
|
emitter.emit("request:end", { request: request2, requestId });
|
@@ -2993,7 +3080,7 @@ async function handleRequest(request2, requestId, handlers, options, emitter, ha
|
|
2993
3080
|
const { response } = lookupResult.data;
|
2994
3081
|
if (!response) {
|
2995
3082
|
emitter.emit("request:end", { request: request2, requestId });
|
2996
|
-
(
|
3083
|
+
(_c2 = handleRequestOptions == null ? void 0 : handleRequestOptions.onPassthroughResponse) == null ? void 0 : _c2.call(handleRequestOptions, request2);
|
2997
3084
|
return;
|
2998
3085
|
}
|
2999
3086
|
if (response.status === 302 && response.headers.get("x-msw-intention") === "passthrough") {
|
@@ -3217,7 +3304,7 @@ var RequestController = class {
|
|
3217
3304
|
this.responsePromise = new DeferredPromise();
|
3218
3305
|
}
|
3219
3306
|
respondWith(response) {
|
3220
|
-
|
3307
|
+
invariant2(
|
3221
3308
|
this.responsePromise.state === "pending",
|
3222
3309
|
'Failed to respond to "%s %s" request: the "request" event has already been responded to.',
|
3223
3310
|
this.request.method,
|
@@ -4530,7 +4617,7 @@ var XMLHttpRequestController = class {
|
|
4530
4617
|
}
|
4531
4618
|
}
|
4532
4619
|
get responseText() {
|
4533
|
-
|
4620
|
+
invariant2(
|
4534
4621
|
this.request.responseType === "" || this.request.responseType === "text",
|
4535
4622
|
"InvalidStateError: The object is in invalid state."
|
4536
4623
|
);
|
@@ -4542,7 +4629,7 @@ var XMLHttpRequestController = class {
|
|
4542
4629
|
return responseText;
|
4543
4630
|
}
|
4544
4631
|
get responseXML() {
|
4545
|
-
|
4632
|
+
invariant2(
|
4546
4633
|
this.request.responseType === "" || this.request.responseType === "document",
|
4547
4634
|
"InvalidStateError: The object is in invalid state."
|
4548
4635
|
);
|
@@ -4801,7 +4888,7 @@ var _XMLHttpRequestInterceptor = class extends Interceptor {
|
|
4801
4888
|
const logger7 = this.logger.extend("setup");
|
4802
4889
|
logger7.info('patching "XMLHttpRequest" module...');
|
4803
4890
|
const PureXMLHttpRequest = globalThis.XMLHttpRequest;
|
4804
|
-
|
4891
|
+
invariant2(
|
4805
4892
|
!PureXMLHttpRequest[IS_PATCHED_MODULE],
|
4806
4893
|
'Failed to patch the "XMLHttpRequest" module: already patched.'
|
4807
4894
|
);
|
@@ -4851,7 +4938,7 @@ var _FetchInterceptor = class extends Interceptor {
|
|
4851
4938
|
}
|
4852
4939
|
async setup() {
|
4853
4940
|
const pureFetch = globalThis.fetch;
|
4854
|
-
|
4941
|
+
invariant2(
|
4855
4942
|
!pureFetch[IS_PATCHED_MODULE],
|
4856
4943
|
'Failed to patch the "fetch" module: already patched.'
|
4857
4944
|
);
|