« get me outta code hell

Merge branch 'preview' into listing-tweaks - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/index.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-10-29 09:26:59 -0300
committer(quasar) nebula <qznebula@protonmail.com>2023-10-29 09:26:59 -0300
commitbfa1953e79a562ee675940b7acc52b5b29d22d8f (patch)
tree5c1cd2f4050c801a60f4b65b367a714ed0979759 /src/data/things/index.js
parentc4ef4ced62d659d217873c6c48dd8038dbf765af (diff)
parent940b2cbf8b68eb0b446cca0feeb507840c486394 (diff)
Merge branch 'preview' into listing-tweaks
Diffstat (limited to 'src/data/things/index.js')
-rw-r--r--src/data/things/index.js29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/data/things/index.js b/src/data/things/index.js
index 591cdc3b..4ea1f007 100644
--- a/src/data/things/index.js
+++ b/src/data/things/index.js
@@ -2,9 +2,9 @@ import * as path from 'node:path';
 import {fileURLToPath} from 'node:url';
 
 import {logError} from '#cli';
+import {compositeFrom} from '#composite';
 import * as serialize from '#serialize';
 import {openAggregate, showAggregate} from '#sugar';
-import * as validators from '#validators';
 
 import Thing from './thing.js';
 
@@ -21,7 +21,11 @@ import * as trackClasses from './track.js';
 import * as wikiInfoClasses from './wiki-info.js';
 
 export {default as Thing} from './thing.js';
-export {default as CacheableObject} from './cacheable-object.js';
+
+export {
+  default as CacheableObject,
+  CacheableObjectPropertyValueError,
+} from './cacheable-object.js';
 
 const allClassLists = {
   'album.js': albumClasses,
@@ -82,6 +86,8 @@ function errorDuplicateClassNames() {
 function flattenClassLists() {
   for (const classes of Object.values(allClassLists)) {
     for (const [name, constructor] of Object.entries(classes)) {
+      if (typeof constructor !== 'function') continue;
+      if (!(constructor.prototype instanceof Thing)) continue;
       allClasses[name] = constructor;
     }
   }
@@ -119,7 +125,7 @@ function descriptorAggregateHelper({
 }
 
 function evaluatePropertyDescriptors() {
-  const opts = {...allClasses, validators};
+  const opts = {...allClasses};
 
   return descriptorAggregateHelper({
     message: `Errors evaluating Thing class property descriptors`,
@@ -129,8 +135,21 @@ function evaluatePropertyDescriptors() {
         throw new Error(`Missing [Thing.getPropertyDescriptors] function`);
       }
 
-      constructor.propertyDescriptors =
-        constructor[Thing.getPropertyDescriptors](opts);
+      const results = constructor[Thing.getPropertyDescriptors](opts);
+
+      for (const [key, value] of Object.entries(results)) {
+        if (Array.isArray(value)) {
+          results[key] = compositeFrom({
+            annotation: `${constructor.name}.${key}`,
+            compose: false,
+            steps: value,
+          });
+        } else if (value.toResolvedComposition) {
+          results[key] = compositeFrom(value.toResolvedComposition());
+        }
+      }
+
+      constructor.propertyDescriptors = results;
     },
 
     showFailedClasses(failedClasses) {