« get me outta code hell

data: annotated artwork references - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite/wiki-properties/referencedArtworkList.js
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-11-14 07:37:14 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-11-14 07:37:14 -0400
commit913f418eadb0b085c805ff1c83b749a0ce620741 (patch)
tree6d369056d724552ac5191930ae87c05b93ee64fc /src/data/composite/wiki-properties/referencedArtworkList.js
parentdb0fd78ca60fc695f87d1f3adf53967bdae2796f (diff)
data: annotated artwork references
Not used on-site, but this is all coded internally.
Diffstat (limited to 'src/data/composite/wiki-properties/referencedArtworkList.js')
-rw-r--r--src/data/composite/wiki-properties/referencedArtworkList.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/data/composite/wiki-properties/referencedArtworkList.js b/src/data/composite/wiki-properties/referencedArtworkList.js
new file mode 100644
index 00000000..bd2962de
--- /dev/null
+++ b/src/data/composite/wiki-properties/referencedArtworkList.js
@@ -0,0 +1,47 @@
+import {input, templateCompositeFrom} from '#composite';
+import {isThingClass, validateAnnotatedReferenceList} from '#validators';
+
+import {exposeDependency} from '#composite/control-flow';
+import {inputWikiData, 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)),
+  }),
+
+  steps: () => [
+    withResolvedArtworkReferenceList({
+      list: input.updateValue(),
+      data: input('data'),
+      find: input('find'),
+    }),
+
+    exposeDependency({dependency: '#resolvedArtworkReferenceList'}),
+  ],
+});