@ai-sdk/provider-utils 4.0.0-beta.45 → 4.0.0-beta.47

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.mjs CHANGED
@@ -289,7 +289,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
289
289
  }
290
290
 
291
291
  // src/version.ts
292
- var VERSION = true ? "4.0.0-beta.45" : "0.0.0-test";
292
+ var VERSION = true ? "4.0.0-beta.47" : "0.0.0-test";
293
293
 
294
294
  // src/get-from-api.ts
295
295
  var getOriginalFetch = () => globalThis.fetch;
@@ -582,6 +582,33 @@ import { TypeValidationError as TypeValidationError2 } from "@ai-sdk/provider";
582
582
  import { TypeValidationError } from "@ai-sdk/provider";
583
583
  import * as z4 from "zod/v4";
584
584
 
585
+ // src/add-additional-properties-to-json-schema.ts
586
+ function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
587
+ if (jsonSchema2.type === "object") {
588
+ jsonSchema2.additionalProperties = false;
589
+ const properties = jsonSchema2.properties;
590
+ if (properties != null) {
591
+ for (const property in properties) {
592
+ properties[property] = addAdditionalPropertiesToJsonSchema(
593
+ properties[property]
594
+ );
595
+ }
596
+ }
597
+ }
598
+ if (jsonSchema2.type === "array" && jsonSchema2.items != null) {
599
+ if (Array.isArray(jsonSchema2.items)) {
600
+ jsonSchema2.items = jsonSchema2.items.map(
601
+ (item) => addAdditionalPropertiesToJsonSchema(item)
602
+ );
603
+ } else {
604
+ jsonSchema2.items = addAdditionalPropertiesToJsonSchema(
605
+ jsonSchema2.items
606
+ );
607
+ }
608
+ }
609
+ return jsonSchema2;
610
+ }
611
+
585
612
  // src/to-json-schema/arktype-to-json-schema.ts
586
613
  var arktypeToJsonSchema = (schema) => () => {
587
614
  return schema.toJsonSchema();
@@ -1893,11 +1920,13 @@ function zod4Schema(zodSchema2, options) {
1893
1920
  const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
1894
1921
  return jsonSchema(
1895
1922
  // defer json schema creation to avoid unnecessary computation when only validation is needed
1896
- () => z4.toJSONSchema(zodSchema2, {
1897
- target: "draft-7",
1898
- io: "output",
1899
- reused: useReferences ? "ref" : "inline"
1900
- }),
1923
+ () => addAdditionalPropertiesToJsonSchema(
1924
+ z4.toJSONSchema(zodSchema2, {
1925
+ target: "draft-7",
1926
+ io: "input",
1927
+ reused: useReferences ? "ref" : "inline"
1928
+ })
1929
+ ),
1901
1930
  {
1902
1931
  validate: async (value) => {
1903
1932
  const result = await z4.safeParseAsync(zodSchema2, value);