@ai-sdk/provider-utils 4.0.0-beta.46 → 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/CHANGELOG.md +6 -0
- package/dist/index.js +35 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +35 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -378,7 +378,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
// src/version.ts
|
|
381
|
-
var VERSION = true ? "4.0.0-beta.
|
|
381
|
+
var VERSION = true ? "4.0.0-beta.47" : "0.0.0-test";
|
|
382
382
|
|
|
383
383
|
// src/get-from-api.ts
|
|
384
384
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -668,6 +668,33 @@ var import_provider7 = require("@ai-sdk/provider");
|
|
|
668
668
|
var import_provider6 = require("@ai-sdk/provider");
|
|
669
669
|
var z4 = __toESM(require("zod/v4"));
|
|
670
670
|
|
|
671
|
+
// src/add-additional-properties-to-json-schema.ts
|
|
672
|
+
function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
|
|
673
|
+
if (jsonSchema2.type === "object") {
|
|
674
|
+
jsonSchema2.additionalProperties = false;
|
|
675
|
+
const properties = jsonSchema2.properties;
|
|
676
|
+
if (properties != null) {
|
|
677
|
+
for (const property in properties) {
|
|
678
|
+
properties[property] = addAdditionalPropertiesToJsonSchema(
|
|
679
|
+
properties[property]
|
|
680
|
+
);
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (jsonSchema2.type === "array" && jsonSchema2.items != null) {
|
|
685
|
+
if (Array.isArray(jsonSchema2.items)) {
|
|
686
|
+
jsonSchema2.items = jsonSchema2.items.map(
|
|
687
|
+
(item) => addAdditionalPropertiesToJsonSchema(item)
|
|
688
|
+
);
|
|
689
|
+
} else {
|
|
690
|
+
jsonSchema2.items = addAdditionalPropertiesToJsonSchema(
|
|
691
|
+
jsonSchema2.items
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
return jsonSchema2;
|
|
696
|
+
}
|
|
697
|
+
|
|
671
698
|
// src/to-json-schema/arktype-to-json-schema.ts
|
|
672
699
|
var arktypeToJsonSchema = (schema) => () => {
|
|
673
700
|
return schema.toJsonSchema();
|
|
@@ -1977,11 +2004,13 @@ function zod4Schema(zodSchema2, options) {
|
|
|
1977
2004
|
const useReferences = (_a = options == null ? void 0 : options.useReferences) != null ? _a : false;
|
|
1978
2005
|
return jsonSchema(
|
|
1979
2006
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
1980
|
-
() =>
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
2007
|
+
() => addAdditionalPropertiesToJsonSchema(
|
|
2008
|
+
z4.toJSONSchema(zodSchema2, {
|
|
2009
|
+
target: "draft-7",
|
|
2010
|
+
io: "input",
|
|
2011
|
+
reused: useReferences ? "ref" : "inline"
|
|
2012
|
+
})
|
|
2013
|
+
),
|
|
1985
2014
|
{
|
|
1986
2015
|
validate: async (value) => {
|
|
1987
2016
|
const result = await z4.safeParseAsync(zodSchema2, value);
|