mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 02:21:13 +00:00
Co-authored-by: Eugene <eugene@n8n.io> Co-authored-by: Daria <daria.staferova@n8n.io> Co-authored-by: Alex Grozav <alex@grozav.com> Co-authored-by: Tomi Turtiainen <10324676+tomi@users.noreply.github.com> Co-authored-by: Guillaume Jacquart <jacquart.guillaume@gmail.com> Co-authored-by: Charlie Kolb <charlie@n8n.io> Co-authored-by: Elias Meire <elias@meire.dev> Co-authored-by: Michael Kret <88898367+michael-radency@users.noreply.github.com> Co-authored-by: shortstacked <declan@n8n.io> Co-authored-by: oleg <me@olegivaniv.com> Co-authored-by: Csaba Tuncsik <csaba@n8n.io> Co-authored-by: Jaakko Husso <jaakko@n8n.io> Co-authored-by: Raúl Gómez Morales <raul00gm@gmail.com> Co-authored-by: Suguru Inoue <suguru@n8n.io> Co-authored-by: Milorad FIlipović <milorad@n8n.io> Co-authored-by: Danny Martini <danny@n8n.io> Co-authored-by: Iván Ovejero <ivov.src@gmail.com> Co-authored-by: RomanDavydchuk <roman.davydchuk@n8n.io> Co-authored-by: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> Co-authored-by: Ricardo Espinoza <ricardo@n8n.io> Co-authored-by: Dana <152518854+dana-gill@users.noreply.github.com> Co-authored-by: Michael Kret <michael.k@radency.com> Co-authored-by: Mutasem Aldmour <mutasem@n8n.io>
86 lines
2.0 KiB
TypeScript
86 lines
2.0 KiB
TypeScript
import type { IExecuteFunctions, INodeExecutionData, INodeProperties } from 'n8n-workflow';
|
|
import { NodeOperationError } from 'n8n-workflow';
|
|
|
|
import { pushFileToSession, triggerFileInput } from './helpers';
|
|
import {
|
|
sessionIdField,
|
|
windowIdField,
|
|
elementDescriptionField,
|
|
includeHiddenElementsField,
|
|
} from '../common/fields';
|
|
|
|
const displayOptions = {
|
|
show: {
|
|
resource: ['file'],
|
|
operation: ['load'],
|
|
},
|
|
};
|
|
|
|
export const description: INodeProperties[] = [
|
|
{
|
|
...sessionIdField,
|
|
description: 'The session ID to load the file into',
|
|
displayOptions,
|
|
},
|
|
{
|
|
...windowIdField,
|
|
description: 'The window ID to trigger the file input in',
|
|
displayOptions,
|
|
},
|
|
{
|
|
displayName: 'File ID',
|
|
name: 'fileId',
|
|
type: 'string',
|
|
default: '',
|
|
required: true,
|
|
description: 'ID of the file to load into the session',
|
|
displayOptions,
|
|
},
|
|
{
|
|
...elementDescriptionField,
|
|
description: 'Optional description of the file input to interact with',
|
|
placeholder: 'e.g. the file upload selection box',
|
|
displayOptions,
|
|
},
|
|
{
|
|
...includeHiddenElementsField,
|
|
displayOptions,
|
|
},
|
|
];
|
|
|
|
export async function execute(
|
|
this: IExecuteFunctions,
|
|
index: number,
|
|
): Promise<INodeExecutionData[]> {
|
|
const fileId = this.getNodeParameter('fileId', index, '') as string;
|
|
const sessionId = this.getNodeParameter('sessionId', index, '') as string;
|
|
const windowId = this.getNodeParameter('windowId', index, '') as string;
|
|
const elementDescription = this.getNodeParameter('elementDescription', index, '') as string;
|
|
const includeHiddenElements = this.getNodeParameter(
|
|
'includeHiddenElements',
|
|
index,
|
|
false,
|
|
) as boolean;
|
|
|
|
try {
|
|
await pushFileToSession.call(this, fileId, sessionId);
|
|
await triggerFileInput.call(this, {
|
|
fileId,
|
|
windowId,
|
|
sessionId,
|
|
elementDescription,
|
|
includeHiddenElements,
|
|
});
|
|
|
|
return this.helpers.returnJsonArray({
|
|
sessionId,
|
|
windowId,
|
|
data: {
|
|
message: 'File loaded successfully',
|
|
},
|
|
});
|
|
} catch (error) {
|
|
throw new NodeOperationError(this.getNode(), error as Error);
|
|
}
|
|
}
|