@veloxts/core 0.3.3 → 0.3.5

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 (54) hide show
  1. package/README.md +697 -16
  2. package/dist/app.d.ts +67 -10
  3. package/dist/app.d.ts.map +1 -1
  4. package/dist/app.js +79 -12
  5. package/dist/app.js.map +1 -1
  6. package/dist/context.d.ts +26 -1
  7. package/dist/context.d.ts.map +1 -1
  8. package/dist/context.js +29 -0
  9. package/dist/context.js.map +1 -1
  10. package/dist/di/container.d.ts +406 -0
  11. package/dist/di/container.d.ts.map +1 -0
  12. package/dist/di/container.js +699 -0
  13. package/dist/di/container.js.map +1 -0
  14. package/dist/di/decorators.d.ts +235 -0
  15. package/dist/di/decorators.d.ts.map +1 -0
  16. package/dist/di/decorators.js +297 -0
  17. package/dist/di/decorators.js.map +1 -0
  18. package/dist/di/index.d.ts +65 -0
  19. package/dist/di/index.d.ts.map +1 -0
  20. package/dist/di/index.js +73 -0
  21. package/dist/di/index.js.map +1 -0
  22. package/dist/di/providers.d.ts +397 -0
  23. package/dist/di/providers.d.ts.map +1 -0
  24. package/dist/di/providers.js +380 -0
  25. package/dist/di/providers.js.map +1 -0
  26. package/dist/di/scope.d.ts +230 -0
  27. package/dist/di/scope.d.ts.map +1 -0
  28. package/dist/di/scope.js +294 -0
  29. package/dist/di/scope.js.map +1 -0
  30. package/dist/di/tokens.d.ts +227 -0
  31. package/dist/di/tokens.d.ts.map +1 -0
  32. package/dist/di/tokens.js +192 -0
  33. package/dist/di/tokens.js.map +1 -0
  34. package/dist/errors/catalog.d.ts +79 -0
  35. package/dist/errors/catalog.d.ts.map +1 -0
  36. package/dist/errors/catalog.js +492 -0
  37. package/dist/errors/catalog.js.map +1 -0
  38. package/dist/errors/formatter.d.ts +101 -0
  39. package/dist/errors/formatter.d.ts.map +1 -0
  40. package/dist/errors/formatter.js +330 -0
  41. package/dist/errors/formatter.js.map +1 -0
  42. package/dist/errors/index.d.ts +14 -0
  43. package/dist/errors/index.d.ts.map +1 -0
  44. package/dist/errors/index.js +16 -0
  45. package/dist/errors/index.js.map +1 -0
  46. package/dist/errors.d.ts +35 -5
  47. package/dist/errors.d.ts.map +1 -1
  48. package/dist/errors.js +57 -4
  49. package/dist/errors.js.map +1 -1
  50. package/dist/index.d.ts +10 -6
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +29 -6
  53. package/dist/index.js.map +1 -1
  54. package/package.json +14 -2
