From 49537d408b17f7583cd00d0866f5de6797a0591e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sun, 26 Nov 2023 17:32:28 -0400 Subject: data: shared & inferred additional names (for tracks) --- .../things/track/withSharedAdditionalNames.js | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/data/composite/things/track/withSharedAdditionalNames.js (limited to 'src/data/composite/things/track/withSharedAdditionalNames.js') diff --git a/src/data/composite/things/track/withSharedAdditionalNames.js b/src/data/composite/things/track/withSharedAdditionalNames.js new file mode 100644 index 00000000..d205dc89 --- /dev/null +++ b/src/data/composite/things/track/withSharedAdditionalNames.js @@ -0,0 +1,46 @@ +// Compiles additional names directly provided on other releases. + +import {input, templateCompositeFrom} from '#composite'; + +import {raiseOutputWithoutDependency} from '#composite/control-flow'; +import {withFlattenedList} from '#composite/data'; + +import CacheableObject from '#cacheable-object'; + +import withOtherReleases from './withOtherReleases.js'; + +export default templateCompositeFrom({ + annotation: `withSharedAdditionalNames`, + + outputs: ['#sharedAdditionalNames'], + + steps: () => [ + withOtherReleases(), + + raiseOutputWithoutDependency({ + dependency: '#otherReleases', + mode: input.value('empty'), + output: input.value({'#inferredAdditionalNames': []}), + }), + + // TODO: Using getUpdateValue is always a bit janky. + + { + dependencies: ['#otherReleases'], + compute: (continuation, { + ['#otherReleases']: otherReleases, + }) => continuation({ + ['#otherReleases.additionalNames']: + otherReleases.map(release => + CacheableObject.getUpdateValue(release, 'additionalNames') + ?? []), + }), + }, + + withFlattenedList({ + list: '#otherReleases.additionalNames', + }).outputs({ + '#flattenedList': '#sharedAdditionalNames', + }), + ], +}); -- cgit 1.3.0-6-gf8a5