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
|
// 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 {raiseOutputWithoutDependency} from '#composite/control-flow';
import withResolvedContribs from './withResolvedContribs.js';
export default templateCompositeFrom({
annotation: `withCoverArtDate`,
inputs: {
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: ['coverArtDate', input('fallback')],
compute: (continuation, {
['coverArtDate']: coverArtDate,
[input('fallback')]: fallback,
}) =>
(coverArtDate
? continuation.raiseOutput({'#coverArtDate': coverArtDate})
: fallback
? continuation()
: continuation.raiseOutput({'#coverArtDate': null})),
},
{
dependencies: ['date'],
compute: (continuation, {date}) =>
(date
? continuation.raiseOutput({'#coverArtDate': date})
: continuation.raiseOutput({'#coverArtDate': null})),
},
],
});
|