namirasoft-core 1.5.2 → 1.5.3

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.
Files changed (57) hide show
  1. package/SKILL.md +223 -223
  2. package/dist/TimeOperation.d.ts +1 -0
  3. package/dist/TimeOperation.js +4 -0
  4. package/dist/TimeOperation.js.map +1 -1
  5. package/package.json +26 -26
  6. package/src/BaseDatabaseRow.ts +6 -6
  7. package/src/BaseLogger.ts +24 -24
  8. package/src/BaseMetaColumn.ts +17 -17
  9. package/src/BaseMetaDatabase.ts +30 -30
  10. package/src/BaseMetaTable.ts +40 -40
  11. package/src/BaseServer.ts +150 -150
  12. package/src/BaseUUID.ts +76 -76
  13. package/src/ByteOperation.ts +57 -57
  14. package/src/CacheService.ts +76 -76
  15. package/src/ColorOperation.ts +153 -153
  16. package/src/ConsoleOperation.ts +68 -68
  17. package/src/ConvertService.ts +123 -123
  18. package/src/CookieService.ts +33 -33
  19. package/src/Countries.ts +486 -486
  20. package/src/Country.ts +21 -21
  21. package/src/CountryOperation.ts +98 -98
  22. package/src/CronOperation.ts +121 -121
  23. package/src/EncodingOperation.ts +46 -46
  24. package/src/EnvService.ts +28 -28
  25. package/src/ErrorOperation.ts +13 -13
  26. package/src/FileOperation.ts +60 -60
  27. package/src/FilterItem.ts +117 -117
  28. package/src/FilterItemColumnType.ts +9 -9
  29. package/src/FilterItemOperator.ts +52 -52
  30. package/src/GeoOperation.ts +18 -18
  31. package/src/HTTPError.ts +8 -8
  32. package/src/HTTPMethod.ts +7 -7
  33. package/src/HashOperation.ts +24 -24
  34. package/src/ILogger.ts +17 -17
  35. package/src/IStorage.ts +5 -5
  36. package/src/IStorageCookie.ts +52 -52
  37. package/src/IStorageJsonFile.ts +45 -45
  38. package/src/IStorageLocal.ts +16 -16
  39. package/src/IStorageMemoryDedicated.ts +17 -17
  40. package/src/IStorageMemoryShared.ts +21 -21
  41. package/src/IStorageSession.ts +16 -16
  42. package/src/LogLevel.ts +11 -11
  43. package/src/NamingConvention.ts +199 -199
  44. package/src/ObjectService.ts +27 -27
  45. package/src/PackageService.ts +76 -76
  46. package/src/PasswordOperation.ts +12 -12
  47. package/src/PhoneOperation.ts +8 -8
  48. package/src/PriceOperation.ts +20 -20
  49. package/src/SearchOperation.ts +31 -31
  50. package/src/SetTimeouService.ts +32 -32
  51. package/src/SortItem.ts +88 -88
  52. package/src/StringOperation.ts +22 -22
  53. package/src/TimeOperation.ts +303 -299
  54. package/src/TimeUnitOperation.ts +82 -82
  55. package/src/URLOperation.ts +66 -66
  56. package/src/VersionOperation.ts +46 -46
  57. package/src/index.ts +52 -52
