n8n-nodes-digit 0.1.18 → 0.1.20
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/nodes/DIGIT.node.js +93 -25
- package/dist/package.json +1 -1
- package/package.json +1 -1
package/dist/nodes/DIGIT.node.js
CHANGED
|
@@ -188,39 +188,107 @@ class DIGIT {
|
|
|
188
188
|
}
|
|
189
189
|
}
|
|
190
190
|
// ==================================================
|
|
191
|
-
// NOTIFICATION — SEND EMAIL
|
|
191
|
+
// NOTIFICATION — SEND EMAIL (FIXED)
|
|
192
192
|
// ==================================================
|
|
193
193
|
if (resource === 'notification') {
|
|
194
194
|
const operation = this.getNodeParameter('notificationOperation', 0);
|
|
195
195
|
if (operation === 'notification_send_email') {
|
|
196
196
|
for (let i = 0; i < items.length; i++) {
|
|
197
|
-
const tenantId = this.getNodeParameter('tenantId', i);
|
|
198
|
-
const accessToken = this.getNodeParameter('accessToken', i);
|
|
199
|
-
const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
|
|
200
|
-
let body;
|
|
201
197
|
try {
|
|
202
|
-
|
|
198
|
+
const tenantId = this.getNodeParameter('tenantId', i);
|
|
199
|
+
const accessToken = this.getNodeParameter('accessToken', i);
|
|
200
|
+
const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
|
|
201
|
+
let body;
|
|
202
|
+
try {
|
|
203
|
+
body = JSON.parse(this.getNodeParameter('requestBody', i));
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
throw new Error('Invalid JSON in Request Body');
|
|
207
|
+
}
|
|
208
|
+
const url = new URL('/notification/v1/email/send', baseUrl).toString();
|
|
209
|
+
const response = await this.helpers.httpRequest({
|
|
210
|
+
method: 'POST',
|
|
211
|
+
url,
|
|
212
|
+
headers: {
|
|
213
|
+
'X-Tenant-ID': tenantId,
|
|
214
|
+
Authorization: `Bearer ${cleanToken}`,
|
|
215
|
+
'Content-Type': 'application/json',
|
|
216
|
+
},
|
|
217
|
+
body,
|
|
218
|
+
json: true,
|
|
219
|
+
});
|
|
220
|
+
// ✅ Push only JSON-safe data
|
|
221
|
+
returnData.push({
|
|
222
|
+
json: response,
|
|
223
|
+
});
|
|
203
224
|
}
|
|
204
|
-
catch {
|
|
205
|
-
|
|
225
|
+
catch (error) {
|
|
226
|
+
if (this.continueOnFail()) {
|
|
227
|
+
// ✅ Never push raw error object
|
|
228
|
+
returnData.push({
|
|
229
|
+
json: {
|
|
230
|
+
error: error.message,
|
|
231
|
+
statusCode: error.statusCode || null,
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
throw error;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return [returnData];
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
// ==================================================
|
|
244
|
+
// NOTIFICATION — SEND EMAIL (FIXED)
|
|
245
|
+
// ==================================================
|
|
246
|
+
if (resource === 'notification') {
|
|
247
|
+
const operation = this.getNodeParameter('notificationOperation', 0);
|
|
248
|
+
if (operation === 'notification_send_email') {
|
|
249
|
+
for (let i = 0; i < items.length; i++) {
|
|
250
|
+
try {
|
|
251
|
+
const tenantId = this.getNodeParameter('tenantId', i);
|
|
252
|
+
const accessToken = this.getNodeParameter('accessToken', i);
|
|
253
|
+
const cleanToken = accessToken.replace(/^Bearer\s+/i, '').trim();
|
|
254
|
+
let body;
|
|
255
|
+
try {
|
|
256
|
+
body = JSON.parse(this.getNodeParameter('requestBody', i));
|
|
257
|
+
}
|
|
258
|
+
catch {
|
|
259
|
+
throw new Error('Invalid JSON in Request Body');
|
|
260
|
+
}
|
|
261
|
+
const url = new URL('/notification/v1/email/send', baseUrl).toString();
|
|
262
|
+
const response = await this.helpers.httpRequest({
|
|
263
|
+
method: 'POST',
|
|
264
|
+
url,
|
|
265
|
+
headers: {
|
|
266
|
+
'X-Tenant-ID': tenantId,
|
|
267
|
+
Authorization: `Bearer ${cleanToken}`,
|
|
268
|
+
'Content-Type': 'application/json',
|
|
269
|
+
},
|
|
270
|
+
body,
|
|
271
|
+
json: true,
|
|
272
|
+
});
|
|
273
|
+
// ✅ Push only JSON-safe data
|
|
274
|
+
returnData.push({
|
|
275
|
+
json: response,
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
catch (error) {
|
|
279
|
+
if (this.continueOnFail()) {
|
|
280
|
+
// ✅ Never push raw error object
|
|
281
|
+
returnData.push({
|
|
282
|
+
json: {
|
|
283
|
+
error: error.message,
|
|
284
|
+
statusCode: error.statusCode || null,
|
|
285
|
+
},
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
throw error;
|
|
290
|
+
}
|
|
206
291
|
}
|
|
207
|
-
// Gateway compatible path
|
|
208
|
-
const notificationPath = '/notification/v1/email/send';
|
|
209
|
-
const apiResponse = await this.helpers.httpRequest({
|
|
210
|
-
method: 'POST',
|
|
211
|
-
url: new URL(notificationPath, baseUrl).toString(),
|
|
212
|
-
headers: {
|
|
213
|
-
'X-Tenant-ID': tenantId,
|
|
214
|
-
Authorization: `Bearer ${cleanToken}`,
|
|
215
|
-
'Content-Type': 'application/json',
|
|
216
|
-
},
|
|
217
|
-
body,
|
|
218
|
-
json: true,
|
|
219
|
-
});
|
|
220
|
-
// Prevent circular reference crash
|
|
221
|
-
returnData.push({
|
|
222
|
-
json: JSON.parse(JSON.stringify(apiResponse)),
|
|
223
|
-
});
|
|
224
292
|
}
|
|
225
293
|
return [returnData];
|
|
226
294
|
}
|
package/dist/package.json
CHANGED