« get me outta code hell

data: split group.js - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things/group/Series.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-01-26 13:38:13 -0400
committer(quasar) nebula <qznebula@protonmail.com>2026-01-26 13:47:00 -0400
commitaa3cb2dd34780fd97873340c3faf7388993fa8d8 (patch)
tree110f77c2f333c251fe61ee51f4faad0b4d2547fd /src/data/things/group/Series.js
parentec05edf5ad729f6a02618f88ca1cfe3ef6a6f0ea (diff)
data: split group.js
Diffstat (limited to 'src/data/things/group/Series.js')
-rw-r--r--src/data/things/group/Series.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/src/data/things/group/Series.js b/src/data/things/group/Series.js
new file mode 100644
index 00000000..940fe575
--- /dev/null
+++ b/src/data/things/group/Series.js
@@ -0,0 +1,79 @@
+import {inspect} from 'node:util';
+
+import {colors} from '#cli';
+import {input, V} from '#composite';
+import Thing from '#thing';
+import {is} from '#validators';
+
+import {contentString, name, referenceList, soupyFind, thing}
+  from '#composite/wiki-properties';
+
+export class Series extends Thing {
+  static [Thing.wikiData] = 'seriesData';
+
+  static [Thing.getPropertyDescriptors] = ({Album, Group}) => ({
+    // Update & expose
+
+    name: name(V('Unnamed Series')),
+
+    showAlbumArtists: {
+      flags: {update: true, expose: true},
+      update: {
+        validate:
+          is('all', 'differing', 'none'),
+      },
+    },
+
+    description: contentString(),
+
+    group: thing(V(Group)),
+
+    albums: referenceList({
+      class: input.value(Album),
+      find: soupyFind.input('album'),
+    }),
+
+    // Update only
+
+    find: soupyFind(),
+  });
+
+  static [Thing.yamlDocumentSpec] = {
+    fields: {
+      'Name': {property: 'name'},
+
+      'Description': {property: 'description'},
+
+      'Show Album Artists': {property: 'showAlbumArtists'},
+
+      'Albums': {property: 'albums'},
+    },
+  };
+
+  [inspect.custom](depth, options, inspect) {
+    const parts = [];
+
+    parts.push(Thing.prototype[inspect.custom].apply(this));
+
+    if (depth >= 0) showGroup: {
+      let group = null;
+      try {
+        group = this.group;
+      } catch {
+        break showGroup;
+      }
+
+      const groupName = group.name;
+      const groupIndex = group.serieses.indexOf(this);
+
+      const num =
+        (groupIndex === -1
+          ? 'indeterminate position'
+          : `#${groupIndex + 1}`);
+
+      parts.push(` (${colors.yellow(num)} in ${colors.green(`"${groupName}"`)})`);
+    }
+
+    return parts.join('');
+  }
+}