« get me outta code hell

Merge branch 'shared-additional-names' into preview - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/things
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2023-12-03 17:50:39 -0400
committer(quasar) nebula <qznebula@protonmail.com>2023-12-03 17:50:39 -0400
commit2d054508f58147f5968a10f39c2f87ba62dd91f7 (patch)
tree2f808645119b9062a4e0ea1a3a9e8256f84af7e8 /src/data/things
parent7ad62ef4a6908a550d5b48ae93877446088d4d82 (diff)
parentc336352a915245e28e08498de61808c96daa3dcf (diff)
Merge branch 'shared-additional-names' into preview
Diffstat (limited to 'src/data/things')
-rw-r--r--src/data/things/track.js5
-rw-r--r--src/data/things/validators.js25
2 files changed, 23 insertions, 7 deletions
diff --git a/src/data/things/track.js b/src/data/things/track.js
index d25213c2..e3fe0804 100644
--- a/src/data/things/track.js
+++ b/src/data/things/track.js
@@ -43,7 +43,9 @@ import {
 
 import {
   exitWithoutUniqueCoverArt,
+  inferredAdditionalNameList,
   inheritFromOriginalRelease,
+  sharedAdditionalNameList,
   trackReverseReferenceList,
   withAlbum,
   withAlwaysReferenceByDirectory,
@@ -64,7 +66,10 @@ export class Track extends Thing {
 
     name: name('Unnamed Track'),
     directory: directory(),
+
     additionalNames: additionalNameList(),
+    sharedAdditionalNames: sharedAdditionalNameList(),
+    inferredAdditionalNames: inferredAdditionalNameList(),
 
     duration: duration(),
     urls: urls(),
diff --git a/src/data/things/validators.js b/src/data/things/validators.js
index 55eedbcf..ac91b456 100644
--- a/src/data/things/validators.js
+++ b/src/data/things/validators.js
@@ -429,13 +429,6 @@ export function isURL(string) {
   return true;
 }
 
-export const isAdditionalName = validateProperties({
-  name: isName,
-  annotation: optional(isStringNonEmpty),
-});
-
-export const isAdditionalNameList = validateArrayItems(isAdditionalName);
-
 export function validateReference(type = 'track') {
   return (ref) => {
     isStringNonEmpty(ref);
@@ -557,6 +550,24 @@ export function validateWikiData({
   };
 }
 
+export const isAdditionalName = validateProperties({
+  name: isName,
+  annotation: optional(isStringNonEmpty),
+
+  // TODO: This only allows indicating sourcing from a track.
+  // That's okay for the current limited use of "from", but
+  // could be expanded later.
+  from:
+    // Double TODO: Explicitly allowing both references and
+    // live objects to co-exist is definitely weird, and
+    // altogether questions the way we define validators...
+    optional(oneOf(
+      validateReferenceList('track'),
+      validateWikiData({referenceType: 'track'}))),
+});
+
+export const isAdditionalNameList = validateArrayItems(isAdditionalName);
+
 // Compositional utilities
 
 export function oneOf(...checks) {