22 Commits 0bf5694063 ... 226c316f21

Auteur SHA1 Message Date
  (quasar) nebula 226c316f21 checks: fix error reporting for bad artwork references il y a 1 semaine
  (quasar) nebula 7f67977621 validators: validateReference: fix multiple type validation il y a 1 semaine
  (quasar) nebula f499d60797 data: referenceList: allow mixed wiki data il y a 1 semaine
  (quasar) nebula 18849547f4 data: Referenced Artworks il y a 1 semaine
  (quasar) nebula 4f6e0bc351 validators: validateReference (etc): multiple reference types il y a 1 semaine
  (quasar) nebula 2d5f323bb4 checks, yaml, etc: pass find to filterReferenceErrors il y a 1 semaine
  (quasar) nebula 5a75006880 wiki-data: combineWikiDataArrays il y a 1 semaine
  (quasar) nebula 9d91023e7c wiki-data: TupleMapForBabies il y a 1 semaine
  (quasar) nebula 82a1f50865 find: cache findMixed by identity of data il y a 1 semaine
  (quasar) nebula cbaad7b6ab find: mixedFind -> findMixed il y a 1 semaine
  (quasar) nebula 042f60f476 find: findMixedHelper directory internals il y a 1 semaine
  (quasar) nebula 3c859e00f5 find: final factoring out, probably il y a 1 semaine
  (quasar) nebula 38f6848135 find: factor out prepareMatchBy{Directory,Name} il y a 1 semaine
  (quasar) nebula 33e87a188b find: factor out some stuff into matchHelper il y a 1 semaine
  (quasar) nebula 36f1a86102 find: copy in some more common behavior il y a 1 semaine
  (quasar) nebula 7360804a1d find: prefer if-style branching in findHelper/mixedFindHelper il y a 1 semaine
  (quasar) nebula 1effe97c83 data: stub real results for find.mixed il y a 1 semaine
  (quasar) nebula 08c46ad7d8 find: factor out keyRefRegex & tidy usage il y a 1 semaine
  (quasar) nebula bcdd272af7 find: decompose processAllAvailableMatches il y a 1 semaine
  (quasar) nebula 6c27ca6069 find: postprocessFindSpec, include() instanceof by default il y a 1 semaine
  (quasar) nebula 394e298731 find: find.mixed stub il y a 1 semaine
  (quasar) nebula 6190ca206d sugar: compareObjects il y a 1 semaine

+ 2 - 1
data-tests/index.js

@@ -4,7 +4,7 @@ import {fileURLToPath} from 'node:url';
 import chokidar from 'chokidar';
 
 import {colors, logError, logInfo, logWarn, parseOptions} from '#cli';
-import {bindFind, getAllFindSpecs} from '#find';
+import find, {bindFind, getAllFindSpecs} from '#find';
 import {isMain} from '#node-utils';
 import {getContextAssignments} from '#repl';
 import {bindOpts, showAggregate} from '#sugar';
@@ -33,6 +33,7 @@ async function main() {
   const watcher = chokidar.watch(metaDirname);
 
   const wikiData = await quickLoadAllFromYAML(dataPath, {
+    find,
     bindFind,
     getAllFindSpecs,
 

+ 20 - 7
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,
@@ -172,6 +172,7 @@ function getFieldPropertyMessage(yamlDocumentSpec, property) {
 // any errors). At the same time, we remove errored references from the thing's
 // data array.
 export function filterReferenceErrors(wikiData, {
+  find,
   bindFind,
 }) {
   const referenceSpec = [
@@ -183,8 +184,7 @@ export function filterReferenceErrors(wikiData, {
       bannerArtistContribs: '_contrib',
       groups: 'group',
       artTags: '_artTag',
-      referencedTrackArtworks: '_trackArtwork',
-      referencedAlbumArtworks: '_albumArtwork',
+      referencedArtworks: '_artwork',
       commentary: '_commentary',
     }],
 
@@ -221,8 +221,7 @@ export function filterReferenceErrors(wikiData, {
       referencedTracks: '_trackNotRerelease',
       sampledTracks: '_trackNotRerelease',
       artTags: '_artTag',
-      referencedTrackArtworks: '_trackArtwork',
-      referencedAlbumArtworks: '_albumArtwork',
+      referencedArtworks: '_artwork',
       originalReleaseTrack: '_trackNotRerelease',
       commentary: '_commentary',
     }],
@@ -289,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, {mode: 'error'});
+
                 break;
+              }
 
               case '_artTag':
                 findFn = boundFind.artTag;

+ 3 - 1
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'),

+ 1 - 1
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({

+ 1 - 1
src/data/composite/wiki-properties/referenceList.js

@@ -31,7 +31,7 @@ export default templateCompositeFrom({
       defaultValue: null,
     }),
 
-    data: inputWikiData({allowMixedTypes: false}),
+    data: inputWikiData({allowMixedTypes: true}),
 
     find: input({type: 'function'}),
   },

+ 35 - 25
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'}),

+ 2 - 0
src/data/thing.js

@@ -14,6 +14,8 @@ export default class Thing extends CacheableObject {
   static getSerializeDescriptors = Symbol.for('Thing.getSerializeDescriptors');
 
   static findSpecs = Symbol.for('Thing.findSpecs');
+  static findThisThingOnly = Symbol.for('Thing.findThisThingOnly');
+
   static yamlDocumentSpec = Symbol.for('Thing.yamlDocumentSpec');
   static getYamlLoadingSpec = Symbol.for('Thing.getYamlLoadingSpec');
 

+ 4 - 26
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,
       },
 

+ 4 - 25
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,
       },
 

+ 0 - 0
src/data/validators.js


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff