Skip to content

Conversation

@mike12345567
Copy link
Contributor

Summary

Adds a script that can be ran from the ai-workflow-builder.ee package to generate mermaid charts for workflow JSON. Simply provide a downloaded workflow JSON file to the script as such:

pnpm workflow:mermaid workflow.json

This will generate a markdown file beside it, in this case called workflow.md which contains the mermaid representation.

By default the script generates mermaid in the same way we use it for templates, with the node names and node types in a comment. You can also add the node parameters with the option --node-params.

Review / Merge checklist

  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with release/backport (if the PR is an urgent fix that needs to be backported)

@mike12345567 mike12345567 self-assigned this Dec 15, 2025
@mike12345567 mike12345567 requested review from a team and mutdmour and removed request for a team December 15, 2025 09:50
@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 issues found across 2 files

Prompt for AI agents (all 3 issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/@n8n/ai-workflow-builder.ee/scripts/workflow-to-mermaid.ts">

<violation number="1" location="packages/@n8n/ai-workflow-builder.ee/scripts/workflow-to-mermaid.ts:113">
P2: Rule violated: **Prefer Typeguards over Type casting**

Type assertion used for narrowing. Consider using a type guard function to validate the `nodes` property structure instead of `as` casting. This pattern could hide runtime type mismatches.</violation>

<violation number="2" location="packages/@n8n/ai-workflow-builder.ee/scripts/workflow-to-mermaid.ts:118">
P2: Rule violated: **Prefer Typeguards over Type casting**

Type assertion used for narrowing. After the `typeof` check, TypeScript already knows `json.workflow` is `object`. Consider using a dedicated type guard or validation function to properly narrow to the expected workflow shape.</violation>

<violation number="3" location="packages/@n8n/ai-workflow-builder.ee/scripts/workflow-to-mermaid.ts:120">
P2: Rule violated: **Prefer Typeguards over Type casting**

Type assertion `as string` used for narrowing. Consider using `typeof workflow.name === &#39;string&#39; ? workflow.name : basename(filePath, &#39;.json&#39;)` instead, which provides proper runtime type safety.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

@blacksmith-sh

This comment has been minimized.

@n8n-assistant n8n-assistant bot added the n8n team Authored by the n8n team label Dec 15, 2025
@currents-bot
Copy link

currents-bot bot commented Dec 15, 2025

E2E Tests: n8n tests passed after 7m 17.5s

🟢 583 · 🔴 0 · ⚪️ 27 · 🟣 2

View Run Details

Run Details

  • Project: n8n

  • Groups: 2

  • Framework: Playwright

  • Run Status: Passed

  • Commit: a39f0f6

  • Spec files: 130

  • Overall tests: 610

  • Duration: 7m 17.5s

  • Parallelization: 9

Groups

GroupId Results Spec Files Progress
multi-main:ui 🟢 526 · 🔴 0 · ⚪️ 27 · 🟣 2 121 / 121
multi-main:ui:isolated 🟢 57 · 🔴 0 · ⚪️ 0 9 / 9


This message was posted automatically by currents.dev | Integration Settings

@mike12345567 mike12345567 merged commit 31cc49e into master Dec 15, 2025
27 checks passed
@mike12345567 mike12345567 deleted the ai-script-convert-to-mermaid branch December 15, 2025 14:33
@n8n-assistant
Copy link

n8n-assistant bot commented Dec 15, 2025

Got released with n8n@[email protected]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

n8n team Authored by the n8n team Released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants