Merge pull request #2022 from automatisch/use-objects-as-variables
feat(PowerInput): support whole objects as variables
This commit is contained in:
@@ -25,25 +25,40 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
|
|||||||
sampleValue: JSON.stringify(sampleValue),
|
sampleValue: JSON.stringify(sampleValue),
|
||||||
};
|
};
|
||||||
|
|
||||||
const arrayItems = sampleValue.flatMap((item, index) =>
|
const arrayItems = sampleValue.flatMap((item, index) => {
|
||||||
process({
|
const itemItself = {
|
||||||
|
label: `${label}.${index}`,
|
||||||
|
value: `${value}.${index}`,
|
||||||
|
sampleValue: JSON.stringify(item),
|
||||||
|
};
|
||||||
|
|
||||||
|
const itemEntries = process({
|
||||||
data: item,
|
data: item,
|
||||||
parentKey: value,
|
parentKey: value,
|
||||||
index,
|
index,
|
||||||
parentLabel: label,
|
parentLabel: label,
|
||||||
}),
|
});
|
||||||
);
|
|
||||||
|
|
||||||
// TODO: remove spreading
|
return [itemItself].concat(itemEntries);
|
||||||
return [arrayItself, ...arrayItems];
|
});
|
||||||
|
|
||||||
|
return [arrayItself].concat(arrayItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof sampleValue === 'object' && sampleValue !== null) {
|
if (typeof sampleValue === 'object' && sampleValue !== null) {
|
||||||
return process({
|
const objectItself = {
|
||||||
|
label,
|
||||||
|
value,
|
||||||
|
sampleValue: JSON.stringify(sampleValue),
|
||||||
|
};
|
||||||
|
|
||||||
|
const objectEntries = process({
|
||||||
data: sampleValue,
|
data: sampleValue,
|
||||||
parentKey: value,
|
parentKey: value,
|
||||||
parentLabel: label,
|
parentLabel: label,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return [objectItself].concat(objectEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
Reference in New Issue
Block a user