mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
49c85a1df8
* Improve code health Fix TS typos in local variables Fix CSS typos in local styles Fix typos in comments Fix typos in strings * Fix order of n8n setup sections in CONTRIBUTING.md
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { IExecuteFunctions } from 'n8n-core';
|
|
import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';
|
|
|
|
export class ClassNameReplace implements INodeType {
|
|
description: INodeTypeDescription = {
|
|
displayName: 'DisplayNameReplace',
|
|
name: 'N8nNameReplace',
|
|
group: ['transform'],
|
|
version: 1,
|
|
description: 'NodeDescriptionReplace',
|
|
defaults: {
|
|
name: 'DisplayNameReplace',
|
|
color: '#772244',
|
|
},
|
|
inputs: ['main'],
|
|
outputs: ['main'],
|
|
properties: [
|
|
// Node properties which the user gets displayed and
|
|
// can change on the node.
|
|
{
|
|
displayName: 'My String',
|
|
name: 'myString',
|
|
type: 'string',
|
|
default: '',
|
|
placeholder: 'Placeholder value',
|
|
description: 'The description text',
|
|
},
|
|
],
|
|
};
|
|
|
|
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
|
const items = this.getInputData();
|
|
|
|
let item: INodeExecutionData;
|
|
let myString: string;
|
|
|
|
// Iterates over all input items and add 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)
|
|
for (let itemIndex = 0; itemIndex < items.length; itemIndex++) {
|
|
myString = this.getNodeParameter('myString', itemIndex, '') as string;
|
|
item = items[itemIndex];
|
|
|
|
item.json.myString = myString;
|
|
}
|
|
|
|
return this.prepareOutputData(items);
|
|
}
|
|
}
|