This commit is contained in:
Deborah Barnard 2022-06-09 08:31:55 +01:00
parent 3b31a6dd2b
commit 0e67c296f1
5 changed files with 51 additions and 38 deletions

View File

@ -1,5 +1,7 @@
# Creating n8n-nodes-module
[TODO: this is the most up to date method, use it]
In this guide, you'll learn to create a custom n8n-nodes-module that can be installed separately alongside your n8n instance. The n8n-nodes-module is an npm package that contains the node. Your custom node will get loaded automatically when n8n starts.
Consider creating n8n-nodes-module if any of the following conditions satisfy your needs:

View File

@ -1,5 +1,7 @@
# Creating Your First Node
[TODO: delete most of this, the n8n-nodes-module doc is more up to date]
Today, you will learn how to create your first node for n8n.
## Prerequisites

View File

@ -1,60 +1,56 @@
# Node Review Checklist
# Node review checklist
If you want to create a new node for a service - that's great, thank you! We recommend you take a look at the [existing nodes](https://github.com/n8n-io/n8n/tree/master/packages/nodes-base/nodes) to get an idea of how your code should look and work like.
There are several things to keep in mind when creating the node. To help you, we prepared a checklist that covers the requirements for creating nodes, from preparation to submission.
Make sure you tick the boxes below before submitting a node for review, as this will help our team review your PR easier and faster.
This checklist helps you build a node that meets the standards for submission to the community nodes collection. It also helps ensure that nodes are consistent and good quality.
## Preparation
<input type="checkbox"> Set up your editor for code formatting (indentation, new lines, linting). If you use Visual Studio Code, you can use the <a href="https://marketplace.visualstudio.com/items?itemName=ms-vscode.vscode-typescript-tslint-plugin">TSLint extension</a> for linting.</input> <br>
<input type="checkbox"> Get credentials (e.g., Client ID, Client Secret, API key, user login, user password, website URL) for the service you are building a node for.</input>
<input type="checkbox"> Get credentials (for example, Client ID, Client Secret, API key, user login, user password, website URL) for the service you are building a node for.</input>
## Development
<input type="checkbox"> Open a pull request as early as possible with `WIP` in the pull request title.</input><br>
<input type="checkbox"> If you are creating a node requested by a community member, make sure to comment on the feature request in the [community forum](https://community.n8n.io/c/feature-requests/5).</input><br>
<input type="checkbox"> Ensure complementary operations to each resource (e.g., create, delete) have been added.</input><br>
<input type="checkbox"> Ensure the node works with multiple items via one input.</input><br>
<input type="checkbox"> If you're' creating a node requested by a community member, make sure to comment on the feature request in the [community forum](https://community.n8n.io/c/feature-requests/5).</input><br>
<input type="checkbox"> Add complementary operations to each resource (for example, create, delete)</input><br>
<input type="checkbox"> Check the node works with more than one item using one input.</input><br> [TODO: what does this mean?]
<input type="checkbox"> Ensure the parameters have the correct type.</input><br>
<input type="checkbox"> Mind the defaults: if the service has a default as true, keep it as true. Changing default values can break the existing workflows of the users.</input><br>
<input type="checkbox"> Check if the node disposes of everything properly, in particular, if connections were properly closed.</input><br>
<input type="checkbox"> Check your code using <a href="https://docs.n8n.io/nodes/creating-nodes/nodelinter.html">Nodelinter</a> to ensure a clean lint <strong>before</strong> submitting your pull request</input><br>
<input type="checkbox"> Check if the node disposes of everything. In particular, the node has closed all connections.</input><br>
<input type="checkbox"> Check your code using <a href="https://docs.n8n.io/nodes/creating-nodes/nodelinter.html">Node linter</a>.</input><br>
## Testing
<input type="checkbox"> Test "create" and "update" operations with all fields/operations.</input><br>
<input type="checkbox"> Test the `continueOnFail` option with a Function node. (For example, a Widget node has a GET operation that takes a widgetId and returns information on the widget. To test that the workflow continues on fail, set the Widget node to continue on fail, create a Function node, return a valid and an invalid widgetId, connect the Function node to Widget node, and run the workflow. The Widget node should show two items: one with information on the widget and another one with the error from having passed an invalid ID.)</input><br>
<input type="checkbox"> Test the `continueOnFail` option with a Function node. For example, a Widget node has a GET operation that takes a widgetId and returns information on the widget. To test that the workflow continues on fail, set the Widget node to continue on fail, create a Function node, return a valid and an invalid widgetId, connect the Function node to Widget node, and run the workflow. The Widget node should show two items: one with information on the widget and another one with the error from having passed an invalid ID.)</input><br>
## Code formatting
<input type="checkbox"> Ensure the branch lints cleanly by running `npm run lint`.</input><br>
<input type="checkbox"> Ensure the indentation is correct. Check this in the editorconfig.</input><br>
<input type="checkbox"> Ensure there are no extra spaces. Check this in the editorconfig.</input><br>
<input type="checkbox"> Ensure the indentation is correct. Check this in the editor configuration.</input><br>
<input type="checkbox"> Ensure there are no extra spaces. Check this in the editor configuration.</input><br>
<input type="checkbox"> Code comment dividers inside if-branches.</input><br>
<input type="checkbox"> Use "create/delete" verbs for operations, except for tags, where you should use "add/remove".</input><br>
## Errors and Outputs
<input type="checkbox"> Ensure empty API responses return `{ success: true }`.</input><br>
<input type="checkbox"> Ensure the error responses are handled and displayed correctly (e.g., malformed requests, requests with invalid credentials) and use the current format. You can check this by making failing requests to the API.</input><br>
<input type="checkbox"> Check if the response can be simplified and add a simplify function (e.g., <a href="https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts">SecurityScorecard node</a>).</input><br>
<input type="checkbox"> Ensure the node handles and displays error responses correctly (for example, malformed requests, requests with invalid credentials) and use the current format. You can check this by making failing requests to the API.</input><br>
<input type="checkbox"> Check if the response can be simplified and add a simplify function (for example, <a href="https://github.com/n8n-io/n8n/blob/master/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts">SecurityScorecard node</a>).</input><br>
<input type="checkbox"> Ensure the response from `Create` is consistent with `Get`.</input><br>
<input type="checkbox"> Ensure the response from `Get All` is consistent with `Get`.</input><br>
## Presentation
<input type="checkbox"> Ensure the primary menu contains only required parameters.</input><br>
<input type="checkbox"> Ensure a JSON object is not shown in a single column in Table view.</input><br>
<input type="checkbox"> The primary menu should only contain required parameters.</input><br>
<input type="checkbox"> Ensure a JSON object isn't shown in a single column in Table view.</input><br>
<input type="checkbox"> Make sure all GetAll operations have the fields `return` and `limit`.</input><br>
<input type="checkbox"> Ensure the property subtitle is set.</input><br>
<input type="checkbox"> Set the property subtitle.</input><br>
<input type="checkbox"> Make sure the pagination (if any) is working correctly. Set Limit 1.</input><br>
## Writing
<input type="checkbox"> Ensure all descriptions are correct and end with a period.</input><br>
<input type="checkbox"> Ensure that most descriptions exist, excluding redundant ones.</input><br>
<input type="checkbox"> Ensure IDs in displayNames are capitalized (i.e.: "IDs", not "ids" or "Ids").</input><br>
<input type="checkbox"> Ensure IDs in displayNames are capitalized (for example: "IDs" not "ids" or "Ids").</input><br>
<input type="checkbox"> Ensure that IDs, if multiple, have descriptive qualifiers.</input><br>
<input type="checkbox"> Ensure the `name` property in `description` in the node class is written in camelCase.</input><br>
<input type="checkbox"> Ensure the file name and the Class name are identical.</input><br>

View File

@ -2,35 +2,46 @@
## Credentials
### Error message: 'Credentials of type “*” are not known'
<!-- vale off -->
### Error message: 'Credentials of type "*" are not known'
<!-- vale on -->
Ensure that the name in the credentials array matches the name used in the property name of the credentials' class.
Check that the name in the credentials array matches the name used in the property name of the credentials' class.
![Troubleshooting credentials](/_images/integrations/creating-nodes/troubleshooting-credentials-1.png)
<!-- vale off -->
## Editor UI
<!-- vale on -->
<!-- vale off -->
### Error message: 'There was a problem loading init data: API-Server can not be reached. It is probably down'
<!-- vale on -->
- Ensure that the node's file name, class's name, and node's folder name matches the path added to `packages/nodes-base/package.json`.
- Ensure the names used in the `displayOptions` property are names used by UI elements in the node.
- Check that the node's file name, class's name, and node's folder name matches the path added to `packages/nodes-base/package.json`.
- Check the names used in the `displayOptions` property are names used by UI elements in the node.
### Node icon doesn't show up in the Create Node menu and the Editor UI
<!-- vale off -->
### Node icon doesn't show up in the Add Node menu and the Editor UI
<!-- vale on -->
- Ensure that the icon is in the same folder as the node.
- Ensure that it's either in PNG or SVG format.
- When the icon is referenced in the 'icon' property, ensure that it includes the logo extension (`.png` or `.svg`) and that it is preceded by the world `file:`. For example, `file:friendGrid.png` or `file:friendGrid.svg`.
- Check that the icon is in the same folder as the node.
- Check that it's either in PNG or SVG format.
- When the `icon` property references the icon file, check that it includes the logo extension (`.png` or `.svg`) and that it prefixes it with `file:`. For example, `file:friendGrid.png` or `file:friendGrid.svg`.
### Node icon does not fit correctly
### Node icon doesn't fit
- If you are using an SVG file, make sure the canvas size is square. You can find instructions to change the canvas size of an SVG file using GIMP [here](https://docs.gimp.org/2.10/en/gimp-image-resize.html).
- If you are using a PNG file, make sure that it's 60x60 pixels.
- If you use an SVG file, make sure the canvas size is square. You can find instructions to change the canvas size of an SVG file using GIMP [here](https://docs.gimp.org/2.10/en/gimp-image-resize.html).
- If you use a PNG file, make sure that it's 60x60 pixels.
### Node does not show up in the Create Node menu
### Node doesn't show up in the Add Node menu
Ensure that the node is registered in the `packages/nodes-base/package.json` file.
Check that you registered the node in the `packages/nodes-base/package.json` file.
### Changes to the description properties do not show in the UI on refreshing
[TODO: does this still apply with new way of adding nodes?]
Every time a change is made to the description properties, you have to stop the current n8n process (ctrl + c) and run it again (npm run dev).
<!-- vale off -->
### Changes to the description properties don't show in the UI on refreshing
<!-- vale on -->
Every time you change the description properties, you have to stop the current n8n process (`ctrl` + `c`) and run it again (`npm run dev`).

View File

@ -3,6 +3,8 @@ Cron
Dockerfile
Enum
enum
GIMP
invalid
n8n
namespace
npm