@@ -0,0 +1,330 @@
1
+ /**
2
+ * Error Formatter - Pretty terminal output with fix suggestions
3
+ *
4
+ * Inspired by Laravel's Ignition error pages, this module provides
5
+ * beautiful, informative error messages with actionable suggestions.
6
+ *
7
+ * @module errors/formatter
8
+ */
9
+ import { getErrorEntry } from './catalog.js';
10
+ // ============================================================================
11
+ // ANSI Color Codes (for terminal output)
12
+ // ============================================================================
13
+ const COLORS = {
14
+ reset: '\x1b[0m',
15
+ bold: '\x1b[1m',
16
+ dim: '\x1b[2m',
17
+ // Text colors
18
+ red: '\x1b[31m',
19
+ green: '\x1b[32m',
20
+ yellow: '\x1b[33m',
21
+ blue: '\x1b[34m',
22
+ magenta: '\x1b[35m',
23
+ cyan: '\x1b[36m',
24
+ white: '\x1b[37m',
25
+ gray: '\x1b[90m',
26
+ // Background colors
27
+ bgRed: '\x1b[41m',
28
+ bgYellow: '\x1b[43m',
29
+ bgBlue: '\x1b[44m',
30
+ };
31
+ /**
32
+ * Check if colors should be enabled
33
+ * Respects NO_COLOR env var and TTY detection
34
+ */
35
+ function shouldUseColors() {
36
+ if (process.env.NO_COLOR)
37
+ return false;
38
+ if (process.env.FORCE_COLOR)
39
+ return true;
40
+ return process.stdout.isTTY ?? false;
41
+ }
42
+ /**
43
+ * Apply color to text if colors are enabled
44
+ */
45
+ function color(text, ...codes) {
46
+ if (!shouldUseColors())
47
+ return text;
48
+ const prefix = codes.map((c) => COLORS[c]).join('');
49
+ return `${prefix}${text}${COLORS.reset}`;
50
+ }
51
+ // ============================================================================
52
+ // Formatting Helpers
53
+ // ============================================================================
54
+ /**
55
+ * Create a horizontal divider line
56
+ */
57
+ function divider(char = '─', length = 70) {
58
+ return char.repeat(length);
59
+ }
60
+ /**
61
+ * Indent text by a number of spaces
62
+ */
63
+ function indent(text, spaces = 2) {
64
+ const pad = ' '.repeat(spaces);
65
+ return text
66
+ .split('\n')
67
+ .map((line) => `${pad}${line}`)
68
+ .join('\n');
69
+ }
70
+ /**
71
+ * Wrap text to a maximum width
72
+ */
73
+ function wrapText(text, maxWidth = 68) {
74
+ const words = text.split(' ');
75
+ const lines = [];
76
+ let currentLine = '';
77
+ for (const word of words) {
78
+ if (currentLine.length + word.length + 1 <= maxWidth) {
79
+ currentLine += (currentLine ? ' ' : '') + word;
80
+ }
81
+ else {
82
+ if (currentLine)
83
+ lines.push(currentLine);
84
+ currentLine = word;
85
+ }
86
+ }
87
+ if (currentLine)
88
+ lines.push(currentLine);
89
+ return lines.join('\n');
90
+ }
91
+ /**
92
+ * Parse stack trace to extract error location
93
+ *
94
+ * @param error - The error to parse
95
+ * @returns Location info or undefined
96
+ */
97
+ export function extractErrorLocation(error) {
98
+ if (!error.stack)
99
+ return undefined;
100
+ // Skip the first line (error message) and internal frames
101
+ const lines = error.stack.split('\n').slice(1);
102
+ for (const line of lines) {
103
+ // Skip internal node_modules frames
104
+ if (line.includes('node_modules'))
105
+ continue;
106
+ if (line.includes('node:internal'))
107
+ continue;
108
+ // Match V8 stack trace format: "at functionName (file:line:col)"
109
+ // or "at file:line:col"
110
+ const match = line.match(/at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?/);
111
+ if (match) {
112
+ return {
113
+ functionName: match[1],
114
+ file: match[2],
115
+ line: parseInt(match[3], 10),
116
+ column: parseInt(match[4], 10),
117
+ };
118
+ }
119
+ }
120
+ return undefined;
121
+ }
122
+ // ============================================================================
123
+ // Main Formatting Functions
124
+ // ============================================================================
125
+ /**
126
+ * Format an error for terminal output with fix suggestions
127
+ *
128
+ * @param error - The error to format
129
+ * @param catalogCode - Optional catalog error code
130
+ * @param options - Formatting options
131
+ * @returns Formatted error string for terminal display
132
+ *
133
+ * @example
134
+ * ```typescript
135
+ * try {
136
+ * // ... code that throws
137
+ * } catch (error) {
138
+ * console.error(formatError(error, 'VELOX-1001'));
139
+ * }
140
+ * ```
141
+ */
142
+ export function formatError(error, catalogCode, options = {}) {
143
+ const { includeStack = process.env.NODE_ENV !== 'production', includeFix = true, includeDocs = true, includeSeeAlso = true, maxWidth = 68, } = options;
144
+ const entry = catalogCode ? getErrorEntry(catalogCode) : undefined;
145
+ const location = extractErrorLocation(error);
146
+ const lines = [];
147
+ // Header
148
+ lines.push('');
149
+ lines.push(color(divider('═'), 'red'));
150
+ lines.push('');
151
+ // Error code and title
152
+ if (entry) {
153
+ lines.push(` ${color(entry.code, 'red', 'bold')} ${color(entry.title, 'white', 'bold')}`);
154
+ }
155
+ else {
156
+ lines.push(` ${color(error.name, 'red', 'bold')}`);
157
+ }
158
+ lines.push('');
159
+ // Error message
160
+ lines.push(indent(wrapText(error.message, maxWidth)));
161
+ lines.push('');
162
+ // Location
163
+ if (location) {
164
+ lines.push(color(divider('─'), 'gray'));
165
+ lines.push('');
166
+ lines.push(` ${color('Location:', 'cyan', 'bold')}`);
167
+ lines.push('');
168
+ const loc = `${location.file}:${location.line}${location.column ? `:${location.column}` : ''}`;
169
+ lines.push(` ${color('→', 'yellow')} ${color(loc, 'white')}`);
170
+ if (location.functionName) {
171
+ lines.push(` ${color('in', 'gray')} ${color(location.functionName, 'cyan')}`);
172
+ }
173
+ lines.push('');
174
+ }
175
+ // Description from catalog
176
+ if (entry?.description) {
177
+ lines.push(color(divider('─'), 'gray'));
178
+ lines.push('');
179
+ lines.push(` ${color('Why this happens:', 'cyan', 'bold')}`);
180
+ lines.push('');
181
+ lines.push(indent(wrapText(entry.description, maxWidth)));
182
+ lines.push('');
183
+ }
184
+ // Fix suggestion
185
+ if (includeFix && entry?.fix) {
186
+ lines.push(color(divider('─'), 'gray'));
187
+ lines.push('');
188
+ lines.push(` ${color('How to fix:', 'green', 'bold')}`);
189
+ lines.push('');
190
+ lines.push(indent(wrapText(entry.fix.suggestion, maxWidth)));
191
+ if (entry.fix.example) {
192
+ lines.push('');
193
+ lines.push(` ${color('Example:', 'yellow')}`);
194
+ lines.push('');
195
+ // Format code example with syntax highlighting hint
196
+ const exampleLines = entry.fix.example.split('\n');
197
+ for (const exLine of exampleLines) {
198
+ if (exLine.trim().startsWith('#') || exLine.trim().startsWith('//')) {
199
+ lines.push(` ${color(exLine, 'gray')}`);
200
+ }
201
+ else if (exLine.trim().startsWith('+')) {
202
+ lines.push(` ${color(exLine, 'green')}`);
203
+ }
204
+ else if (exLine.trim().startsWith('-')) {
205
+ lines.push(` ${color(exLine, 'red')}`);
206
+ }
207
+ else {
208
+ lines.push(` ${color(exLine, 'white')}`);
209
+ }
210
+ }
211
+ lines.push('');
212
+ }
213
+ }
214
+ // Documentation link
215
+ if (includeDocs && entry?.docsUrl) {
216
+ lines.push(color(divider('─'), 'gray'));
217
+ lines.push('');
218
+ lines.push(` ${color('Documentation:', 'blue', 'bold')}`);
219
+ lines.push(` ${color(entry.docsUrl, 'cyan')}`);
220
+ lines.push('');
221
+ }
222
+ // Related errors
223
+ if (includeSeeAlso && entry?.seeAlso && entry.seeAlso.length > 0) {
224
+ lines.push(` ${color('See also:', 'gray')} ${entry.seeAlso.map((c) => color(c, 'yellow')).join(', ')}`);
225
+ lines.push('');
226
+ }
227
+ // Stack trace (development only)
228
+ if (includeStack && error.stack) {
229
+ lines.push(color(divider('─'), 'gray'));
230
+ lines.push('');
231
+ lines.push(` ${color('Stack trace:', 'gray', 'bold')}`);
232
+ lines.push('');
233
+ const stackLines = error.stack.split('\n').slice(1, 8); // First 7 frames
234
+ for (const stackLine of stackLines) {
235
+ lines.push(` ${color(stackLine.trim(), 'gray')}`);
236
+ }
237
+ if (error.stack.split('\n').length > 8) {
238
+ lines.push(` ${color('... more frames hidden', 'dim')}`);
239
+ }
240
+ lines.push('');
241
+ }
242
+ // Footer
243
+ lines.push(color(divider('═'), 'red'));
244
+ lines.push('');
245
+ return lines.join('\n');
246
+ }
247
+ /**
248
+ * Format an error for JSON API response
249
+ * Includes catalog metadata but not stack traces
250
+ *
251
+ * @param error - The error to format
252
+ * @param catalogCode - Optional catalog error code
253
+ * @returns JSON-serializable error object
254
+ */
255
+ export function formatErrorForApi(error, catalogCode) {
256
+ const entry = catalogCode ? getErrorEntry(catalogCode) : undefined;
257
+ const response = {
258
+ error: error.name,
259
+ message: error.message,
260
+ statusCode: error.statusCode ?? entry?.statusCode ?? 500,
261
+ code: catalogCode ?? error.code,
262
+ };
263
+ // Include field errors for validation
264
+ if (error.fields) {
265
+ response.fields = error.fields;
266
+ }
267
+ // Include fix suggestion in development
268
+ if (process.env.NODE_ENV !== 'production' && entry?.fix) {
269
+ response.fix = entry.fix.suggestion;
270
+ }
271
+ // Include docs link
272
+ if (entry?.docsUrl) {
273
+ response.docs = entry.docsUrl;
274
+ }
275
+ return response;
276
+ }
277
+ /**
278
+ * Format a short one-line error summary
279
+ *
280
+ * @param error - The error
281
+ * @param catalogCode - Optional catalog code
282
+ * @returns One-line error string
283
+ */
284
+ export function formatErrorOneLine(error, catalogCode) {
285
+ const entry = catalogCode ? getErrorEntry(catalogCode) : undefined;
286
+ if (entry) {
287
+ return `${color(entry.code, 'red')}: ${error.message}`;
288
+ }
289
+ return `${color(error.name, 'red')}: ${error.message}`;
290
+ }
291
+ // ============================================================================
292
+ // Error Logging Helpers
293
+ // ============================================================================
294
+ /**
295
+ * Log an error with pretty formatting
296
+ *
297
+ * @param error - The error to log
298
+ * @param catalogCode - Optional catalog error code
299
+ */
300
+ export function logError(error, catalogCode) {
301
+ console.error(formatError(error, catalogCode));
302
+ }
303
+ /**
304
+ * Log a warning with pretty formatting
305
+ *
306
+ * @param message - Warning message
307
+ * @param suggestion - Optional fix suggestion
308
+ */
309
+ export function logWarning(message, suggestion) {
310
+ const lines = [];
311
+ lines.push('');
312
+ lines.push(`${color('⚠', 'yellow')} ${color('Warning:', 'yellow', 'bold')} ${message}`);
313
+ if (suggestion) {
314
+ lines.push(` ${color('→', 'gray')} ${suggestion}`);
315
+ }
316
+ lines.push('');
317
+ console.warn(lines.join('\n'));
318
+ }
319
+ /**
320
+ * Log a deprecation warning
321
+ *
322
+ * @param oldApi - The deprecated API
323
+ * @param newApi - The replacement API
324
+ * @param removeVersion - Version when it will be removed
325
+ */
326
+ export function logDeprecation(oldApi, newApi, removeVersion) {
327
+ const removal = removeVersion ? ` (will be removed in ${removeVersion})` : '';
328
+ logWarning(`${color(oldApi, 'white')} is deprecated${removal}`, `Use ${color(newApi, 'green')} instead`);
329
+ }
330
+ //# sourceMappingURL=formatter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatter.js","sourceRoot":"","sources":["../../src/errors/formatter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,+EAA+E;AAC/E,yCAAyC;AACzC,+EAA+E;AAE/E,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,GAAG,EAAE,SAAS;IAEd,cAAc;IACd,GAAG,EAAE,UAAU;IACf,KAAK,EAAE,UAAU;IACjB,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;IACjB,IAAI,EAAE,UAAU;IAEhB,oBAAoB;IACpB,KAAK,EAAE,UAAU;IACjB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,UAAU;CACV,CAAC;AAEX;;;GAGG;AACH,SAAS,eAAe;IACtB,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IACvC,IAAI,OAAO,CAAC,GAAG,CAAC,WAAW;QAAE,OAAO,IAAI,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I,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,MAAc,EAAE,aAAsB;IACnF,MAAM,OAAO,GAAG,aAAa,CAAC,CAAC,CAAC,wBAAwB,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAC9E,UAAU,CACR,GAAG,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,iBAAiB,OAAO,EAAE,EACnD,OAAO,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CACxC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * VeloxTS Error System
3
+ *
4
+ * Provides enhanced error handling with:
5
+ * - Numbered error codes (VELOX-XXXX)
6
+ * - Fix suggestions with code examples
7
+ * - Pretty terminal formatting
8
+ * - Documentation links
9
+ *
10
+ * @module errors
11
+ */
12
+ export { ERROR_CATALOG, ERROR_DOMAINS, type ErrorCatalogEntry, type ErrorDomain, getDocsUrl, getErrorEntry, getErrorsByDomain, isKnownErrorCode, } from './catalog.js';
13
+ export { type ErrorLocation, extractErrorLocation, type FormatErrorOptions, formatError, formatErrorForApi, formatErrorOneLine, logDeprecation, logError, logWarning, } from './formatter.js';
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EACL,aAAa,EACb,aAAa,EACb,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,KAAK,aAAa,EAClB,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,UAAU,GACX,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * VeloxTS Error System
3
+ *
4
+ * Provides enhanced error handling with:
5
+ * - Numbered error codes (VELOX-XXXX)
6
+ * - Fix suggestions with code examples
7
+ * - Pretty terminal formatting
8
+ * - Documentation links
9
+ *
10
+ * @module errors
11
+ */
12
+ // Re-export catalog
13
+ export { ERROR_CATALOG, ERROR_DOMAINS, getDocsUrl, getErrorEntry, getErrorsByDomain, isKnownErrorCode, } from './catalog.js';
14
+ // Re-export formatter
15
+ export { extractErrorLocation, formatError, formatErrorForApi, formatErrorOneLine, logDeprecation, logError, logWarning, } from './formatter.js';
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oBAAoB;AACpB,OAAO,EACL,aAAa,EACb,aAAa,EAGb,UAAU,EACV,aAAa,EACb,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,sBAAsB;AACtB,OAAO,EAEL,oBAAoB,EAEpB,WAAW,EACX,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,QAAQ,EACR,UAAU,GACX,MAAM,gBAAgB,CAAC"}
package/dist/errors.d.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  * Provides base error classes with HTTP status codes and discriminated unions
4
4
  * @module errors
