directus

Форк
0
/
20201029C-remove-system-fields.ts 
1650 строк · 27.9 Кб
1
import type { Knex } from 'knex';
2
import { merge, uniq } from 'lodash-es';
3

4
const defaults = {
5
	collection: null,
6
	field: null,
7
	special: null,
8
	interface: null,
9
	options: null,
10
	display: null,
11
	display_options: null,
12
	locked: false,
13
	readonly: false,
14
	hidden: false,
15
	sort: null,
16
	width: 'full',
17
	group: null,
18
	translations: null,
19
	note: null,
20
};
21

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

1639
	return merge({}, defaults, row);
1640
});
1641

1642
export async function up(knex: Knex): Promise<void> {
1643
	const fieldKeys = uniq(systemFields.map((field: any) => field.field));
1644

1645
	await knex('directus_fields').delete().where('collection', 'like', 'directus_%').whereIn('field', fieldKeys);
1646
}
1647

1648
export async function down(knex: Knex): Promise<void> {
1649
	await knex.insert(systemFields).into('directus_fields');
1650
}
1651

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.