@crombolo/schema 0.63.0 → 0.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/config-references.ts +3 -2
- package/src/edit.ts +1 -2
- package/src/generate-delivery.ts +6 -0
- package/src/generate.ts +5 -0
- package/src/presets.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.0",
|
|
4
4
|
"description": "Internal to crombolo, with no compatibility promise: use @crombolo/crombolo. Schema-as-code for crombolo: TOML document, media and member type definitions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Crombolo",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"access": "public"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@crombolo/core": "0.
|
|
32
|
-
"@crombolo/data": "0.
|
|
31
|
+
"@crombolo/core": "0.64.0",
|
|
32
|
+
"@crombolo/data": "0.64.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/config-references.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* where it expects one), and export writes keys back as aliases. A value shaped
|
|
6
6
|
* like a uuid is a key already and passes through either way.
|
|
7
7
|
*/
|
|
8
|
+
import { BLOCK_EDITORS } from '@crombolo/core'
|
|
8
9
|
import type { SchemaTypeKind } from './model.ts'
|
|
9
10
|
|
|
10
11
|
/** What a reference must name: an element type, or a type of one kind. */
|
|
@@ -28,8 +29,8 @@ export const CONFIG_REFERENCES: Readonly<Record<string, readonly FieldReference[
|
|
|
28
29
|
'Umbraco.ElementPicker': [{ path: ['allowedContentTypes'], many: true, kind: 'element' }],
|
|
29
30
|
'Umbraco.MediaPicker3': [{ path: ['filter'], many: true, kind: 'media' }],
|
|
30
31
|
'Umbraco.MultiNodeTreePicker': [{ path: ['filter'], many: true, kind: 'startNode' }],
|
|
31
|
-
'
|
|
32
|
-
|
|
32
|
+
// Every block editor's blocks are element types; a grid's areas name more.
|
|
33
|
+
...Object.fromEntries([...BLOCK_EDITORS].map((editor) => [editor, BLOCK_FIELDS])),
|
|
33
34
|
'Umbraco.BlockGrid': [
|
|
34
35
|
...BLOCK_FIELDS,
|
|
35
36
|
{
|
package/src/edit.ts
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* the changed type, or the reason it cannot change. Whether the change is safe
|
|
5
5
|
* for the site's content is the check's to say, not these.
|
|
6
6
|
*/
|
|
7
|
+
import { BLOCK_EDITORS } from '@crombolo/core'
|
|
7
8
|
import {
|
|
8
9
|
allProperties,
|
|
9
10
|
type SchemaContentType,
|
|
@@ -289,8 +290,6 @@ export interface DataTypeChanges {
|
|
|
289
290
|
startNode?: string | null
|
|
290
291
|
}
|
|
291
292
|
|
|
292
|
-
const BLOCK_EDITORS = new Set(['Umbraco.BlockList', 'Umbraco.BlockGrid', 'Umbraco.RichText'])
|
|
293
|
-
|
|
294
293
|
/** The preset whose editor a data type uses, when there is one. */
|
|
295
294
|
const presetFor = (dataType: SchemaDataType) =>
|
|
296
295
|
Object.entries(DATA_TYPE_PRESETS).find(([, preset]) => preset.editor === dataType.editor)
|
package/src/generate-delivery.ts
CHANGED
|
@@ -94,6 +94,11 @@ export function generateDeliveryTypes(set: SchemaSet, options: DeliveryTypesOpti
|
|
|
94
94
|
const { content, settings } = blockElements(set, config, blocks)
|
|
95
95
|
return `ApiBlockGrid<${elementUnion(content)}, ${elementUnion(settings)}>`
|
|
96
96
|
}
|
|
97
|
+
// One item; null when empty, as any property here may be (story 345).
|
|
98
|
+
case 'Umbraco.SingleBlock': {
|
|
99
|
+
const { content, settings } = blockElements(set, config, blocks)
|
|
100
|
+
return `ApiBlockListItem<${elementUnion(content)}, ${elementUnion(settings)}>`
|
|
101
|
+
}
|
|
97
102
|
case 'Umbraco.ElementPicker': {
|
|
98
103
|
return `Array<${elementUnion([...new Set(keyAliases(set, config.allowedContentTypes))])}>`
|
|
99
104
|
}
|
|
@@ -212,6 +217,7 @@ export function generateDeliveryTypes(set: SchemaSet, options: DeliveryTypesOpti
|
|
|
212
217
|
const shapes = [
|
|
213
218
|
'ApiBlockGrid',
|
|
214
219
|
'ApiBlockList',
|
|
220
|
+
'ApiBlockListItem',
|
|
215
221
|
'ApiColor',
|
|
216
222
|
'ApiContentReference',
|
|
217
223
|
'ApiElement',
|
package/src/generate.ts
CHANGED
|
@@ -119,6 +119,11 @@ function tsTypeFor(set: SchemaSet, dataTypeAlias: string): string {
|
|
|
119
119
|
const { content } = blockElements(set, config, blocks)
|
|
120
120
|
return `BlockListValue<BlockGridItem & { content: ${elementUnion(content)} }>`
|
|
121
121
|
}
|
|
122
|
+
// One block, or null (story 345).
|
|
123
|
+
case 'Umbraco.SingleBlock': {
|
|
124
|
+
const { content, settings } = blockElements(set, config, blocks)
|
|
125
|
+
return `(BlockItem & { content: ${elementUnion(content)}; settings: ${settings.length ? `${elementUnion(settings)} | null` : 'PublishedElement | null'} }) | null`
|
|
126
|
+
}
|
|
122
127
|
}
|
|
123
128
|
switch (storageTypeFor(editor)) {
|
|
124
129
|
case 'Integer':
|
package/src/presets.ts
CHANGED
|
@@ -122,6 +122,13 @@ export const DATA_TYPE_PRESETS: Readonly<Record<string, Preset>> = {
|
|
|
122
122
|
takes: ['block', 'min', 'max'],
|
|
123
123
|
build: (o) => ({ config: defined({ validationLimit: limit(o) }), blocks: blocks(o) }),
|
|
124
124
|
},
|
|
125
|
+
// One block: a page's one hero or call to action (story 345).
|
|
126
|
+
'single-block': {
|
|
127
|
+
editor: 'Umbraco.SingleBlock',
|
|
128
|
+
editorUi: 'Umb.PropertyEditorUi.BlockSingle',
|
|
129
|
+
takes: ['block'],
|
|
130
|
+
build: (o) => ({ config: {}, blocks: blocks(o) }),
|
|
131
|
+
},
|
|
125
132
|
'block-grid': {
|
|
126
133
|
editor: 'Umbraco.BlockGrid',
|
|
127
134
|
editorUi: 'Umb.PropertyEditorUi.BlockGrid',
|