5
5
  */
6
+ export { ERROR_CATALOG, ERROR_DOMAINS, type ErrorCatalogEntry, type ErrorDomain, type ErrorLocation, extractErrorLocation, type FormatErrorOptions, formatError, formatErrorForApi, formatErrorOneLine, getDocsUrl, getErrorEntry, getErrorsByDomain, isKnownErrorCode, logDeprecation, logError, logWarning, } from './errors/index.js';
6
7
  /**
7
8
  * Known error codes in the VeloxTS framework core
8
9
  * Can be extended via declaration merging by plugins
@@ -104,11 +105,19 @@ export declare function isNotFoundErrorResponse(response: ErrorResponse): respon
104
105
  *
105
106
  * @example
106
107
  * ```typescript
108
+ * // Basic usage
107
109
  * throw new VeloxError('Something went wrong', 500);
108
110
  * ```
109
111
  *
110
112
  * @example
111
113
  * ```typescript
114
+ * // With catalog code for rich error details
115
+ * throw new VeloxError('Database connection failed', 503, 'VELOX-4001');
116
+ * ```
117
+ *
118
+ * @example
119
+ * ```typescript
120
+ * // With legacy string code
112
121
  * throw new VeloxError('Database connection failed', 503, 'DB_CONNECTION_ERROR');
113
122
  * ```
114
123
  */
