refactor: Improve typings for webhook methods (no-changelog) (#5713)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-03-17 12:25:31 +01:00
committed by GitHub
parent a28396ee91
commit 6a8c9b7ccc
43 changed files with 10 additions and 68 deletions

View File

@@ -110,7 +110,6 @@ export class ActiveCampaignTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -114,7 +114,6 @@ export class AcuitySchedulingTrigger implements INodeType {
],
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -152,7 +152,6 @@ export class AffinityTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -112,7 +112,6 @@ export class AsanaTrigger implements INodeType {
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -80,7 +80,6 @@ export class AutopilotTrigger implements INodeType {
],
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -248,7 +248,6 @@ export class BitbucketTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -256,7 +256,6 @@ export class BoxTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -80,7 +80,6 @@ export class CalendlyTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -490,7 +490,6 @@ export class CiscoWebexTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -260,7 +260,6 @@ export class ClickUpTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -237,7 +237,6 @@ export class ConvertKitTrigger implements INodeType {
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -100,7 +100,6 @@ export class CopperTrigger implements INodeType {
],
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -219,7 +219,6 @@ export class CustomerIoTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -226,7 +226,6 @@ export class EventbriteTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -170,7 +170,6 @@ export class FacebookTrigger implements INodeType {
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -92,7 +92,6 @@ export class FigmaTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -91,7 +91,6 @@ export class FlowTrigger implements INodeType {
],
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -121,7 +121,6 @@ export class FormIoTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -98,7 +98,6 @@ export class FormstackTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -155,7 +155,6 @@ export class GetResponseTrigger implements INodeType {
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -174,7 +174,6 @@ export class GitlabTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -83,7 +83,6 @@ export class GumroadTrigger implements INodeType {
],
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -99,7 +99,6 @@ export class HelpScoutTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -287,7 +287,6 @@ export class HubspotTrigger implements INodeType {
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -116,7 +116,6 @@ export class InvoiceNinjaTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -102,7 +102,6 @@ export class JotFormTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -85,7 +85,6 @@ export class KeapTrigger implements INodeType {
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -89,7 +89,6 @@ export class LemlistTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -123,7 +123,6 @@ export class LinearTrigger implements INodeType {
},
};
//@ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -183,7 +183,6 @@ export class MailchimpTrigger implements INodeType {
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -106,7 +106,6 @@ export class MailerLiteTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -74,7 +74,6 @@ export class MailjetTrigger implements INodeType {
],
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -125,7 +125,6 @@ export class MauticTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -48,7 +48,6 @@ export class PushcutTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -201,7 +201,6 @@ export class SendInBlueTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -119,7 +119,6 @@ export class StravaTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -142,7 +142,6 @@ export class TaigaTrigger implements INodeType {
},
};
// @ts-ignore
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -32,7 +32,6 @@ export class TheHiveTrigger implements INodeType {
properties: [...eventsDescription],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -56,7 +56,6 @@ export class TrelloTrigger implements INodeType {
],
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -153,7 +153,6 @@ export class TypeformTrigger implements INodeType {
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -121,7 +121,6 @@ export class WorkableTrigger implements INodeType {
},
};
// @ts-ignore (because of request)
webhookMethods = {
default: {
async checkExists(this: IHookFunctions): Promise<boolean> {

View File

@@ -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;

View File

@@ -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);
}
/**