« get me outta code hell

data: MusicVideo: be good about url/urls composition - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2026-04-11 12:54:49 -0300
committer(quasar) nebula <qznebula@protonmail.com>2026-04-11 12:54:49 -0300
commit0d054901fc56f68dfcbc587115c73e8edc1d8f05 (patch)
treeaf255918b0f88b321e46f72c3c02baa7769053fe /src
parent60eee911f93905704bd49f914cba850b0be873c0 (diff)
data: MusicVideo: be good about url/urls composition
Diffstat (limited to 'src')
-rw-r--r--src/data/things/MusicVideo.js46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/data/things/MusicVideo.js b/src/data/things/MusicVideo.js
index 7037ee59..7ebbba37 100644
--- a/src/data/things/MusicVideo.js
+++ b/src/data/things/MusicVideo.js
@@ -2,6 +2,7 @@ import {inspect} from 'node:util';
 
 import {colors} from '#cli';
 import {input, V} from '#composite';
+import {empty} from '#sugar';
 import Thing from '#thing';
 import {is, isDate, isStringNonEmpty, isURL, validateArrayItems}
   from '#validators';
@@ -13,7 +14,6 @@ import {
   exposeConstant,
   exposeUpdateValueOrContinue,
   exposeWhetherDependencyAvailable,
-  exitWithoutDependency,
 } from '#composite/control-flow';
 
 import {
@@ -66,32 +66,38 @@ export class MusicVideo extends Thing {
       constituteFrom('thing', V('date')),
     ],
 
-    url: [
-      exposeUpdateValueOrContinue({
-        validate: input.value(isURL),
-      }),
+    url: {
+      flags: {update: true, expose: true},
 
-      exitWithoutDependency('urls', V(null), V('empty')),
+      update: {
+        validate: isURL,
+      },
 
-      {
-        dependencies: ['urls'],
-        compute: ({urls}) => urls[0],
+      expose: {
+        dependencies: ['_urls'],
+        transform: (url, {urls}) =>
+          (url          ? url
+         : !empty(urls) ? urls[0]
+                        : null),
       },
-    ],
+    },
 
-    urls: [
-      exposeUpdateValueOrContinue({
-        validate: input.value(
-          validateArrayItems(isURL)),
-      }),
+    urls: {
+      flags: {update: true, expose: true},
 
-      exitWithoutDependency('url', V([])),
+      update: {
+        validate: validateArrayItems(isURL),
+      },
 
-      {
-        dependencies: ['url'],
-        compute: ({url}) => [url],
+      expose: {
+        dependencies: ['_url'],
+        transform: (urls, {url}) =>
+          (url && urls ? [url, ...urls]
+         : url         ? [url]
+         :        urls ? urls
+                       : []),
       },
-    ],
+    },
 
     coverArtFileExtension: fileExtension(V('jpg')),
     coverArtDimensions: dimensions(),