@ai-sdk/provider-utils 4.0.7 → 4.0.9

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 (55) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/index.js +1 -1
  3. package/dist/index.mjs +1 -1
  4. package/package.json +6 -2
  5. package/src/__snapshots__/schema.test.ts.snap +0 -346
  6. package/src/add-additional-properties-to-json-schema.test.ts +0 -289
  7. package/src/convert-async-iterator-to-readable-stream.test.ts +0 -78
  8. package/src/convert-image-model-file-to-data-uri.test.ts +0 -85
  9. package/src/convert-to-form-data.test.ts +0 -167
  10. package/src/create-tool-name-mapping.test.ts +0 -163
  11. package/src/delay.test.ts +0 -212
  12. package/src/delayed-promise.test.ts +0 -132
  13. package/src/download-blob.test.ts +0 -145
  14. package/src/generate-id.test.ts +0 -31
  15. package/src/get-from-api.test.ts +0 -199
  16. package/src/get-runtime-environment-user-agent.test.ts +0 -47
  17. package/src/inject-json-instruction.test.ts +0 -404
  18. package/src/is-url-supported.test.ts +0 -282
  19. package/src/media-type-to-extension.test.ts +0 -26
  20. package/src/normalize-headers.test.ts +0 -64
  21. package/src/parse-json.test.ts +0 -191
  22. package/src/remove-undefined-entries.test.ts +0 -57
  23. package/src/resolve.test.ts +0 -125
  24. package/src/response-handler.test.ts +0 -89
  25. package/src/schema.test-d.ts +0 -11
  26. package/src/schema.test.ts +0 -502
  27. package/src/secure-json-parse.test.ts +0 -59
  28. package/src/to-json-schema/zod3-to-json-schema/parse-def.test.ts +0 -224
  29. package/src/to-json-schema/zod3-to-json-schema/parsers/array.test.ts +0 -98
  30. package/src/to-json-schema/zod3-to-json-schema/parsers/bigint.test.ts +0 -51
  31. package/src/to-json-schema/zod3-to-json-schema/parsers/branded.test.ts +0 -16
  32. package/src/to-json-schema/zod3-to-json-schema/parsers/catch.test.ts +0 -15
  33. package/src/to-json-schema/zod3-to-json-schema/parsers/date.test.ts +0 -97
  34. package/src/to-json-schema/zod3-to-json-schema/parsers/default.test.ts +0 -54
  35. package/src/to-json-schema/zod3-to-json-schema/parsers/effects.test.ts +0 -41
  36. package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.test.ts +0 -92
  37. package/src/to-json-schema/zod3-to-json-schema/parsers/map.test.ts +0 -48
  38. package/src/to-json-schema/zod3-to-json-schema/parsers/native-enum.test.ts +0 -102
  39. package/src/to-json-schema/zod3-to-json-schema/parsers/nullable.test.ts +0 -67
  40. package/src/to-json-schema/zod3-to-json-schema/parsers/number.test.ts +0 -65
  41. package/src/to-json-schema/zod3-to-json-schema/parsers/object.test.ts +0 -149
  42. package/src/to-json-schema/zod3-to-json-schema/parsers/optional.test.ts +0 -147
  43. package/src/to-json-schema/zod3-to-json-schema/parsers/pipe.test.ts +0 -35
  44. package/src/to-json-schema/zod3-to-json-schema/parsers/promise.test.ts +0 -15
  45. package/src/to-json-schema/zod3-to-json-schema/parsers/readonly.test.ts +0 -20
  46. package/src/to-json-schema/zod3-to-json-schema/parsers/record.test.ts +0 -108
  47. package/src/to-json-schema/zod3-to-json-schema/parsers/set.test.ts +0 -20
  48. package/src/to-json-schema/zod3-to-json-schema/parsers/string.test.ts +0 -438
  49. package/src/to-json-schema/zod3-to-json-schema/parsers/tuple.test.ts +0 -33
  50. package/src/to-json-schema/zod3-to-json-schema/parsers/union.test.ts +0 -226
  51. package/src/to-json-schema/zod3-to-json-schema/refs.test.ts +0 -919
  52. package/src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.test.ts +0 -862
  53. package/src/types/tool.test-d.ts +0 -228
  54. package/src/validate-types.test.ts +0 -105
  55. package/src/with-user-agent-suffix.test.ts +0 -84
