diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-02-19 16:24:14 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-03-02 08:24:12 -0400 |
commit | 76e508ffe3818a78fb941ecde05fe9c269e8bc22 (patch) | |
tree | 3dcc62ca4b91799e59dab75a4dcf535e127d5e2b /src/data/composite/things/track/withMainRelease.js | |
parent | 2bbaa9a58728269f654e48fd9888a309ab890881 (diff) |
data: isOriginalRelease -> isMainRelease, etc
Also isRerelease -> isSecondaryRelease Im sure this is completely bug free and will not involve squashing one million additional commits
Diffstat (limited to 'src/data/composite/things/track/withMainRelease.js')
-rw-r--r-- | src/data/composite/things/track/withMainRelease.js | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/src/data/composite/things/track/withMainRelease.js b/src/data/composite/things/track/withMainRelease.js new file mode 100644 index 00000000..3a91edae --- /dev/null +++ b/src/data/composite/things/track/withMainRelease.js @@ -0,0 +1,70 @@ +// Just includes 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 {exitWithoutDependency, withResultOfAvailabilityCheck} + from '#composite/control-flow'; +import {withResolvedReference} from '#composite/wiki-data'; +import {soupyFind} from '#composite/wiki-properties'; + +export default templateCompositeFrom({ + annotation: `withMainRelease`, + + inputs: { + selfIfMain: input({type: 'boolean', defaultValue: false}), + notFoundValue: input({defaultValue: null}), + }, + + outputs: ['#mainRelease'], + + steps: () => [ + withResultOfAvailabilityCheck({ + from: 'mainReleaseTrack', + }), + + { + dependencies: [ + input.myself(), + input('selfIfMain'), + '#availability', + ], + + compute: (continuation, { + [input.myself()]: track, + [input('selfIfMain')]: selfIfMain, + '#availability': availability, + }) => + (availability + ? continuation() + : continuation.raiseOutput({ + ['#mainRelease']: + (selfIfMain ? track : null), + })), + }, + + withResolvedReference({ + ref: 'mainReleaseTrack', + find: soupyFind.input('track'), + }), + + exitWithoutDependency({ + dependency: '#resolvedReference', + value: input('notFoundValue'), + }), + + { + dependencies: ['#resolvedReference'], + + compute: (continuation, { + ['#resolvedReference']: resolvedReference, + }) => + continuation({ + ['#mainRelease']: resolvedReference, + }), + }, + ], +}); |