@@ -118,23 +127,45 @@ export declare class VeloxError<TCode extends string = string> extends Error {
118
127
  */
119
128
  readonly statusCode: number;
120
129
  /**
121
- * Optional error code for programmatic error handling
130
+ * Error code for programmatic error handling
131
+ * Can be a catalog code (VELOX-XXXX) or legacy string code
122
132
  */
123
133
  readonly code?: TCode;
134
+ /**
135
+ * Fix suggestion for developers (populated from catalog)
136
+ */
137
+ readonly fix?: string;
138
+ /**
139
+ * Documentation URL for this error
140
+ */
141
+ readonly docsUrl?: string;
124
142
  /**
125
143
  * Creates a new VeloxError instance
126
144
  *
127
145
  * @param message - Human-readable error message
128
146
  * @param statusCode - HTTP status code (default: 500)
129
- * @param code - Optional error code for programmatic handling
147
+ * @param code - Optional error code (VELOX-XXXX catalog code or legacy string)
130
148
  */
131
149
  constructor(message: string, statusCode?: number, code?: TCode);
132
150
  /**
133
151
  * Converts error to JSON format for API responses
134
152
  *
135
- * @returns Error response object
153
+ * @returns Error response object with optional fix suggestion in development
154
+ */
155
+ toJSON(): GenericErrorResponse & {
156
+ fix?: string;
157
+ docs?: string;
158
+ };
159
+ /**
160
+ * Format error for terminal display with colors and fix suggestions
161
+ *
162
+ * @returns Formatted error string
163
+ */
164
+ format(): string;
165
+ /**
166
+ * Log this error with pretty formatting
136
167
  */
137
- toJSON(): GenericErrorResponse;
168
+ log(): void;
138
169
  }
