💥 Fix typo reponse => response

This commit is contained in:
Jan Oberhauser 2019-08-28 17:16:09 +02:00
parent 1ff456d77c
commit 4d6e25c28e
14 changed files with 70 additions and 72 deletions

View file

@ -107,28 +107,28 @@ export class ActiveWorkflowRunner {
*/ */
async executeWebhook(httpMethod: WebhookHttpMethod, path: string, req: express.Request, res: express.Response): Promise<IResponseCallbackData> { async executeWebhook(httpMethod: WebhookHttpMethod, path: string, req: express.Request, res: express.Response): Promise<IResponseCallbackData> {
if (this.activeWorkflows === null) { if (this.activeWorkflows === null) {
throw new ResponseHelper.ReponseError('The "activeWorkflows" instance did not get initialized yet.', 404, 404); throw new ResponseHelper.ResponseError('The "activeWorkflows" instance did not get initialized yet.', 404, 404);
} }
const webhookData: IWebhookData | undefined = this.activeWebhooks!.get(httpMethod, path); const webhookData: IWebhookData | undefined = this.activeWebhooks!.get(httpMethod, path);
if (webhookData === undefined) { if (webhookData === undefined) {
// The requested webhook is not registred // The requested webhook is not registred
throw new ResponseHelper.ReponseError('The requested webhook is not registred.', 404, 404); throw new ResponseHelper.ResponseError('The requested webhook is not registred.', 404, 404);
} }
// Get the node which has the webhook defined to know where to start from and to // Get the node which has the webhook defined to know where to start from and to
// get additional data // get additional data
const workflowStartNode = webhookData.workflow.getNode(webhookData.node); const workflowStartNode = webhookData.workflow.getNode(webhookData.node);
if (workflowStartNode === null) { if (workflowStartNode === null) {
throw new ResponseHelper.ReponseError('Could not find node to process webhook.', 404, 404); throw new ResponseHelper.ResponseError('Could not find node to process webhook.', 404, 404);
} }
const executionMode = 'webhook'; const executionMode = 'webhook';
const workflowData = await Db.collections.Workflow!.findOne(webhookData.workflow.id!); const workflowData = await Db.collections.Workflow!.findOne(webhookData.workflow.id!);
if (workflowData === undefined) { if (workflowData === undefined) {
throw new ResponseHelper.ReponseError(`Could not find workflow with id "${webhookData.workflow.id}"`, 404, 404); throw new ResponseHelper.ResponseError(`Could not find workflow with id "${webhookData.workflow.id}"`, 404, 404);
} }
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {

View file

@ -13,10 +13,10 @@ import {
* Special Error which allows to return also an error code and http status code * Special Error which allows to return also an error code and http status code
* *
* @export * @export
* @class ReponseError * @class ResponseError
* @extends {Error} * @extends {Error}
*/ */
export class ReponseError extends Error { export class ResponseError extends Error {
// The HTTP status code of response // The HTTP status code of response
httpStatusCode?: number; httpStatusCode?: number;
@ -25,15 +25,15 @@ export class ReponseError extends Error {
errorCode?: number; errorCode?: number;
/** /**
* Creates an instance of ReponseError. * Creates an instance of ResponseError.
* @param {string} message The error message * @param {string} message The error message
* @param {number} [errorCode] The error code which can be used by frontend to identify the actual error * @param {number} [errorCode] The error code which can be used by frontend to identify the actual error
* @param {number} [httpStatusCode] The HTTP status code the response should have * @param {number} [httpStatusCode] The HTTP status code the response should have
* @memberof ReponseError * @memberof ResponseError
*/ */
constructor(message: string, errorCode?: number, httpStatusCode?: number) { constructor(message: string, errorCode?: number, httpStatusCode?: number) {
super(message); super(message);
this.name = 'ReponseError'; this.name = 'ResponseError';
if (errorCode) { if (errorCode) {
this.errorCode = errorCode; this.errorCode = errorCode;
@ -71,7 +71,7 @@ export function sendSuccessResponse(res: Response, data: any, raw?: boolean, res
} }
export function sendErrorResponse(res: Response, error: ReponseError) { export function sendErrorResponse(res: Response, error: ResponseError) {
let httpStatusCode = 500; let httpStatusCode = 500;
if (error.httpStatusCode) { if (error.httpStatusCode) {
httpStatusCode = error.httpStatusCode; httpStatusCode = error.httpStatusCode;

View file

@ -208,7 +208,7 @@ class App {
this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => { this.app.use((req: express.Request, res: express.Response, next: express.NextFunction) => {
if (Db.collections.Workflow === null) { if (Db.collections.Workflow === null) {
const error = new ResponseHelper.ReponseError('Database is not ready!', undefined, 503); const error = new ResponseHelper.ResponseError('Database is not ready!', undefined, 503);
return ResponseHelper.sendErrorResponse(res, error); return ResponseHelper.sendErrorResponse(res, error);
} }
@ -246,10 +246,10 @@ class App {
// Reads and returns workflow data from an URL // Reads and returns workflow data from an URL
this.app.get('/rest/workflows/from-url', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<IWorkflowResponse> => { this.app.get('/rest/workflows/from-url', ResponseHelper.send(async (req: express.Request, res: express.Response): Promise<IWorkflowResponse> => {
if (req.query.url === undefined) { if (req.query.url === undefined) {
throw new ResponseHelper.ReponseError(`The parameter "url" is missing!`, undefined, 400); throw new ResponseHelper.ResponseError(`The parameter "url" is missing!`, undefined, 400);
} }
if (!req.query.url.match(/^http[s]?:\/\/.*\.json$/i)) { if (!req.query.url.match(/^http[s]?:\/\/.*\.json$/i)) {
throw new ResponseHelper.ReponseError(`The parameter "url" is not valid! It does not seem to be a URL pointing to a n8n workflow JSON file.`, undefined, 400); throw new ResponseHelper.ResponseError(`The parameter "url" is not valid! It does not seem to be a URL pointing to a n8n workflow JSON file.`, undefined, 400);
} }
const data = await requestPromise.get(req.query.url); const data = await requestPromise.get(req.query.url);
@ -257,14 +257,14 @@ class App {
try { try {
workflowData = JSON.parse(data); workflowData = JSON.parse(data);
} catch (error) { } catch (error) {
throw new ResponseHelper.ReponseError(`The URL does not point to valid JSON file!`, undefined, 400); throw new ResponseHelper.ResponseError(`The URL does not point to valid JSON file!`, undefined, 400);
} }
// Do a very basic check if it is really a n8n-workflow-json // Do a very basic check if it is really a n8n-workflow-json
if (workflowData === undefined || workflowData.nodes === undefined || !Array.isArray(workflowData.nodes) || if (workflowData === undefined || workflowData.nodes === undefined || !Array.isArray(workflowData.nodes) ||
workflowData.connections === undefined || typeof workflowData.connections !== 'object' || workflowData.connections === undefined || typeof workflowData.connections !== 'object' ||
Array.isArray(workflowData.connections)) { Array.isArray(workflowData.connections)) {
throw new ResponseHelper.ReponseError(`The data in the file does not seem to be a n8n workflow JSON file!`, undefined, 400); throw new ResponseHelper.ResponseError(`The data in the file does not seem to be a n8n workflow JSON file!`, undefined, 400);
} }
return workflowData; return workflowData;
@ -343,13 +343,13 @@ class App {
// We sadly get nothing back from "update". Neither if it updated a record // We sadly get nothing back from "update". Neither if it updated a record
// nor the new value. So query now the hopefully updated entry. // nor the new value. So query now the hopefully updated entry.
const reponseData = await Db.collections.Workflow!.findOne(id); const responseData = await Db.collections.Workflow!.findOne(id);
if (reponseData === undefined) { if (responseData === undefined) {
throw new ResponseHelper.ReponseError(`Workflow with id "${id}" could not be found to be updated.`, undefined, 400); throw new ResponseHelper.ResponseError(`Workflow with id "${id}" could not be found to be updated.`, undefined, 400);
} }
if (reponseData.active === true) { if (responseData.active === true) {
// When the workflow is supposed to be active add it again // When the workflow is supposed to be active add it again
try { try {
await this.activeWorkflowRunner.add(id); await this.activeWorkflowRunner.add(id);
@ -359,7 +359,7 @@ class App {
await Db.collections.Workflow!.update(id, newWorkflowData); await Db.collections.Workflow!.update(id, newWorkflowData);
// Also set it in the returned data // Also set it in the returned data
reponseData.active = false; responseData.active = false;
// Now return the original error for UI to display // Now return the original error for UI to display
throw error; throw error;
@ -367,8 +367,8 @@ class App {
} }
// Convert to response format in which the id is a string // Convert to response format in which the id is a string
(reponseData as IWorkflowBase as IWorkflowResponse).id = reponseData.id.toString(); (responseData as IWorkflowBase as IWorkflowResponse).id = responseData.id.toString();
return reponseData as IWorkflowBase as IWorkflowResponse; return responseData as IWorkflowBase as IWorkflowResponse;
})); }));
@ -569,7 +569,7 @@ class App {
const checkResult = await Db.collections.Credentials!.findOne(findQuery); const checkResult = await Db.collections.Credentials!.findOne(findQuery);
if (checkResult !== undefined) { if (checkResult !== undefined) {
throw new ResponseHelper.ReponseError(`Credentials with the same type and name exist already.`, undefined, 400); throw new ResponseHelper.ResponseError(`Credentials with the same type and name exist already.`, undefined, 400);
} }
// Encrypt the data // Encrypt the data
@ -616,7 +616,7 @@ class App {
const checkResult = await Db.collections.Credentials!.findOne(findQuery); const checkResult = await Db.collections.Credentials!.findOne(findQuery);
if (checkResult !== undefined) { if (checkResult !== undefined) {
throw new ResponseHelper.ReponseError(`Credentials with the same type and name exist already.`, undefined, 400); throw new ResponseHelper.ResponseError(`Credentials with the same type and name exist already.`, undefined, 400);
} }
const encryptionKey = await UserSettings.getEncryptionKey(); const encryptionKey = await UserSettings.getEncryptionKey();
@ -637,18 +637,18 @@ class App {
// We sadly get nothing back from "update". Neither if it updated a record // We sadly get nothing back from "update". Neither if it updated a record
// nor the new value. So query now the hopefully updated entry. // nor the new value. So query now the hopefully updated entry.
const reponseData = await Db.collections.Credentials!.findOne(id); const responseData = await Db.collections.Credentials!.findOne(id);
if (reponseData === undefined) { if (responseData === undefined) {
throw new ResponseHelper.ReponseError(`Credentials with id "${id}" could not be found to be updated.`, undefined, 400); throw new ResponseHelper.ResponseError(`Credentials with id "${id}" could not be found to be updated.`, undefined, 400);
} }
// Remove the encrypted data as it is not needed in the frontend // Remove the encrypted data as it is not needed in the frontend
reponseData.data = ''; responseData.data = '';
// Convert to response format in which the id is a string // Convert to response format in which the id is a string
(reponseData as unknown as ICredentialsResponse).id = reponseData.id.toString(); (responseData as unknown as ICredentialsResponse).id = responseData.id.toString();
return reponseData as unknown as ICredentialsResponse; return responseData as unknown as ICredentialsResponse;
})); }));
@ -837,7 +837,7 @@ class App {
const fullExecutionDataFlatted = await Db.collections.Execution!.findOne(req.params.id); const fullExecutionDataFlatted = await Db.collections.Execution!.findOne(req.params.id);
if (fullExecutionDataFlatted === undefined) { if (fullExecutionDataFlatted === undefined) {
throw new ResponseHelper.ReponseError(`The execution with the id "${req.params.id}" does not exist.`, 404, 404); throw new ResponseHelper.ResponseError(`The execution with the id "${req.params.id}" does not exist.`, 404, 404);
} }
const fullExecutionData = ResponseHelper.unflattenExecutionData(fullExecutionDataFlatted); const fullExecutionData = ResponseHelper.unflattenExecutionData(fullExecutionDataFlatted);

View file

@ -57,14 +57,14 @@ export class TestWebhooks {
if (webhookData === undefined) { if (webhookData === undefined) {
// The requested webhook is not registred // The requested webhook is not registred
throw new ResponseHelper.ReponseError('The requested webhook is not registred.', 404, 404); throw new ResponseHelper.ResponseError('The requested webhook is not registred.', 404, 404);
} }
// Get the node which has the webhook defined to know where to start from and to // Get the node which has the webhook defined to know where to start from and to
// get additional data // get additional data
const workflowStartNode = webhookData.workflow.getNode(webhookData.node); const workflowStartNode = webhookData.workflow.getNode(webhookData.node);
if (workflowStartNode === null) { if (workflowStartNode === null) {
throw new ResponseHelper.ReponseError('Could not find node to process webhook.', 404, 404); throw new ResponseHelper.ResponseError('Could not find node to process webhook.', 404, 404);
} }
const webhookKey = this.activeWebhooks!.getWebhookKey(webhookData.httpMethod, webhookData.path); const webhookKey = this.activeWebhooks!.getWebhookKey(webhookData.httpMethod, webhookData.path);

View file

@ -110,20 +110,20 @@ export function getWorkflowWebhooks(workflow: Workflow, additionalData: IWorkflo
if (nodeType === undefined) { if (nodeType === undefined) {
const errorMessage = `The type of the webhook node "${workflowStartNode.name}" is not known.`; const errorMessage = `The type of the webhook node "${workflowStartNode.name}" is not known.`;
responseCallback(new Error(errorMessage), {}); responseCallback(new Error(errorMessage), {});
throw new ResponseHelper.ReponseError(errorMessage, 500, 500); throw new ResponseHelper.ResponseError(errorMessage, 500, 500);
} }
// Get the responseMode // Get the responseMode
const reponseMode = webhookData.workflow.getSimpleParameterValue(workflowStartNode, webhookData.webhookDescription['reponseMode'], 'onReceived'); const responseMode = webhookData.workflow.getSimpleParameterValue(workflowStartNode, webhookData.webhookDescription['responseMode'], 'onReceived');
const responseCode = webhookData.workflow.getSimpleParameterValue(workflowStartNode, webhookData.webhookDescription['responseCode'], 200); const responseCode = webhookData.workflow.getSimpleParameterValue(workflowStartNode, webhookData.webhookDescription['responseCode'], 200) as number;
if (!['onReceived', 'lastNode'].includes(reponseMode as string)) { if (!['onReceived', 'lastNode'].includes(responseMode as string)) {
// If the mode is not known we error. Is probably best like that instead of using // If the mode is not known we error. Is probably best like that instead of using
// the default that people know as early as possible (probably already testing phase) // the default that people know as early as possible (probably already testing phase)
// that something does not resolve properly. // that something does not resolve properly.
const errorMessage = `The response mode ${reponseMode} is not valid!.`; const errorMessage = `The response mode ${responseMode} is not valid!.`;
responseCallback(new Error(errorMessage), {}); responseCallback(new Error(errorMessage), {});
throw new ResponseHelper.ReponseError(errorMessage, 500, 500); throw new ResponseHelper.ResponseError(errorMessage, 500, 500);
} }
// Prepare everything that is needed to run the workflow // Prepare everything that is needed to run the workflow
@ -170,7 +170,7 @@ export function getWorkflowWebhooks(workflow: Workflow, additionalData: IWorkflo
// Now that we know that the workflow should run we can return the default respons // Now that we know that the workflow should run we can return the default respons
// directly if responseMode it set to "onReceived" and a respone should be sent // directly if responseMode it set to "onReceived" and a respone should be sent
if (reponseMode === 'onReceived' && didSendResponse === false) { if (responseMode === 'onReceived' && didSendResponse === false) {
// Return response directly and do not wait for the workflow to finish // Return response directly and do not wait for the workflow to finish
if (webhookResultData.webhookResponse !== undefined) { if (webhookResultData.webhookResponse !== undefined) {
// Data to respond with is given // Data to respond with is given
@ -179,8 +179,6 @@ export function getWorkflowWebhooks(workflow: Workflow, additionalData: IWorkflo
responseCode, responseCode,
}); });
} else { } else {
console.log('k1: ' + responseCode);
responseCallback(null, { responseCallback(null, {
data: { data: {
message: 'Workflow got started.', message: 'Workflow got started.',
@ -268,15 +266,15 @@ export function getWorkflowWebhooks(workflow: Workflow, additionalData: IWorkflo
return data; return data;
} }
const reponseData = webhookData.workflow.getSimpleParameterValue(workflowStartNode, webhookData.webhookDescription['reponseData'], 'firstEntryJson'); const responseData = webhookData.workflow.getSimpleParameterValue(workflowStartNode, webhookData.webhookDescription['responseData'], 'firstEntryJson');
if (didSendResponse === false) { if (didSendResponse === false) {
let data: IDataObject | IDataObject[]; let data: IDataObject | IDataObject[];
if (reponseData === 'firstEntryJson') { if (responseData === 'firstEntryJson') {
// Return the JSON data of the first entry // Return the JSON data of the first entry
data = returnData.data!.main[0]![0].json; data = returnData.data!.main[0]![0].json;
} else if (reponseData === 'firstEntryBinary') { } else if (responseData === 'firstEntryBinary') {
// Return the binary data of the first entry // Return the binary data of the first entry
data = returnData.data!.main[0]![0]; data = returnData.data!.main[0]![0];
if (data.binary === undefined) { if (data.binary === undefined) {
@ -323,7 +321,7 @@ export function getWorkflowWebhooks(workflow: Workflow, additionalData: IWorkflo
responseCallback(new Error('There was a problem executing the workflow.'), {}); responseCallback(new Error('There was a problem executing the workflow.'), {});
} }
throw new ResponseHelper.ReponseError(e.message, 500, 500); throw new ResponseHelper.ResponseError(e.message, 500, 500);
}); });
return executionId; return executionId;
@ -333,7 +331,7 @@ export function getWorkflowWebhooks(workflow: Workflow, additionalData: IWorkflo
responseCallback(new Error('There was a problem executing the workflow.'), {}); responseCallback(new Error('There was a problem executing the workflow.'), {});
} }
throw new ResponseHelper.ReponseError(e.message, 500, 500); throw new ResponseHelper.ResponseError(e.message, 500, 500);
} }
} }

View file

@ -54,7 +54,7 @@ function unflattenExecutionData (fullExecutionData: IExecutionFlattedResponse):
return returnData; return returnData;
} }
export class ReponseError extends Error { export class ResponseError extends Error {
// The HTTP status code of response // The HTTP status code of response
httpStatusCode?: number; httpStatusCode?: number;
@ -65,16 +65,16 @@ export class ReponseError extends Error {
serverStackTrace?: string; serverStackTrace?: string;
/** /**
* Creates an instance of ReponseError. * Creates an instance of ResponseError.
* @param {string} message The error message * @param {string} message The error message
* @param {number} [errorCode] The error code which can be used by frontend to identify the actual error * @param {number} [errorCode] The error code which can be used by frontend to identify the actual error
* @param {number} [httpStatusCode] The HTTP status code the response should have * @param {number} [httpStatusCode] The HTTP status code the response should have
* @param {string} [stack] The stack trace * @param {string} [stack] The stack trace
* @memberof ReponseError * @memberof ResponseError
*/ */
constructor (message: string, errorCode?: number, httpStatusCode?: number, stack?: string) { constructor (message: string, errorCode?: number, httpStatusCode?: number, stack?: string) {
super(message); super(message);
this.name = 'ReponseError'; this.name = 'ResponseError';
if (errorCode) { if (errorCode) {
this.errorCode = errorCode; this.errorCode = errorCode;
@ -113,12 +113,12 @@ export const restApi = Vue.extend({
return response.data.data; return response.data.data;
} catch (error) { } catch (error) {
if (error.message === 'Network Error') { if (error.message === 'Network Error') {
throw new ReponseError('API-Server can not be reached. It is probably down.'); throw new ResponseError('API-Server can not be reached. It is probably down.');
} }
const errorResponseData = error.response.data; const errorResponseData = error.response.data;
if (errorResponseData !== undefined && errorResponseData.message !== undefined) { if (errorResponseData !== undefined && errorResponseData.message !== undefined) {
throw new ReponseError(errorResponseData.message, errorResponseData.code, error.response.status, errorResponseData.stack); throw new ResponseError(errorResponseData.message, errorResponseData.code, error.response.status, errorResponseData.stack);
} }
throw error; throw error;

View file

@ -40,7 +40,7 @@ export class AsanaTrigger implements INodeType {
{ {
name: 'default', name: 'default',
httpMethod: 'POST', httpMethod: 'POST',
reponseMode: 'onReceived', responseMode: 'onReceived',
path: 'webhook', path: 'webhook',
}, },
], ],

View file

@ -28,7 +28,7 @@ export class ChargebeeTrigger implements INodeType {
{ {
name: 'default', name: 'default',
httpMethod: 'POST', httpMethod: 'POST',
reponseMode: 'onReceived', responseMode: 'onReceived',
path: 'webhook', path: 'webhook',
}, },
], ],

View file

@ -40,7 +40,7 @@ export class GithubTrigger implements INodeType {
{ {
name: 'default', name: 'default',
httpMethod: 'POST', httpMethod: 'POST',
reponseMode: 'onReceived', responseMode: 'onReceived',
path: 'webhook', path: 'webhook',
}, },
], ],

View file

@ -69,7 +69,7 @@ export class PipedriveTrigger implements INodeType {
{ {
name: 'default', name: 'default',
httpMethod: 'POST', httpMethod: 'POST',
reponseMode: 'onReceived', responseMode: 'onReceived',
path: 'webhook', path: 'webhook',
}, },
], ],

View file

@ -41,13 +41,13 @@ export class TrelloTrigger implements INodeType {
{ {
name: 'setup', name: 'setup',
httpMethod: 'GET', httpMethod: 'GET',
reponseMode: 'onReceived', responseMode: 'onReceived',
path: 'webhook', path: 'webhook',
}, },
{ {
name: 'default', name: 'default',
httpMethod: 'POST', httpMethod: 'POST',
reponseMode: 'onReceived', responseMode: 'onReceived',
path: 'webhook', path: 'webhook',
}, },
], ],

View file

@ -72,8 +72,8 @@ export class Webhook implements INodeType {
name: 'default', name: 'default',
httpMethod: '={{$parameter["httpMethod"]}}', httpMethod: '={{$parameter["httpMethod"]}}',
responseCode: '={{$parameter["responseCode"]}}', responseCode: '={{$parameter["responseCode"]}}',
reponseMode: '={{$parameter["reponseMode"]}}', responseMode: '={{$parameter["responseMode"]}}',
reponseData: '={{$parameter["reponseData"]}}', responseData: '={{$parameter["responseData"]}}',
responseBinaryPropertyName: '={{$parameter["responseBinaryPropertyName"]}}', responseBinaryPropertyName: '={{$parameter["responseBinaryPropertyName"]}}',
path: '={{$parameter["path"]}}', path: '={{$parameter["path"]}}',
}, },
@ -139,8 +139,8 @@ export class Webhook implements INodeType {
description: 'The HTTP Response code to return', description: 'The HTTP Response code to return',
}, },
{ {
displayName: 'Reponse Mode', displayName: 'Response Mode',
name: 'reponseMode', name: 'responseMode',
type: 'options', type: 'options',
options: [ options: [
{ {
@ -158,12 +158,12 @@ export class Webhook implements INodeType {
description: 'When and how to respond to the webhook.', description: 'When and how to respond to the webhook.',
}, },
{ {
displayName: 'Reponse Data', displayName: 'Response Data',
name: 'reponseData', name: 'responseData',
type: 'options', type: 'options',
displayOptions: { displayOptions: {
show: { show: {
reponseMode: [ responseMode: [
'lastNode', 'lastNode',
], ],
}, },
@ -196,7 +196,7 @@ export class Webhook implements INodeType {
default: 'data', default: 'data',
displayOptions: { displayOptions: {
show: { show: {
reponseData: [ responseData: [
'firstEntryBinary' 'firstEntryBinary'
], ],
}, },

View file

@ -462,8 +462,8 @@ export interface IWebhookDescription {
name: string; name: string;
path: string; path: string;
responseBinaryPropertyName?: string; responseBinaryPropertyName?: string;
reponseMode?: WebhookResponseMode | string; responseMode?: WebhookResponseMode | string;
reponseData?: WebhookResponseData | string; responseData?: WebhookResponseData | string;
} }
export type WebhookHttpMethod = 'GET' | 'POST'; export type WebhookHttpMethod = 'GET' | 'POST';

View file

@ -977,16 +977,16 @@ export class Workflow {
if (mode === 'manual') { if (mode === 'manual') {
// In manual mode we do not just start the trigger function we also // In manual mode we do not just start the trigger function we also
// want to be able to get informed as soon as the first data got emitted // want to be able to get informed as soon as the first data got emitted
const triggerReponse = await nodeType.trigger!.call(triggerFunctions); const triggerResponse = await nodeType.trigger!.call(triggerFunctions);
// Add the manual trigger response which resolves when the first time data got emitted // Add the manual trigger response which resolves when the first time data got emitted
triggerReponse!.manualTriggerResponse = new Promise((resolve) => { triggerResponse!.manualTriggerResponse = new Promise((resolve) => {
triggerFunctions.emit = ((resolve) => (data: INodeExecutionData[][]) => { triggerFunctions.emit = ((resolve) => (data: INodeExecutionData[][]) => {
resolve(data); resolve(data);
})(resolve); })(resolve);
}); });
return triggerReponse; return triggerResponse;
} else { } else {
// In all other modes simply start the trigger // In all other modes simply start the trigger
return nodeType.trigger!.call(triggerFunctions); return nodeType.trigger!.call(triggerFunctions);