Subflow Templates

A subflow template is a type of subflow that has predetermined inputs, outputs, and maybe env variables too, defined as JSON Schemas, but has no implementation. The implementation is done by the developer who is going to use that subflow

Use case:

I have a flow that the main flow must follow this pattern

Node A -> Subflow B(1) -> Subflow B(2) ->... Subflow B(3) -> Node C

Subflows B are templates that I created and I need developers to implement them. The outputs and inputs of these subflows can't be changed by the developer. The developer must ensure the inputs and outputs conform to the described template pattern. At runtime Subflow Templates will throw exception if the input or output data doesn't comply with its specs.

Another use case is that it would be possible to create examples with subflow templates, and share those with my library of nodes.

When clicking on the deploy buttonn, a verification will run to validate if there are subflows templates with missing implementations.

Possible feature for the future:
When/if node-red is rewritten in typescript, we could define subflow templates outputs and inputs with interfaces and types, and validate them at compile time. With ts the subflow template wrapper/node would accept generics for inputs and outputs. In the UI/Editor there would exist 2 new configs in the form where the author of the subflow can specify the Interface/Type for inputs and outputs.

Never, there's a lot of work for an uncertain benefit. The typing I'm writing will already help.

I'm having trouble understanding your request :thinking:

1 Like

Agree there. I've just created my first proper typings - but not because I wrote them, I can barely read the horrid things. Nope, GitHub Copilot using Claude Sonnet 4 did it for me! :smiley:

JSDoc provides even more help, especially with VS Code. Many standard typings (e.g. HTML API's) are so broken, I often end up turning off TS checks.

Never mind. I found a way to do this