mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +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' },
|
icon: { light: 'file:webhook.svg', dark: 'file:webhook.dark.svg' },
|
||||||
name: 'respondToWebhook',
|
name: 'respondToWebhook',
|
||||||
group: ['transform'],
|
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',
|
description: 'Returns data for Webhook',
|
||||||
defaults: {
|
defaults: {
|
||||||
name: 'Respond to Webhook',
|
name: 'Respond to Webhook',
|
||||||
},
|
},
|
||||||
inputs: [NodeConnectionTypes.Main],
|
inputs: [NodeConnectionTypes.Main],
|
||||||
outputs: `={{(${configuredOutputs})($nodeVersion)}}`,
|
outputs: `={{(${configuredOutputs})($nodeVersion, $parameter)}}`,
|
||||||
credentials: [
|
credentials: [
|
||||||
{
|
{
|
||||||
name: 'jwtAuth',
|
name: 'jwtAuth',
|
||||||
@@ -100,6 +100,16 @@ export class RespondToWebhook implements INodeType {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
properties: [
|
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:
|
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',
|
'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;
|
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 } }]];
|
return [items, [{ json: { response } }]];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,15 @@ import { configuredOutputs } from '../utils';
|
|||||||
|
|
||||||
describe('configuredOutputs', () => {
|
describe('configuredOutputs', () => {
|
||||||
it('returns array of objects when version >= 1.3', () => {
|
it('returns array of objects when version >= 1.3', () => {
|
||||||
const result = configuredOutputs(1.3);
|
const result = configuredOutputs(1.3, {});
|
||||||
expect(result).toEqual([
|
expect(result).toEqual([
|
||||||
{ type: 'main', displayName: 'Input Data' },
|
{ type: 'main', displayName: 'Input Data' },
|
||||||
{ type: 'main', displayName: 'Response' },
|
{ type: 'main', displayName: 'Response' },
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns array of objects when version > 1.3', () => {
|
it('returns array of objects when version > 1.4 and enableResponseOutput', () => {
|
||||||
const result = configuredOutputs(2);
|
const result = configuredOutputs(2, { enableResponseOutput: true });
|
||||||
expect(result).toEqual([
|
expect(result).toEqual([
|
||||||
{ type: 'main', displayName: 'Input Data' },
|
{ type: 'main', displayName: 'Input Data' },
|
||||||
{ type: 'main', displayName: 'Response' },
|
{ type: 'main', displayName: 'Response' },
|
||||||
@@ -18,7 +18,20 @@ describe('configuredOutputs', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('returns ["main"] when version < 1.3', () => {
|
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']);
|
expect(result).toEqual(['main']);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
export const configuredOutputs = (version: number) => {
|
export const configuredOutputs = (
|
||||||
if (version >= 1.3) {
|
version: number,
|
||||||
|
parameters: { enableResponseOutput?: boolean },
|
||||||
|
) => {
|
||||||
|
const multipleOutputs = version === 1.3 || (version >= 1.4 && parameters.enableResponseOutput);
|
||||||
|
if (multipleOutputs) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
type: 'main',
|
type: 'main',
|
||||||
|
|||||||
Reference in New Issue
Block a user