1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Gets the current thing's coverArtDate, or, if the 'fallback' option is set,
// the thing's date. This is always null if the thing doesn't actually have
// any coverArtistContribs.
import {input, templateCompositeFrom} from '#composite';
import {isDate} from '#validators';
import {raiseOutputWithoutDependency} from '#composite/control-flow';
import withResolvedContribs from './withResolvedContribs.js';
export default templateCompositeFrom({
annotation: `withCoverArtDate`,
inputs: {
from: input({
validate: isDate,
defaultDependency: 'coverArtDate',
acceptsNull: true,
}),
fallback: input({
type: 'boolean',
defaultValue: false,
}),
},
outputs: ['#coverArtDate'],
steps: () => [
withResolvedContribs({
from: 'coverArtistContribs',
date: input.value(null),
}),
raiseOutputWithoutDependency({
dependency: '#resolvedContribs',
mode: input.value('empty'),
output: input.value({'#coverArtDate': null}),
}),
{
dependencies: [input('from')],
compute: (continuation, {
[input('from')]: from,
}) =>
(from
? continuation.raiseOutput({'#coverArtDate': from})
: continuation()),
},
{
dependencies: [input('fallback')],
compute: (continuation, {
[input('fallback')]: fallback,
}) =>
(fallback
? continuation()
: continuation.raiseOutput({'#coverArtDate': null})),
},
{
dependencies: ['date'],
compute: (continuation, {date}) =>
(date
? continuation.raiseOutput({'#coverArtDate': date})
: continuation.raiseOutput({'#coverArtDate': null})),
},
],
});
|