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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
import {input, templateCompositeFrom} from '#composite';
import find from '#find';
import {stitchArrays} from '#sugar';
import {isSeriesList, validateThing} from '#validators';
import {raiseOutputWithoutDependency} from '#composite/control-flow';
import {
fillMissingListItems,
withFlattenedList,
withUnflattenedList,
withPropertiesFromList,
} from '#composite/data';
import withResolvedReferenceList from './withResolvedReferenceList.js';
export default templateCompositeFrom({
annotation: `withResolvedSeriesList`,
inputs: {
group: input({
validate: validateThing({referenceType: 'group'}),
}),
list: input({
validate: isSeriesList,
acceptsNull: true,
}),
},
outputs: ['#resolvedSeriesList'],
steps: () => [
raiseOutputWithoutDependency({
dependency: input('list'),
mode: input.value('empty'),
output: input.value({
['#resolvedSeriesList']: [],
}),
}),
withPropertiesFromList({
list: input('list'),
prefix: input.value('#serieses'),
properties: input.value([
'name',
'description',
'albums',
]),
}),
fillMissingListItems({
list: '#serieses.albums',
fill: input.value([]),
}),
withFlattenedList({
list: '#serieses.albums',
}),
withResolvedReferenceList({
list: '#flattenedList',
data: 'albumData',
find: input.value(find.album),
notFoundMode: input.value('null'),
}),
withUnflattenedList({
list: '#resolvedReferenceList',
}).outputs({
'#unflattenedList': '#serieses.albums',
}),
fillMissingListItems({
list: '#serieses.description',
fill: input.value(null),
}),
{
dependencies: [
'#serieses.name',
'#serieses.description',
'#serieses.albums',
],
compute: (continuation, {
['#serieses.name']: name,
['#serieses.description']: description,
['#serieses.albums']: albums,
}) => continuation({
['#seriesProperties']:
stitchArrays({
name,
description,
albums,
}).map(properties => ({
...properties,
group: input
}))
}),
},
{
dependencies: ['#seriesProperties', input('group')],
compute: (continuation, {
['#seriesProperties']: seriesProperties,
[input('group')]: group,
}) => continuation({
['#resolvedSeriesList']:
seriesProperties
.map(properties => ({
...properties,
group,
})),
}),
},
],
});
|