diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2025-11-25 16:08:30 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2025-11-25 16:08:48 -0400 |
| commit | 9c3f0a79ee38ee5a13617ed0406d42e579ed49f3 (patch) | |
| tree | 716f3f64418ecd5df3725e437640fd7f62cb9bfa /src/data/composite | |
| parent | e0ed41638ac5f76968499a16628f7054eae11158 (diff) | |
data: Track: chop withMainReleaseTrack
probably contains normative changes re: dropping notFoundValue behavior in properties which inherit from main release, but has no effect on good wiki data and maybe those compositions resolve the same anyway...
Diffstat (limited to 'src/data/composite')
7 files changed, 54 insertions, 339 deletions
diff --git a/src/data/composite/things/track/alwaysReferenceByDirectory.js b/src/data/composite/things/track/alwaysReferenceByDirectory.js index 7b72865b..b1b0d531 100644 --- a/src/data/composite/things/track/alwaysReferenceByDirectory.js +++ b/src/data/composite/things/track/alwaysReferenceByDirectory.js @@ -15,7 +15,6 @@ import { exposeUpdateValueOrContinue, } from '#composite/control-flow'; -import withMainReleaseTrack from './withMainReleaseTrack.js'; import withPropertyFromAlbum from './withPropertyFromAlbum.js'; export default templateCompositeFrom({ @@ -44,15 +43,13 @@ export default templateCompositeFrom({ value: input.value(false), }), - withMainReleaseTrack(), - exitWithoutDependency({ - dependency: '#mainReleaseTrack', + dependency: 'mainReleaseTrack', value: input.value(false), }), withPropertyFromObject({ - object: '#mainReleaseTrack', + object: 'mainReleaseTrack', property: input.value('name'), }), diff --git a/src/data/composite/things/track/index.js b/src/data/composite/things/track/index.js index 20bc3ff2..61807018 100644 --- a/src/data/composite/things/track/index.js +++ b/src/data/composite/things/track/index.js @@ -4,7 +4,6 @@ export {default as inheritContributionListFromMainRelease} from './inheritContri export {default as inheritFromMainRelease} from './inheritFromMainRelease.js'; export {default as withAllReleases} from './withAllReleases.js'; export {default as withDirectorySuffix} from './withDirectorySuffix.js'; -export {default as withMainReleaseTrack} from './withMainReleaseTrack.js'; export {default as withOtherReleases} from './withOtherReleases.js'; export {default as withPropertyFromAlbum} from './withPropertyFromAlbum.js'; export {default as withPropertyFromMainRelease} from './withPropertyFromMainRelease.js'; diff --git a/src/data/composite/things/track/inheritContributionListFromMainRelease.js b/src/data/composite/things/track/inheritContributionListFromMainRelease.js index d3d0a442..94e19872 100644 --- a/src/data/composite/things/track/inheritContributionListFromMainRelease.js +++ b/src/data/composite/things/track/inheritContributionListFromMainRelease.js @@ -15,16 +15,15 @@ export default templateCompositeFrom({ annotation: `inheritContributionListFromMainRelease`, steps: () => [ - withPropertyFromMainRelease({ - property: input.thisProperty(), - notFoundValue: input.value([]), - }), - raiseOutputWithoutDependency({ - dependency: '#isSecondaryRelease', + dependency: 'isSecondaryRelease', mode: input.value('falsy'), }), + withPropertyFromMainRelease({ + property: input.thisProperty(), + }), + withRecontextualizedContributionList({ list: '#mainReleaseValue', }), diff --git a/src/data/composite/things/track/inheritFromMainRelease.js b/src/data/composite/things/track/inheritFromMainRelease.js index b1cbb65e..32a3165d 100644 --- a/src/data/composite/things/track/inheritFromMainRelease.js +++ b/src/data/composite/things/track/inheritFromMainRelease.js @@ -1,10 +1,6 @@ // Early exits with the value for the same property as specified on the // main release, if this track is a secondary release, and otherwise continues // without providing any further dependencies. -// -// Like withMainRelease, this will early exit (with notFoundValue) if the -// main release is specified by reference and that reference doesn't -// resolve to anything. import {input, templateCompositeFrom} from '#composite'; @@ -17,21 +13,14 @@ import withPropertyFromMainRelease export default templateCompositeFrom({ annotation: `inheritFromMainRelease`, - inputs: { - notFoundValue: input({ - defaultValue: null, + steps: () => [ + raiseOutputWithoutDependency({ + dependency: 'isSecondaryRelease', + mode: input.value('falsy'), }), - }, - steps: () => [ withPropertyFromMainRelease({ property: input.thisProperty(), - notFoundValue: input('notFoundValue'), - }), - - raiseOutputWithoutDependency({ - dependency: '#isSecondaryRelease', - mode: input.value('falsy'), }), exposeDependency({ diff --git a/src/data/composite/things/track/withAllReleases.js b/src/data/composite/things/track/withAllReleases.js index bd54384f..078209a9 100644 --- a/src/data/composite/things/track/withAllReleases.js +++ b/src/data/composite/things/track/withAllReleases.js @@ -10,40 +10,47 @@ import {sortByDate} from '#sort'; import {withPropertyFromObject} from '#composite/data'; -import withMainReleaseTrack from './withMainReleaseTrack.js'; - export default templateCompositeFrom({ annotation: `withAllReleases`, outputs: ['#allReleases'], steps: () => [ - withMainReleaseTrack({ - selfIfMain: input.value(true), - notFoundValue: input.value([]), - }), - - // We don't talk about bruno no no - // Yes, this can perform a normal access equivalent to - // `this.secondaryReleases` from within a data composition. - // Oooooooooooooooooooooooooooooooooooooooooooooooo - withPropertyFromObject({ - object: '#mainReleaseTrack', - property: input.value('secondaryReleases'), - }), + { + dependencies: [ + 'mainReleaseTrack', + 'secondaryReleases', + input.myself(), + ], + + compute: (continuation, { + mainReleaseTrack, + secondaryReleases, + [input.myself()]: thisTrack, + }) => + (mainReleaseTrack + ? continuation({ + ['#mainReleaseTrack']: mainReleaseTrack, + ['#secondaryReleaseTracks']: mainReleaseTrack.secondaryReleases, + }) + : continuation({ + ['#mainReleaseTrack']: thisTrack, + ['#secondaryReleaseTracks']: secondaryReleases, + })), + }, { dependencies: [ '#mainReleaseTrack', - '#mainReleaseTrack.secondaryReleases', + '#secondaryReleaseTracks', ], compute: (continuation, { ['#mainReleaseTrack']: mainReleaseTrack, - ['#mainReleaseTrack.secondaryReleases']: secondaryReleases, + ['#secondaryReleaseTracks']: secondaryReleaseTracks, }) => continuation({ ['#allReleases']: - sortByDate([mainReleaseTrack, ...secondaryReleases]), + sortByDate([mainReleaseTrack, ...secondaryReleaseTracks]), }), }, ], diff --git a/src/data/composite/things/track/withMainReleaseTrack.js b/src/data/composite/things/track/withMainReleaseTrack.js deleted file mode 100644 index c92c2246..00000000 --- a/src/data/composite/things/track/withMainReleaseTrack.js +++ /dev/null @@ -1,244 +0,0 @@ -// Just provides the main release of this track as a dependency. -// If this track isn't a secondary release, then it'll provide null, unless -// the {selfIfMain} option is set, in which case it'll provide this track -// itself. This will early exit (with notFoundValue) if the main release -// is specified by reference and that reference doesn't resolve to anything. - -import {input, templateCompositeFrom} from '#composite'; -import {onlyItem} from '#sugar'; -import {getKebabCase} from '#wiki-data'; - -import { - exitWithoutDependency, - withAvailabilityFilter, - withResultOfAvailabilityCheck, -} from '#composite/control-flow'; - -import { - withFilteredList, - withMappedList, - withPropertyFromList, - withPropertyFromObject, -} from '#composite/data'; - -export default templateCompositeFrom({ - annotation: `withMainReleaseTrack`, - - inputs: { - selfIfMain: input({type: 'boolean', defaultValue: false}), - notFoundValue: input({defaultValue: null}), - }, - - outputs: ['#mainReleaseTrack'], - - steps: () => [ - withResultOfAvailabilityCheck({ - from: '_mainRelease', - }), - - { - dependencies: [ - input.myself(), - input('selfIfMain'), - '#availability', - ], - - compute: (continuation, { - [input.myself()]: track, - [input('selfIfMain')]: selfIfMain, - '#availability': availability, - }) => - (availability - ? continuation() - : continuation.raiseOutput({ - ['#mainReleaseTrack']: - (selfIfMain ? track : null), - })), - }, - - exitWithoutDependency({ - dependency: 'mainRelease', - value: input('notFoundValue'), - }), - - withPropertyFromObject({ - object: 'mainRelease', - property: input.value('isTrack'), - }), - - { - dependencies: ['mainRelease', '#mainRelease.isTrack'], - - compute: (continuation, { - ['mainRelease']: mainRelease, - ['#mainRelease.isTrack']: mainReleaseIsTrack, - }) => - (mainReleaseIsTrack - ? continuation.raiseOutput({ - ['#mainReleaseTrack']: mainRelease, - }) - : continuation()), - }, - - { - dependencies: ['name', '_directory'], - compute: (continuation, { - ['name']: ownName, - ['_directory']: ownDirectory, - }) => { - const ownNameKebabed = getKebabCase(ownName); - - return continuation({ - ['#mapItsNameLikeName']: - name => getKebabCase(name) === ownNameKebabed, - - ['#mapItsDirectoryLikeDirectory']: - (ownDirectory - ? directory => directory === ownDirectory - : () => false), - - ['#mapItsNameLikeDirectory']: - (ownDirectory - ? name => getKebabCase(name) === ownDirectory - : () => false), - - ['#mapItsDirectoryLikeName']: - directory => directory === ownNameKebabed, - }); - }, - }, - - withPropertyFromObject({ - object: 'mainRelease', - property: input.value('tracks'), - }), - - withPropertyFromList({ - list: '#mainRelease.tracks', - property: input.value('mainRelease'), - internal: input.value(true), - }), - - withAvailabilityFilter({ - from: '#mainRelease.tracks.mainRelease', - }), - - withMappedList({ - list: '#availabilityFilter', - map: input.value(item => !item), - }).outputs({ - '#mappedList': '#availabilityFilter', - }), - - withFilteredList({ - list: '#mainRelease.tracks', - filter: '#availabilityFilter', - }).outputs({ - '#filteredList': '#mainRelease.tracks', - }), - - withPropertyFromList({ - list: '#mainRelease.tracks', - property: input.value('name'), - }), - - withPropertyFromList({ - list: '#mainRelease.tracks', - property: input.value('directory'), - internal: input.value(true), - }), - - withMappedList({ - list: '#mainRelease.tracks.name', - map: '#mapItsNameLikeName', - }).outputs({ - '#mappedList': '#filterItsNameLikeName', - }), - - withMappedList({ - list: '#mainRelease.tracks.directory', - map: '#mapItsDirectoryLikeDirectory', - }).outputs({ - '#mappedList': '#filterItsDirectoryLikeDirectory', - }), - - withMappedList({ - list: '#mainRelease.tracks.name', - map: '#mapItsNameLikeDirectory', - }).outputs({ - '#mappedList': '#filterItsNameLikeDirectory', - }), - - withMappedList({ - list: '#mainRelease.tracks.directory', - map: '#mapItsDirectoryLikeName', - }).outputs({ - '#mappedList': '#filterItsDirectoryLikeName', - }), - - withFilteredList({ - list: '#mainRelease.tracks', - filter: '#filterItsNameLikeName', - }).outputs({ - '#filteredList': '#matchingItsNameLikeName', - }), - - withFilteredList({ - list: '#mainRelease.tracks', - filter: '#filterItsDirectoryLikeDirectory', - }).outputs({ - '#filteredList': '#matchingItsDirectoryLikeDirectory', - }), - - withFilteredList({ - list: '#mainRelease.tracks', - filter: '#filterItsNameLikeDirectory', - }).outputs({ - '#filteredList': '#matchingItsNameLikeDirectory', - }), - - withFilteredList({ - list: '#mainRelease.tracks', - filter: '#filterItsDirectoryLikeName', - }).outputs({ - '#filteredList': '#matchingItsDirectoryLikeName', - }), - - { - dependencies: [ - '#matchingItsNameLikeName', - '#matchingItsDirectoryLikeDirectory', - '#matchingItsNameLikeDirectory', - '#matchingItsDirectoryLikeName', - ], - - compute: (continuation, { - ['#matchingItsNameLikeName']: NLN, - ['#matchingItsDirectoryLikeDirectory']: DLD, - ['#matchingItsNameLikeDirectory']: NLD, - ['#matchingItsDirectoryLikeName']: DLN, - }) => continuation({ - ['#mainReleaseTrack']: - onlyItem(DLD) ?? - onlyItem(NLN) ?? - onlyItem(DLN) ?? - onlyItem(NLD) ?? - null, - }), - }, - - { - dependencies: ['#mainReleaseTrack', input.myself()], - - compute: (continuation, { - ['#mainReleaseTrack']: mainReleaseTrack, - [input.myself()]: thisTrack, - }) => continuation({ - ['#mainReleaseTrack']: - (mainReleaseTrack === thisTrack - ? null - : mainReleaseTrack), - }), - }, - ], -}); diff --git a/src/data/composite/things/track/withPropertyFromMainRelease.js b/src/data/composite/things/track/withPropertyFromMainRelease.js index c6f65653..cd24da4a 100644 --- a/src/data/composite/things/track/withPropertyFromMainRelease.js +++ b/src/data/composite/things/track/withPropertyFromMainRelease.js @@ -1,86 +1,54 @@ -// Provides a value inherited from the main release, if applicable, and a -// flag indicating if this track is a secondary release or not. -// -// Like withMainRelease, this will early exit (with notFoundValue) if the -// main release is specified by reference and that reference doesn't -// resolve to anything. +// Provides a value inherited from the main release, or null, +// if this track is not a secondary release. import {input, templateCompositeFrom} from '#composite'; import {withResultOfAvailabilityCheck} from '#composite/control-flow'; import {withPropertyFromObject} from '#composite/data'; -import withMainReleaseTrack from './withMainReleaseTrack.js'; - export default templateCompositeFrom({ annotation: `withPropertyFromMainRelease`, inputs: { property: input({type: 'string'}), - - notFoundValue: input({ - defaultValue: null, - }), }, outputs: ({ [input.staticValue('property')]: property, - }) => - ['#isSecondaryRelease'].concat( - (property - ? ['#mainRelease.' + property] - : ['#mainReleaseValue'])), + }) => [ + (property + ? '#mainRelease.' + property + : '#mainReleaseValue'), + ], steps: () => [ - withMainReleaseTrack({ - notFoundValue: input('notFoundValue'), - }), - - withResultOfAvailabilityCheck({ - from: '#mainReleaseTrack', - }), - { - dependencies: [ - '#availability', - input.staticValue('property'), - ], - + dependencies: ['isSecondaryRelease', input.staticValue('property')], compute: (continuation, { - ['#availability']: availability, + ['isSecondaryRelease']: isSecondaryRelease, [input.staticValue('property')]: property, }) => - (availability + (isSecondaryRelease ? continuation() - : continuation.raiseOutput( - Object.assign( - {'#isSecondaryRelease': false}, - (property - ? {['#mainRelease.' + property]: null} - : {'#mainReleaseValue': null})))), + : property + ? continuation.raiseOutput({['#mainRelease.' + property]: null}) + : continuation.raiseOutput({'#mainReleaseValue': null})), }, withPropertyFromObject({ - object: '#mainReleaseTrack', + object: 'mainReleaseTrack', property: input('property'), }), { - dependencies: [ - '#value', - input.staticValue('property'), - ], - + dependencies: ['#value', input.staticValue('property')], compute: (continuation, { ['#value']: value, [input.staticValue('property')]: property, }) => - continuation.raiseOutput( - Object.assign( - {'#isSecondaryRelease': true}, - (property - ? {['#mainRelease.' + property]: value} - : {'#mainReleaseValue': value}))), + (property + ? continuation.raiseOutput({['#mainRelease.' + property]: value}) + : continuation.raiseOutput({'#mainReleaseValue': value})), }, ], }); |