@warleon/n8n-nodes-payload-cms 1.3.9 → 1.4.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.
@@ -390,6 +390,12 @@ class PayloadCms {
390
390
  async execute() {
391
391
  const items = this.getInputData();
392
392
  const returnData = [];
393
+ const executionId = this.getExecutionId();
394
+ const metadata = {
395
+ __n8n_nodes_payload_cms__: {
396
+ executionId,
397
+ },
398
+ };
393
399
  for (let i = 0; i < items.length; i++) {
394
400
  try {
395
401
  const resource = this.getNodeParameter("resource", i);
@@ -490,29 +496,9 @@ class PayloadCms {
490
496
  let requestConfig = {};
491
497
  // handle binary inputs
492
498
  const binaryPropertyName = additionalOptions.upload;
493
- returnData.push({
494
- json: {
495
- debug: `upload name: ${binaryPropertyName}`,
496
- },
497
- });
498
499
  if (binaryPropertyName) {
499
- returnData.push({
500
- json: {
501
- debug: "entered file data, form-data path",
502
- },
503
- });
504
500
  const binaryData = this.helpers.assertBinaryData(i, binaryPropertyName);
505
- returnData.push({
506
- json: {
507
- debug: `binarydata type: ${binaryData.mimeType}`,
508
- },
509
- });
510
501
  const fileBuffer = await this.helpers.getBinaryDataBuffer(i, binaryPropertyName);
511
- returnData.push({
512
- json: {
513
- debug: `fileBuffer size: ${fileBuffer.length}`,
514
- },
515
- });
516
502
  const fileName = binaryData.fileName;
517
503
  const mimeType = binaryData.mimeType;
518
504
  const formData = new form_data_1.default();
@@ -520,20 +506,14 @@ class PayloadCms {
520
506
  filename: fileName,
521
507
  contentType: mimeType,
522
508
  });
523
- returnData.push({
524
- json: {
525
- debug: `formData append file: ${fileName}`,
526
- },
527
- });
528
509
  if (data) {
529
- const sanitizeData = typeof data === "string" ? JSON.parse(data) : data;
530
- formData.append("_payload", JSON.stringify(sanitizeData));
531
- returnData.push({
532
- json: {
533
- debug: `formData append data: ${data}`,
534
- },
535
- });
510
+ typeof data === "string" ? JSON.parse(data) : data;
511
+ }
512
+ else {
513
+ data = {};
536
514
  }
515
+ const sanitizeData = { ...data, ...metadata };
516
+ formData.append("_payload", JSON.stringify(sanitizeData));
537
517
  requestConfig = {
538
518
  method: method,
539
519
  maxBodyLength: Infinity,
@@ -547,20 +527,18 @@ class PayloadCms {
547
527
  };
548
528
  }
549
529
  else {
550
- returnData.push({
551
- json: {
552
- debug: "entered normal data, json data path",
553
- },
554
- });
555
530
  requestConfig = {
556
531
  method: method,
557
532
  url,
558
533
  params,
559
534
  };
560
535
  if (data) {
561
- requestConfig.data =
562
- typeof data === "string" ? JSON.parse(data) : data;
536
+ data = typeof data === "string" ? JSON.parse(data) : data;
537
+ }
538
+ else {
539
+ data = {};
563
540
  }
541
+ requestConfig.data = { ...data, ...metadata };
564
542
  }
565
543
  const response = await PayloadCms.prototype.makeAuthenticatedRequest.call(this, requestConfig);
566
544
  returnData.push({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@warleon/n8n-nodes-payload-cms",
3
- "version": "1.3.9",
3
+ "version": "1.4.1",
4
4
  "description": "Dynamic n8n node for Payload CMS that auto-discovers collections and operations forked and extended from https://github.com/leadership-institute/n8n-payload-dynamic",
5
5
  "main": "dist/index.js",
6
6
  "author": "warleon",