@catbee/utils 2.0.0-next.0 → 2.0.0-next.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 (97) hide show
  1. package/README.md +52 -16
  2. package/array/index.cjs +180 -71
  3. package/array/index.d.ts +293 -1
  4. package/array/index.mjs +171 -72
  5. package/async/index.cjs +92 -36
  6. package/async/index.d.ts +275 -1
  7. package/async/index.mjs +92 -36
  8. package/cache/index.cjs +1 -1
  9. package/cache/index.d.ts +155 -1
  10. package/cache/index.mjs +2 -2
  11. package/config/index.cjs +78 -64
  12. package/config/index.d.ts +64 -2
  13. package/config/index.mjs +76 -64
  14. package/context-store/index.d.ts +192 -1
  15. package/crypto/index.d.ts +163 -1
  16. package/date/index.cjs +46 -1
  17. package/date/index.d.ts +190 -1
  18. package/date/index.mjs +45 -2
  19. package/decorators/index.cjs +1156 -18
  20. package/decorators/index.d.ts +684 -1
  21. package/decorators/index.mjs +1156 -18
  22. package/dir/index.cjs +4 -3
  23. package/dir/index.d.ts +195 -1
  24. package/dir/index.mjs +4 -3
  25. package/env/index.cjs +10 -26
  26. package/env/index.d.ts +379 -1
  27. package/env/index.mjs +10 -26
  28. package/exception/index.d.ts +232 -1
  29. package/fs/index.cjs +70 -36
  30. package/fs/index.d.ts +205 -1
  31. package/fs/index.mjs +64 -34
  32. package/http-status-codes/index.d.ts +267 -1
  33. package/id/index.d.ts +37 -1
  34. package/index.cjs +3 -3
  35. package/index.d.ts +1 -1
  36. package/index.mjs +1 -1
  37. package/logger/index.cjs +11 -11
  38. package/logger/index.d.ts +189 -1
  39. package/logger/index.mjs +12 -12
  40. package/middleware/index.d.ts +103 -1
  41. package/obj/index.cjs +150 -162
  42. package/obj/index.d.ts +136 -1
  43. package/obj/index.mjs +150 -162
  44. package/package.json +11 -11
  45. package/performance/index.cjs +2 -2
  46. package/performance/index.d.ts +138 -1
  47. package/performance/index.mjs +2 -2
  48. package/request/index.cjs +1 -1
  49. package/request/index.d.ts +241 -2
  50. package/request/index.mjs +1 -1
  51. package/response/index.d.ts +318 -2
  52. package/server/index.cjs +27 -23
  53. package/server/index.d.ts +785 -4
  54. package/server/index.mjs +28 -23
  55. package/stream/index.d.ts +90 -1
  56. package/string/index.d.ts +102 -1
  57. package/type/index.cjs +1 -1
  58. package/type/index.d.ts +107 -1
  59. package/type/index.mjs +1 -1
  60. package/types/index.d.ts +774 -4
  61. package/url/index.cjs +2 -4
  62. package/url/index.d.ts +142 -1
  63. package/url/index.mjs +2 -4
  64. package/{validate → validation}/index.cjs +89 -42
  65. package/{validate/validate.utils.d.ts → validation/index.d.ts} +32 -23
  66. package/{validate → validation}/index.mjs +85 -42
  67. package/array/array.utils.d.ts +0 -191
  68. package/async/async.utils.d.ts +0 -296
  69. package/cache/cache.utils.d.ts +0 -176
  70. package/config/config.d.ts +0 -57
  71. package/context-store/context-store.utils.d.ts +0 -212
  72. package/crypto/crypto.utils.d.ts +0 -183
  73. package/date/date.utils.d.ts +0 -190
  74. package/decorators/decorators.utils.d.ts +0 -705
  75. package/dir/dir.utils.d.ts +0 -216
  76. package/env/env.utils.d.ts +0 -400
  77. package/exception/exception.utils.d.ts +0 -253
  78. package/fs/fs.utils.d.ts +0 -196
  79. package/http-status-codes/http-status-codes.d.ts +0 -289
  80. package/id/id.utils.d.ts +0 -59
  81. package/logger/logger.utils.d.ts +0 -210
  82. package/middleware/middleware.utils.d.ts +0 -123
  83. package/obj/obj.utils.d.ts +0 -156
  84. package/performance/performance.utils.d.ts +0 -159
  85. package/request/request.utils.d.ts +0 -109
  86. package/response/response.utils.d.ts +0 -186
  87. package/server/server.builder.d.ts +0 -531
  88. package/server/server.d.ts +0 -303
  89. package/stream/stream.utils.d.ts +0 -111
  90. package/string/string.utils.d.ts +0 -124
  91. package/type/type.utils.d.ts +0 -129
  92. package/types/api-response.d.ts +0 -175
  93. package/types/common.d.ts +0 -148
  94. package/types/config.d.ts +0 -88
  95. package/types/server.d.ts +0 -291
  96. package/url/url.utils.d.ts +0 -164
  97. package/validate/index.d.ts +0 -25
