« get me outta code hell

data: tidy things folder & imports, nicer fields yaml spec - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/thing.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-01-20 17:23:37 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-01-30 07:59:39 -0400
commit98c2012c0c6233fe3f70ba215c19f6d39d7e1e34 (patch)
treea64dfa62e4134785ad5a4b9b03baaed47aa0854c /src/data/things/thing.js
parent4739ac5fae824c6c985fca9ae34f6335f5c9c13e (diff)
data: tidy things folder & imports, nicer fields yaml spec
Diffstat (limited to 'src/data/things/thing.js')
-rw-r--r--src/data/things/thing.js83
1 files changed, 0 insertions, 83 deletions
diff --git a/src/data/things/thing.js b/src/data/things/thing.js
deleted file mode 100644
index e1f488e..0000000
--- a/src/data/things/thing.js
+++ /dev/null
@@ -1,83 +0,0 @@
-// Thing: base class for wiki data types, providing interfaces generally useful
-// to all wiki data objects on top of foundational CacheableObject behavior.
-
-import {inspect} from 'node:util';
-
-import {colors} from '#cli';
-
-import CacheableObject from './cacheable-object.js';
-
-export default class Thing extends CacheableObject {
-  static referenceType = Symbol.for('Thing.referenceType');
-  static friendlyName = Symbol.for('Thing.friendlyName');
-
-  static getPropertyDescriptors = Symbol.for('Thing.getPropertyDescriptors');
-  static getSerializeDescriptors = Symbol.for('Thing.getSerializeDescriptors');
-
-  static yamlDocumentSpec = Symbol.for('Thing.yamlDocumentSpec');
-
-  // Default custom inspect function, which may be overridden by Thing
-  // subclasses. This will be used when displaying aggregate errors and other
-  // command-line logging - it's the place to provide information useful in
-  // identifying the Thing being presented.
-  [inspect.custom]() {
-    const cname = this.constructor.name;
-
-    return (
-      (this.name ? `${cname} ${colors.green(`"${this.name}"`)}` : `${cname}`) +
-      (this.directory ? ` (${colors.blue(Thing.getReference(this))})` : '')
-    );
-  }
-
-  static getReference(thing) {
-    if (!thing.constructor[Thing.referenceType]) {
-      throw TypeError(`Passed Thing is ${thing.constructor.name}, which provides no [Thing.referenceType]`);
-    }
-
-    if (!thing.directory) {
-      throw TypeError(`Passed ${thing.constructor.name} is missing its directory`);
-    }
-
-    return `${thing.constructor[Thing.referenceType]}:${thing.directory}`;
-  }
-
-  static extendDocumentSpec(thingClass, subspec) {
-    const superspec = thingClass[Thing.yamlDocumentSpec];
-
-    const {
-      fieldTransformations,
-      propertyFieldMapping,
-      ignoredFields,
-      invalidFieldCombinations,
-      ...restOfSubspec
-    } = subspec;
-
-    const newFields =
-      Object.values(subspec.propertyFieldMapping ?? {});
-
-    return {
-      ...superspec,
-      ...restOfSubspec,
-
-      fieldTransformations: {
-        ...superspec.fieldTransformations,
-        ...fieldTransformations,
-      },
-
-      propertyFieldMapping: {
-        ...superspec.propertyFieldMapping,
-        ...propertyFieldMapping,
-      },
-
-      ignoredFields:
-        (superspec.ignoredFields ?? [])
-          .filter(field => newFields.includes(field))
-          .concat(ignoredFields ?? []),
-
-      invalidFieldCombinations: [
-        ...superspec.invalidFieldCombinations ?? [],
-        ...invalidFieldCombinations ?? [],
-      ],
-    };
-  }
-}