UNPKG

2.61 kBTypeScriptView Raw
1import type { KeyValueMap } from '../common-types';
2import type { INLINES, BLOCKS } from '@contentful/rich-text-types';
3interface NumRange {
4 min?: number;
5 max?: number;
6}
7interface DateRange {
8 min?: string;
9 max?: string;
10}
11interface RegExp {
12 pattern: string;
13 flags: string;
14}
15interface NodesValidation {
16 [BLOCKS.EMBEDDED_ENTRY]?: Pick<ContentTypeFieldValidation, 'size' | 'linkContentType' | 'message'>[];
17 [INLINES.EMBEDDED_ENTRY]?: Pick<ContentTypeFieldValidation, 'size' | 'linkContentType' | 'message'>[];
18 [INLINES.ENTRY_HYPERLINK]?: Pick<ContentTypeFieldValidation, 'size' | 'linkContentType' | 'message'>[];
19 [BLOCKS.EMBEDDED_ASSET]?: Pick<ContentTypeFieldValidation, 'size' | 'message'>[];
20 [INLINES.ASSET_HYPERLINK]?: Pick<ContentTypeFieldValidation, 'size' | 'message'>[];
21 [BLOCKS.EMBEDDED_RESOURCE]?: {
22 validations: Pick<ContentTypeFieldValidation, 'size' | 'message'>[];
23 allowedResources: ContentTypeAllowedResources[];
24 };
25 [INLINES.EMBEDDED_RESOURCE]?: {
26 validations: Pick<ContentTypeFieldValidation, 'size' | 'message'>[];
27 allowedResources: ContentTypeAllowedResources[];
28 };
29 [INLINES.RESOURCE_HYPERLINK]?: {
30 validations: Pick<ContentTypeFieldValidation, 'size' | 'message'>[];
31 allowedResources: ContentTypeAllowedResources[];
32 };
33}
34export interface ContentTypeFieldValidation {
35 linkContentType?: string[];
36 in?: (string | number)[];
37 linkMimetypeGroup?: string[];
38 enabledNodeTypes?: (`${BLOCKS}` | `${INLINES}`)[];
39 enabledMarks?: string[];
40 unique?: boolean;
41 size?: NumRange;
42 range?: NumRange;
43 dateRange?: DateRange;
44 regexp?: RegExp;
45 message?: string | null;
46 prohibitRegexp?: RegExp;
47 assetImageDimensions?: {
48 width?: NumRange;
49 height?: NumRange;
50 };
51 assetFileSize?: NumRange;
52 nodes?: NodesValidation;
53}
54interface Item {
55 type: string;
56 linkType?: string;
57 validations?: ContentTypeFieldValidation[];
58}
59type ContentTypeAllowedResources = ContentfulEntryResource | ExternalResource;
60export interface ContentfulEntryResource {
61 type: 'Contentful:Entry';
62 source: string;
63 contentTypes: string[];
64}
65export interface ExternalResource {
66 type: string;
67}
68export interface ContentFields<T = KeyValueMap> extends Item {
69 id: string;
70 name: string;
71 required: boolean;
72 localized: boolean;
73 disabled?: boolean;
74 omitted?: boolean;
75 deleted?: boolean;
76 items?: Item;
77 apiName?: string;
78 defaultValue?: T;
79 allowedResources?: ContentTypeAllowedResources[];
80}
81export {};