@catbee/utils 1.0.5 → 2.0.0-next.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.
Files changed (121) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +27 -27
  3. package/array/array.utils.d.ts +191 -0
  4. package/array/index.cjs +246 -0
  5. package/array/index.d.ts +25 -0
  6. package/array/index.mjs +228 -0
  7. package/async/async.utils.d.ts +296 -0
  8. package/async/index.cjs +428 -0
  9. package/async/index.d.ts +25 -0
  10. package/async/index.mjs +407 -0
  11. package/cache/cache.utils.d.ts +176 -0
  12. package/cache/index.cjs +292 -0
  13. package/cache/index.d.ts +25 -0
  14. package/cache/index.mjs +290 -0
  15. package/config/config.d.ts +57 -0
  16. package/config/index.cjs +136 -0
  17. package/config/index.d.ts +26 -0
  18. package/config/index.mjs +131 -0
  19. package/context-store/context-store.utils.d.ts +212 -0
  20. package/context-store/index.cjs +267 -0
  21. package/context-store/index.d.ts +25 -0
  22. package/context-store/index.mjs +261 -0
  23. package/crypto/crypto.utils.d.ts +183 -0
  24. package/crypto/index.cjs +182 -0
  25. package/crypto/index.d.ts +25 -0
  26. package/crypto/index.mjs +166 -0
  27. package/date/date.utils.d.ts +190 -0
  28. package/date/index.cjs +295 -0
  29. package/date/index.d.ts +25 -0
  30. package/date/index.mjs +283 -0
  31. package/decorators/decorators.utils.d.ts +705 -0
  32. package/decorators/index.cjs +913 -0
  33. package/decorators/index.d.ts +25 -0
  34. package/decorators/index.mjs +872 -0
  35. package/dir/dir.utils.d.ts +216 -0
  36. package/dir/index.cjs +416 -0
  37. package/dir/index.d.ts +25 -0
  38. package/dir/index.mjs +389 -0
  39. package/env/env.utils.d.ts +400 -0
  40. package/env/index.cjs +761 -0
  41. package/env/index.d.ts +25 -0
  42. package/env/index.mjs +758 -0
  43. package/exception/exception.utils.d.ts +253 -0
  44. package/exception/index.cjs +362 -0
  45. package/exception/index.d.ts +25 -0
  46. package/exception/index.mjs +338 -0
  47. package/fs/fs.utils.d.ts +196 -0
  48. package/fs/index.cjs +253 -0
  49. package/fs/index.d.ts +25 -0
  50. package/fs/index.mjs +228 -0
  51. package/http-status-codes/http-status-codes.d.ts +289 -0
  52. package/http-status-codes/index.cjs +96 -0
  53. package/http-status-codes/index.d.ts +25 -0
  54. package/http-status-codes/index.mjs +94 -0
  55. package/id/id.utils.d.ts +59 -0
  56. package/id/index.cjs +62 -0
  57. package/id/index.d.ts +25 -0
  58. package/id/index.mjs +56 -0
  59. package/index.cjs +218 -0
  60. package/index.d.ts +51 -0
  61. package/index.mjs +51 -0
  62. package/logger/index.cjs +334 -0
  63. package/logger/index.d.ts +25 -0
  64. package/logger/index.mjs +313 -0
  65. package/logger/logger.utils.d.ts +210 -0
  66. package/middleware/index.cjs +177 -0
  67. package/middleware/index.d.ts +25 -0
  68. package/middleware/index.mjs +170 -0
  69. package/middleware/middleware.utils.d.ts +123 -0
  70. package/obj/index.cjs +317 -0
  71. package/obj/index.d.ts +25 -0
  72. package/obj/index.mjs +301 -0
  73. package/obj/obj.utils.d.ts +156 -0
  74. package/package.json +172 -20
  75. package/performance/index.cjs +231 -0
  76. package/performance/index.d.ts +25 -0
  77. package/performance/index.mjs +225 -0
  78. package/performance/performance.utils.d.ts +159 -0
  79. package/request/index.cjs +202 -0
  80. package/request/index.d.ts +26 -0
  81. package/request/index.mjs +194 -0
  82. package/request/request.utils.d.ts +109 -0
  83. package/response/index.cjs +234 -0
  84. package/response/index.d.ts +26 -0
  85. package/response/index.mjs +222 -0
  86. package/response/response.utils.d.ts +186 -0
  87. package/server/index.cjs +1627 -0
  88. package/server/index.d.ts +28 -0
  89. package/server/index.mjs +1617 -0
  90. package/server/server.builder.d.ts +531 -0
  91. package/server/server.d.ts +303 -0
  92. package/stream/index.cjs +151 -0
  93. package/stream/index.d.ts +25 -0
  94. package/stream/index.mjs +144 -0
  95. package/stream/stream.utils.d.ts +111 -0
  96. package/string/index.cjs +109 -0
  97. package/string/index.d.ts +25 -0
  98. package/string/index.mjs +95 -0
  99. package/string/string.utils.d.ts +124 -0
  100. package/type/index.cjs +129 -0
  101. package/type/index.d.ts +25 -0
  102. package/type/index.mjs +119 -0
  103. package/type/type.utils.d.ts +129 -0
  104. package/types/api-response.d.ts +175 -0
  105. package/types/common.d.ts +148 -0
  106. package/types/config.d.ts +88 -0
  107. package/types/index.cjs +34 -0
  108. package/types/index.d.ts +28 -0
  109. package/types/index.mjs +32 -0
  110. package/types/server.d.ts +291 -0
  111. package/url/index.cjs +201 -0
  112. package/url/index.d.ts +25 -0
  113. package/url/index.mjs +189 -0
  114. package/url/url.utils.d.ts +164 -0
  115. package/validate/index.cjs +212 -0
  116. package/validate/index.d.ts +25 -0
  117. package/validate/index.mjs +188 -0
  118. package/validate/validate.utils.d.ts +200 -0
  119. package/build/index.cjs +0 -7579
  120. package/build/index.d.ts +0 -5774
  121. package/build/index.mjs +0 -7274
