Skip to content

Commit 91fb34c

Browse files
committed
composite: expose used default{Dependency,Value} at instantiate
There used to be a cool description here, but then vim ate it.
1 parent d669d0e commit 91fb34c

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

src/data/composite.js

+21-20
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,27 @@ export function templateCompositeFrom(description) {
342342
}
343343
});
344344

345-
const inputMetadata = getStaticInputMetadata(inputOptions);
345+
const inputMapping = {};
346+
if ('inputs' in description) {
347+
for (const [name, token] of Object.entries(description.inputs)) {
348+
const tokenValue = getInputTokenValue(token);
349+
if (name in inputOptions) {
350+
if (typeof inputOptions[name] === 'string') {
351+
inputMapping[name] = input.dependency(inputOptions[name]);
352+
} else {
353+
inputMapping[name] = inputOptions[name];
354+
}
355+
} else if (tokenValue.defaultValue) {
356+
inputMapping[name] = input.value(tokenValue.defaultValue);
357+
} else if (tokenValue.defaultDependency) {
358+
inputMapping[name] = input.dependency(tokenValue.defaultDependency);
359+
} else {
360+
inputMapping[name] = input.value(null);
361+
}
362+
}
363+
}
364+
365+
const inputMetadata = getStaticInputMetadata(inputMapping);
346366

347367
const expectedOutputNames =
348368
(Array.isArray(description.outputs)
@@ -414,25 +434,6 @@ export function templateCompositeFrom(description) {
414434
}
415435

416436
if ('inputs' in description) {
417-
const inputMapping = {};
418-
419-
for (const [name, token] of Object.entries(description.inputs)) {
420-
const tokenValue = getInputTokenValue(token);
421-
if (name in inputOptions) {
422-
if (typeof inputOptions[name] === 'string') {
423-
inputMapping[name] = input.dependency(inputOptions[name]);
424-
} else {
425-
inputMapping[name] = inputOptions[name];
426-
}
427-
} else if (tokenValue.defaultValue) {
428-
inputMapping[name] = input.value(tokenValue.defaultValue);
429-
} else if (tokenValue.defaultDependency) {
430-
inputMapping[name] = input.dependency(tokenValue.defaultDependency);
431-
} else {
432-
inputMapping[name] = input.value(null);
433-
}
434-
}
435-
436437
finalDescription.inputMapping = inputMapping;
437438
finalDescription.inputDescriptions = description.inputs;
438439
}

src/data/composite/control-flow/raiseOutputWithoutDependency.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default templateCompositeFrom({
1717

1818
outputs: ({
1919
[input.staticValue('output')]: output,
20-
}) => Object.keys(output ?? {}),
20+
}) => Object.keys(output),
2121

2222
steps: () => [
2323
withResultOfAvailabilityCheck({

src/data/composite/control-flow/raiseOutputWithoutUpdateValue.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default templateCompositeFrom({
1616

1717
outputs: ({
1818
[input.staticValue('output')]: output,
19-
}) => Object.keys(output ?? {}),
19+
}) => Object.keys(output),
2020

2121
steps: () => [
2222
withResultOfAvailabilityCheck({

0 commit comments

Comments
 (0)