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
119
120
121
122
123
124
125
126
|
import {input} from '#composite';
import Thing from '#thing';
import {isContributionList, isDate, validateReferenceList} from '#validators';
import {parseContributors} from '#yaml';
import {withPropertyFromObject} from '#composite/data';
import {simpleString, soupyFind, thing} from '#composite/wiki-properties';
import {
exposeConstant,
exposeDependency,
exposeDependencyOrContinue,
exposeUpdateValueOrContinue,
} from '#composite/control-flow';
import {
withRecontextualizedContributionList,
withResolvedContribs,
withResolvedReferenceList,
} from '#composite/wiki-data';
import {withDate} from '#composite/things/artwork';
export class Artwork extends Thing {
static [Thing.referenceType] = 'artwork';
static [Thing.getPropertyDescriptors] = ({
ArtTag,
Contribution,
}) => ({
// Update & expose
thing: thing(),
artTags: [
withResolvedReferenceList({
list: input.updateValue({
validate:
validateReferenceList(ArtTag[Thing.referenceType]),
}),
find: soupyFind.input('artTag'),
}),
exposeDependencyOrContinue({
dependency: '#resolvedReferenceList',
mode: input.value('empty'),
}),
withPropertyFromObject({
object: 'thing',
property: input.value('artTags'),
}),
exposeDependencyOrContinue({
dependency: '#thing.artTags',
}),
exposeConstant({
value: input.value([]),
}),
],
artistContribsFromThingProperty: simpleString(),
artistContribsArtistProperty: simpleString(),
artistContribs: [
withDate(),
withResolvedContribs({
from: input.updateValue({validate: isContributionList}),
date: '#date',
artistProperty: 'artistContribsArtistProperty',
}),
exposeDependencyOrContinue({
dependency: '#resolvedContribs',
mode: input.value('empty'),
}),
{
dependencies: ['thing', 'artistContribsFromThingProperty'],
compute: (continuation, {thing, artistContribsFromThingProperty}) =>
(artistContribsFromThingProperty
? continuation({
'#artistContribs':
thing[artistContribsFromThingProperty],
})
: continuation.exit(null)),
},
withRecontextualizedContributionList({
list: '#artistContribs',
}),
exposeDependency({
dependency: '#artistContribs',
}),
],
dateFromThingProperty: simpleString(),
date: [
withDate({
from: input.updateValue({validate: isDate}),
}),
exposeDependency({dependency: '#date'}),
],
// Update only
find: soupyFind(),
});
static [Thing.yamlDocumentSpec] = {
fields: {
'Artists': {
property: 'artistContribs',
transform: parseContributors,
},
'Art Tags': {property: 'artTags'},
},
};
}
|