diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-04-06 15:47:33 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-04-10 16:02:40 -0300 |
commit | ab4d203c7df2e69e331bf4c0ae4522ddee5918cb (patch) | |
tree | 32b757ee9e54a674ca3260155e783f9f2c3c705e /src/data/composite | |
parent | e8670dd43d70ef91df6dc1164d11397de639e3b8 (diff) |
data: constitutibleArtworkList.fromYAMLFieldSpec
Also file extension property passing.
Diffstat (limited to 'src/data/composite')
-rw-r--r-- | src/data/composite/wiki-data/withConstitutedArtwork.js | 25 | ||||
-rw-r--r-- | src/data/composite/wiki-properties/constitutibleArtworkList.js | 74 |
2 files changed, 50 insertions, 49 deletions
diff --git a/src/data/composite/wiki-data/withConstitutedArtwork.js b/src/data/composite/wiki-data/withConstitutedArtwork.js index 9843588a..3eb3c893 100644 --- a/src/data/composite/wiki-data/withConstitutedArtwork.js +++ b/src/data/composite/wiki-data/withConstitutedArtwork.js @@ -6,9 +6,10 @@ export default templateCompositeFrom({ annotation: `withConstitutedArtwork`, inputs: { - contribsProperty: input({type: 'string'}), - artistProperty: input({type: 'string'}), - dateProperty: input({type: 'string'}), + fileExtensionFromThingProperty: input({type: 'string'}), + artistContribsFromThingProperty: input({type: 'string'}), + artistContribsArtistProperty: input({type: 'string'}), + dateFromThingProperty: input({type: 'string'}), }, outputs: ['#constitutedArtwork'], @@ -19,24 +20,30 @@ export default templateCompositeFrom({ input.myself(), 'find', - input('contribsProperty'), - input('dateProperty'), + input('fileExtensionFromThingProperty'), + input('artistContribsFromThingProperty'), + input('artistContribsArtistProperty'), + input('dateFromThingProperty'), ], compute: (continuation, { [input.myself()]: myself, ['find']: find, - [input('contribsProperty')]: contribsProperty, - [input('dateProperty')]: dateProperty, + [input('fileExtensionFromThingProperty')]: fileExtensionFromThingProperty, + [input('artistContribsFromThingProperty')]: artistContribsFromThingProperty, + [input('artistContribsArtistProperty')]: artistContribsArtistProperty, + [input('dateFromThingProperty')]: dateFromThingProperty, }) => continuation({ ['#constitutedArtwork']: Object.assign(new thingConstructors.Artwork, { thing: myself, find: find, - artistContribsFromThingProperty: contribsProperty, - dateFromThingProperty: dateProperty, + fileExtensionFromThingProperty, + artistContribsFromThingProperty, + artistContribsArtistProperty, + dateFromThingProperty, }), }), }, 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; |