mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-21 02:56:40 -08:00
refactor: Remove usless catch blocks, and add a linting rule to prevent them (no-changelog) (#12730)
This commit is contained in:
parent
4ee4552b0e
commit
202da76380
|
@ -392,13 +392,9 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
|
|||
);
|
||||
resultData.push(...serializedDocuments);
|
||||
|
||||
try {
|
||||
await args.populateVectorStore(this, embeddings, processedDocuments, itemIndex);
|
||||
await args.populateVectorStore(this, embeddings, processedDocuments, itemIndex);
|
||||
|
||||
logAiEvent(this, 'ai-vector-store-populated');
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
logAiEvent(this, 'ai-vector-store-populated');
|
||||
}
|
||||
|
||||
return [resultData];
|
||||
|
@ -443,16 +439,12 @@ export const createVectorStoreNode = (args: VectorStoreNodeConstructorArgs) =>
|
|||
|
||||
resultData.push(...serializedDocuments);
|
||||
|
||||
try {
|
||||
// Use ids option to upsert instead of insert
|
||||
await vectorStore.addDocuments(processedDocuments, {
|
||||
ids: [documentId],
|
||||
});
|
||||
// Use ids option to upsert instead of insert
|
||||
await vectorStore.addDocuments(processedDocuments, {
|
||||
ids: [documentId],
|
||||
});
|
||||
|
||||
logAiEvent(this, 'ai-vector-store-updated');
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
logAiEvent(this, 'ai-vector-store-updated');
|
||||
}
|
||||
|
||||
return [resultData];
|
||||
|
|
|
@ -369,6 +369,8 @@ const config = (module.exports = {
|
|||
|
||||
'n8n-local-rules/no-unused-param-in-catch-clause': 'error',
|
||||
|
||||
'n8n-local-rules/no-useless-catch-throw': 'error',
|
||||
|
||||
'n8n-local-rules/no-plain-errors': 'error',
|
||||
|
||||
// ******************************************************************
|
||||
|
|
|
@ -172,6 +172,49 @@ module.exports = {
|
|||
},
|
||||
},
|
||||
|
||||
'no-useless-catch-throw': {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
docs: {
|
||||
description: 'Disallow `try-catch` blocks where the `catch` only contains a `throw error`.',
|
||||
recommended: 'error',
|
||||
},
|
||||
messages: {
|
||||
noUselessCatchThrow: 'Remove useless `catch` block.',
|
||||
},
|
||||
fixable: 'code',
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
CatchClause(node) {
|
||||
if (
|
||||
node.body.body.length === 1 &&
|
||||
node.body.body[0].type === 'ThrowStatement' &&
|
||||
node.body.body[0].argument.type === 'Identifier' &&
|
||||
node.body.body[0].argument.name === node.param.name
|
||||
) {
|
||||
context.report({
|
||||
node,
|
||||
messageId: 'noUselessCatchThrow',
|
||||
fix(fixer) {
|
||||
const tryStatement = node.parent;
|
||||
const tryBlock = tryStatement.block;
|
||||
const sourceCode = context.getSourceCode();
|
||||
const tryBlockText = sourceCode.getText(tryBlock);
|
||||
const tryBlockTextWithoutBraces = tryBlockText.slice(1, -1).trim();
|
||||
const indentedTryBlockText = tryBlockTextWithoutBraces
|
||||
.split('\n')
|
||||
.map((line) => line.replace(/\t/, ''))
|
||||
.join('\n');
|
||||
return fixer.replaceText(tryStatement, indentedTryBlockText);
|
||||
},
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
|
||||
'no-skipped-tests': {
|
||||
meta: {
|
||||
type: 'problem',
|
||||
|
|
|
@ -51,3 +51,33 @@ ruleTester.run('no-json-parse-json-stringify', rules['no-json-parse-json-stringi
|
|||
},
|
||||
],
|
||||
});
|
||||
|
||||
ruleTester.run('no-useless-catch-throw', rules['no-useless-catch-throw'], {
|
||||
valid: [
|
||||
{
|
||||
code: 'try { foo(); } catch (e) { console.error(e); }',
|
||||
},
|
||||
{
|
||||
code: 'try { foo(); } catch (e) { throw new Error("Custom error"); }',
|
||||
},
|
||||
],
|
||||
invalid: [
|
||||
{
|
||||
code: `
|
||||
try {
|
||||
// Some comment
|
||||
if (foo) {
|
||||
bar();
|
||||
}
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}`,
|
||||
errors: [{ messageId: 'noUselessCatchThrow' }],
|
||||
output: `
|
||||
// Some comment
|
||||
if (foo) {
|
||||
bar();
|
||||
}`,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
|
@ -161,28 +161,24 @@ export function reducePayloadSizeOrThrow(
|
|||
error: Error,
|
||||
averageTokenLength = 4,
|
||||
) {
|
||||
try {
|
||||
let remainingTokensToReduce = calculateRemainingTokens(error);
|
||||
let remainingTokensToReduce = calculateRemainingTokens(error);
|
||||
|
||||
const [remaining, parentNodesTokenCount] = trimParentNodesSchema(
|
||||
payload,
|
||||
remainingTokensToReduce,
|
||||
averageTokenLength,
|
||||
);
|
||||
const [remaining, parentNodesTokenCount] = trimParentNodesSchema(
|
||||
payload,
|
||||
remainingTokensToReduce,
|
||||
averageTokenLength,
|
||||
);
|
||||
|
||||
remainingTokensToReduce = remaining;
|
||||
remainingTokensToReduce = remaining;
|
||||
|
||||
remainingTokensToReduce = trimInputSchemaProperties(
|
||||
payload,
|
||||
remainingTokensToReduce,
|
||||
averageTokenLength,
|
||||
parentNodesTokenCount,
|
||||
);
|
||||
remainingTokensToReduce = trimInputSchemaProperties(
|
||||
payload,
|
||||
remainingTokensToReduce,
|
||||
averageTokenLength,
|
||||
parentNodesTokenCount,
|
||||
);
|
||||
|
||||
if (remainingTokensToReduce > 0) throw error;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
if (remainingTokensToReduce > 0) throw error;
|
||||
}
|
||||
|
||||
export async function generateCodeForAiTransform(prompt: string, path: string, retries = 1) {
|
||||
|
|
|
@ -200,29 +200,25 @@ async function createExecutionPromise() {
|
|||
}
|
||||
|
||||
async function onRunChatWorkflow(payload: RunWorkflowChatPayload) {
|
||||
try {
|
||||
const runWorkflowOptions: Parameters<typeof runWorkflow>[0] = {
|
||||
triggerNode: payload.triggerNode,
|
||||
nodeData: payload.nodeData,
|
||||
source: payload.source,
|
||||
};
|
||||
const runWorkflowOptions: Parameters<typeof runWorkflow>[0] = {
|
||||
triggerNode: payload.triggerNode,
|
||||
nodeData: payload.nodeData,
|
||||
source: payload.source,
|
||||
};
|
||||
|
||||
if (workflowsStore.chatPartialExecutionDestinationNode) {
|
||||
runWorkflowOptions.destinationNode = workflowsStore.chatPartialExecutionDestinationNode;
|
||||
workflowsStore.chatPartialExecutionDestinationNode = null;
|
||||
}
|
||||
|
||||
const response = await runWorkflow(runWorkflowOptions);
|
||||
|
||||
if (response) {
|
||||
await createExecutionPromise();
|
||||
workflowsStore.appendChatMessage(payload.message);
|
||||
return response;
|
||||
}
|
||||
return;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
if (workflowsStore.chatPartialExecutionDestinationNode) {
|
||||
runWorkflowOptions.destinationNode = workflowsStore.chatPartialExecutionDestinationNode;
|
||||
workflowsStore.chatPartialExecutionDestinationNode = null;
|
||||
}
|
||||
|
||||
const response = await runWorkflow(runWorkflowOptions);
|
||||
|
||||
if (response) {
|
||||
await createExecutionPromise();
|
||||
workflowsStore.appendChatMessage(payload.message);
|
||||
return response;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize chat config
|
||||
|
|
|
@ -55,21 +55,13 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
|||
};
|
||||
|
||||
const installPackage = async (packageName: string): Promise<void> => {
|
||||
try {
|
||||
await communityNodesApi.installNewPackage(rootStore.restApiContext, packageName);
|
||||
await fetchInstalledPackages();
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
await communityNodesApi.installNewPackage(rootStore.restApiContext, packageName);
|
||||
await fetchInstalledPackages();
|
||||
};
|
||||
|
||||
const uninstallPackage = async (packageName: string): Promise<void> => {
|
||||
try {
|
||||
await communityNodesApi.uninstallPackage(rootStore.restApiContext, packageName);
|
||||
removePackageByName(packageName);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
await communityNodesApi.uninstallPackage(rootStore.restApiContext, packageName);
|
||||
removePackageByName(packageName);
|
||||
};
|
||||
|
||||
const removePackageByName = (name: string): void => {
|
||||
|
@ -82,16 +74,12 @@ export const useCommunityNodesStore = defineStore(STORES.COMMUNITY_NODES, () =>
|
|||
};
|
||||
|
||||
const updatePackage = async (packageName: string): Promise<void> => {
|
||||
try {
|
||||
const packageToUpdate = installedPackages.value[packageName];
|
||||
const updatedPackage = await communityNodesApi.updatePackage(
|
||||
rootStore.restApiContext,
|
||||
packageToUpdate.packageName,
|
||||
);
|
||||
updatePackageObject(updatedPackage);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const packageToUpdate = installedPackages.value[packageName];
|
||||
const updatedPackage = await communityNodesApi.updatePackage(
|
||||
rootStore.restApiContext,
|
||||
packageToUpdate.packageName,
|
||||
);
|
||||
updatePackageObject(updatedPackage);
|
||||
};
|
||||
|
||||
return {
|
||||
|
|
|
@ -173,8 +173,6 @@ export const useExecutionsStore = defineStore('executions', () => {
|
|||
executionsCount.value = data.count;
|
||||
executionsCountEstimated.value = data.estimated;
|
||||
return data;
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
|
|
|
@ -601,16 +601,12 @@ export class Disqus implements INodeType {
|
|||
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
const responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject[]),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getPosts') {
|
||||
// ----------------------------------
|
||||
// getPosts
|
||||
|
@ -629,28 +625,24 @@ export class Disqus implements INodeType {
|
|||
qs.forum = id;
|
||||
qs.limit = 100;
|
||||
|
||||
try {
|
||||
let responseData: IDataObject = {};
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
let responseData: IDataObject = {};
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getCategories') {
|
||||
// ----------------------------------
|
||||
// getCategories
|
||||
|
@ -668,34 +660,30 @@ export class Disqus implements INodeType {
|
|||
qs.forum = id;
|
||||
qs.limit = 100;
|
||||
|
||||
try {
|
||||
let responseData: IDataObject = {};
|
||||
let responseData: IDataObject = {};
|
||||
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = (await disqusApiRequest.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
)) as IDataObject;
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = (await disqusApiRequest.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
)) as IDataObject;
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else if (operation === 'getThreads') {
|
||||
// ----------------------------------
|
||||
// getThreads
|
||||
|
@ -715,28 +703,24 @@ export class Disqus implements INodeType {
|
|||
|
||||
Object.assign(qs, additionalFields);
|
||||
|
||||
try {
|
||||
let responseData: IDataObject = {};
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
let responseData: IDataObject = {};
|
||||
if (returnAll) {
|
||||
responseData.response = await disqusApiRequestAllItems.call(
|
||||
this,
|
||||
requestMethod,
|
||||
qs,
|
||||
endpoint,
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} else {
|
||||
const limit = this.getNodeParameter('limit', i);
|
||||
qs.limit = limit;
|
||||
responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint);
|
||||
}
|
||||
const executionData = this.helpers.constructExecutionMetaData(
|
||||
this.helpers.returnJsonArray(responseData.response as IDataObject),
|
||||
{ itemData: { item: i } },
|
||||
);
|
||||
returnData.push(...executionData);
|
||||
} else {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
|
|
|
@ -66,14 +66,10 @@ export async function disqusApiRequestAllItems(
|
|||
|
||||
let responseData;
|
||||
|
||||
try {
|
||||
do {
|
||||
responseData = await disqusApiRequest.call(this, method, qs, uri, body, option);
|
||||
qs.cursor = responseData.cursor.id;
|
||||
returnData.push.apply(returnData, responseData.response as IDataObject[]);
|
||||
} while (responseData.cursor.more === true && responseData.cursor.hasNext === true);
|
||||
return returnData;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
do {
|
||||
responseData = await disqusApiRequest.call(this, method, qs, uri, body, option);
|
||||
qs.cursor = responseData.cursor.id;
|
||||
returnData.push.apply(returnData, responseData.response as IDataObject[]);
|
||||
} while (responseData.cursor.more === true && responseData.cursor.hasNext === true);
|
||||
return returnData;
|
||||
}
|
||||
|
|
|
@ -154,13 +154,8 @@ export async function getFields(this: ILoadOptionsFunctions): Promise<any> {
|
|||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
const responseData = await this.helpers.request(options);
|
||||
return responseData.response.fieldMetaData;
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
}
|
||||
const responseData = await this.helpers.request(options);
|
||||
return responseData.response.fieldMetaData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -185,13 +180,8 @@ export async function getPortals(this: ILoadOptionsFunctions): Promise<any> {
|
|||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
const responseData = await this.helpers.request(options);
|
||||
return responseData.response.portalMetaData;
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
}
|
||||
const responseData = await this.helpers.request(options);
|
||||
return responseData.response.portalMetaData;
|
||||
}
|
||||
|
||||
function parseScriptsList(scripts: ScriptObject[]): INodePropertyOptions[] {
|
||||
|
@ -230,15 +220,10 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise<any> {
|
|||
json: true,
|
||||
};
|
||||
|
||||
try {
|
||||
const responseData = await this.helpers.request(options);
|
||||
const items = parseScriptsList(responseData.response.scripts as ScriptObject[]);
|
||||
items.sort((a, b) => (a.name > b.name ? 0 : 1));
|
||||
return items;
|
||||
} catch (error) {
|
||||
// If that data does not exist for some reason return the actual error
|
||||
throw error;
|
||||
}
|
||||
const responseData = await this.helpers.request(options);
|
||||
const items = parseScriptsList(responseData.response.scripts as ScriptObject[]);
|
||||
items.sort((a, b) => (a.name > b.name ? 0 : 1));
|
||||
return items;
|
||||
}
|
||||
|
||||
export async function logout(
|
||||
|
|
|
@ -107,12 +107,8 @@ export class FlowTrigger implements INodeType {
|
|||
}
|
||||
qs.organization_id = credentials.organizationId as number;
|
||||
const endpoint = '/integration_webhooks';
|
||||
try {
|
||||
webhooks = await flowApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
webhooks = webhooks.integration_webhooks;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
webhooks = await flowApiRequest.call(this, 'GET', endpoint, {}, qs);
|
||||
webhooks = webhooks.integration_webhooks;
|
||||
for (const webhook of webhooks) {
|
||||
// @ts-ignore
|
||||
if (webhookData.webhookIds.includes(webhook.id)) {
|
||||
|
|
|
@ -16,19 +16,15 @@ export async function router(this: IExecuteFunctions): Promise<INodeExecutionDat
|
|||
operation,
|
||||
} as ItemListsType;
|
||||
|
||||
try {
|
||||
switch (itemListsNodeData.resource) {
|
||||
case 'itemList':
|
||||
returnData = await itemList[itemListsNodeData.operation].execute.call(this, items);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
switch (itemListsNodeData.resource) {
|
||||
case 'itemList':
|
||||
returnData = await itemList[itemListsNodeData.operation].execute.call(this, items);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
|
|
|
@ -214,7 +214,6 @@ export class MailchimpTrigger implements INodeType {
|
|||
},
|
||||
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
let webhook;
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const listId = this.getNodeParameter('list') as string;
|
||||
const events = this.getNodeParameter('events', []) as string[];
|
||||
|
@ -233,11 +232,7 @@ export class MailchimpTrigger implements INodeType {
|
|||
}, {}),
|
||||
};
|
||||
const endpoint = `/lists/${listId}/webhooks`;
|
||||
try {
|
||||
webhook = await mailchimpApiRequest.call(this, endpoint, 'POST', body);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const webhook = await mailchimpApiRequest.call(this, endpoint, 'POST', body);
|
||||
if (webhook.id === undefined) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -115,7 +115,6 @@ export class PayPalTrigger implements INodeType {
|
|||
},
|
||||
|
||||
async create(this: IHookFunctions): Promise<boolean> {
|
||||
let webhook;
|
||||
const webhookUrl = this.getNodeWebhookUrl('default');
|
||||
const events = this.getNodeParameter('events', []) as string[];
|
||||
const body = {
|
||||
|
@ -125,11 +124,7 @@ export class PayPalTrigger implements INodeType {
|
|||
}),
|
||||
};
|
||||
const endpoint = '/notifications/webhooks';
|
||||
try {
|
||||
webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
|
||||
if (webhook.id === undefined) {
|
||||
return false;
|
||||
|
@ -156,7 +151,6 @@ export class PayPalTrigger implements INodeType {
|
|||
};
|
||||
|
||||
async webhook(this: IWebhookFunctions): Promise<IWebhookResponseData> {
|
||||
let webhook;
|
||||
const webhookData = this.getWorkflowStaticData('node');
|
||||
const bodyData = this.getBodyData();
|
||||
const req = this.getRequestObject();
|
||||
|
@ -188,11 +182,7 @@ export class PayPalTrigger implements INodeType {
|
|||
webhook_id: webhookData.webhookId,
|
||||
webhook_event: bodyData,
|
||||
};
|
||||
try {
|
||||
webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const webhook = await payPalApiRequest.call(this, endpoint, 'POST', body);
|
||||
if (webhook.verification_status !== 'SUCCESS') {
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -877,12 +877,7 @@ export class StripeTrigger implements INodeType {
|
|||
enabled_events: events,
|
||||
};
|
||||
|
||||
let responseData;
|
||||
try {
|
||||
responseData = await stripeApiRequest.call(this, 'POST', endpoint, body);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
const responseData = await stripeApiRequest.call(this, 'POST', endpoint, body);
|
||||
|
||||
if (
|
||||
responseData.id === undefined ||
|
||||
|
|
|
@ -16,19 +16,15 @@ export async function router(this: IExecuteFunctions): Promise<INodeExecutionDat
|
|||
operation,
|
||||
} as WebflowType;
|
||||
|
||||
try {
|
||||
switch (webflowNodeData.resource) {
|
||||
case 'item':
|
||||
returnData = await item[webflowNodeData.operation].execute.call(this, items);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
} catch (error) {
|
||||
throw error;
|
||||
switch (webflowNodeData.resource) {
|
||||
case 'item':
|
||||
returnData = await item[webflowNodeData.operation].execute.call(this, items);
|
||||
break;
|
||||
default:
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`The operation "${operation}" is not supported!`,
|
||||
);
|
||||
}
|
||||
|
||||
return [returnData];
|
||||
|
|
Loading…
Reference in a new issue