n8n-nodes-ido-toolbox 0.1.0 → 0.3.0
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 +100 -2
- package/dist/nodes/IdoToolbox/IdoToolbox.node.js +463 -0
- package/dist/nodes/IdoToolbox/IdoToolbox.node.js.map +1 -1
- package/dist/nodes/IdoToolbox/ToolboxFields.js +436 -0
- package/dist/nodes/IdoToolbox/ToolboxFields.js.map +1 -1
- package/dist/nodes/IdoToolbox/ToolboxOperations.js +132 -0
- package/dist/nodes/IdoToolbox/ToolboxOperations.js.map +1 -1
- package/dist/package.json +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -11,6 +11,16 @@
|
|
|
11
11
|
- **תגובות אקראיות**: בחירה אקראית מתוך רשימת תגובות
|
|
12
12
|
- **תמיכה באייג'נט**: כל הכלים זמינים לשימוש עם AI agents
|
|
13
13
|
|
|
14
|
+
## 🆕 **חדש בגרסה 0.3.0**
|
|
15
|
+
|
|
16
|
+
## 🆕 **חדש בגרסה 0.2.0**
|
|
17
|
+
|
|
18
|
+
- **כלי UTM** - חילוץ פרמטרי UTM מכתובות URL
|
|
19
|
+
- **פיצול טקסט** - חלוקת טקסט לנתחים עם חפיפה
|
|
20
|
+
- **המרת אזורי זמן** - המרת תאריכים בין אזורי זמן שונים
|
|
21
|
+
- **כלי תאריכים** - יצירת תאריכים אקראיים וחישוב הבדלים
|
|
22
|
+
- **כלי עברית** - קידוד/פענוח מחרוזות עברית ואימות תעודות זהות
|
|
23
|
+
|
|
14
24
|
## 🔧 הכלים הזמינים
|
|
15
25
|
|
|
16
26
|
### 1. כלים אקראיים
|
|
@@ -240,6 +250,94 @@
|
|
|
240
250
|
|
|
241
251
|
---
|
|
242
252
|
|
|
243
|
-
|
|
244
|
-
|
|
253
|
+
### 6. כלי XML ו-JSON
|
|
254
|
+
|
|
255
|
+
#### Convert XML to JSON Object (המרת XML לאובייקט JSON)
|
|
256
|
+
ממיר מחרוזת XML לאובייקט JSON בצורה היררכית.
|
|
257
|
+
|
|
258
|
+
**פרמטרים:**
|
|
259
|
+
- **XML String**: מחרוזת XML להמרה
|
|
260
|
+
|
|
261
|
+
**פלט:**
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"xmlString": "<user><name>John</name><age>30</age></user>",
|
|
265
|
+
"jsonResult": {
|
|
266
|
+
"user": {
|
|
267
|
+
"name": {"_value": "John"},
|
|
268
|
+
"age": {"_value": "30"}
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
"conversionSuccessful": true
|
|
272
|
+
}
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
### 7. יצירת QR Code
|
|
276
|
+
|
|
277
|
+
#### Generate QR Code (יצירת קוד QR)
|
|
278
|
+
יוצר קוד QR מכתובת URL או טקסט (יישום בסיסי).
|
|
279
|
+
|
|
280
|
+
**פרמטרים:**
|
|
281
|
+
- **Content**: התוכן להמרה לקוד QR
|
|
282
|
+
- **Size**: גודל קוד ה-QR בפיקסלים
|
|
283
|
+
- **Format**: פורמט הפלט (Base64/Data URL)
|
|
284
|
+
|
|
285
|
+
**פלט:**
|
|
286
|
+
```json
|
|
287
|
+
{
|
|
288
|
+
"content": "https://example.com",
|
|
289
|
+
"size": 256,
|
|
290
|
+
"format": "base64",
|
|
291
|
+
"qrCode": "base64_encoded_qr_placeholder",
|
|
292
|
+
"note": "This is a placeholder. Use qrcode library for real QR generation."
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
### 8. ניתוח HTML
|
|
297
|
+
|
|
298
|
+
#### HTML Parser (מנתח HTML)
|
|
299
|
+
מנתח מחרוזת HTML לחילוץ מידע שונה.
|
|
300
|
+
|
|
301
|
+
**פרמטרים:**
|
|
302
|
+
- **HTML String**: מחרוזת HTML לניתוח
|
|
303
|
+
- **Parse Type**: סוג המידע לחילוץ (טקסט/קישורים/תמונות/כותרות)
|
|
304
|
+
|
|
305
|
+
**פלט:**
|
|
306
|
+
```json
|
|
307
|
+
{
|
|
308
|
+
"htmlString": "<html>...</html>",
|
|
309
|
+
"parseType": "links",
|
|
310
|
+
"parsedData": {
|
|
311
|
+
"links": [
|
|
312
|
+
{"url": "https://example.com", "text": "Example"}
|
|
313
|
+
],
|
|
314
|
+
"linkCount": 1
|
|
315
|
+
},
|
|
316
|
+
"parsingSuccessful": true
|
|
317
|
+
}
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
### 9. חילוץ תווים מספריים
|
|
321
|
+
|
|
322
|
+
#### Get Numeric Characters (קבלת תווים מספריים)
|
|
323
|
+
מחלץ תווים מספריים ממחרוזת.
|
|
324
|
+
|
|
325
|
+
**פרמטרים:**
|
|
326
|
+
- **Input String**: המחרוזת שממנה לחלץ תווים מספריים
|
|
327
|
+
- **Extract as Numbers**: האם להחזיר כמספרים או כמחרוזות
|
|
328
|
+
|
|
329
|
+
**פלט:**
|
|
330
|
+
```json
|
|
331
|
+
{
|
|
332
|
+
"inputString": "Price: 123.45 USD",
|
|
333
|
+
"numericString": "12345",
|
|
334
|
+
"numbers": [1, 2, 3, 4, 5],
|
|
335
|
+
"count": 5
|
|
336
|
+
}
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
**פותח על ידי:** Ovadiah Ben-David
|
|
342
|
+
**גרסה:** 0.3.0
|
|
245
343
|
**תאימות:** n8n 1.0+
|
|
@@ -5,6 +5,51 @@ const n8n_workflow_1 = require("n8n-workflow");
|
|
|
5
5
|
const n8n_workflow_2 = require("n8n-workflow");
|
|
6
6
|
const ToolboxOperations_1 = require("./ToolboxOperations");
|
|
7
7
|
const ToolboxFields_1 = require("./ToolboxFields");
|
|
8
|
+
function xmlToJson(xml) {
|
|
9
|
+
const result = {};
|
|
10
|
+
xml = xml.replace(/<\?xml.*?\?>|<!--.*?-->|<!\[CDATA\[|\]\]>/g, '');
|
|
11
|
+
const rootMatch = xml.match(/<(\w+)[^>]*>(.*?)<\/\1>/s);
|
|
12
|
+
if (!rootMatch) {
|
|
13
|
+
throw new n8n_workflow_2.ApplicationError('Invalid XML format');
|
|
14
|
+
}
|
|
15
|
+
const [, rootTag, content] = rootMatch;
|
|
16
|
+
result[rootTag] = parseXmlContent(content);
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
function parseXmlContent(content) {
|
|
20
|
+
const result = {};
|
|
21
|
+
const elementRegex = /<(\w+)([^>]*)>(.*?)<\/\1>/gs;
|
|
22
|
+
let match;
|
|
23
|
+
while ((match = elementRegex.exec(content)) !== null) {
|
|
24
|
+
const [, tagName, attributes, innerContent] = match;
|
|
25
|
+
const attrMatch = attributes.match(/(\w+)="([^"]*)"/g);
|
|
26
|
+
const attrs = {};
|
|
27
|
+
if (attrMatch) {
|
|
28
|
+
attrMatch.forEach(attr => {
|
|
29
|
+
const [, key, value] = attr.match(/(\w+)="([^"]*)"/) || [];
|
|
30
|
+
if (key && value) {
|
|
31
|
+
attrs[key] = value;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (innerContent.trim() && !innerContent.includes('<')) {
|
|
36
|
+
result[tagName] = {
|
|
37
|
+
_value: innerContent.trim(),
|
|
38
|
+
...attrs
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
else if (innerContent.includes('<')) {
|
|
42
|
+
result[tagName] = {
|
|
43
|
+
...parseXmlContent(innerContent),
|
|
44
|
+
...attrs
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
result[tagName] = attrs;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
8
53
|
class IdoToolbox {
|
|
9
54
|
constructor() {
|
|
10
55
|
this.description = {
|
|
@@ -32,6 +77,18 @@ class IdoToolbox {
|
|
|
32
77
|
name: 'כלים (Tools)',
|
|
33
78
|
value: 'tools',
|
|
34
79
|
},
|
|
80
|
+
{
|
|
81
|
+
name: 'כלים אחרים (Other)',
|
|
82
|
+
value: 'other',
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
name: 'תאריכים (Dates)',
|
|
86
|
+
value: 'dates',
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: 'ישראלי/עברי (Israeli/Hebrew)',
|
|
90
|
+
value: 'hebrew',
|
|
91
|
+
},
|
|
35
92
|
],
|
|
36
93
|
default: 'tools',
|
|
37
94
|
},
|
|
@@ -339,6 +396,412 @@ class IdoToolbox {
|
|
|
339
396
|
};
|
|
340
397
|
break;
|
|
341
398
|
}
|
|
399
|
+
case 'getUtmParameters': {
|
|
400
|
+
const urlString = this.getNodeParameter('url', itemIndex, '');
|
|
401
|
+
try {
|
|
402
|
+
const urlObj = new globalThis.URL(urlString);
|
|
403
|
+
const utmParams = {};
|
|
404
|
+
for (const [key, value] of urlObj.searchParams.entries()) {
|
|
405
|
+
if (key.startsWith('utm_')) {
|
|
406
|
+
utmParams[key] = value;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
result = {
|
|
410
|
+
originalUrl: urlString,
|
|
411
|
+
utmParameters: utmParams,
|
|
412
|
+
parametersCount: Object.keys(utmParams).length,
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
catch (error) {
|
|
416
|
+
throw new n8n_workflow_2.ApplicationError('Invalid URL format');
|
|
417
|
+
}
|
|
418
|
+
break;
|
|
419
|
+
}
|
|
420
|
+
case 'splitTextToChunks': {
|
|
421
|
+
const inputText = this.getNodeParameter('inputText', itemIndex, '');
|
|
422
|
+
const chunkSize = this.getNodeParameter('chunkSize', itemIndex, 1000);
|
|
423
|
+
const overlapSize = this.getNodeParameter('overlapSize', itemIndex, 0);
|
|
424
|
+
const chunks = [];
|
|
425
|
+
let start = 0;
|
|
426
|
+
while (start < inputText.length) {
|
|
427
|
+
let end = start + chunkSize;
|
|
428
|
+
if (end > inputText.length) {
|
|
429
|
+
end = inputText.length;
|
|
430
|
+
}
|
|
431
|
+
const chunk = inputText.slice(start, end);
|
|
432
|
+
chunks.push(chunk);
|
|
433
|
+
start = end - overlapSize;
|
|
434
|
+
if (start >= inputText.length)
|
|
435
|
+
break;
|
|
436
|
+
}
|
|
437
|
+
result = {
|
|
438
|
+
inputText,
|
|
439
|
+
chunks,
|
|
440
|
+
totalChunks: chunks.length,
|
|
441
|
+
chunkSize,
|
|
442
|
+
overlapSize,
|
|
443
|
+
totalCharacters: inputText.length,
|
|
444
|
+
};
|
|
445
|
+
break;
|
|
446
|
+
}
|
|
447
|
+
case 'stringifyObject': {
|
|
448
|
+
const inputObject = this.getNodeParameter('inputObject', itemIndex, {});
|
|
449
|
+
const indentation = this.getNodeParameter('indentation', itemIndex, 2);
|
|
450
|
+
let jsonString;
|
|
451
|
+
try {
|
|
452
|
+
if (indentation === 0) {
|
|
453
|
+
jsonString = JSON.stringify(inputObject);
|
|
454
|
+
}
|
|
455
|
+
else {
|
|
456
|
+
jsonString = JSON.stringify(inputObject, null, indentation);
|
|
457
|
+
}
|
|
458
|
+
result = {
|
|
459
|
+
inputObject,
|
|
460
|
+
jsonString,
|
|
461
|
+
stringLength: jsonString.length,
|
|
462
|
+
indentation,
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
catch (error) {
|
|
466
|
+
throw new n8n_workflow_2.ApplicationError('Invalid JSON object provided');
|
|
467
|
+
}
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
case 'convertTimezones': {
|
|
471
|
+
const dateTimeString = this.getNodeParameter('dateTimeString', itemIndex, '');
|
|
472
|
+
const sourceTimezone = this.getNodeParameter('sourceTimezone', itemIndex, 'UTC');
|
|
473
|
+
const targetTimezone = this.getNodeParameter('targetTimezone', itemIndex, 'Asia/Jerusalem');
|
|
474
|
+
try {
|
|
475
|
+
const sourceDate = new Date(dateTimeString + (sourceTimezone === 'UTC' ? 'Z' : ''));
|
|
476
|
+
const timezoneOffsets = {
|
|
477
|
+
'UTC': 0, 'GMT': 0, 'EST': -300, 'CST': -360, 'MST': -420, 'PST': -480,
|
|
478
|
+
'America/New_York': -300, 'America/Chicago': -360, 'America/Denver': -420, 'America/Los_Angeles': -480,
|
|
479
|
+
'Europe/London': 0, 'Europe/Paris': 60, 'Europe/Berlin': 60,
|
|
480
|
+
'Asia/Jerusalem': 120, 'Asia/Tokyo': 540, 'Australia/Sydney': 600,
|
|
481
|
+
};
|
|
482
|
+
const sourceOffset = timezoneOffsets[sourceTimezone] || 0;
|
|
483
|
+
const targetOffset = timezoneOffsets[targetTimezone] || 0;
|
|
484
|
+
const utcTime = sourceDate.getTime() - (sourceOffset * 60 * 1000);
|
|
485
|
+
const targetTime = new Date(utcTime + (targetOffset * 60 * 1000));
|
|
486
|
+
result = {
|
|
487
|
+
originalDateTime: dateTimeString,
|
|
488
|
+
sourceTimezone,
|
|
489
|
+
targetTimezone,
|
|
490
|
+
convertedDateTime: targetTime.toISOString().replace('T', ' ').slice(0, 19),
|
|
491
|
+
sourceOffset,
|
|
492
|
+
targetOffset,
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
catch (error) {
|
|
496
|
+
throw new n8n_workflow_2.ApplicationError('Invalid date/time format or timezone');
|
|
497
|
+
}
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
case 'generateRandomDate': {
|
|
501
|
+
const startDateStr = this.getNodeParameter('startDate', itemIndex, '');
|
|
502
|
+
const endDateStr = this.getNodeParameter('endDate', itemIndex, '');
|
|
503
|
+
const startDate = new Date(startDateStr);
|
|
504
|
+
const endDate = new Date(endDateStr);
|
|
505
|
+
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
|
|
506
|
+
throw new n8n_workflow_2.ApplicationError('Invalid date format');
|
|
507
|
+
}
|
|
508
|
+
if (startDate >= endDate) {
|
|
509
|
+
throw new n8n_workflow_2.ApplicationError('Start date must be before end date');
|
|
510
|
+
}
|
|
511
|
+
const startTime = startDate.getTime();
|
|
512
|
+
const endTime = endDate.getTime();
|
|
513
|
+
const randomTime = startTime + Math.random() * (endTime - startTime);
|
|
514
|
+
const randomDate = new Date(randomTime);
|
|
515
|
+
result = {
|
|
516
|
+
startDate: startDateStr,
|
|
517
|
+
endDate: endDateStr,
|
|
518
|
+
randomDate: randomDate.toISOString(),
|
|
519
|
+
randomDateFormatted: randomDate.toLocaleDateString('he-IL'),
|
|
520
|
+
};
|
|
521
|
+
break;
|
|
522
|
+
}
|
|
523
|
+
case 'getDaysBetweenDates': {
|
|
524
|
+
const startDateStr = this.getNodeParameter('startDate', itemIndex, '');
|
|
525
|
+
const endDateStr = this.getNodeParameter('endDate', itemIndex, '');
|
|
526
|
+
const startDate = new Date(startDateStr);
|
|
527
|
+
const endDate = new Date(endDateStr);
|
|
528
|
+
if (isNaN(startDate.getTime()) || isNaN(endDate.getTime())) {
|
|
529
|
+
throw new n8n_workflow_2.ApplicationError('Invalid date format');
|
|
530
|
+
}
|
|
531
|
+
const timeDiff = Math.abs(endDate.getTime() - startDate.getTime());
|
|
532
|
+
const daysDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));
|
|
533
|
+
result = {
|
|
534
|
+
startDate: startDateStr,
|
|
535
|
+
endDate: endDateStr,
|
|
536
|
+
daysBetween: daysDiff,
|
|
537
|
+
startDateFormatted: startDate.toLocaleDateString('he-IL'),
|
|
538
|
+
endDateFormatted: endDate.toLocaleDateString('he-IL'),
|
|
539
|
+
};
|
|
540
|
+
break;
|
|
541
|
+
}
|
|
542
|
+
case 'convertSecondsToDuration': {
|
|
543
|
+
const seconds = this.getNodeParameter('seconds', itemIndex, 0);
|
|
544
|
+
if (seconds < 0) {
|
|
545
|
+
throw new n8n_workflow_2.ApplicationError('Seconds must be a positive number');
|
|
546
|
+
}
|
|
547
|
+
const hours = Math.floor(seconds / 3600);
|
|
548
|
+
const minutes = Math.floor((seconds % 3600) / 60);
|
|
549
|
+
const remainingSeconds = seconds % 60;
|
|
550
|
+
const durationString = `${hours.toString().padStart(2, '0')}:${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`;
|
|
551
|
+
result = {
|
|
552
|
+
seconds,
|
|
553
|
+
hours,
|
|
554
|
+
minutes,
|
|
555
|
+
remainingSeconds,
|
|
556
|
+
durationHHMMSS: durationString,
|
|
557
|
+
totalMinutes: hours * 60 + minutes,
|
|
558
|
+
totalHours: hours + minutes / 60 + remainingSeconds / 3600,
|
|
559
|
+
};
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
case 'decodeHebrewString': {
|
|
563
|
+
const encodedString = this.getNodeParameter('encodedString', itemIndex, '');
|
|
564
|
+
try {
|
|
565
|
+
let decoded = encodedString;
|
|
566
|
+
try {
|
|
567
|
+
decoded = decodeURIComponent(encodedString);
|
|
568
|
+
}
|
|
569
|
+
catch (e) {
|
|
570
|
+
}
|
|
571
|
+
result = {
|
|
572
|
+
originalString: encodedString,
|
|
573
|
+
decodedString: decoded,
|
|
574
|
+
wasDecoded: decoded !== encodedString,
|
|
575
|
+
encodingType: decoded !== encodedString ? 'URL' : 'None',
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
catch (error) {
|
|
579
|
+
throw new n8n_workflow_2.ApplicationError('Failed to decode string');
|
|
580
|
+
}
|
|
581
|
+
break;
|
|
582
|
+
}
|
|
583
|
+
case 'encodeHebrewString': {
|
|
584
|
+
const inputString = this.getNodeParameter('inputString', itemIndex, '');
|
|
585
|
+
try {
|
|
586
|
+
const encoded = encodeURIComponent(inputString);
|
|
587
|
+
result = {
|
|
588
|
+
originalString: inputString,
|
|
589
|
+
encodedString: encoded,
|
|
590
|
+
encodingType: 'URL',
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
catch (error) {
|
|
594
|
+
throw new n8n_workflow_2.ApplicationError('Failed to encode string');
|
|
595
|
+
}
|
|
596
|
+
break;
|
|
597
|
+
}
|
|
598
|
+
case 'validateIsraeliId': {
|
|
599
|
+
const idNumber = this.getNodeParameter('idNumber', itemIndex, '');
|
|
600
|
+
const cleanId = idNumber.replace(/\D/g, '');
|
|
601
|
+
if (cleanId.length !== 9) {
|
|
602
|
+
result = {
|
|
603
|
+
idNumber,
|
|
604
|
+
isValid: false,
|
|
605
|
+
error: 'ID must be 9 digits',
|
|
606
|
+
};
|
|
607
|
+
break;
|
|
608
|
+
}
|
|
609
|
+
const digits = cleanId.split('').map(Number);
|
|
610
|
+
let sum = 0;
|
|
611
|
+
for (let i = 0; i < 9; i++) {
|
|
612
|
+
let digit = digits[i];
|
|
613
|
+
if (i % 2 === 1) {
|
|
614
|
+
digit *= 2;
|
|
615
|
+
if (digit > 9) {
|
|
616
|
+
digit = Math.floor(digit / 10) + (digit % 10);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
sum += digit;
|
|
620
|
+
}
|
|
621
|
+
const isValid = sum % 10 === 0;
|
|
622
|
+
result = {
|
|
623
|
+
idNumber,
|
|
624
|
+
cleanId,
|
|
625
|
+
isValid,
|
|
626
|
+
checksum: sum % 10,
|
|
627
|
+
};
|
|
628
|
+
break;
|
|
629
|
+
}
|
|
630
|
+
case 'formatIsraeliNumbers': {
|
|
631
|
+
const number = this.getNodeParameter('number', itemIndex, 0);
|
|
632
|
+
const formatType = this.getNodeParameter('formatType', itemIndex, 'currency');
|
|
633
|
+
let formatted;
|
|
634
|
+
switch (formatType) {
|
|
635
|
+
case 'currency':
|
|
636
|
+
formatted = new Intl.NumberFormat('he-IL', {
|
|
637
|
+
style: 'currency',
|
|
638
|
+
currency: 'ILS',
|
|
639
|
+
}).format(number);
|
|
640
|
+
break;
|
|
641
|
+
case 'percent':
|
|
642
|
+
formatted = new Intl.NumberFormat('he-IL', {
|
|
643
|
+
style: 'percent',
|
|
644
|
+
minimumFractionDigits: 2,
|
|
645
|
+
}).format(number / 100);
|
|
646
|
+
break;
|
|
647
|
+
case 'number':
|
|
648
|
+
default:
|
|
649
|
+
formatted = new Intl.NumberFormat('he-IL').format(number);
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
result = {
|
|
653
|
+
originalNumber: number,
|
|
654
|
+
formattedNumber: formatted,
|
|
655
|
+
formatType,
|
|
656
|
+
locale: 'he-IL',
|
|
657
|
+
};
|
|
658
|
+
break;
|
|
659
|
+
}
|
|
660
|
+
case 'getNumericCharacters': {
|
|
661
|
+
const inputString = this.getNodeParameter('inputString', itemIndex, '');
|
|
662
|
+
const extractAsNumbers = this.getNodeParameter('extractAsNumbers', itemIndex, true);
|
|
663
|
+
const numericChars = inputString.match(/\d/g) || [];
|
|
664
|
+
const numericString = numericChars.join('');
|
|
665
|
+
if (extractAsNumbers && numericString) {
|
|
666
|
+
const numbers = numericChars.map(char => parseInt(char));
|
|
667
|
+
result = {
|
|
668
|
+
inputString,
|
|
669
|
+
numericString,
|
|
670
|
+
numbers,
|
|
671
|
+
count: numericChars.length,
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
else {
|
|
675
|
+
result = {
|
|
676
|
+
inputString,
|
|
677
|
+
numericString,
|
|
678
|
+
count: numericChars.length,
|
|
679
|
+
};
|
|
680
|
+
}
|
|
681
|
+
break;
|
|
682
|
+
}
|
|
683
|
+
case 'convertXmlToJson': {
|
|
684
|
+
const xmlString = this.getNodeParameter('xmlString', itemIndex, '');
|
|
685
|
+
try {
|
|
686
|
+
const jsonResult = xmlToJson(xmlString);
|
|
687
|
+
result = {
|
|
688
|
+
xmlString,
|
|
689
|
+
jsonResult,
|
|
690
|
+
conversionSuccessful: true,
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
catch (error) {
|
|
694
|
+
throw new n8n_workflow_2.ApplicationError('Failed to convert XML to JSON');
|
|
695
|
+
}
|
|
696
|
+
break;
|
|
697
|
+
}
|
|
698
|
+
case 'generateQrCode': {
|
|
699
|
+
const qrContent = this.getNodeParameter('qrContent', itemIndex, '');
|
|
700
|
+
const qrSize = this.getNodeParameter('qrSize', itemIndex, 256);
|
|
701
|
+
const qrFormat = this.getNodeParameter('qrFormat', itemIndex, 'base64');
|
|
702
|
+
try {
|
|
703
|
+
const qrPlaceholder = `QR:${qrContent}:${qrSize}x${qrSize}`;
|
|
704
|
+
const buffer = globalThis.Buffer;
|
|
705
|
+
if (qrFormat === 'base64') {
|
|
706
|
+
const base64Placeholder = buffer.from(qrPlaceholder).toString('base64');
|
|
707
|
+
result = {
|
|
708
|
+
content: qrContent,
|
|
709
|
+
size: qrSize,
|
|
710
|
+
format: qrFormat,
|
|
711
|
+
qrCode: base64Placeholder,
|
|
712
|
+
note: 'This is a placeholder. Use qrcode library for real QR generation.',
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
else {
|
|
716
|
+
result = {
|
|
717
|
+
content: qrContent,
|
|
718
|
+
size: qrSize,
|
|
719
|
+
format: qrFormat,
|
|
720
|
+
qrCode: `data:image/png;base64,${buffer.from(qrPlaceholder).toString('base64')}`,
|
|
721
|
+
note: 'This is a placeholder. Use qrcode library for real QR generation.',
|
|
722
|
+
};
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
catch (error) {
|
|
726
|
+
throw new n8n_workflow_2.ApplicationError('Failed to generate QR code');
|
|
727
|
+
}
|
|
728
|
+
break;
|
|
729
|
+
}
|
|
730
|
+
case 'htmlParser': {
|
|
731
|
+
const htmlString = this.getNodeParameter('htmlString', itemIndex, '');
|
|
732
|
+
const parseType = this.getNodeParameter('parseType', itemIndex, 'text');
|
|
733
|
+
try {
|
|
734
|
+
let parsedData = {};
|
|
735
|
+
switch (parseType) {
|
|
736
|
+
case 'text':
|
|
737
|
+
const textContent = htmlString.replace(/<[^>]*>/g, '').trim();
|
|
738
|
+
parsedData = {
|
|
739
|
+
textContent,
|
|
740
|
+
characterCount: textContent.length,
|
|
741
|
+
wordCount: textContent.split(/\s+/).filter(word => word.length > 0).length,
|
|
742
|
+
};
|
|
743
|
+
break;
|
|
744
|
+
case 'links':
|
|
745
|
+
const linkRegex = /<a[^>]*href="([^"]*)"[^>]*>([^<]*)<\/a>/gi;
|
|
746
|
+
const links = [];
|
|
747
|
+
let linkMatch;
|
|
748
|
+
while ((linkMatch = linkRegex.exec(htmlString)) !== null) {
|
|
749
|
+
links.push({
|
|
750
|
+
url: linkMatch[1],
|
|
751
|
+
text: linkMatch[2],
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
parsedData = {
|
|
755
|
+
links,
|
|
756
|
+
linkCount: links.length,
|
|
757
|
+
};
|
|
758
|
+
break;
|
|
759
|
+
case 'images':
|
|
760
|
+
const imageRegex = /<img[^>]*src="([^"]*)"[^>]*(?:alt="([^"]*)")?[^>]*>/gi;
|
|
761
|
+
const images = [];
|
|
762
|
+
let imageMatch;
|
|
763
|
+
while ((imageMatch = imageRegex.exec(htmlString)) !== null) {
|
|
764
|
+
images.push({
|
|
765
|
+
src: imageMatch[1],
|
|
766
|
+
alt: imageMatch[2] || '',
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
parsedData = {
|
|
770
|
+
images,
|
|
771
|
+
imageCount: images.length,
|
|
772
|
+
};
|
|
773
|
+
break;
|
|
774
|
+
case 'headings':
|
|
775
|
+
const headingRegex = /<h[1-6][^>]*>([^<]*)<\/h[1-6]>/gi;
|
|
776
|
+
const headings = [];
|
|
777
|
+
let headingMatch;
|
|
778
|
+
while ((headingMatch = headingRegex.exec(htmlString)) !== null) {
|
|
779
|
+
const tagMatch = headingMatch[0].match(/<h([1-6])/);
|
|
780
|
+
headings.push({
|
|
781
|
+
level: tagMatch ? parseInt(tagMatch[1]) : 1,
|
|
782
|
+
text: headingMatch[1],
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
parsedData = {
|
|
786
|
+
headings,
|
|
787
|
+
headingCount: headings.length,
|
|
788
|
+
};
|
|
789
|
+
break;
|
|
790
|
+
default:
|
|
791
|
+
parsedData = { error: 'Unknown parse type' };
|
|
792
|
+
}
|
|
793
|
+
result = {
|
|
794
|
+
htmlString,
|
|
795
|
+
parseType,
|
|
796
|
+
parsedData,
|
|
797
|
+
parsingSuccessful: true,
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
catch (error) {
|
|
801
|
+
throw new n8n_workflow_2.ApplicationError('Failed to parse HTML');
|
|
802
|
+
}
|
|
803
|
+
break;
|
|
804
|
+
}
|
|
342
805
|
default:
|
|
343
806
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), `Operation ${operation} is not supported`);
|
|
344
807
|
}
|