@ai-sdk/provider-utils 3.0.18 → 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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 3.0.19
4
+
5
+ ### Patch Changes
6
+
7
+ - ef6d784: fix: generate zod4 json schema from input schema
8
+
3
9
  ## 3.0.18
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -356,7 +356,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
356
356
  }
357
357
 
358
358
  // src/version.ts
359
- var VERSION = true ? "3.0.18" : "0.0.0-test";
359
+ var VERSION = true ? "3.0.19" : "0.0.0-test";
360
360
 
361
361
  // src/get-from-api.ts
362
362
  var getOriginalFetch = () => globalThis.fetch;
@@ -1160,6 +1160,33 @@ var createStatusCodeErrorResponseHandler = () => async ({ response, url, request
1160
1160
  // src/zod-schema.ts
1161
1161
  var z4 = __toESM(require("zod/v4"));
1162
1162
 
1163
+ // src/add-additional-properties-to-json-schema.ts
1164
+ function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
1165
+ if (jsonSchema2.type === "object") {
1166
+ jsonSchema2.additionalProperties = false;
1167
+ const properties = jsonSchema2.properties;
1168
+ if (properties != null) {
1169
+ for (const property in properties) {
1170
+ properties[property] = addAdditionalPropertiesToJsonSchema(
1171
+ properties[property]
1172
+ );
1173
+ }
1174
+ }
1175
+ }
1176
+ if (jsonSchema2.type === "array" && jsonSchema2.items != null) {
1177
+ if (Array.isArray(jsonSchema2.items)) {
1178
+ jsonSchema2.items = jsonSchema2.items.map(
1179
+ (item) => addAdditionalPropertiesToJsonSchema(item)
1180
+ );
1181
+ } else {
1182
+ jsonSchema2.items = addAdditionalPropertiesToJsonSchema(
1183
+ jsonSchema2.items
1184
+ );
1185
+ }
1186
+ }
1187
+ return jsonSchema2;
1188
+ }
1189
+
1163
1190
  // src/zod-to-json-schema/get-relative-path.ts
1164
1191
  var getRelativePath = (pathA, pathB) => {
1165
1192
  let i = 0;
@@ -2363,11 +2390,13 @@ function zod4Schema(zodSchema2, options) {
2363
2390
  const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
2364
2391
  return jsonSchema(
2365
2392
  // defer json schema creation to avoid unnecessary computation when only validation is needed
2366
- () => z4.toJSONSchema(zodSchema2, {
2367
- target: "draft-7",
2368
- io: "output",
2369
- reused: useReferences ? "ref" : "inline"
2370
- }),
2393
+ () => addAdditionalPropertiesToJsonSchema(
2394
+ z4.toJSONSchema(zodSchema2, {
2395
+ target: "draft-7",
2396
+ io: "input",
2397
+ reused: useReferences ? "ref" : "inline"
2398
+ })
2399
+ ),
2371
2400
  {
2372
2401
  validate: async (value) => {
2373
2402
  const result = await z4.safeParseAsync(zodSchema2, value);