Skip to content

Commit 69422d0

Browse files
committed
[TASK] Add Schema for Record Types
1 parent 923c61e commit 69422d0

File tree

5 files changed

+6022
-0
lines changed

5 files changed

+6022
-0
lines changed
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema",
3+
"$id": "http://typo3.org/record-type.json",
4+
"title": "Record Type",
5+
"description": "TYPO3 CMS Content Blocks Record Type",
6+
"additionalProperties": false,
7+
"properties": {
8+
"group": {},
9+
"typeName": {},
10+
"name": {},
11+
"title": {},
12+
"prefixFields": {},
13+
"prefixType": {},
14+
"vendorPrefix": {},
15+
"priority": {},
16+
"basics": {},
17+
"fields": {},
18+
"table": {},
19+
"labelField": {},
20+
"fallbackLabelFields": {},
21+
"typeField": {},
22+
"languageAware": {},
23+
"workspaceAware": {},
24+
"editLocking": {},
25+
"restriction": {},
26+
"softDelete": {},
27+
"trackCreationDate": {},
28+
"trackUpdateDate": {},
29+
"sortable": {},
30+
"sortField": {},
31+
"internalDescription": {},
32+
"rootLevelType": {},
33+
"security": {},
34+
"readOnly": {},
35+
"adminOnly": {},
36+
"hideAtCopy": {},
37+
"appendLabelAtCopy": {}
38+
},
39+
"allOf": [
40+
{
41+
"type": "object",
42+
"properties": {
43+
"table": {
44+
"type": "string",
45+
"description": "The custom table name to be used for the new Record Type."
46+
},
47+
"group": {
48+
"type": "string",
49+
"description": "Group name the Content Block should be displayed in"
50+
},
51+
"typeName": {
52+
"description": "Unqique type identifier for this Content Block",
53+
"type": "string"
54+
},
55+
"labelField": {
56+
"description": "Defines which field should be used as the title of the record.",
57+
"oneOf": [
58+
{
59+
"type": "string"
60+
},
61+
{
62+
"type": "array",
63+
"items": {
64+
"type": "string"
65+
}
66+
}
67+
]
68+
},
69+
"fallbackLabelFields": {
70+
"description": "Defines which fields should be used as fallback, if labelField is not filled.",
71+
"type": "array",
72+
"items": {
73+
"type": "string"
74+
}
75+
},
76+
"typeField": {
77+
"description": "The field identifier to use as the type switch.",
78+
"type": "string"
79+
},
80+
"languageAware": {
81+
"description": "Whether the record type should be language-aware.",
82+
"type": "boolean",
83+
"default": true
84+
},
85+
"workspaceAware": {
86+
"description": "Whether the record type should be workspace-aware.",
87+
"type": "boolean",
88+
"default": true
89+
},
90+
"editLocking": {
91+
"description": "Whether the edit-locking functionality should be available",
92+
"type": "boolean",
93+
"default": true
94+
},
95+
"restriction": {
96+
"type": "object",
97+
"description": "There are several restrictions in TYPO3, which filter records by certain constraints.",
98+
"additionalProperties": false,
99+
"properties": {
100+
"disabled": {
101+
"type": "boolean",
102+
"default": true
103+
},
104+
"startTime": {
105+
"type": "boolean",
106+
"default": true
107+
},
108+
"endTime": {
109+
"type": "boolean",
110+
"default": true
111+
},
112+
"userGroup": {
113+
"type": "boolean",
114+
"default": true
115+
}
116+
}
117+
},
118+
"softDelete": {
119+
"type": "boolean",
120+
"description": "When deleting records in the TYPO3 backend, they are not really deleted in the database.",
121+
"default": true
122+
},
123+
"trackCreationDate": {
124+
"type": "boolean",
125+
"description": "Tracks the timestamp of the creation date.",
126+
"default": true
127+
},
128+
"trackUpdateDate": {
129+
"type": "boolean",
130+
"description": "Tracks the timestamp of the last update.",
131+
"default": true
132+
},
133+
"sortable": {
134+
"type": "boolean",
135+
"description": "Tracks the order of records.",
136+
"default": true
137+
},
138+
"sortField": {
139+
"description": "The field identifier to use for sorting records.",
140+
"oneOf": [
141+
{
142+
"type": "string"
143+
},
144+
{
145+
"type": "array",
146+
"items": {
147+
"type": "object",
148+
"additionalProperties": false,
149+
"properties": {
150+
"identifier": {
151+
"type": "string"
152+
},
153+
"order": {
154+
"type": "string",
155+
"enum": ["asc", "desc"]
156+
}
157+
}
158+
}
159+
}
160+
]
161+
},
162+
"internalDescription": {
163+
"type": "boolean",
164+
"description": "Adds a new tab Notes with a description field.",
165+
"default": false
166+
},
167+
"rootLevelType": {
168+
"type": "string",
169+
"description": "Restricts the place, where the record can be created.",
170+
"enum": ["onlyOnPages", "onlyOnRootLevel", "both"],
171+
"default": "onlyOnPages"
172+
},
173+
"security": {
174+
"type": "object",
175+
"additionalProperties": false,
176+
"properties": {
177+
"ignoreWebMountRestriction": {
178+
"type": "boolean"
179+
},
180+
"ignoreRootLevelRestriction": {
181+
"type": "boolean"
182+
},
183+
"ignorePageTypeRestriction": {
184+
"type": "boolean"
185+
}
186+
}
187+
},
188+
"readOnly": {
189+
"type": "boolean",
190+
"description": "If enabled, the record can not be edited in the TYPO3 backend anymore.",
191+
"default": false
192+
},
193+
"adminOnly": {
194+
"type": "boolean",
195+
"description": "If enabled, only admins can edit the record.",
196+
"default": false
197+
},
198+
"hideAtCopy": {
199+
"type": "boolean",
200+
"description": "If enabled, the record will be disabled, when copied. Only works, if restriction.disabled is set to true.",
201+
"default": false
202+
},
203+
"appendLabelAtCopy": {
204+
"type": "string",
205+
"description": "If set, the label field labelField will be appended with this string, when copied."
206+
}
207+
}
208+
},
209+
{
210+
"$ref": "content-type.json"
211+
}
212+
]
213+
}