package/fs/index.mjs CHANGED
@@ -22,8 +22,8 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- import { createReadStream, createWriteStream } from 'fs';
26
- import fs from 'fs/promises';
25
+ import fs from 'fs';
26
+ import fsp from 'fs/promises';
27
27
  import { tmpdir } from 'os';
28
28
  import path from 'path';
29
29
  import { pipeline } from 'stream/promises';
@@ -33,7 +33,7 @@ var __defProp = Object.defineProperty;
33
33
  var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
34
34
  async function fileExists(path2) {
35
35
  try {
36
- await fs.access(path2);
36
+ await fsp.access(path2);
37
37
  return true;
38
38
  } catch {
39
39
  return false;
@@ -42,7 +42,7 @@ async function fileExists(path2) {
42
42
  __name(fileExists, "fileExists");
43
43
  async function readJsonFile(path2) {
44
44
  try {
45
- const data = await fs.readFile(path2, "utf-8");
45
+ const data = await fsp.readFile(path2, "utf-8");
46
46
  return JSON.parse(data);
47
47
  } catch {
48
48
  return null;
@@ -56,12 +56,12 @@ async function readJsonOrDefault(path2, defaultValue) {
56
56
  __name(readJsonOrDefault, "readJsonOrDefault");
57
57
  async function writeJsonFile(path2, data, space = 2) {
58
58
  const json = JSON.stringify(data, null, space);
59
- await fs.writeFile(path2, json, "utf-8");
59
+ await fsp.writeFile(path2, json, "utf-8");
60
60
  }
61
61
  __name(writeJsonFile, "writeJsonFile");
62
62
  async function deleteFileIfExists(path2) {
63
63
  try {
64
- await fs.unlink(path2);
64
+ await fsp.unlink(path2);
65
65
  return true;
66
66
  } catch (err) {
67
67
  if (err.code === "ENOENT") return true;
@@ -69,36 +69,66 @@ async function deleteFileIfExists(path2) {
69
69
  }
70
70
  }
71
71
  __name(deleteFileIfExists, "deleteFileIfExists");
72
- async function readTextFile(path2, encoding = "utf-8") {
72
+ async function readFile(path2, encoding = "utf-8") {
73
+ return await fsp.readFile(path2, encoding);
74
+ }
75
+ __name(readFile, "readFile");
76
+ function readFileSync(path2, encoding = "utf-8") {
77
+ return fs.readFileSync(path2, encoding);
78
+ }
79
+ __name(readFileSync, "readFileSync");
80
+ async function safeReadFile(path2, encoding = "utf-8") {
73
81
  try {
74
- return await fs.readFile(path2, encoding);
75
- } catch {
76
- return null;
82
+ const data = await fsp.readFile(path2, encoding);
83
+ return {
84
+ data,
85
+ error: null
86
+ };
87
+ } catch (error) {
88
+ return {
89
+ data: null,
90
+ error: new Error(`Failed to read file ${path2}: ${error.message}`)
91
+ };
92
+ }
93
+ }
94
+ __name(safeReadFile, "safeReadFile");
95
+ function safeReadFileSync(path2, encoding = "utf-8") {
96
+ try {
97
+ const data = fs.readFileSync(path2, encoding);
98
+ return {
99
+ data,
100
+ error: null
101
+ };
102
+ } catch (error) {
103
+ return {
104
+ data: null,
105
+ error: new Error(`Failed to read file ${path2}: ${error.message}`)
106
+ };
77
107
  }
78
108
  }
79
- __name(readTextFile, "readTextFile");
80
- async function writeTextFile(path2, content, encoding = "utf-8") {
109
+ __name(safeReadFileSync, "safeReadFileSync");
110
+ async function writeFile(path2, content, encoding = "utf-8") {
81
111
  try {
82
- await fs.writeFile(path2, content, encoding);
112
+ await fsp.writeFile(path2, content, encoding);
83
113
  return true;
84
114
  } catch {
85
115
  return false;
86
116
  }
87
117
  }
88
- __name(writeTextFile, "writeTextFile");
89
- async function appendTextFile(path2, content, encoding = "utf-8") {
118
+ __name(writeFile, "writeFile");
119
+ async function appendFile(path2, content, encoding = "utf-8") {
90
120
  try {
91
- await fs.appendFile(path2, content, encoding);
121
+ await fsp.appendFile(path2, content, encoding);
92
122
  return true;
93
123
  } catch {
94
124
  return false;
95
125
  }
96
126
  }
97
- __name(appendTextFile, "appendTextFile");
127
+ __name(appendFile, "appendFile");
98
128
  async function copyFile(source, destination, overwrite = false) {
99
129
  try {
100
- const flags = overwrite ? 0 : fs.constants.COPYFILE_EXCL;
101
- await fs.copyFile(source, destination, flags);
130
+ const flags = overwrite ? 0 : fsp.constants.COPYFILE_EXCL;
131
+ await fsp.copyFile(source, destination, flags);
102
132
  return true;
103
133
  } catch {
104
134
  return false;
@@ -107,12 +137,12 @@ async function copyFile(source, destination, overwrite = false) {
107
137
  __name(copyFile, "copyFile");
108
138
  async function moveFile(oldPath, newPath) {
109
139
  try {
110
- await fs.rename(oldPath, newPath);
140
+ await fsp.rename(oldPath, newPath);
111
141
  return true;
112
142
  } catch {
113
143
  try {
114
- await fs.copyFile(oldPath, newPath);
115
- await fs.unlink(oldPath);
144
+ await fsp.copyFile(oldPath, newPath);
145
+ await fsp.unlink(oldPath);
116
146
  return true;
117
147
  } catch {
118
148
  return false;
@@ -122,7 +152,7 @@ async function moveFile(oldPath, newPath) {
122
152
  __name(moveFile, "moveFile");
123
153
  async function getFileStats(path2) {
124
154
  try {
125
- return await fs.stat(path2);
155
+ return await fsp.stat(path2);
126
156
  } catch {
127
157
  return null;
128
158
  }
@@ -133,16 +163,16 @@ async function createTempFile({ prefix = "tmp-", extension = "", dir = tmpdir(),
133
163
  const filename = `${prefix}${randomUUID()}${ext}`;
134
164
  const filepath = path.join(dir, filename);
135
165
  if (content) {
136
- await fs.writeFile(filepath, content);
166
+ await fsp.writeFile(filepath, content);
137
167
  } else {
138
- await fs.writeFile(filepath, "");
168
+ await fsp.writeFile(filepath, "");
139
169
  }
140
170
  return filepath;
141
171
  }
142
172
  __name(createTempFile, "createTempFile");
143
173
  async function streamFile(source, destination) {
144
- const readStream = createReadStream(source);
145
- const writeStream = createWriteStream(destination);
174
+ const readStream = fs.createReadStream(source);
175
+ const writeStream = fs.createWriteStream(destination);
146
176
  try {
147
177
  await pipeline(readStream, writeStream);
148
178
  } catch (error) {
@@ -153,7 +183,7 @@ async function streamFile(source, destination) {
153
183
  }
154
184
  __name(streamFile, "streamFile");
155
185
  async function readDirectory(dirPath, options = {}) {
156
- const files = await fs.readdir(dirPath);
186
+ const files = await fsp.readdir(dirPath);
157
187
  let result = files;
158
188
  if (options.filter) {
159
189
  result = result.filter((file) => options.filter.test(file));
@@ -166,7 +196,7 @@ async function readDirectory(dirPath, options = {}) {
166
196
  __name(readDirectory, "readDirectory");
167
197
  async function createDirectory(dirPath, recursive = true) {
168
198
  try {
169
- await fs.mkdir(dirPath, {
199
+ await fsp.mkdir(dirPath, {
170
200
  recursive
171
201
  });
172
202
  return true;
@@ -177,7 +207,7 @@ async function createDirectory(dirPath, recursive = true) {
177
207
  __name(createDirectory, "createDirectory");
178
208
  async function safeReadJsonFile(path2) {
179
209
  try {
180
- const content = await fs.readFile(path2, "utf-8");
210
+ const content = await fsp.readFile(path2, "utf-8");
181
211
  try {
182
212
  const data = JSON.parse(content);
183
213
  return {
@@ -200,7 +230,7 @@ async function safeReadJsonFile(path2) {
200
230
  __name(safeReadJsonFile, "safeReadJsonFile");
201
231
  async function isFile(path2) {
202
232
  try {
203
- const stat = await fs.stat(path2);
233
+ const stat = await fsp.stat(path2);
204
234
  return stat.isFile();
205
235
  } catch {
206
236
  return false;
@@ -209,7 +239,7 @@ async function isFile(path2) {
209
239
  __name(isFile, "isFile");
210
240
  async function getFileSize(path2) {
211
241
  try {
212
- const stat = await fs.stat(path2);
242
+ const stat = await fsp.stat(path2);
213
243
  return stat.size;
214
244
  } catch {
215
245
  return -1;
@@ -218,11 +248,11 @@ async function getFileSize(path2) {
218
248
  __name(getFileSize, "getFileSize");
219
249
  async function readFileBuffer(path2) {
220
250
  try {
221
- return await fs.readFile(path2);
251
+ return await fsp.readFile(path2);
222
252
  } catch {
223
253
  return null;
224
254
  }
225
255
  }
226
256
  __name(readFileBuffer, "readFileBuffer");
227
257
 
228
- export { appendTextFile, copyFile, createDirectory, createTempFile, deleteFileIfExists, fileExists, getFileSize, getFileStats, isFile, moveFile, readDirectory, readFileBuffer, readJsonFile, readJsonOrDefault, readTextFile, safeReadJsonFile, streamFile, writeJsonFile, writeTextFile };
258
+ export { appendFile, copyFile, createDirectory, createTempFile, deleteFileIfExists, fileExists, getFileSize, getFileStats, isFile, moveFile, readDirectory, readFile, readFileBuffer, readFileSync, readJsonFile, readJsonOrDefault, safeReadFile, safeReadFileSync, safeReadJsonFile, streamFile, writeFile, writeJsonFile };
@@ -22,4 +22,270 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- export * from './http-status-codes';
25
+ /**
26
+ * Complete HTTP status codes enum with descriptions.
27
+ * For use with API responses and error handling.
28
+ */
29
+ declare enum HttpStatusCodes {
30
+ /**
31
+ * The server has received the request headers and the client should proceed to send the request body.
32
+ */
33
+ CONTINUE = 100,
34
+ /**
35
+ * The server is switching protocols according to the client's request.
36
+ */
37
+ SWITCHING_PROTOCOLS = 101,
38
+ /**
39
+ * Server has received the request and is still processing it.
40
+ */
41
+ PROCESSING = 102,
42
+ /**
43
+ * The server is sending preliminary headers while preparing the final response.
44
+ */
45
+ EARLY_HINTS = 103,
46
+ /**
47
+ * The request succeeded. The result meaning depends on the HTTP method used.
48
+ */
49
+ OK = 200,
50
+ /**
51
+ * The request succeeded and a new resource was created as a result.
52
+ */
53
+ CREATED = 201,
54
+ /**
55
+ * The request has been received but not yet acted upon.
56
+ */
57
+ ACCEPTED = 202,
58
+ /**
59
+ * The returned information is from a third-party source, not the origin server.
60
+ */
61
+ NON_AUTHORITATIVE_INFORMATION = 203,
62
+ /**
63
+ * The request succeeded but there's no content to send in the response.
64
+ */
65
+ NO_CONTENT = 204,
66
+ /**
67
+ * The client should reset the document view that caused this request.
68
+ */
69
+ RESET_CONTENT = 205,
70
+ /**
71
+ * The server is delivering only part of the resource due to a range header sent by the client.
72
+ */
73
+ PARTIAL_CONTENT = 206,
74
+ /**
75
+ * Conveys information about multiple resources, for complex operations.
76
+ */
77
+ MULTI_STATUS = 207,
78
+ /**
79
+ * The members of a DAV binding have already been enumerated and are not included in the response.
80
+ */
81
+ ALREADY_REPORTED = 208,
82
+ /**
83
+ * The server has fulfilled a request for the resource, and the response represents the result of one or more instance-manipulations.
84
+ */
85
+ IM_USED = 226,
86
+ /**
87
+ * The request has more than one possible response and the client should choose one.
88
+ */
89
+ MULTIPLE_CHOICES = 300,
90
+ /**
91
+ * The resource has been permanently moved to a new URL.
92
+ */
93
+ MOVED_PERMANENTLY = 301,
94
+ /**
95
+ * The resource has been temporarily moved to another URL.
96
+ */
97
+ MOVED_TEMPORARILY = 302,
98
+ /**
99
+ * The response to the request can be found under another URI using the GET method.
100
+ */
101
+ SEE_OTHER = 303,
102
+ /**
103
+ * The resource hasn't been modified since the last request.
104
+ */
105
+ NOT_MODIFIED = 304,
106
+ /**
107
+ * @deprecated
108
+ * Response must be accessed through a proxy.
109
+ */
110
+ USE_PROXY = 305,
111
+ /**
112
+ * The resource is temporarily available at a different URI, using the same HTTP method.
113
+ */
114
+ TEMPORARY_REDIRECT = 307,
115
+ /**
116
+ * The resource has been permanently moved to another URL, using the same HTTP method.
117
+ */
118
+ PERMANENT_REDIRECT = 308,
119
+ /**
120
+ * The server cannot process the request due to a client error (malformed request).
121
+ */
122
+ BAD_REQUEST = 400,
123
+ /**
124
+ * Authentication is required and has failed or not been provided.
125
+ */
126
+ UNAUTHORIZED = 401,
127
+ /**
128
+ * Reserved for future use, originally intended for digital payment systems.
129
+ */
130
+ PAYMENT_REQUIRED = 402,
131
+ /**
132
+ * The client doesn't have permission to access the requested resource.
133
+ */
134
+ FORBIDDEN = 403,
135
+ /**
136
+ * The requested resource could not be found on the server.
137
+ */
138
+ NOT_FOUND = 404,
139
+ /**
140
+ * The request method is not supported for the requested resource.
141
+ */
142
+ METHOD_NOT_ALLOWED = 405,
143
+ /**
144
+ * The server can't provide a response matching the list of acceptable values in the client's headers.
145
+ */
146
+ NOT_ACCEPTABLE = 406,
147
+ /**
148
+ * Authentication by a proxy is required.
149
+ */
150
+ PROXY_AUTHENTICATION_REQUIRED = 407,
151
+ /**
152
+ * The server timed out waiting for the request.
153
+ */
154
+ REQUEST_TIMEOUT = 408,
155
+ /**
156
+ * The request conflicts with the current state of the server.
157
+ */
158
+ CONFLICT = 409,
159
+ /**
160
+ * The resource has been permanently deleted with no forwarding address.
161
+ */
162
+ GONE = 410,
163
+ /**
164
+ * The server requires a Content-Length header field.
165
+ */
166
+ LENGTH_REQUIRED = 411,
167
+ /**
168
+ * Preconditions in the client's headers failed.
169
+ */
170
+ PRECONDITION_FAILED = 412,
171
+ /**
172
+ * Request entity is larger than limits defined by server.
173
+ */
174
+ REQUEST_TOO_LONG = 413,
175
+ /**
176
+ * The request payload exceeds server size limits.
177
+ * Modern equivalent of REQUEST_TOO_LONG.
178
+ */
179
+ PAYLOAD_TOO_LARGE = 413,
180
+ /**
181
+ * The URI requested is too long for the server to interpret.
182
+ */
183
+ REQUEST_URI_TOO_LONG = 414,
184
+ /**
185
+ * The server does not support the media type requested by the client.
186
+ */
187
+ UNSUPPORTED_MEDIA_TYPE = 415,
188
+ /**
189
+ * The range specified by the Range header cannot be fulfilled.
190
+ */
191
+ REQUESTED_RANGE_NOT_SATISFIABLE = 416,
192
+ /**
193
+ * The server cannot meet the expectations given in the Expect header.
194
+ */
195
+ EXPECTATION_FAILED = 417,
196
+ /**
197
+ * The server refuses to brew coffee because it is a teapot. (April Fools' joke)
198
+ */
199
+ IM_A_TEAPOT = 418,
200
+ /**
201
+ * The server cannot store the representation needed to complete the request.
202
+ */
203
+ INSUFFICIENT_SPACE_ON_RESOURCE = 419,
204
+ /**
205
+ * @deprecated
206
+ * A method has failed - specific to Spring Framework.
207
+ */
208
+ METHOD_FAILURE = 420,
209
+ /**
210
+ * The server cannot produce a response for the requested URI scheme and authority.
211
+ */
212
+ MISDIRECTED_REQUEST = 421,
213
+ /**
214
+ * The request was well-formed but has semantic errors preventing processing.
215
+ */
216
+ UNPROCESSABLE_ENTITY = 422,
217
+ /**
218
+ * The requested resource is locked against access.
219
+ */
220
+ LOCKED = 423,
221
+ /**
222
+ * The request failed due to the failure of a previous request.
223
+ */
224
+ FAILED_DEPENDENCY = 424,
225
+ /**
226
+ * The client should switch to a different protocol.
227
+ */
228
+ UPGRADE_REQUIRED = 426,
229
+ /**
230
+ * The server requires conditional requests to prevent lost updates.
231
+ */
232
+ PRECONDITION_REQUIRED = 428,
233
+ /**
234
+ * The client has sent too many requests in a given time period (rate limiting).
235
+ */
236
+ TOO_MANY_REQUESTS = 429,
237
+ /**
238
+ * Request headers are too large for the server to process.
239
+ */
240
+ REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
241
+ /**
242
+ * Resource cannot be legally provided (e.g., censored by government).
243
+ */
244
+ UNAVAILABLE_FOR_LEGAL_REASONS = 451,
245
+ /**
246
+ * The server encountered an unexpected error preventing it from fulfilling the request.
247
+ */
248
+ INTERNAL_SERVER_ERROR = 500,
249
+ /**
250
+ * The server does not support the functionality required to fulfill the request.
251
+ */
252
+ NOT_IMPLEMENTED = 501,
253
+ /**
254
+ * The server, acting as a gateway, received an invalid response from an upstream server.
255
+ */
256
+ BAD_GATEWAY = 502,
257
+ /**
258
+ * The server is currently unable to handle the request due to temporary overload or maintenance.
259
+ */
260
+ SERVICE_UNAVAILABLE = 503,
261
+ /**
262
+ * The server, acting as a gateway, did not receive a timely response from an upstream server.
263
+ */
264
+ GATEWAY_TIMEOUT = 504,
265
+ /**
266
+ * The server does not support the HTTP protocol version used in the request.
267
+ */
268
+ HTTP_VERSION_NOT_SUPPORTED = 505,
269
+ /**
270
+ * Transparent content negotiation for the request resulted in circular reference.
271
+ */
272
+ VARIANT_ALSO_NEGOTIATES = 506,
273
+ /**
274
+ * The server cannot store the representation needed to complete the request.
275
+ */
276
+ INSUFFICIENT_STORAGE = 507,
277
+ /**
278
+ * The server detected an infinite loop while processing the request.
279
+ */
280
+ LOOP_DETECTED = 508,
281
+ /**
282
+ * Further extensions to the request are required for the server to fulfill it.
283
+ */
284
+ NOT_EXTENDED = 510,
285
+ /**
286
+ * The client needs to authenticate to gain network access.
287
+ */
288
+ NETWORK_AUTHENTICATION_REQUIRED = 511
289
+ }
290
+
291
+ export { HttpStatusCodes };
package/id/index.d.ts CHANGED
@@ -22,4 +22,40 @@
22
22
  * SOFTWARE.
23
23
  */
24
24
 
25
- export * from './id.utils';
25
+ /**
26
+ * Generates a UUID v4 string (RFC 4122).
27
+ *
28
+ * @returns {string} UUID v4 (e.g., 'c0de1234-5678-9abc-def0-123456789abc')
29
+ */
30
+ declare function uuid(): string;
31
+ /**
32
+ * Generates a nanoid-style random ID (URL-safe, customizable length).
33
+ *
34
+ * @param {number} length - Length of the ID (default: 21).
35
+ * @returns {string} Nanoid-style random string.
36
+ */
37
+ declare function nanoId(length?: number): string;
38
+ /**
39
+ * Generates a cryptographically strong random hex string.
40
+ *
41
+ * @param {number} byteLength - Number of random bytes (default: 16 -> 32 hex chars).
42
+ * @returns {string} Random hex string.
43
+ */
44
+ declare function randomHex(byteLength?: number): string;
45
+ /**
46
+ * Generates a random integer between min (inclusive) and max (inclusive).
47
+ *
48
+ * @param {number} min - Minimum value.
49
+ * @param {number} max - Maximum value.
50
+ * @returns {number} Random integer in range.
51
+ */
52
+ declare function randomInt(min: number, max: number): number;
53
+ /**
54
+ * Generates a cryptographically strong random base64 string.
55
+ *
56
+ * @param {number} byteLength - Number of random bytes (default: 16).
57
+ * @returns {string} Random base64 string (URL-safe, no padding).
58
+ */
59
+ declare function randomBase64(byteLength?: number): string;
60
+
61
+ export { nanoId, randomBase64, randomHex, randomInt, uuid };
package/index.cjs CHANGED
@@ -50,7 +50,7 @@ var stream = require("./stream/index.cjs");
50
50
  var string = require("./string/index.cjs");
51
51
  var type = require("./type/index.cjs");
52
52
  var url = require("./url/index.cjs");
53
- var validate = require("./validate/index.cjs");
53
+ var validation = require("./validation/index.cjs");
54
54
 
55
55
 
56
56
 
@@ -210,9 +210,9 @@ Object.keys(url).forEach(function (k) {
210
210
  get: function () { return url[k]; }
211
211
  });
212
212
  });
213
- Object.keys(validate).forEach(function (k) {
213
+ Object.keys(validation).forEach(function (k) {
214
214
  if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
215
215
  enumerable: true,
216
- get: function () { return validate[k]; }
216
+ get: function () { return validation[k]; }
217
217
  });
218
218
  });
package/index.d.ts CHANGED
@@ -48,4 +48,4 @@ export * from './stream';
48
48
  export * from './string';
49
49
  export * from './type';
50
50
  export * from './url';
51
- export * from './validate';
51
+ export * from './validation';
package/index.mjs CHANGED
@@ -48,4 +48,4 @@ export * from "./stream/index.mjs";
48
48
  export * from "./string/index.mjs";
49
49
  export * from "./type/index.mjs";
50
50
  export * from "./url/index.mjs";
51
- export * from "./validate/index.mjs";
51
+ export * from "./validation/index.mjs";
package/logger/index.cjs CHANGED
@@ -158,8 +158,8 @@ function setupLogger(isGlobal = true) {
158
158
  ...sensitiveFields.flatMap((field) => generateDeepPaths(field, 2))
159
159
  ]);
160
160
  const logParams = {
161
- name: config.defaultCatbeeConfig.logger?.name || "@catbee/utils",
162
- level: config.defaultCatbeeConfig.logger?.level || "info",
161
+ name: config.getCatbeeGlobalConfig().logger?.name || "@catbee/utils",
162
+ level: config.getCatbeeGlobalConfig().logger?.level || "info",
163
163
  redact: {
164
164
  paths: Array.from(paths),
165
165
  censor: /* @__PURE__ */ __name((value, path) => redact(value, path), "censor")
@@ -175,25 +175,25 @@ function setupLogger(isGlobal = true) {
175
175
  timestamp: pino.stdTimeFunctions.isoTime
176
176
  };
177
177
  let logger;
178
- const logDir = config.defaultCatbeeConfig.logger?.dir?.trim();
178
+ const logDir = config.getCatbeeGlobalConfig().logger?.dir?.trim();
179
179
  const hasFileLogging = Boolean(logDir);
180
- if (hasFileLogging && config.defaultCatbeeConfig.logger?.pretty) {
180
+ if (hasFileLogging && config.getCatbeeGlobalConfig().logger?.pretty) {
181
181
  logger = pino__default.default(logParams, pino__default.default.transport({
182
182
  targets: [
183
183
  {
184
184
  target: "pino-pretty",
185
- level: config.defaultCatbeeConfig.logger?.level ?? "info",
185
+ level: config.getCatbeeGlobalConfig().logger?.level ?? "info",
186
186
  options: {
187
- colorize: config.defaultCatbeeConfig.logger?.colorize,
187
+ colorize: config.getCatbeeGlobalConfig().logger?.colorize,
188
188
  translateTime: "SYS:standard",
189
189
  ignore: "pid,hostname",
190
- singleLine: config.defaultCatbeeConfig.logger?.singleLine,
190
+ singleLine: config.getCatbeeGlobalConfig().logger?.singleLine,
191
191
  levelFirst: true
192
192
  }
193
193
  },
194
194
  {
195
195
  target: "pino/file",
196
- level: config.defaultCatbeeConfig.logger?.level ?? "info",
196
+ level: config.getCatbeeGlobalConfig().logger?.level ?? "info",
197
197
  options: {
198
198
  destination: `${logDir}/app.log`,
199
199
  mkdir: true
@@ -209,14 +209,14 @@ function setupLogger(isGlobal = true) {
209
209
  mkdir: true
210
210
  }
211
211
  }));
212
- } else if (config.defaultCatbeeConfig.logger?.pretty) {
212
+ } else if (config.getCatbeeGlobalConfig().logger?.pretty) {
213
213
  logger = pino__default.default(logParams, pino__default.default.transport({
214
214
  target: "pino-pretty",
215
215
  options: {
216
- colorize: config.defaultCatbeeConfig.logger?.colorize,
216
+ colorize: config.getCatbeeGlobalConfig().logger?.colorize,
217
217
  translateTime: "SYS:standard",
218
218
  ignore: "pid,hostname",
219
- singleLine: config.defaultCatbeeConfig.logger?.singleLine,
219
+ singleLine: config.getCatbeeGlobalConfig().logger?.singleLine,
220
220
  levelFirst: true
221
221
  }
222
222
  }));