diff options
Diffstat (limited to 'src/data/composite/things')
-rw-r--r-- | src/data/composite/things/track/withOriginalRelease.js | 45 |
1 files changed, 31 insertions, 14 deletions
diff --git a/src/data/composite/things/track/withOriginalRelease.js b/src/data/composite/things/track/withOriginalRelease.js index d2ee39df..6e30a0a0 100644 --- a/src/data/composite/things/track/withOriginalRelease.js +++ b/src/data/composite/things/track/withOriginalRelease.js @@ -9,6 +9,8 @@ import {input, templateCompositeFrom} from '#composite'; import find from '#find'; import {validateWikiData} from '#validators'; +import {exitWithoutDependency, withResultOfAvailabilityCheck} + from '#composite/control-flow'; import {withResolvedReference} from '#composite/wiki-data'; export default templateCompositeFrom({ @@ -26,33 +28,48 @@ export default templateCompositeFrom({ outputs: ['#originalRelease'], steps: () => [ - withResolvedReference({ - ref: 'originalReleaseTrack', - data: input('data'), - find: input.value(find.track), - notFoundMode: input.value('exit'), - }).outputs({ - ['#resolvedReference']: '#originalRelease', + withResultOfAvailabilityCheck({ + from: 'originalReleaseTrack', }), { dependencies: [ input.myself(), input('selfIfOriginal'), - '#originalRelease', + '#availability', ], compute: (continuation, { [input.myself()]: track, [input('selfIfOriginal')]: selfIfOriginal, - ['#originalRelease']: originalRelease, + '#availability': availability, + }) => + (availability + ? continuation() + : continuation.raiseOutput({ + ['#originalRelease']: + (selfIfOriginal ? track : null), + })), + }, + + withResolvedReference({ + ref: 'originalReleaseTrack', + data: input('data'), + find: input.value(find.track), + }), + + exitWithoutDependency({ + dependency: '#resolvedReference', + }), + + { + dependencies: ['#resolvedReference'], + + compute: (continuation, { + ['#resolvedReference']: resolvedReference, }) => continuation({ - ['#originalRelease']: - (originalRelease ?? - (selfIfOriginal - ? track - : null)), + ['#originalRelease']: resolvedReference, }), }, ], |