@asaidimu/utils-error 1.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.md +21 -0
- package/README.md +3 -0
- package/index.d.mts +286 -0
- package/index.d.ts +286 -0
- package/index.js +1 -0
- package/index.mjs +1 -0
- package/package.json +63 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Saidimu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
package/index.d.mts
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Severity levels for structured issues and errors.
|
|
3
|
+
*/
|
|
4
|
+
type Severity = "error" | "warning" | "info";
|
|
5
|
+
/**
|
|
6
|
+
* Represents a detailed validation or operational problem.
|
|
7
|
+
* Designed to be machine-readable while remaining human-friendly.
|
|
8
|
+
*/
|
|
9
|
+
interface Issue {
|
|
10
|
+
/** Machine-readable identifier (e.g., "REQUIRED_FIELD_MISSING"). */
|
|
11
|
+
readonly code: string;
|
|
12
|
+
/** Human-readable description of the problem. */
|
|
13
|
+
readonly message: string;
|
|
14
|
+
/** Field path in a document or state (e.g., "users.0.email"). */
|
|
15
|
+
readonly path?: string;
|
|
16
|
+
/** Optional array index when the issue relates to a specific element. */
|
|
17
|
+
readonly index?: number;
|
|
18
|
+
/** Seriousness of the issue. Defaults to "error". */
|
|
19
|
+
readonly severity?: Severity;
|
|
20
|
+
/** Optional detailed explanation, can be multi-line. */
|
|
21
|
+
readonly description?: string;
|
|
22
|
+
/** Nested issues that caused this one. */
|
|
23
|
+
readonly cause?: readonly Issue[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Standardized error code format: CATEGORY-XXX[-SUFFIX]
|
|
27
|
+
* Examples:
|
|
28
|
+
* - VAL-001 (Validation: required field missing)
|
|
29
|
+
* - DB-002-NF (Database: not found)
|
|
30
|
+
* - AUTH-003-DENIED (Auth: permission denied)
|
|
31
|
+
*/
|
|
32
|
+
interface ErrorCodeMetadata {
|
|
33
|
+
/** The formal error code (e.g., "VAL-001") */
|
|
34
|
+
readonly code: string;
|
|
35
|
+
/** Human-readable name for the error type */
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/** Detailed description of when this error occurs */
|
|
38
|
+
readonly description: string;
|
|
39
|
+
/** Suggested action for handling or resolving the error */
|
|
40
|
+
readonly action?: string;
|
|
41
|
+
/** HTTP status code mapping (if applicable) */
|
|
42
|
+
readonly httpStatus?: number;
|
|
43
|
+
/** Category of the error */
|
|
44
|
+
readonly category: ErrorCategory;
|
|
45
|
+
/** Whether this error should be logged as warning vs error */
|
|
46
|
+
readonly logLevel?: "debug" | "info" | "warn" | "error";
|
|
47
|
+
}
|
|
48
|
+
type ErrorCategory = "validation" | "database" | "auth" | "business" | "system" | "network" | "concurrency" | "custom";
|
|
49
|
+
/**
|
|
50
|
+
* Central registry of built-in error codes.
|
|
51
|
+
*/
|
|
52
|
+
declare const ErrorCodes: {
|
|
53
|
+
readonly VALIDATION_FAILED: {
|
|
54
|
+
readonly code: "VAL-001";
|
|
55
|
+
readonly name: "VALIDATION_FAILED";
|
|
56
|
+
readonly description: "Input validation failed due to one or more invalid fields";
|
|
57
|
+
readonly category: "validation";
|
|
58
|
+
readonly httpStatus: 400;
|
|
59
|
+
readonly logLevel: "warn";
|
|
60
|
+
};
|
|
61
|
+
readonly REQUIRED_FIELD_MISSING: {
|
|
62
|
+
readonly code: "VAL-002";
|
|
63
|
+
readonly name: "REQUIRED_FIELD_MISSING";
|
|
64
|
+
readonly description: "A required field was not provided in the request";
|
|
65
|
+
readonly category: "validation";
|
|
66
|
+
readonly httpStatus: 400;
|
|
67
|
+
readonly logLevel: "warn";
|
|
68
|
+
};
|
|
69
|
+
readonly INVALID_FORMAT: {
|
|
70
|
+
readonly code: "VAL-003";
|
|
71
|
+
readonly name: "INVALID_FORMAT";
|
|
72
|
+
readonly description: "Field value does not match expected format";
|
|
73
|
+
readonly category: "validation";
|
|
74
|
+
readonly httpStatus: 400;
|
|
75
|
+
readonly logLevel: "warn";
|
|
76
|
+
};
|
|
77
|
+
readonly NOT_FOUND: {
|
|
78
|
+
readonly code: "DB-001-NF";
|
|
79
|
+
readonly name: "NOT_FOUND";
|
|
80
|
+
readonly description: "The requested resource could not be found";
|
|
81
|
+
readonly category: "database";
|
|
82
|
+
readonly httpStatus: 404;
|
|
83
|
+
readonly logLevel: "info";
|
|
84
|
+
readonly action: "Verify the resource identifier exists before accessing";
|
|
85
|
+
};
|
|
86
|
+
readonly DUPLICATE_KEY: {
|
|
87
|
+
readonly code: "DB-002-DUP";
|
|
88
|
+
readonly name: "DUPLICATE_KEY";
|
|
89
|
+
readonly description: "A unique constraint violation occurred";
|
|
90
|
+
readonly category: "database";
|
|
91
|
+
readonly httpStatus: 409;
|
|
92
|
+
readonly logLevel: "warn";
|
|
93
|
+
readonly action: "Check if the resource already exists before creation";
|
|
94
|
+
};
|
|
95
|
+
readonly RESOURCE_LOCKED: {
|
|
96
|
+
readonly code: "DB-003-LOCK";
|
|
97
|
+
readonly name: "RESOURCE_LOCKED";
|
|
98
|
+
readonly description: "The resource is currently locked by another operation";
|
|
99
|
+
readonly category: "database";
|
|
100
|
+
readonly httpStatus: 409;
|
|
101
|
+
readonly logLevel: "warn";
|
|
102
|
+
readonly action: "Retry the operation after a brief delay";
|
|
103
|
+
};
|
|
104
|
+
readonly PERMISSION_DENIED: {
|
|
105
|
+
readonly code: "AUTH-001-DENIED";
|
|
106
|
+
readonly name: "PERMISSION_DENIED";
|
|
107
|
+
readonly description: "The authenticated user lacks permission for this operation";
|
|
108
|
+
readonly category: "auth";
|
|
109
|
+
readonly httpStatus: 403;
|
|
110
|
+
readonly logLevel: "warn";
|
|
111
|
+
readonly action: "Check user roles and permissions";
|
|
112
|
+
};
|
|
113
|
+
readonly UNAUTHENTICATED: {
|
|
114
|
+
readonly code: "AUTH-002-UNAUTH";
|
|
115
|
+
readonly name: "UNAUTHENTICATED";
|
|
116
|
+
readonly description: "Authentication is required for this operation";
|
|
117
|
+
readonly category: "auth";
|
|
118
|
+
readonly httpStatus: 401;
|
|
119
|
+
readonly logLevel: "info";
|
|
120
|
+
readonly action: "Provide valid authentication credentials";
|
|
121
|
+
};
|
|
122
|
+
readonly INVALID_COMMAND: {
|
|
123
|
+
readonly code: "BUS-001";
|
|
124
|
+
readonly name: "INVALID_COMMAND";
|
|
125
|
+
readonly description: "The command or operation is invalid for the current state";
|
|
126
|
+
readonly category: "business";
|
|
127
|
+
readonly httpStatus: 400;
|
|
128
|
+
readonly logLevel: "warn";
|
|
129
|
+
};
|
|
130
|
+
readonly OPERATION_ABORTED: {
|
|
131
|
+
readonly code: "BUS-002-ABORT";
|
|
132
|
+
readonly name: "OPERATION_ABORTED";
|
|
133
|
+
readonly description: "The operation was explicitly aborted";
|
|
134
|
+
readonly category: "business";
|
|
135
|
+
readonly httpStatus: 409;
|
|
136
|
+
readonly logLevel: "info";
|
|
137
|
+
};
|
|
138
|
+
readonly INTERNAL_ERROR: {
|
|
139
|
+
readonly code: "SYS-001";
|
|
140
|
+
readonly name: "INTERNAL_ERROR";
|
|
141
|
+
readonly description: "An unexpected internal error occurred";
|
|
142
|
+
readonly category: "system";
|
|
143
|
+
readonly httpStatus: 500;
|
|
144
|
+
readonly logLevel: "error";
|
|
145
|
+
readonly action: "Check system logs for stack traces and diagnostic information";
|
|
146
|
+
};
|
|
147
|
+
readonly BACKEND_ERROR: {
|
|
148
|
+
readonly code: "SYS-002";
|
|
149
|
+
readonly name: "BACKEND_ERROR";
|
|
150
|
+
readonly description: "An error occurred in a backend service";
|
|
151
|
+
readonly category: "system";
|
|
152
|
+
readonly httpStatus: 502;
|
|
153
|
+
readonly logLevel: "error";
|
|
154
|
+
};
|
|
155
|
+
readonly CONCURRENCY_ERROR: {
|
|
156
|
+
readonly code: "CON-001";
|
|
157
|
+
readonly name: "CONCURRENCY_ERROR";
|
|
158
|
+
readonly description: "A concurrency conflict occurred during the operation";
|
|
159
|
+
readonly category: "concurrency";
|
|
160
|
+
readonly httpStatus: 409;
|
|
161
|
+
readonly logLevel: "warn";
|
|
162
|
+
readonly action: "Retry the operation with updated data";
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Register a custom error code at runtime.
|
|
167
|
+
* @throws if code already exists as a built-in error
|
|
168
|
+
*/
|
|
169
|
+
declare function registerErrorCode(metadata: ErrorCodeMetadata): void;
|
|
170
|
+
/**
|
|
171
|
+
* Get metadata for any error code (built-in or custom).
|
|
172
|
+
* Returns default metadata for unknown codes instead of throwing.
|
|
173
|
+
*/
|
|
174
|
+
declare function getErrorMetadata(code: string): ErrorCodeMetadata;
|
|
175
|
+
/**
|
|
176
|
+
* Check if an error code is known (built-in or registered custom).
|
|
177
|
+
*/
|
|
178
|
+
declare function isKnownErrorCode(code: string): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* SystemError is the primary error type for all operational and validation errors.
|
|
181
|
+
* Supports both predefined and custom error codes with full metadata.
|
|
182
|
+
*/
|
|
183
|
+
declare class SystemError extends Error {
|
|
184
|
+
readonly code: string;
|
|
185
|
+
readonly codeMetadata: ErrorCodeMetadata;
|
|
186
|
+
readonly severity: Severity;
|
|
187
|
+
readonly path?: string;
|
|
188
|
+
readonly operation?: string;
|
|
189
|
+
readonly issues: readonly Issue[];
|
|
190
|
+
readonly cause?: unknown;
|
|
191
|
+
constructor(params: {
|
|
192
|
+
code: string;
|
|
193
|
+
message?: string;
|
|
194
|
+
severity?: Severity;
|
|
195
|
+
path?: string;
|
|
196
|
+
operation?: string;
|
|
197
|
+
issues?: readonly Issue[];
|
|
198
|
+
cause?: unknown;
|
|
199
|
+
metadata?: Partial<Omit<ErrorCodeMetadata, "code">>;
|
|
200
|
+
});
|
|
201
|
+
/**
|
|
202
|
+
* Returns a new SystemError with the specified path.
|
|
203
|
+
*/
|
|
204
|
+
withPath(path: string): SystemError;
|
|
205
|
+
/**
|
|
206
|
+
* Returns a new SystemError with the specified operation name.
|
|
207
|
+
*/
|
|
208
|
+
withOperation(operation: string): SystemError;
|
|
209
|
+
/**
|
|
210
|
+
* Returns a new SystemError with the specified issue appended.
|
|
211
|
+
*/
|
|
212
|
+
withIssue(issue: Issue): SystemError;
|
|
213
|
+
/**
|
|
214
|
+
* Returns a new SystemError with multiple issues appended.
|
|
215
|
+
*/
|
|
216
|
+
withIssues(issues: readonly Issue[]): SystemError;
|
|
217
|
+
/**
|
|
218
|
+
* Returns a new SystemError wrapping the specified cause.
|
|
219
|
+
*/
|
|
220
|
+
withCause(cause: unknown): SystemError;
|
|
221
|
+
/**
|
|
222
|
+
* Returns the HTTP status code for this error (if applicable).
|
|
223
|
+
*/
|
|
224
|
+
getHttpStatus(): number | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Formats the error for logging with structured metadata.
|
|
227
|
+
*/
|
|
228
|
+
toLogEntry(): Record<string, unknown>;
|
|
229
|
+
/**
|
|
230
|
+
* Produces a human-readable representation suitable for logging.
|
|
231
|
+
*/
|
|
232
|
+
toString(): string;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Factory for creating a new SystemError with automatic metadata.
|
|
236
|
+
*/
|
|
237
|
+
declare function createError(code: string, message?: string): SystemError;
|
|
238
|
+
/**
|
|
239
|
+
* Helper for quick ad-hoc errors (useful for testing or prototyping).
|
|
240
|
+
*/
|
|
241
|
+
declare function error(code: string, message?: string): SystemError;
|
|
242
|
+
/**
|
|
243
|
+
* Predefined error codes for common scenarios (backward compatibility).
|
|
244
|
+
*/
|
|
245
|
+
declare const CommonErrors: {
|
|
246
|
+
readonly NOT_FOUND: "DB-001-NF";
|
|
247
|
+
readonly DUPLICATE_KEY: "DB-002-DUP";
|
|
248
|
+
readonly INVALID_COMMAND: "BUS-001";
|
|
249
|
+
readonly PERMISSION_DENIED: "AUTH-001-DENIED";
|
|
250
|
+
readonly BACKEND_ERROR: "SYS-002";
|
|
251
|
+
readonly INTERNAL_ERROR: "SYS-001";
|
|
252
|
+
readonly VALIDATION_FAILED: "VAL-001";
|
|
253
|
+
readonly CONCURRENCY_ERROR: "CON-001";
|
|
254
|
+
readonly RESOURCE_LOCKED: "DB-003-LOCK";
|
|
255
|
+
readonly OPERATION_ABORTED: "BUS-002-ABORT";
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Convenience factory functions for common errors.
|
|
259
|
+
*/
|
|
260
|
+
declare const Errors: {
|
|
261
|
+
notFound: (path?: string, message?: string) => SystemError;
|
|
262
|
+
duplicateKey: (path?: string, message?: string) => SystemError;
|
|
263
|
+
permissionDenied: (operation?: string, message?: string) => SystemError;
|
|
264
|
+
validationFailed: (issues: Issue[], path?: string) => SystemError;
|
|
265
|
+
internalError: (cause?: unknown, message?: string) => SystemError;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* A functional wrapper for operations that can fail.
|
|
269
|
+
* Encourages explicit error handling over try/catch blocks.
|
|
270
|
+
*/
|
|
271
|
+
type Result<T, E = SystemError> = {
|
|
272
|
+
readonly ok: true;
|
|
273
|
+
readonly value: T;
|
|
274
|
+
} | {
|
|
275
|
+
readonly ok: false;
|
|
276
|
+
readonly error: E;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Type-safe helpers for creating Results.
|
|
280
|
+
*/
|
|
281
|
+
declare const Result: {
|
|
282
|
+
ok: <T>(value: T) => Result<T, never>;
|
|
283
|
+
fail: <E>(error: E) => Result<never, E>;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export { CommonErrors, type ErrorCategory, type ErrorCodeMetadata, ErrorCodes, Errors, type Issue, Result, type Severity, SystemError, createError, error, getErrorMetadata, isKnownErrorCode, registerErrorCode };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Severity levels for structured issues and errors.
|
|
3
|
+
*/
|
|
4
|
+
type Severity = "error" | "warning" | "info";
|
|
5
|
+
/**
|
|
6
|
+
* Represents a detailed validation or operational problem.
|
|
7
|
+
* Designed to be machine-readable while remaining human-friendly.
|
|
8
|
+
*/
|
|
9
|
+
interface Issue {
|
|
10
|
+
/** Machine-readable identifier (e.g., "REQUIRED_FIELD_MISSING"). */
|
|
11
|
+
readonly code: string;
|
|
12
|
+
/** Human-readable description of the problem. */
|
|
13
|
+
readonly message: string;
|
|
14
|
+
/** Field path in a document or state (e.g., "users.0.email"). */
|
|
15
|
+
readonly path?: string;
|
|
16
|
+
/** Optional array index when the issue relates to a specific element. */
|
|
17
|
+
readonly index?: number;
|
|
18
|
+
/** Seriousness of the issue. Defaults to "error". */
|
|
19
|
+
readonly severity?: Severity;
|
|
20
|
+
/** Optional detailed explanation, can be multi-line. */
|
|
21
|
+
readonly description?: string;
|
|
22
|
+
/** Nested issues that caused this one. */
|
|
23
|
+
readonly cause?: readonly Issue[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Standardized error code format: CATEGORY-XXX[-SUFFIX]
|
|
27
|
+
* Examples:
|
|
28
|
+
* - VAL-001 (Validation: required field missing)
|
|
29
|
+
* - DB-002-NF (Database: not found)
|
|
30
|
+
* - AUTH-003-DENIED (Auth: permission denied)
|
|
31
|
+
*/
|
|
32
|
+
interface ErrorCodeMetadata {
|
|
33
|
+
/** The formal error code (e.g., "VAL-001") */
|
|
34
|
+
readonly code: string;
|
|
35
|
+
/** Human-readable name for the error type */
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/** Detailed description of when this error occurs */
|
|
38
|
+
readonly description: string;
|
|
39
|
+
/** Suggested action for handling or resolving the error */
|
|
40
|
+
readonly action?: string;
|
|
41
|
+
/** HTTP status code mapping (if applicable) */
|
|
42
|
+
readonly httpStatus?: number;
|
|
43
|
+
/** Category of the error */
|
|
44
|
+
readonly category: ErrorCategory;
|
|
45
|
+
/** Whether this error should be logged as warning vs error */
|
|
46
|
+
readonly logLevel?: "debug" | "info" | "warn" | "error";
|
|
47
|
+
}
|
|
48
|
+
type ErrorCategory = "validation" | "database" | "auth" | "business" | "system" | "network" | "concurrency" | "custom";
|
|
49
|
+
/**
|
|
50
|
+
* Central registry of built-in error codes.
|
|
51
|
+
*/
|
|
52
|
+
declare const ErrorCodes: {
|
|
53
|
+
readonly VALIDATION_FAILED: {
|
|
54
|
+
readonly code: "VAL-001";
|
|
55
|
+
readonly name: "VALIDATION_FAILED";
|
|
56
|
+
readonly description: "Input validation failed due to one or more invalid fields";
|
|
57
|
+
readonly category: "validation";
|
|
58
|
+
readonly httpStatus: 400;
|
|
59
|
+
readonly logLevel: "warn";
|
|
60
|
+
};
|
|
61
|
+
readonly REQUIRED_FIELD_MISSING: {
|
|
62
|
+
readonly code: "VAL-002";
|
|
63
|
+
readonly name: "REQUIRED_FIELD_MISSING";
|
|
64
|
+
readonly description: "A required field was not provided in the request";
|
|
65
|
+
readonly category: "validation";
|
|
66
|
+
readonly httpStatus: 400;
|
|
67
|
+
readonly logLevel: "warn";
|
|
68
|
+
};
|
|
69
|
+
readonly INVALID_FORMAT: {
|
|
70
|
+
readonly code: "VAL-003";
|
|
71
|
+
readonly name: "INVALID_FORMAT";
|
|
72
|
+
readonly description: "Field value does not match expected format";
|
|
73
|
+
readonly category: "validation";
|
|
74
|
+
readonly httpStatus: 400;
|
|
75
|
+
readonly logLevel: "warn";
|
|
76
|
+
};
|
|
77
|
+
readonly NOT_FOUND: {
|
|
78
|
+
readonly code: "DB-001-NF";
|
|
79
|
+
readonly name: "NOT_FOUND";
|
|
80
|
+
readonly description: "The requested resource could not be found";
|
|
81
|
+
readonly category: "database";
|
|
82
|
+
readonly httpStatus: 404;
|
|
83
|
+
readonly logLevel: "info";
|
|
84
|
+
readonly action: "Verify the resource identifier exists before accessing";
|
|
85
|
+
};
|
|
86
|
+
readonly DUPLICATE_KEY: {
|
|
87
|
+
readonly code: "DB-002-DUP";
|
|
88
|
+
readonly name: "DUPLICATE_KEY";
|
|
89
|
+
readonly description: "A unique constraint violation occurred";
|
|
90
|
+
readonly category: "database";
|
|
91
|
+
readonly httpStatus: 409;
|
|
92
|
+
readonly logLevel: "warn";
|
|
93
|
+
readonly action: "Check if the resource already exists before creation";
|
|
94
|
+
};
|
|
95
|
+
readonly RESOURCE_LOCKED: {
|
|
96
|
+
readonly code: "DB-003-LOCK";
|
|
97
|
+
readonly name: "RESOURCE_LOCKED";
|
|
98
|
+
readonly description: "The resource is currently locked by another operation";
|
|
99
|
+
readonly category: "database";
|
|
100
|
+
readonly httpStatus: 409;
|
|
101
|
+
readonly logLevel: "warn";
|
|
102
|
+
readonly action: "Retry the operation after a brief delay";
|
|
103
|
+
};
|
|
104
|
+
readonly PERMISSION_DENIED: {
|
|
105
|
+
readonly code: "AUTH-001-DENIED";
|
|
106
|
+
readonly name: "PERMISSION_DENIED";
|
|
107
|
+
readonly description: "The authenticated user lacks permission for this operation";
|
|
108
|
+
readonly category: "auth";
|
|
109
|
+
readonly httpStatus: 403;
|
|
110
|
+
readonly logLevel: "warn";
|
|
111
|
+
readonly action: "Check user roles and permissions";
|
|
112
|
+
};
|
|
113
|
+
readonly UNAUTHENTICATED: {
|
|
114
|
+
readonly code: "AUTH-002-UNAUTH";
|
|
115
|
+
readonly name: "UNAUTHENTICATED";
|
|
116
|
+
readonly description: "Authentication is required for this operation";
|
|
117
|
+
readonly category: "auth";
|
|
118
|
+
readonly httpStatus: 401;
|
|
119
|
+
readonly logLevel: "info";
|
|
120
|
+
readonly action: "Provide valid authentication credentials";
|
|
121
|
+
};
|
|
122
|
+
readonly INVALID_COMMAND: {
|
|
123
|
+
readonly code: "BUS-001";
|
|
124
|
+
readonly name: "INVALID_COMMAND";
|
|
125
|
+
readonly description: "The command or operation is invalid for the current state";
|
|
126
|
+
readonly category: "business";
|
|
127
|
+
readonly httpStatus: 400;
|
|
128
|
+
readonly logLevel: "warn";
|
|
129
|
+
};
|
|
130
|
+
readonly OPERATION_ABORTED: {
|
|
131
|
+
readonly code: "BUS-002-ABORT";
|
|
132
|
+
readonly name: "OPERATION_ABORTED";
|
|
133
|
+
readonly description: "The operation was explicitly aborted";
|
|
134
|
+
readonly category: "business";
|
|
135
|
+
readonly httpStatus: 409;
|
|
136
|
+
readonly logLevel: "info";
|
|
137
|
+
};
|
|
138
|
+
readonly INTERNAL_ERROR: {
|
|
139
|
+
readonly code: "SYS-001";
|
|
140
|
+
readonly name: "INTERNAL_ERROR";
|
|
141
|
+
readonly description: "An unexpected internal error occurred";
|
|
142
|
+
readonly category: "system";
|
|
143
|
+
readonly httpStatus: 500;
|
|
144
|
+
readonly logLevel: "error";
|
|
145
|
+
readonly action: "Check system logs for stack traces and diagnostic information";
|
|
146
|
+
};
|
|
147
|
+
readonly BACKEND_ERROR: {
|
|
148
|
+
readonly code: "SYS-002";
|
|
149
|
+
readonly name: "BACKEND_ERROR";
|
|
150
|
+
readonly description: "An error occurred in a backend service";
|
|
151
|
+
readonly category: "system";
|
|
152
|
+
readonly httpStatus: 502;
|
|
153
|
+
readonly logLevel: "error";
|
|
154
|
+
};
|
|
155
|
+
readonly CONCURRENCY_ERROR: {
|
|
156
|
+
readonly code: "CON-001";
|
|
157
|
+
readonly name: "CONCURRENCY_ERROR";
|
|
158
|
+
readonly description: "A concurrency conflict occurred during the operation";
|
|
159
|
+
readonly category: "concurrency";
|
|
160
|
+
readonly httpStatus: 409;
|
|
161
|
+
readonly logLevel: "warn";
|
|
162
|
+
readonly action: "Retry the operation with updated data";
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* Register a custom error code at runtime.
|
|
167
|
+
* @throws if code already exists as a built-in error
|
|
168
|
+
*/
|
|
169
|
+
declare function registerErrorCode(metadata: ErrorCodeMetadata): void;
|
|
170
|
+
/**
|
|
171
|
+
* Get metadata for any error code (built-in or custom).
|
|
172
|
+
* Returns default metadata for unknown codes instead of throwing.
|
|
173
|
+
*/
|
|
174
|
+
declare function getErrorMetadata(code: string): ErrorCodeMetadata;
|
|
175
|
+
/**
|
|
176
|
+
* Check if an error code is known (built-in or registered custom).
|
|
177
|
+
*/
|
|
178
|
+
declare function isKnownErrorCode(code: string): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* SystemError is the primary error type for all operational and validation errors.
|
|
181
|
+
* Supports both predefined and custom error codes with full metadata.
|
|
182
|
+
*/
|
|
183
|
+
declare class SystemError extends Error {
|
|
184
|
+
readonly code: string;
|
|
185
|
+
readonly codeMetadata: ErrorCodeMetadata;
|
|
186
|
+
readonly severity: Severity;
|
|
187
|
+
readonly path?: string;
|
|
188
|
+
readonly operation?: string;
|
|
189
|
+
readonly issues: readonly Issue[];
|
|
190
|
+
readonly cause?: unknown;
|
|
191
|
+
constructor(params: {
|
|
192
|
+
code: string;
|
|
193
|
+
message?: string;
|
|
194
|
+
severity?: Severity;
|
|
195
|
+
path?: string;
|
|
196
|
+
operation?: string;
|
|
197
|
+
issues?: readonly Issue[];
|
|
198
|
+
cause?: unknown;
|
|
199
|
+
metadata?: Partial<Omit<ErrorCodeMetadata, "code">>;
|
|
200
|
+
});
|
|
201
|
+
/**
|
|
202
|
+
* Returns a new SystemError with the specified path.
|
|
203
|
+
*/
|
|
204
|
+
withPath(path: string): SystemError;
|
|
205
|
+
/**
|
|
206
|
+
* Returns a new SystemError with the specified operation name.
|
|
207
|
+
*/
|
|
208
|
+
withOperation(operation: string): SystemError;
|
|
209
|
+
/**
|
|
210
|
+
* Returns a new SystemError with the specified issue appended.
|
|
211
|
+
*/
|
|
212
|
+
withIssue(issue: Issue): SystemError;
|
|
213
|
+
/**
|
|
214
|
+
* Returns a new SystemError with multiple issues appended.
|
|
215
|
+
*/
|
|
216
|
+
withIssues(issues: readonly Issue[]): SystemError;
|
|
217
|
+
/**
|
|
218
|
+
* Returns a new SystemError wrapping the specified cause.
|
|
219
|
+
*/
|
|
220
|
+
withCause(cause: unknown): SystemError;
|
|
221
|
+
/**
|
|
222
|
+
* Returns the HTTP status code for this error (if applicable).
|
|
223
|
+
*/
|
|
224
|
+
getHttpStatus(): number | undefined;
|
|
225
|
+
/**
|
|
226
|
+
* Formats the error for logging with structured metadata.
|
|
227
|
+
*/
|
|
228
|
+
toLogEntry(): Record<string, unknown>;
|
|
229
|
+
/**
|
|
230
|
+
* Produces a human-readable representation suitable for logging.
|
|
231
|
+
*/
|
|
232
|
+
toString(): string;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Factory for creating a new SystemError with automatic metadata.
|
|
236
|
+
*/
|
|
237
|
+
declare function createError(code: string, message?: string): SystemError;
|
|
238
|
+
/**
|
|
239
|
+
* Helper for quick ad-hoc errors (useful for testing or prototyping).
|
|
240
|
+
*/
|
|
241
|
+
declare function error(code: string, message?: string): SystemError;
|
|
242
|
+
/**
|
|
243
|
+
* Predefined error codes for common scenarios (backward compatibility).
|
|
244
|
+
*/
|
|
245
|
+
declare const CommonErrors: {
|
|
246
|
+
readonly NOT_FOUND: "DB-001-NF";
|
|
247
|
+
readonly DUPLICATE_KEY: "DB-002-DUP";
|
|
248
|
+
readonly INVALID_COMMAND: "BUS-001";
|
|
249
|
+
readonly PERMISSION_DENIED: "AUTH-001-DENIED";
|
|
250
|
+
readonly BACKEND_ERROR: "SYS-002";
|
|
251
|
+
readonly INTERNAL_ERROR: "SYS-001";
|
|
252
|
+
readonly VALIDATION_FAILED: "VAL-001";
|
|
253
|
+
readonly CONCURRENCY_ERROR: "CON-001";
|
|
254
|
+
readonly RESOURCE_LOCKED: "DB-003-LOCK";
|
|
255
|
+
readonly OPERATION_ABORTED: "BUS-002-ABORT";
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Convenience factory functions for common errors.
|
|
259
|
+
*/
|
|
260
|
+
declare const Errors: {
|
|
261
|
+
notFound: (path?: string, message?: string) => SystemError;
|
|
262
|
+
duplicateKey: (path?: string, message?: string) => SystemError;
|
|
263
|
+
permissionDenied: (operation?: string, message?: string) => SystemError;
|
|
264
|
+
validationFailed: (issues: Issue[], path?: string) => SystemError;
|
|
265
|
+
internalError: (cause?: unknown, message?: string) => SystemError;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* A functional wrapper for operations that can fail.
|
|
269
|
+
* Encourages explicit error handling over try/catch blocks.
|
|
270
|
+
*/
|
|
271
|
+
type Result<T, E = SystemError> = {
|
|
272
|
+
readonly ok: true;
|
|
273
|
+
readonly value: T;
|
|
274
|
+
} | {
|
|
275
|
+
readonly ok: false;
|
|
276
|
+
readonly error: E;
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Type-safe helpers for creating Results.
|
|
280
|
+
*/
|
|
281
|
+
declare const Result: {
|
|
282
|
+
ok: <T>(value: T) => Result<T, never>;
|
|
283
|
+
fail: <E>(error: E) => Result<never, E>;
|
|
284
|
+
};
|
|
285
|
+
|
|
286
|
+
export { CommonErrors, type ErrorCategory, type ErrorCodeMetadata, ErrorCodes, Errors, type Issue, Result, type Severity, SystemError, createError, error, getErrorMetadata, isKnownErrorCode, registerErrorCode };
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e={VALIDATION_FAILED:{code:"VAL-001",name:"VALIDATION_FAILED",description:"Input validation failed due to one or more invalid fields",category:"validation",httpStatus:400,logLevel:"warn"},REQUIRED_FIELD_MISSING:{code:"VAL-002",name:"REQUIRED_FIELD_MISSING",description:"A required field was not provided in the request",category:"validation",httpStatus:400,logLevel:"warn"},INVALID_FORMAT:{code:"VAL-003",name:"INVALID_FORMAT",description:"Field value does not match expected format",category:"validation",httpStatus:400,logLevel:"warn"},NOT_FOUND:{code:"DB-001-NF",name:"NOT_FOUND",description:"The requested resource could not be found",category:"database",httpStatus:404,logLevel:"info",action:"Verify the resource identifier exists before accessing"},DUPLICATE_KEY:{code:"DB-002-DUP",name:"DUPLICATE_KEY",description:"A unique constraint violation occurred",category:"database",httpStatus:409,logLevel:"warn",action:"Check if the resource already exists before creation"},RESOURCE_LOCKED:{code:"DB-003-LOCK",name:"RESOURCE_LOCKED",description:"The resource is currently locked by another operation",category:"database",httpStatus:409,logLevel:"warn",action:"Retry the operation after a brief delay"},PERMISSION_DENIED:{code:"AUTH-001-DENIED",name:"PERMISSION_DENIED",description:"The authenticated user lacks permission for this operation",category:"auth",httpStatus:403,logLevel:"warn",action:"Check user roles and permissions"},UNAUTHENTICATED:{code:"AUTH-002-UNAUTH",name:"UNAUTHENTICATED",description:"Authentication is required for this operation",category:"auth",httpStatus:401,logLevel:"info",action:"Provide valid authentication credentials"},INVALID_COMMAND:{code:"BUS-001",name:"INVALID_COMMAND",description:"The command or operation is invalid for the current state",category:"business",httpStatus:400,logLevel:"warn"},OPERATION_ABORTED:{code:"BUS-002-ABORT",name:"OPERATION_ABORTED",description:"The operation was explicitly aborted",category:"business",httpStatus:409,logLevel:"info"},INTERNAL_ERROR:{code:"SYS-001",name:"INTERNAL_ERROR",description:"An unexpected internal error occurred",category:"system",httpStatus:500,logLevel:"error",action:"Check system logs for stack traces and diagnostic information"},BACKEND_ERROR:{code:"SYS-002",name:"BACKEND_ERROR",description:"An error occurred in a backend service",category:"system",httpStatus:502,logLevel:"error"},CONCURRENCY_ERROR:{code:"CON-001",name:"CONCURRENCY_ERROR",description:"A concurrency conflict occurred during the operation",category:"concurrency",httpStatus:409,logLevel:"warn",action:"Retry the operation with updated data"}},t=new Map;function s(s){const a=Object.values(e).find((e=>e.code===s));if(a)return a;const r=t.get(s);return r||{code:s,name:s.replace(/-/g,"_"),description:`Unknown error: ${s}`,category:"custom",httpStatus:500,logLevel:"error",action:"Check if this error code is properly registered or handle as unknown error"}}var a=class e extends Error{code;codeMetadata;severity;path;operation;issues;cause;constructor(t){const a={...s(t.code),...t.metadata,code:t.code};super(t.message??a.description),this.name="SystemError",this.code=t.code,this.codeMetadata=a,this.severity=t.severity??"error",this.path=t.path,this.operation=t.operation,this.issues=t.issues??[],this.cause=t.cause,Object.setPrototypeOf(this,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,e)}withPath(t){return new e({code:this.code,message:this.message,severity:this.severity,path:t,operation:this.operation,issues:this.issues,cause:this.cause,metadata:this.codeMetadata})}withOperation(t){return new e({code:this.code,message:this.message,severity:this.severity,path:this.path,operation:t,issues:this.issues,cause:this.cause,metadata:this.codeMetadata})}withIssue(t){return new e({code:this.code,message:this.message,severity:this.severity,path:this.path,operation:this.operation,issues:[...this.issues,t],cause:this.cause,metadata:this.codeMetadata})}withIssues(t){return new e({code:this.code,message:this.message,severity:this.severity,path:this.path,operation:this.operation,issues:[...this.issues,...t],cause:this.cause,metadata:this.codeMetadata})}withCause(t){return new e({code:this.code,message:this.message,severity:this.severity,path:this.path,operation:this.operation,issues:this.issues,cause:t,metadata:this.codeMetadata})}getHttpStatus(){return this.codeMetadata.httpStatus}toLogEntry(){return{name:this.name,code:this.code,category:this.codeMetadata.category,message:this.message,path:this.path,operation:this.operation,issues:this.issues,cause:this.cause instanceof Error?this.cause.message:this.cause,stack:this.stack,timestamp:(new Date).toISOString()}}toString(){let e=`[${this.code}] ${this.message} (${this.codeMetadata.category})`;return this.path&&(e+=` at '${this.path}'`),this.operation&&(e+=` during '${this.operation}'`),this.issues.length>0&&(e+="\nIssues:\n"+this.issues.map(((e,t)=>` ${t+1}. ${e.message} [${e.code}]`)).join("\n")),this.cause&&(e+=`\nCause: ${this.cause instanceof Error?this.cause.message:String(this.cause)}`),e}};var r={NOT_FOUND:"DB-001-NF",DUPLICATE_KEY:"DB-002-DUP",INVALID_COMMAND:"BUS-001",PERMISSION_DENIED:"AUTH-001-DENIED",BACKEND_ERROR:"SYS-002",INTERNAL_ERROR:"SYS-001",VALIDATION_FAILED:"VAL-001",CONCURRENCY_ERROR:"CON-001",RESOURCE_LOCKED:"DB-003-LOCK",OPERATION_ABORTED:"BUS-002-ABORT"},o={notFound:(e,t)=>new a({code:r.NOT_FOUND,message:t,path:e}),duplicateKey:(e,t)=>new a({code:r.DUPLICATE_KEY,message:t,path:e}),permissionDenied:(e,t)=>new a({code:r.PERMISSION_DENIED,message:t,operation:e}),validationFailed:(e,t)=>new a({code:r.VALIDATION_FAILED,issues:e,path:t}),internalError:(e,t)=>new a({code:r.INTERNAL_ERROR,message:t,cause:e})};exports.CommonErrors=r,exports.ErrorCodes=e,exports.Errors=o,exports.Result={ok:e=>({ok:!0,value:e}),fail:e=>({ok:!1,error:e})},exports.SystemError=a,exports.createError=function(e,t){return new a({code:e,message:t})},exports.error=function(e,t){return new a({code:e,message:t})},exports.getErrorMetadata=s,exports.isKnownErrorCode=function(s){return Object.values(e).some((e=>e.code===s))||t.has(s)},exports.registerErrorCode=function(s){if(Object.values(e).find((e=>e.code===s.code)))throw new Error(`Cannot register custom error code "${s.code}": already exists as built-in error`);if(t.has(s.code))throw new Error(`Custom error code "${s.code}" is already registered`);t.set(s.code,s)};
|
package/index.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={VALIDATION_FAILED:{code:"VAL-001",name:"VALIDATION_FAILED",description:"Input validation failed due to one or more invalid fields",category:"validation",httpStatus:400,logLevel:"warn"},REQUIRED_FIELD_MISSING:{code:"VAL-002",name:"REQUIRED_FIELD_MISSING",description:"A required field was not provided in the request",category:"validation",httpStatus:400,logLevel:"warn"},INVALID_FORMAT:{code:"VAL-003",name:"INVALID_FORMAT",description:"Field value does not match expected format",category:"validation",httpStatus:400,logLevel:"warn"},NOT_FOUND:{code:"DB-001-NF",name:"NOT_FOUND",description:"The requested resource could not be found",category:"database",httpStatus:404,logLevel:"info",action:"Verify the resource identifier exists before accessing"},DUPLICATE_KEY:{code:"DB-002-DUP",name:"DUPLICATE_KEY",description:"A unique constraint violation occurred",category:"database",httpStatus:409,logLevel:"warn",action:"Check if the resource already exists before creation"},RESOURCE_LOCKED:{code:"DB-003-LOCK",name:"RESOURCE_LOCKED",description:"The resource is currently locked by another operation",category:"database",httpStatus:409,logLevel:"warn",action:"Retry the operation after a brief delay"},PERMISSION_DENIED:{code:"AUTH-001-DENIED",name:"PERMISSION_DENIED",description:"The authenticated user lacks permission for this operation",category:"auth",httpStatus:403,logLevel:"warn",action:"Check user roles and permissions"},UNAUTHENTICATED:{code:"AUTH-002-UNAUTH",name:"UNAUTHENTICATED",description:"Authentication is required for this operation",category:"auth",httpStatus:401,logLevel:"info",action:"Provide valid authentication credentials"},INVALID_COMMAND:{code:"BUS-001",name:"INVALID_COMMAND",description:"The command or operation is invalid for the current state",category:"business",httpStatus:400,logLevel:"warn"},OPERATION_ABORTED:{code:"BUS-002-ABORT",name:"OPERATION_ABORTED",description:"The operation was explicitly aborted",category:"business",httpStatus:409,logLevel:"info"},INTERNAL_ERROR:{code:"SYS-001",name:"INTERNAL_ERROR",description:"An unexpected internal error occurred",category:"system",httpStatus:500,logLevel:"error",action:"Check system logs for stack traces and diagnostic information"},BACKEND_ERROR:{code:"SYS-002",name:"BACKEND_ERROR",description:"An error occurred in a backend service",category:"system",httpStatus:502,logLevel:"error"},CONCURRENCY_ERROR:{code:"CON-001",name:"CONCURRENCY_ERROR",description:"A concurrency conflict occurred during the operation",category:"concurrency",httpStatus:409,logLevel:"warn",action:"Retry the operation with updated data"}},t=new Map;function s(s){if(Object.values(e).find((e=>e.code===s.code)))throw new Error(`Cannot register custom error code "${s.code}": already exists as built-in error`);if(t.has(s.code))throw new Error(`Custom error code "${s.code}" is already registered`);t.set(s.code,s)}function a(s){const a=Object.values(e).find((e=>e.code===s));if(a)return a;const o=t.get(s);return o||{code:s,name:s.replace(/-/g,"_"),description:`Unknown error: ${s}`,category:"custom",httpStatus:500,logLevel:"error",action:"Check if this error code is properly registered or handle as unknown error"}}function o(s){return Object.values(e).some((e=>e.code===s))||t.has(s)}var i=class e extends Error{code;codeMetadata;severity;path;operation;issues;cause;constructor(t){const s={...a(t.code),...t.metadata,code:t.code};super(t.message??s.description),this.name="SystemError",this.code=t.code,this.codeMetadata=s,this.severity=t.severity??"error",this.path=t.path,this.operation=t.operation,this.issues=t.issues??[],this.cause=t.cause,Object.setPrototypeOf(this,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,e)}withPath(t){return new e({code:this.code,message:this.message,severity:this.severity,path:t,operation:this.operation,issues:this.issues,cause:this.cause,metadata:this.codeMetadata})}withOperation(t){return new e({code:this.code,message:this.message,severity:this.severity,path:this.path,operation:t,issues:this.issues,cause:this.cause,metadata:this.codeMetadata})}withIssue(t){return new e({code:this.code,message:this.message,severity:this.severity,path:this.path,operation:this.operation,issues:[...this.issues,t],cause:this.cause,metadata:this.codeMetadata})}withIssues(t){return new e({code:this.code,message:this.message,severity:this.severity,path:this.path,operation:this.operation,issues:[...this.issues,...t],cause:this.cause,metadata:this.codeMetadata})}withCause(t){return new e({code:this.code,message:this.message,severity:this.severity,path:this.path,operation:this.operation,issues:this.issues,cause:t,metadata:this.codeMetadata})}getHttpStatus(){return this.codeMetadata.httpStatus}toLogEntry(){return{name:this.name,code:this.code,category:this.codeMetadata.category,message:this.message,path:this.path,operation:this.operation,issues:this.issues,cause:this.cause instanceof Error?this.cause.message:this.cause,stack:this.stack,timestamp:(new Date).toISOString()}}toString(){let e=`[${this.code}] ${this.message} (${this.codeMetadata.category})`;return this.path&&(e+=` at '${this.path}'`),this.operation&&(e+=` during '${this.operation}'`),this.issues.length>0&&(e+="\nIssues:\n"+this.issues.map(((e,t)=>` ${t+1}. ${e.message} [${e.code}]`)).join("\n")),this.cause&&(e+=`\nCause: ${this.cause instanceof Error?this.cause.message:String(this.cause)}`),e}};function r(e,t){return new i({code:e,message:t})}function n(e,t){return new i({code:e,message:t})}var c={NOT_FOUND:"DB-001-NF",DUPLICATE_KEY:"DB-002-DUP",INVALID_COMMAND:"BUS-001",PERMISSION_DENIED:"AUTH-001-DENIED",BACKEND_ERROR:"SYS-002",INTERNAL_ERROR:"SYS-001",VALIDATION_FAILED:"VAL-001",CONCURRENCY_ERROR:"CON-001",RESOURCE_LOCKED:"DB-003-LOCK",OPERATION_ABORTED:"BUS-002-ABORT"},d={notFound:(e,t)=>new i({code:c.NOT_FOUND,message:t,path:e}),duplicateKey:(e,t)=>new i({code:c.DUPLICATE_KEY,message:t,path:e}),permissionDenied:(e,t)=>new i({code:c.PERMISSION_DENIED,message:t,operation:e}),validationFailed:(e,t)=>new i({code:c.VALIDATION_FAILED,issues:e,path:t}),internalError:(e,t)=>new i({code:c.INTERNAL_ERROR,message:t,cause:e})},h={ok:e=>({ok:!0,value:e}),fail:e=>({ok:!1,error:e})};export{c as CommonErrors,e as ErrorCodes,d as Errors,h as Result,i as SystemError,r as createError,n as error,a as getErrorMetadata,o as isKnownErrorCode,s as registerErrorCode};
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@asaidimu/utils-error",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A collection of error utilities.",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "index.mjs",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"typescript",
|
|
10
|
+
"utility"
|
|
11
|
+
],
|
|
12
|
+
"author": "Saidimu <47994458+asaidimu@users.noreply.github.com>",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/asaidimu/erp-utils.git"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/asaidimu/erp-utils/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/asaidimu/erp-utils/tree/main/src/error#readme",
|
|
22
|
+
"files": [
|
|
23
|
+
"./*"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"import": {
|
|
28
|
+
"types": "./index.d.ts",
|
|
29
|
+
"default": "./index.mjs"
|
|
30
|
+
},
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./index.d.ts",
|
|
33
|
+
"default": "./index.js"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {},
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"registry": "https://registry.npmjs.org/",
|
|
40
|
+
"tag": "latest",
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"release": {
|
|
44
|
+
"plugins": [
|
|
45
|
+
[
|
|
46
|
+
"@semantic-release/npm",
|
|
47
|
+
{
|
|
48
|
+
"pkgRoot": "./dist"
|
|
49
|
+
}
|
|
50
|
+
],
|
|
51
|
+
[
|
|
52
|
+
"@semantic-release/git",
|
|
53
|
+
{
|
|
54
|
+
"assets": [
|
|
55
|
+
"CHANGELOG.md",
|
|
56
|
+
"package.json"
|
|
57
|
+
],
|
|
58
|
+
"message": "chore(release): Release @asaidimu/utils-error v${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
}
|