2019-10-03 08:53:03 +02:00
|
|
|
import { IExecuteFunctions } from 'n8n-core';
|
2022-06-27 11:45:32 +02:00
|
|
|
import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
2019-10-03 08:53:03 +02:00
|
|
|
|
|
|
|
|
export class ExampleNode implements INodeType {
|
|
|
|
|
description: INodeTypeDescription = {
|
|
|
|
|
displayName: 'Example Node',
|
|
|
|
|
name: 'exampleNode',
|
|
|
|
|
group: ['transform'],
|
|
|
|
|
version: 1,
|
|
|
|
|
description: 'Basic Example Node',
|
|
|
|
|
defaults: {
|
|
|
|
|
name: 'Example Node',
|
|
|
|
|
},
|
|
|
|
|
inputs: ['main'],
|
|
|
|
|
outputs: ['main'],
|
|
|
|
|
properties: [
|
2022-06-28 15:27:25 +02:00
|
|
|
// Node properties that the user can see and change on the node.
|
2019-10-03 08:53:03 +02:00
|
|
|
{
|
|
|
|
|
displayName: 'My String',
|
|
|
|
|
name: 'myString',
|
|
|
|
|
type: 'string',
|
|
|
|
|
default: '',
|
|
|
|
|
placeholder: 'Placeholder value',
|
2022-06-28 15:27:25 +02:00
|
|
|
description: 'This is a description',
|
2022-01-17 18:29:15 +01:00
|
|
|
},
|
|
|
|
|
],
|
2019-10-03 08:53:03 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
|
|
|
const items = this.getInputData();
|
|
|
|
|
|
2022-06-28 15:27:25 +02:00
|
|
|
// The node iterates over all input items and adds the key "myString" with the
|
|
|
|
|
// value the parameter "myString" resolves to. (This could be a different value
|
|
|
|
|
// for each item in case it contains an expression.)
|
2019-10-03 08:53:03 +02:00
|
|
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
2022-06-28 15:27:25 +02:00
|
|
|
const myString = this.getNodeParameter('myString', itemIndex, '') as string;
|
|
|
|
|
const item = items[itemIndex];
|
2019-10-03 08:53:03 +02:00
|
|
|
|
|
|
|
|
item.json['myString'] = myString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return this.prepareOutputData(items);
|
|
|
|
|
}
|
|
|
|
|
}
|