n8n icon indicating copy to clipboard operation
n8n copied to clipboard

refactor: Use `NodeConnectionType` consistently across the code base (no-changelog)

Open RicardoE105 opened this issue 1 year ago • 1 comments

Summary

I was moving the NodeSettings.vue file https://github.com/n8n-io/n8n/pull/10545 to use the composition API and trying to fix one small type issue snowball into a lot of type issues because we have two types in the FE that represent the same. One is an enum, and the other is a type union that we use in the editor-ui, workflow, and nodes-base, and they do not match (a known problem with enums). So, to avoid this, I deleted the ConnectionType type and used the NodeConnectionType enum everywhere.

  • Uses NodeConnectionType consistently across the code base.
  • Deletes ConnectionType type.

ALL unit, integration and e2e tests pass.

Review / Merge checklist

  • [x] 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)

RicardoE105 avatar Aug 28 '24 17:08 RicardoE105

n8n    Run #6665

Run Properties:  status check passed Passed #6665  •  git commit 93a6afacd5: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 RicardoE105 🗃️ e2e/*
Project n8n
Branch Review refactor-types-NodeConnectionType
Run status status check passed Passed #6665
Run duration 04m 48s
Commit git commit 93a6afacd5: 🌳 🖥️ browsers:node18.12.0-chrome107 🤖 RicardoE105 🗃️ e2e/*
Committer Ricardo Espinoza
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 421
View all changes introduced in this branch ↗︎

cypress[bot] avatar Aug 28 '24 17:08 cypress[bot]

:white_check_mark: All Cypress E2E specs passed

github-actions[bot] avatar Aug 29 '24 13:08 github-actions[bot]

Got released with [email protected]

janober avatar Sep 05 '24 10:09 janober

eslint-plugin-n8n-nodes-base is not happy with NodeConnectionType.Main

30:3 error Replace with "['main']" [autofixable] n8n-nodes-base/node-class-description-outputs-wrong

if I put ['main'] then INodeTypeDescription yells at me.

I am not sure how the community node developers are keeping up with you guys. :(

anantanandgupta avatar Sep 12 '24 09:09 anantanandgupta

@Juneezee apologies for the harm this caused. Us not realizing this is a breaking change for the n8n-workflow package was an oversight from our end. To fix the errors you can use the NodeConnectionType enum from the n8n-workflow package and replace 'main' with NodeConnectionType.Main

tomi avatar Jan 07 '25 13:01 tomi

To fix the errors you can use the NodeConnectionType enum from the n8n-workflow package and replace 'main' with NodeConnectionType.Main

@tomi Thanks for your reply. This fixes the TypeScript error, but the ESLint error still remain. The ESLint rule from this plugin https://github.com/ivov/eslint-plugin-n8n-nodes-base needs to be updated. See

  1. https://github.com/ivov/eslint-plugin-n8n-nodes-base/issues/194
  2. https://github.com/ivov/eslint-plugin-n8n-nodes-base/issues/195

Juneezee avatar Jan 07 '25 13:01 Juneezee

i am still not able to figure out if i put input: [NodeConnectionType.Main] then linter yells at me and if i put input: ['main'], compiler yells at me. finally when i use input: '={{"main"}}' both are happy. i am not sure if this will work or break.

anantanandgupta avatar Feb 21 '25 04:02 anantanandgupta

To fix the errors you can use the NodeConnectionType enum from the n8n-workflow package and replace 'main' with NodeConnectionType.Main

@tomi that is indeed the fix, however, as @anantanandgupta pointed out (and I've suffered as well), the linter rules have not been updated to reflect these changes, and therefore the only option to build a custom node currently is to completely disable the linter.

gammons avatar Apr 19 '25 12:04 gammons