feat: support arrays in flows

This commit is contained in:
Ali BARIN
2024-07-29 11:33:36 +00:00
parent 02a872a376
commit 920a711c00
2 changed files with 33 additions and 7 deletions

View File

@@ -19,7 +19,13 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
const value = joinBy('.', parentKey, index?.toString(), name);
if (Array.isArray(sampleValue)) {
return sampleValue.flatMap((item, index) =>
const arrayItself = {
label,
value,
sampleValue: JSON.stringify(sampleValue),
};
const arrayItems = sampleValue.flatMap((item, index) =>
process({
data: item,
parentKey: value,
@@ -27,6 +33,9 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
parentLabel: label,
}),
);
// TODO: remove spreading
return [arrayItself, ...arrayItems];
}
if (typeof sampleValue === 'object' && sampleValue !== null) {
@@ -36,6 +45,7 @@ const process = ({ data, parentKey, index, parentLabel = '' }) => {
parentLabel: label,
});
}
return [
{
label,