@crombolo/schema 0.65.1 → 0.67.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 +1 -0
- package/src/describe.ts +6 -0
- package/src/edit.ts +8 -10
- package/src/editors.gen.ts +756 -0
- package/src/editors.ts +79 -0
- package/src/generate-delivery.ts +5 -0
- package/src/generate.ts +17 -0
- package/src/index.ts +1 -0
- package/src/presets.ts +353 -53
- package/src/site-edit.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crombolo/schema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.67.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.67.0",
|
|
32
|
+
"@crombolo/data": "0.67.0"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/config-references.ts
CHANGED
|
@@ -26,6 +26,7 @@ const BLOCK_FIELDS: readonly FieldReference[] = [
|
|
|
26
26
|
]
|
|
27
27
|
|
|
28
28
|
export const CONFIG_REFERENCES: Readonly<Record<string, readonly FieldReference[]>> = {
|
|
29
|
+
'Umbraco.ContentPicker': [{ path: ['allowedContentTypes'], many: true, kind: 'document' }],
|
|
29
30
|
'Umbraco.ElementPicker': [{ path: ['allowedContentTypes'], many: true, kind: 'element' }],
|
|
30
31
|
'Umbraco.MediaPicker3': [{ path: ['filter'], many: true, kind: 'media' }],
|
|
31
32
|
'Umbraco.MultiNodeTreePicker': [{ path: ['filter'], many: true, kind: 'startNode' }],
|
package/src/describe.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
type SchemaDataType,
|
|
13
13
|
type SchemaSet,
|
|
14
14
|
} from './model.ts'
|
|
15
|
+
import { presetOf } from './presets.ts'
|
|
15
16
|
|
|
16
17
|
/** What a definition is, as a person names it. */
|
|
17
18
|
export type DescribedKind = 'content' | 'element' | 'media' | 'member' | 'data'
|
|
@@ -92,6 +93,9 @@ export interface DataTypeDetail {
|
|
|
92
93
|
alias: string
|
|
93
94
|
name: string
|
|
94
95
|
editor: string
|
|
96
|
+
editorUi: string | null
|
|
97
|
+
/** The name `types new data-type --editor` knows it by, when it has one (story 357). */
|
|
98
|
+
preset: string | null
|
|
95
99
|
builtIn: boolean
|
|
96
100
|
/** Its settings by their own names, with the plain name where one is known. */
|
|
97
101
|
settings: Array<{ setting: string; label: string | null; value: unknown }>
|
|
@@ -313,6 +317,8 @@ export function describeType(set: SchemaSet, alias: string, kind?: DescribedKind
|
|
|
313
317
|
alias: dataType.alias,
|
|
314
318
|
name: dataType.name,
|
|
315
319
|
editor: dataType.editor,
|
|
320
|
+
editorUi: dataType.editorUi ?? null,
|
|
321
|
+
preset: presetOf(dataType.editor, dataType.editorUi)?.[0] ?? null,
|
|
316
322
|
builtIn,
|
|
317
323
|
settings: Object.entries(dataType.config).map(([setting, value]) => ({
|
|
318
324
|
setting,
|
package/src/edit.ts
CHANGED
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
type SchemaProperty,
|
|
13
13
|
type SchemaTab,
|
|
14
14
|
} from './model.ts'
|
|
15
|
-
import {
|
|
15
|
+
import { optionFlag, type PresetOptions, presetConfig, presetOf } from './presets.ts'
|
|
16
16
|
import { addProperty } from './scaffold.ts'
|
|
17
17
|
|
|
18
18
|
export { addProperty }
|
|
@@ -290,10 +290,6 @@ export interface DataTypeChanges {
|
|
|
290
290
|
startNode?: string | null
|
|
291
291
|
}
|
|
292
292
|
|
|
293
|
-
/** The preset whose editor a data type uses, when there is one. */
|
|
294
|
-
const presetFor = (dataType: SchemaDataType) =>
|
|
295
|
-
Object.entries(DATA_TYPE_PRESETS).find(([, preset]) => preset.editor === dataType.editor)
|
|
296
|
-
|
|
297
293
|
/** The settings a preset's options write, and only those: the rest of the data type is left as it is. */
|
|
298
294
|
function presetSettings(
|
|
299
295
|
dataType: SchemaDataType,
|
|
@@ -301,17 +297,19 @@ function presetSettings(
|
|
|
301
297
|
): Record<string, unknown> | string {
|
|
302
298
|
const given = Object.entries(options).filter(([, value]) => value !== undefined)
|
|
303
299
|
if (given.length === 0) return {}
|
|
304
|
-
const found =
|
|
300
|
+
const found = presetOf(dataType.editor, dataType.editorUi)
|
|
305
301
|
if (!found) return `"${dataType.editor}" takes no named settings: use --set <setting>=<value>`
|
|
306
302
|
const [name, preset] = found
|
|
307
303
|
const unknown = given.filter(([option]) => !preset.takes.includes(option as keyof PresetOptions))
|
|
308
304
|
if (unknown.length > 0)
|
|
309
305
|
return `${unknown.map(([option]) => optionFlag(option)).join(', ')} does not apply to ${name}: it takes ${preset.takes.map(optionFlag).join(', ') || 'no named settings'}`
|
|
310
|
-
const without = preset
|
|
311
|
-
const withThem = preset
|
|
306
|
+
const without = presetConfig(name, preset, {})
|
|
307
|
+
const withThem = presetConfig(name, preset, options)
|
|
308
|
+
if (typeof withThem === 'string') return withThem
|
|
309
|
+
const before = typeof without === 'string' ? {} : without.config
|
|
312
310
|
return Object.fromEntries(
|
|
313
|
-
Object.entries(withThem).filter(
|
|
314
|
-
([key, value]) => JSON.stringify(value) !== JSON.stringify(
|
|
311
|
+
Object.entries(withThem.config).filter(
|
|
312
|
+
([key, value]) => JSON.stringify(value) !== JSON.stringify(before[key]),
|
|
315
313
|
),
|
|
316
314
|
)
|
|
317
315
|
}
|