From ab4d203c7df2e69e331bf4c0ae4522ddee5918cb Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 6 Apr 2025 15:47:33 -0300 Subject: data: constitutibleArtworkList.fromYAMLFieldSpec Also file extension property passing. --- .../wiki-properties/constitutibleArtworkList.js | 74 ++++++++++------------ 1 file changed, 34 insertions(+), 40 deletions(-) (limited to 'src/data/composite/wiki-properties') diff --git a/src/data/composite/wiki-properties/constitutibleArtworkList.js b/src/data/composite/wiki-properties/constitutibleArtworkList.js index 01429f03..bc56f887 100644 --- a/src/data/composite/wiki-properties/constitutibleArtworkList.js +++ b/src/data/composite/wiki-properties/constitutibleArtworkList.js @@ -1,29 +1,25 @@ +// This composition does not actually inspect the values of any properties +// specified, so it's not responsible for determining whether a constituted +// artwork should exist at all. + import {input, templateCompositeFrom} from '#composite'; -import {isContributionList, isDate, validateWikiData} from '#validators'; +import {withEntries} from '#sugar'; +import Thing from '#thing'; +import {validateWikiData} from '#validators'; -import {exitWithoutDependency, exposeUpdateValueOrContinue} - from '#composite/control-flow'; +import {exposeUpdateValueOrContinue} from '#composite/control-flow'; import {withConstitutedArtwork} from '#composite/wiki-data'; -export default templateCompositeFrom({ +const template = templateCompositeFrom({ annotation: `constitutibleArtwork`, compose: false, inputs: { - contribs: input.staticDependency({ - validate: isContributionList, - acceptsNull: true, - }), - - date: input.staticDependency({ - validate: isDate, - acceptsNull: true, - }), - - artistProperty: input.staticValue({ - type: 'string', - }), + fileExtensionFromThingProperty: input({type: 'string'}), + artistContribsFromThingProperty: input({type: 'string'}), + artistContribsArtistProperty: input({type: 'string'}), + dateFromThingProperty: input({type: 'string'}), }, steps: () => [ @@ -34,30 +30,11 @@ export default templateCompositeFrom({ })), }), - exitWithoutDependency({ - dependency: input('contribs'), - value: input.value([]), - }), - - { - dependencies: [ - input.staticDependency('contribs'), - input.staticDependency('date'), - ], - - compute: (continuation, { - [input.staticDependency('contribs')]: contribsProperty, - [input.staticDependency('date')]: dateProperty, - }) => continuation({ - ['#contribsProperty']: contribsProperty, - ['#dateProperty']: dateProperty, - }) - }, - withConstitutedArtwork({ - contribsProperty: '#contribsProperty', - artistProperty: input('artistProperty'), - dateProperty: '#dateProperty', + fileExtensionFromThingProperty: input('fileExtensionFromThingProperty'), + artistContribsFromThingProperty: input('artistContribsFromThingProperty'), + artistContribsArtistProperty: input('artistContribsArtistProperty'), + dateFromThingProperty: input('dateFromThingProperty'), }), { @@ -68,3 +45,20 @@ export default templateCompositeFrom({ }, ], }); + +template.fromYAMLFieldSpec = function(field) { + const {[Thing.yamlDocumentSpec]: documentSpec} = this; + + const {provide} = documentSpec.fields[field].transform; + + const inputs = + withEntries(provide, entries => + entries.map(([property, value]) => [ + property, + input.value(value), + ])); + + return template(inputs); +}; + +export default template; -- cgit 1.3.0-6-gf8a5