@ai-sdk/provider-utils 3.0.17 → 3.0.19
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 +12 -0
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +84 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +83 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -77,6 +77,53 @@ function createAbortError() {
|
|
|
77
77
|
return new DOMException("Delay was aborted", "AbortError");
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
// src/delayed-promise.ts
|
|
81
|
+
var DelayedPromise = class {
|
|
82
|
+
constructor() {
|
|
83
|
+
this.status = { type: "pending" };
|
|
84
|
+
this._resolve = void 0;
|
|
85
|
+
this._reject = void 0;
|
|
86
|
+
}
|
|
87
|
+
get promise() {
|
|
88
|
+
if (this._promise) {
|
|
89
|
+
return this._promise;
|
|
90
|
+
}
|
|
91
|
+
this._promise = new Promise((resolve2, reject) => {
|
|
92
|
+
if (this.status.type === "resolved") {
|
|
93
|
+
resolve2(this.status.value);
|
|
94
|
+
} else if (this.status.type === "rejected") {
|
|
95
|
+
reject(this.status.error);
|
|
96
|
+
}
|
|
97
|
+
this._resolve = resolve2;
|
|
98
|
+
this._reject = reject;
|
|
99
|
+
});
|
|
100
|
+
return this._promise;
|
|
101
|
+
}
|
|
102
|
+
resolve(value) {
|
|
103
|
+
var _a;
|
|
104
|
+
this.status = { type: "resolved", value };
|
|
105
|
+
if (this._promise) {
|
|
106
|
+
(_a = this._resolve) == null ? void 0 : _a.call(this, value);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
reject(error) {
|
|
110
|
+
var _a;
|
|
111
|
+
this.status = { type: "rejected", error };
|
|
112
|
+
if (this._promise) {
|
|
113
|
+
(_a = this._reject) == null ? void 0 : _a.call(this, error);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
isResolved() {
|
|
117
|
+
return this.status.type === "resolved";
|
|
118
|
+
}
|
|
119
|
+
isRejected() {
|
|
120
|
+
return this.status.type === "rejected";
|
|
121
|
+
}
|
|
122
|
+
isPending() {
|
|
123
|
+
return this.status.type === "pending";
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
80
127
|
// src/extract-response-headers.ts
|
|
81
128
|
function extractResponseHeaders(response) {
|
|
82
129
|
return Object.fromEntries([...response.headers]);
|
|
@@ -216,7 +263,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
216
263
|
}
|
|
217
264
|
|
|
218
265
|
// src/version.ts
|
|
219
|
-
var VERSION = true ? "3.0.
|
|
266
|
+
var VERSION = true ? "3.0.19" : "0.0.0-test";
|
|
220
267
|
|
|
221
268
|
// src/get-from-api.ts
|
|
222
269
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -1025,6 +1072,33 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
|
|
|
1025
1072
|
// src/zod-schema.ts
|
|
1026
1073
|
import * as z4 from "zod/v4";
|
|
1027
1074
|
|
|
1075
|
+
// src/add-additional-properties-to-json-schema.ts
|
|
1076
|
+
function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
|
|
1077
|
+
if (jsonSchema2.type === "object") {
|
|
1078
|
+
jsonSchema2.additionalProperties = false;
|
|
1079
|
+
const properties = jsonSchema2.properties;
|
|
1080
|
+
if (properties != null) {
|
|
1081
|
+
for (const property in properties) {
|
|
1082
|
+
properties[property] = addAdditionalPropertiesToJsonSchema(
|
|
1083
|
+
properties[property]
|
|
1084
|
+
);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
if (jsonSchema2.type === "array" && jsonSchema2.items != null) {
|
|
1089
|
+
if (Array.isArray(jsonSchema2.items)) {
|
|
1090
|
+
jsonSchema2.items = jsonSchema2.items.map(
|
|
1091
|
+
(item) => addAdditionalPropertiesToJsonSchema(item)
|
|
1092
|
+
);
|
|
1093
|
+
} else {
|
|
1094
|
+
jsonSchema2.items = addAdditionalPropertiesToJsonSchema(
|
|
1095
|
+
jsonSchema2.items
|
|
1096
|
+
);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
return jsonSchema2;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1028
1102
|
// src/zod-to-json-schema/get-relative-path.ts
|
|
1029
1103
|
var getRelativePath = (pathA, pathB) => {
|
|
1030
1104
|
let i = 0;
|
|
@@ -2230,11 +2304,13 @@ function zod4Schema(zodSchema2, options) {
|
|
|
2230
2304
|
const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
|
|
2231
2305
|
return jsonSchema(
|
|
2232
2306
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
2233
|
-
() =>
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2307
|
+
() => addAdditionalPropertiesToJsonSchema(
|
|
2308
|
+
z4.toJSONSchema(zodSchema2, {
|
|
2309
|
+
target: "draft-7",
|
|
2310
|
+
io: "input",
|
|
2311
|
+
reused: useReferences ? "ref" : "inline"
|
|
2312
|
+
})
|
|
2313
|
+
),
|
|
2238
2314
|
{
|
|
2239
2315
|
validate: async (value) => {
|
|
2240
2316
|
const result = await z4.safeParseAsync(zodSchema2, value);
|
|
@@ -2345,6 +2421,7 @@ import {
|
|
|
2345
2421
|
EventSourceParserStream as EventSourceParserStream2
|
|
2346
2422
|
} from "eventsource-parser/stream";
|
|
2347
2423
|
export {
|
|
2424
|
+
DelayedPromise,
|
|
2348
2425
|
EventSourceParserStream2 as EventSourceParserStream,
|
|
2349
2426
|
VERSION,
|
|
2350
2427
|
asSchema,
|