From 91fb34c3ec48483d6f451ff74b266799ce0e5e42 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 25 Jul 2024 16:31:15 -0300 Subject: composite: expose used default{Dependency,Value} at instantiate There used to be a cool description here, but then vim ate it. --- src/data/composite.js | 41 +++++++++++----------- .../control-flow/raiseOutputWithoutDependency.js | 2 +- .../control-flow/raiseOutputWithoutUpdateValue.js | 2 +- 3 files changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/data/composite.js b/src/data/composite.js index ea7a3480..5af1becf 100644 --- a/src/data/composite.js +++ b/src/data/composite.js @@ -342,7 +342,27 @@ export function templateCompositeFrom(description) { } }); - const inputMetadata = getStaticInputMetadata(inputOptions); + const inputMapping = {}; + if ('inputs' in description) { + for (const [name, token] of Object.entries(description.inputs)) { + const tokenValue = getInputTokenValue(token); + if (name in inputOptions) { + if (typeof inputOptions[name] === 'string') { + inputMapping[name] = input.dependency(inputOptions[name]); + } else { + inputMapping[name] = inputOptions[name]; + } + } else if (tokenValue.defaultValue) { + inputMapping[name] = input.value(tokenValue.defaultValue); + } else if (tokenValue.defaultDependency) { + inputMapping[name] = input.dependency(tokenValue.defaultDependency); + } else { + inputMapping[name] = input.value(null); + } + } + } + + const inputMetadata = getStaticInputMetadata(inputMapping); const expectedOutputNames = (Array.isArray(description.outputs) @@ -414,25 +434,6 @@ export function templateCompositeFrom(description) { } if ('inputs' in description) { - const inputMapping = {}; - - for (const [name, token] of Object.entries(description.inputs)) { - const tokenValue = getInputTokenValue(token); - if (name in inputOptions) { - if (typeof inputOptions[name] === 'string') { - inputMapping[name] = input.dependency(inputOptions[name]); - } else { - inputMapping[name] = inputOptions[name]; - } - } else if (tokenValue.defaultValue) { - inputMapping[name] = input.value(tokenValue.defaultValue); - } else if (tokenValue.defaultDependency) { - inputMapping[name] = input.dependency(tokenValue.defaultDependency); - } else { - inputMapping[name] = input.value(null); - } - } - finalDescription.inputMapping = inputMapping; finalDescription.inputDescriptions = description.inputs; } diff --git a/src/data/composite/control-flow/raiseOutputWithoutDependency.js b/src/data/composite/control-flow/raiseOutputWithoutDependency.js index 3d04f8a9..03d8036a 100644 --- a/src/data/composite/control-flow/raiseOutputWithoutDependency.js +++ b/src/data/composite/control-flow/raiseOutputWithoutDependency.js @@ -17,7 +17,7 @@ export default templateCompositeFrom({ outputs: ({ [input.staticValue('output')]: output, - }) => Object.keys(output ?? {}), + }) => Object.keys(output), steps: () => [ withResultOfAvailabilityCheck({ diff --git a/src/data/composite/control-flow/raiseOutputWithoutUpdateValue.js b/src/data/composite/control-flow/raiseOutputWithoutUpdateValue.js index ffa83a94..3c39f5ba 100644 --- a/src/data/composite/control-flow/raiseOutputWithoutUpdateValue.js +++ b/src/data/composite/control-flow/raiseOutputWithoutUpdateValue.js @@ -16,7 +16,7 @@ export default templateCompositeFrom({ outputs: ({ [input.staticValue('output')]: output, - }) => Object.keys(output ?? {}), + }) => Object.keys(output), steps: () => [ withResultOfAvailabilityCheck({ -- cgit 1.3.0-6-gf8a5