@@ -1,154 +1,154 @@
1
- export class ColorOperation
2
- {
3
- private static readonly GOLDEN_ANGLE = 137.508;
4
- private static readonly BASE_HUE = 210;
5
- private static readonly SATURATION = 68;
6
- private static readonly LIGHTNESS = 56;
7
-
8
- private index: number;
9
-
10
- constructor(startIndex: number = 0)
11
- {
12
- this.index = startIndex;
13
- }
14
-
15
- generate(): string
16
- {
17
- return ColorOperation.at(this.index++);
18
- }
19
-
20
- peek(): string
21
- {
22
- return ColorOperation.at(this.index);
23
- }
24
-
25
- reset(startIndex: number = 0): void
26
- {
27
- this.index = startIndex;
28
- }
29
-
30
- static at(index: number): string
31
- {
32
- let hue = ColorOperation.normalizeHue(ColorOperation.BASE_HUE + index * ColorOperation.GOLDEN_ANGLE);
33
- return ColorOperation.hslToHex(hue, ColorOperation.SATURATION, ColorOperation.LIGHTNESS);
34
- }
35
-
36
- static generate(count: number): string[]
37
- {
38
- let colors: string[] = [];
39
- for (let i = 0; i < count; i++)
40
- colors.push(ColorOperation.at(i));
41
- return colors;
42
- }
43
-
44
- static random(): string
45
- {
46
- return ColorOperation.hslToHex(Math.random() * 360, ColorOperation.SATURATION, ColorOperation.LIGHTNESS);
47
- }
48
-
49
- static randoms(count: number): string[]
50
- {
51
- let start = Math.random() * 360;
52
- let colors: string[] = [];
53
- for (let i = 0; i < count; i++)
54
- {
55
- let hue = ColorOperation.normalizeHue(start + i * ColorOperation.GOLDEN_ANGLE);
56
- colors.push(ColorOperation.hslToHex(hue, ColorOperation.SATURATION, ColorOperation.LIGHTNESS));
57
- }
58
- return colors;
59
- }
60
-
61
- static next(color: string): string
62
- {
63
- let { h, s, l } = ColorOperation.toHsl(color);
64
- return ColorOperation.hslToHex(ColorOperation.normalizeHue(h + ColorOperation.GOLDEN_ANGLE), s, l);
65
- }
66
-
67
- static prev(color: string): string
68
- {
69
- let { h, s, l } = ColorOperation.toHsl(color);
70
- return ColorOperation.hslToHex(ColorOperation.normalizeHue(h - ColorOperation.GOLDEN_ANGLE), s, l);
71
- }
72
-
73
- static hslToHex(h: number, s: number, l: number): string
74
- {
75
- h = ColorOperation.normalizeHue(h);
76
- s = Math.max(0, Math.min(100, s)) / 100;
77
- l = Math.max(0, Math.min(100, l)) / 100;
78
-
79
- let c = (1 - Math.abs(2 * l - 1)) * s;
80
- let x = c * (1 - Math.abs(((h / 60) % 2) - 1));
81
- let m = l - c / 2;
82
-
83
- let r = 0, g = 0, b = 0;
84
- if (h < 60) { r = c; g = x; b = 0; }
85
- else if (h < 120) { r = x; g = c; b = 0; }
86
- else if (h < 180) { r = 0; g = c; b = x; }
87
- else if (h < 240) { r = 0; g = x; b = c; }
88
- else if (h < 300) { r = x; g = 0; b = c; }
89
- else { r = c; g = 0; b = x; }
90
-
91
- return ColorOperation.rgbToHex((r + m) * 255, (g + m) * 255, (b + m) * 255);
92
- }
93
-
94
- static toHsl(color: string): { h: number, s: number, l: number }
95
- {
96
- let trimmed = color.trim().toLowerCase();
97
- if (trimmed.startsWith("hsl"))
98
- {
99
- let parts = trimmed.replace(/hsla?\(|\)|%/g, "").split(/[\s,/]+/).filter(Boolean);
100
- return {
101
- h: ColorOperation.normalizeHue(parseFloat(parts[0]) || 0),
102
- s: parseFloat(parts[1]) || 0,
103
- l: parseFloat(parts[2]) || 0,
104
- };
105
- }
106
- let { r, g, b } = ColorOperation.hexToRgb(trimmed);
107
- return ColorOperation.rgbToHsl(r, g, b);
108
- }
109
-
110
- private static normalizeHue(hue: number): number
111
- {
112
- return ((hue % 360) + 360) % 360;
113
- }
114
-
115
- private static hexToRgb(hex: string): { r: number, g: number, b: number }
116
- {
117
- let value = hex.replace("#", "");
118
- if (value.length === 3)
119
- value = value.split("").map(ch => ch + ch).join("");
120
- let num = parseInt(value, 16);
121
- return {
122
- r: (num >> 16) & 255,
123
- g: (num >> 8) & 255,
124
- b: num & 255,
125
- };
126
- }
127
-
128
- private static rgbToHex(r: number, g: number, b: number): string
129
- {
130
- let toHex = (v: number) => Math.round(Math.max(0, Math.min(255, v))).toString(16).padStart(2, "0");
131
- return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase();
132
- }
133
-
134
- private static rgbToHsl(r: number, g: number, b: number): { h: number, s: number, l: number }
135
- {
136
- r /= 255; g /= 255; b /= 255;
137
- let max = Math.max(r, g, b), min = Math.min(r, g, b);
138
- let l = (max + min) / 2;
139
- let d = max - min;
140
- let h = 0, s = 0;
141
- if (d !== 0)
142
- {
143
- s = d / (1 - Math.abs(2 * l - 1));
144
- switch (max)
145
- {
146
- case r: h = ((g - b) / d) % 6; break;
147
- case g: h = (b - r) / d + 2; break;
148
- default: h = (r - g) / d + 4; break;
149
- }
150
- h *= 60;
151
- }
152
- return { h: ColorOperation.normalizeHue(h), s: s * 100, l: l * 100 };
153
- }
1
+ export class ColorOperation
2
+ {
3
+ private static readonly GOLDEN_ANGLE = 137.508;
4
+ private static readonly BASE_HUE = 210;
5
+ private static readonly SATURATION = 68;
6
+ private static readonly LIGHTNESS = 56;
7
+
8
+ private index: number;
9
+
10
+ constructor(startIndex: number = 0)
11
+ {
12
+ this.index = startIndex;
13
+ }
14
+
15
+ generate(): string
16
+ {
17
+ return ColorOperation.at(this.index++);
18
+ }
19
+
20
+ peek(): string
21
+ {
22
+ return ColorOperation.at(this.index);
23
+ }
24
+
25
+ reset(startIndex: number = 0): void
26
+ {
27
+ this.index = startIndex;
28
+ }
29
+
30
+ static at(index: number): string
31
+ {
32
+ let hue = ColorOperation.normalizeHue(ColorOperation.BASE_HUE + index * ColorOperation.GOLDEN_ANGLE);
33
+ return ColorOperation.hslToHex(hue, ColorOperation.SATURATION, ColorOperation.LIGHTNESS);
34
+ }
35
+
36
+ static generate(count: number): string[]
37
+ {
38
+ let colors: string[] = [];
39
+ for (let i = 0; i < count; i++)
40
+ colors.push(ColorOperation.at(i));
41
+ return colors;
42
+ }
43
+
44
+ static random(): string
45
+ {
46
+ return ColorOperation.hslToHex(Math.random() * 360, ColorOperation.SATURATION, ColorOperation.LIGHTNESS);
47
+ }
48
+
49
+ static randoms(count: number): string[]
50
+ {
51
+ let start = Math.random() * 360;
52
+ let colors: string[] = [];
53
+ for (let i = 0; i < count; i++)
54
+ {
55
+ let hue = ColorOperation.normalizeHue(start + i * ColorOperation.GOLDEN_ANGLE);
56
+ colors.push(ColorOperation.hslToHex(hue, ColorOperation.SATURATION, ColorOperation.LIGHTNESS));
57
+ }
58
+ return colors;
59
+ }
60
+
61
+ static next(color: string): string
62
+ {
63
+ let { h, s, l } = ColorOperation.toHsl(color);
64
+ return ColorOperation.hslToHex(ColorOperation.normalizeHue(h + ColorOperation.GOLDEN_ANGLE), s, l);
65
+ }
66
+
67
+ static prev(color: string): string
68
+ {
69
+ let { h, s, l } = ColorOperation.toHsl(color);
70
+ return ColorOperation.hslToHex(ColorOperation.normalizeHue(h - ColorOperation.GOLDEN_ANGLE), s, l);
71
+ }
72
+
73
+ static hslToHex(h: number, s: number, l: number): string
74
+ {
75
+ h = ColorOperation.normalizeHue(h);
76
+ s = Math.max(0, Math.min(100, s)) / 100;
77
+ l = Math.max(0, Math.min(100, l)) / 100;
78
+
79
+ let c = (1 - Math.abs(2 * l - 1)) * s;
80
+ let x = c * (1 - Math.abs(((h / 60) % 2) - 1));
81
+ let m = l - c / 2;
82
+
83
+ let r = 0, g = 0, b = 0;
84
+ if (h < 60) { r = c; g = x; b = 0; }
85
+ else if (h < 120) { r = x; g = c; b = 0; }
86
+ else if (h < 180) { r = 0; g = c; b = x; }
87
+ else if (h < 240) { r = 0; g = x; b = c; }
88
+ else if (h < 300) { r = x; g = 0; b = c; }
89
+ else { r = c; g = 0; b = x; }
90
+
91
+ return ColorOperation.rgbToHex((r + m) * 255, (g + m) * 255, (b + m) * 255);
92
+ }
93
+
94
+ static toHsl(color: string): { h: number, s: number, l: number }
95
+ {
96
+ let trimmed = color.trim().toLowerCase();
97
+ if (trimmed.startsWith("hsl"))
98
+ {
99
+ let parts = trimmed.replace(/hsla?\(|\)|%/g, "").split(/[\s,/]+/).filter(Boolean);
100
+ return {
101
+ h: ColorOperation.normalizeHue(parseFloat(parts[0]) || 0),
102
+ s: parseFloat(parts[1]) || 0,
103
+ l: parseFloat(parts[2]) || 0,
104
+ };
105
+ }
106
+ let { r, g, b } = ColorOperation.hexToRgb(trimmed);
107
+ return ColorOperation.rgbToHsl(r, g, b);
108
+ }
109
+
110
+ private static normalizeHue(hue: number): number
111
+ {
112
+ return ((hue % 360) + 360) % 360;
113
+ }
114
+
115
+ private static hexToRgb(hex: string): { r: number, g: number, b: number }
116
+ {
117
+ let value = hex.replace("#", "");
118
+ if (value.length === 3)
119
+ value = value.split("").map(ch => ch + ch).join("");
120
+ let num = parseInt(value, 16);
121
+ return {
122
+ r: (num >> 16) & 255,
123
+ g: (num >> 8) & 255,
124
+ b: num & 255,
125
+ };
126
+ }
127
+
128
+ private static rgbToHex(r: number, g: number, b: number): string
129
+ {
130
+ let toHex = (v: number) => Math.round(Math.max(0, Math.min(255, v))).toString(16).padStart(2, "0");
131
+ return `#${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase();
132
+ }
133
+
134
+ private static rgbToHsl(r: number, g: number, b: number): { h: number, s: number, l: number }
135
+ {
136
+ r /= 255; g /= 255; b /= 255;
137
+ let max = Math.max(r, g, b), min = Math.min(r, g, b);
138
+ let l = (max + min) / 2;
139
+ let d = max - min;
140
+ let h = 0, s = 0;
141
+ if (d !== 0)
142
+ {
143
+ s = d / (1 - Math.abs(2 * l - 1));
144
+ switch (max)
145
+ {
146
+ case r: h = ((g - b) / d) % 6; break;
147
+ case g: h = (b - r) / d + 2; break;
148
+ default: h = (r - g) / d + 4; break;
149
+ }
150
+ h *= 60;
151
+ }
152
+ return { h: ColorOperation.normalizeHue(h), s: s * 100, l: l * 100 };
153
+ }
154
154
  }
@@ -1,69 +1,69 @@
1
- export class ConsoleOperation
2
- {
3
- public static colors = {
4
- reset: '\x1b[0m',
5
- red: '\x1b[31m',
6
- green: '\x1b[32m',
7
- yellow: '\x1b[33m',
8
- blue: '\x1b[34m',
9
- magenta: '\x1b[35m',
10
- cyan: '\x1b[36m',
11
- white: '\x1b[37m',
12
- };
13
- static formatLogColor(message: string)
14
- {
15
- return (ConsoleOperation.colors.white + message + ConsoleOperation.colors.reset);
16
- }
17
- static formatInfoColor(message: string)
18
- {
19
- return (ConsoleOperation.colors.cyan + message + ConsoleOperation.colors.reset);
20
- }
21
- static formatTraceColor(message: string)
22
- {
23
- return (ConsoleOperation.colors.blue + message + ConsoleOperation.colors.reset);
24
- }
25
- static formatDebugColor(message: string)
26
- {
27
- return (ConsoleOperation.colors.magenta + message + ConsoleOperation.colors.reset);
28
- }
29
- static formatSuccessColor(message: string)
30
- {
31
- return (ConsoleOperation.colors.green + message + ConsoleOperation.colors.reset);
32
- }
33
- static formatWarningColor(message: string)
34
- {
35
- return (ConsoleOperation.colors.yellow + message + ConsoleOperation.colors.reset);
36
- }
37
- static formatErrorColor(message: string)
38
- {
39
- return (ConsoleOperation.colors.red + message + ConsoleOperation.colors.reset);
40
- }
41
- static log(message: string)
42
- {
43
- console.log(ConsoleOperation.formatLogColor(message));
44
- }
45
- static info(message: string)
46
- {
47
- console.info(ConsoleOperation.formatInfoColor(message));
48
- }
49
- static trace(message: string)
50
- {
51
- console.trace(ConsoleOperation.formatTraceColor(message));
52
- }
53
- static debug(message: string)
54
- {
55
- console.debug(ConsoleOperation.formatDebugColor(message));
56
- }
57
- static success(message: string)
58
- {
59
- console.info(ConsoleOperation.formatSuccessColor(message));
60
- }
61
- static warning(message: string)
62
- {
63
- console.warn(ConsoleOperation.formatWarningColor(message));
64
- }
65
- static error(message: string)
66
- {
67
- console.error(ConsoleOperation.formatErrorColor(message));
68
- }
1
+ export class ConsoleOperation
2
+ {
3
+ public static colors = {
4
+ reset: '\x1b[0m',
5
+ red: '\x1b[31m',
6
+ green: '\x1b[32m',
7
+ yellow: '\x1b[33m',
8
+ blue: '\x1b[34m',
9
+ magenta: '\x1b[35m',
10
+ cyan: '\x1b[36m',
11
+ white: '\x1b[37m',
12
+ };
13
+ static formatLogColor(message: string)
14
+ {
15
+ return (ConsoleOperation.colors.white + message + ConsoleOperation.colors.reset);
16
+ }
17
+ static formatInfoColor(message: string)
18
+ {
19
+ return (ConsoleOperation.colors.cyan + message + ConsoleOperation.colors.reset);
20
+ }
21
+ static formatTraceColor(message: string)
22
+ {
23
+ return (ConsoleOperation.colors.blue + message + ConsoleOperation.colors.reset);
24
+ }
25
+ static formatDebugColor(message: string)
26
+ {
27
+ return (ConsoleOperation.colors.magenta + message + ConsoleOperation.colors.reset);
28
+ }
29
+ static formatSuccessColor(message: string)
30
+ {
31
+ return (ConsoleOperation.colors.green + message + ConsoleOperation.colors.reset);
32
+ }
33
+ static formatWarningColor(message: string)
34
+ {
35
+ return (ConsoleOperation.colors.yellow + message + ConsoleOperation.colors.reset);
36
+ }
37
+ static formatErrorColor(message: string)
38
+ {
39
+ return (ConsoleOperation.colors.red + message + ConsoleOperation.colors.reset);
40
+ }
41
+ static log(message: string)
42
+ {
43
+ console.log(ConsoleOperation.formatLogColor(message));
44
+ }
45
+ static info(message: string)
46
+ {
47
+ console.info(ConsoleOperation.formatInfoColor(message));
48
+ }
49
+ static trace(message: string)
50
+ {
51
+ console.trace(ConsoleOperation.formatTraceColor(message));
52
+ }
53
+ static debug(message: string)
54
+ {
55
+ console.debug(ConsoleOperation.formatDebugColor(message));
56
+ }
57
+ static success(message: string)
58
+ {
59
+ console.info(ConsoleOperation.formatSuccessColor(message));
60
+ }
61
+ static warning(message: string)
62
+ {
63
+ console.warn(ConsoleOperation.formatWarningColor(message));
64
+ }
65
+ static error(message: string)
66
+ {
67
+ console.error(ConsoleOperation.formatErrorColor(message));
68
+ }
69
69
  }