diff options
| author | (quasar) nebula <qznebula@protonmail.com> | 2025-11-25 15:38:49 -0400 |
|---|---|---|
| committer | (quasar) nebula <qznebula@protonmail.com> | 2025-11-25 15:38:49 -0400 |
| commit | e0ed41638ac5f76968499a16628f7054eae11158 (patch) | |
| tree | 3771f13d308a3cdac56c347d5c3ea6cd8f90a079 /src/data/composite/things/track/withMainRelease.js | |
| parent | e4125608ed4f88ba3115ffc888035922c798705c (diff) | |
data: Track: chop withMainRelease
Diffstat (limited to 'src/data/composite/things/track/withMainRelease.js')
| -rw-r--r-- | src/data/composite/things/track/withMainRelease.js | 137 |
1 files changed, 0 insertions, 137 deletions
diff --git a/src/data/composite/things/track/withMainRelease.js b/src/data/composite/things/track/withMainRelease.js deleted file mode 100644 index fb1342ec..00000000 --- a/src/data/composite/things/track/withMainRelease.js +++ /dev/null @@ -1,137 +0,0 @@ -// Resolves this track's `mainRelease` reference, using weird-ass atypical -// machinery that operates on soupyFind and does not operate on findMixed, -// let alone a prim and proper standalone find spec. -// -// Raises null only if there is no `mainRelease` reference provided at all. -// This will early exit (with notFoundValue) if the reference doesn't resolve. -// - -import {input, templateCompositeFrom} from '#composite'; - -import {raiseOutputWithoutDependency} from '#composite/control-flow'; -import {withPropertyFromObject} from '#composite/data'; -import {withResolvedReference} from '#composite/wiki-data'; -import {soupyFind} from '#composite/wiki-properties'; - -export default templateCompositeFrom({ - annotation: `withMainRelease`, - - inputs: { - from: input({ - defaultDependency: '_mainRelease', - acceptsNull: true, - }), - - notFoundValue: input({defaultValue: null}), - }, - - outputs: ['#mainRelease'], - - steps: () => [ - raiseOutputWithoutDependency({ - dependency: input('from'), - output: input.value({'#mainRelease': null}), - }), - - { - dependencies: [input('from'), 'name'], - compute: (continuation, { - [input('from')]: ref, - ['name']: ownName, - }) => - (ref === 'same name single' - ? continuation({ - ['#albumOrTrackReference']: null, - ['#sameNameSingleReference']: ownName, - }) - : continuation({ - ['#albumOrTrackReference']: ref, - ['#sameNameSingleReference']: null, - })), - }, - - withResolvedReference({ - ref: '#albumOrTrackReference', - find: soupyFind.input('trackMainReleasesOnly'), - }).outputs({ - '#resolvedReference': '#matchingTrack', - }), - - withResolvedReference({ - ref: '#albumOrTrackReference', - find: soupyFind.input('album'), - }).outputs({ - '#resolvedReference': '#matchingAlbum', - }), - - withResolvedReference({ - ref: '#sameNameSingleReference', - find: soupyFind.input('albumSinglesOnly'), - findOptions: input.value({ - fuzz: { - capitalization: true, - kebab: true, - }, - }), - }).outputs({ - '#resolvedReference': '#sameNameSingle', - }), - - { - dependencies: ['#sameNameSingle'], - compute: (continuation, { - ['#sameNameSingle']: sameNameSingle, - }) => - (sameNameSingle - ? continuation.raiseOutput({ - ['#mainRelease']: - sameNameSingle, - }) - : continuation()), - }, - - { - dependencies: [ - '#matchingTrack', - '#matchingAlbum', - input('notFoundValue'), - ], - - compute: (continuation, { - ['#matchingTrack']: matchingTrack, - ['#matchingAlbum']: matchingAlbum, - [input('notFoundValue')]: notFoundValue, - }) => - (matchingTrack && matchingAlbum - ? continuation() - : matchingTrack ?? matchingAlbum - ? continuation.raiseOutput({ - ['#mainRelease']: - matchingTrack ?? matchingAlbum, - }) - : continuation.exit(notFoundValue)), - }, - - withPropertyFromObject({ - object: '#matchingAlbum', - property: input.value('tracks'), - }), - - { - dependencies: [ - '#matchingAlbum.tracks', - '#matchingTrack', - input('notFoundValue'), - ], - - compute: (continuation, { - ['#matchingAlbum.tracks']: matchingAlbumTracks, - ['#matchingTrack']: matchingTrack, - [input('notFoundValue')]: notFoundValue, - }) => - (matchingAlbumTracks.includes(matchingTrack) - ? continuation.raiseOutput({'#mainRelease': matchingTrack}) - : continuation.exit(notFoundValue)), - }, - ], -}); |