@middag-io/n8n-nodes-middag 0.1.3 → 0.2.1
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.
|
@@ -203,20 +203,36 @@ class MiddagHubspot {
|
|
|
203
203
|
const resource = this.getNodeParameter('resource', i);
|
|
204
204
|
const operation = this.getNodeParameter('operation', i);
|
|
205
205
|
const portalId = this.getNodeParameter('portalId', i);
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
206
|
+
try {
|
|
207
|
+
const request = requestFor(this, resource, operation, i);
|
|
208
|
+
const options = {
|
|
209
|
+
method: request.method,
|
|
210
|
+
url: `${credentials.workerUrl.replace(/\/$/, '')}/internal/hubspot/${portalId}/${request.path}`,
|
|
211
|
+
headers: {
|
|
212
|
+
'CF-Access-Client-Id': credentials.accessClientId,
|
|
213
|
+
'CF-Access-Client-Secret': credentials.accessClientSecret,
|
|
214
|
+
'content-type': 'application/json',
|
|
215
|
+
},
|
|
216
|
+
body: request.body,
|
|
217
|
+
json: true,
|
|
218
|
+
};
|
|
219
|
+
const response = await this.helpers.httpRequest(options);
|
|
220
|
+
returnData.push({ json: response, pairedItem: { item: i } });
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
// Without this, one bad item (e.g. a transient network error or a HubSpot 4xx on a
|
|
224
|
+
// single contact) throws and discards every other item already processed in the batch.
|
|
225
|
+
// `continueOnFail()` is the node's own "Continue on Fail" toggle (off by default), so
|
|
226
|
+
// this only changes behavior for workflows that explicitly opted in.
|
|
227
|
+
if (this.continueOnFail()) {
|
|
228
|
+
returnData.push({
|
|
229
|
+
json: { error: error instanceof Error ? error.message : String(error) },
|
|
230
|
+
pairedItem: { item: i },
|
|
231
|
+
});
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
throw error;
|
|
235
|
+
}
|
|
220
236
|
}
|
|
221
237
|
return [returnData];
|
|
222
238
|
}
|
|
@@ -39,7 +39,7 @@ class MiddagTrigger {
|
|
|
39
39
|
{
|
|
40
40
|
name: 'default',
|
|
41
41
|
httpMethod: 'POST',
|
|
42
|
-
responseMode: 'onReceived',
|
|
42
|
+
responseMode: '={{$parameter["deferResponse"] ? "responseNode" : "onReceived"}}',
|
|
43
43
|
path: '={{$parameter["path"]}}',
|
|
44
44
|
isFullPath: true,
|
|
45
45
|
},
|
|
@@ -53,6 +53,13 @@ class MiddagTrigger {
|
|
|
53
53
|
required: true,
|
|
54
54
|
description: 'Webhook path. Configure this exact URL as the account destination.n8nUrl.',
|
|
55
55
|
},
|
|
56
|
+
{
|
|
57
|
+
displayName: 'Defer Response to Workflow',
|
|
58
|
+
name: 'deferResponse',
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
default: false,
|
|
61
|
+
description: 'Whether to let the rest of the workflow decide the HTTP response (via a "Respond to Webhook" node) instead of this node answering 200 immediately. Enable this when the Worker needs the real processing outcome (e.g. 502 on downstream failure) to decide whether to retry the delivery. Invalid-signature (401) and duplicate-delivery (200) responses are still answered by this node either way.',
|
|
62
|
+
},
|
|
56
63
|
],
|
|
57
64
|
};
|
|
58
65
|
}
|
|
@@ -79,6 +86,11 @@ class MiddagTrigger {
|
|
|
79
86
|
}
|
|
80
87
|
const staticData = this.getWorkflowStaticData('node');
|
|
81
88
|
if (deliveryId) {
|
|
89
|
+
// Duplicates are always answered here, in both response modes: the workflow's downstream
|
|
90
|
+
// "Respond to Webhook" branches model real outcomes (order created, WooCommerce error,
|
|
91
|
+
// etc.), not "this is a redelivery we're ignoring". Re-running those branches for a
|
|
92
|
+
// duplicate would be at best redundant and at worst double-process side effects the
|
|
93
|
+
// workflow assumed run once per deliveryId.
|
|
82
94
|
if ((0, deliveryDedupe_1.isDuplicateDelivery)(staticData, deliveryId)) {
|
|
83
95
|
this.getResponseObject().status(200).json({ success: true, duplicate: true });
|
|
84
96
|
return { noWebhookResponse: true };
|
|
@@ -86,6 +98,13 @@ class MiddagTrigger {
|
|
|
86
98
|
(0, deliveryDedupe_1.rememberDelivery)(staticData, deliveryId);
|
|
87
99
|
}
|
|
88
100
|
const envelope = this.getBodyData();
|
|
101
|
+
const deferResponse = this.getNodeParameter('deferResponse', false);
|
|
102
|
+
if (deferResponse) {
|
|
103
|
+
// responseMode is 'responseNode' for this execution (see `webhooks` above): a downstream
|
|
104
|
+
// "Respond to Webhook" node answers the HTTP request. Do not touch the response object
|
|
105
|
+
// here, and do not set `noWebhookResponse` — n8n itself waits for that node.
|
|
106
|
+
return { workflowData: [[{ json: outputItemFor(envelope, deliveryId) }]] };
|
|
107
|
+
}
|
|
89
108
|
this.getResponseObject().status(200).json({ success: true });
|
|
90
109
|
return {
|
|
91
110
|
noWebhookResponse: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middag-io/n8n-nodes-middag",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "n8n community nodes for the MIDDAG Connector for HubSpot: a native trigger for signed deliveries from the Worker and an action node for the HubSpot proxy.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package"
|
|
@@ -35,11 +35,13 @@
|
|
|
35
35
|
"dist/nodes/MiddagHubspot/MiddagHubspot.node.js"
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"n8n-workflow": "^1.63.0"
|
|
40
|
+
},
|
|
38
41
|
"devDependencies": {
|
|
39
42
|
"@types/jest": "^29.5.12",
|
|
40
43
|
"@types/node": "^20.14.0",
|
|
41
44
|
"jest": "^29.7.0",
|
|
42
|
-
"n8n-workflow": "^1.63.0",
|
|
43
45
|
"ts-jest": "^29.1.5",
|
|
44
46
|
"typescript": "^5.5.4"
|
|
45
47
|
}
|