« get me outta code hell

data: Artwork, constitutibleArtwork, etc - 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-03-31 15:04:20 -0300
committer(quasar) nebula <qznebula@protonmail.com>2025-04-10 16:02:35 -0300
commite8964d7a9f9dc787d4d84c0554d22149bb2daa0c (patch)
tree460944e7a5417ee8a998e37d7cbd05364398fd4f /src/data/composite/wiki-properties
parent964273f8cb26c6d9df8ec827126167dc5b58ae27 (diff)
data: Artwork, constitutibleArtwork, etc
Not used in content yet.
Diffstat (limited to 'src/data/composite/wiki-properties')
-rw-r--r--src/data/composite/wiki-properties/constitutibleArtwork.js67
-rw-r--r--src/data/composite/wiki-properties/index.js1
2 files changed, 68 insertions, 0 deletions
diff --git a/src/data/composite/wiki-properties/constitutibleArtwork.js b/src/data/composite/wiki-properties/constitutibleArtwork.js
new file mode 100644
index 00000000..e0f0f521
--- /dev/null
+++ b/src/data/composite/wiki-properties/constitutibleArtwork.js
@@ -0,0 +1,67 @@
+import {input, templateCompositeFrom} from '#composite';
+import {isContributionList, isDate, validateThing} from '#validators';
+
+import {exitWithoutDependency, exposeDependency, exposeUpdateValueOrContinue}
+  from '#composite/control-flow';
+import {withConstitutedArtwork} from '#composite/wiki-data';
+
+export default templateCompositeFrom({
+  annotation: `constitutibleArtwork`,
+
+  compose: false,
+
+  inputs: {
+    contribs: input.staticDependency({
+      validate: isContributionList,
+      acceptsNull: true,
+    }),
+
+    date: input.staticDependency({
+      validate: isDate,
+      acceptsNull: true,
+    }),
+
+    artistProperty: input.staticValue({
+      type: 'string',
+    }),
+  },
+
+  steps: () => [
+    exposeUpdateValueOrContinue({
+      validate: input.value(
+        validateThing({
+          referenceType: 'artwork',
+        })),
+    }),
+
+    exitWithoutDependency({
+      dependency: input('contribs'),
+      value: input.value(null),
+    }),
+
+    {
+      dependencies: [
+        input.staticDependency('contribs'),
+        input.staticDependency('date'),
+      ],
+
+      compute: (continuation, {
+        [input.staticDependency('contribs')]: contribsProperty,
+        [input.staticDependency('date')]: dateProperty,
+      }) => continuation({
+        ['#contribsProperty']: contribsProperty,
+        ['#dateProperty']: dateProperty,
+      })
+    },
+
+    withConstitutedArtwork({
+      contribsProperty: '#contribsProperty',
+      artistProperty: input('artistProperty'),
+      dateProperty: '#dateProperty',
+    }),
+
+    exposeDependency({
+      dependency: '#constitutedArtwork',
+    }),
+  ],
+});
diff --git a/src/data/composite/wiki-properties/index.js b/src/data/composite/wiki-properties/index.js
index 4aaaeb72..7583630d 100644
--- a/src/data/composite/wiki-properties/index.js
+++ b/src/data/composite/wiki-properties/index.js
@@ -9,6 +9,7 @@ export {default as annotatedReferenceList} from './annotatedReferenceList.js';
 export {default as color} from './color.js';
 export {default as commentary} from './commentary.js';
 export {default as commentatorArtists} from './commentatorArtists.js';
+export {default as constitutibleArtwork} from './constitutibleArtwork.js';
 export {default as contentString} from './contentString.js';
 export {default as contribsPresent} from './contribsPresent.js';
 export {default as contributionList} from './contributionList.js';