diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-11-16 13:51:25 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-11-17 13:40:00 -0400 |
commit | d28e04697429b607c38042ac09418adfceb06baf (patch) | |
tree | 4e6d422c065ab0925d9547865061b380db247276 /src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js | |
parent | 65ff74446f22976613caf352d42253c8c17e172d (diff) |
data: withResolvedArtworkReferenceList -> ...Annotated
Diffstat (limited to 'src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js')
-rw-r--r-- | src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js b/src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js new file mode 100644 index 00000000..341fdb3d --- /dev/null +++ b/src/data/composite/wiki-data/withResolvedAnnotatedReferenceList.js @@ -0,0 +1,82 @@ +import {input, templateCompositeFrom} from '#composite'; +import {stitchArrays} from '#sugar'; +import {isString, optional, validateArrayItems, validateProperties} + from '#validators'; + +import {withAvailabilityFilter} from '#composite/control-flow'; +import {withPropertiesFromList} from '#composite/data'; + +import inputNotFoundMode from './inputNotFoundMode.js'; +import inputWikiData from './inputWikiData.js'; +import raiseResolvedReferenceList from './raiseResolvedReferenceList.js'; +import withResolvedReferenceList from './withResolvedReferenceList.js'; + +export default templateCompositeFrom({ + annotation: `withResolvedAnnotatedReferenceList`, + + inputs: { + list: input({ + validate: + validateArrayItems( + validateProperties({ + reference: isString, + annotation: optional(isString), + })), + + acceptsNull: true, + }), + + data: inputWikiData({allowMixedTypes: true}), + find: input({type: 'function'}), + + notFoundMode: inputNotFoundMode(), + }, + + outputs: ['#resolvedAnnotatedReferenceList'], + + steps: () => [ + withPropertiesFromList({ + list: input('list'), + properties: input.value([ + 'reference', + 'annotation', + ]), + }), + + withResolvedReferenceList({ + list: '#list.reference', + data: input('data'), + find: input('find'), + notFoundMode: input.value('null'), + }), + + { + dependencies: [ + '#resolvedReferenceList', + '#list.annotation', + ], + + compute: (continuation, { + ['#resolvedReferenceList']: thing, + ['#list.annotation']: annotation, + }) => continuation({ + ['#matches']: + stitchArrays({ + thing, + annotation, + }), + }), + }, + + withAvailabilityFilter({ + from: '#resolvedReferenceList', + }), + + raiseResolvedReferenceList({ + notFoundMode: input('notFoundMode'), + results: '#matches', + filter: '#availabilityFilter', + outputs: input.value('#resolvedAnnotatedReferenceList'), + }), + ], +}) |