From ff6d14354612a9da430d523fa9dbc237cae3a6e2 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 7 Sep 2023 09:38:26 -0300 Subject: infra, data: allow exporting non-classes from things/ files --- src/data/things/index.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/data/things/index.js') diff --git a/src/data/things/index.js b/src/data/things/index.js index 591cdc3b..2d4f77d7 100644 --- a/src/data/things/index.js +++ b/src/data/things/index.js @@ -82,6 +82,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; } } -- cgit 1.3.0-6-gf8a5 From 6889c764caef5542ba9ad8362acf6e8b7b879ea9 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 7 Sep 2023 12:06:06 -0300 Subject: data, infra: import validators directly --- src/data/things/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/data/things/index.js') diff --git a/src/data/things/index.js b/src/data/things/index.js index 2d4f77d7..3b73a772 100644 --- a/src/data/things/index.js +++ b/src/data/things/index.js @@ -4,7 +4,6 @@ import {fileURLToPath} from 'node:url'; import {logError} from '#cli'; import * as serialize from '#serialize'; import {openAggregate, showAggregate} from '#sugar'; -import * as validators from '#validators'; import Thing from './thing.js'; @@ -121,7 +120,7 @@ function descriptorAggregateHelper({ } function evaluatePropertyDescriptors() { - const opts = {...allClasses, validators}; + const opts = {...allClasses}; return descriptorAggregateHelper({ message: `Errors evaluating Thing class property descriptors`, -- cgit 1.3.0-6-gf8a5 From 7b32066dd9629bbb220c2e2425b5294070b5a0db Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 9 Sep 2023 09:16:50 -0300 Subject: infra, data: cut unneeded boilerplate from top-level compositions --- src/data/things/index.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/data/things/index.js') diff --git a/src/data/things/index.js b/src/data/things/index.js index 3b73a772..4d8d9d1f 100644 --- a/src/data/things/index.js +++ b/src/data/things/index.js @@ -2,6 +2,7 @@ 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'; @@ -130,8 +131,16 @@ 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(`${constructor.name}.${key}`, value); + continue; + } + } + + constructor.propertyDescriptors = results; }, showFailedClasses(failedClasses) { -- cgit 1.3.0-6-gf8a5 From cc4bf401f4d1df63ce33191ae82af6327c7da568 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 20 Sep 2023 17:33:50 -0300 Subject: data: fix many validation errors --- src/data/things/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/data/things/index.js') diff --git a/src/data/things/index.js b/src/data/things/index.js index 4d8d9d1f..f908653d 100644 --- a/src/data/things/index.js +++ b/src/data/things/index.js @@ -135,7 +135,12 @@ function evaluatePropertyDescriptors() { for (const [key, value] of Object.entries(results)) { if (Array.isArray(value)) { - results[key] = compositeFrom(`${constructor.name}.${key}`, value); + results[key] = compositeFrom({ + annotation: `${constructor.name}.${key}`, + compose: false, + steps: value, + }); + continue; } } -- cgit 1.3.0-6-gf8a5 From 572b5465f9ce1e992e0384aa92461ec11dbaabff Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 21 Sep 2023 11:04:33 -0300 Subject: data: make composites work --- src/data/things/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/data/things/index.js') diff --git a/src/data/things/index.js b/src/data/things/index.js index f908653d..77e5fa76 100644 --- a/src/data/things/index.js +++ b/src/data/things/index.js @@ -140,8 +140,8 @@ function evaluatePropertyDescriptors() { compose: false, steps: value, }); - - continue; + } else if (value.toResolvedComposition) { + results[key] = compositeFrom(value.toResolvedComposition()); } } -- cgit 1.3.0-6-gf8a5 From 645a127bef38c3a7a2ef1b94d23b25fb7bdc4191 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 18 Oct 2023 14:26:49 -0300 Subject: data, test: wrap property value errors with proper class & cause --- src/data/things/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/data/things/index.js') diff --git a/src/data/things/index.js b/src/data/things/index.js index 77e5fa76..4ea1f007 100644 --- a/src/data/things/index.js +++ b/src/data/things/index.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, -- cgit 1.3.0-6-gf8a5