@ai-sdk/provider-utils 4.0.0-beta.51 → 4.0.0-beta.53
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 +13 -0
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +18 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -76
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @ai-sdk/provider-utils
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.53
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [366f50b]
|
|
8
|
+
- @ai-sdk/provider@3.0.0-beta.27
|
|
9
|
+
|
|
10
|
+
## 4.0.0-beta.52
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 763d04a: feat: Standard JSON Schema support
|
|
15
|
+
|
|
3
16
|
## 4.0.0-beta.51
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
|
|
2
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
export * from '@standard-schema/spec';
|
|
4
4
|
import * as z3 from 'zod/v3';
|
|
5
5
|
import * as z4 from 'zod/v4';
|
|
@@ -164,8 +164,10 @@ type Schema<OBJECT = unknown> = {
|
|
|
164
164
|
*/
|
|
165
165
|
declare function lazySchema<SCHEMA>(createSchema: () => Schema<SCHEMA>): LazySchema<SCHEMA>;
|
|
166
166
|
type LazySchema<SCHEMA> = () => Schema<SCHEMA>;
|
|
167
|
-
type
|
|
168
|
-
type
|
|
167
|
+
type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | z4.core.$ZodType<SCHEMA, any>;
|
|
168
|
+
type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & StandardJSONSchemaV1<unknown, SCHEMA>;
|
|
169
|
+
type FlexibleSchema<SCHEMA = any> = Schema<SCHEMA> | LazySchema<SCHEMA> | ZodSchema<SCHEMA> | StandardSchema<SCHEMA>;
|
|
170
|
+
type InferSchema<SCHEMA> = SCHEMA extends ZodSchema<infer T> ? T : SCHEMA extends StandardSchema<infer T> ? T : SCHEMA extends LazySchema<infer T> ? T : SCHEMA extends Schema<infer T> ? T : never;
|
|
169
171
|
/**
|
|
170
172
|
* Create a schema using a JSON Schema.
|
|
171
173
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LanguageModelV3FunctionTool, LanguageModelV3ProviderTool, JSONSchema7, JSONParseError, TypeValidationError, JSONValue, APICallError, LanguageModelV3Prompt, SharedV3ProviderOptions } from '@ai-sdk/provider';
|
|
2
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
|
+
import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
3
3
|
export * from '@standard-schema/spec';
|
|
4
4
|
import * as z3 from 'zod/v3';
|
|
5
5
|
import * as z4 from 'zod/v4';
|
|
@@ -164,8 +164,10 @@ type Schema<OBJECT = unknown> = {
|
|
|
164
164
|
*/
|
|
165
165
|
declare function lazySchema<SCHEMA>(createSchema: () => Schema<SCHEMA>): LazySchema<SCHEMA>;
|
|
166
166
|
type LazySchema<SCHEMA> = () => Schema<SCHEMA>;
|
|
167
|
-
type
|
|
168
|
-
type
|
|
167
|
+
type ZodSchema<SCHEMA = any> = z3.Schema<SCHEMA, z3.ZodTypeDef, any> | z4.core.$ZodType<SCHEMA, any>;
|
|
168
|
+
type StandardSchema<SCHEMA = any> = StandardSchemaV1<unknown, SCHEMA> & StandardJSONSchemaV1<unknown, SCHEMA>;
|
|
169
|
+
type FlexibleSchema<SCHEMA = any> = Schema<SCHEMA> | LazySchema<SCHEMA> | ZodSchema<SCHEMA> | StandardSchema<SCHEMA>;
|
|
170
|
+
type InferSchema<SCHEMA> = SCHEMA extends ZodSchema<infer T> ? T : SCHEMA extends StandardSchema<infer T> ? T : SCHEMA extends LazySchema<infer T> ? T : SCHEMA extends Schema<infer T> ? T : never;
|
|
169
171
|
/**
|
|
170
172
|
* Create a schema using a JSON Schema.
|
|
171
173
|
*
|
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.53" : "0.0.0-test";
|
|
382
382
|
|
|
383
383
|
// src/get-from-api.ts
|
|
384
384
|
var getOriginalFetch = () => globalThis.fetch;
|
|
@@ -695,33 +695,6 @@ function addAdditionalPropertiesToJsonSchema(jsonSchema2) {
|
|
|
695
695
|
return jsonSchema2;
|
|
696
696
|
}
|
|
697
697
|
|
|
698
|
-
// src/to-json-schema/arktype-to-json-schema.ts
|
|
699
|
-
var arktypeToJsonSchema = (schema) => () => {
|
|
700
|
-
return schema.toJsonSchema();
|
|
701
|
-
};
|
|
702
|
-
|
|
703
|
-
// src/to-json-schema/effect-to-json-schema.ts
|
|
704
|
-
var effectToJsonSchema = (schema) => async () => {
|
|
705
|
-
try {
|
|
706
|
-
const { JSONSchema } = await import("effect");
|
|
707
|
-
return JSONSchema.make(schema);
|
|
708
|
-
} catch (e) {
|
|
709
|
-
throw new Error(`Failed to import module 'effect'`);
|
|
710
|
-
}
|
|
711
|
-
};
|
|
712
|
-
|
|
713
|
-
// src/to-json-schema/valibot-to-json-schema.ts
|
|
714
|
-
var valibotToJsonSchema = (schema) => {
|
|
715
|
-
return async () => {
|
|
716
|
-
try {
|
|
717
|
-
const { toJsonSchema } = await import("@valibot/to-json-schema");
|
|
718
|
-
return toJsonSchema(schema);
|
|
719
|
-
} catch (e) {
|
|
720
|
-
throw new Error(`Failed to import module '@valibot/to-json-schema'`);
|
|
721
|
-
}
|
|
722
|
-
};
|
|
723
|
-
};
|
|
724
|
-
|
|
725
698
|
// src/to-json-schema/zod3-to-json-schema/options.ts
|
|
726
699
|
var ignoreOverride = Symbol(
|
|
727
700
|
"Let zodToJsonSchema decide on which parser to use"
|
|
@@ -1931,57 +1904,26 @@ function isSchema(value) {
|
|
|
1931
1904
|
return typeof value === "object" && value !== null && schemaSymbol in value && value[schemaSymbol] === true && "jsonSchema" in value && "validate" in value;
|
|
1932
1905
|
}
|
|
1933
1906
|
function asSchema(schema) {
|
|
1934
|
-
return schema == null ? jsonSchema({
|
|
1935
|
-
properties: {},
|
|
1936
|
-
additionalProperties: false
|
|
1937
|
-
}) : isSchema(schema) ? schema : "~standard" in schema ? standardSchema(schema) : schema();
|
|
1907
|
+
return schema == null ? jsonSchema({ properties: {}, additionalProperties: false }) : isSchema(schema) ? schema : "~standard" in schema ? schema["~standard"].vendor === "zod" ? zodSchema(schema) : standardSchema(schema) : schema();
|
|
1938
1908
|
}
|
|
1939
1909
|
function standardSchema(standardSchema2) {
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
)
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
standardSchema2,
|
|
1956
|
-
effectToJsonSchema
|
|
1957
|
-
);
|
|
1958
|
-
}
|
|
1959
|
-
case "valibot": {
|
|
1960
|
-
return standardSchemaWithJsonSchemaResolver(
|
|
1961
|
-
standardSchema2,
|
|
1962
|
-
valibotToJsonSchema
|
|
1963
|
-
);
|
|
1964
|
-
}
|
|
1965
|
-
default: {
|
|
1966
|
-
return standardSchemaWithJsonSchemaResolver(standardSchema2, () => () => {
|
|
1967
|
-
throw new Error(`Unsupported standard schema vendor: ${vendor}`);
|
|
1968
|
-
});
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
function standardSchemaWithJsonSchemaResolver(standardSchema2, jsonSchemaResolver) {
|
|
1973
|
-
return jsonSchema(jsonSchemaResolver(standardSchema2), {
|
|
1974
|
-
validate: async (value) => {
|
|
1975
|
-
const result = await standardSchema2["~standard"].validate(value);
|
|
1976
|
-
return "value" in result ? { success: true, value: result.value } : {
|
|
1977
|
-
success: false,
|
|
1978
|
-
error: new import_provider6.TypeValidationError({
|
|
1979
|
-
value,
|
|
1980
|
-
cause: result.issues
|
|
1981
|
-
})
|
|
1982
|
-
};
|
|
1910
|
+
return jsonSchema(
|
|
1911
|
+
() => standardSchema2["~standard"].jsonSchema.input({
|
|
1912
|
+
target: "draft-07"
|
|
1913
|
+
}),
|
|
1914
|
+
{
|
|
1915
|
+
validate: async (value) => {
|
|
1916
|
+
const result = await standardSchema2["~standard"].validate(value);
|
|
1917
|
+
return "value" in result ? { success: true, value: result.value } : {
|
|
1918
|
+
success: false,
|
|
1919
|
+
error: new import_provider6.TypeValidationError({
|
|
1920
|
+
value,
|
|
1921
|
+
cause: result.issues
|
|
1922
|
+
})
|
|
1923
|
+
};
|
|
1924
|
+
}
|
|
1983
1925
|
}
|
|
1984
|
-
|
|
1926
|
+
);
|
|
1985
1927
|
}
|
|
1986
1928
|
function zod3Schema(zodSchema2, options) {
|
|
1987
1929
|
var _a;
|