2023-03-09 09:13:15 -08:00
|
|
|
import {
|
|
|
|
IExecuteFunctions,
|
|
|
|
INodeExecutionData,
|
|
|
|
INodeType,
|
|
|
|
INodeTypeDescription,
|
|
|
|
} from 'n8n-workflow';
|
2019-06-23 03:35:23 -07:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2022-09-02 07:13:17 -07:00
|
|
|
// Iterates over all input items and add the key "myString" with the
|
2019-06-23 03:35:23 -07:00
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
2023-09-05 03:59:02 -07:00
|
|
|
return [items];
|
2019-06-23 03:35:23 -07:00
|
|
|
}
|
|
|
|
}
|