From aec2c402e298646d13cf249568b6c4b9e2241760 Mon Sep 17 00:00:00 2001 From: maas Date: Fri, 22 May 2020 09:42:16 +0200 Subject: [PATCH] Add support for complex data formats for Node-RED flow generator --- src/utility/generators/MsbClientGeneratorNodeRed.js | 6 ------ .../msb-client-websocket-nodered/msb-client-flow.json.raw | 6 ++++-- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/utility/generators/MsbClientGeneratorNodeRed.js b/src/utility/generators/MsbClientGeneratorNodeRed.js index 06aae2a..5929684 100644 --- a/src/utility/generators/MsbClientGeneratorNodeRed.js +++ b/src/utility/generators/MsbClientGeneratorNodeRed.js @@ -100,12 +100,6 @@ export default class MsbClientGeneratorNodeRed extends MsbClientGenerator { settings.msbObjectNodeId = uuidv4() settings.debugNodeId = uuidv4() - // TODO: Support complex objects in events an functions - // remove complex events - events = this.removeEventsOrFunctionsWithComplexObjects(events) - // remove complex functions - functions = this.removeEventsOrFunctionsWithComplexObjects(functions) - // TODO: Support no payload in events an functions // fix events with no payload events = this.fixDataFormatWithNoPayload(events) diff --git a/src/utility/templates/msb-client-websocket-nodered/msb-client-flow.json.raw b/src/utility/templates/msb-client-websocket-nodered/msb-client-flow.json.raw index acb1fe2..25b0c60 100644 --- a/src/utility/templates/msb-client-websocket-nodered/msb-client-flow.json.raw +++ b/src/utility/templates/msb-client-websocket-nodered/msb-client-flow.json.raw @@ -28,7 +28,8 @@ <%# TODO: Add support for complex objects -%> { "name": "<%= event.eventId -%>", - "dataTypeName": "<%- (event.dataFormat.dataObject.format ? event.dataFormat.dataObject.format : event.dataFormat.dataObject.type) -%>" + "dataTypeName": "<%- (event.dataFormat.dataObject.format ? event.dataFormat.dataObject.format : (event.dataFormat.dataObject.type ? event.dataFormat.dataObject.type : 'object')) -%>", + "schema": <%- ((!event.dataFormat.dataObject.type || event.dataFormat.dataObject.type === 'object') ? JSON.stringify(JSON.stringify(event.dataFormat)) : '""' ) %> }<%= (events[events.length-1].eventId != event.eventId) ? "," : "" %> <% }) -%> <% } -%> @@ -39,7 +40,8 @@ <%# TODO: Add support for complex objects -%> { "name": "<%= func.functionId -%>", - "dataTypeName": "<%- (func.dataFormat.dataObject.format ? func.dataFormat.dataObject.format : func.dataFormat.dataObject.type) -%>", + "dataTypeName": "<%- (func.dataFormat.dataObject.format ? func.dataFormat.dataObject.format : (func.dataFormat.dataObject.type ? func.dataFormat.dataObject.type : 'object')) -%>", + "schema": <%- ((!func.dataFormat.dataObject.type || func.dataFormat.dataObject.type === 'object') ? JSON.stringify(JSON.stringify(func.dataFormat)) : '""' ) -%>, "output": "<%= index + 1 -%>" }<%= (functions[functions.length-1].functionId != func.functionId) ? "," : "" %> <% }) -%>