diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2025-11-20 11:55:28 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2025-11-25 07:06:48 -0400 |
| commit | 03142771e556f9e115709832a98d81942528f10a (patch) | |
| tree | 03fa9e4be249310f855476c7c48664dc8fe36f10 /src/data/things | |
| parent | f2b4a2df290394af1c079aab2f818aa34edcfe7d (diff) | |
data, infra: auto-inherit yaml document specs
Diffstat (limited to 'src/data/things')
| -rw-r--r-- | src/data/things/homepage-layout.js | 12 | ||||
| -rw-r--r-- | src/data/things/index.js | 36 |
2 files changed, 32 insertions, 16 deletions
diff --git a/src/data/things/homepage-layout.js b/src/data/things/homepage-layout.js index d00a2f4b..7c97935e 100644 --- a/src/data/things/homepage-layout.js +++ b/src/data/things/homepage-layout.js @@ -265,11 +265,11 @@ export class HomepageLayoutActionsRow extends HomepageLayoutRow { }, }); - static [Thing.yamlDocumentSpec] = Thing.extendDocumentSpec(HomepageLayoutRow, { + static [Thing.yamlDocumentSpec] = { fields: { 'Actions': {property: 'actionLinks'}, }, - }); + }; } export class HomepageLayoutAlbumCarouselRow extends HomepageLayoutRow { @@ -297,11 +297,11 @@ export class HomepageLayoutAlbumCarouselRow extends HomepageLayoutRow { }, }); - static [Thing.yamlDocumentSpec] = Thing.extendDocumentSpec(HomepageLayoutRow, { + static [Thing.yamlDocumentSpec] = { fields: { 'Albums': {property: 'albums'}, }, - }); + }; } export class HomepageLayoutAlbumGridRow extends HomepageLayoutRow { @@ -361,11 +361,11 @@ export class HomepageLayoutAlbumGridRow extends HomepageLayoutRow { }, }); - static [Thing.yamlDocumentSpec] = Thing.extendDocumentSpec(HomepageLayoutRow, { + static [Thing.yamlDocumentSpec] = { fields: { 'Group': {property: 'sourceGroup'}, 'Count': {property: 'countAlbumsFromGroup'}, 'Albums': {property: 'sourceAlbums'}, }, - }); + }; } diff --git a/src/data/things/index.js b/src/data/things/index.js index 33fc933d..893684de 100644 --- a/src/data/things/index.js +++ b/src/data/things/index.js @@ -216,6 +216,27 @@ function evaluateSerializeDescriptors() { }); } +function finalizeYamlDocumentSpecs() { + return descriptorAggregateHelper({ + message: `Errors finalizing Thing YAML document specs`, + + op(constructor) { + const superclass = Object.getPrototypeOf(constructor); + if ( + constructor[Thing.yamlDocumentSpec] && + superclass[Thing.yamlDocumentSpec] + ) { + constructor[Thing.yamlDocumentSpec] = + Thing.extendDocumentSpec(superclass, constructor[Thing.yamlDocumentSpec]); + } + }, + + showFailedClasses(failedClasses) { + logError`Failed to finalize YAML document specs for classes: ${failedClasses.join(', ')}`; + }, + }); +} + function finalizeCacheableObjectPrototypes() { return descriptorAggregateHelper({ message: `Errors finalizing Thing class prototypes`, @@ -230,19 +251,14 @@ function finalizeCacheableObjectPrototypes() { }); } -if (!errorDuplicateClassNames()) - process.exit(1); +if (!errorDuplicateClassNames()) process.exit(1); flattenClassLists(); -if (!evaluatePropertyDescriptors()) - process.exit(1); - -if (!evaluateSerializeDescriptors()) - process.exit(1); - -if (!finalizeCacheableObjectPrototypes()) - process.exit(1); +if (!evaluatePropertyDescriptors()) process.exit(1); +if (!evaluateSerializeDescriptors()) process.exit(1); +if (!finalizeYamlDocumentSpecs()) process.exit(1); +if (!finalizeCacheableObjectPrototypes()) process.exit(1); Object.assign(allClasses, {Thing}); |