diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/data/checks.js | 26 | ||||
-rw-r--r-- | src/data/composite/wiki-data/withResolvedArtworkReferenceList.js | 4 | ||||
-rw-r--r-- | src/data/composite/wiki-data/withResolvedReferenceList.js | 2 | ||||
-rw-r--r-- | src/data/composite/wiki-properties/referencedArtworkList.js | 60 | ||||
-rw-r--r-- | src/data/things/album.js | 30 | ||||
-rw-r--r-- | src/data/things/track.js | 29 |
6 files changed, 66 insertions, 85 deletions
diff --git a/src/data/checks.js b/src/data/checks.js index cbc4ce0b..feefc171 100644 --- a/src/data/checks.js +++ b/src/data/checks.js @@ -9,7 +9,7 @@ import {compareArrays, cut, cutStart, empty, getNestedProp, iterateMultiline} from '#sugar'; import Thing from '#thing'; import thingConstructors from '#things'; -import {commentaryRegexCaseSensitive} from '#wiki-data'; +import {combineWikiDataArrays, commentaryRegexCaseSensitive} from '#wiki-data'; import { annotateErrorWithIndex, @@ -184,8 +184,7 @@ export function filterReferenceErrors(wikiData, { bannerArtistContribs: '_contrib', groups: 'group', artTags: '_artTag', - referencedTrackArtworks: '_trackArtwork', - referencedAlbumArtworks: '_albumArtwork', + referencedArtworks: '_artwork', commentary: '_commentary', }], @@ -222,8 +221,7 @@ export function filterReferenceErrors(wikiData, { referencedTracks: '_trackNotRerelease', sampledTracks: '_trackNotRerelease', artTags: '_artTag', - referencedTrackArtworks: '_trackArtwork', - referencedAlbumArtworks: '_albumArtwork', + referencedArtworks: '_artwork', originalReleaseTrack: '_trackNotRerelease', commentary: '_commentary', }], @@ -290,9 +288,23 @@ export function filterReferenceErrors(wikiData, { let findFn; switch (findFnKey) { - case '_albumArtwork': - findFn = ref => boundFind.album(ref.reference); + case '_artwork': { + const mixed = + find.mixed({ + album: find.album, + track: find.track, + }); + + const data = + combineWikiDataArrays([ + wikiData.albumData, + wikiData.trackData, + ]); + + findFn = ref => mixed(ref.reference, data); + break; + } case '_artTag': findFn = boundFind.artTag; diff --git a/src/data/composite/wiki-data/withResolvedArtworkReferenceList.js b/src/data/composite/wiki-data/withResolvedArtworkReferenceList.js index e9c6a590..08c45ec8 100644 --- a/src/data/composite/wiki-data/withResolvedArtworkReferenceList.js +++ b/src/data/composite/wiki-data/withResolvedArtworkReferenceList.js @@ -24,7 +24,7 @@ export default templateCompositeFrom({ acceptsNull: true, }), - data: inputWikiData({allowMixedTypes: false}), + data: inputWikiData({allowMixedTypes: true}), find: input({type: 'function'}), notFoundMode: input({ @@ -33,6 +33,8 @@ export default templateCompositeFrom({ }), }, + outputs: ['#resolvedArtworkReferenceList'], + steps: () => [ withPropertiesFromList({ list: input('list'), diff --git a/src/data/composite/wiki-data/withResolvedReferenceList.js b/src/data/composite/wiki-data/withResolvedReferenceList.js index 1d39e5b2..42f0e175 100644 --- a/src/data/composite/wiki-data/withResolvedReferenceList.js +++ b/src/data/composite/wiki-data/withResolvedReferenceList.js @@ -23,7 +23,7 @@ export default templateCompositeFrom({ acceptsNull: true, }), - data: inputWikiData({allowMixedTypes: false}), + data: inputWikiData({allowMixedTypes: true}), find: input({type: 'function'}), notFoundMode: input({ diff --git a/src/data/composite/wiki-properties/referencedArtworkList.js b/src/data/composite/wiki-properties/referencedArtworkList.js index bd2962de..251944e5 100644 --- a/src/data/composite/wiki-properties/referencedArtworkList.js +++ b/src/data/composite/wiki-properties/referencedArtworkList.js @@ -1,45 +1,55 @@ import {input, templateCompositeFrom} from '#composite'; -import {isThingClass, validateAnnotatedReferenceList} from '#validators'; +import find from '#find'; +import {validateAnnotatedReferenceList} from '#validators'; +import {combineWikiDataArrays} from '#wiki-data'; import {exposeDependency} from '#composite/control-flow'; -import {inputWikiData, withResolvedArtworkReferenceList} from '#composite/wiki-data'; +import {withResolvedArtworkReferenceList} from '#composite/wiki-data'; export default templateCompositeFrom({ annotation: `referencedArtworkList`, - inputs: { - class: input.staticValue({ - validate: isThingClass, - acceptsNull: true, - defaultValue: null, - }), - - referenceType: input.staticValue({ - type: 'string', - acceptsNull: true, - defaultValue: null, - }), - - data: inputWikiData({allowMixedTypes: false}), - find: input({type: 'function'}), - }, - update: ({ [input.staticValue('class')]: thingClass, [input.staticValue('referenceType')]: referenceType, }) => ({ validate: - validateAnnotatedReferenceList( - (thingClass - ? thingClass[Symbol.for('Thing.referenceType')] - : referenceType)), + validateAnnotatedReferenceList(['album', 'track']), }), steps: () => [ + { + dependencies: [ + 'albumData', + 'trackData', + ], + + compute: (continuation, { + albumData, + trackData, + }) => continuation({ + ['#data']: + combineWikiDataArrays([ + albumData, + trackData, + ]), + }), + }, + + { + compute: (continuation) => continuation({ + ['#find']: + find.mixed({ + track: find.track, + album: find.album, + }), + }), + }, + withResolvedArtworkReferenceList({ list: input.updateValue(), - data: input('data'), - find: input('find'), + data: '#data', + find: '#find', }), exposeDependency({dependency: '#resolvedArtworkReferenceList'}), diff --git a/src/data/things/album.js b/src/data/things/album.js index 4a714361..6bfec68c 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -233,30 +233,13 @@ export class Album extends Thing { }), ], - referencedTrackArtworks: [ + referencedArtworks: [ exitWithoutContribs({ contribs: 'coverArtistContribs', value: input.value([]), }), - referencedArtworkList({ - class: input.value(Track), - find: input.value(find.track), - data: 'trackData', - }), - ], - - referencedAlbumArtworks: [ - exitWithoutContribs({ - contribs: 'coverArtistContribs', - value: input.value([]), - }), - - referencedArtworkList({ - class: input.value(Album), - find: input.value(find.album), - data: 'albumData', - }), + referencedArtworkList(), ], // Update only @@ -429,13 +412,8 @@ export class Album extends Thing { transform: parseAdditionalFiles, }, - 'Referenced Track Artworks': { - property: 'referencedTrackArtworks', - transform: parseReferencedArtworks, - }, - - 'Referenced Album Artworks': { - property: 'referencedAlbumArtworks', + 'Referenced Artworks': { + property: 'referencedArtworks', transform: parseReferencedArtworks, }, diff --git a/src/data/things/track.js b/src/data/things/track.js index a1740f87..d86c7635 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -352,28 +352,12 @@ export class Track extends Thing { }), ], - referencedTrackArtworks: [ + referencedArtworks: [ exitWithoutUniqueCoverArt({ value: input.value([]), }), - referencedArtworkList({ - class: input.value(Track), - find: input.value(find.track), - data: 'trackData', - }), - ], - - referencedAlbumArtworks: [ - exitWithoutUniqueCoverArt({ - value: input.value([]), - }), - - referencedArtworkList({ - class: input.value(Album), - find: input.value(find.album), - data: 'albumData', - }), + referencedArtworkList(), ], // Update only @@ -540,13 +524,8 @@ export class Track extends Thing { 'Referenced Tracks': {property: 'referencedTracks'}, 'Sampled Tracks': {property: 'sampledTracks'}, - 'Referenced Track Artworks': { - property: 'referencedTrackArtworks', - transform: parseReferencedArtworks, - }, - - 'Referenced Album Artworks': { - property: 'referencedAlbumArtworks', + 'Referenced Artworks': { + property: 'referencedArtworks', transform: parseReferencedArtworks, }, |