directus
1650 строк · 27.9 Кб
1import type { Knex } from 'knex';
2import { merge, uniq } from 'lodash-es';
3
4const defaults = {
5collection: null,
6field: null,
7special: null,
8interface: null,
9options: null,
10display: null,
11display_options: null,
12locked: false,
13readonly: false,
14hidden: false,
15sort: null,
16width: 'full',
17group: null,
18translations: null,
19note: null,
20};
21
22const systemFields = [
23{
24collection: 'directus_collections',
25field: 'collection_divider',
26special: 'alias',
27interface: 'divider',
28options: {
29icon: 'box',
30title: 'Collection Setup',
31color: '#2F80ED',
32},
33locked: true,
34sort: 1,
35width: 'full',
36},
37{
38collection: 'directus_collections',
39field: 'collection',
40interface: 'text-input',
41options: {
42font: 'monospace',
43},
44locked: true,
45readonly: true,
46sort: 2,
47width: 'half',
48},
49{
50collection: 'directus_collections',
51field: 'icon',
52interface: 'icon',
53options: null,
54locked: true,
55sort: 3,
56width: 'half',
57},
58{
59collection: 'directus_collections',
60field: 'note',
61interface: 'text-input',
62options: {
63placeholder: 'A description of this collection...',
64},
65locked: true,
66sort: 4,
67width: 'full',
68},
69{
70collection: 'directus_collections',
71field: 'display_template',
72interface: 'display-template',
73options: {
74collectionField: 'collection',
75},
76locked: true,
77sort: 5,
78width: 'full',
79},
80{
81collection: 'directus_collections',
82field: 'hidden',
83special: 'boolean',
84interface: 'toggle',
85options: {
86label: 'Hide within the App',
87},
88locked: true,
89sort: 6,
90width: 'half',
91},
92{
93collection: 'directus_collections',
94field: 'singleton',
95special: 'boolean',
96interface: 'toggle',
97options: {
98label: 'Treat as single object',
99},
100locked: true,
101sort: 7,
102width: 'half',
103},
104{
105collection: 'directus_collections',
106field: 'translations',
107special: 'json',
108interface: 'repeater',
109options: {
110template: '{{ translation }} ({{ language }})',
111fields: [
112{
113field: 'language',
114name: 'Language',
115type: 'string',
116schema: {
117default_value: 'en-US',
118},
119meta: {
120interface: 'system-language',
121width: 'half',
122},
123},
124{
125field: 'translation',
126name: 'translation',
127type: 'string',
128meta: {
129interface: 'text-input',
130width: 'half',
131options: {
132placeholder: 'Enter a translation...',
133},
134},
135},
136],
137},
138locked: true,
139sort: 8,
140width: 'full',
141},
142{
143collection: 'directus_collections',
144field: 'archive_divider',
145special: 'alias',
146interface: 'divider',
147options: {
148icon: 'archive',
149title: 'Archive',
150color: '#2F80ED',
151},
152locked: true,
153sort: 9,
154width: 'full',
155},
156{
157collection: 'directus_collections',
158field: 'archive_field',
159interface: 'field',
160options: {
161collectionField: 'collection',
162allowNone: true,
163placeholder: 'Choose a field...',
164},
165locked: true,
166sort: 10,
167width: 'half',
168},
169{
170collection: 'directus_collections',
171field: 'archive_app_filter',
172interface: 'toggle',
173special: 'boolean',
174options: {
175label: 'Enable App Archive Filter',
176},
177locked: true,
178sort: 11,
179width: 'half',
180},
181{
182collection: 'directus_collections',
183field: 'archive_value',
184interface: 'text-input',
185options: {
186font: 'monospace',
187iconRight: 'archive',
188placeholder: 'Value set when archiving...',
189},
190locked: true,
191sort: 12,
192width: 'half',
193},
194{
195collection: 'directus_collections',
196field: 'unarchive_value',
197interface: 'text-input',
198options: {
199font: 'monospace',
200iconRight: 'unarchive',
201placeholder: 'Value set when unarchiving...',
202},
203locked: true,
204sort: 13,
205width: 'half',
206},
207{
208collection: 'directus_collections',
209field: 'sort_divider',
210special: 'alias',
211interface: 'divider',
212options: {
213icon: 'sort',
214title: 'Sort',
215color: '#2F80ED',
216},
217locked: true,
218sort: 14,
219width: 'full',
220},
221{
222collection: 'directus_collections',
223field: 'sort_field',
224interface: 'field',
225options: {
226collectionField: 'collection',
227placeholder: 'Choose a field...',
228typeAllowList: ['float', 'decimal', 'integer'],
229allowNone: true,
230},
231locked: true,
232sort: 15,
233width: 'half',
234},
235{
236collection: 'directus_roles',
237field: 'id',
238hidden: true,
239interface: 'text-input',
240locked: true,
241special: 'uuid',
242},
243{
244collection: 'directus_roles',
245field: 'name',
246interface: 'text-input',
247options: {
248placeholder: 'The unique name for this role...',
249},
250locked: true,
251sort: 1,
252width: 'half',
253},
254{
255collection: 'directus_roles',
256field: 'icon',
257interface: 'icon',
258display: 'icon',
259locked: true,
260sort: 2,
261width: 'half',
262},
263{
264collection: 'directus_roles',
265field: 'description',
266interface: 'text-input',
267options: {
268placeholder: 'A description of this role...',
269},
270locked: true,
271sort: 3,
272width: 'full',
273},
274{
275collection: 'directus_roles',
276field: 'app_access',
277interface: 'toggle',
278locked: true,
279special: 'boolean',
280sort: 4,
281width: 'half',
282},
283{
284collection: 'directus_roles',
285field: 'admin_access',
286interface: 'toggle',
287locked: true,
288special: 'boolean',
289sort: 5,
290width: 'half',
291},
292{
293collection: 'directus_roles',
294field: 'ip_access',
295interface: 'tags',
296options: {
297placeholder: 'Add allowed IP addresses, leave empty to allow all...',
298},
299locked: true,
300special: 'csv',
301sort: 6,
302width: 'full',
303},
304{
305collection: 'directus_roles',
306field: 'enforce_tfa',
307interface: 'toggle',
308locked: true,
309sort: 7,
310special: 'boolean',
311width: 'half',
312},
313{
314collection: 'directus_roles',
315field: 'users',
316interface: 'one-to-many',
317locked: true,
318special: 'o2m',
319sort: 8,
320options: {
321fields: ['first_name', 'last_name'],
322},
323width: 'full',
324},
325{
326collection: 'directus_roles',
327field: 'module_list',
328interface: 'repeater',
329locked: true,
330options: {
331template: '{{ name }}',
332addLabel: 'Add New Module...',
333fields: [
334{
335name: 'Icon',
336field: 'icon',
337type: 'string',
338meta: {
339interface: 'icon',
340width: 'half',
341},
342},
343{
344name: 'Name',
345field: 'name',
346type: 'string',
347meta: {
348interface: 'text-input',
349width: 'half',
350options: {
351iconRight: 'title',
352placeholder: 'Enter a title...',
353},
354},
355},
356{
357name: 'Link',
358field: 'link',
359type: 'string',
360meta: {
361interface: 'text-input',
362width: 'full',
363options: {
364iconRight: 'link',
365placeholder: 'Relative or absolute URL...',
366},
367},
368},
369],
370},
371special: 'json',
372sort: 9,
373width: 'full',
374},
375{
376collection: 'directus_roles',
377field: 'collection_list',
378interface: 'repeater',
379locked: true,
380options: {
381template: '{{ group_name }}',
382addLabel: 'Add New Group...',
383fields: [
384{
385name: 'Group Name',
386field: 'group_name',
387type: 'string',
388meta: {
389width: 'half',
390interface: 'text-input',
391options: {
392iconRight: 'title',
393placeholder: 'Label this group...',
394},
395},
396schema: {
397is_nullable: false,
398},
399},
400{
401name: 'Type',
402field: 'accordion',
403type: 'string',
404schema: {
405default_value: 'always_open',
406},
407meta: {
408width: 'half',
409interface: 'dropdown',
410options: {
411choices: [
412{
413value: 'always_open',
414text: 'Always Open',
415},
416{
417value: 'start_open',
418text: 'Start Open',
419},
420{
421value: 'start_collapsed',
422text: 'Start Collapsed',
423},
424],
425},
426},
427},
428{
429name: 'Collections',
430field: 'collections',
431type: 'JSON',
432meta: {
433interface: 'repeater',
434options: {
435addLabel: 'Add New Collection...',
436template: '{{ collection }}',
437fields: [
438{
439name: 'Collection',
440field: 'collection',
441type: 'string',
442meta: {
443interface: 'collection',
444width: 'full',
445},
446schema: {
447is_nullable: false,
448},
449},
450],
451},
452},
453},
454],
455},
456special: 'json',
457sort: 10,
458width: 'full',
459},
460{
461collection: 'directus_fields',
462field: 'options',
463hidden: true,
464locked: true,
465special: 'json',
466},
467{
468collection: 'directus_fields',
469field: 'display_options',
470hidden: true,
471locked: true,
472special: 'json',
473},
474{
475collection: 'directus_fields',
476field: 'locked',
477hidden: true,
478locked: true,
479special: 'boolean',
480},
481{
482collection: 'directus_fields',
483field: 'readonly',
484hidden: true,
485locked: true,
486special: 'boolean',
487},
488{
489collection: 'directus_fields',
490field: 'hidden',
491hidden: true,
492locked: true,
493special: 'boolean',
494},
495{
496collection: 'directus_fields',
497field: 'special',
498hidden: true,
499locked: true,
500special: 'csv',
501},
502{
503collection: 'directus_fields',
504field: 'translations',
505hidden: true,
506locked: true,
507special: 'json',
508},
509{
510collection: 'directus_users',
511field: 'first_name',
512interface: 'text-input',
513locked: true,
514options: {
515iconRight: 'account_circle',
516},
517sort: 1,
518width: 'half',
519},
520{
521collection: 'directus_users',
522field: 'last_name',
523interface: 'text-input',
524locked: true,
525options: {
526iconRight: 'account_circle',
527},
528sort: 2,
529width: 'half',
530},
531{
532collection: 'directus_users',
533field: 'email',
534interface: 'text-input',
535locked: true,
536options: {
537iconRight: 'email',
538},
539sort: 3,
540width: 'half',
541},
542{
543collection: 'directus_users',
544field: 'password',
545special: 'hash, conceal',
546interface: 'hash',
547locked: true,
548options: {
549iconRight: 'lock',
550masked: true,
551},
552sort: 4,
553width: 'half',
554},
555{
556collection: 'directus_users',
557field: 'avatar',
558interface: 'file',
559locked: true,
560sort: 5,
561width: 'full',
562},
563{
564collection: 'directus_users',
565field: 'location',
566interface: 'text-input',
567options: {
568iconRight: 'place',
569},
570sort: 6,
571width: 'half',
572},
573{
574collection: 'directus_users',
575field: 'title',
576interface: 'text-input',
577options: {
578iconRight: 'work',
579},
580sort: 7,
581width: 'half',
582},
583{
584collection: 'directus_users',
585field: 'description',
586interface: 'textarea',
587sort: 8,
588width: 'full',
589},
590{
591collection: 'directus_users',
592field: 'tags',
593interface: 'tags',
594special: 'json',
595sort: 9,
596width: 'full',
597options: {
598iconRight: 'local_offer',
599},
600},
601{
602collection: 'directus_users',
603field: 'preferences_divider',
604interface: 'divider',
605options: {
606icon: 'face',
607title: 'User Preferences',
608color: '#2F80ED',
609},
610special: 'alias',
611sort: 10,
612width: 'full',
613},
614{
615collection: 'directus_users',
616field: 'language',
617interface: 'dropdown',
618locked: true,
619options: {
620choices: [
621{
622text: 'Afrikaans (South Africa)',
623value: 'af-ZA',
624},
625{
626text: 'Arabic (Saudi Arabia)',
627value: 'ar-SA',
628},
629{
630text: 'Catalan (Spain)',
631value: 'ca-ES',
632},
633{
634text: 'Chinese (Simplified)',
635value: 'zh-CN',
636},
637{
638text: 'Czech (Czech Republic)',
639value: 'cs-CZ',
640},
641{
642text: 'Danish (Denmark)',
643value: 'da-DK',
644},
645{
646text: 'Dutch (Netherlands)',
647value: 'nl-NL',
648},
649{
650text: 'English (United States)',
651value: 'en-US',
652},
653{
654text: 'Finnish (Finland)',
655value: 'fi-FI',
656},
657{
658text: 'French (France)',
659value: 'fr-FR',
660},
661{
662text: 'German (Germany)',
663value: 'de-DE',
664},
665{
666text: 'Greek (Greece)',
667value: 'el-GR',
668},
669{
670text: 'Hebrew (Israel)',
671value: 'he-IL',
672},
673{
674text: 'Hungarian (Hungary)',
675value: 'hu-HU',
676},
677{
678text: 'Icelandic (Iceland)',
679value: 'is-IS',
680},
681{
682text: 'Indonesian (Indonesia)',
683value: 'id-ID',
684},
685{
686text: 'Italian (Italy)',
687value: 'it-IT',
688},
689{
690text: 'Japanese (Japan)',
691value: 'ja-JP',
692},
693{
694text: 'Korean (Korea)',
695value: 'ko-KR',
696},
697{
698text: 'Malay (Malaysia)',
699value: 'ms-MY',
700},
701{
702text: 'Norwegian (Norway)',
703value: 'no-NO',
704},
705{
706text: 'Polish (Poland)',
707value: 'pl-PL',
708},
709{
710text: 'Portuguese (Brazil)',
711value: 'pt-BR',
712},
713{
714text: 'Portuguese (Portugal)',
715value: 'pt-PT',
716},
717{
718text: 'Russian (Russian Federation)',
719value: 'ru-RU',
720},
721{
722text: 'Spanish (Spain)',
723value: 'es-ES',
724},
725{
726text: 'Spanish (Latin America)',
727value: 'es-419',
728},
729{
730text: 'Taiwanese Mandarin (Taiwan)',
731value: 'zh-TW',
732},
733{
734text: 'Turkish (Turkey)',
735value: 'tr-TR',
736},
737{
738text: 'Ukrainian (Ukraine)',
739value: 'uk-UA',
740},
741{
742text: 'Vietnamese (Vietnam)',
743value: 'vi-VN',
744},
745],
746},
747sort: 11,
748width: 'half',
749},
750{
751collection: 'directus_users',
752field: 'theme',
753interface: 'dropdown',
754locked: true,
755options: {
756choices: [
757{
758value: 'auto',
759text: 'Automatic (Based on System)',
760},
761{
762value: 'light',
763text: 'Light Mode',
764},
765{
766value: 'dark',
767text: 'Dark Mode',
768},
769],
770},
771sort: 12,
772width: 'half',
773},
774{
775collection: 'directus_users',
776field: 'tfa_secret',
777interface: 'tfa-setup',
778locked: true,
779special: 'conceal',
780sort: 13,
781width: 'half',
782},
783{
784collection: 'directus_users',
785field: 'admin_divider',
786interface: 'divider',
787locked: true,
788options: {
789icon: 'verified_user',
790title: 'Admin Options',
791color: '#F2994A',
792},
793special: 'alias',
794sort: 14,
795width: 'full',
796},
797{
798collection: 'directus_users',
799field: 'status',
800interface: 'dropdown',
801locked: true,
802options: {
803choices: [
804{
805text: 'Draft',
806value: 'draft',
807},
808{
809text: 'Invited',
810value: 'invited',
811},
812{
813text: 'Active',
814value: 'active',
815},
816{
817text: 'Suspended',
818value: 'suspended',
819},
820{
821text: 'Archived',
822value: 'archived',
823},
824],
825},
826sort: 15,
827width: 'half',
828},
829{
830collection: 'directus_users',
831field: 'role',
832interface: 'many-to-one',
833locked: true,
834options: {
835template: '{{ name }}',
836},
837special: 'm2o',
838sort: 16,
839width: 'half',
840},
841{
842collection: 'directus_users',
843field: 'token',
844interface: 'token',
845locked: true,
846options: {
847iconRight: 'vpn_key',
848placeholder: 'Enter a secure access token...',
849},
850sort: 17,
851width: 'full',
852},
853{
854collection: 'directus_users',
855field: 'id',
856special: 'uuid',
857interface: 'text-input',
858locked: true,
859options: {
860iconRight: 'vpn_key',
861},
862sort: 18,
863width: 'full',
864},
865{
866collection: 'directus_folders',
867field: 'id',
868interface: 'text-input',
869locked: true,
870special: 'uuid',
871},
872{
873collection: 'directus_files',
874field: 'id',
875hidden: true,
876interface: 'text-input',
877locked: true,
878special: 'uuid',
879},
880{
881collection: 'directus_files',
882field: 'title',
883interface: 'text-input',
884locked: true,
885options: {
886iconRight: 'title',
887placeholder: 'A unique title...',
888},
889sort: 1,
890width: 'full',
891},
892{
893collection: 'directus_files',
894field: 'description',
895interface: 'textarea',
896locked: true,
897sort: 2,
898width: 'full',
899options: {
900placeholder: 'An optional description...',
901},
902},
903{
904collection: 'directus_files',
905field: 'tags',
906interface: 'tags',
907locked: true,
908options: {
909iconRight: 'local_offer',
910},
911special: 'json',
912sort: 3,
913width: 'full',
914display: 'tags',
915},
916{
917collection: 'directus_files',
918field: 'location',
919interface: 'text-input',
920locked: true,
921options: {
922iconRight: 'place',
923placeholder: 'An optional location...',
924},
925sort: 4,
926width: 'half',
927},
928{
929collection: 'directus_files',
930field: 'storage',
931interface: 'text-input',
932locked: true,
933options: {
934iconRight: 'storage',
935},
936sort: 5,
937width: 'half',
938readonly: true,
939},
940{
941collection: 'directus_files',
942field: 'storage_divider',
943interface: 'divider',
944locked: true,
945options: {
946icon: 'insert_drive_file',
947title: 'File Naming',
948color: '#2F80ED',
949},
950special: 'alias',
951sort: 6,
952width: 'full',
953},
954{
955collection: 'directus_files',
956field: 'filename_disk',
957interface: 'text-input',
958locked: true,
959options: {
960iconRight: 'publish',
961placeholder: 'Name on disk storage...',
962},
963sort: 7,
964width: 'half',
965},
966{
967collection: 'directus_files',
968field: 'filename_download',
969interface: 'text-input',
970locked: true,
971options: {
972iconRight: 'get_app',
973placeholder: 'Name when downloading...',
974},
975sort: 8,
976width: 'half',
977},
978{
979collection: 'directus_files',
980field: 'metadata',
981hidden: true,
982locked: true,
983special: 'json',
984},
985{
986collection: 'directus_files',
987field: 'type',
988display: 'mime-type',
989},
990{
991collection: 'directus_files',
992field: 'filesize',
993display: 'filesize',
994},
995{
996collection: 'directus_files',
997field: 'modified_by',
998interface: 'user',
999locked: true,
1000special: 'user-updated',
1001width: 'half',
1002display: 'user',
1003},
1004{
1005collection: 'directus_files',
1006field: 'modified_on',
1007interface: 'datetime',
1008locked: true,
1009special: 'date-updated',
1010width: 'half',
1011display: 'datetime',
1012},
1013{
1014collection: 'directus_files',
1015field: 'created_on',
1016display: 'datetime',
1017},
1018{
1019collection: 'directus_files',
1020field: 'created_by',
1021display: 'user',
1022},
1023{
1024collection: 'directus_permissions',
1025field: 'permissions',
1026hidden: true,
1027locked: true,
1028special: 'json',
1029},
1030{
1031collection: 'directus_permissions',
1032field: 'presets',
1033hidden: true,
1034locked: true,
1035special: 'json',
1036},
1037{
1038collection: 'directus_presets',
1039field: 'filters',
1040hidden: true,
1041locked: true,
1042special: 'json',
1043},
1044{
1045collection: 'directus_presets',
1046field: 'layout_query',
1047hidden: true,
1048locked: true,
1049special: 'json',
1050},
1051{
1052collection: 'directus_presets',
1053field: 'layout_options',
1054hidden: true,
1055locked: true,
1056special: 'json',
1057},
1058{
1059collection: 'directus_revisions',
1060field: 'data',
1061hidden: true,
1062locked: true,
1063special: 'json',
1064},
1065{
1066collection: 'directus_revisions',
1067field: 'delta',
1068hidden: true,
1069locked: true,
1070special: 'json',
1071},
1072{
1073collection: 'directus_settings',
1074field: 'project_name',
1075interface: 'text-input',
1076locked: true,
1077options: {
1078iconRight: 'title',
1079placeholder: 'My project...',
1080},
1081sort: 1,
1082translations: {
1083language: 'en-US',
1084translations: 'Name',
1085},
1086width: 'half',
1087},
1088{
1089collection: 'directus_settings',
1090field: 'project_url',
1091interface: 'text-input',
1092locked: true,
1093options: {
1094iconRight: 'link',
1095placeholder: 'https://example.com',
1096},
1097sort: 2,
1098translations: {
1099language: 'en-US',
1100translations: 'Website',
1101},
1102width: 'half',
1103},
1104{
1105collection: 'directus_settings',
1106field: 'project_color',
1107interface: 'color',
1108locked: true,
1109note: 'Login & Logo Background',
1110sort: 3,
1111translations: {
1112language: 'en-US',
1113translations: 'Brand Color',
1114},
1115width: 'half',
1116},
1117{
1118collection: 'directus_settings',
1119field: 'project_logo',
1120interface: 'file',
1121locked: true,
1122note: 'White 40x40 SVG/PNG',
1123sort: 4,
1124translations: {
1125language: 'en-US',
1126translations: 'Brand Logo',
1127},
1128width: 'half',
1129},
1130{
1131collection: 'directus_settings',
1132field: 'public_divider',
1133interface: 'divider',
1134locked: true,
1135options: {
1136icon: 'public',
1137title: 'Public Pages',
1138color: '#2F80ED',
1139},
1140special: 'alias',
1141sort: 5,
1142width: 'full',
1143},
1144{
1145collection: 'directus_settings',
1146field: 'public_foreground',
1147interface: 'file',
1148locked: true,
1149sort: 6,
1150translations: {
1151language: 'en-US',
1152translations: 'Login Foreground',
1153},
1154width: 'half',
1155},
1156{
1157collection: 'directus_settings',
1158field: 'public_background',
1159interface: 'file',
1160locked: true,
1161sort: 7,
1162translations: {
1163language: 'en-US',
1164translations: 'Login Background',
1165},
1166width: 'half',
1167},
1168{
1169collection: 'directus_settings',
1170field: 'public_note',
1171interface: 'textarea',
1172locked: true,
1173options: {
1174placeholder: 'A short, public message that supports markdown formatting...',
1175},
1176sort: 8,
1177width: 'full',
1178},
1179{
1180collection: 'directus_settings',
1181field: 'security_divider',
1182interface: 'divider',
1183locked: true,
1184options: {
1185icon: 'security',
1186title: 'Security',
1187color: '#2F80ED',
1188},
1189special: 'alias',
1190sort: 9,
1191width: 'full',
1192},
1193{
1194collection: 'directus_settings',
1195field: 'auth_password_policy',
1196interface: 'dropdown',
1197locked: true,
1198options: {
1199choices: [
1200{
1201value: null,
1202text: 'None – Not Recommended',
1203},
1204{
1205value: '/^.{8,}$/',
1206text: 'Weak – Minimum 8 Characters',
1207},
1208{
1209value: "/(?=^.{8,}$)(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&*()_+}{';'?>.<,])(?!.*\\s).*$/",
1210text: 'Strong – Upper / Lowercase / Numbers / Special',
1211},
1212],
1213},
1214sort: 10,
1215width: 'half',
1216},
1217{
1218collection: 'directus_settings',
1219field: 'auth_login_attempts',
1220interface: 'numeric',
1221locked: true,
1222options: {
1223iconRight: 'lock',
1224},
1225sort: 11,
1226width: 'half',
1227},
1228{
1229collection: 'directus_settings',
1230field: 'files_divider',
1231interface: 'divider',
1232locked: true,
1233options: {
1234icon: 'storage',
1235title: 'Files & Thumbnails',
1236color: '#2F80ED',
1237},
1238special: 'alias',
1239sort: 12,
1240width: 'full',
1241},
1242{
1243collection: 'directus_settings',
1244field: 'storage_asset_presets',
1245interface: 'repeater',
1246locked: true,
1247options: {
1248fields: [
1249{
1250field: 'key',
1251name: 'Key',
1252type: 'string',
1253schema: {
1254is_nullable: false,
1255},
1256meta: {
1257interface: 'slug',
1258options: {
1259onlyOnCreate: false,
1260},
1261width: 'half',
1262},
1263},
1264{
1265field: 'fit',
1266name: 'Fit',
1267type: 'string',
1268schema: {
1269is_nullable: false,
1270},
1271meta: {
1272interface: 'dropdown',
1273options: {
1274choices: [
1275{
1276value: 'contain',
1277text: 'Contain (preserve aspect ratio)',
1278},
1279{
1280value: 'cover',
1281text: 'Cover (forces exact size)',
1282},
1283],
1284},
1285width: 'half',
1286},
1287},
1288{
1289field: 'width',
1290name: 'Width',
1291type: 'integer',
1292schema: {
1293is_nullable: false,
1294},
1295meta: {
1296interface: 'numeric',
1297width: 'half',
1298},
1299},
1300{
1301field: 'height',
1302name: 'Height',
1303type: 'integer',
1304schema: {
1305is_nullable: false,
1306},
1307meta: {
1308interface: 'numeric',
1309width: 'half',
1310},
1311},
1312{
1313field: 'quality',
1314type: 'integer',
1315name: 'Quality',
1316schema: {
1317default_value: 80,
1318is_nullable: false,
1319},
1320meta: {
1321interface: 'slider',
1322options: {
1323max: 100,
1324min: 0,
1325step: 1,
1326},
1327width: 'full',
1328},
1329},
1330],
1331template: '{{key}}',
1332},
1333special: 'json',
1334sort: 13,
1335width: 'full',
1336},
1337{
1338collection: 'directus_settings',
1339field: 'storage_asset_transform',
1340interface: 'dropdown',
1341locked: true,
1342options: {
1343choices: [
1344{
1345value: 'all',
1346text: 'All',
1347},
1348{
1349value: 'none',
1350text: 'None',
1351},
1352{
1353value: 'presets',
1354text: 'Presets Only',
1355},
1356],
1357},
1358sort: 14,
1359width: 'half',
1360},
1361{
1362collection: 'directus_settings',
1363field: 'id',
1364hidden: true,
1365locked: true,
1366},
1367{
1368collection: 'directus_settings',
1369field: 'overrides_divider',
1370interface: 'divider',
1371locked: true,
1372options: {
1373icon: 'brush',
1374title: 'App Overrides',
1375color: '#2F80ED',
1376},
1377special: 'alias',
1378sort: 15,
1379width: 'full',
1380},
1381{
1382collection: 'directus_settings',
1383field: 'custom_css',
1384interface: 'code',
1385locked: true,
1386options: {
1387language: 'css',
1388lineNumber: true,
1389},
1390sort: 16,
1391width: 'full',
1392},
1393{
1394collection: 'directus_webhooks',
1395field: 'id',
1396hidden: true,
1397locked: true,
1398},
1399{
1400collection: 'directus_webhooks',
1401field: 'name',
1402interface: 'text-input',
1403locked: true,
1404options: {
1405iconRight: 'title',
1406},
1407sort: 1,
1408width: 'full',
1409},
1410{
1411collection: 'directus_webhooks',
1412field: 'method',
1413interface: 'dropdown',
1414display: 'labels',
1415display_options: {
1416defaultBackground: '#ECEFF1',
1417choices: null,
1418format: false,
1419},
1420locked: true,
1421options: {
1422choices: ['GET', 'POST'],
1423},
1424sort: 2,
1425width: 'half',
1426},
1427{
1428collection: 'directus_webhooks',
1429field: 'url',
1430interface: 'text-input',
1431locked: true,
1432options: {
1433iconRight: 'link',
1434},
1435sort: 3,
1436width: 'half',
1437},
1438{
1439collection: 'directus_webhooks',
1440field: 'status',
1441interface: 'dropdown',
1442display: 'labels',
1443display_options: {
1444defaultColor: '#B0BEC5',
1445defaultBackground: '#ECEFF1',
1446showAsDot: true,
1447choices: [
1448{
1449text: 'Active',
1450value: 'active',
1451foreground: '#607D8B',
1452background: '#2F80ED',
1453},
1454{
1455text: 'Inactive',
1456value: 'inactive',
1457foreground: '#607D8B',
1458background: '#ECEFF1',
1459},
1460],
1461},
1462locked: true,
1463options: {
1464choices: [
1465{
1466text: 'Active',
1467value: 'active',
1468},
1469{
1470text: 'Inactive',
1471value: 'inactive',
1472},
1473],
1474},
1475sort: 4,
1476width: 'half',
1477},
1478{
1479collection: 'directus_webhooks',
1480field: 'data',
1481interface: 'toggle',
1482locked: true,
1483options: {
1484label: 'Send Event Data',
1485},
1486special: 'boolean',
1487sort: 5,
1488width: 'half',
1489},
1490{
1491collection: 'directus_webhooks',
1492field: 'triggers_divider',
1493interface: 'divider',
1494options: {
1495icon: 'api',
1496title: 'Triggers',
1497color: '#2F80ED',
1498},
1499special: 'alias',
1500sort: 6,
1501width: 'full',
1502},
1503{
1504collection: 'directus_webhooks',
1505field: 'actions',
1506interface: 'checkboxes',
1507options: {
1508choices: [
1509{
1510text: 'Create',
1511value: 'create',
1512},
1513{
1514text: 'Update',
1515value: 'update',
1516},
1517{
1518text: 'Delete',
1519value: 'delete',
1520},
1521],
1522},
1523special: 'csv',
1524sort: 7,
1525width: 'full',
1526},
1527{
1528collection: 'directus_webhooks',
1529field: 'collections',
1530interface: 'collections',
1531special: 'csv',
1532sort: 8,
1533width: 'full',
1534},
1535{
1536collection: 'directus_activity',
1537field: 'action',
1538display: 'labels',
1539display_options: {
1540defaultForeground: '#263238',
1541defaultBackground: '#eceff1',
1542choices: [
1543{
1544text: 'Create',
1545value: 'create',
1546foreground: '#27ae60',
1547background: '#c9ebd7',
1548},
1549{
1550text: 'Update',
1551value: 'update',
1552foreground: '#2f80ed',
1553background: '#cbdffb',
1554},
1555{
1556text: 'Delete',
1557value: 'delete',
1558foreground: '#eb5757',
1559background: '#fad5d5',
1560},
1561{
1562text: 'Login',
1563value: 'authenticate',
1564foreground: '#9b51e0',
1565background: '#e6d3f7',
1566},
1567],
1568},
1569},
1570{
1571collection: 'directus_activity',
1572field: 'collection',
1573display: 'collection',
1574display_options: {
1575icon: true,
1576},
1577},
1578{
1579collection: 'directus_activity',
1580field: 'timestamp',
1581display: 'datetime',
1582options: {
1583relative: true,
1584},
1585},
1586{
1587collection: 'directus_activity',
1588field: 'user',
1589display: 'user',
1590},
1591{
1592collection: 'directus_activity',
1593field: 'comment',
1594display: 'formatted-text',
1595display_options: {
1596subdued: true,
1597},
1598},
1599{
1600collection: 'directus_activity',
1601field: 'user_agent',
1602display: 'formatted-text',
1603display_options: {
1604font: 'monospace',
1605},
1606},
1607{
1608collection: 'directus_activity',
1609field: 'ip',
1610display: 'formatted-text',
1611display_options: {
1612font: 'monospace',
1613},
1614},
1615{
1616collection: 'directus_activity',
1617field: 'revisions',
1618interface: 'one-to-many',
1619locked: true,
1620special: 'o2m',
1621options: {
1622fields: ['collection', 'item'],
1623},
1624width: 'full',
1625},
1626{
1627collection: 'directus_relations',
1628field: 'one_allowed_collections',
1629locked: true,
1630special: 'csv',
1631},
1632].map((row) => {
1633for (const [key, value] of Object.entries(row)) {
1634if (value !== null && (typeof value === 'object' || Array.isArray(value))) {
1635(row as any)[key] = JSON.stringify(value);
1636}
1637}
1638
1639return merge({}, defaults, row);
1640});
1641
1642export async function up(knex: Knex): Promise<void> {
1643const fieldKeys = uniq(systemFields.map((field: any) => field.field));
1644
1645await knex('directus_fields').delete().where('collection', 'like', 'directus_%').whereIn('field', fieldKeys);
1646}
1647
1648export async function down(knex: Knex): Promise<void> {
1649await knex.insert(systemFields).into('directus_fields');
1650}
1651