flowfuse icon indicating copy to clipboard operation
flowfuse copied to clipboard

SubFlow Version control

Open zackwasli opened this issue 1 year ago • 4 comments

Description

The idea here is for a sub-flow to function like a snapshot and act as a single source of truth.

If said sub-flow changes, then it could propagate to all instances that have said sub-flow.

This would be helpful in updating and maintaining similar instances that all reply upon the same sub-flow portion, but contain unique characteristics that can not be controlled for with snapshots and environment variables.

Which customers would this be available to

Enterprise Tier Only (EE)

Have you provided an initial effort estimate for this issue?

I have provided an initial effort estimate

zackwasli avatar Apr 01 '24 16:04 zackwasli

Crossover with https://github.com/FlowFuse/flowfuse/issues/3841

joepavitt avatar Aug 12 '24 15:08 joepavitt

And crossover with https://github.com/FlowFuse/flowfuse/issues/3230

joepavitt avatar Aug 12 '24 15:08 joepavitt

Now that we have support for a team-wide npm repository, the proposal here is to take advantage of the fact subflows can be packaged and distributed as npm modules.

The high level workflow would be:

  1. User develops subflow in Instance A.
  2. When they want to share it with other instances, they package and publish to the team node repository
  3. The module can then be installed into any other team instances via the palette manager
  4. If there is an update to distribute, the subflow is updated in Instance A, then an updated module published to the team repo
  5. The module can then be updated via the palette manager in other instances.

The technical guide for how the packaging works is available here.

Subflows already have a 'Module Properties' tab in their edit dialog that allows the user to enter much of the required info:

Image

From a UX point of view, the missing part is then the ability to publish to the team repository.

Proposal

  • Create a NR plugin that provides:
    • UI sidebar for managing subflow modules
      • List subflows, allow user to view/edit the module meta data
        • The existing form is free-form. We have strict requirements on module name when working with the team repo - need to validate and enforce in the sidebar UI
        • Have a 'publish' button to trigger npm publish on the backend

Open problem: npm credentials

Currently instances/devices are provisioned with individual npm read-only token that do not have permission to publish to the registry. But this work will require the instance to have access to a write token.

Write tokens are scoped to individual users; for RBAC and auditing.

One potential solution; create an api end point that generates a short-lived npm token for a user. This can be called by the plugin backend as part of the publish workflow. (This short-lived token should not replace any existing token the user has provisioned manually via the UI).

knolleary avatar Mar 14 '25 14:03 knolleary

For the UI Plugin for the Editor, do we want to consider a generalised "FlowFuse" plugin? We could extend that with creating snapshots, importing blueprints, etc. in the future? Rather than having scope for multiple tabs being added for each functionality?

joepavitt avatar Mar 14 '25 15:03 joepavitt

@knolleary Would it be possible for a user to export the JSON of a subflow and create a node with it, without us needing engineering time here?

gstout52 avatar May 09 '25 20:05 gstout52

Yes. That is all possible to do today, but is a manual, technical process. The proposed scope of this item is the UI work to automate it, making it easy to do in the context of a low code tool.

knolleary avatar May 09 '25 20:05 knolleary

Would it be possible for a user to export the JSON of a subflow and create a node with it, without us needing engineering time here?

The key here too is that if you import it, it just treats it like any imported flow, so has no tie-in the the "source". If a change is made to the subflow, it would be a manual process to have to go and update all the Instances that then used the subflow.

The proposal here is that the version control could be managed by publishing the subflow as a node to the Team's private NPM catalogue. By doing so, the source control is fully automated, and a user can update the subflow through the Node-RED palatte manager, without having to manually update flows.

joepavitt avatar May 12 '25 11:05 joepavitt

Thanks, both, for the clarification. I scheduled it for 2.19.

gstout52 avatar May 12 '25 12:05 gstout52

@gstout52 FYI - shifting into 2.21

joepavitt avatar Jul 30 '25 10:07 joepavitt

PoC done. now need to make it "safe" and report errors.

https://flowforgeworkspace.slack.com/archives/C04GW82DJFK/p1755186033671719

https://github.com/user-attachments/assets/06cafd30-63ce-469c-90fc-ed9c04227080

hardillb avatar Aug 14 '25 15:08 hardillb

While this is marked as Enterprise is it going to have it's own feature flag or be covered under the same flag as the Team NPM registry?

@gstout52 ^

hardillb avatar Aug 18 '25 17:08 hardillb

While this is marked as Enterprise is it going to have it's own feature flag or be covered under the same flag as the Team NPM registry?

Given the dependency of the subflow version control on the Team NPM Registry, I think having them share the same flag is fine for now I'd say.

joepavitt avatar Aug 19 '25 09:08 joepavitt

@hardillb any PRs for this at all? Draft or otherwise?

joepavitt avatar Aug 19 '25 09:08 joepavitt

@joepavitt

  • https://github.com/FlowFuse/nr-subflow-export
  • https://github.com/FlowFuse/nr-launcher/pull/375
  • https://github.com/FlowFuse/flowfuse/pull/5928

hardillb avatar Aug 19 '25 12:08 hardillb

Blocked waiting on UI work

hardillb avatar Aug 20 '25 08:08 hardillb

Image

@hardillb thoughts?

joepavitt avatar Aug 21 '25 14:08 joepavitt

PR opened as https://github.com/FlowFuse/nr-subflow-export/pull/1 for the UI work

joepavitt avatar Aug 21 '25 15:08 joepavitt

Outstanding items:

  • [x] Follow "new Repo" process for nr-subflow-export plugin (https://github.com/FlowFuse/admin/issues/428)
  • [x] Publish first release of nr-subflow-export plugin
  • [x] Add it to the nr-launcher dependencies (https://github.com/FlowFuse/nr-launcher/pull/375)
  • [x] Add it to the dev-env package so it is correctly linked (https://github.com/FlowFuse/dev-env/pull/39)
  • [x] Merge forge app pr (#5928)
  • [x] Merge nr-launcher pr (FlowFuse/nr-launcher#375)

hardillb avatar Aug 21 '25 15:08 hardillb

How's this one going, @hardillb ? On track for 2.21?

gstout52 avatar Aug 26 '25 15:08 gstout52

@gstout52 it's all done

hardillb avatar Aug 26 '25 15:08 hardillb

@hardillb if it's all done, why is the issue still open?

joepavitt avatar Aug 28 '25 08:08 joepavitt