@crombolo/schema 0.39.0 → 0.40.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crombolo/schema",
3
- "version": "0.39.0",
3
+ "version": "0.40.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.39.0",
32
- "@crombolo/data": "0.39.0"
31
+ "@crombolo/core": "0.40.0",
32
+ "@crombolo/data": "0.40.0"
33
33
  }
34
34
  }
package/src/export.ts CHANGED
@@ -113,6 +113,7 @@ export function toSchemaContentType(
113
113
  }
114
114
  if (aggregate.description) type.description = aggregate.description
115
115
  if (aggregate.siteSearch === false) type.siteSearch = false
116
+ if (aggregate.siteSettings) type.siteSettings = true
116
117
  if (aggregate.defaultComponentKey) {
117
118
  const alias = ctx.componentAlias(aggregate.defaultComponentKey)
118
119
  if (alias) type.defaultComponent = alias
@@ -41,6 +41,7 @@ export function generateDeliveryTypes(set: SchemaSet, options: DeliveryTypesOpti
41
41
  const serves = options.serves ?? (() => true)
42
42
  const pages = set.contentTypes.filter((t) => !t.isElement && serves(t.alias)).sort(byAlias)
43
43
  const elements = set.contentTypes.filter((t) => t.isElement).sort(byAlias)
44
+ const settingsTypes = pages.filter((t) => t.siteSettings)
44
45
  const media = mediaTypes(set)
45
46
 
46
47
  const name = (type: SchemaContentType) => `${pascal(type.alias)}Properties`
@@ -160,6 +161,9 @@ export function generateDeliveryTypes(set: SchemaSet, options: DeliveryTypesOpti
160
161
  ' media: {',
161
162
  ...media.map((t) => ` ${key(t.alias)}: ${mediaName(t.alias)}`),
162
163
  ' }',
164
+ ...(settingsTypes.length > 0
165
+ ? [` settings: ${settingsTypes.map((t) => `'${t.alias}'`).join(' | ')}`]
166
+ : []),
163
167
  '}',
164
168
  '',
165
169
  '/** Any page, as the item, query and search endpoints answer it. */',
package/src/model.ts CHANGED
@@ -77,6 +77,8 @@ export interface SchemaContentType {
77
77
  since?: string
78
78
  /** False leaves every page of the type out of site search. */
79
79
  siteSearch?: false
80
+ /** A site's settings (story 058): its page, a root's direct child, has no address. */
81
+ siteSettings?: true
80
82
  /** Properties outside any tab. */
81
83
  properties: SchemaProperty[]
82
84
  /** Groups outside any tab — `[[group]]`; Umbraco's built-in media types use one. */
package/src/parse.ts CHANGED
@@ -66,6 +66,7 @@ const TYPE_KEYS = [
66
66
  'cleanup',
67
67
  'since',
68
68
  'site-search',
69
+ 'site-settings',
69
70
  ] as const
70
71
  const CLEANUP_KEYS = [
71
72
  'prevent',
@@ -305,10 +306,16 @@ export function parseContentType(
305
306
  ...(t['site-search'] !== undefined && typeSiteSearch(r, t, path) === false
306
307
  ? { siteSearch: false as const }
307
308
  : {}),
309
+ ...(r.bool(t, 'site-settings', path, false) ? { siteSettings: true as const } : {}),
308
310
  properties: r.tables(root.property, 'property').map((p, i) => property(r, p, `property[${i}]`)),
309
311
  tabs: r.tables(root.tab, 'tab').map((x, i) => tab(r, x, `tab[${i}]`)),
310
312
  groups: r.tables(root.group, 'group').map((g, i) => group(r, g, `group[${i}]`)),
311
313
  }
314
+ if (value.siteSettings && value.isElement)
315
+ r.problem(
316
+ `${path}.site-settings`,
317
+ "an element type is never a page, so it cannot be a site's settings",
318
+ )
312
319
  return { value: r.problems.length === 0 ? value : undefined, problems: r.problems }
313
320
  }
314
321
 
package/src/sync.ts CHANGED
@@ -574,6 +574,7 @@ export async function syncSchema(
574
574
  collectionKey: t.collection ? (dataTypeKeyByAlias.get(t.collection) ?? null) : null,
575
575
  sinceVersion: t.since ?? null,
576
576
  siteSearch: t.siteSearch !== false,
577
+ siteSettings: t.siteSettings === true,
577
578
  cleanup: {
578
579
  preventCleanup: t.cleanup.prevent,
579
580
  keepAllVersionsNewerThanDays: t.cleanup.keepAllNewerThanDays ?? null,
package/src/write.ts CHANGED
@@ -126,6 +126,7 @@ export function writeContentType(t: SchemaContentType, kind: SchemaTypeKind = 'd
126
126
  line(out, 'folder', t.folder)
127
127
  line(out, 'since', t.since)
128
128
  line(out, 'site-search', false, t.siteSearch === false)
129
+ line(out, 'site-settings', true, t.siteSettings === true)
129
130
  if (
130
131
  t.cleanup.prevent ||
131
132
  t.cleanup.keepAllNewerThanDays !== undefined ||