n8n-nodes-resend 3.2.0 → 3.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.
@@ -422,38 +422,40 @@ async function execute(index) {
422
422
  });
423
423
  if (additionalOptions.topicId) requestBody.topic_id = additionalOptions.topicId;
424
424
  if (additionalOptions.scheduledAt) requestBody.scheduled_at = additionalOptions.scheduledAt;
425
- if ((_additionalOptions$at = additionalOptions.attachments) === null || _additionalOptions$at === void 0 || (_additionalOptions$at = _additionalOptions$at.attachments) === null || _additionalOptions$at === void 0 ? void 0 : _additionalOptions$at.length) requestBody.attachments = additionalOptions.attachments.attachments.map((attachment) => {
426
- var _attachment$content_i, _attachment$content_t;
427
- const contentId = (_attachment$content_i = attachment.content_id) !== null && _attachment$content_i !== void 0 ? _attachment$content_i : attachment.contentId;
428
- const contentType = (_attachment$content_t = attachment.content_type) !== null && _attachment$content_t !== void 0 ? _attachment$content_t : attachment.contentType;
429
- if (attachment.attachmentType === "binaryData") {
430
- var _items$index$binary;
431
- const binaryPropertyName = attachment.binaryPropertyName || "data";
432
- const binaryData = (_items$index$binary = items[index].binary) === null || _items$index$binary === void 0 ? void 0 : _items$index$binary[binaryPropertyName];
433
- if (!binaryData) throw new n8n_workflow.NodeOperationError(this.getNode(), `Binary property "${binaryPropertyName}" not found in item ${index}`, { itemIndex: index });
434
- const filename = attachment.filename || binaryData.fileName;
435
- if (!filename) throw new n8n_workflow.NodeOperationError(this.getNode(), "File Name is required for binary attachments.", { itemIndex: index });
436
- const attachmentEntry = {
437
- filename,
438
- content: binaryData.data
439
- };
440
- if (contentId) attachmentEntry.content_id = contentId;
441
- if (contentType) attachmentEntry.content_type = contentType;
442
- return attachmentEntry;
443
- }
444
- if (attachment.attachmentType === "url") {
445
- if (!attachment.filename) throw new n8n_workflow.NodeOperationError(this.getNode(), "File Name is required for URL attachments.", { itemIndex: index });
446
- if (!attachment.fileUrl) throw new n8n_workflow.NodeOperationError(this.getNode(), "File URL is required for URL attachments.", { itemIndex: index });
447
- const attachmentEntry = {
448
- filename: attachment.filename,
449
- path: attachment.fileUrl
450
- };
451
- if (contentId) attachmentEntry.content_id = contentId;
452
- if (contentType) attachmentEntry.content_type = contentType;
453
- return attachmentEntry;
425
+ if ((_additionalOptions$at = additionalOptions.attachments) === null || _additionalOptions$at === void 0 || (_additionalOptions$at = _additionalOptions$at.attachments) === null || _additionalOptions$at === void 0 ? void 0 : _additionalOptions$at.length) {
426
+ const attachments = [];
427
+ for (const attachment of additionalOptions.attachments.attachments) {
428
+ var _attachment$content_i, _attachment$content_t;
429
+ const contentId = (_attachment$content_i = attachment.content_id) !== null && _attachment$content_i !== void 0 ? _attachment$content_i : attachment.contentId;
430
+ const contentType = (_attachment$content_t = attachment.content_type) !== null && _attachment$content_t !== void 0 ? _attachment$content_t : attachment.contentType;
431
+ if (attachment.attachmentType === "binaryData") {
432
+ var _items$index$binary;
433
+ const binaryPropertyName = attachment.binaryPropertyName || "data";
434
+ const binaryData = (_items$index$binary = items[index].binary) === null || _items$index$binary === void 0 ? void 0 : _items$index$binary[binaryPropertyName];
435
+ if (!binaryData) throw new n8n_workflow.NodeOperationError(this.getNode(), `Binary property "${binaryPropertyName}" not found in item ${index}`, { itemIndex: index });
436
+ const filename = attachment.filename || binaryData.fileName;
437
+ if (!filename) throw new n8n_workflow.NodeOperationError(this.getNode(), "File Name is required for binary attachments.", { itemIndex: index });
438
+ const attachmentEntry = {
439
+ filename,
440
+ content: (await this.helpers.getBinaryDataBuffer(index, binaryPropertyName)).toString("base64")
441
+ };
442
+ if (contentId) attachmentEntry.content_id = contentId;
443
+ if (contentType) attachmentEntry.content_type = contentType;
444
+ attachments.push(attachmentEntry);
445
+ } else if (attachment.attachmentType === "url") {
446
+ if (!attachment.filename) throw new n8n_workflow.NodeOperationError(this.getNode(), "File Name is required for URL attachments.", { itemIndex: index });
447
+ if (!attachment.fileUrl) throw new n8n_workflow.NodeOperationError(this.getNode(), "File URL is required for URL attachments.", { itemIndex: index });
448
+ const attachmentEntry = {
449
+ filename: attachment.filename,
450
+ path: attachment.fileUrl
451
+ };
452
+ if (contentId) attachmentEntry.content_id = contentId;
453
+ if (contentType) attachmentEntry.content_type = contentType;
454
+ attachments.push(attachmentEntry);
455
+ }
454
456
  }
455
- return null;
456
- }).filter((attachment) => attachment !== null);
457
+ requestBody.attachments = attachments;
458
+ }
457
459
  const requestHeaders = { "Content-Type": "application/json" };
458
460
  if (additionalOptions.idempotencyKey) requestHeaders["Idempotency-Key"] = additionalOptions.idempotencyKey;
459
461
  let response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n8n-nodes-resend",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "Resend integration for n8n: Email, Broadcasts, Templates, Domains, Contacts, Segments, Topics, Webhooks, Automations, Events, and more",
5
5
  "keywords": [
6
6
  "n8n-community-node-package",