Quick add multiple nodes (like a macro to add a set of nodes) #72
Replies: 3 comments 4 replies
-
JSON format (proposal)JSON schema{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Node-RED Macro",
"description": "A flow macro for Node-RED",
"type": "array",
"items": {
"type": "object",
"required": ["nodes"],
"properties": {
"label": { "type": "string" },
"color": { "type": ["string", "integer"] },
"nodes": {
"type": "array", "required": [], "minItems": 1,
"items": { "type": "string", "minLength": 1 }
},
"links": {
"type": "array",
"items": {
"type": "object",
"required": [ "source", "target"],
"properties": {
"source": { "type": "integer", "minimum": 0 },
"target": { "type": "integer", "minimum": 0 }
}
}
},
"wires": {
"type": "array",
"items": {
"type": "object",
"required": ["source","sourcePort","target"],
"properties": {
"source": { "type": "integer", "minimum": 0 },
"sourcePort": { "type": "integer", "minimum": 0 },
"target": { "type": "integer", "minimum": 0 }
}
}
},
"properties": {
"type": "array",
"items": {
"type": "object",
"required": ["node","property","value"],
"properties": {
"node": { "type": "integer", "minimum": 0 },
"property": { "type": "string" },
"value": { }
}
}
}
}
}
} SamplesSample 1[
{
"label": "inject → function → debug",
"nodes": [ "inject", "function", "debug" ],
"wires": [
{ "source": 0, "sourcePort": 0, "target": 1 },
{ "source": 1, "sourcePort": 0, "target": 2 }
],
"properties": [
{ "node": 0, "property": "name", "value": "my inject" },
{ "node": 1, "property": "name", "value": "edit me" },
{ "node": 2, "property": "name", "value": "result" }
]
}
] Result 1Sample 2[
{
"label": "link call → link in → link return",
"nodes": [ "link call", "link in", "link out" ],
"links": [
{ "source": 0, "target": 1 }
],
"wires": [
{ "source": 1, "sourcePort": 0, "target": 2 }
],
"properties": [
{"node": 2, "property": "mode", "value": "return"}
]
}
] Result 2Sample 3[
{
"label": "Create http endpoint",
"icon": "font-awesome/fa-wifi",
"color": "#32a852",
"nodes": [ "http in", "function", "http response" ],
"wires": [
{ "source": 0, "sourcePort": 0, "target": 1 },
{ "source": 1, "sourcePort": 0, "target": 2 }
],
"properties": [
{"node": 0, "property":"url", "value": "/endpoint"},
{"node": 0, "property":"name", "value": "endpoint"},
{"node": 1, "property":"name", "value": "edit me"},
{"node": 2, "property":"name", "value": "set my headers"}
]
}
] Result 3Validated here: https://www.jsonschemavalidator.net/ |
Beta Was this translation helpful? Give feedback.
-
Devils advocate here.... as these look like tiny flows... should not the flow part of the schema be the existing flow format ? ie an array - and then wrap that into an object that holds the other metadata you need ... That may make "composing" macros easier in the future ? |
Beta Was this translation helpful? Give feedback.
-
"adding an additional meta-data property to each node".... could this be achieved by (ahem) letting groups have metadata... and using the group feature to define a macro ? :-) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Carrying on from here: https://discourse.nodered.org/t/fr-quick-add-multiple-nodes-ready-linked/52439/7
A means of adding common/related sets of nodes
demo
Proposal (open to re-definition)
Stretch features
{node: x, changeable: { type: "string", "label": "Enter a name for the debug node", default: "Debug #"} }
Beta Was this translation helpful? Give feedback.
All reactions