@@ -1,108 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parseRecordDef } from './record';
4
- import { getRefs } from '../refs';
5
- import { JSONSchema7 } from '@ai-sdk/provider';
6
-
7
- describe('record', () => {
8
- it('should be possible to describe a simple record', () => {
9
- const schema = z.record(z.number());
10
-
11
- const parsedSchema = parseRecordDef(schema._def, getRefs());
12
-
13
- expect(parsedSchema).toStrictEqual({
14
- type: 'object',
15
- additionalProperties: {
16
- type: 'number',
17
- },
18
- } satisfies JSONSchema7);
19
- });
20
- it('should be possible to describe a simple record with a branded key', () => {
21
- const schema = z.record(z.string().brand('MyBrand'), z.number());
22
-
23
- const parsedSchema = parseRecordDef(schema._def, getRefs());
24
-
25
- expect(parsedSchema).toStrictEqual({
26
- type: 'object',
27
- additionalProperties: {
28
- type: 'number',
29
- },
30
- } satisfies JSONSchema7);
31
- });
32
-
33
- it('should be possible to describe a complex record with checks', () => {
34
- const schema = z.record(
35
- z.object({ foo: z.number().min(2) }).catchall(z.string().cuid()),
36
- );
37
-
38
- const parsedSchema = parseRecordDef(schema._def, getRefs());
39
-
40
- expect(parsedSchema).toStrictEqual({
41
- type: 'object',
42
- additionalProperties: {
43
- type: 'object',
44
- properties: {
45
- foo: {
46
- type: 'number',
47
- minimum: 2,
48
- },
49
- },
50
- required: ['foo'],
51
- additionalProperties: {
52
- type: 'string',
53
- pattern: '^[cC][^\\s-]{8,}$',
54
- },
55
- },
56
- } satisfies JSONSchema7);
57
- });
58
-
59
- it('should be possible to describe a key schema', () => {
60
- const schema = z.record(z.string().uuid(), z.number());
61
-
62
- const parsedSchema = parseRecordDef(schema._def, getRefs());
63
-
64
- expect(parsedSchema).toStrictEqual({
65
- type: 'object',
66
- additionalProperties: {
67
- type: 'number',
68
- },
69
- propertyNames: {
70
- format: 'uuid',
71
- },
72
- } satisfies JSONSchema7);
73
- });
74
-
75
- it('should be possible to describe a branded key schema', () => {
76
- const schema = z.record(
77
- z.string().regex(/.+/).brand('MyBrandedThingo'),
78
- z.number(),
79
- );
80
-
81
- const parsedSchema = parseRecordDef(schema._def, getRefs());
82
-
83
- expect(parsedSchema).toStrictEqual({
84
- type: 'object',
85
- additionalProperties: {
86
- type: 'number',
87
- },
88
- propertyNames: {
89
- pattern: '.+',
90
- },
91
- } satisfies JSONSchema7);
92
- });
93
-
94
- it('should be possible to describe a key with an enum', () => {
95
- const schema = z.record(z.enum(['foo', 'bar']), z.number());
96
- const parsedSchema = parseRecordDef(schema._def, getRefs());
97
-
98
- expect(parsedSchema).toStrictEqual({
99
- type: 'object',
100
- additionalProperties: {
101
- type: 'number',
102
- },
103
- propertyNames: {
104
- enum: ['foo', 'bar'],
105
- },
106
- } satisfies JSONSchema7);
107
- });
108
- });
@@ -1,20 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { JSONSchema7 } from '@ai-sdk/provider';
3
- import { z } from 'zod/v3';
4
- import { getRefs } from '../refs';
5
- import { parseSetDef } from './set';
6
-
7
- describe('set', () => {
8
- it('should map set', () => {
9
- const zodSchema = z.set(z.any()).min(5).max(10);
10
- const jsonParsedSchema = parseSetDef(zodSchema._def, getRefs());
11
-
12
- expect(jsonParsedSchema).toStrictEqual({
13
- type: 'array',
14
- minItems: 5,
15
- maxItems: 10,
16
- uniqueItems: true,
17
- items: {},
18
- } satisfies JSONSchema7);
19
- });
20
- });
@@ -1,438 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { JSONSchema7 } from '@ai-sdk/provider';
3
- import { z } from 'zod/v3';
4
- import { getRefs } from '../refs';
5
- import { parseStringDef, zodPatterns } from './string';
6
-
7
- describe('string', () => {
8
- it('should be possible to describe minimum length of a string', () => {
9
- const parsedSchema = parseStringDef(z.string().min(5)._def, getRefs());
10
-
11
- expect(parsedSchema).toStrictEqual({
12
- type: 'string',
13
- minLength: 5,
14
- } satisfies JSONSchema7);
15
- });
16
-
17
- it('should be possible to describe maximum length of a string', () => {
18
- const parsedSchema = parseStringDef(z.string().max(5)._def, getRefs());
19
-
20
- expect(parsedSchema).toStrictEqual({
21
- type: 'string',
22
- maxLength: 5,
23
- } satisfies JSONSchema7);
24
- });
25
-
26
- it('should be possible to describe both minimum and maximum length of a string', () => {
27
- const parsedSchema = parseStringDef(
28
- z.string().min(5).max(5)._def,
29
- getRefs(),
30
- );
31
-
32
- expect(parsedSchema).toStrictEqual({
33
- type: 'string',
34
- minLength: 5,
35
- maxLength: 5,
36
- } satisfies JSONSchema7);
37
- });
38
-
39
- it('should be possible to use email constraint', () => {
40
- const parsedSchema = parseStringDef(z.string().email()._def, getRefs());
41
-
42
- expect(parsedSchema).toStrictEqual({
43
- type: 'string',
44
- format: 'email',
45
- } satisfies JSONSchema7);
46
- });
47
-
48
- it('should be possible to use uuid constraint', () => {
49
- const parsedSchema = parseStringDef(z.string().uuid()._def, getRefs());
50
-
51
- expect(parsedSchema).toStrictEqual({
52
- type: 'string',
53
- format: 'uuid',
54
- } satisfies JSONSchema7);
55
- });
56
- it('should be possible to use url constraint', () => {
57
- const parsedSchema = parseStringDef(z.string().url()._def, getRefs());
58
-
59
- expect(parsedSchema).toStrictEqual({
60
- type: 'string',
61
- format: 'uri',
62
- } satisfies JSONSchema7);
63
- });
64
-
65
- it('should be possible to use regex constraint', () => {
66
- const parsedSchema = parseStringDef(
67
- z.string().regex(/[A-C]/)._def,
68
- getRefs(),
69
- );
70
-
71
- expect(parsedSchema).toStrictEqual({
72
- type: 'string',
73
- pattern: '[A-C]',
74
- } satisfies JSONSchema7);
75
- });
76
-
77
- it('should be possible to use CUID constraint', () => {
78
- const parsedSchema = parseStringDef(z.string().cuid()._def, getRefs());
79
-
80
- expect(parsedSchema).toStrictEqual({
81
- type: 'string',
82
- pattern: '^[cC][^\\s-]{8,}$',
83
- } satisfies JSONSchema7);
84
- });
85
-
86
- it('should be possible to use Cuid2 constraint', () => {
87
- const parsedSchema = parseStringDef(z.string().cuid2()._def, getRefs());
88
-
89
- expect(parsedSchema).toStrictEqual({
90
- type: 'string',
91
- pattern: '^[0-9a-z]+$',
92
- } satisfies JSONSchema7);
93
- });
94
-
95
- it('should be possible to use datetime constraint', () => {
96
- const parsedSchema = parseStringDef(z.string().datetime()._def, getRefs());
97
-
98
- expect(parsedSchema).toStrictEqual({
99
- type: 'string',
100
- format: 'date-time',
101
- } satisfies JSONSchema7);
102
- });
103
-
104
- it('should be possible to use date constraint', () => {
105
- const parsedSchema = parseStringDef(z.string().date()._def, getRefs());
106
-
107
- expect(parsedSchema).toStrictEqual({
108
- type: 'string',
109
- format: 'date',
110
- } satisfies JSONSchema7);
111
- });
112
-
113
- it('should be possible to use time constraint', () => {
114
- const parsedSchema = parseStringDef(z.string().time()._def, getRefs());
115
-
116
- expect(parsedSchema).toStrictEqual({
117
- type: 'string',
118
- format: 'time',
119
- } satisfies JSONSchema7);
120
- });
121
-
122
- it('should be possible to use duration constraint', () => {
123
- const parsedSchema = parseStringDef(z.string().duration()._def, getRefs());
124
-
125
- expect(parsedSchema).toStrictEqual({
126
- type: 'string',
127
- format: 'duration',
128
- } satisfies JSONSchema7);
129
- });
130
-
131
- it('should be possible to use length constraint', () => {
132
- const parsedSchema = parseStringDef(z.string().length(15)._def, getRefs());
133
-
134
- expect(parsedSchema).toStrictEqual({
135
- type: 'string',
136
- minLength: 15,
137
- maxLength: 15,
138
- } satisfies JSONSchema7);
139
- });
140
-
141
- it('should be possible to use length with min and max constraints', () => {
142
- const parsedSchema = parseStringDef(
143
- z.string().min(20).max(25).length(15)._def,
144
- getRefs(),
145
- );
146
-
147
- expect(parsedSchema).toStrictEqual({
148
- type: 'string',
149
- minLength: 20,
150
- maxLength: 15,
151
- } satisfies JSONSchema7);
152
- });
153
-
154
- it('should gracefully ignore the .trim() "check"', () => {
155
- const parsedSchema = parseStringDef(z.string().trim()._def, getRefs());
156
-
157
- expect(parsedSchema).toStrictEqual({
158
- type: 'string',
159
- } satisfies JSONSchema7);
160
- });
161
-
162
- it('should gracefully ignore the .toLowerCase() "check"', () => {
163
- const parsedSchema = parseStringDef(
164
- z.string().toLowerCase()._def,
165
- getRefs(),
166
- );
167
-
168
- expect(parsedSchema).toStrictEqual({
169
- type: 'string',
170
- } satisfies JSONSchema7);
171
- });
172
-
173
- it('should gracefully ignore the .toUpperCase() "check"', () => {
174
- const parsedSchema = parseStringDef(
175
- z.string().toUpperCase()._def,
176
- getRefs(),
177
- );
178
-
179
- expect(parsedSchema).toStrictEqual({
180
- type: 'string',
181
- } satisfies JSONSchema7);
182
- });
183
-
184
- it('should work with the startsWith check', () => {
185
- expect(
186
- parseStringDef(z.string().startsWith('aBcD123{}[]')._def, getRefs()),
187
- ).toStrictEqual({
188
- type: 'string',
189
- pattern: '^aBcD123\\{\\}\\[\\]',
190
- } satisfies JSONSchema7);
191
- });
192
-
193
- it('should work with the endsWith check', () => {
194
- expect(
195
- parseStringDef(z.string().endsWith('aBcD123{}[]')._def, getRefs()),
196
- ).toStrictEqual({
197
- type: 'string',
198
- pattern: 'aBcD123\\{\\}\\[\\]$',
199
- } satisfies JSONSchema7);
200
- });
201
-
202
- it('should work with the includes check', () => {
203
- expect(
204
- parseStringDef(z.string().includes('aBcD123{}[]')._def, getRefs()),
205
- ).toStrictEqual({
206
- type: 'string',
207
- pattern: 'aBcD123\\{\\}\\[\\]',
208
- } satisfies JSONSchema7);
209
- });
210
-
211
- it('should work with the preserve patternStrategy', () => {
212
- expect(
213
- parseStringDef(
214
- z.string().includes('aBcD123{}[]')._def,
215
- getRefs({
216
- patternStrategy: 'preserve',
217
- }),
218
- ),
219
- ).toStrictEqual({
220
- type: 'string',
221
- pattern: 'aBcD123{}[]',
222
- } satisfies JSONSchema7);
223
- });
224
-
225
- it('should bundle multiple pattern type checks in an allOf container', () => {
226
- expect(
227
- parseStringDef(
228
- z.string().startsWith('alpha').endsWith('omega')._def,
229
- getRefs(),
230
- ),
231
- ).toStrictEqual({
232
- type: 'string',
233
- allOf: [
234
- {
235
- pattern: '^alpha',
236
- },
237
- {
238
- pattern: 'omega$',
239
- },
240
- ],
241
- } satisfies JSONSchema7);
242
- });
243
-
244
- it('should pick correct value if multiple min/max are present', () => {
245
- expect(
246
- parseStringDef(z.string().min(1).min(2).max(3).max(4)._def, getRefs()),
247
- ).toStrictEqual({
248
- type: 'string',
249
- maxLength: 3,
250
- minLength: 2,
251
- } satisfies JSONSchema7);
252
- });
253
-
254
- it('should bundle multiple formats into anyOf', () => {
255
- const zodSchema = z.string().ip().email();
256
- const jsonParsedSchema = parseStringDef(zodSchema._def, getRefs());
257
-
258
- expect(jsonParsedSchema).toStrictEqual({
259
- type: 'string',
260
- anyOf: [
261
- {
262
- format: 'ipv4',
263
- },
264
- {
265
- format: 'ipv6',
266
- },
267
- {
268
- format: 'email',
269
- },
270
- ],
271
- } satisfies JSONSchema7);
272
- });
273
-
274
- it('should default to contentEncoding for base64, but format and pattern should also work', () => {
275
- const def = z.string().base64()._def;
276
-
277
- expect(parseStringDef(def, getRefs())).toStrictEqual({
278
- type: 'string',
279
- contentEncoding: 'base64',
280
- } satisfies JSONSchema7);
281
-
282
- expect(
283
- parseStringDef(
284
- def,
285
- getRefs({ base64Strategy: 'contentEncoding:base64' }),
286
- ),
287
- ).toStrictEqual({
288
- type: 'string',
289
- contentEncoding: 'base64',
290
- } satisfies JSONSchema7);
291
-
292
- expect(
293
- parseStringDef(def, getRefs({ base64Strategy: 'format:binary' })),
294
- ).toStrictEqual({
295
- type: 'string',
296
- format: 'binary',
297
- } satisfies JSONSchema7);
298
-
299
- expect(
300
- parseStringDef(def, getRefs({ base64Strategy: 'pattern:zod' })),
301
- ).toStrictEqual({
302
- type: 'string',
303
- pattern: zodPatterns.base64.source,
304
- } satisfies JSONSchema7);
305
- });
306
-
307
- it('should be possible to use nanoid constraint', () => {
308
- const def = z.string().nanoid()._def;
309
-
310
- expect(parseStringDef(def, getRefs())).toStrictEqual({
311
- type: 'string',
312
- pattern: '^[a-zA-Z0-9_-]{21}$',
313
- } satisfies JSONSchema7);
314
- });
315
-
316
- it('should be possible to use ulid constraint', () => {
317
- const def = z.string().ulid()._def;
318
-
319
- expect(parseStringDef(def, getRefs())).toStrictEqual({
320
- type: 'string',
321
- pattern: '^[0-9A-HJKMNP-TV-Z]{26}$',
322
- } satisfies JSONSchema7);
323
- });
324
-
325
- it('should be possible to pick format:email, format:idn-email or pattern:zod', () => {
326
- expect(parseStringDef(z.string().email()._def, getRefs())).toStrictEqual({
327
- type: 'string',
328
- format: 'email',
329
- } satisfies JSONSchema7);
330
-
331
- expect(
332
- parseStringDef(
333
- z.string().email()._def,
334
- getRefs({ emailStrategy: 'format:email' }),
335
- ),
336
- ).toStrictEqual({
337
- type: 'string',
338
- format: 'email',
339
- } satisfies JSONSchema7);
340
-
341
- expect(
342
- parseStringDef(
343
- z.string().email()._def,
344
- getRefs({ emailStrategy: 'format:idn-email' }),
345
- ),
346
- ).toStrictEqual({
347
- type: 'string',
348
- format: 'idn-email',
349
- } satisfies JSONSchema7);
350
-
351
- expect(
352
- parseStringDef(
353
- z.string().email()._def,
354
- getRefs({ emailStrategy: 'pattern:zod' }),
355
- ),
356
- ).toStrictEqual({
357
- type: 'string',
358
- pattern: zodPatterns.email.source,
359
- } satisfies JSONSchema7);
360
- });
361
-
362
- it('should correctly handle reasonable non-contrived regexes with flags', () => {
363
- expect(
364
- parseStringDef(
365
- z.string().regex(/(^|\^foo)Ba[r-z]+./)._def,
366
- getRefs({ applyRegexFlags: true }),
367
- ),
368
- ).toStrictEqual({
369
- type: 'string',
370
- pattern: '(^|\\^foo)Ba[r-z]+.',
371
- } satisfies JSONSchema7);
372
-
373
- expect(
374
- parseStringDef(
375
- z.string().regex(/(^|\^foo)Ba[r-z]+./i)._def,
376
- getRefs({ applyRegexFlags: true }),
377
- ),
378
- ).toStrictEqual({
379
- type: 'string',
380
- pattern: '(^|\\^[fF][oO][oO])[bB][aA][r-zR-Z]+.',
381
- } satisfies JSONSchema7);
382
-
383
- expect(
384
- parseStringDef(
385
- z.string().regex(/(^|\^foo)Ba[r-z]+./ms)._def,
386
- getRefs({ applyRegexFlags: true }),
387
- ),
388
- ).toStrictEqual({
389
- type: 'string',
390
- pattern: '((^|(?<=[\r\n]))|\\^foo)Ba[r-z]+[.\r\n]',
391
- } satisfies JSONSchema7);
392
-
393
- expect(
394
- parseStringDef(
395
- z.string().regex(/(^|\^foo)Ba[r-z]+./ims)._def,
396
- getRefs({ applyRegexFlags: true }),
397
- ),
398
- ).toStrictEqual({
399
- type: 'string',
400
- pattern: '((^|(?<=[\r\n]))|\\^[fF][oO][oO])[bB][aA][r-zR-Z]+[.\r\n]',
401
- } satisfies JSONSchema7);
402
-
403
- expect(
404
- parseStringDef(
405
- z.string().regex(/foo.+$/m)._def,
406
- getRefs({ applyRegexFlags: true }),
407
- ),
408
- ).toStrictEqual({
409
- type: 'string',
410
- pattern: 'foo.+($|(?=[\r\n]))',
411
- } satisfies JSONSchema7);
412
-
413
- expect(
414
- parseStringDef(
415
- z.string().regex(/foo.+[amz]/i)._def,
416
- getRefs({ applyRegexFlags: true }),
417
- ),
418
- ).toStrictEqual({
419
- type: 'string',
420
- pattern: '[fF][oO][oO].+[aAmMzZ]',
421
- } satisfies JSONSchema7);
422
- });
423
-
424
- it('Unescape forward slashes', () => {
425
- const zodSchema = z.string().regex(/^\/$/);
426
-
427
- const jsonSchema = parseStringDef(zodSchema._def, getRefs());
428
-
429
- const pattern = jsonSchema.pattern!;
430
- const patternJson = JSON.stringify(pattern);
431
- const patternJsonParsed = JSON.parse(patternJson);
432
-
433
- const regexp = new RegExp(patternJsonParsed);
434
- expect(regexp.test('')).toBe(false);
435
- expect(regexp.test('/')).toBe(true);
436
- expect(regexp.test('//')).toBe(false);
437
- });
438
- });
@@ -1,33 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { z } from 'zod/v3';
3
- import { parseTupleDef } from './tuple';
4
- import { getRefs } from '../refs';
5
- import { JSONSchema7 } from '@ai-sdk/provider';
6
-
7
- describe('tuple', () => {
8
- it('should be possible to describe a simple tuple schema', () => {
9
- const schema = z.tuple([z.string(), z.number()]);
10
- const parsedSchema = parseTupleDef(schema._def, getRefs());
11
-
12
- expect(parsedSchema).toStrictEqual({
13
- type: 'array',
14
- items: [{ type: 'string' }, { type: 'number' }],
15
- minItems: 2,
16
- maxItems: 2,
17
- } satisfies JSONSchema7);
18
- });
19
-
20
- it('should be possible to describe a tuple schema with rest()', () => {
21
- const schema = z.tuple([z.string(), z.number()]).rest(z.boolean());
22
- const parsedSchema = parseTupleDef(schema._def, getRefs());
23
-
24
- expect(parsedSchema).toStrictEqual({
25
- type: 'array',
26
- items: [{ type: 'string' }, { type: 'number' }],
27
- minItems: 2,
28
- additionalItems: {
29
- type: 'boolean',
30
- },
31
- } satisfies JSONSchema7);
32
- });
33
- });