Build/JsonSchema/json-schema-bundler.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,17 @@ let contentElementSchemaJson = JSON.stringify(contentElementSchema, null, 2);
1111
let pageTypeSchema = await $RefParser.bundle(join(__dirname, 'SchemaSources/page-type.json'));
1212
let pageTypeSchemaJson = JSON.stringify(pageTypeSchema, null, 2);
1313

14+
let recordTypeSchema = await $RefParser.bundle(join(__dirname, 'SchemaSources/record-type.json'));
15+
let recordTypeSchemaJson = JSON.stringify(recordTypeSchema, null, 2);
16+
1417
const contentElementOutputPath = join(__dirname, '../../JsonSchema/content-element.schema.json');
1518
await mkdir(dirname(contentElementOutputPath), { recursive: true });
1619
await writeFile(contentElementOutputPath, contentElementSchemaJson);
1720

1821
const pageTypeOutputPath = join(__dirname, '../../JsonSchema/page-type.schema.json');
1922
await mkdir(dirname(pageTypeOutputPath), { recursive: true });
2023
await writeFile(pageTypeOutputPath, pageTypeSchemaJson);
24+
25+
const recordTypeOutputPath = join(__dirname, '../../JsonSchema/record-type.schema.json');
26+
await mkdir(dirname(recordTypeOutputPath), { recursive: true });
27+
await writeFile(recordTypeOutputPath, recordTypeSchemaJson);

Classes/JsonSchemaValidation/JsonSchemaValidator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ public function validateContentElement(object $data, string $schemaIdentifier):
3535
'http://typo3.org/page-type.json',
3636
__DIR__ . '/../../JsonSchema/page-type.schema.json'
3737
);
38+
$validator->resolver()->registerFile(
39+
'http://typo3.org/record-type.json',
40+
__DIR__ . '/../../JsonSchema/record-type.schema.json'
41+
);
3842
$result = $validator->validate($data, $schemaIdentifier);
3943
return !$result->hasError();
4044
}

0 commit comments

Comments
 (0)