n8n 1.103.0 → 1.103.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.tsbuildinfo +1 -1
- package/dist/webhooks/webhook-execution-context.d.ts +11 -0
- package/dist/webhooks/webhook-execution-context.js +20 -0
- package/dist/webhooks/webhook-execution-context.js.map +1 -0
- package/dist/webhooks/webhook-helpers.d.ts +3 -3
- package/dist/webhooks/webhook-helpers.js +51 -123
- package/dist/webhooks/webhook-helpers.js.map +1 -1
- package/dist/webhooks/webhook-last-node-response-extractor.d.ts +16 -0
- package/dist/webhooks/webhook-last-node-response-extractor.js +89 -0
- package/dist/webhooks/webhook-last-node-response-extractor.js.map +1 -0
- package/dist/webhooks/webhook-on-received-response-extractor.d.ts +2 -0
- package/dist/webhooks/webhook-on-received-response-extractor.js +16 -0
- package/dist/webhooks/webhook-on-received-response-extractor.js.map +1 -0
- package/dist/webhooks/webhook-request-handler.js +67 -3
- package/dist/webhooks/webhook-request-handler.js.map +1 -1
- package/dist/webhooks/webhook-response.d.ts +26 -0
- package/dist/webhooks/webhook-response.js +45 -0
- package/dist/webhooks/webhook-response.js.map +1 -0
- package/dist/webhooks/webhook.types.d.ts +7 -0
- package/package.json +10 -10
|
@@ -36,10 +36,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.createWebhookHandlerFor = createWebhookHandlerFor;
|
|
37
37
|
const backend_common_1 = require("@n8n/backend-common");
|
|
38
38
|
const di_1 = require("@n8n/di");
|
|
39
|
+
const n8n_core_1 = require("n8n-core");
|
|
39
40
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
41
|
+
const promises_1 = require("stream/promises");
|
|
42
|
+
const webhook_service_1 = require("./webhook.service");
|
|
40
43
|
const webhook_not_found_error_1 = require("../errors/response-errors/webhook-not-found.error");
|
|
41
44
|
const ResponseHelper = __importStar(require("../response-helper"));
|
|
42
|
-
const
|
|
45
|
+
const webhook_response_1 = require("../webhooks/webhook-response");
|
|
43
46
|
const WEBHOOK_METHODS = ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT'];
|
|
44
47
|
class WebhookRequestHandler {
|
|
45
48
|
constructor(webhookManager) {
|
|
@@ -61,8 +64,13 @@ class WebhookRequestHandler {
|
|
|
61
64
|
}
|
|
62
65
|
try {
|
|
63
66
|
const response = await this.webhookManager.executeWebhook(req, res);
|
|
64
|
-
if (
|
|
65
|
-
|
|
67
|
+
if ((0, webhook_response_1.isWebhookResponse)(response)) {
|
|
68
|
+
await this.sendWebhookResponse(res, response);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
if (response.noWebhookResponse !== true) {
|
|
72
|
+
ResponseHelper.sendSuccessResponse(res, response.data, true, response.responseCode, response.headers);
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
}
|
|
68
76
|
catch (e) {
|
|
@@ -80,6 +88,62 @@ class WebhookRequestHandler {
|
|
|
80
88
|
return ResponseHelper.sendErrorResponse(res, error);
|
|
81
89
|
}
|
|
82
90
|
}
|
|
91
|
+
async sendWebhookResponse(res, webhookResponse) {
|
|
92
|
+
if ((0, webhook_response_1.isWebhookNoResponse)(webhookResponse)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
if ((0, webhook_response_1.isWebhookStaticResponse)(webhookResponse)) {
|
|
96
|
+
this.sendStaticResponse(res, webhookResponse);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if ((0, webhook_response_1.isWebhookStreamResponse)(webhookResponse)) {
|
|
100
|
+
await this.sendStreamResponse(res, webhookResponse);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
async sendStreamResponse(res, webhookResponse) {
|
|
105
|
+
const { stream, code, headers } = webhookResponse;
|
|
106
|
+
this.setResponseStatus(res, code);
|
|
107
|
+
this.setResponseHeaders(res, headers);
|
|
108
|
+
const contentType = res.getHeader('content-type');
|
|
109
|
+
const needsSandbox = contentType && (0, n8n_core_1.isHtmlRenderedContentType)(contentType);
|
|
110
|
+
const streamToSend = needsSandbox ? stream.pipe((0, n8n_core_1.createHtmlSandboxTransformStream)()) : stream;
|
|
111
|
+
streamToSend.pipe(res, { end: false });
|
|
112
|
+
await (0, promises_1.finished)(streamToSend);
|
|
113
|
+
process.nextTick(() => res.end());
|
|
114
|
+
}
|
|
115
|
+
sendStaticResponse(res, webhookResponse) {
|
|
116
|
+
const { body, code, headers } = webhookResponse;
|
|
117
|
+
this.setResponseStatus(res, code);
|
|
118
|
+
this.setResponseHeaders(res, headers);
|
|
119
|
+
const contentType = res.getHeader('content-type');
|
|
120
|
+
if (typeof body === 'string') {
|
|
121
|
+
const needsSandbox = !contentType || (0, n8n_core_1.isHtmlRenderedContentType)(contentType);
|
|
122
|
+
const bodyToSend = needsSandbox ? (0, n8n_core_1.sandboxHtmlResponse)(body) : body;
|
|
123
|
+
res.send(bodyToSend);
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
const needsSandbox = contentType && (0, n8n_core_1.isHtmlRenderedContentType)(contentType);
|
|
127
|
+
if (needsSandbox) {
|
|
128
|
+
res.send((0, n8n_core_1.sandboxHtmlResponse)(JSON.stringify(body)));
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
res.json(body);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
setResponseStatus(res, statusCode) {
|
|
136
|
+
if (statusCode !== undefined) {
|
|
137
|
+
res.status(statusCode);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
setResponseHeaders(res, headers) {
|
|
141
|
+
if (headers) {
|
|
142
|
+
for (const [name, value] of headers.entries()) {
|
|
143
|
+
res.setHeader(name, value);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
83
147
|
async setupCorsHeaders(req, res) {
|
|
84
148
|
const method = req.method;
|
|
85
149
|
const { path } = req.params;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhook-request-handler.js","sourceRoot":"","sources":["../../src/webhooks/webhook-request-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"webhook-request-handler.js","sourceRoot":"","sources":["../../src/webhooks/webhook-request-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoOA,0DAUC;AA9OD,wDAA6C;AAC7C,gCAAoC;AAEpC,uCAIkB;AAClB,+CAAqE;AACrE,8CAA2C;AAE3C,uDAAmD;AAEnD,8FAAwF;AACxF,kEAAoD;AAMpD,kEAKqC;AAQrC,MAAM,eAAe,GAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;AAEjG,MAAM,qBAAqB;IAC1B,YAA6B,cAA+B;QAA/B,mBAAc,GAAd,cAAc,CAAiB;IAAG,CAAC;IAMhE,KAAK,CAAC,aAAa,CAAC,GAA2C,EAAE,GAAqB;QACrF,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC;QAE1B,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,eAAe,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC/D,OAAO,cAAc,CAAC,iBAAiB,CACtC,GAAG,EACH,IAAI,KAAK,CAAC,cAAc,MAAM,oBAAoB,CAAC,CACnD,CAAC;QACH,CAAC;QAGD,IAAI,QAAQ,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;YAC7B,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAC7D,IAAI,cAAc,EAAE,CAAC;gBACpB,OAAO,cAAc,CAAC,iBAAiB,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;YAC9D,CAAC;QACF,CAAC;QAED,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC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AM,EAAE,GAAG,GAAG,CAAC;QACvB,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;YAChC,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACrC,CAAC;QACD,MAAM,OAAO,CAAC,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACvC,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Readable } from 'stream';
|
|
2
|
+
import type { WebhookResponseHeaders } from './webhook.types';
|
|
3
|
+
export declare const WebhookResponseTag: unique symbol;
|
|
4
|
+
export type WebhookNoResponse = {
|
|
5
|
+
[WebhookResponseTag]: 'noResponse';
|
|
6
|
+
};
|
|
7
|
+
export type WebhookStaticResponse = {
|
|
8
|
+
[WebhookResponseTag]: 'static';
|
|
9
|
+
body: unknown;
|
|
10
|
+
headers: WebhookResponseHeaders | undefined;
|
|
11
|
+
code: number | undefined;
|
|
12
|
+
};
|
|
13
|
+
export type WebhookResponseStream = {
|
|
14
|
+
[WebhookResponseTag]: 'stream';
|
|
15
|
+
stream: Readable;
|
|
16
|
+
code: number | undefined;
|
|
17
|
+
headers: WebhookResponseHeaders | undefined;
|
|
18
|
+
};
|
|
19
|
+
export type WebhookResponse = WebhookNoResponse | WebhookStaticResponse | WebhookResponseStream;
|
|
20
|
+
export declare const isWebhookResponse: (response: unknown) => response is WebhookResponse;
|
|
21
|
+
export declare const isWebhookNoResponse: (response: unknown) => response is WebhookNoResponse;
|
|
22
|
+
export declare const isWebhookStaticResponse: (response: unknown) => response is WebhookStaticResponse;
|
|
23
|
+
export declare const isWebhookStreamResponse: (response: unknown) => response is WebhookResponseStream;
|
|
24
|
+
export declare const createNoResponse: () => WebhookNoResponse;
|
|
25
|
+
export declare const createStaticResponse: (body: unknown, code: number | undefined, headers: WebhookResponseHeaders | undefined) => WebhookStaticResponse;
|
|
26
|
+
export declare const createStreamResponse: (stream: Readable, code: number | undefined, headers: WebhookResponseHeaders | undefined) => WebhookResponseStream;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createStreamResponse = exports.createStaticResponse = exports.createNoResponse = exports.isWebhookStreamResponse = exports.isWebhookStaticResponse = exports.isWebhookNoResponse = exports.isWebhookResponse = exports.WebhookResponseTag = void 0;
|
|
4
|
+
exports.WebhookResponseTag = Symbol('WebhookResponse');
|
|
5
|
+
const isWebhookResponse = (response) => {
|
|
6
|
+
return typeof response === 'object' && response !== null && exports.WebhookResponseTag in response;
|
|
7
|
+
};
|
|
8
|
+
exports.isWebhookResponse = isWebhookResponse;
|
|
9
|
+
const isWebhookNoResponse = (response) => {
|
|
10
|
+
return (0, exports.isWebhookResponse)(response) && response[exports.WebhookResponseTag] === 'noResponse';
|
|
11
|
+
};
|
|
12
|
+
exports.isWebhookNoResponse = isWebhookNoResponse;
|
|
13
|
+
const isWebhookStaticResponse = (response) => {
|
|
14
|
+
return (0, exports.isWebhookResponse)(response) && response[exports.WebhookResponseTag] === 'static';
|
|
15
|
+
};
|
|
16
|
+
exports.isWebhookStaticResponse = isWebhookStaticResponse;
|
|
17
|
+
const isWebhookStreamResponse = (response) => {
|
|
18
|
+
return (0, exports.isWebhookResponse)(response) && response[exports.WebhookResponseTag] === 'stream';
|
|
19
|
+
};
|
|
20
|
+
exports.isWebhookStreamResponse = isWebhookStreamResponse;
|
|
21
|
+
const createNoResponse = () => {
|
|
22
|
+
return {
|
|
23
|
+
[exports.WebhookResponseTag]: 'noResponse',
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
exports.createNoResponse = createNoResponse;
|
|
27
|
+
const createStaticResponse = (body, code, headers) => {
|
|
28
|
+
return {
|
|
29
|
+
[exports.WebhookResponseTag]: 'static',
|
|
30
|
+
body,
|
|
31
|
+
code,
|
|
32
|
+
headers,
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
exports.createStaticResponse = createStaticResponse;
|
|
36
|
+
const createStreamResponse = (stream, code, headers) => {
|
|
37
|
+
return {
|
|
38
|
+
[exports.WebhookResponseTag]: 'stream',
|
|
39
|
+
stream,
|
|
40
|
+
code,
|
|
41
|
+
headers,
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
exports.createStreamResponse = createStreamResponse;
|
|
45
|
+
//# sourceMappingURL=webhook-response.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhook-response.js","sourceRoot":"","sources":["../../src/webhooks/webhook-response.ts"],"names":[],"mappings":";;;AAIa,QAAA,kBAAkB,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAgCrD,MAAM,iBAAiB,GAAG,CAAC,QAAiB,EAA+B,EAAE;IACnF,OAAO,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,IAAI,0BAAkB,IAAI,QAAQ,CAAC;AAC5F,CAAC,CAAC;AAFW,QAAA,iBAAiB,qBAE5B;AAEK,MAAM,mBAAmB,GAAG,CAAC,QAAiB,EAAiC,EAAE;IACvF,OAAO,IAAA,yBAAiB,EAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,0BAAkB,CAAC,KAAK,YAAY,CAAC;AACrF,CAAC,CAAC;AAFW,QAAA,mBAAmB,uBAE9B;AAEK,MAAM,uBAAuB,GAAG,CAAC,QAAiB,EAAqC,EAAE;IAC/F,OAAO,IAAA,yBAAiB,EAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,0BAAkB,CAAC,KAAK,QAAQ,CAAC;AACjF,CAAC,CAAC;AAFW,QAAA,uBAAuB,2BAElC;AAEK,MAAM,uBAAuB,GAAG,CAAC,QAAiB,EAAqC,EAAE;IAC/F,OAAO,IAAA,yBAAiB,EAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,0BAAkB,CAAC,KAAK,QAAQ,CAAC;AACjF,CAAC,CAAC;AAFW,QAAA,uBAAuB,2BAElC;AAEK,MAAM,gBAAgB,GAAG,GAAsB,EAAE;IACvD,OAAO;QACN,CAAC,0BAAkB,CAAC,EAAE,YAAY;KAClC,CAAC;AACH,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B;AAEK,MAAM,oBAAoB,GAAG,CACnC,IAAa,EACb,IAAwB,EACxB,OAA2C,EACnB,EAAE;IAC1B,OAAO;QACN,CAAC,0BAAkB,CAAC,EAAE,QAAQ;QAC9B,IAAI;QACJ,IAAI;QACJ,OAAO;KACP,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,oBAAoB,wBAW/B;AAEK,MAAM,oBAAoB,GAAG,CACnC,MAAgB,EAChB,IAAwB,EACxB,OAA2C,EACnB,EAAE;IAC1B,OAAO;QACN,CAAC,0BAAkB,CAAC,EAAE,QAAQ;QAC9B,MAAM;QACN,IAAI;QACJ,OAAO;KACP,CAAC;AACH,CAAC,CAAC;AAXW,QAAA,oBAAoB,wBAW/B"}
|
|
@@ -29,3 +29,10 @@ export interface IWebhookResponseCallbackData {
|
|
|
29
29
|
responseCode?: number;
|
|
30
30
|
}
|
|
31
31
|
export type Method = NonNullable<IHttpRequestMethods>;
|
|
32
|
+
export type WebhookResponseHeaders = Map<string, string>;
|
|
33
|
+
export type WebhookNodeResponseHeaders = {
|
|
34
|
+
entries?: Array<{
|
|
35
|
+
name: string;
|
|
36
|
+
value: string;
|
|
37
|
+
}>;
|
|
38
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "n8n",
|
|
3
|
-
"version": "1.103.
|
|
3
|
+
"version": "1.103.2",
|
|
4
4
|
"description": "n8n Workflow Automation Tool",
|
|
5
5
|
"main": "dist/index",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -140,23 +140,23 @@
|
|
|
140
140
|
"yargs-parser": "21.1.1",
|
|
141
141
|
"zod": "3.25.67",
|
|
142
142
|
"@n8n/ai-workflow-builder": "0.13.0",
|
|
143
|
-
"@n8n/api-types": "0.37.0",
|
|
144
143
|
"@n8n/backend-common": "^0.13.0",
|
|
144
|
+
"@n8n/api-types": "0.37.0",
|
|
145
145
|
"@n8n/client-oauth2": "0.27.0",
|
|
146
146
|
"@n8n/config": "1.46.0",
|
|
147
147
|
"@n8n/constants": "^0.9.0",
|
|
148
|
-
"@n8n/db": "^0.14.
|
|
148
|
+
"@n8n/db": "^0.14.1",
|
|
149
149
|
"@n8n/decorators": "0.13.0",
|
|
150
150
|
"@n8n/di": "0.8.0",
|
|
151
|
-
"@n8n/backend-test-utils": "^0.6.0",
|
|
152
151
|
"@n8n/errors": "0.2.0",
|
|
152
|
+
"@n8n/backend-test-utils": "^0.6.0",
|
|
153
153
|
"@n8n/permissions": "0.30.0",
|
|
154
|
-
"@n8n/n8n-nodes-langchain": "1.102.
|
|
155
|
-
"
|
|
156
|
-
"n8n-editor-ui": "1.103.
|
|
157
|
-
"n8n-
|
|
158
|
-
"n8n-
|
|
159
|
-
"n8n-
|
|
154
|
+
"@n8n/n8n-nodes-langchain": "1.102.1",
|
|
155
|
+
"n8n-core": "1.102.1",
|
|
156
|
+
"n8n-editor-ui": "1.103.1",
|
|
157
|
+
"@n8n/task-runner": "1.39.1",
|
|
158
|
+
"n8n-workflow": "1.100.0",
|
|
159
|
+
"n8n-nodes-base": "1.101.0"
|
|
160
160
|
},
|
|
161
161
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
162
162
|
"homepage": "https://n8n.io",
|