n8n-nodes-custom-webhook-wait 1.0.5 → 1.0.7
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.
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
|
|
1
|
+
import { IExecuteFunctions, INodeExecutionData, INodeType, INodeTypeDescription, IWebhookFunctions, IWebhookResponseData } from 'n8n-workflow';
|
|
2
2
|
export declare class WebhookWait implements INodeType {
|
|
3
3
|
description: INodeTypeDescription;
|
|
4
4
|
webhook(this: IWebhookFunctions): Promise<IWebhookResponseData>;
|
|
5
|
+
execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]>;
|
|
5
6
|
}
|
|
@@ -7,10 +7,10 @@ class WebhookWait {
|
|
|
7
7
|
displayName: 'Webhook Wait',
|
|
8
8
|
name: 'webhookWait',
|
|
9
9
|
icon: 'fa:pause-circle',
|
|
10
|
-
group: ['
|
|
10
|
+
group: ['transform'],
|
|
11
11
|
version: 1,
|
|
12
12
|
subtitle: '={{$parameter["httpMethod"] + ": /" + $parameter["path"]}}',
|
|
13
|
-
description: 'Pauses workflow execution and waits for a webhook call to
|
|
13
|
+
description: 'Pauses workflow execution and waits for a webhook call to resume. Uses a static URL.',
|
|
14
14
|
defaults: {
|
|
15
15
|
name: 'Webhook Wait',
|
|
16
16
|
},
|
|
@@ -22,18 +22,26 @@ class WebhookWait {
|
|
|
22
22
|
httpMethod: '={{$parameter["httpMethod"]}}',
|
|
23
23
|
responseMode: 'onReceived',
|
|
24
24
|
path: '={{$parameter["path"]}}',
|
|
25
|
-
restartWebhook:
|
|
25
|
+
restartWebhook: true,
|
|
26
26
|
},
|
|
27
27
|
],
|
|
28
28
|
properties: [
|
|
29
|
+
{
|
|
30
|
+
displayName: 'Webhook URL',
|
|
31
|
+
name: 'notice',
|
|
32
|
+
type: 'notice',
|
|
33
|
+
default: '',
|
|
34
|
+
// eslint-disable-next-line n8n-nodes-base/node-param-description-unencoded-angle-brackets
|
|
35
|
+
description: 'When waiting, call this URL to resume:<br><br><strong>{{ $execution.resumeUrl }}/{{ $parameter["path"] }}</strong><br><br>The full URL is only available during execution. Copy it from the execution panel when the workflow is waiting.',
|
|
36
|
+
},
|
|
29
37
|
{
|
|
30
38
|
displayName: 'Path',
|
|
31
39
|
name: 'path',
|
|
32
40
|
type: 'string',
|
|
33
|
-
default: '
|
|
41
|
+
default: '',
|
|
34
42
|
placeholder: 'my-webhook-path',
|
|
35
43
|
required: true,
|
|
36
|
-
description: 'The
|
|
44
|
+
description: 'The webhook path suffix appended to the resume URL',
|
|
37
45
|
},
|
|
38
46
|
{
|
|
39
47
|
displayName: 'HTTP Method',
|
|
@@ -93,6 +101,25 @@ class WebhookWait {
|
|
|
93
101
|
default: '{"status": "ok"}',
|
|
94
102
|
description: 'Custom JSON response to send back',
|
|
95
103
|
},
|
|
104
|
+
{
|
|
105
|
+
displayName: 'Limit Wait Time',
|
|
106
|
+
name: 'limitWaitTime',
|
|
107
|
+
type: 'boolean',
|
|
108
|
+
default: false,
|
|
109
|
+
description: 'Whether to limit how long the workflow will wait',
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
displayName: 'Max Wait Time',
|
|
113
|
+
name: 'maxWaitTime',
|
|
114
|
+
type: 'number',
|
|
115
|
+
displayOptions: {
|
|
116
|
+
show: {
|
|
117
|
+
limitWaitTime: [true],
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
default: 60,
|
|
121
|
+
description: 'Maximum time to wait in minutes',
|
|
122
|
+
},
|
|
96
123
|
],
|
|
97
124
|
};
|
|
98
125
|
}
|
|
@@ -103,18 +130,21 @@ class WebhookWait {
|
|
|
103
130
|
// Prepare the webhook data to pass to the next node
|
|
104
131
|
const webhookData = {
|
|
105
132
|
json: {
|
|
133
|
+
body: req.body,
|
|
106
134
|
headers: req.headers,
|
|
107
|
-
params: req.params,
|
|
108
135
|
query: req.query,
|
|
109
|
-
|
|
110
|
-
method: req.method,
|
|
136
|
+
params: req.params,
|
|
111
137
|
},
|
|
112
138
|
};
|
|
113
|
-
// If body
|
|
139
|
+
// If body has properties, spread them for easier access
|
|
114
140
|
if (req.body && typeof req.body === 'object' && !Buffer.isBuffer(req.body)) {
|
|
115
141
|
webhookData.json = {
|
|
116
|
-
...webhookData.json,
|
|
117
142
|
...req.body,
|
|
143
|
+
_webhookData: {
|
|
144
|
+
headers: req.headers,
|
|
145
|
+
query: req.query,
|
|
146
|
+
params: req.params,
|
|
147
|
+
},
|
|
118
148
|
};
|
|
119
149
|
}
|
|
120
150
|
// Handle binary data if present
|
|
@@ -151,6 +181,27 @@ class WebhookWait {
|
|
|
151
181
|
workflowData: [[webhookData]],
|
|
152
182
|
};
|
|
153
183
|
}
|
|
184
|
+
async execute() {
|
|
185
|
+
// Get wait time configuration
|
|
186
|
+
const limitWaitTime = this.getNodeParameter('limitWaitTime', 0);
|
|
187
|
+
const maxWaitTime = this.getNodeParameter('maxWaitTime', 0, 60);
|
|
188
|
+
// Calculate wait until time
|
|
189
|
+
let waitUntil;
|
|
190
|
+
if (limitWaitTime && maxWaitTime > 0) {
|
|
191
|
+
waitUntil = new Date(Date.now() + maxWaitTime * 60 * 1000);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// Wait for 1 year (effectively forever)
|
|
195
|
+
waitUntil = new Date(Date.now() + 365 * 24 * 60 * 60 * 1000);
|
|
196
|
+
}
|
|
197
|
+
// This pauses the execution and waits for the webhook to be called
|
|
198
|
+
// The webhook URL will be shown in the execution panel
|
|
199
|
+
await this.putExecutionToWait(waitUntil);
|
|
200
|
+
// This code runs after the webhook resumes the execution
|
|
201
|
+
// But actually, when resumed by webhook, the webhook() function provides the data
|
|
202
|
+
// So this return is only used if the wait times out
|
|
203
|
+
return [this.getInputData()];
|
|
204
|
+
}
|
|
154
205
|
}
|
|
155
206
|
exports.WebhookWait = WebhookWait;
|
|
156
207
|
//# sourceMappingURL=WebhookWait.node.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WebhookWait.node.js","sourceRoot":"","sources":["../../../nodes/WebhookWait/WebhookWait.node.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"WebhookWait.node.js","sourceRoot":"","sources":["../../../nodes/WebhookWait/WebhookWait.node.ts"],"names":[],"mappings":";;;AASA,MAAa,WAAW;IAAxB;QACC,gBAAW,GAAyB;YACnC,WAAW,EAAE,cAAc;YAC3B,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,iBAAiB;YACvB,KAAK,EAAE,CAAC,WAAW,CAAC;YACpB,OAAO,EAAE,CAAC;YACV,QAAQ,EAAE,4DAA4D;YACtE,WAAW,EAAE,sFAAsF;YACnG,QAAQ,EAAE;gBACT,IAAI,EAAE,cAAc;aACpB;YACD,MAAM,EAAE,CAAC,MAAM,CAAC;YAChB,OAAO,EAAE,CAAC,MAAM,CAAC;YACjB,QAAQ,EAAE;gBACT;oBACC,IAAI,EAAE,SAAS;oBACf,UAAU,EAAE,+BAA+B;oBAC3C,YAAY,EAAE,YAAY;oBAC1B,IAAI,EAAE,yBAAyB;oBAC/B,cAAc,EAAE,IAAI;iBACpB;aACD;YACD,UAAU,EAAE;gBACX;oBACC,WAAW,EAAE,aAAa;oBAC1B,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,EAAE;oBACX,0FAA0F;oBAC1F,WAAW,EAAE,2OAA2O;iBACxP;gBACD;oBACC,WAAW,EAAE,MAAM;oBACnB,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,QAAQ;oBACd,OAAO,EAAE,EAAE;oBACX,WAAW,EAAE,iBAAiB;oBAC9B,QAAQ,EAAE,IAAI;oBACd,WAAW,EAAE,oDAAoD;iBACjE;gBACD;oBACC,WAAW,EAAE,aAAa;oBAC1B,IAAI,EAAE,YAAY;oBAClB,IAAI,EAAE,SAAS;oBACf,OA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