@catbee/utils 0.0.1

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 (183) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +295 -0
  3. package/build/esm/config.d.ts +22 -0
  4. package/build/esm/config.js +21 -0
  5. package/build/esm/config.js.map +1 -0
  6. package/build/esm/index.d.ts +19 -0
  7. package/build/esm/index.js +19 -0
  8. package/build/esm/index.js.map +1 -0
  9. package/build/esm/types/api-response.d.ts +44 -0
  10. package/build/esm/types/api-response.js +2 -0
  11. package/build/esm/types/api-response.js.map +1 -0
  12. package/build/esm/utils/array.utils.d.ts +105 -0
  13. package/build/esm/utils/array.utils.js +232 -0
  14. package/build/esm/utils/array.utils.js.map +1 -0
  15. package/build/esm/utils/async.utils.d.ts +119 -0
  16. package/build/esm/utils/async.utils.js +474 -0
  17. package/build/esm/utils/async.utils.js.map +1 -0
  18. package/build/esm/utils/cache.utils.d.ts +90 -0
  19. package/build/esm/utils/cache.utils.js +294 -0
  20. package/build/esm/utils/cache.utils.js.map +1 -0
  21. package/build/esm/utils/context-store.utils.d.ts +85 -0
  22. package/build/esm/utils/context-store.utils.js +99 -0
  23. package/build/esm/utils/context-store.utils.js.map +1 -0
  24. package/build/esm/utils/crypto.utils.d.ts +58 -0
  25. package/build/esm/utils/crypto.utils.js +76 -0
  26. package/build/esm/utils/crypto.utils.js.map +1 -0
  27. package/build/esm/utils/dir.utils.d.ts +75 -0
  28. package/build/esm/utils/dir.utils.js +400 -0
  29. package/build/esm/utils/dir.utils.js.map +1 -0
  30. package/build/esm/utils/env.utils.d.ts +131 -0
  31. package/build/esm/utils/env.utils.js +218 -0
  32. package/build/esm/utils/env.utils.js.map +1 -0
  33. package/build/esm/utils/exception.utils.d.ts +114 -0
  34. package/build/esm/utils/exception.utils.js +217 -0
  35. package/build/esm/utils/exception.utils.js.map +1 -0
  36. package/build/esm/utils/fs.utils.d.ts +32 -0
  37. package/build/esm/utils/fs.utils.js +140 -0
  38. package/build/esm/utils/fs.utils.js.map +1 -0
  39. package/build/esm/utils/http-status-codes.d.ts +357 -0
  40. package/build/esm/utils/http-status-codes.js +358 -0
  41. package/build/esm/utils/http-status-codes.js.map +1 -0
  42. package/build/esm/utils/id.utils.d.ts +35 -0
  43. package/build/esm/utils/id.utils.js +55 -0
  44. package/build/esm/utils/id.utils.js.map +1 -0
  45. package/build/esm/utils/logger.utils.d.ts +15 -0
  46. package/build/esm/utils/logger.utils.js +59 -0
  47. package/build/esm/utils/logger.utils.js.map +1 -0
  48. package/build/esm/utils/obj.utils.d.ts +55 -0
  49. package/build/esm/utils/obj.utils.js +121 -0
  50. package/build/esm/utils/obj.utils.js.map +1 -0
  51. package/build/esm/utils/response.utils.d.ts +48 -0
  52. package/build/esm/utils/response.utils.js +80 -0
  53. package/build/esm/utils/response.utils.js.map +1 -0
  54. package/build/esm/utils/string.utils.d.ts +37 -0
  55. package/build/esm/utils/string.utils.js +56 -0
  56. package/build/esm/utils/string.utils.js.map +1 -0
  57. package/build/esm/utils/url.utils.d.ts +24 -0
  58. package/build/esm/utils/url.utils.js +73 -0
  59. package/build/esm/utils/url.utils.js.map +1 -0
  60. package/build/esm/utils/validate.utils.d.ts +60 -0
  61. package/build/esm/utils/validate.utils.js +121 -0
  62. package/build/esm/utils/validate.utils.js.map +1 -0
  63. package/build/esnext/config.d.ts +22 -0
  64. package/build/esnext/config.js +21 -0
  65. package/build/esnext/config.js.map +1 -0
  66. package/build/esnext/index.d.ts +19 -0
  67. package/build/esnext/index.js +19 -0
  68. package/build/esnext/index.js.map +1 -0
  69. package/build/esnext/types/api-response.d.ts +44 -0
  70. package/build/esnext/types/api-response.js +2 -0
  71. package/build/esnext/types/api-response.js.map +1 -0
  72. package/build/esnext/utils/array.utils.d.ts +105 -0
  73. package/build/esnext/utils/array.utils.js +203 -0
  74. package/build/esnext/utils/array.utils.js.map +1 -0
  75. package/build/esnext/utils/async.utils.d.ts +119 -0
  76. package/build/esnext/utils/async.utils.js +291 -0
  77. package/build/esnext/utils/async.utils.js.map +1 -0
  78. package/build/esnext/utils/cache.utils.d.ts +90 -0
  79. package/build/esnext/utils/cache.utils.js +142 -0
  80. package/build/esnext/utils/cache.utils.js.map +1 -0
  81. package/build/esnext/utils/context-store.utils.d.ts +85 -0
  82. package/build/esnext/utils/context-store.utils.js +95 -0
  83. package/build/esnext/utils/context-store.utils.js.map +1 -0
  84. package/build/esnext/utils/crypto.utils.d.ts +58 -0
  85. package/build/esnext/utils/crypto.utils.js +72 -0
  86. package/build/esnext/utils/crypto.utils.js.map +1 -0
  87. package/build/esnext/utils/dir.utils.d.ts +75 -0
  88. package/build/esnext/utils/dir.utils.js +150 -0
  89. package/build/esnext/utils/dir.utils.js.map +1 -0
  90. package/build/esnext/utils/env.utils.d.ts +131 -0
  91. package/build/esnext/utils/env.utils.js +211 -0
  92. package/build/esnext/utils/env.utils.js.map +1 -0
  93. package/build/esnext/utils/exception.utils.d.ts +114 -0
  94. package/build/esnext/utils/exception.utils.js +148 -0
  95. package/build/esnext/utils/exception.utils.js.map +1 -0
  96. package/build/esnext/utils/fs.utils.d.ts +32 -0
  97. package/build/esnext/utils/fs.utils.js +62 -0
  98. package/build/esnext/utils/fs.utils.js.map +1 -0
  99. package/build/esnext/utils/http-status-codes.d.ts +357 -0
  100. package/build/esnext/utils/http-status-codes.js +358 -0
  101. package/build/esnext/utils/http-status-codes.js.map +1 -0
  102. package/build/esnext/utils/id.utils.d.ts +35 -0
  103. package/build/esnext/utils/id.utils.js +53 -0
  104. package/build/esnext/utils/id.utils.js.map +1 -0
  105. package/build/esnext/utils/logger.utils.d.ts +15 -0
  106. package/build/esnext/utils/logger.utils.js +59 -0
  107. package/build/esnext/utils/logger.utils.js.map +1 -0
  108. package/build/esnext/utils/obj.utils.d.ts +55 -0
  109. package/build/esnext/utils/obj.utils.js +94 -0
  110. package/build/esnext/utils/obj.utils.js.map +1 -0
  111. package/build/esnext/utils/response.utils.d.ts +48 -0
  112. package/build/esnext/utils/response.utils.js +58 -0
  113. package/build/esnext/utils/response.utils.js.map +1 -0
  114. package/build/esnext/utils/string.utils.d.ts +37 -0
  115. package/build/esnext/utils/string.utils.js +46 -0
  116. package/build/esnext/utils/string.utils.js.map +1 -0
  117. package/build/esnext/utils/url.utils.d.ts +24 -0
  118. package/build/esnext/utils/url.utils.js +35 -0
  119. package/build/esnext/utils/url.utils.js.map +1 -0
  120. package/build/esnext/utils/validate.utils.d.ts +60 -0
  121. package/build/esnext/utils/validate.utils.js +105 -0
  122. package/build/esnext/utils/validate.utils.js.map +1 -0
  123. package/build/src/config.d.ts +22 -0
  124. package/build/src/config.js +24 -0
  125. package/build/src/config.js.map +1 -0
  126. package/build/src/index.d.ts +19 -0
  127. package/build/src/index.js +35 -0
  128. package/build/src/index.js.map +1 -0
  129. package/build/src/types/api-response.d.ts +44 -0
  130. package/build/src/types/api-response.js +3 -0
  131. package/build/src/types/api-response.js.map +1 -0
  132. package/build/src/utils/array.utils.d.ts +105 -0
  133. package/build/src/utils/array.utils.js +216 -0
  134. package/build/src/utils/array.utils.js.map +1 -0
  135. package/build/src/utils/async.utils.d.ts +119 -0
  136. package/build/src/utils/async.utils.js +304 -0
  137. package/build/src/utils/async.utils.js.map +1 -0
  138. package/build/src/utils/cache.utils.d.ts +90 -0
  139. package/build/src/utils/cache.utils.js +146 -0
  140. package/build/src/utils/cache.utils.js.map +1 -0
  141. package/build/src/utils/context-store.utils.d.ts +85 -0
  142. package/build/src/utils/context-store.utils.js +100 -0
  143. package/build/src/utils/context-store.utils.js.map +1 -0
  144. package/build/src/utils/crypto.utils.d.ts +58 -0
  145. package/build/src/utils/crypto.utils.js +82 -0
  146. package/build/src/utils/crypto.utils.js.map +1 -0
  147. package/build/src/utils/dir.utils.d.ts +75 -0
  148. package/build/src/utils/dir.utils.js +164 -0
  149. package/build/src/utils/dir.utils.js.map +1 -0
  150. package/build/src/utils/env.utils.d.ts +131 -0
  151. package/build/src/utils/env.utils.js +215 -0
  152. package/build/src/utils/env.utils.js.map +1 -0
  153. package/build/src/utils/exception.utils.d.ts +114 -0
  154. package/build/src/utils/exception.utils.js +162 -0
  155. package/build/src/utils/exception.utils.js.map +1 -0
  156. package/build/src/utils/fs.utils.d.ts +32 -0
  157. package/build/src/utils/fs.utils.js +71 -0
  158. package/build/src/utils/fs.utils.js.map +1 -0
  159. package/build/src/utils/http-status-codes.d.ts +357 -0
  160. package/build/src/utils/http-status-codes.js +361 -0
  161. package/build/src/utils/http-status-codes.js.map +1 -0
  162. package/build/src/utils/id.utils.d.ts +35 -0
  163. package/build/src/utils/id.utils.js +60 -0
  164. package/build/src/utils/id.utils.js.map +1 -0
  165. package/build/src/utils/logger.utils.d.ts +15 -0
  166. package/build/src/utils/logger.utils.js +96 -0
  167. package/build/src/utils/logger.utils.js.map +1 -0
  168. package/build/src/utils/obj.utils.d.ts +55 -0
  169. package/build/src/utils/obj.utils.js +103 -0
  170. package/build/src/utils/obj.utils.js.map +1 -0
  171. package/build/src/utils/response.utils.d.ts +48 -0
  172. package/build/src/utils/response.utils.js +63 -0
  173. package/build/src/utils/response.utils.js.map +1 -0
  174. package/build/src/utils/string.utils.d.ts +37 -0
  175. package/build/src/utils/string.utils.js +54 -0
  176. package/build/src/utils/string.utils.js.map +1 -0
  177. package/build/src/utils/url.utils.d.ts +24 -0
  178. package/build/src/utils/url.utils.js +39 -0
  179. package/build/src/utils/url.utils.js.map +1 -0
  180. package/build/src/utils/validate.utils.d.ts +60 -0
  181. package/build/src/utils/validate.utils.js +115 -0
  182. package/build/src/utils/validate.utils.js.map +1 -0
  183. package/package.json +80 -0
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Checks whether the object has no own enumerable properties.
3
+ *
4
+ * @param {Record<any, any>} obj - The object to check.
5
+ * @returns {boolean} True if the object is empty, false otherwise.
6
+ */
7
+ export declare const isObjEmpty: (obj: Record<any, any>) => boolean;
8
+ /**
9
+ * Returns a new object with only the specified keys picked.
10
+ *
11
+ * @template T
12
+ * @template K
13
+ * @param {T} obj - The source object.
14
+ * @param {K[]} keys - Keys to pick from the object.
15
+ * @returns {Pick<T, K>} New object with picked keys.
16
+ */
17
+ export declare const pick: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
18
+ /**
19
+ * Returns a new object with the specified keys omitted.
20
+ *
21
+ * @template T
22
+ * @template K
23
+ * @param {T} obj - The source object.
24
+ * @param {K[]} keys - Keys to omit from the object.
25
+ * @returns {Omit<T, K>} New object without omitted keys.
26
+ */
27
+ export declare const omit: <T extends object, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
28
+ /**
29
+ * Deeply merges two objects (mutates and returns the target object, not pure).
30
+ *
31
+ * @template T
32
+ * @param {T} target - The object to merge into (will be mutated).
33
+ * @param {Partial<T>} source - The object to merge from.
34
+ * @returns {T} The merged object (same as target).
35
+ */
36
+ export declare function deepObjMerge<T extends Record<string, any>>(target: T, source: Partial<T>): T;
37
+ /**
38
+ * Flattens a nested object using dot notation for keys (e.g., `{a: {b: 1}}` → `{ "a.b": 1 }`).
39
+ *
40
+ * @template T
41
+ * @param {T} obj - The object to flatten.
42
+ * @param {string} [prefix=""] - Optional prefix for nested keys (used internally).
43
+ * @returns {Record<string, any>} A new object with flattened keys.
44
+ */
45
+ export declare function flattenObject<T extends Record<string, any>>(obj: T, prefix?: string): Record<string, any>;
46
+ /**
47
+ * Safely gets the value of a deeply nested key in an object using dot/bracket notation path.
48
+ *
49
+ * @template T
50
+ * @param {T} obj - The object to extract from.
51
+ * @param {string} path - String path using dot and/or bracket notation (e.g., 'user.friends[0].name').
52
+ * @returns {any} The value at the given path, or undefined if not found.
53
+ */
54
+ export declare function getValueByPath<T extends object>(obj: T, path: string): any;
55
+ //# sourceMappingURL=obj.utils.d.ts.map
@@ -0,0 +1,121 @@
1
+ var __read = (this && this.__read) || function (o, n) {
2
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
3
+ if (!m) return o;
4
+ var i = m.call(o), r, ar = [], e;
5
+ try {
6
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
+ }
8
+ catch (error) { e = { error: error }; }
9
+ finally {
10
+ try {
11
+ if (r && !r.done && (m = i["return"])) m.call(i);
12
+ }
13
+ finally { if (e) throw e.error; }
14
+ }
15
+ return ar;
16
+ };
17
+ /**
18
+ * Checks whether the object has no own enumerable properties.
19
+ *
20
+ * @param {Record<any, any>} obj - The object to check.
21
+ * @returns {boolean} True if the object is empty, false otherwise.
22
+ */
23
+ export var isObjEmpty = function (obj) {
24
+ return !!obj && typeof obj === "object" && Object.keys(obj).length === 0;
25
+ };
26
+ /**
27
+ * Returns a new object with only the specified keys picked.
28
+ *
29
+ * @template T
30
+ * @template K
31
+ * @param {T} obj - The source object.
32
+ * @param {K[]} keys - Keys to pick from the object.
33
+ * @returns {Pick<T, K>} New object with picked keys.
34
+ */
35
+ export var pick = function (obj, keys) {
36
+ return Object.fromEntries(keys.map(function (key) { return [key, obj[key]]; }));
37
+ };
38
+ /**
39
+ * Returns a new object with the specified keys omitted.
40
+ *
41
+ * @template T
42
+ * @template K
43
+ * @param {T} obj - The source object.
44
+ * @param {K[]} keys - Keys to omit from the object.
45
+ * @returns {Omit<T, K>} New object without omitted keys.
46
+ */
47
+ export var omit = function (obj, keys) {
48
+ return Object.fromEntries(Object.entries(obj).filter(function (_a) {
49
+ var _b = __read(_a, 1), key = _b[0];
50
+ return !keys.includes(key);
51
+ }));
52
+ };
53
+ /**
54
+ * Deeply merges two objects (mutates and returns the target object, not pure).
55
+ *
56
+ * @template T
57
+ * @param {T} target - The object to merge into (will be mutated).
58
+ * @param {Partial<T>} source - The object to merge from.
59
+ * @returns {T} The merged object (same as target).
60
+ */
61
+ export function deepObjMerge(target, source) {
62
+ for (var key in source) {
63
+ var sourceVal = source[key];
64
+ var targetVal = target[key];
65
+ if (sourceVal &&
66
+ typeof sourceVal === "object" &&
67
+ !Array.isArray(sourceVal)) {
68
+ if (!targetVal ||
69
+ typeof targetVal !== "object" ||
70
+ Array.isArray(targetVal)) {
71
+ target[key] = {};
72
+ }
73
+ deepObjMerge(target[key], sourceVal);
74
+ }
75
+ else {
76
+ target[key] = sourceVal;
77
+ }
78
+ }
79
+ return target;
80
+ }
81
+ /**
82
+ * Flattens a nested object using dot notation for keys (e.g., `{a: {b: 1}}` → `{ "a.b": 1 }`).
83
+ *
84
+ * @template T
85
+ * @param {T} obj - The object to flatten.
86
+ * @param {string} [prefix=""] - Optional prefix for nested keys (used internally).
87
+ * @returns {Record<string, any>} A new object with flattened keys.
88
+ */
89
+ export function flattenObject(obj, prefix) {
90
+ if (prefix === void 0) { prefix = ""; }
91
+ return Object.entries(obj).reduce(function (acc, _a) {
92
+ var _b = __read(_a, 2), key = _b[0], value = _b[1];
93
+ var newKey = prefix ? "".concat(prefix, ".").concat(key) : key;
94
+ if (value && typeof value === "object" && !Array.isArray(value)) {
95
+ Object.assign(acc, flattenObject(value, newKey));
96
+ }
97
+ else {
98
+ acc[newKey] = value;
99
+ }
100
+ return acc;
101
+ }, {});
102
+ }
103
+ /**
104
+ * Safely gets the value of a deeply nested key in an object using dot/bracket notation path.
105
+ *
106
+ * @template T
107
+ * @param {T} obj - The object to extract from.
108
+ * @param {string} path - String path using dot and/or bracket notation (e.g., 'user.friends[0].name').
109
+ * @returns {any} The value at the given path, or undefined if not found.
110
+ */
111
+ export function getValueByPath(obj, path) {
112
+ if (!obj || typeof obj !== "object")
113
+ return undefined;
114
+ // Convert path like "a.b[0].c" into ["a", "b", "0", "c"]
115
+ var parts = path
116
+ .replace(/\[(\d+)\]/g, ".$1") // convert [0] to .0
117
+ .split(".")
118
+ .filter(Boolean); // remove empty strings
119
+ return parts.reduce(function (acc, key) { return acc === null || acc === void 0 ? void 0 : acc[key]; }, obj);
120
+ }
121
+ //# sourceMappingURL=obj.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"obj.utils.js","sourceRoot":"","sources":["../../../src/utils/obj.utils.ts"],"names":[],"mappings":"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","sourcesContent":["/**\n * Checks whether the object has no own enumerable properties.\n *\n * @param {Record<any, any>} obj - The object to check.\n * @returns {boolean} True if the object is empty, false otherwise.\n */\nexport const isObjEmpty = (obj: Record<any, any>): boolean =>\n !!obj && typeof obj === \"object\" && Object.keys(obj).length === 0;\n\n/**\n * Returns a new object with only the specified keys picked.\n *\n * @template T\n * @template K\n * @param {T} obj - The source object.\n * @param {K[]} keys - Keys to pick from the object.\n * @returns {Pick<T, K>} New object with picked keys.\n */\nexport const pick = <T extends object, K extends keyof T>(\n obj: T,\n keys: K[],\n): Pick<T, K> =>\n Object.fromEntries(keys.map((key) => [key, obj[key]])) as Pick<T, K>;\n\n/**\n * Returns a new object with the specified keys omitted.\n *\n * @template T\n * @template K\n * @param {T} obj - The source object.\n * @param {K[]} keys - Keys to omit from the object.\n * @returns {Omit<T, K>} New object without omitted keys.\n */\nexport const omit = <T extends object, K extends keyof T>(\n obj: T,\n keys: K[],\n): Omit<T, K> =>\n Object.fromEntries(\n Object.entries(obj).filter(([key]) => !keys.includes(key as K)),\n ) as Omit<T, K>;\n\n/**\n * Deeply merges two objects (mutates and returns the target object, not pure).\n *\n * @template T\n * @param {T} target - The object to merge into (will be mutated).\n * @param {Partial<T>} source - The object to merge from.\n * @returns {T} The merged object (same as target).\n */\nexport function deepObjMerge<T extends Record<string, any>>(\n target: T,\n source: Partial<T>,\n): T {\n for (const key in source) {\n const sourceVal = source[key];\n const targetVal = target[key];\n\n if (\n sourceVal &&\n typeof sourceVal === \"object\" &&\n !Array.isArray(sourceVal)\n ) {\n if (\n !targetVal ||\n typeof targetVal !== \"object\" ||\n Array.isArray(targetVal)\n ) {\n target[key] = {} as any;\n }\n deepObjMerge(target[key], sourceVal as any);\n } else {\n target[key] = sourceVal as T[Extract<keyof T, string>];\n }\n }\n return target;\n}\n\n/**\n * Flattens a nested object using dot notation for keys (e.g., `{a: {b: 1}}` → `{ \"a.b\": 1 }`).\n *\n * @template T\n * @param {T} obj - The object to flatten.\n * @param {string} [prefix=\"\"] - Optional prefix for nested keys (used internally).\n * @returns {Record<string, any>} A new object with flattened keys.\n */\nexport function flattenObject<T extends Record<string, any>>(\n obj: T,\n prefix = \"\",\n): Record<string, any> {\n return Object.entries(obj).reduce(\n (acc: Record<string, any>, [key, value]) => {\n const newKey = prefix ? `${prefix}.${key}` : key;\n\n if (value && typeof value === \"object\" && !Array.isArray(value)) {\n Object.assign(acc, flattenObject(value, newKey));\n } else {\n acc[newKey] = value;\n }\n\n return acc;\n },\n {},\n );\n}\n\n/**\n * Safely gets the value of a deeply nested key in an object using dot/bracket notation path.\n *\n * @template T\n * @param {T} obj - The object to extract from.\n * @param {string} path - String path using dot and/or bracket notation (e.g., 'user.friends[0].name').\n * @returns {any} The value at the given path, or undefined if not found.\n */\nexport function getValueByPath<T extends object>(obj: T, path: string) {\n if (!obj || typeof obj !== \"object\") return undefined;\n\n // Convert path like \"a.b[0].c\" into [\"a\", \"b\", \"0\", \"c\"]\n const parts = path\n .replace(/\\[(\\d+)\\]/g, \".$1\") // convert [0] to .0\n .split(\".\")\n .filter(Boolean); // remove empty strings\n\n return parts.reduce((acc: any, key: string) => acc?.[key], obj);\n}\n"]}
@@ -0,0 +1,48 @@
1
+ import { ApiResponse } from "../types/api-response";
2
+ /**
3
+ * Standard HTTP response wrapper for successful responses.
4
+ * Implements the `ApiResponse<T>` interface and sets default values.
5
+ *
6
+ * @typeParam T - The shape of the data returned in the response.
7
+ */
8
+ export declare class SuccessResponse<T> implements ApiResponse<T> {
9
+ /** Message describing the result of the operation. */
10
+ message: string;
11
+ /** Whether the response is an error. Always false in success responses. */
12
+ error: boolean;
13
+ /** The payload returned from the API. */
14
+ data: T | null;
15
+ /** Timestamp when the response was generated, in ISO format. */
16
+ timestamp: string;
17
+ /** Unique identifier for this response, useful for request tracing. */
18
+ requestId: string;
19
+ /**
20
+ * Constructs a new success response.
21
+ *
22
+ * @param {string} message - Optional message to override the default.
23
+ * @param {T} [data] - Optional data payload.
24
+ */
25
+ constructor(message: string, data?: T);
26
+ }
27
+ /**
28
+ * Wrapper for error responses that extends the native `Error` object.
29
+ * Implements `ApiResponse` but omits the `data` field (which should not be present in errors).
30
+ */
31
+ export declare class ErrorResponse extends Error implements Omit<ApiResponse<never>, "data"> {
32
+ /** HTTP status code associated with the error (e.g., 404, 500). */
33
+ status: number;
34
+ /** Indicates that this is an error. Always true. */
35
+ error: boolean;
36
+ /** Timestamp when the error occurred, in ISO format. */
37
+ timestamp: string;
38
+ /** Unique identifier for this error instance. */
39
+ requestId: string;
40
+ /**
41
+ * Constructs a new error response.
42
+ *
43
+ * @param {string} message - The error message to display or log.
44
+ * @param {number} [status=500] - Optional HTTP status code (defaults to 500).
45
+ */
46
+ constructor(message: string, status?: number);
47
+ }
48
+ //# sourceMappingURL=response.utils.d.ts.map
@@ -0,0 +1,80 @@
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
16
+ import { randomUUID } from "crypto";
17
+ import { getRequestId } from "./context-store.utils";
18
+ /**
19
+ * Standard HTTP response wrapper for successful responses.
20
+ * Implements the `ApiResponse<T>` interface and sets default values.
21
+ *
22
+ * @typeParam T - The shape of the data returned in the response.
23
+ */
24
+ var SuccessResponse = /** @class */ (function () {
25
+ /**
26
+ * Constructs a new success response.
27
+ *
28
+ * @param {string} message - Optional message to override the default.
29
+ * @param {T} [data] - Optional data payload.
30
+ */
31
+ function SuccessResponse(message, data) {
32
+ var _a;
33
+ /** Message describing the result of the operation. */
34
+ this.message = "Success";
35
+ /** Whether the response is an error. Always false in success responses. */
36
+ this.error = false;
37
+ /** The payload returned from the API. */
38
+ this.data = null;
39
+ /** Timestamp when the response was generated, in ISO format. */
40
+ this.timestamp = new Date().toISOString();
41
+ /** Unique identifier for this response, useful for request tracing. */
42
+ this.requestId = (_a = getRequestId()) !== null && _a !== void 0 ? _a : randomUUID();
43
+ if (message)
44
+ this.message = message;
45
+ this.data = data !== null && data !== void 0 ? data : null;
46
+ }
47
+ return SuccessResponse;
48
+ }());
49
+ export { SuccessResponse };
50
+ /**
51
+ * Wrapper for error responses that extends the native `Error` object.
52
+ * Implements `ApiResponse` but omits the `data` field (which should not be present in errors).
53
+ */
54
+ var ErrorResponse = /** @class */ (function (_super) {
55
+ __extends(ErrorResponse, _super);
56
+ /**
57
+ * Constructs a new error response.
58
+ *
59
+ * @param {string} message - The error message to display or log.
60
+ * @param {number} [status=500] - Optional HTTP status code (defaults to 500).
61
+ */
62
+ function ErrorResponse(message, status) {
63
+ if (status === void 0) { status = 500; }
64
+ var _a;
65
+ var _this = _super.call(this, message) || this;
66
+ /** Indicates that this is an error. Always true. */
67
+ _this.error = true;
68
+ /** Timestamp when the error occurred, in ISO format. */
69
+ _this.timestamp = new Date().toISOString();
70
+ /** Unique identifier for this error instance. */
71
+ _this.requestId = (_a = getRequestId()) !== null && _a !== void 0 ? _a : randomUUID();
72
+ _this.status = status;
73
+ _this.name = _this.constructor.name;
74
+ Error.captureStackTrace(_this, _this.constructor);
75
+ return _this;
76
+ }
77
+ return ErrorResponse;
78
+ }(Error));
79
+ export { ErrorResponse };
80
+ //# sourceMappingURL=response.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response.utils.js","sourceRoot":"","sources":["../../../src/utils/response.utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD;;;;;GAKG;AACH;IAgBE;;;;;OAKG;IACH,yBAAY,OAAe,EAAE,IAAQ;;QArBrC,sDAAsD;QACtD,YAAO,GAAW,SAAS,CAAC;QAE5B,2EAA2E;QAC3E,UAAK,GAAY,KAAK,CAAC;QAEvB,yCAAyC;QACzC,SAAI,GAAa,IAAI,CAAC;QAEtB,gEAAgE;QAChE,cAAS,GAAW,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAE7C,uEAAuE;QACvE,cAAS,GAAW,MAAA,YAAY,EAAE,mCAAI,UAAU,EAAE,CAAC;QASjD,IAAI,OAAO;YAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,IAAI,CAAC;IAC3B,CAAC;IACH,sBAAC;AAAD,CAAC,AA1BD,IA0BC;;AAED;;;GAGG;AACH;IACU,iCAAK;IAeb;;;;;OAKG;IACH,uBAAY,OAAe,EAAE,MAAoB;QAApB,uBAAA,EAAA,YAAoB;;QAC/C,YAAA,MAAK,YAAC,OAAO,CAAC,SAAC;QAhBjB,oDAAoD;QACpD,WAAK,GAAY,IAAI,CAAC;QAEtB,wDAAwD;QACxD,eAAS,GAAW,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAE7C,iDAAiD;QACjD,eAAS,GAAW,MAAA,YAAY,EAAE,mCAAI,UAAU,EAAE,CAAC;QAUjD,KAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,KAAI,CAAC,IAAI,GAAG,KAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,KAAK,CAAC,iBAAiB,CAAC,KAAI,EAAE,KAAI,CAAC,WAAW,CAAC,CAAC;;IAClD,CAAC;IACH,oBAAC;AAAD,CAAC,AA5BD,CACU,KAAK,GA2Bd","sourcesContent":["import { randomUUID } from \"crypto\";\nimport { ApiResponse } from \"../types/api-response\";\nimport { getRequestId } from \"./context-store.utils\";\n\n/**\n * Standard HTTP response wrapper for successful responses.\n * Implements the `ApiResponse<T>` interface and sets default values.\n *\n * @typeParam T - The shape of the data returned in the response.\n */\nexport class SuccessResponse<T> implements ApiResponse<T> {\n /** Message describing the result of the operation. */\n message: string = \"Success\";\n\n /** Whether the response is an error. Always false in success responses. */\n error: boolean = false;\n\n /** The payload returned from the API. */\n data: T | null = null;\n\n /** Timestamp when the response was generated, in ISO format. */\n timestamp: string = new Date().toISOString();\n\n /** Unique identifier for this response, useful for request tracing. */\n requestId: string = getRequestId() ?? randomUUID();\n\n /**\n * Constructs a new success response.\n *\n * @param {string} message - Optional message to override the default.\n * @param {T} [data] - Optional data payload.\n */\n constructor(message: string, data?: T) {\n if (message) this.message = message;\n this.data = data ?? null;\n }\n}\n\n/**\n * Wrapper for error responses that extends the native `Error` object.\n * Implements `ApiResponse` but omits the `data` field (which should not be present in errors).\n */\nexport class ErrorResponse\n extends Error\n implements Omit<ApiResponse<never>, \"data\">\n{\n /** HTTP status code associated with the error (e.g., 404, 500). */\n status: number;\n\n /** Indicates that this is an error. Always true. */\n error: boolean = true;\n\n /** Timestamp when the error occurred, in ISO format. */\n timestamp: string = new Date().toISOString();\n\n /** Unique identifier for this error instance. */\n requestId: string = getRequestId() ?? randomUUID();\n\n /**\n * Constructs a new error response.\n *\n * @param {string} message - The error message to display or log.\n * @param {number} [status=500] - Optional HTTP status code (defaults to 500).\n */\n constructor(message: string, status: number = 500) {\n super(message);\n this.status = status;\n this.name = this.constructor.name;\n Error.captureStackTrace(this, this.constructor);\n }\n}\n"]}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Capitalizes the first character of a string.
3
+ *
4
+ * @param {string} str - The input string.
5
+ * @returns {string} The string with the first character in uppercase.
6
+ */
7
+ export declare const capitalize: (str: string) => string;
8
+ /**
9
+ * Converts a string to kebab-case (e.g., "FooBar test" → "foo-bar-test").
10
+ *
11
+ * @param {string} str - The input string.
12
+ * @returns {string} The kebab-cased string.
13
+ */
14
+ export declare const toKebabCase: (str: string) => string;
15
+ /**
16
+ * Converts a kebab-case or snake_case string to camelCase.
17
+ *
18
+ * @param {string} str - The input string.
19
+ * @returns {string} The camelCased string.
20
+ */
21
+ export declare const toCamelCase: (str: string) => string;
22
+ /**
23
+ * Converts a string to a URL-friendly slug (lowercase, dashes, alphanumeric).
24
+ *
25
+ * @param {string} str - The input string.
26
+ * @returns {string} The slugified string.
27
+ */
28
+ export declare const slugify: (str: string) => string;
29
+ /**
30
+ * Truncates a string to a specific length, appending '...' if truncated.
31
+ *
32
+ * @param {string} str - The input string.
33
+ * @param {number} len - The maximum length.
34
+ * @returns {string} The truncated string.
35
+ */
36
+ export declare const truncate: (str: string, len: number) => string;
37
+ //# sourceMappingURL=string.utils.d.ts.map
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Capitalizes the first character of a string.
3
+ *
4
+ * @param {string} str - The input string.
5
+ * @returns {string} The string with the first character in uppercase.
6
+ */
7
+ export var capitalize = function (str) {
8
+ return str.length === 0 ? "" : str.charAt(0).toUpperCase() + str.slice(1);
9
+ };
10
+ /**
11
+ * Converts a string to kebab-case (e.g., "FooBar test" → "foo-bar-test").
12
+ *
13
+ * @param {string} str - The input string.
14
+ * @returns {string} The kebab-cased string.
15
+ */
16
+ export var toKebabCase = function (str) {
17
+ return str
18
+ .replace(/([a-z])([A-Z])/g, "$1-$2") // camelCase -> camel-Case
19
+ .replace(/\s+/g, "-") // spaces to dash
20
+ .replace(/_+/g, "-") // underscores to dash
21
+ .toLowerCase();
22
+ };
23
+ /**
24
+ * Converts a kebab-case or snake_case string to camelCase.
25
+ *
26
+ * @param {string} str - The input string.
27
+ * @returns {string} The camelCased string.
28
+ */
29
+ export var toCamelCase = function (str) {
30
+ return str.replace(/[-_](.)/g, function (_, c) { return c.toUpperCase(); });
31
+ };
32
+ /**
33
+ * Converts a string to a URL-friendly slug (lowercase, dashes, alphanumeric).
34
+ *
35
+ * @param {string} str - The input string.
36
+ * @returns {string} The slugified string.
37
+ */
38
+ export var slugify = function (str) {
39
+ return str
40
+ .toLowerCase()
41
+ .replace(/[^\w\s-]/g, "") // remove non-word
42
+ .replace(/\s+/g, "-") // spaces to dash
43
+ .replace(/-+/g, "-") // multiple dashes to one
44
+ .replace(/^-+|-+$/g, "");
45
+ }; // trim leading/trailing dashes
46
+ /**
47
+ * Truncates a string to a specific length, appending '...' if truncated.
48
+ *
49
+ * @param {string} str - The input string.
50
+ * @param {number} len - The maximum length.
51
+ * @returns {string} The truncated string.
52
+ */
53
+ export var truncate = function (str, len) {
54
+ return str.length > len ? str.slice(0, len) + "..." : str;
55
+ };
56
+ //# sourceMappingURL=string.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string.utils.js","sourceRoot":"","sources":["../../../src/utils/string.utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,IAAM,UAAU,GAAG,UAAC,GAAW;IACpC,OAAA,GAAG,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAAlE,CAAkE,CAAC;AAErE;;;;;GAKG;AACH,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,GAAW;IACrC,OAAA,GAAG;SACA,OAAO,CAAC,iBAAiB,EAAE,OAAO,CAAC,CAAC,0BAA0B;SAC9D,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,iBAAiB;SACtC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,sBAAsB;SAC1C,WAAW,EAAE;AAJhB,CAIgB,CAAC;AAEnB;;;;;GAKG;AACH,MAAM,CAAC,IAAM,WAAW,GAAG,UAAC,GAAW;IACrC,OAAA,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,UAAC,CAAC,EAAE,CAAS,IAAK,OAAA,CAAC,CAAC,WAAW,EAAE,EAAf,CAAe,CAAC;AAA1D,CAA0D,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,CAAC,IAAM,OAAO,GAAG,UAAC,GAAW;IACjC,OAAA,GAAG;SACA,WAAW,EAAE;SACb,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,kBAAkB;SAC3C,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,iBAAiB;SACtC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,yBAAyB;SAC7C,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;AAL1B,CAK0B,CAAC,CAAC,+BAA+B;AAE7D;;;;;;GAMG;AACH,MAAM,CAAC,IAAM,QAAQ,GAAG,UAAC,GAAW,EAAE,GAAW;IAC/C,OAAA,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,GAAG;AAAlD,CAAkD,CAAC","sourcesContent":["/**\n * Capitalizes the first character of a string.\n *\n * @param {string} str - The input string.\n * @returns {string} The string with the first character in uppercase.\n */\nexport const capitalize = (str: string): string =>\n str.length === 0 ? \"\" : str.charAt(0).toUpperCase() + str.slice(1);\n\n/**\n * Converts a string to kebab-case (e.g., \"FooBar test\" → \"foo-bar-test\").\n *\n * @param {string} str - The input string.\n * @returns {string} The kebab-cased string.\n */\nexport const toKebabCase = (str: string): string =>\n str\n .replace(/([a-z])([A-Z])/g, \"$1-$2\") // camelCase -> camel-Case\n .replace(/\\s+/g, \"-\") // spaces to dash\n .replace(/_+/g, \"-\") // underscores to dash\n .toLowerCase();\n\n/**\n * Converts a kebab-case or snake_case string to camelCase.\n *\n * @param {string} str - The input string.\n * @returns {string} The camelCased string.\n */\nexport const toCamelCase = (str: string): string =>\n str.replace(/[-_](.)/g, (_, c: string) => c.toUpperCase());\n\n/**\n * Converts a string to a URL-friendly slug (lowercase, dashes, alphanumeric).\n *\n * @param {string} str - The input string.\n * @returns {string} The slugified string.\n */\nexport const slugify = (str: string): string =>\n str\n .toLowerCase()\n .replace(/[^\\w\\s-]/g, \"\") // remove non-word\n .replace(/\\s+/g, \"-\") // spaces to dash\n .replace(/-+/g, \"-\") // multiple dashes to one\n .replace(/^-+|-+$/g, \"\"); // trim leading/trailing dashes\n\n/**\n * Truncates a string to a specific length, appending '...' if truncated.\n *\n * @param {string} str - The input string.\n * @param {number} len - The maximum length.\n * @returns {string} The truncated string.\n */\nexport const truncate = (str: string, len: number): string =>\n str.length > len ? str.slice(0, len) + \"...\" : str;\n"]}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Appends query parameters to a given URL.
3
+ *
4
+ * @param {string} url - The base URL to which query parameters will be appended.
5
+ * @param {Record<string, string | number>} params - Key-value pairs to add as query parameters.
6
+ * @returns {string} The new URL string with query parameters appended.
7
+ *
8
+ * @example
9
+ * appendQueryParams('https://example.com', { page: 1, limit: 10 });
10
+ * // → 'https://example.com/?page=1&limit=10'
11
+ */
12
+ export declare function appendQueryParams(url: string, params: Record<string, string | number>): string;
13
+ /**
14
+ * Parses a query string into a key-value object.
15
+ *
16
+ * @param {string} query - The query string (with or without leading '?').
17
+ * @returns {Record<string, string>} Object representing parsed query parameters.
18
+ *
19
+ * @example
20
+ * parseQueryString('?page=1&limit=10');
21
+ * // → { page: '1', limit: '10' }
22
+ */
23
+ export declare function parseQueryString(query: string): Record<string, string>;
24
+ //# sourceMappingURL=url.utils.d.ts.map
@@ -0,0 +1,73 @@
1
+ var __values = (this && this.__values) || function(o) {
2
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
+ if (m) return m.call(o);
4
+ if (o && typeof o.length === "number") return {
5
+ next: function () {
6
+ if (o && i >= o.length) o = void 0;
7
+ return { value: o && o[i++], done: !o };
8
+ }
9
+ };
10
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
+ };
12
+ var __read = (this && this.__read) || function (o, n) {
13
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
14
+ if (!m) return o;
15
+ var i = m.call(o), r, ar = [], e;
16
+ try {
17
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
18
+ }
19
+ catch (error) { e = { error: error }; }
20
+ finally {
21
+ try {
22
+ if (r && !r.done && (m = i["return"])) m.call(i);
23
+ }
24
+ finally { if (e) throw e.error; }
25
+ }
26
+ return ar;
27
+ };
28
+ import { URL, URLSearchParams } from "url";
29
+ /**
30
+ * Appends query parameters to a given URL.
31
+ *
32
+ * @param {string} url - The base URL to which query parameters will be appended.
33
+ * @param {Record<string, string | number>} params - Key-value pairs to add as query parameters.
34
+ * @returns {string} The new URL string with query parameters appended.
35
+ *
36
+ * @example
37
+ * appendQueryParams('https://example.com', { page: 1, limit: 10 });
38
+ * // → 'https://example.com/?page=1&limit=10'
39
+ */
40
+ export function appendQueryParams(url, params) {
41
+ var e_1, _a;
42
+ var urlObj = new URL(url);
43
+ try {
44
+ for (var _b = __values(Object.entries(params)), _c = _b.next(); !_c.done; _c = _b.next()) {
45
+ var _d = __read(_c.value, 2), key = _d[0], value = _d[1];
46
+ urlObj.searchParams.set(key, value.toString());
47
+ }
48
+ }
49
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
50
+ finally {
51
+ try {
52
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
53
+ }
54
+ finally { if (e_1) throw e_1.error; }
55
+ }
56
+ return urlObj.toString();
57
+ }
58
+ /**
59
+ * Parses a query string into a key-value object.
60
+ *
61
+ * @param {string} query - The query string (with or without leading '?').
62
+ * @returns {Record<string, string>} Object representing parsed query parameters.
63
+ *
64
+ * @example
65
+ * parseQueryString('?page=1&limit=10');
66
+ * // → { page: '1', limit: '10' }
67
+ */
68
+ export function parseQueryString(query) {
69
+ var cleanQuery = query.startsWith("?") ? query.slice(1) : query;
70
+ // Object.fromEntries guarantees string values in result
71
+ return Object.fromEntries(new URLSearchParams(cleanQuery));
72
+ }
73
+ //# sourceMappingURL=url.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"url.utils.js","sourceRoot":"","sources":["../../../src/utils/url.utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,MAAM,KAAK,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAC/B,GAAW,EACX,MAAuC;;IAEvC,IAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;;QAC5B,KAA2B,IAAA,KAAA,SAAA,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA,gBAAA,4BAAE,CAAC;YAAzC,IAAA,KAAA,mBAAY,EAAX,GAAG,QAAA,EAAE,KAAK,QAAA;YACpB,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;QACjD,CAAC;;;;;;;;;IACD,OAAO,MAAM,CAAC,QAAQ,EAAE,CAAC;AAC3B,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAM,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAClE,wDAAwD;IACxD,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,eAAe,CAAC,UAAU,CAAC,CAGxD,CAAC;AACJ,CAAC","sourcesContent":["import { URL, URLSearchParams } from \"url\";\n\n/**\n * Appends query parameters to a given URL.\n *\n * @param {string} url - The base URL to which query parameters will be appended.\n * @param {Record<string, string | number>} params - Key-value pairs to add as query parameters.\n * @returns {string} The new URL string with query parameters appended.\n *\n * @example\n * appendQueryParams('https://example.com', { page: 1, limit: 10 });\n * // → 'https://example.com/?page=1&limit=10'\n */\nexport function appendQueryParams(\n url: string,\n params: Record<string, string | number>,\n): string {\n const urlObj = new URL(url);\n for (const [key, value] of Object.entries(params)) {\n urlObj.searchParams.set(key, value.toString());\n }\n return urlObj.toString();\n}\n\n/**\n * Parses a query string into a key-value object.\n *\n * @param {string} query - The query string (with or without leading '?').\n * @returns {Record<string, string>} Object representing parsed query parameters.\n *\n * @example\n * parseQueryString('?page=1&limit=10');\n * // → { page: '1', limit: '10' }\n */\nexport function parseQueryString(query: string): Record<string, string> {\n const cleanQuery = query.startsWith(\"?\") ? query.slice(1) : query;\n // Object.fromEntries guarantees string values in result\n return Object.fromEntries(new URLSearchParams(cleanQuery)) as Record<\n string,\n string\n >;\n}\n"]}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Collection of common validation helpers for strings, numbers, email, UUID, etc.
3
+ */
4
+ /**
5
+ * Checks if a string is a valid email address.
6
+ *
7
+ * @param {string} str - The input string.
8
+ * @returns {boolean} True if valid email, else false.
9
+ */
10
+ export declare function isEmail(str: string): boolean;
11
+ /**
12
+ * Checks if a string is a valid UUID (versions 1-5).
13
+ *
14
+ * @param {string} str - The input string.
15
+ * @returns {boolean} True if valid UUID, else false.
16
+ */
17
+ export declare function isUUID(str: string): boolean;
18
+ /**
19
+ * Checks if a string is a valid URL.
20
+ *
21
+ * @param {string} str - The input string.
22
+ * @returns {boolean} True if valid URL, else false.
23
+ */
24
+ export declare function isURL(str: string): boolean;
25
+ /**
26
+ * Checks if a string is a valid international phone number (E.164 or common patterns).
27
+ *
28
+ * @param {string} str - The input string.
29
+ * @returns {boolean} True if looks like a phone number.
30
+ */
31
+ export declare function isPhone(str: string): boolean;
32
+ /**
33
+ * Checks if a string is strictly alphanumeric (letters/numbers only).
34
+ *
35
+ * @param {string} str - The input string.
36
+ * @returns {boolean} True if alphanumeric.
37
+ */
38
+ export declare function isAlphanumeric(str: string): boolean;
39
+ /**
40
+ * Checks if a string or number can be safely parsed to a number.
41
+ *
42
+ * @param {string | number} value - The value to check.
43
+ * @returns {boolean} True if the value is numeric.
44
+ */
45
+ export declare function isNumeric(value: string | number): boolean;
46
+ /**
47
+ * Checks if a string is a valid hex color code (e.g. #FFF or #FFFFFF).
48
+ *
49
+ * @param {string} str - Input string.
50
+ * @returns {boolean}
51
+ */
52
+ export declare function isHexColor(str: string): boolean;
53
+ /**
54
+ * Checks if a string is a valid date string.
55
+ *
56
+ * @param {string} str - Input string.
57
+ * @returns {boolean}
58
+ */
59
+ export declare function isISODate(str: string): boolean;
60
+ //# sourceMappingURL=validate.utils.d.ts.map