-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
schema.ts
57 lines (49 loc) · 1.45 KB
/
schema.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { z } from "zod"
export const blockChunkSchema = z.object({
name: z.string(),
description: z.string(),
component: z.any(),
file: z.string(),
code: z.string().optional(),
container: z
.object({
className: z.string().nullish(),
})
.optional(),
})
export const registryEntrySchema = z.object({
name: z.string(),
description: z.string().optional(),
dependencies: z.array(z.string()).optional(),
devDependencies: z.array(z.string()).optional(),
registryDependencies: z.array(z.string()).optional(),
files: z.array(z.string()),
source: z.string().optional(),
type: z.enum([
"components:ui",
"components:component",
"components:example",
"components:block",
]),
category: z.string().optional(),
subcategory: z.string().optional(),
chunks: z.array(blockChunkSchema).optional(),
})
export const registrySchema = z.array(registryEntrySchema)
export type RegistryEntry = z.infer<typeof registryEntrySchema>
export type Registry = z.infer<typeof registrySchema>
export const blockSchema = registryEntrySchema.extend({
type: z.literal("components:block"),
style: z.enum(["default", "new-york"]),
component: z.any(),
container: z
.object({
height: z.string().optional(),
className: z.string().nullish(),
})
.optional(),
code: z.string(),
highlightedCode: z.string(),
})
export type Block = z.infer<typeof blockSchema>
export type BlockChunk = z.infer<typeof blockChunkSchema>