@kichat/n8n-nodes-kirimchat 1.0.4 → 1.0.5
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/README.md +1 -1
- package/dist/nodes/KirimChat/KirimChat.node.js +37 -3
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ This is an n8n community node for [KirimChat](https://kirim.chat) - a messaging
|
|
|
14
14
|
|
|
15
15
|
1. Go to **Settings > Community Nodes**
|
|
16
16
|
2. Select **Install**
|
|
17
|
-
3. Enter `@n8n-nodes-kirimchat` and confirm
|
|
17
|
+
3. Enter `@kichat/n8n-nodes-kirimchat` and confirm
|
|
18
18
|
|
|
19
19
|
## Credentials
|
|
20
20
|
|
|
@@ -2,6 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.KirimChat = void 0;
|
|
4
4
|
const n8n_workflow_1 = require("n8n-workflow");
|
|
5
|
+
/**
|
|
6
|
+
* Validates if a string is a valid URL
|
|
7
|
+
*/
|
|
8
|
+
function isValidUrl(urlString) {
|
|
9
|
+
try {
|
|
10
|
+
const url = new URL(urlString);
|
|
11
|
+
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Validates template components structure
|
|
19
|
+
*/
|
|
20
|
+
function validateTemplateComponents(components) {
|
|
21
|
+
if (!Array.isArray(components)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return components.every((component) => typeof component === 'object' && component !== null);
|
|
25
|
+
}
|
|
5
26
|
class KirimChat {
|
|
6
27
|
constructor() {
|
|
7
28
|
this.description = {
|
|
@@ -341,12 +362,16 @@ class KirimChat {
|
|
|
341
362
|
const templateName = this.getNodeParameter('templateName', i);
|
|
342
363
|
const templateLanguage = this.getNodeParameter('templateLanguage', i);
|
|
343
364
|
const templateComponentsJson = this.getNodeParameter('templateComponents', i, '[]');
|
|
344
|
-
let templateComponents
|
|
365
|
+
let templateComponents;
|
|
345
366
|
try {
|
|
346
367
|
templateComponents = JSON.parse(templateComponentsJson);
|
|
347
368
|
}
|
|
348
369
|
catch (error) {
|
|
349
|
-
throw new
|
|
370
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid JSON in Template Components: ${error instanceof Error ? error.message : 'Parse failed'}`, { itemIndex: i });
|
|
371
|
+
}
|
|
372
|
+
// Validate template components structure
|
|
373
|
+
if (!validateTemplateComponents(templateComponents)) {
|
|
374
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Template Components must be a JSON array of objects. Example: [{"type": "body", "parameters": [...]}]', { itemIndex: i });
|
|
350
375
|
}
|
|
351
376
|
body.template = {
|
|
352
377
|
name: templateName,
|
|
@@ -356,7 +381,16 @@ class KirimChat {
|
|
|
356
381
|
}
|
|
357
382
|
else {
|
|
358
383
|
// Media messages
|
|
359
|
-
|
|
384
|
+
const mediaUrl = this.getNodeParameter('mediaUrl', i, '');
|
|
385
|
+
// Validate media URL is provided
|
|
386
|
+
if (!mediaUrl) {
|
|
387
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Media URL is required for media messages (image, document, audio, video, media_share)', { itemIndex: i });
|
|
388
|
+
}
|
|
389
|
+
// Validate media URL format
|
|
390
|
+
if (!isValidUrl(mediaUrl)) {
|
|
391
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Invalid Media URL format: "${mediaUrl}". URL must start with http:// or https://`, { itemIndex: i });
|
|
392
|
+
}
|
|
393
|
+
body.media_url = mediaUrl;
|
|
360
394
|
const caption = this.getNodeParameter('caption', i, '');
|
|
361
395
|
if (caption) {
|
|
362
396
|
body.caption = caption;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kichat/n8n-nodes-kirimchat",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "n8n community node for KirimChat - Send WhatsApp & Instagram messages, mark as read, and send typing indicators",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"n8n-community-node-package",
|
|
@@ -53,4 +53,4 @@
|
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"n8n-workflow": "*"
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|