@ai-sdk/provider-utils 4.0.8 → 4.0.10

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/index.js +29 -1
  3. package/dist/index.js.map +1 -1
  4. package/dist/index.mjs +29 -1
  5. package/dist/index.mjs.map +1 -1
  6. package/package.json +6 -2
  7. package/src/handle-fetch-error.ts +33 -0
  8. package/src/__snapshots__/schema.test.ts.snap +0 -346
  9. package/src/add-additional-properties-to-json-schema.test.ts +0 -289
  10. package/src/convert-async-iterator-to-readable-stream.test.ts +0 -78
  11. package/src/convert-image-model-file-to-data-uri.test.ts +0 -85
  12. package/src/convert-to-form-data.test.ts +0 -167
  13. package/src/create-tool-name-mapping.test.ts +0 -163
  14. package/src/delay.test.ts +0 -212
  15. package/src/delayed-promise.test.ts +0 -132
  16. package/src/download-blob.test.ts +0 -145
  17. package/src/generate-id.test.ts +0 -31
  18. package/src/get-from-api.test.ts +0 -199
  19. package/src/get-runtime-environment-user-agent.test.ts +0 -47
  20. package/src/inject-json-instruction.test.ts +0 -404
  21. package/src/is-url-supported.test.ts +0 -282
  22. package/src/media-type-to-extension.test.ts +0 -26
  23. package/src/normalize-headers.test.ts +0 -64
  24. package/src/parse-json.test.ts +0 -191
  25. package/src/remove-undefined-entries.test.ts +0 -57
  26. package/src/resolve.test.ts +0 -125
  27. package/src/response-handler.test.ts +0 -89
  28. package/src/schema.test-d.ts +0 -11
  29. package/src/schema.test.ts +0 -502
  30. package/src/secure-json-parse.test.ts +0 -59
  31. package/src/to-json-schema/zod3-to-json-schema/parse-def.test.ts +0 -224
  32. package/src/to-json-schema/zod3-to-json-schema/parsers/array.test.ts +0 -98
  33. package/src/to-json-schema/zod3-to-json-schema/parsers/bigint.test.ts +0 -51
  34. package/src/to-json-schema/zod3-to-json-schema/parsers/branded.test.ts +0 -16
  35. package/src/to-json-schema/zod3-to-json-schema/parsers/catch.test.ts +0 -15
  36. package/src/to-json-schema/zod3-to-json-schema/parsers/date.test.ts +0 -97
  37. package/src/to-json-schema/zod3-to-json-schema/parsers/default.test.ts +0 -54
  38. package/src/to-json-schema/zod3-to-json-schema/parsers/effects.test.ts +0 -41
  39. package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.test.ts +0 -92
  40. package/src/to-json-schema/zod3-to-json-schema/parsers/map.test.ts +0 -48
  41. package/src/to-json-schema/zod3-to-json-schema/parsers/native-enum.test.ts +0 -102
  42. package/src/to-json-schema/zod3-to-json-schema/parsers/nullable.test.ts +0 -67
  43. package/src/to-json-schema/zod3-to-json-schema/parsers/number.test.ts +0 -65
  44. package/src/to-json-schema/zod3-to-json-schema/parsers/object.test.ts +0 -149
  45. package/src/to-json-schema/zod3-to-json-schema/parsers/optional.test.ts +0 -147
  46. package/src/to-json-schema/zod3-to-json-schema/parsers/pipe.test.ts +0 -35
  47. package/src/to-json-schema/zod3-to-json-schema/parsers/promise.test.ts +0 -15
  48. package/src/to-json-schema/zod3-to-json-schema/parsers/readonly.test.ts +0 -20
  49. package/src/to-json-schema/zod3-to-json-schema/parsers/record.test.ts +0 -108
  50. package/src/to-json-schema/zod3-to-json-schema/parsers/set.test.ts +0 -20
  51. package/src/to-json-schema/zod3-to-json-schema/parsers/string.test.ts +0 -438
  52. package/src/to-json-schema/zod3-to-json-schema/parsers/tuple.test.ts +0 -33
  53. package/src/to-json-schema/zod3-to-json-schema/parsers/union.test.ts +0 -226
  54. package/src/to-json-schema/zod3-to-json-schema/refs.test.ts +0 -919
  55. package/src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.test.ts +0 -862
  56. package/src/types/tool.test-d.ts +0 -228
  57. package/src/validate-types.test.ts +0 -105
  58. package/src/with-user-agent-suffix.test.ts +0 -84
