@atom8n/n8n-node-dev 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,218 @@
1
+ ![n8n.io - Workflow Automation](https://user-images.githubusercontent.com/65276001/173571060-9f2f6d7b-bac0-43b6-bdb2-001da9694058.png)
2
+
3
+ # n8n-node-dev
4
+
5
+ Currently very simple and not very sophisticated CLI which makes it easier
6
+ to create credentials and nodes in TypeScript for n8n.
7
+
8
+ ```
9
+ npm install n8n-node-dev -g
10
+ ```
11
+
12
+ ## Contents
13
+
14
+ - [Usage](#usage)
15
+ - [Commands](#commands)
16
+ - [Create a node](#create-a-node)
17
+ - [Node Type](#node-type)
18
+ - [Node Type Description](#node-type-description)
19
+ - [Node Properties](#node-properties)
20
+ - [Node Property Options](#node-property-options)
21
+ - [License](#license)
22
+
23
+ ## Usage
24
+
25
+ The commandline tool can be started with `n8n-node-dev <COMMAND>`
26
+
27
+ ## Commands
28
+
29
+ The following commands exist:
30
+
31
+ ### build
32
+
33
+ Builds credentials and nodes in the current folder and copies them into the
34
+ n8n custom extension folder (`~/.n8n/custom/`) unless destination path is
35
+ overwritten with `--destination <FOLDER_PATH>`
36
+
37
+ When "--watch" gets set it starts in watch mode and automatically builds and
38
+ copies files whenever they change. To stop press "ctrl + c".
39
+
40
+ ### new
41
+
42
+ Creates new basic credentials or node of the selected type to have a first starting point.
43
+
44
+ ## Create a node
45
+
46
+ The easiest way to create a new node is via the "n8n-node-dev" cli. It sets up
47
+ all the basics.
48
+
49
+ A n8n node is a JavaScript file (normally written in TypeScript) which describes
50
+ some basic information (like name, description, ...) and also at least one method.
51
+ Depending on which method gets implemented defines if it is a regular-, trigger-
52
+ or webhook-node.
53
+
54
+ A simple regular node which:
55
+
56
+ - defines one node property
57
+ - sets its value to all items it receives
58
+
59
+ would look like this:
60
+
61
+ File named: `MyNode.node.ts`
62
+
63
+ ```TypeScript
64
+ import {
65
+ IExecuteFunctions,
66
+ INodeExecutionData,
67
+ INodeType,
68
+ INodeTypeDescription,
69
+ } from 'n8n-workflow';
70
+
71
+
72
+ export class MyNode implements INodeType {
73
+ description: INodeTypeDescription = {
74
+ displayName: 'My Node',
75
+ name: 'myNode',
76
+ group: ['transform'],
77
+ version: 1,
78
+ description: 'Adds "myString" on all items to defined value.',
79
+ defaults: {
80
+ name: 'My Node',
81
+ color: '#772244',
82
+ },
83
+ inputs: ['main'],
84
+ outputs: ['main'],
85
+ properties: [
86
+ // Node properties which the user gets displayed and
87
+ // can change on the node.
88
+ {
89
+ displayName: 'My String',
90
+ name: 'myString',
91
+ type: 'string',
92
+ default: '',
93
+ placeholder: 'Placeholder value',
94
+ description: 'The description text',
95
+ }
96
+ ]
97
+ };
98
+
99
+
100
+ async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
101
+
102
+ const items = this.getInputData();
103
+
104
+ let item: INodeExecutionData;
105
+ let myString: string;
106
+
107
+ // Itterates over all input items and add the key "myString" with the
108
+ // value the parameter "myString" resolves to.
109
+ // (This could be a different value for each item in case it contains an expression)
110
+ for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
111
+ myString = this.getNodeParameter('myString', itemIndex, '') as string;
112
+ item = items[itemIndex];
113
+
114
+ item.json['myString'] = myString;
115
+ }
116
+
117
+ return [items];
118
+
119
+ }
120
+ }
121
+ ```
122
+
123
+ The "description" property has to be set on all nodes because it contains all
124
+ the base information. Additionally all nodes have to have exactly one of the
125
+ following methods defined which contains the actual logic:
126
+
127
+ **Regular node**
128
+
129
+ Method is called when the workflow gets executed
130
+
131
+ - `execute`: Executed once no matter how many items
132
+
133
+ By default, `execute` should always be used, especially when creating a
134
+ third-party integration. The reason for this is that it provides much more
135
+ flexibility and allows, for example, returning a different number of items than
136
+ it received as input. This becomes crucial when a node needs to query data such as _return
137
+ all users_. In such cases, the node typically receives only one input item but returns as
138
+ many items as there are users. Therefore, when in doubt, it is recommended to use `execute`!
139
+
140
+ **Trigger node**
141
+
142
+ Method is called once when the workflow gets activated. It can then trigger workflow runs and provide the necessary data by itself.
143
+
144
+ - `trigger`
145
+
146
+ **Webhook node**
147
+
148
+ Method is called when webhook gets called.
149
+
150
+ - `webhook`
151
+
152
+ ### Node Type
153
+
154
+ Property overview
155
+
156
+ - **description** [required]: Describes the node like its name, properties, hooks, ... see `Node Type Description` bellow.
157
+ - **execute** [optional]: Method is called when the workflow gets executed (once).
158
+ - **hooks** [optional]: The hook methods.
159
+ - **methods** [optional]: Additional methods. Currently only "loadOptions" exists which allows loading options for parameters from external services
160
+ - **trigger** [optional]: Method is called once when the workflow gets activated.
161
+ - **webhook** [optional]: Method is called when webhook gets called.
162
+ - **webhookMethods** [optional]: Methods to setup webhooks on external services.
163
+
164
+ ### Node Type Description
165
+
166
+ The following properties can be set in the node description:
167
+
168
+ - **credentials** [optional]: Credentials the node requests access to
169
+ - **defaults** [required]: Default "name" and "color" to set on node when it gets created
170
+ - **displayName** [required]: Name to display users in Editor UI
171
+ - **description** [required]: Description to display users in Editor UI
172
+ - **group** [required]: Node group for example "transform" or "trigger"
173
+ - **hooks** [optional]: Methods to execute at different points in time like when the workflow gets activated or deactivated
174
+ - **icon** [optional]: Icon to display (can be an icon or a font awesome icon)
175
+ - **inputs** [required]: Types of inputs the node has (currently only "main" exists) and the amount
176
+ - **outputs** [required]: Types of outputs the node has (currently only "main" exists) and the amount
177
+ - **outputNames** [optional]: In case a node has multiple outputs, names can be set that users know what data to expect
178
+ - **maxNodes** [optional]: If an unlimited number of nodes of that type cannot exist in a workflow, the max-amount can be specified
179
+ - **name** [required]: Name of the node (for n8n to use internally, in camelCase)
180
+ - **properties** [required]: Properties which get displayed in the Editor UI and can be set by the user
181
+ - **subtitle** [optional]: Text which should be displayed underneath the name of the node in the Editor UI (can be an expression)
182
+ - **version** [required]: Version of the node. Currently always "1" (integer). For future usage, does not get used yet
183
+ - **webhooks** [optional]: Webhooks the node should listen to
184
+
185
+ ### Node Properties
186
+
187
+ The following properties can be set in the node properties:
188
+
189
+ - **default** [required]: Default value of the property
190
+ - **description** [required]: Description that is displayed to users in the Editor UI
191
+ - **displayName** [required]: Name that is displayed to users in the Editor UI
192
+ - **displayOptions** [optional]: Defines logic to decide if a property should be displayed or not
193
+ - **name** [required]: Name of the property (for n8n to use internally, in camelCase)
194
+ - **options** [optional]: The options the user can select when type of property is "collection", "fixedCollection" or "options"
195
+ - **placeholder** [optional]: Placeholder text that is displayed to users in the Editor UI
196
+ - **type** [required]: Type of the property. If it is for example a "string", "number", ...
197
+ - **typeOptions** [optional]: Additional options for type. Like for example the min or max value of a number
198
+ - **required** [optional]: Defines if the value has to be set or if it can stay empty
199
+
200
+ ### Node Property Options
201
+
202
+ The following properties can be set in the node property options:
203
+
204
+ All properties are optional. However, most only work when the node-property is of a specfic type.
205
+
206
+ - **alwaysOpenEditWindow** [type: json]: If set then the "Editor Window" will always open when the user tries to edit the field. Helpful if long text is typically used in the property
207
+ - **loadOptionsMethod** [type: options]: Method to use to load options from an external service
208
+ - **maxValue** [type: number]: Maximum value of the number
209
+ - **minValue** [type: number]: Minimum value of the number
210
+ - **multipleValues** [type: all]: If set the property gets turned into an Array and the user can add multiple values
211
+ - **multipleValueButtonText** [type: all]: Custom text for add button in case "multipleValues" were set
212
+ - **numberPrecision** [type: number]: The precision of the number. By default, it is "0" and will only allow integers
213
+ - **password** [type: string]: If a password field should be displayed (normally only used by credentials because all node data is not encrypted and gets saved in clear-text)
214
+ - **rows** [type: string]: Number of rows the input field should have. By default it is "1"
215
+
216
+ ## License
217
+
218
+ You can find the license information [here](https://github.com/n8n-io/n8n/blob/master/README.md#license)
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ (async () => {
4
+ const oclif = await import('@oclif/core');
5
+ await oclif.execute({});
6
+ })();
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\n8n-node-dev" %*