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
71
72
73
74
75
76
77
78
|
// Resolves the contribsByRef contained in the provided dependency,
// providing (named by the second argument) the result. "Resolving"
// means mapping the artist reference of each contribution to an artist
// object, and filtering out those whose artist reference doesn't match
// any artist.
import {input, templateCompositeFrom} from '#composite';
import find from '#find';
import {filterMultipleArrays, stitchArrays} from '#sugar';
import {is, isContributionList} from '#validators';
import {
raiseOutputWithoutDependency,
} from '#composite/control-flow';
import {
withPropertiesFromList,
} from '#composite/data';
import withResolvedReferenceList from './withResolvedReferenceList.js';
export default templateCompositeFrom({
annotation: `withResolvedContribs`,
inputs: {
from: input({
validate: isContributionList,
acceptsNull: true,
}),
notFoundMode: input({
validate: is('exit', 'filter', 'null'),
defaultValue: 'null',
}),
},
outputs: ['#resolvedContribs'],
steps: () => [
raiseOutputWithoutDependency({
dependency: input('from'),
mode: input.value('empty'),
output: input.value({
['#resolvedContribs']: [],
}),
}),
withPropertiesFromList({
list: input('from'),
properties: input.value(['artist', 'annotation']),
prefix: input.value('#contribs'),
}),
withResolvedReferenceList({
list: '#contribs.artist',
data: 'artistData',
find: input.value(find.artist),
notFoundMode: input('notFoundMode'),
}).outputs({
['#resolvedReferenceList']: '#contribs.artist',
}),
{
dependencies: ['#contribs.artist', '#contribs.annotation'],
compute(continuation, {
['#contribs.artist']: artist,
['#contribs.annotation']: annotation,
}) {
filterMultipleArrays(artist, annotation, (artist, _annotation) => artist);
return continuation({
['#resolvedContribs']:
stitchArrays({artist, annotation}),
});
},
},
],
});
|