|
1 | 1 | import { Collection } from '@msw/data'; |
2 | | -import { z } from 'zod'; |
| 2 | +import * as v from 'valibot'; |
3 | 3 |
|
4 | 4 | import { applyDefault } from '../utils/defaults.js'; |
5 | 5 | import { preCreateExtension } from '../utils/pre-create-extension.js'; |
6 | 6 |
|
7 | | -const schema = z.object({ |
8 | | - // `z.string()` is used to support some of our old fixture that use strings here for some reason |
9 | | - id: z.number().or(z.string()), |
| 7 | +const schema = v.object({ |
| 8 | + // `v.string()` is used to support some of our old fixtures that use strings here for some reason |
| 9 | + id: v.union([v.number(), v.string()]), |
10 | 10 |
|
11 | | - name: z.string(), |
12 | | - description: z.string(), |
13 | | - downloads: z.number(), |
14 | | - recent_downloads: z.number(), |
15 | | - documentation: z.string().nullable(), |
16 | | - homepage: z.string().nullable(), |
17 | | - repository: z.string().nullable(), |
18 | | - created_at: z.string(), |
19 | | - updated_at: z.string(), |
20 | | - badges: z.array(z.any()), |
21 | | - _extra_downloads: z.array(z.any()), |
22 | | - trustpubOnly: z.boolean(), |
| 11 | + name: v.string(), |
| 12 | + description: v.string(), |
| 13 | + downloads: v.number(), |
| 14 | + recent_downloads: v.number(), |
| 15 | + documentation: v.nullable(v.string()), |
| 16 | + homepage: v.nullable(v.string()), |
| 17 | + repository: v.nullable(v.string()), |
| 18 | + created_at: v.string(), |
| 19 | + updated_at: v.string(), |
| 20 | + badges: v.array(v.any()), |
| 21 | + _extra_downloads: v.array(v.any()), |
| 22 | + trustpubOnly: v.boolean(), |
23 | 23 |
|
24 | | - categories: z.array(z.any()).default(() => []), |
25 | | - keywords: z.array(z.any()).default(() => []), |
| 24 | + categories: v.optional(v.array(v.any()), () => []), |
| 25 | + keywords: v.optional(v.array(v.any()), () => []), |
26 | 26 | }); |
27 | 27 |
|
28 | 28 | function preCreate(attrs, counter) { |
|
0 commit comments