« get me outta code hell

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:
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'}),
+  ],
+});