@catbee/utils 2.0.0-next.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +102 -52
- package/array/index.cjs +215 -74
- package/array/index.d.ts +345 -2
- package/array/index.mjs +201 -74
- package/async/index.cjs +116 -39
- package/async/index.d.ts +292 -2
- package/async/index.mjs +116 -40
- package/cache/index.cjs +2 -2
- package/cache/index.d.ts +156 -2
- package/cache/index.mjs +3 -3
- package/config/index.cjs +80 -66
- package/config/index.d.ts +65 -3
- package/config/index.mjs +77 -65
- package/context-store/index.cjs +2 -3
- package/context-store/index.d.ts +193 -2
- package/context-store/index.mjs +2 -3
- package/crypto/index.cjs +55 -5
- package/crypto/index.d.ts +225 -2
- package/crypto/index.mjs +52 -7
- package/date/index.cjs +676 -2
- package/date/index.d.ts +676 -2
- package/date/index.mjs +665 -3
- package/decorator/index.cjs +2172 -0
- package/{decorators/decorators.utils.d.ts → decorator/index.d.ts} +58 -54
- package/decorator/index.mjs +2131 -0
- package/{dir → directory}/index.cjs +5 -4
- package/{dir/dir.utils.d.ts → directory/index.d.ts} +24 -21
- package/{dir → directory}/index.mjs +5 -4
- package/env/index.cjs +100 -68
- package/env/index.d.ts +391 -2
- package/env/index.mjs +100 -68
- package/exception/index.cjs +1 -1
- package/exception/index.d.ts +233 -2
- package/exception/index.mjs +1 -1
- package/fs/index.cjs +71 -37
- package/fs/index.d.ts +206 -2
- package/fs/index.mjs +65 -35
- package/http-status-codes/index.cjs +1 -1
- package/http-status-codes/index.d.ts +268 -2
- package/http-status-codes/index.mjs +1 -1
- package/id/index.cjs +1 -1
- package/id/index.d.ts +38 -2
- package/id/index.mjs +1 -1
- package/index.cjs +13 -13
- package/index.d.ts +5 -5
- package/index.mjs +5 -5
- package/logger/index.cjs +13 -15
- package/logger/index.d.ts +190 -2
- package/logger/index.mjs +14 -16
- package/middleware/index.cjs +1 -1
- package/middleware/index.d.ts +104 -2
- package/middleware/index.mjs +1 -1
- package/object/index.cjs +379 -0
- package/{obj/obj.utils.d.ts → object/index.d.ts} +73 -33
- package/object/index.mjs +360 -0
- package/package.json +41 -23
- package/performance/index.cjs +4 -4
- package/performance/index.d.ts +139 -2
- package/performance/index.mjs +4 -4
- package/request/index.cjs +37 -25
- package/request/index.d.ts +242 -3
- package/request/index.mjs +37 -25
- package/response/index.cjs +1 -1
- package/response/index.d.ts +319 -3
- package/response/index.mjs +1 -1
- package/server/index.cjs +249 -146
- package/server/index.d.ts +866 -5
- package/server/index.mjs +248 -144
- package/stream/index.cjs +1 -1
- package/stream/index.d.ts +91 -2
- package/stream/index.mjs +1 -1
- package/string/index.cjs +34 -1
- package/string/index.d.ts +146 -2
- package/string/index.mjs +31 -2
- package/type/index.cjs +19 -2
- package/type/index.d.ts +144 -2
- package/type/index.mjs +17 -3
- package/types/index.cjs +1 -1
- package/types/index.d.ts +775 -5
- package/types/index.mjs +1 -1
- package/url/index.cjs +63 -5
- package/url/index.d.ts +200 -2
- package/url/index.mjs +59 -6
- package/{validate → validation}/index.cjs +91 -44
- package/{validate/validate.utils.d.ts → validation/index.d.ts} +33 -24
- package/{validate → validation}/index.mjs +87 -44
- package/array/array.utils.d.ts +0 -191
- package/async/async.utils.d.ts +0 -296
- package/cache/cache.utils.d.ts +0 -176
- package/config/config.d.ts +0 -57
- package/context-store/context-store.utils.d.ts +0 -212
- package/crypto/crypto.utils.d.ts +0 -183
- package/date/date.utils.d.ts +0 -190
- package/decorators/index.cjs +0 -913
- package/decorators/index.d.ts +0 -25
- package/decorators/index.mjs +0 -872
- package/dir/index.d.ts +0 -25
- package/env/env.utils.d.ts +0 -400
- package/exception/exception.utils.d.ts +0 -253
- package/fs/fs.utils.d.ts +0 -196
- package/http-status-codes/http-status-codes.d.ts +0 -289
- package/id/id.utils.d.ts +0 -59
- package/logger/logger.utils.d.ts +0 -210
- package/middleware/middleware.utils.d.ts +0 -123
- package/obj/index.cjs +0 -317
- package/obj/index.d.ts +0 -25
- package/obj/index.mjs +0 -301
- package/performance/performance.utils.d.ts +0 -159
- package/request/request.utils.d.ts +0 -109
- package/response/response.utils.d.ts +0 -186
- package/server/server.builder.d.ts +0 -531
- package/server/server.d.ts +0 -303
- package/stream/stream.utils.d.ts +0 -111
- package/string/string.utils.d.ts +0 -124
- package/type/type.utils.d.ts +0 -129
- package/types/api-response.d.ts +0 -175
- package/types/common.d.ts +0 -148
- package/types/config.d.ts +0 -88
- package/types/server.d.ts +0 -291
- package/url/url.utils.d.ts +0 -164
- package/validate/index.d.ts +0 -25
package/fs/fs.utils.d.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2025 Catbee Technologies. https://catbee.in/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
|
-
import type { BufferEncoding } from '@catbee/utils/crypto';
|
|
26
|
-
import { Stats } from 'fs';
|
|
27
|
-
/**
|
|
28
|
-
* Checks whether a file or directory exists at the given path.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} path - The file or directory path to check.
|
|
31
|
-
* @returns {Promise<boolean>} Resolves to `true` if the path exists, `false` otherwise.
|
|
32
|
-
*/
|
|
33
|
-
export declare function fileExists(path: string): Promise<boolean>;
|
|
34
|
-
/**
|
|
35
|
-
* Reads and parses a JSON file from the specified path.
|
|
36
|
-
*
|
|
37
|
-
* @typeParam T - The expected type of the parsed JSON object.
|
|
38
|
-
* @param {string} path - The path to the JSON file.
|
|
39
|
-
* @returns {Promise<T | null>} The parsed object, or `null` if reading or parsing fails.
|
|
40
|
-
*/
|
|
41
|
-
export declare function readJsonFile<T = any>(path: string): Promise<T | null>;
|
|
42
|
-
/**
|
|
43
|
-
* Read and parse JSON file or return a provided default value on error.
|
|
44
|
-
*
|
|
45
|
-
* @typeParam T
|
|
46
|
-
* @param {string} path - Path to JSON file
|
|
47
|
-
* @param {T} defaultValue - Default value to return when read/parse fails
|
|
48
|
-
* @returns {Promise<T>} Parsed JSON or defaultValue
|
|
49
|
-
*/
|
|
50
|
-
export declare function readJsonOrDefault<T = any>(path: string, defaultValue: T): Promise<T>;
|
|
51
|
-
/**
|
|
52
|
-
* Writes a JavaScript object to a file as formatted JSON.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} path - The destination file path.
|
|
55
|
-
* @param {any} data - The object to serialize and write.
|
|
56
|
-
* @param {number} [space=2] - Number of spaces for JSON formatting.
|
|
57
|
-
* @returns {Promise<void>} Resolves when writing is complete.
|
|
58
|
-
*/
|
|
59
|
-
export declare function writeJsonFile(path: string, data: any, space?: number): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
* Deletes a file if it exists.
|
|
62
|
-
*
|
|
63
|
-
* @param {string} path - The file path to delete.
|
|
64
|
-
* @returns {Promise<boolean>} Resolves to `true` if the file was deleted or didn't exist, `false` if deletion failed.
|
|
65
|
-
*/
|
|
66
|
-
export declare function deleteFileIfExists(path: string): Promise<boolean>;
|
|
67
|
-
/**
|
|
68
|
-
* Reads a text file from the specified path.
|
|
69
|
-
*
|
|
70
|
-
* @param {string} path - The path to the text file.
|
|
71
|
-
* @param {BufferEncoding} [encoding="utf-8"] - The encoding to use.
|
|
72
|
-
* @returns {Promise<string | null>} The file contents, or `null` if reading fails.
|
|
73
|
-
*/
|
|
74
|
-
export declare function readTextFile(path: string, encoding?: BufferEncoding): Promise<string | null>;
|
|
75
|
-
/**
|
|
76
|
-
* Writes text content to a file.
|
|
77
|
-
*
|
|
78
|
-
* @param {string} path - The destination file path.
|
|
79
|
-
* @param {string} content - The text content to write.
|
|
80
|
-
* @param {BufferEncoding} [encoding="utf-8"] - The encoding to use.
|
|
81
|
-
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
82
|
-
*/
|
|
83
|
-
export declare function writeTextFile(path: string, content: string, encoding?: BufferEncoding): Promise<boolean>;
|
|
84
|
-
/**
|
|
85
|
-
* Appends text content to a file.
|
|
86
|
-
*
|
|
87
|
-
* @param {string} path - The file path to append to.
|
|
88
|
-
* @param {string} content - The text content to append.
|
|
89
|
-
* @param {BufferEncoding} [encoding="utf-8"] - The encoding to use.
|
|
90
|
-
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
91
|
-
*/
|
|
92
|
-
export declare function appendTextFile(path: string, content: string, encoding?: BufferEncoding): Promise<boolean>;
|
|
93
|
-
/**
|
|
94
|
-
* Copies a file from source to destination.
|
|
95
|
-
*
|
|
96
|
-
* @param {string} source - Source file path.
|
|
97
|
-
* @param {string} destination - Destination file path.
|
|
98
|
-
* @param {boolean} [overwrite=false] - Whether to overwrite if destination exists.
|
|
99
|
-
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
100
|
-
*/
|
|
101
|
-
export declare function copyFile(source: string, destination: string, overwrite?: boolean): Promise<boolean>;
|
|
102
|
-
/**
|
|
103
|
-
* Renames/moves a file.
|
|
104
|
-
*
|
|
105
|
-
* @param {string} oldPath - Current file path.
|
|
106
|
-
* @param {string} newPath - New file path.
|
|
107
|
-
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
108
|
-
*/
|
|
109
|
-
export declare function moveFile(oldPath: string, newPath: string): Promise<boolean>;
|
|
110
|
-
/**
|
|
111
|
-
* Gets file stats if the file exists.
|
|
112
|
-
*
|
|
113
|
-
* @param {string} path - Path to the file.
|
|
114
|
-
* @returns {Promise<fs.Stats | null>} File stats object or null if file doesn't exist.
|
|
115
|
-
*/
|
|
116
|
-
export declare function getFileStats(path: string): Promise<Stats | null>;
|
|
117
|
-
/**
|
|
118
|
-
* Creates a temporary file with optional content.
|
|
119
|
-
*
|
|
120
|
-
* @param {object} [options] - Options for creating the temp file.
|
|
121
|
-
* @param {string} [options.prefix="tmp-"] - Filename prefix.
|
|
122
|
-
* @param {string} [options.extension=""] - File extension.
|
|
123
|
-
* @param {string} [options.dir] - Directory to create the file in (defaults to OS temp dir).
|
|
124
|
-
* @param {string | Buffer} [options.content] - Optional content to write to the file.
|
|
125
|
-
* @returns {Promise<string>} Path to the created temporary file.
|
|
126
|
-
*/
|
|
127
|
-
export declare function createTempFile({ prefix, extension, dir, content }?: {
|
|
128
|
-
prefix?: string;
|
|
129
|
-
extension?: string;
|
|
130
|
-
dir?: string;
|
|
131
|
-
content?: string | Buffer;
|
|
132
|
-
}): Promise<string>;
|
|
133
|
-
/**
|
|
134
|
-
* Streams a file from source to destination.
|
|
135
|
-
* Useful for large files to avoid loading the entire file into memory.
|
|
136
|
-
*
|
|
137
|
-
* @param {string} source - Source file path.
|
|
138
|
-
* @param {string} destination - Destination file path.
|
|
139
|
-
* @returns {Promise<void>} Resolves when streaming completes.
|
|
140
|
-
* @throws {Error} If streaming fails.
|
|
141
|
-
*/
|
|
142
|
-
export declare function streamFile(source: string, destination: string): Promise<void>;
|
|
143
|
-
/**
|
|
144
|
-
* Reads a directory and returns file names.
|
|
145
|
-
*
|
|
146
|
-
* @param {string} dirPath - Path to the directory.
|
|
147
|
-
* @param {object} [options] - Options for reading the directory.
|
|
148
|
-
* @param {boolean} [options.fullPaths=false] - Whether to return full paths.
|
|
149
|
-
* @param {RegExp} [options.filter] - Optional regex to filter files.
|
|
150
|
-
* @returns {Promise<string[]>} Array of file names or paths.
|
|
151
|
-
* @throws {Error} If directory cannot be read.
|
|
152
|
-
*/
|
|
153
|
-
export declare function readDirectory(dirPath: string, options?: {
|
|
154
|
-
fullPaths?: boolean;
|
|
155
|
-
filter?: RegExp;
|
|
156
|
-
}): Promise<string[]>;
|
|
157
|
-
/**
|
|
158
|
-
* Creates a directory if it doesn't exist.
|
|
159
|
-
*
|
|
160
|
-
* @param {string} dirPath - Path to the directory.
|
|
161
|
-
* @param {boolean} [recursive=true] - Whether to create parent directories.
|
|
162
|
-
* @returns {Promise<boolean>} Resolves to `true` if successful, `false` otherwise.
|
|
163
|
-
*/
|
|
164
|
-
export declare function createDirectory(dirPath: string, recursive?: boolean): Promise<boolean>;
|
|
165
|
-
/**
|
|
166
|
-
* Safely reads and parses a JSON file with error details.
|
|
167
|
-
*
|
|
168
|
-
* @typeParam T - The expected type of the parsed JSON object.
|
|
169
|
-
* @param {string} path - The path to the JSON file.
|
|
170
|
-
* @returns {Promise<{ data: T | null; error: Error | null }>} Object with data and error properties.
|
|
171
|
-
*/
|
|
172
|
-
export declare function safeReadJsonFile<T = any>(path: string): Promise<{
|
|
173
|
-
data: T | null;
|
|
174
|
-
error: Error | null;
|
|
175
|
-
}>;
|
|
176
|
-
/**
|
|
177
|
-
* Checks if a path points to a file (not a directory).
|
|
178
|
-
*
|
|
179
|
-
* @param {string} path - Path to check.
|
|
180
|
-
* @returns {Promise<boolean>} True if the path is a file, false otherwise.
|
|
181
|
-
*/
|
|
182
|
-
export declare function isFile(path: string): Promise<boolean>;
|
|
183
|
-
/**
|
|
184
|
-
* Gets the size of a file in bytes.
|
|
185
|
-
*
|
|
186
|
-
* @param {string} path - Path to the file.
|
|
187
|
-
* @returns {Promise<number>} Size in bytes or -1 if file doesn't exist.
|
|
188
|
-
*/
|
|
189
|
-
export declare function getFileSize(path: string): Promise<number>;
|
|
190
|
-
/**
|
|
191
|
-
* Reads a file as a Buffer.
|
|
192
|
-
*
|
|
193
|
-
* @param {string} path - Path to the file.
|
|
194
|
-
* @returns {Promise<Buffer | null>} File contents as Buffer or null if reading fails.
|
|
195
|
-
*/
|
|
196
|
-
export declare function readFileBuffer(path: string): Promise<Buffer | null>;
|
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2025 Catbee Technologies. https://catbee.in/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
|
-
/**
|
|
26
|
-
* Complete HTTP status codes enum with descriptions.
|
|
27
|
-
* For use with API responses and error handling.
|
|
28
|
-
*/
|
|
29
|
-
export 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
|
-
}
|
package/id/id.utils.d.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2025 Catbee Technologies. https://catbee.in/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
|
-
/**
|
|
26
|
-
* Generates a UUID v4 string (RFC 4122).
|
|
27
|
-
*
|
|
28
|
-
* @returns {string} UUID v4 (e.g., 'c0de1234-5678-9abc-def0-123456789abc')
|
|
29
|
-
*/
|
|
30
|
-
export 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
|
-
export 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
|
-
export 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
|
-
export 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
|
-
export declare function randomBase64(byteLength?: number): string;
|