1 | export type BooleanType = {
|
2 | type: "boolean";
|
3 | input?: "checkbox" | "toggle";
|
4 | required?: boolean;
|
5 | index?: boolean;
|
6 | defaultValue?: boolean;
|
7 | hidden?: boolean;
|
8 | };
|
9 |
|
10 | export type NumberType = {
|
11 | type: "number";
|
12 | min?: number;
|
13 | max?: number;
|
14 | placeholder?: string;
|
15 | required?: boolean;
|
16 | index?: boolean;
|
17 | search?: boolean;
|
18 | hidden?: boolean;
|
19 | };
|
20 | export type RichtextType = {
|
21 | type: "richtext";
|
22 | required?: boolean;
|
23 | formats?: any[][] | string[];
|
24 | modules?: {
|
25 | [key: string]: any;
|
26 | };
|
27 | index?: boolean;
|
28 | search?: boolean;
|
29 | hidden?: boolean;
|
30 | };
|
31 |
|
32 | type Text = {
|
33 | type: "string";
|
34 | placeholder?: string;
|
35 | readOnly?: boolean;
|
36 | maxLength?: number;
|
37 | required?: boolean;
|
38 | index?: boolean;
|
39 | search?: boolean;
|
40 | hidden?: boolean;
|
41 | };
|
42 | type TextArea = {
|
43 | type: "string";
|
44 | input: "textarea";
|
45 | required?: boolean;
|
46 | placeholder?: string;
|
47 | readOnly?: boolean;
|
48 | maxLength?: number;
|
49 | minRows?: number;
|
50 | maxRows?: number;
|
51 | index?: boolean;
|
52 | search?: boolean;
|
53 | hidden?: boolean;
|
54 | };
|
55 |
|
56 | type Slug = {
|
57 | type: "string";
|
58 | input: "slug";
|
59 | required?: boolean;
|
60 | index?: boolean;
|
61 | search?: boolean;
|
62 | hidden?: boolean;
|
63 | };
|
64 |
|
65 | type DateString = {
|
66 | type: "string";
|
67 | input: "date";
|
68 | required?: boolean;
|
69 | placeholder?: string;
|
70 | defaultValue?: string;
|
71 | index?: boolean;
|
72 | search?: boolean;
|
73 | hidden?: boolean;
|
74 | };
|
75 |
|
76 | type SelectValue = { label: string; value: string | number } | string;
|
77 |
|
78 | type Select = {
|
79 | type: "string";
|
80 | input: "select";
|
81 | nullLabel?: string;
|
82 | fetch?: string;
|
83 | values?: SelectValue[];
|
84 | required?: boolean;
|
85 | index?: boolean;
|
86 | search?: boolean;
|
87 | hidden?: boolean;
|
88 | };
|
89 | type PositionType = {
|
90 | type: "position";
|
91 | index?: boolean;
|
92 | };
|
93 |
|
94 | type InverseReferenceType = {
|
95 | type: "references";
|
96 | model: string;
|
97 | fieldName: string;
|
98 | };
|
99 |
|
100 | export type StringType = Text | Slug | Select | DateString | TextArea;
|
101 | export type ScalarType = BooleanType | NumberType | StringType | RichtextType;
|
102 |
|
103 | type AllMediaType = {
|
104 | mediaType?: "all";
|
105 | mimeType?: string;
|
106 | };
|
107 | type ImageMediaType = {
|
108 | mediaType: "image";
|
109 | minWidth?: number;
|
110 | minHeight?: number;
|
111 | maxWidth?: number;
|
112 | maxHeight?: number;
|
113 | };
|
114 | type VideoMediaType = {
|
115 | mediaType: "video";
|
116 | };
|
117 | type PDFMediaType = {
|
118 | mediaType: "pdf";
|
119 | };
|
120 | export type MediaType = {
|
121 | type: "media";
|
122 | required?: boolean;
|
123 | withExternal?: boolean;
|
124 | hidden?: boolean;
|
125 | maxSize?: number;
|
126 | } & (AllMediaType | ImageMediaType | VideoMediaType | PDFMediaType);
|
127 |
|
128 | export type SettingsType = {
|
129 | type: "settings";
|
130 | model: string;
|
131 | required?: boolean;
|
132 | };
|
133 |
|
134 | export type Field = Type & { label?: string };
|
135 |
|
136 | export type Fields = {
|
137 | [key: string]: Field;
|
138 | };
|
139 |
|
140 | export type ObjectType = {
|
141 | type: "object";
|
142 | fields: Fields;
|
143 | layout?: "vertical" | "horizontal" | "inline";
|
144 | modalView?: boolean;
|
145 | };
|
146 |
|
147 | export type MapType = {
|
148 | type: "map";
|
149 | keys: {
|
150 | fetch: string;
|
151 | values?: string[];
|
152 | };
|
153 | values: Type;
|
154 | };
|
155 |
|
156 | export type ListType = {
|
157 | type: "list";
|
158 | item: Field;
|
159 | sortable?: boolean;
|
160 | schedule?: boolean;
|
161 | addLabel?: string;
|
162 | required?: boolean;
|
163 | minLength?: number;
|
164 | maxLength?: number;
|
165 | layout?: "inline" | "block";
|
166 | hidden?: boolean;
|
167 | };
|
168 |
|
169 | export type UnionTypeType = ObjectType & { label?: string; icon?: string };
|
170 | type UnionTypeTypes = {
|
171 | [key: string]: UnionTypeType;
|
172 | };
|
173 |
|
174 | export type UnionType = {
|
175 | type: "union";
|
176 | types: UnionTypeTypes;
|
177 | required?: boolean;
|
178 | };
|
179 |
|
180 | export type ReferenceType = {
|
181 | type: "content" | "settings" | "external";
|
182 | model?: string;
|
183 | models?: string[];
|
184 | required?: boolean;
|
185 | allowAbsoluteRefs?: boolean;
|
186 | index?: boolean;
|
187 | hidden?: boolean;
|
188 | };
|
189 |
|
190 | export type ImmutableType = {
|
191 | type: "immutable";
|
192 | child: Field;
|
193 | };
|
194 |
|
195 | export type Type =
|
196 | | ScalarType
|
197 | | MediaType
|
198 | | SettingsType
|
199 | | ObjectType
|
200 | | MapType
|
201 | | ListType
|
202 | | UnionType
|
203 | | ReferenceType
|
204 | | PositionType
|
205 | | ImmutableType
|
206 | | InverseReferenceType;
|
207 |
|
208 | export type ModelOpts = {
|
209 | name: string;
|
210 | singular?: string;
|
211 | plural?: string;
|
212 | collection?: "list" | "singleton" | "none";
|
213 | urlPath?: string;
|
214 | fields: {
|
215 | [key: string]: Field & { unique?: boolean };
|
216 | };
|
217 | customQuery?: {
|
218 | [s: string]: string;
|
219 | };
|
220 | uniqueFields?: string[];
|
221 | title?: string;
|
222 | image?: string;
|
223 | group?: string;
|
224 | notSearchAble?: boolean;
|
225 | orderBy?: string;
|
226 | order?: "asc" | "desc";
|
227 | };
|
228 |
|
229 | export interface GroupItemOpts {
|
230 | type: "group";
|
231 | name: string;
|
232 | path?: string;
|
233 | items: NavigationOpts[];
|
234 | }
|
235 |
|
236 | export interface GroupItem extends GroupItemOpts {
|
237 | path: string;
|
238 | items: NavigationItem[];
|
239 | }
|
240 |
|
241 | export interface ModelItemOpts {
|
242 | type: "model";
|
243 | name?: string;
|
244 | path?: string;
|
245 | model: string;
|
246 | }
|
247 |
|
248 | export interface ModelItem extends ModelItemOpts {
|
249 | path: string;
|
250 | }
|
251 |
|
252 | export type NavigationOpts = GroupItemOpts | ModelItemOpts;
|
253 |
|
254 | export type NavigationItem = GroupItem | ModelItem;
|
255 |
|
256 | export type ModelPaths = {
|
257 | [key: string]: string;
|
258 | };
|
259 |
|
260 | export type ModelBuilderOpts = Partial<ModelOpts> & {
|
261 | type: "content" | "settings" | "media";
|
262 | versioned?: boolean;
|
263 | required?: boolean;
|
264 | writable?: boolean;
|
265 | external?: boolean;
|
266 | };
|
267 |
|
268 | export type Model = ModelBuilderOpts &
|
269 | ModelOpts & {
|
270 | name: string;
|
271 | plural: string;
|
272 | singular: string;
|
273 | title: string;
|
274 | };
|
275 |
|
276 | export type Models = {
|
277 | content: Model[];
|
278 | settings: Model[];
|
279 | media: Model;
|
280 | };
|
281 |
|
282 | export type ModelsJson = {
|
283 | $schema?: string;
|
284 | models: ModelOpts[];
|
285 | };
|
286 |
|
287 | export type NavigationJson = {
|
288 | $schema?: string;
|
289 | navigation: NavigationItem[];
|
290 | };
|