« get me outta code hell

data: soupy reverse - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-properties
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2025-01-11 20:49:26 -0400
committer(quasar) nebula <qznebula@protonmail.com>2025-01-11 20:49:26 -0400
commit77fc589466fc0c04326231638c5ec6026e7948d4 (patch)
treedbc019e4f72851bd3fa8fd5195d87fe6f6177f7c /src/data/composite/wiki-properties
parent3bb0a89e80fddb985cc1fc4775e58b0d4a7445dc (diff)
data: soupy reverse
Diffstat (limited to 'src/data/composite/wiki-properties')
-rw-r--r--src/data/composite/wiki-properties/index.js5
-rw-r--r--src/data/composite/wiki-properties/reverseAnnotatedReferenceList.js33
-rw-r--r--src/data/composite/wiki-properties/reverseContributionList.js24
-rw-r--r--src/data/composite/wiki-properties/reverseReferenceList.js12
-rw-r--r--src/data/composite/wiki-properties/reverseReferencedArtworkList.js39
-rw-r--r--src/data/composite/wiki-properties/reverseSingleReferenceList.js24
-rw-r--r--src/data/composite/wiki-properties/soupyReverse.js22
7 files changed, 29 insertions, 130 deletions
diff --git a/src/data/composite/wiki-properties/index.js b/src/data/composite/wiki-properties/index.js
index d2e32e6d..4aaaeb72 100644
--- a/src/data/composite/wiki-properties/index.js
+++ b/src/data/composite/wiki-properties/index.js
@@ -21,16 +21,13 @@ export {default as flag} from './flag.js';
 export {default as name} from './name.js';
 export {default as referenceList} from './referenceList.js';
 export {default as referencedArtworkList} from './referencedArtworkList.js';
-export {default as reverseAnnotatedReferenceList} from './reverseAnnotatedReferenceList.js';
-export {default as reverseContributionList} from './reverseContributionList.js';
 export {default as reverseReferenceList} from './reverseReferenceList.js';
-export {default as reverseReferencedArtworkList} from './reverseReferencedArtworkList.js';
-export {default as reverseSingleReferenceList} from './reverseSingleReferenceList.js';
 export {default as seriesList} from './seriesList.js';
 export {default as simpleDate} from './simpleDate.js';
 export {default as simpleString} from './simpleString.js';
 export {default as singleReference} from './singleReference.js';
 export {default as soupyFind} from './soupyFind.js';
+export {default as soupyReverse} from './soupyReverse.js';
 export {default as thing} from './thing.js';
 export {default as thingList} from './thingList.js';
 export {default as urls} from './urls.js';
diff --git a/src/data/composite/wiki-properties/reverseAnnotatedReferenceList.js b/src/data/composite/wiki-properties/reverseAnnotatedReferenceList.js
deleted file mode 100644
index ba7166b9..00000000
--- a/src/data/composite/wiki-properties/reverseAnnotatedReferenceList.js
+++ /dev/null
@@ -1,33 +0,0 @@
-import {input, templateCompositeFrom} from '#composite';
-
-import {exposeDependency} from '#composite/control-flow';
-import {inputWikiData, withReverseAnnotatedReferenceList}
-  from '#composite/wiki-data';
-
-export default templateCompositeFrom({
-  annotation: `reverseAnnotatedReferenceList`,
-
-  compose: false,
-
-  inputs: {
-    data: inputWikiData({allowMixedTypes: false}),
-    list: input({type: 'string'}),
-
-    forward: input({type: 'string', defaultValue: 'thing'}),
-    backward: input({type: 'string', defaultValue: 'thing'}),
-    annotation: input({type: 'string', defaultValue: 'annotation'}),
-  },
-
-  steps: () => [
-    withReverseAnnotatedReferenceList({
-      data: input('data'),
-      list: input('list'),
-
-      forward: input('forward'),
-      backward: input('backward'),
-      annotation: input('annotation'),
-    }),
-
-    exposeDependency({dependency: '#reverseAnnotatedReferenceList'}),
-  ],
-});
diff --git a/src/data/composite/wiki-properties/reverseContributionList.js b/src/data/composite/wiki-properties/reverseContributionList.js
deleted file mode 100644
index 7f3f9c81..00000000
--- a/src/data/composite/wiki-properties/reverseContributionList.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import {input, templateCompositeFrom} from '#composite';
-
-import {exposeDependency} from '#composite/control-flow';
-import {inputWikiData, withReverseContributionList} from '#composite/wiki-data';
-
-export default templateCompositeFrom({
-  annotation: `reverseContributionList`,
-
-  compose: false,
-
-  inputs: {
-    data: inputWikiData({allowMixedTypes: false}),
-    list: input({type: 'string'}),
-  },
-
-  steps: () => [
-    withReverseContributionList({
-      data: input('data'),
-      list: input('list'),
-    }),
-
-    exposeDependency({dependency: '#reverseContributionList'}),
-  ],
-});
diff --git a/src/data/composite/wiki-properties/reverseReferenceList.js b/src/data/composite/wiki-properties/reverseReferenceList.js
index 84ba67df..6d590a67 100644
--- a/src/data/composite/wiki-properties/reverseReferenceList.js
+++ b/src/data/composite/wiki-properties/reverseReferenceList.js
@@ -1,13 +1,13 @@
 // Neat little shortcut for "reversing" the reference lists stored on other
 // things - for example, tracks specify a "referenced tracks" property, and
 // you would use this to compute a corresponding "referenced *by* tracks"
