@warleon/n8n-nodes-payload-cms 1.3.0 → 1.3.2
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,11 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
5
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
39
|
exports.PayloadCms = void 0;
|
|
7
40
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
8
|
-
const axios_1 =
|
|
41
|
+
const axios_1 = __importStar(require("axios"));
|
|
42
|
+
const form_data_1 = __importDefault(require("form-data"));
|
|
9
43
|
class PayloadCms {
|
|
10
44
|
// Cache for authentication tokens
|
|
11
45
|
static authTokenCache = new Map();
|
|
@@ -458,8 +492,11 @@ class PayloadCms {
|
|
|
458
492
|
const fileBuffer = await this.helpers.getBinaryDataBuffer(0, binaryPropertyName);
|
|
459
493
|
const fileName = binaryData.fileName;
|
|
460
494
|
const mimeType = binaryData.mimeType;
|
|
461
|
-
const formData = new
|
|
462
|
-
formData.append("file", fileBuffer,
|
|
495
|
+
const formData = new form_data_1.default();
|
|
496
|
+
formData.append("file", fileBuffer, {
|
|
497
|
+
filename: fileName,
|
|
498
|
+
contentType: mimeType,
|
|
499
|
+
});
|
|
463
500
|
if (data) {
|
|
464
501
|
const sanitizeData = typeof data === "string" ? JSON.parse(data) : data;
|
|
465
502
|
formData.append("_payload", JSON.stringify(sanitizeData));
|
|
@@ -491,6 +528,20 @@ class PayloadCms {
|
|
|
491
528
|
});
|
|
492
529
|
}
|
|
493
530
|
catch (error) {
|
|
531
|
+
if (error instanceof axios_1.AxiosError) {
|
|
532
|
+
if (error.response) {
|
|
533
|
+
// HTTP error (400, 500, etc.)
|
|
534
|
+
const status = error.response.status;
|
|
535
|
+
const data = error.response.data; // body from server
|
|
536
|
+
// Log to n8n logs
|
|
537
|
+
this.logger.error(`Request failed with status ${status}`);
|
|
538
|
+
this.logger.error(`Response body: ${JSON.stringify(data)}`);
|
|
539
|
+
returnData.push({
|
|
540
|
+
error: new n8n_workflow_1.NodeOperationError(this.getNode(), error),
|
|
541
|
+
json: data,
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
494
545
|
if (this.continueOnFail()) {
|
|
495
546
|
returnData.push({
|
|
496
547
|
json: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warleon/n8n-nodes-payload-cms",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
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",
|