« 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/things/artist.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/data/things/artist.js')
-rw-r--r--src/data/things/artist.js118
1 files changed, 113 insertions, 5 deletions
diff --git a/src/data/things/artist.js b/src/data/things/artist.js
index 9e329c74..accebf20 100644
--- a/src/data/things/artist.js
+++ b/src/data/things/artist.js
@@ -5,14 +5,21 @@ import {inspect} from 'node:util';
 import CacheableObject from '#cacheable-object';
 import {colors} from '#cli';
 import {input} from '#composite';
-import {sortAlphabetically} from '#sort';
 import {stitchArrays} from '#sugar';
 import Thing from '#thing';
 import {isName, validateArrayItems} from '#validators';
 import {getKebabCase} from '#wiki-data';
 import {parseArtwork} from '#yaml';
 
-import {exitWithoutDependency} from '#composite/control-flow';
+import {
+  sortAlbumsTracksChronologically,
+  sortArtworksChronologically,
+  sortAlphabetically,
+  sortContributionsChronologically,
+} from '#sort';
+
+import {exitWithoutDependency, exposeConstant} from '#composite/control-flow';
+import {withReverseReferenceList} from '#composite/wiki-data';
 
 import {
   constitutibleArtwork,
@@ -26,7 +33,6 @@ import {
   soupyFind,
   soupyReverse,
   urls,
-  wikiData,
 } from '#composite/wiki-properties';
 
 import {artistTotalDuration} from '#composite/things/artist';
@@ -35,7 +41,7 @@ export class Artist extends Thing {
   static [Thing.referenceType] = 'artist';
   static [Thing.wikiDataArray] = 'artistData';
 
-  static [Thing.getPropertyDescriptors] = ({Album, Flash, Group, Track}) => ({
+  static [Thing.getPropertyDescriptors] = () => ({
     // Update & expose
 
     name: name('Unnamed Artist'),
@@ -77,6 +83,12 @@ export class Artist extends Thing {
 
     // Expose only
 
+    isArtist: [
+      exposeConstant({
+        value: input.value(true),
+      }),
+    ],
+
     trackArtistContributions: reverseReferenceList({
       reverse: soupyReverse.input('trackArtistContributionsBy'),
     }),
@@ -125,6 +137,102 @@ export class Artist extends Thing {
       reverse: soupyReverse.input('groupsCloselyLinkedTo'),
     }),
 
+    musicContributions: [
+      withReverseReferenceList({
+        reverse: soupyReverse.input('trackArtistContributionsBy'),
+      }).outputs({
+        '#reverseReferenceList': '#trackArtistContribs',
+      }),
+
+      withReverseReferenceList({
+        reverse: soupyReverse.input('trackContributorContributionsBy'),
+      }).outputs({
+        '#reverseReferenceList': '#trackContributorContribs',
+      }),
+
+      {
+        dependencies: [
+          '#trackArtistContribs',
+          '#trackContributorContribs',
+        ],
+
+        compute: (continuation, {
+          ['#trackArtistContribs']: trackArtistContribs,
+          ['#trackContributorContribs']: trackContributorContribs,
+        }) => continuation({
+          ['#contributions']: [
+            ...trackArtistContribs,
+            ...trackContributorContribs,
+          ],
+        }),
+      },
+
+      {
+        dependencies: ['#contributions'],
+        compute: ({'#contributions': contributions}) =>
+          sortContributionsChronologically(
+            contributions,
+            sortAlbumsTracksChronologically),
+      },
+    ],
+
+    artworkContributions: [
+      withReverseReferenceList({
+        reverse: soupyReverse.input('trackCoverArtistContributionsBy'),
+      }).outputs({
+        '#reverseReferenceList': '#trackCoverArtistContribs',
+      }),
+
+      withReverseReferenceList({
+        reverse: soupyReverse.input('albumCoverArtistContributionsBy'),
+      }).outputs({
+        '#reverseReferenceList': '#albumCoverArtistContribs',
+      }),
+
+      withReverseReferenceList({
+        reverse: soupyReverse.input('albumWallpaperArtistContributionsBy'),
+      }).outputs({
+        '#reverseReferenceList': '#albumWallpaperArtistContribs',
+      }),
+
+      withReverseReferenceList({
+        reverse: soupyReverse.input('albumBannerArtistContributionsBy'),
+      }).outputs({
+        '#reverseReferenceList': '#albumBannerArtistContribs',
+      }),
+
+      {
+        dependencies: [
+          '#trackCoverArtistContribs',
+          '#albumCoverArtistContribs',
+          '#albumWallpaperArtistContribs',
+          '#albumBannerArtistContribs',
+        ],
+
+        compute: (continuation, {
+          ['#trackCoverArtistContribs']: trackCoverArtistContribs,
+          ['#albumCoverArtistContribs']: albumCoverArtistContribs,
+          ['#albumWallpaperArtistContribs']: albumWallpaperArtistContribs,
+          ['#albumBannerArtistContribs']: albumBannerArtistContribs,
+        }) => continuation({
+          ['#contributions']: [
+            ...trackCoverArtistContribs,
+            ...albumCoverArtistContribs,
+            ...albumWallpaperArtistContribs,
+            ...albumBannerArtistContribs,
+          ],
+        }),
+      },
+
+      {
+        dependencies: ['#contributions'],
+        compute: ({'#contributions': contributions}) =>
+          sortContributionsChronologically(
+            contributions,
+            sortArtworksChronologically),
+      },
+    ],
+
     totalDuration: artistTotalDuration(),
   });
 
@@ -287,7 +395,7 @@ export class Artist extends Thing {
       let aliasedArtist;
       try {
         aliasedArtist = this.aliasedArtist.name;
-      } catch (_error) {
+      } catch {
         aliasedArtist = CacheableObject.getUpdateValue(this, 'aliasedArtist');
       }