-
Notifications
You must be signed in to change notification settings - Fork 52.4k
chore(ai-builder): Adding a script to convert workflow JSON to a mermaid chart #23214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this 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 === 'string' ? workflow.name : basename(filePath, '.json')` 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
packages/@n8n/ai-workflow-builder.ee/scripts/workflow-to-mermaid.ts
Outdated
Show resolved
Hide resolved
packages/@n8n/ai-workflow-builder.ee/scripts/workflow-to-mermaid.ts
Outdated
Show resolved
Hide resolved
packages/@n8n/ai-workflow-builder.ee/scripts/workflow-to-mermaid.ts
Outdated
Show resolved
Hide resolved
This comment has been minimized.
This comment has been minimized.
|
E2E Tests: n8n tests passed after 7m 17.5s Run Details
Groups
This message was posted automatically by
currents.dev | Integration Settings
|
|
Got released with |
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:
This will generate a markdown file beside it, in this case called
workflow.mdwhich 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
release/backport(if the PR is an urgent fix that needs to be backported)