-
-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathitems-config.ts
47 lines (42 loc) · 1.29 KB
/
items-config.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
import { Static, Type } from '@sinclair/typebox';
export const ItemConfigSchema = Type.Object({
name: Type.String(),
description: Type.String(),
icon: Type.String(),
onUse: Type.Optional(
Type.Object({
action: Type.String(),
label: Type.String(),
}),
),
tag: Type.Optional(Type.String()),
category: Type.Optional(Type.String()),
showIfEmpty: Type.Optional(Type.Boolean()),
});
export type ItemConfig = Static<typeof ItemConfigSchema>;
export const ItemCategorySchema = Type.Object({
id: Type.String(),
title: Type.String(),
});
export type ItemCategory = Static<typeof ItemCategorySchema>;
export const ItemsListSchema = Type.Record(Type.String(), ItemConfigSchema);
export type ItemsList = Static<typeof ItemsListSchema>;
export const ItemsConfigSchema = Type.Object({
categories: Type.Array(ItemCategorySchema),
items: ItemsListSchema,
});
export type ItemsConfig = Static<typeof ItemsConfigSchema>;
export const ItemsInputConfigSchema = Type.Object({
categories: Type.Optional(Type.Array(ItemCategorySchema)),
items: Type.Optional(ItemsListSchema),
});
export type ItemsInputConfig = Static<typeof ItemsInputConfigSchema>;
export const defaultItemsConfig: ItemsConfig = {
categories: [
{
id: 'default',
title: 'Items',
},
],
items: {},
};