From 9d99dafca9dc4e16b867b707746314040a8d9ba5 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Sat, 11 Jan 2025 00:11:37 -0400 Subject: data: use soupyFind everywhere also notes where remaining directly-provided wikiData() props are used --- .../things/contribution/withContributionArtist.js | 11 ++------ .../things/track/withAlwaysReferenceByDirectory.js | 4 +-- .../composite/things/track/withOriginalRelease.js | 10 ++----- .../wiki-data/withParsedCommentaryEntries.js | 4 +-- .../composite/wiki-data/withResolvedContribs.js | 3 ++ .../composite/wiki-data/withResolvedSeriesList.js | 4 +-- src/data/things/album.js | 22 ++++----------- src/data/things/art-tag.js | 2 ++ src/data/things/artist.js | 14 ++++++---- src/data/things/contribution.js | 6 +++- src/data/things/flash.js | 28 ++++--------------- src/data/things/group.js | 23 +++++++--------- src/data/things/homepage-layout.js | 20 +++----------- src/data/things/track.js | 24 +++++++--------- src/data/things/wiki-info.js | 11 +++----- src/data/yaml.js | 32 ++++++---------------- 16 files changed, 77 insertions(+), 141 deletions(-) (limited to 'src/data') diff --git a/src/data/composite/things/contribution/withContributionArtist.js b/src/data/composite/things/contribution/withContributionArtist.js index 5a611c1a..50f60486 100644 --- a/src/data/composite/things/contribution/withContributionArtist.js +++ b/src/data/composite/things/contribution/withContributionArtist.js @@ -1,8 +1,8 @@ import {input, templateCompositeFrom} from '#composite'; import find from '#find'; -import {withPropertyFromObject} from '#composite/data'; import {withResolvedReference} from '#composite/wiki-data'; +import {soupyFind} from '#composite/wiki-properties'; export default templateCompositeFrom({ annotation: `withContributionArtist`, @@ -17,16 +17,9 @@ export default templateCompositeFrom({ outputs: ['#artist'], steps: () => [ - withPropertyFromObject({ - object: 'thing', - property: input.value('artistData'), - internal: input.value(true), - }), - withResolvedReference({ ref: input('ref'), - data: '#thing.artistData', - find: input.value(find.artist), + find: soupyFind.input('artist'), }).outputs({ '#resolvedReference': '#artist', }), diff --git a/src/data/composite/things/track/withAlwaysReferenceByDirectory.js b/src/data/composite/things/track/withAlwaysReferenceByDirectory.js index e01720b4..26c5ba97 100644 --- a/src/data/composite/things/track/withAlwaysReferenceByDirectory.js +++ b/src/data/composite/things/track/withAlwaysReferenceByDirectory.js @@ -9,6 +9,7 @@ import {isBoolean} from '#validators'; import {withPropertyFromObject} from '#composite/data'; import {withResolvedReference} from '#composite/wiki-data'; +import {soupyFind} from '#composite/wiki-properties'; import { exitWithoutDependency, @@ -31,8 +32,7 @@ export default templateCompositeFrom({ // recurse back into alwaysReferenceByDirectory! withResolvedReference({ ref: 'dataSourceAlbum', - data: 'albumData', - find: input.value(find.album), + find: soupyFind.input('album'), }).outputs({ '#resolvedReference': '#album', }), diff --git a/src/data/composite/things/track/withOriginalRelease.js b/src/data/composite/things/track/withOriginalRelease.js index c7f49657..59302eac 100644 --- a/src/data/composite/things/track/withOriginalRelease.js +++ b/src/data/composite/things/track/withOriginalRelease.js @@ -11,18 +11,13 @@ import {validateWikiData} from '#validators'; import {exitWithoutDependency, withResultOfAvailabilityCheck} from '#composite/control-flow'; import {withResolvedReference} from '#composite/wiki-data'; +import {soupyFind} from '#composite/wiki-properties'; export default templateCompositeFrom({ annotation: `withOriginalRelease`, inputs: { selfIfOriginal: input({type: 'boolean', defaultValue: false}), - - data: input({ - validate: validateWikiData({referenceType: 'track'}), - defaultDependency: 'trackData', - }), - notFoundValue: input({defaultValue: null}), }, @@ -55,8 +50,7 @@ export default templateCompositeFrom({ withResolvedReference({ ref: 'originalReleaseTrack', - data: input('data'), - find: input.value(find.track), + find: soupyFind.input('track'), }), exitWithoutDependency({ diff --git a/src/data/composite/wiki-data/withParsedCommentaryEntries.js b/src/data/composite/wiki-data/withParsedCommentaryEntries.js index 144781a8..d302b59e 100644 --- a/src/data/composite/wiki-data/withParsedCommentaryEntries.js +++ b/src/data/composite/wiki-data/withParsedCommentaryEntries.js @@ -11,6 +11,7 @@ import { withUnflattenedList, } from '#composite/data'; +import inputSoupyFind from './inputSoupyFind.js'; import withResolvedReferenceList from './withResolvedReferenceList.js'; export default templateCompositeFrom({ @@ -122,8 +123,7 @@ export default templateCompositeFrom({ withResolvedReferenceList({ list: '#flattenedList', - data: 'artistData', - find: input.value(find.artist), + find: inputSoupyFind.input('artist'), notFoundMode: input.value('null'), }), diff --git a/src/data/composite/wiki-data/withResolvedContribs.js b/src/data/composite/wiki-data/withResolvedContribs.js index fd3d8a0d..838c991f 100644 --- a/src/data/composite/wiki-data/withResolvedContribs.js +++ b/src/data/composite/wiki-data/withResolvedContribs.js @@ -110,6 +110,7 @@ export default templateCompositeFrom({ '#thingProperty', input('artistProperty'), input.myself(), + 'find', ], compute: (continuation, { @@ -117,6 +118,7 @@ export default templateCompositeFrom({ ['#thingProperty']: thingProperty, [input('artistProperty')]: artistProperty, [input.myself()]: myself, + ['find']: find, }) => continuation({ ['#contributions']: details.map(details => { @@ -127,6 +129,7 @@ export default templateCompositeFrom({ thing: myself, thingProperty: thingProperty, artistProperty: artistProperty, + find: find, }); return contrib; diff --git a/src/data/composite/wiki-data/withResolvedSeriesList.js b/src/data/composite/wiki-data/withResolvedSeriesList.js index 4ac74cc3..d31aa01a 100644 --- a/src/data/composite/wiki-data/withResolvedSeriesList.js +++ b/src/data/composite/wiki-data/withResolvedSeriesList.js @@ -12,6 +12,7 @@ import { withPropertiesFromList, } from '#composite/data'; +import inputSoupyFind from './inputSoupyFind.js'; import withResolvedReferenceList from './withResolvedReferenceList.js'; export default templateCompositeFrom({ @@ -62,8 +63,7 @@ export default templateCompositeFrom({ withResolvedReferenceList({ list: '#flattenedList', - data: 'albumData', - find: input.value(find.album), + find: inputSoupyFind.input('album'), notFoundMode: input.value('null'), }), diff --git a/src/data/things/album.js b/src/data/things/album.js index dbc3ca5b..1f789306 100644 --- a/src/data/things/album.js +++ b/src/data/things/album.js @@ -230,8 +230,7 @@ export class Album extends Thing { groups: referenceList({ class: input.value(Group), - find: input.value(find.group), - data: 'groupData', + find: soupyFind.input('group'), }), artTags: [ @@ -242,8 +241,7 @@ export class Album extends Thing { referenceList({ class: input.value(ArtTag), - find: input.value(find.artTag), - data: 'artTagData', + find: soupyFind.input('artTag'), }), ], @@ -273,26 +271,17 @@ export class Album extends Thing { find: soupyFind(), + // used for referencedArtworkList (mixedFind) albumData: wikiData({ class: input.value(Album), }), - artistData: wikiData({ - class: input.value(Artist), - }), - - artTagData: wikiData({ - class: input.value(ArtTag), - }), - - groupData: wikiData({ - class: input.value(Group), - }), - + // used for referencedArtworkList (mixedFind) trackData: wikiData({ class: input.value(Track), }), + // used for withMatchingContributionPresets (indirectly by Contribution) wikiInfo: thing({ class: input.value(WikiInfo), }), @@ -643,6 +632,7 @@ export class TrackSection extends Thing { // Update only + // used for withAlbum albumData: wikiData({ class: input.value(Album), }), diff --git a/src/data/things/art-tag.js b/src/data/things/art-tag.js index 3149b310..b7d79e8c 100644 --- a/src/data/things/art-tag.js +++ b/src/data/things/art-tag.js @@ -41,10 +41,12 @@ export class ArtTag extends Thing { // Update only + // used for taggedInThings (reverse) albumData: wikiData({ class: input.value(Album), }), + // used for taggedInThings (reverse) trackData: wikiData({ class: input.value(Track), }), diff --git a/src/data/things/artist.js b/src/data/things/artist.js index 8fdb8a12..64487dd0 100644 --- a/src/data/things/artist.js +++ b/src/data/things/artist.js @@ -25,6 +25,7 @@ import { reverseContributionList, reverseReferenceList, singleReference, + soupyFind, urls, wikiData, } from '#composite/wiki-properties'; @@ -57,28 +58,29 @@ export class Artist extends Thing { aliasedArtist: singleReference({ class: input.value(Artist), - find: input.value(find.artist), - data: 'artistData', + find: soupyFind.input('artist'), }), // Update only + find: soupyFind(), + + // used for reverse contribution lists albumData: wikiData({ class: input.value(Album), }), - artistData: wikiData({ - class: input.value(Artist), - }), - + // used for reverse contribution lists flashData: wikiData({ class: input.value(Flash), }), + // used for closelyLinkedGroups groupData: wikiData({ class: input.value(Group), }), + // used for reverse contribution lists trackData: wikiData({ class: input.value(Track), }), diff --git a/src/data/things/contribution.js b/src/data/things/contribution.js index 2712af70..5b6a4496 100644 --- a/src/data/things/contribution.js +++ b/src/data/things/contribution.js @@ -9,7 +9,7 @@ import {isStringNonEmpty, isThing, validateReference} from '#validators'; import {exitWithoutDependency, exposeDependency} from '#composite/control-flow'; import {withResolvedReference} from '#composite/wiki-data'; -import {flag, simpleDate} from '#composite/wiki-properties'; +import {flag, simpleDate, soupyFind} from '#composite/wiki-properties'; import { withFilteredList, @@ -82,6 +82,10 @@ export class Contribution extends Thing { flag(true), ], + // Update only + + find: soupyFind(), + // Expose only context: [ diff --git a/src/data/things/flash.js b/src/data/things/flash.js index bd995035..a681e013 100644 --- a/src/data/things/flash.js +++ b/src/data/things/flash.js @@ -106,8 +106,7 @@ export class Flash extends Thing { featuredTracks: referenceList({ class: input.value(Track), - find: input.value(find.track), - data: 'trackData', + find: soupyFind.input('track'), }), urls: urls(), @@ -119,18 +118,12 @@ export class Flash extends Thing { find: soupyFind(), - artistData: wikiData({ - class: input.value(Artist), - }), - - trackData: wikiData({ - class: input.value(Track), - }), - + // used for withFlashAct (reverse) flashActData: wikiData({ class: input.value(FlashAct), }), + // used for withMatchingContributionPresets (indirectly by Contribution) wikiInfo: thing({ class: input.value(WikiInfo), }), @@ -245,18 +238,14 @@ export class FlashAct extends Thing { flashes: referenceList({ class: input.value(Flash), - find: input.value(find.flash), - data: 'flashData', + find: soupyFind.input('flash'), }), // Update only find: soupyFind(), - flashData: wikiData({ - class: input.value(Flash), - }), - + // used for withFlashSide flashSideData: wikiData({ class: input.value(FlashSide), }), @@ -303,17 +292,12 @@ export class FlashSide extends Thing { acts: referenceList({ class: input.value(FlashAct), - find: input.value(find.flashAct), - data: 'flashActData', + find: soupyFind.input('flashAct'), }), // Update only find: soupyFind(), - - flashActData: wikiData({ - class: input.value(FlashAct), - }), }); static [Thing.yamlDocumentSpec] = { diff --git a/src/data/things/group.js b/src/data/things/group.js index 8418cb99..ffcc287c 100644 --- a/src/data/things/group.js +++ b/src/data/things/group.js @@ -13,6 +13,7 @@ import { name, referenceList, seriesList, + soupyFind, urls, wikiData, } from '#composite/wiki-properties'; @@ -32,8 +33,7 @@ export class Group extends Thing { closelyLinkedArtists: annotatedReferenceList({ class: input.value(Artist), - find: input.value(find.artist), - data: 'artistData', + find: soupyFind.input('artist'), date: input.value(null), @@ -43,8 +43,7 @@ export class Group extends Thing { featuredAlbums: referenceList({ class: input.value(Album), - find: input.value(find.album), - data: 'albumData', + find: soupyFind.input('album'), }), serieses: seriesList({ @@ -53,14 +52,15 @@ export class Group extends Thing { // Update only + find: soupyFind(), + + // used for albums (reverse) albumData: wikiData({ class: input.value(Album), }), - artistData: wikiData({ - class: input.value(Artist), - }), - + // used for category (reverse) + // used for color (reverse) groupCategoryData: wikiData({ class: input.value(GroupCategory), }), @@ -210,15 +210,12 @@ export class GroupCategory extends Thing { groups: referenceList({ class: input.value(Group), - find: input.value(find.group), - data: 'groupData', + find: soupyFind.input('group'), }), // Update only - groupData: wikiData({ - class: input.value(Group), - }), + find: soupyFind(), }); static [Thing.yamlDocumentSpec] = { diff --git a/src/data/things/homepage-layout.js b/src/data/things/homepage-layout.js index 00d6aef5..52be1b11 100644 --- a/src/data/things/homepage-layout.js +++ b/src/data/things/homepage-layout.js @@ -17,7 +17,7 @@ import { import {exposeDependency} from '#composite/control-flow'; import {withResolvedReference} from '#composite/wiki-data'; -import {color, contentString, name, referenceList, wikiData} +import {color, contentString, name, referenceList, soupyFind} from '#composite/wiki-properties'; export class HomepageLayout extends Thing { @@ -74,17 +74,7 @@ export class HomepageLayoutRow extends Thing { // Update only - // These wiki data arrays aren't necessarily used by every subclass, but - // to the convenience of providing these, the superclass accepts all wiki - // data arrays depended upon by any subclass. - - albumData: wikiData({ - class: input.value(Album), - }), - - groupData: wikiData({ - class: input.value(Group), - }), + find: soupyFind(), }); static [Thing.yamlDocumentSpec] = { @@ -151,8 +141,7 @@ export class HomepageLayoutAlbumsRow extends HomepageLayoutRow { withResolvedReference({ ref: input.updateValue(), - data: 'groupData', - find: input.value(find.group), + find: soupyFind.input('group'), }), exposeDependency({dependency: '#resolvedReference'}), @@ -160,8 +149,7 @@ export class HomepageLayoutAlbumsRow extends HomepageLayoutRow { sourceAlbums: referenceList({ class: input.value(Album), - find: input.value(find.album), - data: 'albumData', + find: soupyFind.input('album'), }), countAlbumsFromGroup: { diff --git a/src/data/things/track.js b/src/data/things/track.js index d88f366c..4662be89 100644 --- a/src/data/things/track.js +++ b/src/data/things/track.js @@ -222,8 +222,7 @@ export class Track extends Thing { originalReleaseTrack: singleReference({ class: input.value(Track), - find: input.value(find.track), - data: 'trackData', + find: soupyFind.input('track'), }), // Internal use only - for directly identifying an album inside a track's @@ -231,8 +230,7 @@ export class Track extends Thing { // included in an album's track list). dataSourceAlbum: singleReference({ class: input.value(Album), - find: input.value(find.album), - data: 'albumData', + find: soupyFind.input('album'), }), artistContribs: [ @@ -354,8 +352,7 @@ export class Track extends Thing { referenceList({ class: input.value(ArtTag), - find: input.value(find.artTag), - data: 'artTagData', + find: soupyFind.input('artTag'), }), ], @@ -377,30 +374,29 @@ export class Track extends Thing { find: soupyFind(), + // used for referencedArtworkList (mixedFind) + // used for withAlbum (reverse) albumData: wikiData({ class: input.value(Album), }), - artistData: wikiData({ - class: input.value(Artist), - }), - - artTagData: wikiData({ - class: input.value(ArtTag), - }), - + // used for featuredInFlashes (reverse) flashData: wikiData({ class: input.value(Flash), }), + // used for referencedArtworkList (mixedFind) + // used for trackReverseReferenceList (reverse) trackData: wikiData({ class: input.value(Track), }), + // used for withContainingTrackSection (reverse) trackSectionData: wikiData({ class: input.value(TrackSection), }), + // used for withMatchingContributionPresets (indirectly by Contribution) wikiInfo: thing({ class: input.value(WikiInfo), }), diff --git a/src/data/things/wiki-info.js b/src/data/things/wiki-info.js index ef643681..1a91ac5e 100644 --- a/src/data/things/wiki-info.js +++ b/src/data/things/wiki-info.js @@ -15,7 +15,7 @@ import { } from '#validators'; import {exitWithoutDependency} from '#composite/control-flow'; -import {contentString, flag, name, referenceList, wikiData} +import {contentString, flag, name, referenceList, soupyFind} from '#composite/wiki-properties'; export class WikiInfo extends Thing { @@ -71,8 +71,7 @@ export class WikiInfo extends Thing { divideTrackListsByGroups: referenceList({ class: input.value(Group), - find: input.value(find.group), - data: 'groupData', + find: soupyFind.input('group'), }), contributionPresets: { @@ -99,6 +98,8 @@ export class WikiInfo extends Thing { // Update only + find: soupyFind(), + searchDataAvailable: { flags: {update: true}, update: { @@ -106,10 +107,6 @@ export class WikiInfo extends Thing { default: false, }, }, - - groupData: wikiData({ - class: input.value(Group), - }), }); static [Thing.yamlDocumentSpec] = { diff --git a/src/data/yaml.js b/src/data/yaml.js index 2420bf71..cb16f872 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -1227,11 +1227,11 @@ export async function loadAndProcessDataDocuments(dataSteps, {dataPath}) { // of which are required for page HTML generation and other expected behavior). export function linkWikiDataArrays(wikiData, {bindFind}) { const linkWikiDataSpec = new Map([ + // entries must be present here even without any properties to explicitly + // link if the 'find' property will be implicitly linked + [wikiData.albumData, [ 'albumData', - 'artTagData', - 'artistData', - 'groupData', 'trackData', 'wikiInfo', ]], @@ -1243,47 +1243,33 @@ export function linkWikiDataArrays(wikiData, {bindFind}) { [wikiData.artistData, [ 'albumData', - 'artistData', 'flashData', 'groupData', 'trackData', ]], [wikiData.flashData, [ - 'artistData', 'flashActData', - 'trackData', 'wikiInfo', ]], [wikiData.flashActData, [ - 'flashData', 'flashSideData', ]], - [wikiData.flashSideData, [ - 'flashActData', - ]], + [wikiData.flashSideData, [/* find */]], [wikiData.groupData, [ 'albumData', - 'artistData', 'groupCategoryData', ]], - [wikiData.groupCategoryData, [ - 'groupData', - ]], + [wikiData.groupCategoryData, [/* find */]], - [wikiData.homepageLayout?.rows, [ - 'albumData', - 'groupData', - ]], + [wikiData.homepageLayout.rows, [/* find */]], [wikiData.trackData, [ 'albumData', - 'artTagData', - 'artistData', 'flashData', 'trackData', 'trackSectionData', @@ -1294,14 +1280,14 @@ export function linkWikiDataArrays(wikiData, {bindFind}) { 'albumData', ]], - [[wikiData.wikiInfo], [ - 'groupData', - ]], + [[wikiData.wikiInfo], [/* find */]], ]); const constructorHasFindMap = new Map(); const boundFind = bindFind(wikiData); + for (const thing of Object.values(wikiData).flat()); + for (const [things, keys] of linkWikiDataSpec.entries()) { if (things === undefined) continue; -- cgit 1.3.0-6-gf8a5