|
|
@ -36,12 +36,32 @@ module.exports = {
|
|
|
|
let result = await script();
|
|
|
|
let result = await script();
|
|
|
|
let message = {};
|
|
|
|
let message = {};
|
|
|
|
entity.output.forEach((out, index) => {
|
|
|
|
entity.output.forEach((out, index) => {
|
|
|
|
message[out.name] = result[index];
|
|
|
|
if (out.type.name == "list")
|
|
|
|
|
|
|
|
message[out.name] = arrayFromLiteral(result[index]);
|
|
|
|
|
|
|
|
else message[out.name] = result[index];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return message;
|
|
|
|
return message;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: default error message
|
|
|
|
return entity;
|
|
|
|
return entity;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// happy with it? totally not. but for now oke
|
|
|
|
|
|
|
|
// https://stackoverflow.com/questions/48676751/convert-javascript-string-to-literal-array
|
|
|
|
|
|
|
|
function arrayFromLiteral(literal) {
|
|
|
|
|
|
|
|
return literal
|
|
|
|
|
|
|
|
.replace(/^\[|\]$/g, "") // Remove leading and ending square brackets ([]).
|
|
|
|
|
|
|
|
.split(",") // Split by comma.
|
|
|
|
|
|
|
|
.map(
|
|
|
|
|
|
|
|
(
|
|
|
|
|
|
|
|
phrase // Iterate over each phrase.
|
|
|
|
|
|
|
|
) =>
|
|
|
|
|
|
|
|
phrase
|
|
|
|
|
|
|
|
.trim() // Remove leading and ending whitespace.
|
|
|
|
|
|
|
|
.replace(/"/g, "") // Remove all double quotes (").
|
|
|
|
|
|
|
|
.replace(/^\'|\'$/g, "") // Remove leading and ending single quotes (').
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
}
|
|
|
|