From db054be170faa6146759cce20b18f242d89dfdcf Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Mon, 4 Mar 2024 13:34:56 -0400 Subject: data: transparent basic Contribution objects --- .../composite/wiki-data/withResolvedContribs.js | 57 ++++++++++++++-------- 1 file changed, 38 insertions(+), 19 deletions(-) (limited to 'src/data/composite/wiki-data') diff --git a/src/data/composite/wiki-data/withResolvedContribs.js b/src/data/composite/wiki-data/withResolvedContribs.js index 95266382..7ff7b1bc 100644 --- a/src/data/composite/wiki-data/withResolvedContribs.js +++ b/src/data/composite/wiki-data/withResolvedContribs.js @@ -7,17 +7,11 @@ import {input, templateCompositeFrom} from '#composite'; import find from '#find'; import {filterMultipleArrays, stitchArrays} from '#sugar'; +import thingConstructors from '#things'; import {is, isContributionList} from '#validators'; -import { - raiseOutputWithoutDependency, -} from '#composite/control-flow'; - -import { - withPropertiesFromList, -} from '#composite/data'; - -import withResolvedReferenceList from './withResolvedReferenceList.js'; +import {raiseOutputWithoutDependency} from '#composite/control-flow'; +import {withPropertiesFromList} from '#composite/data'; export default templateCompositeFrom({ annotation: `withResolvedContribs`, @@ -51,15 +45,6 @@ export default templateCompositeFrom({ 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'], @@ -68,11 +53,45 @@ export default templateCompositeFrom({ ['#contribs.annotation']: annotation, }) { filterMultipleArrays(artist, annotation, (artist, _annotation) => artist); + return continuation({ - ['#resolvedContribs']: + ['#details']: stitchArrays({artist, annotation}), }); }, }, + + { + dependencies: ['#details', input.myself()], + + compute: (continuation, { + ['#details']: details, + [input.myself()]: myself, + }) => continuation({ + ['#contributions']: + details.map(details => { + const contrib = new thingConstructors.Contribution(); + + Object.assign(contrib, { + ...details, + thing: myself, + }); + + return contrib; + }), + }), + }, + + { + dependencies: ['#contributions'], + + compute: (continuation, { + ['#contributions']: contributions, + }) => continuation({ + ['#resolvedContribs']: + contributions + .filter(contrib => contrib.artist), + }), + }, ], }); -- cgit 1.3.0-6-gf8a5