diff options
Diffstat (limited to 'src/data/composite')
-rw-r--r-- | src/data/composite/wiki-data/index.js | 1 | ||||
-rw-r--r-- | src/data/composite/wiki-data/inputThingClass.js | 23 | ||||
-rw-r--r-- | src/data/composite/wiki-properties/referenceList.js | 20 | ||||
-rw-r--r-- | src/data/composite/wiki-properties/singleReference.js | 21 | ||||
-rw-r--r-- | src/data/composite/wiki-properties/wikiData.js | 20 |
5 files changed, 28 insertions, 57 deletions
diff --git a/src/data/composite/wiki-data/index.js b/src/data/composite/wiki-data/index.js index d64930e1..3ccfa75d 100644 --- a/src/data/composite/wiki-data/index.js +++ b/src/data/composite/wiki-data/index.js @@ -5,7 +5,6 @@ // export {default as exitWithoutContribs} from './exitWithoutContribs.js'; -export {default as inputThingClass} from './inputThingClass.js'; export {default as inputWikiData} from './inputWikiData.js'; export {default as withParsedCommentaryEntries} from './withParsedCommentaryEntries.js'; export {default as withResolvedContribs} from './withResolvedContribs.js'; diff --git a/src/data/composite/wiki-data/inputThingClass.js b/src/data/composite/wiki-data/inputThingClass.js deleted file mode 100644 index 5f2ca5a6..00000000 --- a/src/data/composite/wiki-data/inputThingClass.js +++ /dev/null @@ -1,23 +0,0 @@ -// Please note that this input, used in a variety of #composite/wiki-data -// utilities, is basically always a kludge. Any usage of it depends on -// referencing Thing class values defined outside of the #composite folder. - -import {input} from '#composite'; -import {isFunction} from '#validators'; - -// TODO: Kludge. -import Thing from '../../things/thing.js'; - -export default function inputThingClass() { - return input.staticValue({ - validate(thingClass) { - isFunction(thingClass); - - if (!Object.hasOwn(thingClass, Thing.referenceType)) { - throw new TypeError(`Expected a Thing constructor, missing Thing.referenceType`); - } - - return true; - }, - }); -} diff --git a/src/data/composite/wiki-properties/referenceList.js b/src/data/composite/wiki-properties/referenceList.js index f5b6c58e..af634a68 100644 --- a/src/data/composite/wiki-properties/referenceList.js +++ b/src/data/composite/wiki-properties/referenceList.js @@ -7,14 +7,10 @@ // import {input, templateCompositeFrom} from '#composite'; -import {validateReferenceList} from '#validators'; +import {isThingClass, validateReferenceList} from '#validators'; import {exposeDependency} from '#composite/control-flow'; -import {inputThingClass, inputWikiData, withResolvedReferenceList} - from '#composite/wiki-data'; - -// TODO: Kludge. -import Thing from '../../things/thing.js'; +import {inputWikiData, withResolvedReferenceList} from '#composite/wiki-data'; export default templateCompositeFrom({ annotation: `referenceList`, @@ -22,18 +18,20 @@ export default templateCompositeFrom({ compose: false, inputs: { - class: inputThingClass(), + class: input.staticValue({validate: isThingClass}), data: inputWikiData({allowMixedTypes: false}), + find: input({type: 'function'}), }, update: ({ [input.staticValue('class')]: thingClass, - }) => { - const {[Thing.referenceType]: referenceType} = thingClass; - return {validate: validateReferenceList(referenceType)}; - }, + }) => ({ + validate: + validateReferenceList( + thingClass[Symbol.for('Thing.referenceType')]), + }), steps: () => [ withResolvedReferenceList({ diff --git a/src/data/composite/wiki-properties/singleReference.js b/src/data/composite/wiki-properties/singleReference.js index 34bd2e6d..db4fc9f9 100644 --- a/src/data/composite/wiki-properties/singleReference.js +++ b/src/data/composite/wiki-properties/singleReference.js @@ -8,14 +8,10 @@ // import {input, templateCompositeFrom} from '#composite'; -import {validateReference} from '#validators'; +import {isThingClass, validateReference} from '#validators'; import {exposeDependency} from '#composite/control-flow'; -import {inputThingClass, inputWikiData, withResolvedReference} - from '#composite/wiki-data'; - -// TODO: Kludge. -import Thing from '../../things/thing.js'; +import {inputWikiData, withResolvedReference} from '#composite/wiki-data'; export default templateCompositeFrom({ annotation: `singleReference`, @@ -23,17 +19,20 @@ export default templateCompositeFrom({ compose: false, inputs: { - class: inputThingClass(), + class: input.staticValue({validate: isThingClass}), + find: input({type: 'function'}), + data: inputWikiData({allowMixedTypes: false}), }, update: ({ [input.staticValue('class')]: thingClass, - }) => { - const {[Thing.referenceType]: referenceType} = thingClass; - return {validate: validateReference(referenceType)}; - }, + }) => ({ + validate: + validateReference( + thingClass[Symbol.for('Thing.referenceType')]), + }), steps: () => [ withResolvedReference({ diff --git a/src/data/composite/wiki-properties/wikiData.js b/src/data/composite/wiki-properties/wikiData.js index 5cea49a0..3bebed33 100644 --- a/src/data/composite/wiki-properties/wikiData.js +++ b/src/data/composite/wiki-properties/wikiData.js @@ -2,12 +2,7 @@ // trackData, etc. import {input, templateCompositeFrom} from '#composite'; -import {validateWikiData} from '#validators'; - -import {inputThingClass} from '#composite/wiki-data'; - -// TODO: Kludge. -import Thing from '../../things/thing.js'; +import {isThingClass, validateWikiData} from '#validators'; export default templateCompositeFrom({ annotation: `wikiData`, @@ -15,15 +10,18 @@ export default templateCompositeFrom({ compose: false, inputs: { - class: inputThingClass(), + class: input.staticValue({validate: isThingClass}), }, update: ({ [input.staticValue('class')]: thingClass, - }) => { - const referenceType = thingClass[Thing.referenceType]; - return {validate: validateWikiData({referenceType})}; - }, + }) => ({ + validate: + validateWikiData({ + referenceType: + thingClass[Symbol.for('Thing.referenceType')], + }), + }), steps: () => [], }); |