mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
feat(Respond to Webhook Node): Setting to configure outputs (#15619)
Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
This commit is contained in:
@@ -81,13 +81,13 @@ export class RespondToWebhook implements INodeType {
|
||||
icon: { light: 'file:webhook.svg', dark: 'file:webhook.dark.svg' },
|
||||
name: 'respondToWebhook',
|
||||
group: ['transform'],
|
||||
version: [1, 1.1, 1.2, 1.3],
|
||||
version: [1, 1.1, 1.2, 1.3, 1.4],
|
||||
description: 'Returns data for Webhook',
|
||||
defaults: {
|
||||
name: 'Respond to Webhook',
|
||||
},
|
||||
inputs: [NodeConnectionTypes.Main],
|
||||
outputs: `={{(${configuredOutputs})($nodeVersion)}}`,
|
||||
outputs: `={{(${configuredOutputs})($nodeVersion, $parameter)}}`,
|
||||
credentials: [
|
||||
{
|
||||
name: 'jwtAuth',
|
||||
@@ -100,6 +100,16 @@ export class RespondToWebhook implements INodeType {
|
||||
},
|
||||
],
|
||||
properties: [
|
||||
{
|
||||
displayName: 'Enable Response Output Branch',
|
||||
name: 'enableResponseOutput',
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
description:
|
||||
'Whether to provide an additional output branch with the response sent to the webhook',
|
||||
isNodeSetting: true,
|
||||
displayOptions: { show: { '@version': [{ _cnd: { gte: 1.4 } }] } },
|
||||
},
|
||||
{
|
||||
displayName:
|
||||
'Verify that the "Webhook" node\'s "Respond" parameter is set to "Using Respond to Webhook Node". <a href="https://docs.n8n.io/integrations/builtin/core-nodes/n8n-nodes-base.respondtowebhook/" target="_blank">More details',
|
||||
@@ -468,7 +478,9 @@ export class RespondToWebhook implements INodeType {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (nodeVersion >= 1.3) {
|
||||
if (nodeVersion === 1.3) {
|
||||
return [items, [{ json: { response } }]];
|
||||
} else if (nodeVersion >= 1.4 && this.getNodeParameter('enableResponseOutput', 0, false)) {
|
||||
return [items, [{ json: { response } }]];
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@ import { configuredOutputs } from '../utils';
|
||||
|
||||
describe('configuredOutputs', () => {
|
||||
it('returns array of objects when version >= 1.3', () => {
|
||||
const result = configuredOutputs(1.3);
|
||||
const result = configuredOutputs(1.3, {});
|
||||
expect(result).toEqual([
|
||||
{ type: 'main', displayName: 'Input Data' },
|
||||
{ type: 'main', displayName: 'Response' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns array of objects when version > 1.3', () => {
|
||||
const result = configuredOutputs(2);
|
||||
it('returns array of objects when version > 1.4 and enableResponseOutput', () => {
|
||||
const result = configuredOutputs(2, { enableResponseOutput: true });
|
||||
expect(result).toEqual([
|
||||
{ type: 'main', displayName: 'Input Data' },
|
||||
{ type: 'main', displayName: 'Response' },
|
||||
@@ -18,7 +18,20 @@ describe('configuredOutputs', () => {
|
||||
});
|
||||
|
||||
it('returns ["main"] when version < 1.3', () => {
|
||||
const result = configuredOutputs(1.2);
|
||||
const result = configuredOutputs(1.2, {});
|
||||
expect(result).toEqual(['main']);
|
||||
});
|
||||
|
||||
it('returns array of objects when version 1.4 and enableResponseOutput', () => {
|
||||
const result = configuredOutputs(1.4, { enableResponseOutput: true });
|
||||
expect(result).toEqual([
|
||||
{ type: 'main', displayName: 'Input Data' },
|
||||
{ type: 'main', displayName: 'Response' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('returns ["main"] when version 1.4 and !enableResponseOutput', () => {
|
||||
const result = configuredOutputs(1.4, { enableResponseOutput: false });
|
||||
expect(result).toEqual(['main']);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
export const configuredOutputs = (version: number) => {
|
||||
if (version >= 1.3) {
|
||||
export const configuredOutputs = (
|
||||
version: number,
|
||||
parameters: { enableResponseOutput?: boolean },
|
||||
) => {
|
||||
const multipleOutputs = version === 1.3 || (version >= 1.4 && parameters.enableResponseOutput);
|
||||
if (multipleOutputs) {
|
||||
return [
|
||||
{
|
||||
type: 'main',
|
||||
|
||||
Reference in New Issue
Block a user