« get me outta code hell

data: contribution: context - hsmusic-wiki - HSMusic - static wiki software cataloguing collaborative creation
about summary refs log tree commit diff
path: root/src/data/composite
diff options
context:
space:
mode:
author(quasar) nebula <qznebula@protonmail.com>2024-03-04 20:25:05 -0400
committer(quasar) nebula <qznebula@protonmail.com>2024-06-18 22:56:00 -0300
commit7f3bd77e36839b8601b498b6d13c0a60406d9899 (patch)
treecbe3f1f28bd656848f766fd7f5dee65d99033743 /src/data/composite
parent32cafa563c289dc5893565afb4133e2a84ac4fcc (diff)
data: contribution: context
Diffstat (limited to 'src/data/composite')
-rw-r--r--src/data/composite/things/contribution/index.js1
-rw-r--r--src/data/composite/things/contribution/withContributionContext.js29
2 files changed, 30 insertions, 0 deletions
diff --git a/src/data/composite/things/contribution/index.js b/src/data/composite/things/contribution/index.js
index c0506a2b..b06e8677 100644
--- a/src/data/composite/things/contribution/index.js
+++ b/src/data/composite/things/contribution/index.js
@@ -1 +1,2 @@
 export {default as withContributionArtist} from './withContributionArtist.js';
+export {default as withContributionContext} from './withContributionContext.js';
diff --git a/src/data/composite/things/contribution/withContributionContext.js b/src/data/composite/things/contribution/withContributionContext.js
new file mode 100644
index 00000000..83ad5b73
--- /dev/null
+++ b/src/data/composite/things/contribution/withContributionContext.js
@@ -0,0 +1,29 @@
+import {input, templateCompositeFrom} from '#composite';
+
+import {withPropertiesFromObject} from '#composite/data';
+
+export default templateCompositeFrom({
+  annotation: `withContributionContext`,
+
+  outputs: [
+    '#contributionTarget',
+    '#contributionProperty',
+  ],
+
+  steps: () => [
+    {
+      dependencies: ['thing', 'thingProperty'],
+
+      compute: (continuation, {
+        ['thing']: thing,
+        ['thingProperty']: thingProperty,
+      }) => continuation({
+        ['#contributionTarget']:
+          thing.constructor[Symbol.for('Thing.referenceType')],
+
+        ['#contributionProperty']:
+          thingProperty,
+      }),
+    },
+  ],
+});