mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Improve typings for webhook methods (no-changelog) (#5713)
This commit is contained in:
committed by
GitHub
parent
a28396ee91
commit
6a8c9b7ccc
@@ -110,7 +110,6 @@ export class ActiveCampaignTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -114,7 +114,6 @@ export class AcuitySchedulingTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -152,7 +152,6 @@ export class AffinityTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -112,7 +112,6 @@ export class AsanaTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -80,7 +80,6 @@ export class AutopilotTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -248,7 +248,6 @@ export class BitbucketTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -256,7 +256,6 @@ export class BoxTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -80,7 +80,6 @@ export class CalendlyTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -490,7 +490,6 @@ export class CiscoWebexTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -260,7 +260,6 @@ export class ClickUpTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -237,7 +237,6 @@ export class ConvertKitTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -100,7 +100,6 @@ export class CopperTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -219,7 +219,6 @@ export class CustomerIoTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -226,7 +226,6 @@ export class EventbriteTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -170,7 +170,6 @@ export class FacebookTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -92,7 +92,6 @@ export class FigmaTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -91,7 +91,6 @@ export class FlowTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -121,7 +121,6 @@ export class FormIoTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -98,7 +98,6 @@ export class FormstackTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -155,7 +155,6 @@ export class GetResponseTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -174,7 +174,6 @@ export class GitlabTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -83,7 +83,6 @@ export class GumroadTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -99,7 +99,6 @@ export class HelpScoutTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -287,7 +287,6 @@ export class HubspotTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -116,7 +116,6 @@ export class InvoiceNinjaTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -102,7 +102,6 @@ export class JotFormTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -85,7 +85,6 @@ export class KeapTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -89,7 +89,6 @@ export class LemlistTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -123,7 +123,6 @@ export class LinearTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
//@ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -183,7 +183,6 @@ export class MailchimpTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -106,7 +106,6 @@ export class MailerLiteTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -74,7 +74,6 @@ export class MailjetTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -125,7 +125,6 @@ export class MauticTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -48,7 +48,6 @@ export class PushcutTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -201,7 +201,6 @@ export class SendInBlueTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -119,7 +119,6 @@ export class StravaTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -142,7 +142,6 @@ export class TaigaTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -32,7 +32,6 @@ export class TheHiveTrigger implements INodeType {
|
||||
properties: [...eventsDescription],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -56,7 +56,6 @@ export class TrelloTrigger implements INodeType {
|
||||
],
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -153,7 +153,6 @@ export class TypeformTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -121,7 +121,6 @@ export class WorkableTrigger implements INodeType {
|
||||
},
|
||||
};
|
||||
|
||||
// @ts-ignore (because of request)
|
||||
webhookMethods = {
|
||||
default: {
|
||||
async checkExists(this: IHookFunctions): Promise<boolean> {
|
||||
|
||||
@@ -1163,6 +1163,8 @@ export interface ITriggerResponse {
|
||||
manualTriggerResponse?: Promise<INodeExecutionData[][]>;
|
||||
}
|
||||
|
||||
export type WebhookSetupMethodNames = 'checkExists' | 'create' | 'delete';
|
||||
|
||||
export interface INodeType {
|
||||
description: INodeTypeDescription;
|
||||
execute?(
|
||||
@@ -1172,9 +1174,6 @@ export interface INodeType {
|
||||
poll?(this: IPollFunctions): Promise<INodeExecutionData[][] | null>;
|
||||
trigger?(this: ITriggerFunctions): Promise<ITriggerResponse | undefined>;
|
||||
webhook?(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
||||
hooks?: {
|
||||
[key: string]: (this: IHookFunctions) => Promise<boolean>;
|
||||
};
|
||||
methods?: {
|
||||
loadOptions?: {
|
||||
[key: string]: (this: ILoadOptionsFunctions) => Promise<INodePropertyOptions[]>;
|
||||
@@ -1192,7 +1191,9 @@ export interface INodeType {
|
||||
};
|
||||
};
|
||||
webhookMethods?: {
|
||||
[key: string]: IWebhookSetupMethods;
|
||||
[name in IWebhookDescription['name']]?: {
|
||||
[method in WebhookSetupMethodNames]: (this: IHookFunctions) => Promise<boolean>;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1213,15 +1214,6 @@ export interface INodeCredentialTestRequest {
|
||||
credentials: ICredentialsDecrypted;
|
||||
}
|
||||
|
||||
export type WebhookSetupMethodNames = 'checkExists' | 'create' | 'delete';
|
||||
|
||||
export interface IWebhookSetupMethods {
|
||||
[key: string]: ((this: IHookFunctions) => Promise<boolean>) | undefined;
|
||||
checkExists?: (this: IHookFunctions) => Promise<boolean>;
|
||||
create?: (this: IHookFunctions) => Promise<boolean>;
|
||||
delete?: (this: IHookFunctions) => Promise<boolean>;
|
||||
}
|
||||
|
||||
export interface INodeCredentialDescription {
|
||||
name: string;
|
||||
required?: boolean;
|
||||
@@ -1436,7 +1428,7 @@ export interface IWebhookDescription {
|
||||
[key: string]: WebhookHttpMethod | WebhookResponseMode | boolean | string | undefined;
|
||||
httpMethod: WebhookHttpMethod | string;
|
||||
isFullPath?: boolean;
|
||||
name: string;
|
||||
name: 'default' | 'setup';
|
||||
path: string;
|
||||
responseBinaryPropertyName?: string;
|
||||
responseContentType?: string;
|
||||
|
||||
@@ -982,17 +982,8 @@ export class Workflow {
|
||||
const node = this.getNode(webhookData.node) as INode;
|
||||
const nodeType = this.nodeTypes.getByNameAndVersion(node.type, node.typeVersion);
|
||||
|
||||
if (nodeType.webhookMethods === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nodeType.webhookMethods[webhookData.webhookDescription.name] === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (nodeType.webhookMethods[webhookData.webhookDescription.name][method] === undefined) {
|
||||
return;
|
||||
}
|
||||
const webhookFn = nodeType.webhookMethods?.[webhookData.webhookDescription.name]?.[method];
|
||||
if (webhookFn === undefined) return;
|
||||
|
||||
const thisArgs = nodeExecuteFunctions.getExecuteHookFunctions(
|
||||
this,
|
||||
@@ -1003,8 +994,8 @@ export class Workflow {
|
||||
isTest,
|
||||
webhookData,
|
||||
);
|
||||
// eslint-disable-next-line consistent-return
|
||||
return nodeType.webhookMethods[webhookData.webhookDescription.name][method]!.call(thisArgs);
|
||||
|
||||
return webhookFn.call(thisArgs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user