139
170
  /**
140
171
  * Validation error for invalid user input
@@ -294,5 +325,4 @@ export declare function isConfigurationError(error: unknown): error is Configura
294
325
  * ```
295
326
  */
296
327
  export declare function assertNever(value: never): never;
297
- export {};
298
328
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAMH;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAC1B,kBAAkB,GAClB,WAAW,GACX,qBAAqB,GACrB,2BAA2B,GAC3B,wBAAwB,GACxB,oBAAoB,GACpB,oBAAoB,GACpB,mBAAmB,GACnB,yBAAyB,CAAC;AAE9B;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,sBAAsB;IACrC,IAAI,EAAE,kBAAkB,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,sBAAsB,CAAC,MAAM,sBAAsB,CAAC,CAAC;AAMlF;;GAEG;AACH,UAAU,iBAAiB;IACzB,uBAAuB;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,KAAK,EAAE,iBAAiB,CAAC;IACzB,UAAU,EAAE,GAAG,CAAC;IAChB,IAAI,EAAE,kBAAkB,CAAC;IACzB,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,iBAAiB;IAC9D,KAAK,EAAE,eAAe,CAAC;IACvB,UAAU,EAAE,GAAG,CAAC;IAChB,IAAI,EAAE,WAAW,CAAC;IAClB,0CAA0C;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,iBAA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,MAAM;CAQ5B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,aAAc,SAAQ,UAAU,CAAC,WAAW,CAAC;IACxD;;OAEG;IACH,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAEjC;;OAEG;IACH,SAAgB,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpC;;;;;OAKG;gBACS,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;IAejD;;;;OAIG;IACM,MAAM,IAAI,qBAAqB;CAUzC;AAMD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,eAAe,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,kBAAkB,CAEhF;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAE/C"}
package/dist/errors.js CHANGED
@@ -3,6 +3,11 @@
3
3
  * Provides base error classes with HTTP status codes and discriminated unions
