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