@catbee/utils 0.0.8-rc.3 → 1.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 (129) hide show
  1. package/README.md +3 -2
  2. package/build/index.cjs +6912 -0
  3. package/build/index.d.ts +5284 -0
  4. package/build/index.mjs +6635 -0
  5. package/package.json +13 -292
  6. package/build/cjs/config.d.ts +0 -121
  7. package/build/cjs/config.js +0 -137
  8. package/build/cjs/index.d.ts +0 -26
  9. package/build/cjs/index.js +0 -68
  10. package/build/cjs/servers/server.builder.d.ts +0 -507
  11. package/build/cjs/servers/server.builder.js +0 -658
  12. package/build/cjs/servers/server.d.ts +0 -255
  13. package/build/cjs/servers/server.js +0 -970
  14. package/build/cjs/types/api-response.d.ts +0 -151
  15. package/build/cjs/types/api-response.js +0 -36
  16. package/build/cjs/types/index.d.ts +0 -124
  17. package/build/cjs/types/index.js +0 -25
  18. package/build/cjs/types/server.d.ts +0 -267
  19. package/build/cjs/types/server.js +0 -25
  20. package/build/cjs/utils/array.utils.d.ts +0 -167
  21. package/build/cjs/utils/array.utils.js +0 -363
  22. package/build/cjs/utils/async.utils.d.ts +0 -264
  23. package/build/cjs/utils/async.utils.js +0 -640
  24. package/build/cjs/utils/cache.utils.d.ts +0 -152
  25. package/build/cjs/utils/cache.utils.js +0 -298
  26. package/build/cjs/utils/context-store.utils.d.ts +0 -188
  27. package/build/cjs/utils/context-store.utils.js +0 -297
  28. package/build/cjs/utils/crypto.utils.d.ts +0 -159
  29. package/build/cjs/utils/crypto.utils.js +0 -295
  30. package/build/cjs/utils/date.utils.d.ts +0 -158
  31. package/build/cjs/utils/date.utils.js +0 -395
  32. package/build/cjs/utils/decorators.utils.d.ts +0 -511
  33. package/build/cjs/utils/decorators.utils.js +0 -1035
  34. package/build/cjs/utils/dir.utils.d.ts +0 -195
  35. package/build/cjs/utils/dir.utils.js +0 -500
  36. package/build/cjs/utils/env.utils.d.ts +0 -376
  37. package/build/cjs/utils/env.utils.js +0 -786
  38. package/build/cjs/utils/exception.utils.d.ts +0 -229
  39. package/build/cjs/utils/exception.utils.js +0 -408
  40. package/build/cjs/utils/fs.utils.d.ts +0 -163
  41. package/build/cjs/utils/fs.utils.js +0 -371
  42. package/build/cjs/utils/http-status-codes.d.ts +0 -265
  43. package/build/cjs/utils/http-status-codes.js +0 -297
  44. package/build/cjs/utils/id.utils.d.ts +0 -35
  45. package/build/cjs/utils/id.utils.js +0 -90
  46. package/build/cjs/utils/logger.utils.d.ts +0 -159
  47. package/build/cjs/utils/logger.utils.js +0 -350
  48. package/build/cjs/utils/middleware.utils.d.ts +0 -99
  49. package/build/cjs/utils/middleware.utils.js +0 -243
  50. package/build/cjs/utils/obj.utils.d.ts +0 -123
  51. package/build/cjs/utils/obj.utils.js +0 -428
  52. package/build/cjs/utils/performance.utils.d.ts +0 -135
  53. package/build/cjs/utils/performance.utils.js +0 -280
  54. package/build/cjs/utils/request.utils.d.ts +0 -85
  55. package/build/cjs/utils/request.utils.js +0 -199
  56. package/build/cjs/utils/response.utils.d.ts +0 -162
  57. package/build/cjs/utils/response.utils.js +0 -274
  58. package/build/cjs/utils/stream.utils.d.ts +0 -87
  59. package/build/cjs/utils/stream.utils.js +0 -217
  60. package/build/cjs/utils/string.utils.d.ts +0 -92
  61. package/build/cjs/utils/string.utils.js +0 -178
  62. package/build/cjs/utils/type.utils.d.ts +0 -89
  63. package/build/cjs/utils/type.utils.js +0 -195
  64. package/build/cjs/utils/url.utils.d.ts +0 -140
  65. package/build/cjs/utils/url.utils.js +0 -316
  66. package/build/cjs/utils/validate.utils.d.ts +0 -176
  67. package/build/cjs/utils/validate.utils.js +0 -344
  68. package/build/esm/config.d.ts +0 -121
  69. package/build/esm/config.js +0 -132
  70. package/build/esm/index.d.ts +0 -26
  71. package/build/esm/index.js +0 -49
  72. package/build/esm/servers/server.builder.d.ts +0 -507
  73. package/build/esm/servers/server.builder.js +0 -654
  74. package/build/esm/servers/server.d.ts +0 -255
  75. package/build/esm/servers/server.js +0 -963
  76. package/build/esm/types/api-response.d.ts +0 -151
  77. package/build/esm/types/api-response.js +0 -33
  78. package/build/esm/types/index.d.ts +0 -124
  79. package/build/esm/types/index.js +0 -24
  80. package/build/esm/types/server.d.ts +0 -267
  81. package/build/esm/types/server.js +0 -24
  82. package/build/esm/utils/array.utils.d.ts +0 -167
  83. package/build/esm/utils/array.utils.js +0 -344
  84. package/build/esm/utils/async.utils.d.ts +0 -264
  85. package/build/esm/utils/async.utils.js +0 -619
  86. package/build/esm/utils/cache.utils.d.ts +0 -152
  87. package/build/esm/utils/cache.utils.js +0 -294
  88. package/build/esm/utils/context-store.utils.d.ts +0 -188
  89. package/build/esm/utils/context-store.utils.js +0 -290
  90. package/build/esm/utils/crypto.utils.d.ts +0 -159
  91. package/build/esm/utils/crypto.utils.js +0 -278
  92. package/build/esm/utils/date.utils.d.ts +0 -158
  93. package/build/esm/utils/date.utils.js +0 -383
  94. package/build/esm/utils/decorators.utils.d.ts +0 -511
  95. package/build/esm/utils/decorators.utils.js +0 -1013
  96. package/build/esm/utils/dir.utils.d.ts +0 -195
  97. package/build/esm/utils/dir.utils.js +0 -476
  98. package/build/esm/utils/env.utils.d.ts +0 -376
  99. package/build/esm/utils/env.utils.js +0 -782
  100. package/build/esm/utils/exception.utils.d.ts +0 -229
  101. package/build/esm/utils/exception.utils.js +0 -382
  102. package/build/esm/utils/fs.utils.d.ts +0 -163
  103. package/build/esm/utils/fs.utils.js +0 -348
  104. package/build/esm/utils/http-status-codes.d.ts +0 -265
  105. package/build/esm/utils/http-status-codes.js +0 -294
  106. package/build/esm/utils/id.utils.d.ts +0 -35
  107. package/build/esm/utils/id.utils.js +0 -83
  108. package/build/esm/utils/logger.utils.d.ts +0 -159
  109. package/build/esm/utils/logger.utils.js +0 -304
  110. package/build/esm/utils/middleware.utils.d.ts +0 -99
  111. package/build/esm/utils/middleware.utils.js +0 -235
  112. package/build/esm/utils/obj.utils.d.ts +0 -123
  113. package/build/esm/utils/obj.utils.js +0 -412
  114. package/build/esm/utils/performance.utils.d.ts +0 -135
  115. package/build/esm/utils/performance.utils.js +0 -273
  116. package/build/esm/utils/request.utils.d.ts +0 -85
  117. package/build/esm/utils/request.utils.js +0 -190
  118. package/build/esm/utils/response.utils.d.ts +0 -162
  119. package/build/esm/utils/response.utils.js +0 -261
  120. package/build/esm/utils/stream.utils.d.ts +0 -87
  121. package/build/esm/utils/stream.utils.js +0 -209
  122. package/build/esm/utils/string.utils.d.ts +0 -92
  123. package/build/esm/utils/string.utils.js +0 -164
  124. package/build/esm/utils/type.utils.d.ts +0 -89
  125. package/build/esm/utils/type.utils.js +0 -186
  126. package/build/esm/utils/url.utils.d.ts +0 -140
  127. package/build/esm/utils/url.utils.js +0 -303
  128. package/build/esm/utils/validate.utils.d.ts +0 -176
  129. package/build/esm/utils/validate.utils.js +0 -319