4
4
  * @module errors
5
5
  */
6
+ // Import catalog for use in error classes
7
+ import { ERROR_CATALOG } from './errors/catalog.js';
8
+ import { formatError as _formatError } from './errors/formatter.js';
9
+ // Re-export the enhanced error catalog and formatter
10
+ export { ERROR_CATALOG, ERROR_DOMAINS, extractErrorLocation, formatError, formatErrorForApi, formatErrorOneLine, getDocsUrl, getErrorEntry, getErrorsByDomain, isKnownErrorCode, logDeprecation, logError, logWarning, } from './errors/index.js';
6
11
  /**
7
12
  * Type guard for validation error responses
8
13
  */
@@ -28,11 +33,19 @@ export function isNotFoundErrorResponse(response) {
28
33
  *
29
34
  * @example
30
35
  * ```typescript
36
+ * // Basic usage
31
37
  * throw new VeloxError('Something went wrong', 500);
32
38
  * ```
33
39
  *
34
40
  * @example
35
41
  * ```typescript
42
+ * // With catalog code for rich error details
43
+ * throw new VeloxError('Database connection failed', 503, 'VELOX-4001');
44
+ * ```
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * // With legacy string code
36
49
  * throw new VeloxError('Database connection failed', 503, 'DB_CONNECTION_ERROR');
37
50
  * ```
38
51
  */
@@ -42,21 +55,38 @@ export class VeloxError extends Error {
42
55
  */
43
56
  statusCode;
44
57
  /**
45
- * Optional error code for programmatic error handling
58
+ * Error code for programmatic error handling
59
+ * Can be a catalog code (VELOX-XXXX) or legacy string code
46
60
  */
47
61
  code;
62
+ /**
63
+ * Fix suggestion for developers (populated from catalog)
64
+ */
65
+ fix;
66
+ /**
67
+ * Documentation URL for this error
68
+ */
69
+ docsUrl;
48
70
  /**
49
71
  * Creates a new VeloxError instance
50
72
  *
51
73
  * @param message - Human-readable error message
52
74
  * @param statusCode - HTTP status code (default: 500)
53
- * @param code - Optional error code for programmatic handling
75
+ * @param code - Optional error code (VELOX-XXXX catalog code or legacy string)
54
76
  */
55
77
  constructor(message, statusCode = 500, code) {
56
78
  super(message);
57
79
  this.name = 'VeloxError';
58
80
  this.statusCode = statusCode;
59
81
  this.code = code;
82
+ // Look up catalog entry for enhanced error info
83
+ if (code && typeof code === 'string' && code.startsWith('VELOX-')) {
84
+ const entry = ERROR_CATALOG[code];
85
+ if (entry) {
86
+ this.fix = entry.fix?.suggestion;
87
+ this.docsUrl = entry.docsUrl;
88
+ }
89
+ }
60
90
  // Maintains proper stack trace for where error was thrown (V8 only)
61
91
  if (Error.captureStackTrace) {
62
92
  Error.captureStackTrace(this, VeloxError);
@@ -65,15 +95,38 @@ export class VeloxError extends Error {
65
95
  /**
66
96
  * Converts error to JSON format for API responses
67
97
  *
68
- * @returns Error response object
98
+ * @returns Error response object with optional fix suggestion in development
69
99
  */
70
100
  toJSON() {
71
- return {
101
+ const response = {
72
102
  error: this.name,
73
103
  message: this.message,
74
104
  statusCode: this.statusCode,
75
105
  code: this.code,
76
106
  };
107
+ // Include fix suggestion in development only
108
+ if (process.env.NODE_ENV !== 'production' && this.fix) {
109
+ response.fix = this.fix;
110
+ }
111
+ // Always include docs URL if available
112
+ if (this.docsUrl) {
113
+ response.docs = this.docsUrl;
114
+ }
115
+ return response;
116
+ }
117
+ /**
118
+ * Format error for terminal display with colors and fix suggestions
119
+ *
120
+ * @returns Formatted error string
121
+ */
122
+ format() {
123
+ return _formatError(this, this.code);
124
+ }
125
+ /**
126
+ * Log this error with pretty formatting
127
+ */
128
+ log() {
129
+ console.error(this.format());
77
130
  }
78
131
  }
79
132
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8GH;;GAEG;AACH,MAAM,UAAU,yBAAyB,CACvC,QAAuB;IAEvB,OAAO,QAAQ,CAAC,KAAK,KAAK,iBAAiB,CAAC;AAC9C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAAuB;IAEvB,OAAO,QAAQ,CAAC,KAAK,KAAK,eAAe,CAAC;AAC5C,CAAC;AAED,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,UAA0C,SAAQ,KAAK;IAClE;;OAEG;IACa,UAAU,CAAS;IAEnC;;OAEG;IACa,IAAI,CAAS;IAE7B;;;;;;OAMG;IACH,YAAY,OAAe,EAAE,aAAqB,GAAG,EAAE,IAAY;QACjE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAEjB,oEAAoE;QACpE,IAA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KAAc;IAC9C,OAAO,KAAK,YAAY,eAAe,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,KAAK,YAAY,aAAa,CAAC;AACxC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAc;IACjD,OAAO,KAAK,YAAY,kBAAkB,CAAC;AAC7C,CAAC;AAED,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,WAAW,CAAC,KAAY;IACtC,MAAM,IAAI,KAAK,CAAC,oBAAoB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AAC/D,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,24 +1,28 @@
1
1
  /**
2
2
  * @veloxts/core - Foundation package for the VeloxTS framework
3
3
  *
4
- * Provides the core Fastify wrapper, plugin system, and base context
5
- * that all other framework packages build upon.
4
+ * Provides the core Fastify wrapper, plugin system, base context,
5
+ * and dependency injection container that all other framework
6
+ * packages build upon.
6
7
  *
7
8
  * @example
8
9
  * ```typescript
9
- * import { createVeloxApp, definePlugin } from '@veloxts/core';
10
+ * import { veloxApp, definePlugin, Container, Injectable } from '@veloxts/core';
10
11
  *
11
- * const app = await createVeloxApp({ port: 3210 });
12
+ * const app = await veloxApp({ port: 3210 });
12
13
  * await app.start();
13
14
  * ```
14
15
  *
15
16
  * @module @veloxts/core
16
17
  */
18
+ import 'reflect-metadata';
17
19
  /** VeloxTS framework version */
18
20
  export declare const VELOX_VERSION: string;
19
- export { createVeloxApp, VeloxApp } from './app.js';
21
+ export { createVeloxApp, VeloxApp, veloxApp } from './app.js';
20
22
  export type { BaseContext } from './context.js';
21
- export { createContext, isContext } from './context.js';
23
+ export { createContext, isContext, setupTestContext } from './context.js';
24
+ export type { AbstractClass, ClassConstructor, ClassProvider, ContainerOptions, ExistingProvider, FactoryProvider, InjectableOptions, InjectionToken, Provider, ResolutionContext, StringToken, SymbolToken, TokenType, ValueProvider, } from './di/index.js';
25
+ export { asClass, asExisting, asFactory, asValue, Container, container, createContainer, createStringToken, createSymbolToken, factory, getConstructorTokens, getExplicitInjectTokens, getInjectableScope, getOptionalParams, getTokenName, Inject, Injectable, isClassProvider, isClassToken, isExistingProvider, isFactoryProvider, isInjectable, isStringToken, isSymbolToken, isValueProvider, makeInjectable, Optional, Scope, ScopeManager, scoped, setInjectTokens, singleton, token, transient, validateProvider, validateToken, value, } from './di/index.js';
22
26
  export type { ErrorResponse, GenericErrorResponse, NotFoundErrorResponse, ValidationErrorResponse, VeloxCoreErrorCode, VeloxErrorCode, VeloxErrorCodeRegistry, } from './errors.js';
23
27
  export { assertNever, ConfigurationError, isConfigurationError, isNotFoundError, isNotFoundErrorResponse, isValidationError, isValidationErrorResponse, isVeloxError, NotFoundError, ValidationError, VeloxError, } from './errors.js';
24
28
  export type { InferPluginOptions, PluginMetadata, PluginOptions, VeloxPlugin } from './plugin.js';