@warleon/n8n-nodes-payload-cms 1.4.0 → 1.4.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.
|
@@ -40,6 +40,7 @@ exports.PayloadCms = void 0;
|
|
|
40
40
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
41
41
|
const axios_1 = __importStar(require("axios"));
|
|
42
42
|
const form_data_1 = __importDefault(require("form-data"));
|
|
43
|
+
const qs_esm_1 = require("qs-esm");
|
|
43
44
|
class PayloadCms {
|
|
44
45
|
// Cache for authentication tokens
|
|
45
46
|
static authTokenCache = new Map();
|
|
@@ -390,6 +391,12 @@ class PayloadCms {
|
|
|
390
391
|
async execute() {
|
|
391
392
|
const items = this.getInputData();
|
|
392
393
|
const returnData = [];
|
|
394
|
+
const executionId = this.getExecutionId();
|
|
395
|
+
const metadata = {
|
|
396
|
+
__n8n_nodes_payload_cms__: {
|
|
397
|
+
executionId,
|
|
398
|
+
},
|
|
399
|
+
};
|
|
393
400
|
for (let i = 0; i < items.length; i++) {
|
|
394
401
|
try {
|
|
395
402
|
const resource = this.getNodeParameter("resource", i);
|
|
@@ -416,7 +423,7 @@ class PayloadCms {
|
|
|
416
423
|
const whereClause = typeof additionalOptions.where === "string"
|
|
417
424
|
? JSON.parse(additionalOptions.where)
|
|
418
425
|
: additionalOptions.where;
|
|
419
|
-
params.where =
|
|
426
|
+
params.where = (0, qs_esm_1.stringify)(whereClause);
|
|
420
427
|
}
|
|
421
428
|
if (additionalOptions.select)
|
|
422
429
|
params.select = additionalOptions.select;
|
|
@@ -501,9 +508,13 @@ class PayloadCms {
|
|
|
501
508
|
contentType: mimeType,
|
|
502
509
|
});
|
|
503
510
|
if (data) {
|
|
504
|
-
|
|
505
|
-
formData.append("_payload", JSON.stringify(sanitizeData));
|
|
511
|
+
typeof data === "string" ? JSON.parse(data) : data;
|
|
506
512
|
}
|
|
513
|
+
else {
|
|
514
|
+
data = {};
|
|
515
|
+
}
|
|
516
|
+
const sanitizeData = { ...data, ...metadata };
|
|
517
|
+
formData.append("_payload", JSON.stringify(sanitizeData));
|
|
507
518
|
requestConfig = {
|
|
508
519
|
method: method,
|
|
509
520
|
maxBodyLength: Infinity,
|
|
@@ -523,9 +534,12 @@ class PayloadCms {
|
|
|
523
534
|
params,
|
|
524
535
|
};
|
|
525
536
|
if (data) {
|
|
526
|
-
|
|
527
|
-
|
|
537
|
+
data = typeof data === "string" ? JSON.parse(data) : data;
|
|
538
|
+
}
|
|
539
|
+
else {
|
|
540
|
+
data = {};
|
|
528
541
|
}
|
|
542
|
+
requestConfig.data = { ...data, ...metadata };
|
|
529
543
|
}
|
|
530
544
|
const response = await PayloadCms.prototype.makeAuthenticatedRequest.call(this, requestConfig);
|
|
531
545
|
returnData.push({
|
|
@@ -126,3 +126,35 @@ export type GlobalConfig<TSlug extends GlobalSlug = any> = {
|
|
|
126
126
|
fields: Field[];
|
|
127
127
|
label?: StaticLabel;
|
|
128
128
|
};
|
|
129
|
+
export declare const validOperators: readonly [
|
|
130
|
+
"equals",
|
|
131
|
+
"contains",
|
|
132
|
+
"not_equals",
|
|
133
|
+
"in",
|
|
134
|
+
"all",
|
|
135
|
+
"not_in",
|
|
136
|
+
"exists",
|
|
137
|
+
"greater_than",
|
|
138
|
+
"greater_than_equal",
|
|
139
|
+
"less_than",
|
|
140
|
+
"less_than_equal",
|
|
141
|
+
"like",
|
|
142
|
+
"not_like",
|
|
143
|
+
"within",
|
|
144
|
+
"intersects",
|
|
145
|
+
"near"
|
|
146
|
+
];
|
|
147
|
+
export type Operator = (typeof validOperators)[number];
|
|
148
|
+
export type JsonValue = JsonArray | JsonObject | unknown;
|
|
149
|
+
export type JsonArray = Array<JsonValue>;
|
|
150
|
+
export interface JsonObject {
|
|
151
|
+
[key: string]: any;
|
|
152
|
+
}
|
|
153
|
+
export type WhereField = {
|
|
154
|
+
[key in Operator]?: JsonValue;
|
|
155
|
+
};
|
|
156
|
+
export type Where = {
|
|
157
|
+
and?: Where[];
|
|
158
|
+
or?: Where[];
|
|
159
|
+
[key: string]: Where[] | WhereField | undefined;
|
|
160
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warleon/n8n-nodes-payload-cms",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.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",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"typescript": "^5.0.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"axios": "^1.10.0"
|
|
62
|
+
"axios": "^1.10.0",
|
|
63
|
+
"qs-esm": "^7.0.2"
|
|
63
64
|
}
|
|
64
65
|
}
|