From 0d054901fc56f68dfcbc587115c73e8edc1d8f05 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 11 Apr 2026 12:54:49 -0300 Subject: data: MusicVideo: be good about url/urls composition --- src/data/things/MusicVideo.js | 46 ++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'src/data/things') 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(), -- cgit 1.3.0-6-gf8a5