@@ -1,48 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parseMapDef } from './map';
4
- import { getRefs } from '../refs';
5
- import { JSONSchema7 } from '@ai-sdk/provider';
6
-
7
- describe('map', () => {
8
- it('should be possible to use Map', () => {
9
- const mapSchema = z.map(z.string(), z.number());
10
-
11
- const parsedSchema = parseMapDef(mapSchema._def, getRefs());
12
-
13
- expect(parsedSchema).toStrictEqual({
14
- type: 'array',
15
- maxItems: 125,
16
- items: {
17
- type: 'array',
18
- items: [
19
- {
20
- type: 'string',
21
- },
22
- {
23
- type: 'number',
24
- },
25
- ],
26
- minItems: 2,
27
- maxItems: 2,
28
- },
29
- } satisfies JSONSchema7);
30
- });
31
-
32
- it('should be possible to use additionalProperties-pattern (record)', () => {
33
- expect(
34
- parseMapDef(
35
- z.map(z.string().min(1), z.number())._def,
36
- getRefs({ mapStrategy: 'record' }),
37
- ),
38
- ).toStrictEqual({
39
- type: 'object',
40
- additionalProperties: {
41
- type: 'number',
42
- },
43
- propertyNames: {
44
- minLength: 1,
45
- },
46
- } satisfies JSONSchema7);
47
- });
48
- });
@@ -1,102 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parseNativeEnumDef } from './native-enum';
4
- import { JSONSchema7 } from '@ai-sdk/provider';
5
-
6
- describe('native enum', () => {
7
- it('should be possible to convert a basic native number enum', () => {
8
- enum MyEnum {
9
- val1,
10
- val2,
11
- val3,
12
- }
13
-
14
- const parsedSchema = parseNativeEnumDef(z.nativeEnum(MyEnum)._def);
15
-
16
- expect(parsedSchema).toStrictEqual({
17
- type: 'number',
18
- enum: [0, 1, 2],
19
- } satisfies JSONSchema7);
20
- });
21
-
22
- it('should be possible to convert a native string enum', () => {
23
- enum MyEnum {
24
- val1 = 'a',
25
- val2 = 'b',
26
- val3 = 'c',
27
- }
28
-
29
- const parsedSchema = parseNativeEnumDef(z.nativeEnum(MyEnum)._def);
30
-
31
- expect(parsedSchema).toStrictEqual({
32
- type: 'string',
33
- enum: ['a', 'b', 'c'],
34
- } satisfies JSONSchema7);
35
- });
36
-
37
- it('should be possible to convert a mixed value native enum', () => {
38
- enum MyEnum {
39
- val1 = 'a',
40
- val2 = 1,
41
- val3 = 'c',
42
- }
43
-
44
- const parsedSchema = parseNativeEnumDef(z.nativeEnum(MyEnum)._def);
45
-
46
- expect(parsedSchema).toStrictEqual({
47
- type: ['string', 'number'],
48
- enum: ['a', 1, 'c'],
49
- } satisfies JSONSchema7);
50
- });
51
-
52
- it('should be possible to convert a native const assertion object', () => {
53
- const MyConstAssertionObject = {
54
- val1: 0,
55
- val2: 1,
56
- val3: 2,
57
- } as const;
58
-
59
- const parsedSchema = parseNativeEnumDef(
60
- z.nativeEnum(MyConstAssertionObject)._def,
61
- );
62
-
63
- expect(parsedSchema).toStrictEqual({
64
- type: 'number',
65
- enum: [0, 1, 2],
66
- } satisfies JSONSchema7);
67
- });
68
-
69
- it('should be possible to convert a native const assertion string object', () => {
70
- const MyConstAssertionObject = {
71
- val1: 'a',
72
- val2: 'b',
73
- val3: 'c',
74
- } as const;
75
-
76
- const parsedSchema = parseNativeEnumDef(
77
- z.nativeEnum(MyConstAssertionObject)._def,
78
- );
79
-
80
- expect(parsedSchema).toStrictEqual({
81
- type: 'string',
82
- enum: ['a', 'b', 'c'],
83
- } satisfies JSONSchema7);
84
- });
85
-
86
- it('should be possible to convert a mixed value native const assertion string object', () => {
87
- const MyConstAssertionObject = {
88
- val1: 'a',
89
- val2: 1,
90
- val3: 'c',
91
- } as const;
92
-
93
- const parsedSchema = parseNativeEnumDef(
94
- z.nativeEnum(MyConstAssertionObject)._def,
95
- );
96
-
97
- expect(parsedSchema).toStrictEqual({
98
- type: ['string', 'number'],
99
- enum: ['a', 1, 'c'],
100
- } satisfies JSONSchema7);
101
- });
102
- });
@@ -1,67 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parseObjectDef } from './object';
4
- import { getRefs } from '../refs';
5
- import { JSONSchema7 } from '@ai-sdk/provider';
6
-
7
- describe('nullable', () => {
8
- it('should be possible to properly reference nested nullable primitives', () => {
9
- const nullablePrimitive = z.string().nullable();
10
-
11
- const schema = z.object({
12
- one: nullablePrimitive,
13
- two: nullablePrimitive,
14
- });
15
-
16
- const jsonSchema: any = parseObjectDef(schema._def, getRefs());
17
-
18
- expect(jsonSchema).toStrictEqual({
19
- additionalProperties: false,
20
- type: 'object',
21
- properties: {
22
- one: { type: ['string', 'null'] },
23
- two: { $ref: '#/properties/one' },
24
- },
25
- required: ['one', 'two'],
26
- } satisfies JSONSchema7);
27
- });
28
-
29
- it('should be possible to properly reference nested nullable primitives', () => {
30
- const three = z.string();
31
-
32
- const nullableObject = z
33
- .object({
34
- three,
35
- })
36
- .nullable();
37
-
38
- const schema = z.object({
39
- one: nullableObject,
40
- two: nullableObject,
41
- three,
42
- });
43
-
44
- const jsonSchema: any = parseObjectDef(schema._def, getRefs());
45
-
46
- expect(jsonSchema).toStrictEqual({
47
- type: 'object',
48
- properties: {
49
- one: {
50
- anyOf: [
51
- {
52
- type: 'object',
53
- additionalProperties: false,
54
- required: ['three'],
55
- properties: { three: { type: 'string' } },
56
- },
57
- { type: 'null' },
58
- ],
59
- },
60
- two: { $ref: '#/properties/one' },
61
- three: { $ref: '#/properties/one/anyOf/0/properties/three' },
62
- },
63
- required: ['one', 'two', 'three'],
64
- additionalProperties: false,
65
- } satisfies JSONSchema7);
66
- });
67
- });
@@ -1,65 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { JSONSchema7 } from '@ai-sdk/provider';
3
- import { z } from 'zod/v3';
4
- import { parseNumberDef } from './number';
5
-
6
- describe('number', () => {
7
- it('should be possible to describe minimum number', () => {
8
- const parsedSchema = parseNumberDef(z.number().min(5)._def);
9
-
10
- expect(parsedSchema).toStrictEqual({
11
- type: 'number',
12
- minimum: 5,
13
- } satisfies JSONSchema7);
14
- });
15
-
16
- it('should be possible to describe maximum number', () => {
17
- const parsedSchema = parseNumberDef(z.number().max(5)._def);
18
-
19
- expect(parsedSchema).toStrictEqual({
20
- type: 'number',
21
- maximum: 5,
22
- } satisfies JSONSchema7);
23
- });
24
-
25
- it('should be possible to describe both minimum and maximum number', () => {
26
- const parsedSchema = parseNumberDef(z.number().min(5).max(5)._def);
27
-
28
- expect(parsedSchema).toStrictEqual({
29
- type: 'number',
30
- minimum: 5,
31
- maximum: 5,
32
- } satisfies JSONSchema7);
33
- });
34
-
35
- it('should be possible to describe an integer', () => {
36
- const parsedSchema = parseNumberDef(z.number().int()._def);
37
-
38
- expect(parsedSchema).toStrictEqual({
39
- type: 'integer',
40
- } satisfies JSONSchema7);
41
- });
42
-
43
- it('should be possible to describe multiples of n', () => {
44
- const parsedSchema = parseNumberDef(z.number().multipleOf(2)._def);
45
-
46
- expect(parsedSchema).toStrictEqual({
47
- type: 'number',
48
- multipleOf: 2,
49
- } satisfies JSONSchema7);
50
- });
51
-
52
- it('should be possible to describe positive, negative, nonpositive and nonnegative numbers', () => {
53
- const parsedSchema = parseNumberDef(
54
- z.number().positive().negative().nonpositive().nonnegative()._def,
55
- );
56
-
57
- expect(parsedSchema).toStrictEqual({
58
- type: 'number',
59
- minimum: 0,
60
- maximum: 0,
61
- exclusiveMaximum: 0,
62
- exclusiveMinimum: 0,
63
- } satisfies JSONSchema7);
64
- });
65
- });
@@ -1,149 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parseObjectDef } from './object';
4
- import { getRefs } from '../refs';
5
- import { JSONSchema7 } from '@ai-sdk/provider';
6
-
7
- describe('object', () => {
8
- it('should be possible to describe catchAll schema', () => {
9
- const schema = z
10
- .object({ normalProperty: z.string() })
11
- .catchall(z.boolean());
12
-
13
- const parsedSchema = parseObjectDef(schema._def, getRefs());
14
-
15
- expect(parsedSchema).toStrictEqual({
16
- type: 'object',
17
- properties: {
18
- normalProperty: { type: 'string' },
19
- },
20
- required: ['normalProperty'],
21
- additionalProperties: {
22
- type: 'boolean',
23
- },
24
- } satisfies JSONSchema7);
25
- });
26
-
27
- it('should be possible to use selective partial', () => {
28
- const schema = z
29
- .object({ foo: z.boolean(), bar: z.number() })
30
- .partial({ foo: true });
31
-
32
- const parsedSchema = parseObjectDef(schema._def, getRefs());
33
-
34
- expect(parsedSchema).toStrictEqual({
35
- type: 'object',
36
- properties: {
37
- foo: { type: 'boolean' },
38
- bar: { type: 'number' },
39
- },
40
- required: ['bar'],
41
- additionalProperties: false,
42
- } satisfies JSONSchema7);
43
- });
44
-
45
- it('should allow additional properties unless strict when removeAdditionalStrategy is strict', () => {
46
- const schema = z.object({ foo: z.boolean(), bar: z.number() });
47
-
48
- const parsedSchema = parseObjectDef(
49
- schema._def,
50
- getRefs({ removeAdditionalStrategy: 'strict' }),
51
- );
52
-
53
- expect(parsedSchema).toStrictEqual({
54
- type: 'object',
55
- properties: {
56
- foo: { type: 'boolean' },
57
- bar: { type: 'number' },
58
- },
59
- required: ['foo', 'bar'],
60
- additionalProperties: true,
61
- } satisfies JSONSchema7);
62
-
63
- const strictSchema = z
64
- .object({ foo: z.boolean(), bar: z.number() })
65
- .strict();
66
-
67
- const parsedStrictSchema = parseObjectDef(
68
- strictSchema._def,
69
- getRefs({ removeAdditionalStrategy: 'strict' }),
70
- );
71
-
72
- expect(parsedStrictSchema).toStrictEqual({
73
- type: 'object',
74
- properties: {
75
- foo: { type: 'boolean' },
76
- bar: { type: 'number' },
77
- },
78
- required: ['foo', 'bar'],
79
- additionalProperties: false,
80
- } satisfies JSONSchema7);
81
- });
82
-
83
- it('should allow additional properties with catchall when removeAdditionalStrategy is strict', () => {
84
- const schema = z
85
- .object({ foo: z.boolean(), bar: z.number() })
86
- .catchall(z.boolean());
87
-
88
- const parsedSchema = parseObjectDef(
89
- schema._def,
90
- getRefs({ removeAdditionalStrategy: 'strict' }),
91
- );
92
-
93
- expect(parsedSchema).toStrictEqual({
94
- type: 'object',
95
- properties: {
96
- foo: { type: 'boolean' },
97
- bar: { type: 'number' },
98
- },
99
- required: ['foo', 'bar'],
100
- additionalProperties: {
101
- type: 'boolean',
102
- },
103
- } satisfies JSONSchema7);
104
- });
105
-
106
- it('should be possible to not set additionalProperties at all when allowed', () => {
107
- const schema = z
108
- .object({ foo: z.boolean(), bar: z.number() })
109
- .passthrough();
110
-
111
- const parsedSchema = parseObjectDef(
112
- schema._def,
113
- getRefs({
114
- removeAdditionalStrategy: 'passthrough',
115
- allowedAdditionalProperties: undefined,
116
- }),
117
- );
118
-
119
- expect(parsedSchema).toStrictEqual({
120
- type: 'object',
121
- properties: {
122
- foo: { type: 'boolean' },
123
- bar: { type: 'number' },
124
- },
125
- required: ['foo', 'bar'],
126
- } satisfies JSONSchema7);
127
- });
128
-
129
- it('should be possible to not set additionalProperties at all when rejected', () => {
130
- const schema = z.object({ foo: z.boolean(), bar: z.number() }).strict();
131
-
132
- const parsedSchema = parseObjectDef(
133
- schema._def,
134
- getRefs({
135
- removeAdditionalStrategy: 'passthrough',
136
- rejectedAdditionalProperties: undefined,
137
- }),
138
- );
139
-
140
- expect(parsedSchema).toStrictEqual({
141
- type: 'object',
142
- properties: {
143
- foo: { type: 'boolean' },
144
- bar: { type: 'number' },
145
- },
146
- required: ['foo', 'bar'],
147
- } satisfies JSONSchema7);
148
- });
149
- });
@@ -1,147 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parseDef } from '../parse-def';
4
- import { getRefs } from '../refs';
5
- import { JSONSchema7 } from '@ai-sdk/provider';
6
-
7
- describe('Standalone optionals', () => {
8
- it('should work as unions with undefined', () => {
9
- const parsedSchema = parseDef(z.string().optional()._def, getRefs());
10
-
11
- expect(parsedSchema).toStrictEqual({
12
- anyOf: [
13
- {
14
- not: {},
15
- },
16
- {
17
- type: 'string',
18
- },
19
- ],
20
- } satisfies JSONSchema7);
21
- });
22
-
23
- it('should work as unions with void', () => {
24
- const parsedSchema = parseDef(z.void().optional()._def, getRefs());
25
-
26
- expect(parsedSchema).toStrictEqual({} satisfies JSONSchema7);
27
- });
28
-
29
- it('should not affect object properties', () => {
30
- const parsedSchema = parseDef(
31
- z.object({ myProperty: z.string().optional() })._def,
32
- getRefs(),
33
- );
34
-
35
- expect(parsedSchema).toStrictEqual({
36
- type: 'object',
37
- properties: {
38
- myProperty: {
39
- type: 'string',
40
- },
41
- },
42
- additionalProperties: false,
43
- } satisfies JSONSchema7);
44
- });
45
-
46
- it('should work with nested properties', () => {
47
- const parsedSchema = parseDef(
48
- z.object({ myProperty: z.string().optional().array() })._def,
49
- getRefs(),
50
- );
51
-
52
- expect(parsedSchema).toStrictEqual({
53
- type: 'object',
54
- properties: {
55
- myProperty: {
56
- type: 'array',
57
- items: {
58
- anyOf: [{ not: {} }, { type: 'string' }],
59
- },
60
- },
61
- },
62
- required: ['myProperty'],
63
- additionalProperties: false,
64
- } satisfies JSONSchema7);
65
- });
66
-
67
- it('should work with nested properties as object properties', () => {
68
- const parsedSchema = parseDef(
69
- z.object({
70
- myProperty: z.object({ myInnerProperty: z.string().optional() }),
71
- })._def,
72
- getRefs(),
73
- );
74
-
75
- expect(parsedSchema).toStrictEqual({
76
- type: 'object',
77
- properties: {
78
- myProperty: {
79
- type: 'object',
80
- properties: {
81
- myInnerProperty: {
82
- type: 'string',
83
- },
84
- },
85
- additionalProperties: false,
86
- },
87
- },
88
- required: ['myProperty'],
89
- additionalProperties: false,
90
- } satisfies JSONSchema7);
91
- });
92
-
93
- it('should work with nested properties with nested object property parents', () => {
94
- const parsedSchema = parseDef(
95
- z.object({
96
- myProperty: z.object({
97
- myInnerProperty: z.string().optional().array(),
98
- }),
99
- })._def,
100
- getRefs(),
101
- );
102
-
103
- expect(parsedSchema).toStrictEqual({
104
- type: 'object',
105
- properties: {
106
- myProperty: {
107
- type: 'object',
108
- properties: {
109
- myInnerProperty: {
110
- type: 'array',
111
- items: {
112
- anyOf: [
113
- { not: {} },
114
- {
115
- type: 'string',
116
- },
117
- ],
118
- },
119
- },
120
- },
121
- required: ['myInnerProperty'],
122
- additionalProperties: false,
123
- },
124
- },
125
- required: ['myProperty'],
126
- additionalProperties: false,
127
- } satisfies JSONSchema7);
128
- });
129
-
130
- it('should work with ref pathing', () => {
131
- const recurring = z.string();
132
-
133
- const schema = z.tuple([recurring.optional(), recurring]);
134
-
135
- const parsedSchema = parseDef(schema._def, getRefs());
136
-
137
- expect(parsedSchema).toStrictEqual({
138
- type: 'array',
139
- minItems: 2,
140
- maxItems: 2,
141
- items: [
142
- { anyOf: [{ not: {} }, { type: 'string' }] },
143
- { $ref: '#/items/0/anyOf/1' },
144
- ],
145
- } satisfies JSONSchema7);
146
- });
147
- });
@@ -1,35 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parsePipelineDef } from './pipeline';
4
- import { getRefs } from '../refs';
5
- import { JSONSchema7 } from '@ai-sdk/provider';
6
-
7
- describe('pipe', () => {
8
- it('Should create an allOf schema with all its inner schemas represented', () => {
9
- const schema = z.number().pipe(z.number().int());
10
-
11
- expect(parsePipelineDef(schema._def, getRefs())).toStrictEqual({
12
- allOf: [{ type: 'number' }, { type: 'integer' }],
13
- } satisfies JSONSchema7);
14
- });
15
-
16
- it('Should parse the input schema if that strategy is selected', () => {
17
- const schema = z.number().pipe(z.number().int());
18
-
19
- expect(
20
- parsePipelineDef(schema._def, getRefs({ pipeStrategy: 'input' })),
21
- ).toStrictEqual({
22
- type: 'number',
23
- } satisfies JSONSchema7);
24
- });
25
-
26
- it('Should parse the output schema (last schema in pipe) if that strategy is selected', () => {
27
- const schema = z.string().pipe(z.date()).pipe(z.number().int());
28
-
29
- expect(
30
- parsePipelineDef(schema._def, getRefs({ pipeStrategy: 'output' })),
31
- ).toStrictEqual({
32
- type: 'integer',
33
- } satisfies JSONSchema7);
34
- });
35
- });
@@ -1,15 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parsePromiseDef } from './promise';
4
- import { getRefs } from '../refs';
5
- import { JSONSchema7 } from '@ai-sdk/provider';
6
-
7
- describe('promise', () => {
8
- it('should be possible to use promise', () => {
9
- const parsedSchema = parsePromiseDef(z.promise(z.string())._def, getRefs());
10
-
11
- expect(parsedSchema).toStrictEqual({
12
- type: 'string',
13
- } satisfies JSONSchema7);
14
- });
15
- });
@@ -1,20 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parseReadonlyDef } from './readonly';
4
- import { getRefs } from '../refs';
5
- import { JSONSchema7 } from '@ai-sdk/provider';
6
-
7
- describe('readonly', () => {
8
- it('should be possible to use readonly', () => {
9
- const parsedSchema = parseReadonlyDef(
10
- z.object({}).readonly()._def,
11
- getRefs(),
12
- );
13
-
14
- expect(parsedSchema).toStrictEqual({
15
- type: 'object',
16
- properties: {},
17
- additionalProperties: false,
18
- } satisfies JSONSchema7);
19
- });
20
- });