Skip to content

Commit c06233c

Browse files
committed
composite: simplify getStaticInputMetadata
Since it always operates on inputMapping, we can make more assumptions about shape. (All input names are always provided i.e. non-null, and they are always present as input tokens.)
1 parent 91fb34c commit c06233c

File tree

1 file changed

+16
-22
lines changed

1 file changed

+16
-22
lines changed

src/data/composite.js

+16-22
Original file line numberDiff line numberDiff line change
@@ -72,30 +72,22 @@ function getInputTokenValue(token) {
7272
}
7373
}
7474

75-
function getStaticInputMetadata(inputOptions) {
75+
function getStaticInputMetadata(inputMapping) {
7676
const metadata = {};
7777

78-
for (const [name, token] of Object.entries(inputOptions)) {
79-
if (typeof token === 'string') {
80-
metadata[input.staticDependency(name)] = token;
81-
metadata[input.staticValue(name)] = null;
82-
} else if (isInputToken(token)) {
83-
const tokenShape = getInputTokenShape(token);
84-
const tokenValue = getInputTokenValue(token);
85-
86-
metadata[input.staticDependency(name)] =
87-
(tokenShape === 'input.dependency'
88-
? tokenValue
89-
: null);
90-
91-
metadata[input.staticValue(name)] =
92-
(tokenShape === 'input.value'
93-
? tokenValue
94-
: null);
95-
} else {
96-
metadata[input.staticDependency(name)] = null;
97-
metadata[input.staticValue(name)] = null;
98-
}
78+
for (const [name, token] of Object.entries(inputMapping)) {
79+
const tokenShape = getInputTokenShape(token);
80+
const tokenValue = getInputTokenValue(token);
81+
82+
metadata[input.staticDependency(name)] =
83+
(tokenShape === 'input.dependency'
84+
? tokenValue
85+
: null);
86+
87+
metadata[input.staticValue(name)] =
88+
(tokenShape === 'input.value'
89+
? tokenValue
90+
: null);
9991
}
10092

10193
return metadata;
@@ -350,6 +342,8 @@ export function templateCompositeFrom(description) {
350342
if (typeof inputOptions[name] === 'string') {
351343
inputMapping[name] = input.dependency(inputOptions[name]);
352344
} else {
345+
// This is always an input token, since only a string or
346+
// an input token is a valid input option (asserted above).
353347
inputMapping[name] = inputOptions[name];
354348
}
355349
} else if (tokenValue.defaultValue) {

0 commit comments

Comments
 (0)