import { INodeType, INodeTypeDescription, INodeExecutionData, IExecuteFunctions } from 'n8n-workflow';

export class ReturnTextNode implements INodeType {
	description: INodeTypeDescription = {
		displayName: 'Return Text',
		name: 'returnTextNode',
		group: ['transform'],
		version: 1,
		description: 'Returns user input as text',
		defaults: {
			name: 'Return Text',
		},
		inputs: ['main'],
		outputs: ['main'],
		properties: [
			{
				displayName: 'Text to Return',
				name: 'message',
				type: 'string',
				default: '',
				placeholder: 'Type your message here...',
				required: true,
				description: 'Message to return',
			},
		],
	};

	async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
		const returnData: INodeExecutionData[] = [];

		for (let i = 0; i < this.getInputData().length; i++) {
			const message = this.getNodeParameter('message', i) as string;

			returnData.push({
				json: {
					message,
				},
			});
		}

		return [returnData];
	}
}