@@ -1,265 +0,0 @@
1
- /**
2
- * Complete HTTP status codes enum with descriptions.
3
- * For use with API responses and error handling.
4
- */
5
- export declare enum HttpStatusCodes {
6
- /**
7
- * The server has received the request headers and the client should proceed to send the request body.
8
- */
9
- CONTINUE = 100,
10
- /**
11
- * The server is switching protocols according to the client's request.
12
- */
13
- SWITCHING_PROTOCOLS = 101,
14
- /**
15
- * Server has received the request and is still processing it.
16
- */
17
- PROCESSING = 102,
18
- /**
19
- * The server is sending preliminary headers while preparing the final response.
20
- */
21
- EARLY_HINTS = 103,
22
- /**
23
- * The request succeeded. The result meaning depends on the HTTP method used.
24
- */
25
- OK = 200,
26
- /**
27
- * The request succeeded and a new resource was created as a result.
28
- */
29
- CREATED = 201,
30
- /**
31
- * The request has been received but not yet acted upon.
32
- */
33
- ACCEPTED = 202,
34
- /**
35
- * The returned information is from a third-party source, not the origin server.
36
- */
37
- NON_AUTHORITATIVE_INFORMATION = 203,
38
- /**
39
- * The request succeeded but there's no content to send in the response.
40
- */
41
- NO_CONTENT = 204,
42
- /**
43
- * The client should reset the document view that caused this request.
44
- */
45
- RESET_CONTENT = 205,
46
- /**
47
- * The server is delivering only part of the resource due to a range header sent by the client.
48
- */
49
- PARTIAL_CONTENT = 206,
50
- /**
51
- * Conveys information about multiple resources, for complex operations.
52
- */
53
- MULTI_STATUS = 207,
54
- /**
55
- * The members of a DAV binding have already been enumerated and are not included in the response.
56
- */
57
- ALREADY_REPORTED = 208,
58
- /**
59
- * The server has fulfilled a request for the resource, and the response represents the result of one or more instance-manipulations.
60
- */
61
- IM_USED = 226,
62
- /**
63
- * The request has more than one possible response and the client should choose one.
64
- */
65
- MULTIPLE_CHOICES = 300,
66
- /**
67
- * The resource has been permanently moved to a new URL.
68
- */
69
- MOVED_PERMANENTLY = 301,
70
- /**
71
- * The resource has been temporarily moved to another URL.
72
- */
73
- MOVED_TEMPORARILY = 302,
74
- /**
75
- * The response to the request can be found under another URI using the GET method.
76
- */
77
- SEE_OTHER = 303,
78
- /**
79
- * The resource hasn't been modified since the last request.
80
- */
81
- NOT_MODIFIED = 304,
82
- /**
83
- * @deprecated
84
- * Response must be accessed through a proxy.
85
- */
86
- USE_PROXY = 305,
87
- /**
88
- * The resource is temporarily available at a different URI, using the same HTTP method.
89
- */
90
- TEMPORARY_REDIRECT = 307,
91
- /**
92
- * The resource has been permanently moved to another URL, using the same HTTP method.
93
- */
94
- PERMANENT_REDIRECT = 308,
95
- /**
96
- * The server cannot process the request due to a client error (malformed request).
97
- */
98
- BAD_REQUEST = 400,
99
- /**
100
- * Authentication is required and has failed or not been provided.
101
- */
102
- UNAUTHORIZED = 401,
103
- /**
104
- * Reserved for future use, originally intended for digital payment systems.
105
- */
106
- PAYMENT_REQUIRED = 402,
107
- /**
108
- * The client doesn't have permission to access the requested resource.
109
- */
110
- FORBIDDEN = 403,
111
- /**
112
- * The requested resource could not be found on the server.
113
- */
114
- NOT_FOUND = 404,
115
- /**
116
- * The request method is not supported for the requested resource.
117
- */
118
- METHOD_NOT_ALLOWED = 405,
119
- /**
120
- * The server can't provide a response matching the list of acceptable values in the client's headers.
121
- */
122
- NOT_ACCEPTABLE = 406,
123
- /**
124
- * Authentication by a proxy is required.
125
- */
126
- PROXY_AUTHENTICATION_REQUIRED = 407,
127
- /**
128
- * The server timed out waiting for the request.
129
- */
130
- REQUEST_TIMEOUT = 408,
131
- /**
132
- * The request conflicts with the current state of the server.
133
- */
134
- CONFLICT = 409,
135
- /**
136
- * The resource has been permanently deleted with no forwarding address.
137
- */
138
- GONE = 410,
139
- /**
140
- * The server requires a Content-Length header field.
141
- */
142
- LENGTH_REQUIRED = 411,
143
- /**
144
- * Preconditions in the client's headers failed.
145
- */
146
- PRECONDITION_FAILED = 412,
147
- /**
148
- * Request entity is larger than limits defined by server.
149
- */
150
- REQUEST_TOO_LONG = 413,
151
- /**
152
- * The request payload exceeds server size limits.
153
- * Modern equivalent of REQUEST_TOO_LONG.
154
- */
155
- PAYLOAD_TOO_LARGE = 413,
156
- /**
157
- * The URI requested is too long for the server to interpret.
158
- */
159
- REQUEST_URI_TOO_LONG = 414,
160
- /**
161
- * The server does not support the media type requested by the client.
162
- */
163
- UNSUPPORTED_MEDIA_TYPE = 415,
164
- /**
165
- * The range specified by the Range header cannot be fulfilled.
166
- */
167
- REQUESTED_RANGE_NOT_SATISFIABLE = 416,
168
- /**
169
- * The server cannot meet the expectations given in the Expect header.
170
- */
171
- EXPECTATION_FAILED = 417,
172
- /**
173
- * The server refuses to brew coffee because it is a teapot. (April Fools' joke)
174
- */
175
- IM_A_TEAPOT = 418,
176
- /**
177
- * The server cannot store the representation needed to complete the request.
178
- */
179
- INSUFFICIENT_SPACE_ON_RESOURCE = 419,
180
- /**
181
- * @deprecated
182
- * A method has failed - specific to Spring Framework.
183
- */
184
- METHOD_FAILURE = 420,
185
- /**
186
- * The server cannot produce a response for the requested URI scheme and authority.
187
- */
188
- MISDIRECTED_REQUEST = 421,
189
- /**
190
- * The request was well-formed but has semantic errors preventing processing.
191
- */
192
- UNPROCESSABLE_ENTITY = 422,
193
- /**
194
- * The requested resource is locked against access.
195
- */
196
- LOCKED = 423,
197
- /**
198
- * The request failed due to the failure of a previous request.
199
- */
200
- FAILED_DEPENDENCY = 424,
201
- /**
202
- * The client should switch to a different protocol.
203
- */
204
- UPGRADE_REQUIRED = 426,
205
- /**
206
- * The server requires conditional requests to prevent lost updates.
207
- */
208
- PRECONDITION_REQUIRED = 428,
209
- /**
210
- * The client has sent too many requests in a given time period (rate limiting).
211
- */
212
- TOO_MANY_REQUESTS = 429,
213
- /**
214
- * Request headers are too large for the server to process.
215
- */
216
- REQUEST_HEADER_FIELDS_TOO_LARGE = 431,
217
- /**
218
- * Resource cannot be legally provided (e.g., censored by government).
219
- */
220
- UNAVAILABLE_FOR_LEGAL_REASONS = 451,
221
- /**
222
- * The server encountered an unexpected error preventing it from fulfilling the request.
223
- */
224
- INTERNAL_SERVER_ERROR = 500,
225
- /**
226
- * The server does not support the functionality required to fulfill the request.
227
- */
228
- NOT_IMPLEMENTED = 501,
229
- /**
230
- * The server, acting as a gateway, received an invalid response from an upstream server.
231
- */
232
- BAD_GATEWAY = 502,
233
- /**
234
- * The server is currently unable to handle the request due to temporary overload or maintenance.
235
- */
236
- SERVICE_UNAVAILABLE = 503,
237
- /**
238
- * The server, acting as a gateway, did not receive a timely response from an upstream server.
239
- */
240
- GATEWAY_TIMEOUT = 504,
241
- /**
242
- * The server does not support the HTTP protocol version used in the request.
243
- */
244
- HTTP_VERSION_NOT_SUPPORTED = 505,
245
- /**
246
- * Transparent content negotiation for the request resulted in circular reference.
247
- */
248
- VARIANT_ALSO_NEGOTIATES = 506,
249
- /**
250
- * The server cannot store the representation needed to complete the request.
251
- */
252
- INSUFFICIENT_STORAGE = 507,
253
- /**
254
- * The server detected an infinite loop while processing the request.
255
- */
256
- LOOP_DETECTED = 508,
257
- /**
258
- * Further extensions to the request are required for the server to fulfill it.
259
- */
260
- NOT_EXTENDED = 510,
261
- /**
262
- * The client needs to authenticate to gain network access.
263
- */
264
- NETWORK_AUTHENTICATION_REQUIRED = 511
265
- }
@@ -1,294 +0,0 @@
1
- /*
2
- * The MIT License
3
- *
4
- * Copyright (c) 2025 Catbee Technologies. https://catbee-utils.npm.hprasath.com/license
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
- /**
25
- * Complete HTTP status codes enum with descriptions.
26
- * For use with API responses and error handling.
27
- */
28
- export var HttpStatusCodes;
29
- (function (HttpStatusCodes) {
30
- // 1xx Informational
31
- /**
32
- * The server has received the request headers and the client should proceed to send the request body.
33
- */
34
- HttpStatusCodes[HttpStatusCodes["CONTINUE"] = 100] = "CONTINUE";
35
- /**
36
- * The server is switching protocols according to the client's request.
37
- */
38
- HttpStatusCodes[HttpStatusCodes["SWITCHING_PROTOCOLS"] = 101] = "SWITCHING_PROTOCOLS";
39
- /**
40
- * Server has received the request and is still processing it.
41
- */
42
- HttpStatusCodes[HttpStatusCodes["PROCESSING"] = 102] = "PROCESSING";
43
- /**
44
- * The server is sending preliminary headers while preparing the final response.
45
- */
46
- HttpStatusCodes[HttpStatusCodes["EARLY_HINTS"] = 103] = "EARLY_HINTS";
47
- // 2xx Success
48
- /**
49
- * The request succeeded. The result meaning depends on the HTTP method used.
50
- */
51
- HttpStatusCodes[HttpStatusCodes["OK"] = 200] = "OK";
52
- /**
53
- * The request succeeded and a new resource was created as a result.
54
- */
55
- HttpStatusCodes[HttpStatusCodes["CREATED"] = 201] = "CREATED";
56
- /**
57
- * The request has been received but not yet acted upon.
58
- */
59
- HttpStatusCodes[HttpStatusCodes["ACCEPTED"] = 202] = "ACCEPTED";
60
- /**
61
- * The returned information is from a third-party source, not the origin server.
62
- */
63
- HttpStatusCodes[HttpStatusCodes["NON_AUTHORITATIVE_INFORMATION"] = 203] = "NON_AUTHORITATIVE_INFORMATION";
64
- /**
65
- * The request succeeded but there's no content to send in the response.
66
- */
67
- HttpStatusCodes[HttpStatusCodes["NO_CONTENT"] = 204] = "NO_CONTENT";
68
- /**
69
- * The client should reset the document view that caused this request.
70
- */
71
- HttpStatusCodes[HttpStatusCodes["RESET_CONTENT"] = 205] = "RESET_CONTENT";
72
- /**
73
- * The server is delivering only part of the resource due to a range header sent by the client.
74
- */
75
- HttpStatusCodes[HttpStatusCodes["PARTIAL_CONTENT"] = 206] = "PARTIAL_CONTENT";
76
- /**
77
- * Conveys information about multiple resources, for complex operations.
78
- */
79
- HttpStatusCodes[HttpStatusCodes["MULTI_STATUS"] = 207] = "MULTI_STATUS";
80
- /**
81
- * The members of a DAV binding have already been enumerated and are not included in the response.
82
- */
83
- HttpStatusCodes[HttpStatusCodes["ALREADY_REPORTED"] = 208] = "ALREADY_REPORTED";
84
- /**
85
- * The server has fulfilled a request for the resource, and the response represents the result of one or more instance-manipulations.
86
- */
87
- HttpStatusCodes[HttpStatusCodes["IM_USED"] = 226] = "IM_USED";
88
- // 3xx Redirection
89
- /**
90
- * The request has more than one possible response and the client should choose one.
91
- */
92
- HttpStatusCodes[HttpStatusCodes["MULTIPLE_CHOICES"] = 300] = "MULTIPLE_CHOICES";
93
- /**
94
- * The resource has been permanently moved to a new URL.
95
- */
96
- HttpStatusCodes[HttpStatusCodes["MOVED_PERMANENTLY"] = 301] = "MOVED_PERMANENTLY";
97
- /**
98
- * The resource has been temporarily moved to another URL.
99
- */
100
- HttpStatusCodes[HttpStatusCodes["MOVED_TEMPORARILY"] = 302] = "MOVED_TEMPORARILY";
101
- /**
102
- * The response to the request can be found under another URI using the GET method.
103
- */
104
- HttpStatusCodes[HttpStatusCodes["SEE_OTHER"] = 303] = "SEE_OTHER";
105
- /**
106
- * The resource hasn't been modified since the last request.
107
- */
108
- HttpStatusCodes[HttpStatusCodes["NOT_MODIFIED"] = 304] = "NOT_MODIFIED";
109
- /**
110
- * @deprecated
111
- * Response must be accessed through a proxy.
112
- */
113
- HttpStatusCodes[HttpStatusCodes["USE_PROXY"] = 305] = "USE_PROXY";
114
- /**
115
- * The resource is temporarily available at a different URI, using the same HTTP method.
116
- */
117
- HttpStatusCodes[HttpStatusCodes["TEMPORARY_REDIRECT"] = 307] = "TEMPORARY_REDIRECT";
118
- /**
119
- * The resource has been permanently moved to another URL, using the same HTTP method.
120
- */
121
- HttpStatusCodes[HttpStatusCodes["PERMANENT_REDIRECT"] = 308] = "PERMANENT_REDIRECT";
122
- // 4xx Client Error
123
- /**
124
- * The server cannot process the request due to a client error (malformed request).
125
- */
126
- HttpStatusCodes[HttpStatusCodes["BAD_REQUEST"] = 400] = "BAD_REQUEST";
127
- /**
128
- * Authentication is required and has failed or not been provided.
129
- */
130
- HttpStatusCodes[HttpStatusCodes["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
131
- /**
132
- * Reserved for future use, originally intended for digital payment systems.
133
- */
134
- HttpStatusCodes[HttpStatusCodes["PAYMENT_REQUIRED"] = 402] = "PAYMENT_REQUIRED";
135
- /**
136
- * The client doesn't have permission to access the requested resource.
137
- */
138
- HttpStatusCodes[HttpStatusCodes["FORBIDDEN"] = 403] = "FORBIDDEN";
139
- /**
140
- * The requested resource could not be found on the server.
141
- */
142
- HttpStatusCodes[HttpStatusCodes["NOT_FOUND"] = 404] = "NOT_FOUND";
143
- /**
144
- * The request method is not supported for the requested resource.
145
- */
146
- HttpStatusCodes[HttpStatusCodes["METHOD_NOT_ALLOWED"] = 405] = "METHOD_NOT_ALLOWED";
147
- /**
148
- * The server can't provide a response matching the list of acceptable values in the client's headers.
149
- */
150
- HttpStatusCodes[HttpStatusCodes["NOT_ACCEPTABLE"] = 406] = "NOT_ACCEPTABLE";
151
- /**
152
- * Authentication by a proxy is required.
153
- */
154
- HttpStatusCodes[HttpStatusCodes["PROXY_AUTHENTICATION_REQUIRED"] = 407] = "PROXY_AUTHENTICATION_REQUIRED";
155
- /**
156
- * The server timed out waiting for the request.
157
- */
158
- HttpStatusCodes[HttpStatusCodes["REQUEST_TIMEOUT"] = 408] = "REQUEST_TIMEOUT";
159
- /**
160
- * The request conflicts with the current state of the server.
161
- */
162
- HttpStatusCodes[HttpStatusCodes["CONFLICT"] = 409] = "CONFLICT";
163
- /**
164
- * The resource has been permanently deleted with no forwarding address.
165
- */
166
- HttpStatusCodes[HttpStatusCodes["GONE"] = 410] = "GONE";
167
- /**
168
- * The server requires a Content-Length header field.
169
- */
170
- HttpStatusCodes[HttpStatusCodes["LENGTH_REQUIRED"] = 411] = "LENGTH_REQUIRED";
171
- /**
172
- * Preconditions in the client's headers failed.
173
- */
174
- HttpStatusCodes[HttpStatusCodes["PRECONDITION_FAILED"] = 412] = "PRECONDITION_FAILED";
175
- /**
176
- * Request entity is larger than limits defined by server.
177
- */
178
- HttpStatusCodes[HttpStatusCodes["REQUEST_TOO_LONG"] = 413] = "REQUEST_TOO_LONG";
179
- /**
180
- * The request payload exceeds server size limits.
181
- * Modern equivalent of REQUEST_TOO_LONG.
182
- */
183
- HttpStatusCodes[HttpStatusCodes["PAYLOAD_TOO_LARGE"] = 413] = "PAYLOAD_TOO_LARGE";
184
- /**
185
- * The URI requested is too long for the server to interpret.
186
- */
187
- HttpStatusCodes[HttpStatusCodes["REQUEST_URI_TOO_LONG"] = 414] = "REQUEST_URI_TOO_LONG";
188
- /**
189
- * The server does not support the media type requested by the client.
190
- */
191
- HttpStatusCodes[HttpStatusCodes["UNSUPPORTED_MEDIA_TYPE"] = 415] = "UNSUPPORTED_MEDIA_TYPE";
192
- /**
193
- * The range specified by the Range header cannot be fulfilled.
194
- */
195
- HttpStatusCodes[HttpStatusCodes["REQUESTED_RANGE_NOT_SATISFIABLE"] = 416] = "REQUESTED_RANGE_NOT_SATISFIABLE";
196
- /**
197
- * The server cannot meet the expectations given in the Expect header.
198
- */
199
- HttpStatusCodes[HttpStatusCodes["EXPECTATION_FAILED"] = 417] = "EXPECTATION_FAILED";
200
- /**
201
- * The server refuses to brew coffee because it is a teapot. (April Fools' joke)
202
- */
203
- HttpStatusCodes[HttpStatusCodes["IM_A_TEAPOT"] = 418] = "IM_A_TEAPOT";
204
- /**
205
- * The server cannot store the representation needed to complete the request.
206
- */
207
- HttpStatusCodes[HttpStatusCodes["INSUFFICIENT_SPACE_ON_RESOURCE"] = 419] = "INSUFFICIENT_SPACE_ON_RESOURCE";
208
- /**
209
- * @deprecated
210
- * A method has failed - specific to Spring Framework.
211
- */
212
- HttpStatusCodes[HttpStatusCodes["METHOD_FAILURE"] = 420] = "METHOD_FAILURE";
213
- /**
214
- * The server cannot produce a response for the requested URI scheme and authority.
215
- */
216
- HttpStatusCodes[HttpStatusCodes["MISDIRECTED_REQUEST"] = 421] = "MISDIRECTED_REQUEST";
217
- /**
218
- * The request was well-formed but has semantic errors preventing processing.
219
- */
220
- HttpStatusCodes[HttpStatusCodes["UNPROCESSABLE_ENTITY"] = 422] = "UNPROCESSABLE_ENTITY";
221
- /**
222
- * The requested resource is locked against access.
223
- */
224
- HttpStatusCodes[HttpStatusCodes["LOCKED"] = 423] = "LOCKED";
225
- /**
226
- * The request failed due to the failure of a previous request.
227
- */
228
- HttpStatusCodes[HttpStatusCodes["FAILED_DEPENDENCY"] = 424] = "FAILED_DEPENDENCY";
229
- /**
230
- * The client should switch to a different protocol.
231
- */
232
- HttpStatusCodes[HttpStatusCodes["UPGRADE_REQUIRED"] = 426] = "UPGRADE_REQUIRED";
233
- /**
234
- * The server requires conditional requests to prevent lost updates.
235
- */
236
- HttpStatusCodes[HttpStatusCodes["PRECONDITION_REQUIRED"] = 428] = "PRECONDITION_REQUIRED";
237
- /**
238
- * The client has sent too many requests in a given time period (rate limiting).
239
- */
240
- HttpStatusCodes[HttpStatusCodes["TOO_MANY_REQUESTS"] = 429] = "TOO_MANY_REQUESTS";
241
- /**
242
- * Request headers are too large for the server to process.
243
- */
244
- HttpStatusCodes[HttpStatusCodes["REQUEST_HEADER_FIELDS_TOO_LARGE"] = 431] = "REQUEST_HEADER_FIELDS_TOO_LARGE";
245
- /**
246
- * Resource cannot be legally provided (e.g., censored by government).
247
- */
248
- HttpStatusCodes[HttpStatusCodes["UNAVAILABLE_FOR_LEGAL_REASONS"] = 451] = "UNAVAILABLE_FOR_LEGAL_REASONS";
249
- // 5xx Server Error
250
- /**
251
- * The server encountered an unexpected error preventing it from fulfilling the request.
252
- */
253
- HttpStatusCodes[HttpStatusCodes["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
254
- /**
255
- * The server does not support the functionality required to fulfill the request.
256
- */
257
- HttpStatusCodes[HttpStatusCodes["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
258
- /**
259
- * The server, acting as a gateway, received an invalid response from an upstream server.
260
- */
261
- HttpStatusCodes[HttpStatusCodes["BAD_GATEWAY"] = 502] = "BAD_GATEWAY";
262
- /**
263
- * The server is currently unable to handle the request due to temporary overload or maintenance.
264
- */
265
- HttpStatusCodes[HttpStatusCodes["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";
266
- /**
267
- * The server, acting as a gateway, did not receive a timely response from an upstream server.
268
- */
269
- HttpStatusCodes[HttpStatusCodes["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
270
- /**
271
- * The server does not support the HTTP protocol version used in the request.
272
- */
273
- HttpStatusCodes[HttpStatusCodes["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
274
- /**
275
- * Transparent content negotiation for the request resulted in circular reference.
276
- */
277
- HttpStatusCodes[HttpStatusCodes["VARIANT_ALSO_NEGOTIATES"] = 506] = "VARIANT_ALSO_NEGOTIATES";
278
- /**
279
- * The server cannot store the representation needed to complete the request.
280
- */
281
- HttpStatusCodes[HttpStatusCodes["INSUFFICIENT_STORAGE"] = 507] = "INSUFFICIENT_STORAGE";
282
- /**
283
- * The server detected an infinite loop while processing the request.
284
- */
285
- HttpStatusCodes[HttpStatusCodes["LOOP_DETECTED"] = 508] = "LOOP_DETECTED";
286
- /**
287
- * Further extensions to the request are required for the server to fulfill it.
288
- */
289
- HttpStatusCodes[HttpStatusCodes["NOT_EXTENDED"] = 510] = "NOT_EXTENDED";
290
- /**
291
- * The client needs to authenticate to gain network access.
292
- */
293
- HttpStatusCodes[HttpStatusCodes["NETWORK_AUTHENTICATION_REQUIRED"] = 511] = "NETWORK_AUTHENTICATION_REQUIRED";
294
- })(HttpStatusCodes || (HttpStatusCodes = {}));
@@ -1,35 +0,0 @@
1
- /**
2
- * Generates a UUID v4 string (RFC 4122).
3
- *
4
- * @returns {string} UUID v4 (e.g., 'c0de1234-5678-9abc-def0-123456789abc')
5
- */
6
- export declare function uuid(): string;
7
- /**
8
- * Generates a nanoid-style random ID (URL-safe, customizable length).
9
- *
10
- * @param {number} length - Length of the ID (default: 21).
11
- * @returns {string} Nanoid-style random string.
12
- */
13
- export declare function nanoId(length?: number): string;
14
- /**
15
- * Generates a cryptographically strong random hex string.
16
- *
17
- * @param {number} byteLength - Number of random bytes (default: 16 → 32 hex chars).
18
- * @returns {string} Random hex string.
19
- */
20
- export declare function randomHex(byteLength?: number): string;
21
- /**
22
- * Generates a random integer between min (inclusive) and max (inclusive).
23
- *
24
- * @param {number} min - Minimum value.
25
- * @param {number} max - Maximum value.
26
- * @returns {number} Random integer in range.
27
- */
28
- export declare function randomInt(min: number, max: number): number;
29
- /**
30
- * Generates a cryptographically strong random base64 string.
31
- *
32
- * @param {number} byteLength - Number of random bytes (default: 16).
33
- * @returns {string} Random base64 string (URL-safe, no padding).
34
- */
35
- export declare function randomBase64(byteLength?: number): string;
@@ -1,83 +0,0 @@
1
- /*
2
- * The MIT License
3
- *
4
- * Copyright (c) 2025 Catbee Technologies. https://catbee-utils.npm.hprasath.com/license
5
- *
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to deal
8
- * in the Software without restriction, including without limitation the rights
9
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- * copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in all
14
- * copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- * SOFTWARE.
23
- */
24
- import { randomUUID, randomBytes } from 'crypto';
25
- /**
26
- * Generates a UUID v4 string (RFC 4122).
27
- *
28
- * @returns {string} UUID v4 (e.g., 'c0de1234-5678-9abc-def0-123456789abc')
29
- */
30
- export function uuid() {
31
- return randomUUID();
32
- }
33
- /**
34
- * Generates a nanoid-style random ID (URL-safe, customizable length).
35
- *
36
- * @param {number} length - Length of the ID (default: 21).
37
- * @returns {string} Nanoid-style random string.
38
- */
39
- export function nanoId(length = 21) {
40
- if (length <= 0)
41
- return '';
42
- let id = '';
43
- while (id.length < length) {
44
- id += randomBytes(Math.ceil((length * 3) / 4))
45
- .toString('base64url')
46
- .replace(/[+/=]/g, '');
47
- }
48
- return id.slice(0, length);
49
- }
50
- /**
51
- * Generates a cryptographically strong random hex string.
52
- *
53
- * @param {number} byteLength - Number of random bytes (default: 16 → 32 hex chars).
54
- * @returns {string} Random hex string.
55
- */
56
- export function randomHex(byteLength = 16) {
57
- // Use Node.js crypto for both Node and browser compatibility
58
- // Prefer randomBytes if available (Node), fallback to getRandomValues for browser (not used here)
59
- return randomBytes(byteLength)
60
- .toString('hex')
61
- .padStart(byteLength * 2, '0')
62
- .slice(0, byteLength * 2);
63
- }
64
- /**
65
- * Generates a random integer between min (inclusive) and max (inclusive).
66
- *
67
- * @param {number} min - Minimum value.
68
- * @param {number} max - Maximum value.
69
- * @returns {number} Random integer in range.
70
- */
71
- export function randomInt(min, max) {
72
- const range = max - min + 1;
73
- return Math.floor(Math.random() * range) + min;
74
- }
75
- /**
76
- * Generates a cryptographically strong random base64 string.
77
- *
78
- * @param {number} byteLength - Number of random bytes (default: 16).
79
- * @returns {string} Random base64 string (URL-safe, no padding).
80
- */
81
- export function randomBase64(byteLength = 16) {
82
- return randomBytes(byteLength).toString('base64url');
83
- }