« get me outta code hell

hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/thing.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/thing.js')
-rw-r--r--src/data/thing.js52
1 files changed, 42 insertions, 10 deletions
diff --git a/src/data/thing.js b/src/data/thing.js
index 9a8cec91..f719224d 100644
--- a/src/data/thing.js
+++ b/src/data/thing.js
@@ -14,9 +14,21 @@ export default class Thing extends CacheableObject {
   static getSerializeDescriptors = Symbol.for('Thing.getSerializeDescriptors');
 
   static findSpecs = Symbol.for('Thing.findSpecs');
+  static findThisThingOnly = Symbol.for('Thing.findThisThingOnly');
+
+  static reverseSpecs = Symbol.for('Thing.reverseSpecs');
+
   static yamlDocumentSpec = Symbol.for('Thing.yamlDocumentSpec');
   static getYamlLoadingSpec = Symbol.for('Thing.getYamlLoadingSpec');
 
+  static yamlSourceFilename = Symbol.for('Thing.yamlSourceFilename');
+  static yamlSourceDocument = Symbol.for('Thing.yamlSourceDocument');
+  static yamlSourceDocumentPlacement = Symbol.for('Thing.yamlSourceDocumentPlacement');
+
+  [Symbol.for('Thing.yamlSourceFilename')] = null;
+  [Symbol.for('Thing.yamlSourceDocument')] = null;
+  [Symbol.for('Thing.yamlSourceDocumentPlacement')] = null;
+
   static isThingConstructor = Symbol.for('Thing.isThingConstructor');
   static isThing = Symbol.for('Thing.isThing');
 
@@ -24,26 +36,46 @@ export default class Thing extends CacheableObject {
   // Symbol.for('Thing.isThingConstructor') in constructor
   static [Symbol.for('Thing.isThingConstructor')] = NaN;
 
-  static [CacheableObject.propertyDescriptors] = {
+  constructor() {
+    super({seal: false});
+
     // To detect:
     // Object.hasOwn(object, Symbol.for('Thing.isThing'))
-    [Symbol.for('Thing.isThing')]: {
-      flags: {expose: true},
-      expose: {compute: () => NaN},
-    },
-  };
+    this[Symbol.for('Thing.isThing')] = NaN;
+
+    Object.seal(this);
+  }
+
+  static [Symbol.for('Thing.selectAll')] = _wikiData => [];
 
   // 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;
+    const constructorName = this.constructor.name;
+
+    let name;
+    try {
+      if (this.name) {
+        name = colors.green(`"${this.name}"`);
+      }
+    } catch {
+      name = colors.yellow(`couldn't get name`);
+    }
+
+    let reference;
+    try {
+      if (this.directory) {
+        reference = colors.blue(Thing.getReference(this));
+      }
+    } catch {
+      reference = colors.yellow(`couldn't get reference`);
+    }
 
     return (
-      (this.name ? `${cname} ${colors.green(`"${this.name}"`)}` : `${cname}`) +
-      (this.directory ? ` (${colors.blue(Thing.getReference(this))})` : '')
-    );
+      (name ? `${constructorName} ${name}` : `${constructorName}`) +
+      (reference ? ` (${reference})` : ''));
   }
 
   static getReference(thing) {