package/type/index.mjs ADDED
@@ -0,0 +1,119 @@
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
+ var __defProp = Object.defineProperty;
26
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
27
+
28
+ // src/type/type.utils.ts
29
+ function isPrimitiveType(value, type) {
30
+ if (type === "array") {
31
+ return Array.isArray(value);
32
+ }
33
+ if (type === "null") {
34
+ return value === null;
35
+ }
36
+ if (type === "undefined") {
37
+ return value === void 0;
38
+ }
39
+ if (type === "object") {
40
+ return typeof value === "object" && value !== null && !Array.isArray(value);
41
+ }
42
+ return typeof value === type;
43
+ }
44
+ __name(isPrimitiveType, "isPrimitiveType");
45
+ function getTypeOf(value) {
46
+ if (value === null) return "null";
47
+ if (value === void 0) return "undefined";
48
+ if (Array.isArray(value)) return "array";
49
+ return typeof value;
50
+ }
51
+ __name(getTypeOf, "getTypeOf");
52
+ function isArrayOf(value, itemTypeGuard) {
53
+ if (!Array.isArray(value)) return false;
54
+ return value.every((item) => itemTypeGuard(item));
55
+ }
56
+ __name(isArrayOf, "isArrayOf");
57
+ function toStr(value, defaultValue = "") {
58
+ if (value === null || value === void 0) return defaultValue;
59
+ try {
60
+ if (typeof value === "object") {
61
+ return JSON.stringify(value);
62
+ }
63
+ return String(value);
64
+ } catch {
65
+ return defaultValue;
66
+ }
67
+ }
68
+ __name(toStr, "toStr");
69
+ function toNum(value, defaultValue = 0) {
70
+ if (value === null || value === void 0) return defaultValue;
71
+ if (typeof value === "number") return value;
72
+ try {
73
+ const num = Number(value);
74
+ return isNaN(num) ? defaultValue : num;
75
+ } catch {
76
+ return defaultValue;
77
+ }
78
+ }
79
+ __name(toNum, "toNum");
80
+ function toBool(value, defaultValue = false) {
81
+ if (value === null || value === void 0) return defaultValue;
82
+ if (typeof value === "boolean") return value;
83
+ if (typeof value === "string") {
84
+ const lowercased = value.toLowerCase();
85
+ if (lowercased === "true" || lowercased === "yes" || lowercased === "y" || lowercased === "1") {
86
+ return true;
87
+ }
88
+ if (lowercased === "false" || lowercased === "no" || lowercased === "n" || lowercased === "0") {
89
+ return false;
90
+ }
91
+ }
92
+ if (typeof value === "number") {
93
+ return value !== 0;
94
+ }
95
+ return defaultValue;
96
+ }
97
+ __name(toBool, "toBool");
98
+ function ensureType(value, expectedType, defaultValue) {
99
+ if (getTypeOf(value) === expectedType) {
100
+ return value;
101
+ }
102
+ return defaultValue;
103
+ }
104
+ __name(ensureType, "ensureType");
105
+ function isDefined(value) {
106
+ return value !== null && value !== void 0;
107
+ }
108
+ __name(isDefined, "isDefined");
109
+ function isEmpty(value) {
110
+ if (value == null) return true;
111
+ if (typeof value === "string") return value.trim().length === 0;
112
+ if (Array.isArray(value)) return value.length === 0;
113
+ if (value instanceof Map || value instanceof Set) return value.size === 0;
114
+ if (typeof value === "object") return Object.keys(value).length === 0;
115
+ return false;
116
+ }
117
+ __name(isEmpty, "isEmpty");
118
+
119
+ export { ensureType, getTypeOf, isArrayOf, isDefined, isEmpty, isPrimitiveType, toBool, toNum, toStr };
@@ -0,0 +1,129 @@
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
+ * Check if a value is of a specific primitive type.
27
+ *
28
+ * @param value - Value to check
29
+ * @param type - Type to check against
30
+ * @returns Whether the value is of the specified type
31
+ *
32
+ * @example
33
+ * ```typescript
34
+ * isPrimitiveType('hello', 'string'); // true
35
+ * isPrimitiveType(42, 'number'); // true
36
+ * isPrimitiveType(true, 'boolean'); // true
37
+ * isPrimitiveType(null, 'null'); // true
38
+ * isPrimitiveType(undefined, 'undefined'); // true
39
+ * isPrimitiveType({}, 'object'); // true
40
+ * isPrimitiveType([], 'array'); // true
41
+ * ```
42
+ */
43
+ export declare function isPrimitiveType(value: unknown, type: 'string' | 'number' | 'boolean' | 'symbol' | 'bigint' | 'function' | 'object' | 'array' | 'null' | 'undefined'): boolean;
44
+ /**
45
+ * Get the primitive type of a value as a string.
46
+ *
47
+ * @param value - Value to get the type of
48
+ * @returns String representing the type
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * getTypeOf('hello'); // 'string'
53
+ * getTypeOf(42); // 'number'
54
+ * getTypeOf([]); // 'array'
55
+ * getTypeOf(null); // 'null'
56
+ * ```
57
+ */
58
+ export declare function getTypeOf(value: unknown): string;
59
+ /**
60
+ * Type guard for checking if a value is an array of a specific type.
61
+ *
62
+ * @param value - Value to check
63
+ * @param itemTypeGuard - Function that checks if items are of the expected type
64
+ * @returns True if the value is an array with items of the expected type
65
+ *
66
+ * @example
67
+ * ```typescript
68
+ * isArrayOf([1, 2, 3], (item): item is number => typeof item === 'number'); // true
69
+ * isArrayOf(['a', 'b', 'c'], (item): item is string => typeof item === 'string'); // true
70
+ * isArrayOf([1, '2', 3], (item): item is number => typeof item === 'number'); // false
71
+ * ```
72
+ */
73
+ export declare function isArrayOf<T>(value: unknown, itemTypeGuard: (item: unknown) => item is T): value is T[];
74
+ /**
75
+ * Convert a value to a string.
76
+ *
77
+ * @param value - Value to convert
78
+ * @param defaultValue - Default value if conversion fails
79
+ * @returns String representation of the value
80
+ */
81
+ export declare function toStr(value: unknown, defaultValue?: string): string;
82
+ /**
83
+ * Convert a value to a number.
84
+ *
85
+ * @param value - Value to convert
86
+ * @param defaultValue - Default value if conversion fails
87
+ * @returns Numeric representation of the value
88
+ */
89
+ export declare function toNum(value: unknown, defaultValue?: number): number;
90
+ /**
91
+ * Convert a value to a boolean.
92
+ *
93
+ * @param value - Value to convert
94
+ * @param defaultValue - Default value if conversion fails
95
+ * @returns Boolean representation of the value
96
+ */
97
+ export declare function toBool(value: unknown, defaultValue?: boolean): boolean;
98
+ /**
99
+ * Ensure a value matches the expected type, or provide a default.
100
+ *
101
+ * @param value - Value to check
102
+ * @param expectedType - Expected primitive type
103
+ * @param defaultValue - Default value to use if type doesn't match
104
+ * @returns The value if it matches the type, otherwise the default
105
+ *
106
+ * @example
107
+ * ```typescript
108
+ * ensureType(42, 'number', 0); // 42
109
+ * ensureType('42', 'number', 0); // 0
110
+ * ensureType(undefined, 'string', 'default'); // 'default'
111
+ * ```
112
+ */
113
+ export declare function ensureType<T>(value: unknown, expectedType: string, defaultValue: T): T;
114
+ /**
115
+ * Check whether a value is neither null nor undefined.
116
+ * Useful in filter chains and guards.
117
+ *
118
+ * @param value - Value to check
119
+ * @returns True when value !== null && value !== undefined
120
+ */
121
+ export declare function isDefined<T>(value: T | null | undefined): value is T;
122
+ /**
123
+ * Check whether a value is empty.
124
+ * Supports strings, arrays, maps, sets and plain objects.
125
+ *
126
+ * @param value - Value to inspect
127
+ * @returns True when value is considered empty
128
+ */
129
+ export declare function isEmpty(value: any): boolean;
@@ -0,0 +1,175 @@
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
+ * Generic API response format.
27
+ * Used to wrap any successful or failed response from the server.
28
+ */
29
+ export interface ApiResponse<T = any> {
30
+ /** Payload returned from the API. Can be any shape depending on the endpoint. */
31
+ data: T | null;
32
+ /** Indicates whether an error occurred (true = error, false = success). */
33
+ error: boolean;
34
+ /** Success message describing the result of the operation. */
35
+ message: string;
36
+ /** Unique request ID for traceability in logs (e.g., from a middleware). */
37
+ requestId: string;
38
+ /** ISO timestamp when the response was generated. */
39
+ timestamp: string;
40
+ }
41
+ /**
42
+ * Generic pagination structure used for paged lists (e.g., /users?page=1).
43
+ */
44
+ export interface Pagination<T = any> {
45
+ /** List of records for the current page. */
46
+ content: T[];
47
+ /** Metadata about the pagination state. */
48
+ pagination: {
49
+ /** Total number of records across all pages. */
50
+ totalRecords: number;
51
+ /** Total number of pages available. */
52
+ totalPages: number;
53
+ /** Current page number (1-based index). */
54
+ page: number;
55
+ /** Number of records per page. */
56
+ limit: number;
57
+ /** Field by which the data is sorted. */
58
+ sortBy: string;
59
+ /** Sort order: ascending or descending. */
60
+ sortOrder: 'asc' | 'desc';
61
+ };
62
+ }
63
+ /**
64
+ * Alias for paginated API response.
65
+ * Allows semantic naming like `PaginationResponse<User>` or `PaginationResponse<Post>`.
66
+ */
67
+ export type PaginationResponse<T = any> = Pagination<T>;
68
+ /**
69
+ * Error response structure with additional metadata.
70
+ * Used for providing richer error information to clients.
71
+ */
72
+ export interface ApiErrorResponse extends Omit<ApiResponse<never>, 'data'> {
73
+ /** Error always true for error responses */
74
+ error: true;
75
+ /** HTTP status code */
76
+ status: number;
77
+ /** Path to the resource that caused the error */
78
+ path: string;
79
+ /** Stack trace of the error (if available) */
80
+ stack?: string[];
81
+ }
82
+ /**
83
+ * Success response structure with strongly typed data.
84
+ * Used for providing successful responses to clients.
85
+ */
86
+ export interface ApiSuccessResponse<T = any> extends ApiResponse<T> {
87
+ /** Error always false for success responses */
88
+ error: false;
89
+ /** HTTP status code (usually 200) */
90
+ status?: number;
91
+ }
92
+ /**
93
+ * Response structure for batch operations.
94
+ * Used when multiple operations are performed in a single request.
95
+ */
96
+ export interface BatchResponse<T = any> {
97
+ /** Overall success/failure indicator */
98
+ success: boolean;
99
+ /** Total number of operations */
100
+ total: number;
101
+ /** Number of successful operations */
102
+ successful: number;
103
+ /** Number of failed operations */
104
+ failed: number;
105
+ /** Results of individual operations */
106
+ results: Array<{
107
+ /** Identifier for this operation */
108
+ id: string | number;
109
+ /** Success/failure indicator for this operation */
110
+ success: boolean;
111
+ /** Response data for this operation */
112
+ data?: T;
113
+ /** Error information if this operation failed */
114
+ error?: {
115
+ message: string;
116
+ code?: string;
117
+ };
118
+ }>;
119
+ }
120
+ /**
121
+ * Response structure for asynchronous operations.
122
+ * Used when the operation will complete in the future.
123
+ */
124
+ export interface AsyncOperationResponse {
125
+ /** Always true for async operations */
126
+ async: true;
127
+ /** Job or task ID to check status later */
128
+ jobId: string;
129
+ /** Estimated completion time in seconds (if known) */
130
+ estimatedTime?: number;
131
+ /** URL to check status */
132
+ statusUrl: string;
133
+ }
134
+ /**
135
+ * Response structure for streaming operations.
136
+ * Used when data is returned as a stream rather than all at once.
137
+ */
138
+ export interface StreamResponse {
139
+ /** Stream identifier */
140
+ streamId: string;
141
+ /** Stream type (e.g., 'json', 'binary') */
142
+ streamType: string;
143
+ /** Total size in bytes (if known) */
144
+ totalSize?: number;
145
+ /** Chunk size in bytes */
146
+ chunkSize: number;
147
+ }
148
+ /**
149
+ * Sort direction enumeration.
150
+ */
151
+ export declare enum SortDirection {
152
+ /** Ascending sort order */
153
+ ASC = "asc",
154
+ /** Descending sort order */
155
+ DESC = "desc"
156
+ }
157
+ /**
158
+ * Pagination parameters for API requests.
159
+ */
160
+ export interface PaginationParams {
161
+ /** Current page number (1-based index) */
162
+ page: number;
163
+ /** Number of records per page */
164
+ limit: number;
165
+ /** Field by which the data is sorted */
166
+ sortBy: string;
167
+ /** Sort order: ascending or descending */
168
+ sortOrder: SortDirection;
169
+ /** Optional search query */
170
+ search?: string;
171
+ }
172
+ /**
173
+ * Type that combines pagination parameters with additional data.
174
+ */
175
+ export type WithPagination<T = {}> = PaginationParams & T;
@@ -0,0 +1,148 @@
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
+ * A type that represents a configurable toggle.
27
+ * Can be `true`, `false`, or a custom configuration object `T`.
28
+ */
29
+ export type ToggleConfig<T> = boolean | T;
30
+ /**
31
+ * A type representing a value that can be `null` or `undefined`.
32
+ */
33
+ export type Nullable<T> = T | null | undefined;
34
+ /**
35
+ * A type representing a value that may or may not be present.
36
+ */
37
+ export type Optional<T> = T | undefined;
38
+ /**
39
+ * A type that makes all properties of `T` deeply optional.
40
+ */
41
+ export type DeepPartial<T> = {
42
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
43
+ };
44
+ /**
45
+ * A type that makes all properties of `T` readonly, recursively.
46
+ */
47
+ export type DeepReadonly<T> = {
48
+ readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
49
+ };
50
+ /**
51
+ * A type that converts a union of types into an intersection.
52
+ */
53
+ export type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
54
+ /**
55
+ * A type representing a promise or a plain value.
56
+ */
57
+ export type MaybePromise<T> = T | Promise<T>;
58
+ /**
59
+ * A type representing a record with string keys and values of type `T`.
60
+ */
61
+ export type StringKeyedRecord<T> = Record<string, T>;
62
+ /**
63
+ * A type representing a function that returns `R` and optionally receives arguments `A`.
64
+ */
65
+ export type Func<A extends any[] = any[], R = any> = (...args: A) => R;
66
+ /**
67
+ * A type representing a partial pick from `T` (like Partial + Pick combined)
68
+ */
69
+ export type PartialPick<T, K extends keyof T> = Partial<Pick<T, K>> & Omit<T, K>;
70
+ /**
71
+ * A type that deeply stringifies all properties of T or makes them null.
72
+ */
73
+ export type DeepStringifyOrNull<T> = T extends string | number | boolean | bigint | boolean | symbol | null | undefined | null ? string | null : T extends Array<infer U> ? Array<DeepStringifyOrNull<U>> : T extends object ? {
74
+ [K in keyof T]: DeepStringifyOrNull<T[K]>;
75
+ } : string | null;
76
+ /**
77
+ * A type representing a non-empty array of T.
78
+ */
79
+ export type NonEmptyArray<T> = [T, ...T[]];
80
+ /**
81
+ * A type representing the union of all property values of T.
82
+ */
83
+ export type ValueOf<T> = T[keyof T];
84
+ /**
85
+ * A type that makes all properties of T mutable (removes readonly).
86
+ */
87
+ export type Mutable<T> = {
88
+ -readonly [P in keyof T]: T[P];
89
+ };
90
+ /**
91
+ * A type that gets the keys of T whose values are assignable to U.
92
+ */
93
+ export type KeysOfType<T, U> = {
94
+ [K in keyof T]: T[K] extends U ? K : never;
95
+ }[keyof T];
96
+ /**
97
+ * Require at least one of the keys in K to be present in T.
98
+ */
99
+ export type RequireAtLeastOne<T, K extends keyof T = keyof T> = K extends keyof T ? {
100
+ [P in K]-?: T[P];
101
+ } & Omit<T, K> : never;
102
+ /**
103
+ * A record type with optional keys.
104
+ */
105
+ export type RecordOptional<K extends string | number | symbol, T> = {
106
+ [P in K]?: T;
107
+ };
108
+ /**
109
+ * Primitive types in TypeScript.
110
+ */
111
+ export type Primitive = string | number | boolean | bigint | symbol | undefined | null;
112
+ /**
113
+ * Recursively unwraps Promise types to get their resolved value type.
114
+ */
115
+ export type Awaited<T> = T extends Promise<infer U> ? Awaited<U> : T;
116
+ /**
117
+ * Picks properties from T that are of type U.
118
+ */
119
+ export type PickByType<T, U> = {
120
+ [P in keyof T as T[P] extends U ? P : never]: T[P];
121
+ };
122
+ /**
123
+ * Makes all properties of T required recursively.
124
+ */
125
+ export type DeepRequired<T> = {
126
+ [P in keyof T]-?: T[P] extends object ? DeepRequired<T[P]> : T[P];
127
+ };
128
+ /**
129
+ * Checks if two types are exactly equal.
130
+ * Returns true or false as type.
131
+ */
132
+ export type IsEqual<T, U> = (<G>() => G extends T ? 1 : 2) extends <G>() => G extends U ? 1 : 2 ? true : false;
133
+ /**
134
+ * Makes all properties of an object writable (removes readonly).
135
+ */
136
+ export type Writable<T> = {
137
+ -readonly [P in keyof T]: T[P];
138
+ };
139
+ /**
140
+ * Makes specific keys K of type T optional.
141
+ */
142
+ export type Optional2<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
143
+ /**
144
+ * Creates a type with all properties of T except those with types assignable to U.
145
+ */
146
+ export type Without<T, U> = {
147
+ [P in keyof T as T[P] extends U ? never : P]: T[P];
148
+ };
@@ -0,0 +1,88 @@
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 { LoggerLevels } from '@catbee/utils/logger';
26
+ export interface CatbeeConfig {
27
+ logger?: {
28
+ /**
29
+ * Logging level (e.g., 'info', 'debug', 'warn', 'error')
30
+ * Environment variable: LOGGER_LEVEL
31
+ * Default: 'info' in production, 'debug' in development
32
+ */
33
+ level?: LoggerLevels;
34
+ /**
35
+ * Name of the logger instance (defaults to npm package name)
36
+ * Environment variable: LOGGER_NAME
37
+ * Default: value of npm_package_name or '@catbee/utils'
38
+ */
39
+ name?: string;
40
+ /**
41
+ * Enables pretty-print logging in development.
42
+ * Has no effect in production.
43
+ * Environment variable: LOGGER_PRETTY
44
+ * Default: true in development, false in production
45
+ */
46
+ pretty?: boolean;
47
+ /**
48
+ * Enables colorized output for pretty-print (default: true)
49
+ * Environment variable: LOGGER_PRETTY_COLORIZE
50
+ */
51
+ colorize?: boolean;
52
+ /**
53
+ * Single line output for pretty-print (default: false)
54
+ * Environment variable: LOGGER_PRETTY_SINGLE_LINE
55
+ */
56
+ singleLine?: boolean;
57
+ /**
58
+ * Directory to write log files to (if empty, file logging is disabled)
59
+ * Environment variable: LOGGER_DIR
60
+ * Eg: process.cwd() + '/logs'
61
+ * Note: Directory must exist, it is not created automatically
62
+ */
63
+ dir?: string;
64
+ };
65
+ cache: {
66
+ /**
67
+ * Default TTL (time to live) for cache entries in milliseconds
68
+ * Environment variable: CACHE_DEFAULT_TTL_SECONDS
69
+ * Default: 3600000 (1 hour)
70
+ */
71
+ defaultTtl: number;
72
+ };
73
+ server: {
74
+ /**
75
+ * Skip healthz endpoint even if health checks are configured
76
+ * Default: false
77
+ * Set to true to return 200 OK for /healthz without checks
78
+ * Useful in environments where a simple liveness probe is needed
79
+ * without performing actual health checks
80
+ * Example: Kubernetes liveness probe
81
+ * Note: This does not disable the health check functionality itself
82
+ * Health checks can still be performed programmatically
83
+ * or via other endpoints if needed
84
+ * Environment variable: SERVER_SKIP_HEALTHZ
85
+ */
86
+ skipHealthz: boolean;
87
+ };
88
+ }
@@ -0,0 +1,34 @@
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
+ 'use strict';
26
+
27
+ // src/types/api-response.ts
28
+ var SortDirection = /* @__PURE__ */ (function(SortDirection2) {
29
+ SortDirection2["ASC"] = "asc";
30
+ SortDirection2["DESC"] = "desc";
31
+ return SortDirection2;
32
+ })({});
33
+
34
+ exports.SortDirection = SortDirection;