@ai-sdk/provider-utils 4.0.2 → 4.0.4

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,18 @@
1
1
  # @ai-sdk/provider-utils
2
2
 
3
+ ## 4.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [d937c8f]
8
+ - @ai-sdk/provider@3.0.2
9
+
10
+ ## 4.0.3
11
+
12
+ ### Patch Changes
13
+
14
+ - 0b429d4: fix(provider-utils): handle anyOf/allOf/oneOf and definitions in addAdditionalPropertiesToJsonSchema
15
+
3
16
  ## 4.0.2
4
17
 
5
18
  ### Patch Changes
package/dist/index.js CHANGED
@@ -475,7 +475,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
475
475
  }
476
476
 
477
477
  // src/version.ts
478
- var VERSION = true ? "4.0.2" : "0.0.0-test";
478
+ var VERSION = true ? "4.0.4" : "0.0.0-test";
479
479
 
480
480
  // src/get-from-api.ts
481
481
  var getOriginalFetch = () => globalThis.fetch;
@@ -767,30 +767,39 @@ var z4 = __toESM(require("zod/v4"));
767
767
 
768
768
  // src/add-additional-properties-to-json-schema.ts
769
769
  function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
770
- if (jsonSchema2.type === "object") {
770
+ if (jsonSchema2.type === "object" || Array.isArray(jsonSchema2.type) && jsonSchema2.type.includes("object")) {
771
771
  jsonSchema2.additionalProperties = false;
772
- const properties = jsonSchema2.properties;
772
+ const { properties } = jsonSchema2;
773
773
  if (properties != null) {
774
- for (const property in properties) {
775
- properties[property] = addAdditionalPropertiesToJsonSchema(
776
- properties[property]
777
- );
774
+ for (const key of Object.keys(properties)) {
775
+ properties[key] = visit(properties[key]);
778
776
  }
779
777
  }
780
778
  }
781
- if (jsonSchema2.type === "array" && jsonSchema2.items != null) {
782
- if (Array.isArray(jsonSchema2.items)) {
783
- jsonSchema2.items = jsonSchema2.items.map(
784
- (item) => addAdditionalPropertiesToJsonSchema(item)
785
- );
786
- } else {
787
- jsonSchema2.items = addAdditionalPropertiesToJsonSchema(
788
- jsonSchema2.items
789
- );
779
+ if (jsonSchema2.items != null) {
780
+ jsonSchema2.items = Array.isArray(jsonSchema2.items) ? jsonSchema2.items.map(visit) : visit(jsonSchema2.items);
781
+ }
782
+ if (jsonSchema2.anyOf != null) {
783
+ jsonSchema2.anyOf = jsonSchema2.anyOf.map(visit);
784
+ }
785
+ if (jsonSchema2.allOf != null) {
786
+ jsonSchema2.allOf = jsonSchema2.allOf.map(visit);
787
+ }
788
+ if (jsonSchema2.oneOf != null) {
789
+ jsonSchema2.oneOf = jsonSchema2.oneOf.map(visit);
790
+ }
791
+ const { definitions } = jsonSchema2;
792
+ if (definitions != null) {
793
+ for (const key of Object.keys(definitions)) {
794
+ definitions[key] = visit(definitions[key]);
790
795
  }
791
796
  }
792
797
  return jsonSchema2;
793
798
  }
799
+ function visit(def) {
800
+ if (typeof def === "boolean") return def;
801
+ return addAdditionalPropertiesToJsonSchema(def);
802
+ }
794
803
 
795
804
  // src/to-json-schema/zod3-to-json-schema/options.ts
796
805
  var ignoreOverride = Symbol(