-// property. Naturally, the passed ref list property is of the things in the
-// wiki data provided, not the requesting Thing itself.
+// property.
 
 import {input, templateCompositeFrom} from '#composite';
 
 import {exposeDependency} from '#composite/control-flow';
-import {inputWikiData, withReverseReferenceList} from '#composite/wiki-data';
+import {inputSoupyReverse, inputWikiData, withReverseReferenceList}
+  from '#composite/wiki-data';
 
 export default templateCompositeFrom({
   annotation: `reverseReferenceList`,
@@ -15,14 +15,14 @@ export default templateCompositeFrom({
   compose: false,
 
   inputs: {
-    data: inputWikiData({allowMixedTypes: false}),
-    list: input({type: 'string'}),
+    data: inputWikiData({allowMixedTypes: true}),
+    reverse: inputSoupyReverse(),
   },
 
   steps: () => [
     withReverseReferenceList({
       data: input('data'),
-      list: input('list'),
+      reverse: input('reverse'),
     }),
 
     exposeDependency({dependency: '#reverseReferenceList'}),
diff --git a/src/data/composite/wiki-properties/reverseReferencedArtworkList.js b/src/data/composite/wiki-properties/reverseReferencedArtworkList.js
deleted file mode 100644
index 2950bdb9..00000000
--- a/src/data/composite/wiki-properties/reverseReferencedArtworkList.js
+++ /dev/null
@@ -1,39 +0,0 @@
-import {input, templateCompositeFrom} from '#composite';
-import {combineWikiDataArrays} from '#wiki-data';
-
-import {exposeDependency} from '#composite/control-flow';
-import {inputWikiData, withReverseAnnotatedReferenceList}
-  from '#composite/wiki-data';
-
-export default templateCompositeFrom({
-  annotation: `reverseReferencedArtworkList`,
-
-  compose: false,
-
-  steps: () => [
-    {
-      dependencies: [
-        'albumData',
-        'trackData',
-      ],
-
-      compute: (continuation, {
-        albumData,
-        trackData,
-      }) => continuation({
-        ['#data']:
-          combineWikiDataArrays([
-            albumData,
-            trackData,
-          ]),
-      }),
-    },
-
-    withReverseAnnotatedReferenceList({
-      data: '#data',
-      list: input.value('referencedArtworks'),
-    }),
-
-    exposeDependency({dependency: '#reverseAnnotatedReferenceList'}),
-  ],
-});
diff --git a/src/data/composite/wiki-properties/reverseSingleReferenceList.js b/src/data/composite/wiki-properties/reverseSingleReferenceList.js
deleted file mode 100644
index d180b12d..00000000
--- a/src/data/composite/wiki-properties/reverseSingleReferenceList.js
+++ /dev/null
@@ -1,24 +0,0 @@
-import {input, templateCompositeFrom} from '#composite';
-
-import {exposeDependency} from '#composite/control-flow';
-import {inputWikiData, withReverseSingleReferenceList} from '#composite/wiki-data';
-
-export default templateCompositeFrom({
-  annotation: `reverseSingleReferenceList`,
-
-  compose: false,
-
-  inputs: {
-    data: inputWikiData({allowMixedTypes: false}),
-    ref: input({type: 'string'}),
-  },
-
-  steps: () => [
-    withReverseSingleReferenceList({
-      data: input('data'),
-      ref: input('ref'),
-    }),
-
-    exposeDependency({dependency: '#reverseSingleReferenceList'}),
-  ],
-});
diff --git a/src/data/composite/wiki-properties/soupyReverse.js b/src/data/composite/wiki-properties/soupyReverse.js
new file mode 100644
index 00000000..269ccd6f
--- /dev/null
+++ b/src/data/composite/wiki-properties/soupyReverse.js
@@ -0,0 +1,22 @@
+import {isObject} from '#validators';
+
+import {inputSoupyReverse} from '#composite/wiki-data';
+
+function soupyReverse() {
+  return {
+    flags: {update: true},
+    update: {validate: isObject},
+  };
+}
+
+soupyReverse.input = inputSoupyReverse.input;
+
+soupyReverse.contributionsBy =
+  (bindTo, contributionsProperty) => ({
+    bindTo,
+
+    referencing: thing => thing[contributionsProperty],
+    referenced: contrib => [contrib.artist],
+  });
+
+export default soupyReverse;