@hazeljs/core 0.3.1 → 0.4.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/dist/__tests__/container.test.js +176 -366
- package/dist/__tests__/enhanced-errors.test.d.ts +2 -0
- package/dist/__tests__/enhanced-errors.test.d.ts.map +1 -0
- package/dist/__tests__/enhanced-errors.test.js +315 -0
- package/dist/__tests__/performance.test.d.ts +2 -0
- package/dist/__tests__/performance.test.d.ts.map +1 -0
- package/dist/__tests__/performance.test.js +324 -0
- package/dist/container.d.ts +1 -0
- package/dist/container.d.ts.map +1 -1
- package/dist/container.js +31 -9
- package/dist/decorators.d.ts +4 -0
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +10 -0
- package/dist/enhanced-errors.d.ts +30 -0
- package/dist/enhanced-errors.d.ts.map +1 -0
- package/dist/enhanced-errors.js +227 -0
- package/dist/hazel-app.d.ts +10 -0
- package/dist/hazel-app.d.ts.map +1 -1
- package/dist/hazel-app.js +35 -6
- package/dist/hazel-module.d.ts +1 -0
- package/dist/hazel-module.d.ts.map +1 -1
- package/dist/hazel-module.js +14 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -3
- package/dist/performance.d.ts +49 -0
- package/dist/performance.d.ts.map +1 -0
- package/dist/performance.js +140 -0
- package/package.json +2 -2
package/dist/container.js
CHANGED
|
@@ -52,11 +52,16 @@ class Container {
|
|
|
52
52
|
*/
|
|
53
53
|
registerProvider(provider) {
|
|
54
54
|
const tokenName = this.getTokenName(provider.token);
|
|
55
|
-
logger_1.default.debug(`Registering provider configuration: ${tokenName}`);
|
|
55
|
+
logger_1.default.debug(`Registering provider configuration: ${tokenName} (lazy: ${provider.lazy || false})`);
|
|
56
56
|
const scope = provider.scope || Scope.SINGLETON;
|
|
57
|
-
const metadata = {
|
|
57
|
+
const metadata = {
|
|
58
|
+
scope,
|
|
59
|
+
lazy: provider.lazy,
|
|
60
|
+
loaded: false,
|
|
61
|
+
};
|
|
58
62
|
if (provider.useValue !== undefined) {
|
|
59
63
|
metadata.instance = provider.useValue;
|
|
64
|
+
metadata.loaded = true;
|
|
60
65
|
}
|
|
61
66
|
else if (provider.useFactory) {
|
|
62
67
|
metadata.factory = (requestId) => {
|
|
@@ -122,14 +127,31 @@ class Container {
|
|
|
122
127
|
throw new Error(`Singleton ${tokenName} is already being resolved (possible async race)`);
|
|
123
128
|
}
|
|
124
129
|
if (metadata.factory) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
metadata.
|
|
129
|
-
|
|
130
|
+
// Check if this is a lazy provider that hasn't been loaded yet
|
|
131
|
+
if (metadata.lazy && !metadata.loaded) {
|
|
132
|
+
logger_1.default.debug(`Lazy loading provider: ${tokenName}`);
|
|
133
|
+
metadata.isResolving = true;
|
|
134
|
+
try {
|
|
135
|
+
const result = metadata.factory(requestId);
|
|
136
|
+
metadata.instance = result;
|
|
137
|
+
metadata.loaded = true;
|
|
138
|
+
logger_1.default.debug(`Lazy loaded provider: ${tokenName}`);
|
|
139
|
+
return metadata.instance;
|
|
140
|
+
}
|
|
141
|
+
finally {
|
|
142
|
+
metadata.isResolving = false;
|
|
143
|
+
}
|
|
130
144
|
}
|
|
131
|
-
|
|
132
|
-
metadata.isResolving =
|
|
145
|
+
else {
|
|
146
|
+
metadata.isResolving = true;
|
|
147
|
+
try {
|
|
148
|
+
const result = metadata.factory(requestId);
|
|
149
|
+
metadata.instance = result;
|
|
150
|
+
return metadata.instance;
|
|
151
|
+
}
|
|
152
|
+
finally {
|
|
153
|
+
metadata.isResolving = false;
|
|
154
|
+
}
|
|
133
155
|
}
|
|
134
156
|
}
|
|
135
157
|
break;
|
package/dist/decorators.d.ts
CHANGED
|
@@ -67,6 +67,10 @@ export interface CanActivate {
|
|
|
67
67
|
export { HazelModule, Module } from './hazel-module';
|
|
68
68
|
export declare function Controller(options: ControllerOptions | string): ClassDecorator;
|
|
69
69
|
export declare function Injectable(options?: InjectableOptions): ClassDecorator;
|
|
70
|
+
/**
|
|
71
|
+
* Marks a provider as lazy-loaded - it will only be instantiated when first requested
|
|
72
|
+
*/
|
|
73
|
+
export declare function Lazy(): ClassDecorator;
|
|
70
74
|
export declare function Get(options?: {
|
|
71
75
|
path?: string;
|
|
72
76
|
} | string): MethodDecorator;
|
package/dist/decorators.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAoB,MAAM,4BAA4B,CAAC;AAChG,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAmB7C,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,mBAAmB,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9B,KAAK,CAAC,EAAE,YAAY,EAAE,CAAC;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,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M,EAAE,GAAG,cAAc,GAAG,eAAe,CAoB3E;AAED,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,MAAM,GAAG,eAAe,CAUnF;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,eAAe,CAczF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,GAAG,OAAO,EACrC,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAC5B,CAAC,GAAG,SAAS,CAMf;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,cAAc,CAAC;IACxB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,CAAC,GAAG,OAAO,EAC9C,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvF,kBAAkB,CAcpB;AA8CD,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
package/dist/decorators.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.HazelApp = exports.SkipAuth = exports.Module = exports.HazelModule = exports.CUSTOM_METADATA_PREFIX = void 0;
|
|
7
7
|
exports.Controller = Controller;
|
|
8
8
|
exports.Injectable = Injectable;
|
|
9
|
+
exports.Lazy = Lazy;
|
|
9
10
|
exports.Get = Get;
|
|
10
11
|
exports.Post = Post;
|
|
11
12
|
exports.Put = Put;
|
|
@@ -83,6 +84,15 @@ function Injectable(options = {}) {
|
|
|
83
84
|
}
|
|
84
85
|
};
|
|
85
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Marks a provider as lazy-loaded - it will only be instantiated when first requested
|
|
89
|
+
*/
|
|
90
|
+
function Lazy() {
|
|
91
|
+
return (target) => {
|
|
92
|
+
logger_1.default.debug(`Marking provider as lazy: ${target.constructor?.name || target.name}`);
|
|
93
|
+
Reflect.defineMetadata('hazel:lazy', true, target);
|
|
94
|
+
};
|
|
95
|
+
}
|
|
86
96
|
function Get(options) {
|
|
87
97
|
const opts = typeof options === 'string' ? { path: options } : options || {};
|
|
88
98
|
return createRouteDecorator('GET', opts);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { HttpError } from './errors/http.error';
|
|
2
|
+
export interface ErrorSuggestion {
|
|
3
|
+
message: string;
|
|
4
|
+
code?: string;
|
|
5
|
+
fix?: string;
|
|
6
|
+
relatedDocs?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface EnhancedError extends HttpError {
|
|
9
|
+
suggestions: ErrorSuggestion[];
|
|
10
|
+
context?: Record<string, unknown>;
|
|
11
|
+
requestId?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare class ErrorHandler {
|
|
14
|
+
private static suggestionMap;
|
|
15
|
+
private static initializeSuggestions;
|
|
16
|
+
static enhanceError(error: Error | HttpError, context?: Record<string, unknown>, requestId?: string): EnhancedError;
|
|
17
|
+
static getSuggestions(error: Error): ErrorSuggestion[];
|
|
18
|
+
static addCustomSuggestions(errorType: string, suggestions: ErrorSuggestion[]): void;
|
|
19
|
+
static formatErrorResponse(error: EnhancedError): Record<string, unknown>;
|
|
20
|
+
static logEnhancedError(error: EnhancedError): void;
|
|
21
|
+
}
|
|
22
|
+
export declare function createEnhancedError(message: string, statusCode?: number, suggestions?: ErrorSuggestion[], context?: Record<string, unknown>): EnhancedError;
|
|
23
|
+
export declare const EnhancedErrors: {
|
|
24
|
+
validationFailed: (details?: string) => EnhancedError;
|
|
25
|
+
unauthorized: (details?: string) => EnhancedError;
|
|
26
|
+
notFound: (resource?: string) => EnhancedError;
|
|
27
|
+
methodNotAllowed: (method?: string) => EnhancedError;
|
|
28
|
+
rateLimitExceeded: (retryAfter?: number) => EnhancedError;
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=enhanced-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enhanced-errors.d.ts","sourceRoot":"","sources":["../src/enhanced-errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,aAAc,SAAQ,SAAS;IAC9C,WAAW,EAAE,eAAe,EAAE,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,aAAa,CAAwC;IAOpE,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAkFpC,MAAM,CAAC,YAAY,CACjB,KAAK,EAAE,KAAK,GAAG,SAAS,EACxB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,SAAS,CAAC,EAAE,MAAM,GACjB,aAAa;IAqChB,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,KAAK,GAAG,eAAe,EAAE;IAkBtD,MAAM,CAAC,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,eAAe,EAAE,GAAG,IAAI;IAIpF,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IA0BzE,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI;CAapD;AAGD,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,MAAM,EACf,UAAU,GAAE,MAAY,EACxB,WAAW,CAAC,EAAE,eAAe,EAAE,EAC/B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAChC,aAAa,CAKf;AAGD,eAAO,MAAM,cAAc;iCACI,MAAM,KAAG,aAAa;6BAa1B,MAAM,KAAG,aAAa;0BAazB,MAAM,KAAG,aAAa;gCAahB,MAAM,KAAG,aAAa;qCAajB,MAAM,KAAG,aAAa;CAYxD,CAAC"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.EnhancedErrors = exports.ErrorHandler = void 0;
|
|
8
|
+
exports.createEnhancedError = createEnhancedError;
|
|
9
|
+
const http_error_1 = require("./errors/http.error");
|
|
10
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
11
|
+
class ErrorHandler {
|
|
12
|
+
static initializeSuggestions() {
|
|
13
|
+
// Validation errors
|
|
14
|
+
this.suggestionMap.set('ValidationError', [
|
|
15
|
+
{
|
|
16
|
+
message: 'Check your request body format and required fields',
|
|
17
|
+
code: 'VALIDATION_FAILED',
|
|
18
|
+
fix: 'Ensure all required fields are present and correctly typed. Check the API documentation for expected format.',
|
|
19
|
+
relatedDocs: '/docs/validation',
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
// Authentication errors
|
|
23
|
+
this.suggestionMap.set('UnauthorizedError', [
|
|
24
|
+
{
|
|
25
|
+
message: 'Authentication required or invalid credentials',
|
|
26
|
+
code: 'AUTH_REQUIRED',
|
|
27
|
+
fix: 'Provide a valid authentication token in the Authorization header.',
|
|
28
|
+
relatedDocs: '/docs/authentication',
|
|
29
|
+
},
|
|
30
|
+
]);
|
|
31
|
+
// Not found errors
|
|
32
|
+
this.suggestionMap.set('NotFoundError', [
|
|
33
|
+
{
|
|
34
|
+
message: 'Resource not found',
|
|
35
|
+
code: 'RESOURCE_NOT_FOUND',
|
|
36
|
+
fix: 'Check the resource ID and ensure it exists. Verify the endpoint path is correct.',
|
|
37
|
+
relatedDocs: '/docs/endpoints',
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
// Method not allowed
|
|
41
|
+
this.suggestionMap.set('MethodNotAllowedError', [
|
|
42
|
+
{
|
|
43
|
+
message: 'HTTP method not supported for this endpoint',
|
|
44
|
+
code: 'METHOD_NOT_ALLOWED',
|
|
45
|
+
fix: 'Check the allowed HTTP methods for this endpoint. Use GET for retrieving, POST for creating, PUT/PATCH for updating, DELETE for removing.',
|
|
46
|
+
relatedDocs: '/docs/http-methods',
|
|
47
|
+
},
|
|
48
|
+
]);
|
|
49
|
+
// Rate limit errors
|
|
50
|
+
this.suggestionMap.set('RateLimitError', [
|
|
51
|
+
{
|
|
52
|
+
message: 'Too many requests',
|
|
53
|
+
code: 'RATE_LIMIT_EXCEEDED',
|
|
54
|
+
fix: 'Wait before making another request. Implement exponential backoff in your client.',
|
|
55
|
+
relatedDocs: '/docs/rate-limiting',
|
|
56
|
+
},
|
|
57
|
+
]);
|
|
58
|
+
// Timeout errors
|
|
59
|
+
this.suggestionMap.set('TimeoutError', [
|
|
60
|
+
{
|
|
61
|
+
message: 'Request took too long to process',
|
|
62
|
+
code: 'REQUEST_TIMEOUT',
|
|
63
|
+
fix: 'Try again with a smaller payload or optimize your request. Consider implementing pagination.',
|
|
64
|
+
relatedDocs: '/docs/optimization',
|
|
65
|
+
},
|
|
66
|
+
]);
|
|
67
|
+
// Database errors
|
|
68
|
+
this.suggestionMap.set('DatabaseError', [
|
|
69
|
+
{
|
|
70
|
+
message: 'Database operation failed',
|
|
71
|
+
code: 'DATABASE_ERROR',
|
|
72
|
+
fix: 'Check database connection and retry. Contact support if the issue persists.',
|
|
73
|
+
relatedDocs: '/docs/database',
|
|
74
|
+
},
|
|
75
|
+
]);
|
|
76
|
+
// Dependency injection errors
|
|
77
|
+
this.suggestionMap.set('DependencyInjectionError', [
|
|
78
|
+
{
|
|
79
|
+
message: 'Dependency injection configuration issue',
|
|
80
|
+
code: 'DI_ERROR',
|
|
81
|
+
fix: 'Ensure all dependencies are properly registered in the module providers array.',
|
|
82
|
+
relatedDocs: '/docs/dependency-injection',
|
|
83
|
+
},
|
|
84
|
+
]);
|
|
85
|
+
}
|
|
86
|
+
static enhanceError(error, context, requestId) {
|
|
87
|
+
const enhancedError = error;
|
|
88
|
+
enhancedError.suggestions = this.getSuggestions(error);
|
|
89
|
+
enhancedError.context = context;
|
|
90
|
+
enhancedError.requestId = requestId;
|
|
91
|
+
// Add helpful context based on error type
|
|
92
|
+
if (error.message.includes('Cannot resolve dependency')) {
|
|
93
|
+
enhancedError.suggestions.push({
|
|
94
|
+
message: 'Dependency injection issue detected',
|
|
95
|
+
code: 'DEPENDENCY_RESOLUTION',
|
|
96
|
+
fix: 'Make sure the dependency is registered in the module providers or imported modules.',
|
|
97
|
+
relatedDocs: '/docs/dependency-injection',
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (error.message.includes('Route not found')) {
|
|
101
|
+
enhancedError.suggestions.push({
|
|
102
|
+
message: 'Route not found',
|
|
103
|
+
code: 'ROUTE_NOT_FOUND',
|
|
104
|
+
fix: 'Check the controller path and method decorators. Ensure the route is properly registered.',
|
|
105
|
+
relatedDocs: '/docs/routing',
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
if (error.message.includes('validation')) {
|
|
109
|
+
enhancedError.suggestions.push({
|
|
110
|
+
message: 'Validation failed',
|
|
111
|
+
code: 'VALIDATION_ERROR',
|
|
112
|
+
fix: 'Check your DTO class and validation decorators. Ensure required fields are marked.',
|
|
113
|
+
relatedDocs: '/docs/validation',
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
return enhancedError;
|
|
117
|
+
}
|
|
118
|
+
static getSuggestions(error) {
|
|
119
|
+
for (const [errorType, suggestions] of this.suggestionMap) {
|
|
120
|
+
if (error.constructor.name === errorType || error.message.includes(errorType)) {
|
|
121
|
+
return suggestions;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Default suggestions for unknown errors
|
|
125
|
+
return [
|
|
126
|
+
{
|
|
127
|
+
message: 'An unexpected error occurred',
|
|
128
|
+
code: 'UNKNOWN_ERROR',
|
|
129
|
+
fix: 'Check the server logs for more details. Contact support if the issue persists.',
|
|
130
|
+
relatedDocs: '/docs/troubleshooting',
|
|
131
|
+
},
|
|
132
|
+
];
|
|
133
|
+
}
|
|
134
|
+
static addCustomSuggestions(errorType, suggestions) {
|
|
135
|
+
this.suggestionMap.set(errorType, suggestions);
|
|
136
|
+
}
|
|
137
|
+
static formatErrorResponse(error) {
|
|
138
|
+
const response = {
|
|
139
|
+
error: {
|
|
140
|
+
message: error.message,
|
|
141
|
+
statusCode: error.statusCode || 500,
|
|
142
|
+
timestamp: new Date().toISOString(),
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
if (error.requestId) {
|
|
146
|
+
response.error.requestId = error.requestId;
|
|
147
|
+
}
|
|
148
|
+
// Include suggestions in development mode
|
|
149
|
+
if (process.env.NODE_ENV === 'development' && error.suggestions.length > 0) {
|
|
150
|
+
response.error.suggestions = error.suggestions;
|
|
151
|
+
}
|
|
152
|
+
// Include context in development mode
|
|
153
|
+
if (process.env.NODE_ENV === 'development' && error.context) {
|
|
154
|
+
response.error.context = error.context;
|
|
155
|
+
}
|
|
156
|
+
return response;
|
|
157
|
+
}
|
|
158
|
+
static logEnhancedError(error) {
|
|
159
|
+
logger_1.default.error(`Enhanced Error [${error.requestId || 'unknown'}]:`, {
|
|
160
|
+
message: error.message,
|
|
161
|
+
statusCode: error.statusCode || 500,
|
|
162
|
+
suggestions: error.suggestions.map(s => s.message),
|
|
163
|
+
context: error.context,
|
|
164
|
+
});
|
|
165
|
+
// Log suggestions in debug mode
|
|
166
|
+
if (process.env.NODE_ENV === 'development') {
|
|
167
|
+
logger_1.default.debug('Error suggestions:', error.suggestions);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
exports.ErrorHandler = ErrorHandler;
|
|
172
|
+
_a = ErrorHandler;
|
|
173
|
+
ErrorHandler.suggestionMap = new Map();
|
|
174
|
+
(() => {
|
|
175
|
+
// Initialize common error suggestions
|
|
176
|
+
_a.initializeSuggestions();
|
|
177
|
+
})();
|
|
178
|
+
// Helper function to create enhanced errors
|
|
179
|
+
function createEnhancedError(message, statusCode = 500, suggestions, context) {
|
|
180
|
+
const error = new http_error_1.HttpError(statusCode, message);
|
|
181
|
+
error.suggestions = suggestions || [];
|
|
182
|
+
error.context = context;
|
|
183
|
+
return error;
|
|
184
|
+
}
|
|
185
|
+
// Common enhanced error creators
|
|
186
|
+
exports.EnhancedErrors = {
|
|
187
|
+
validationFailed: (details) => createEnhancedError(`Validation failed${details ? `: ${details}` : ''}`, 400, [
|
|
188
|
+
{
|
|
189
|
+
message: 'Request validation failed',
|
|
190
|
+
code: 'VALIDATION_FAILED',
|
|
191
|
+
fix: 'Check your request body format and required fields',
|
|
192
|
+
relatedDocs: '/docs/validation',
|
|
193
|
+
},
|
|
194
|
+
]),
|
|
195
|
+
unauthorized: (details) => createEnhancedError(`Unauthorized${details ? `: ${details}` : ''}`, 401, [
|
|
196
|
+
{
|
|
197
|
+
message: 'Authentication required',
|
|
198
|
+
code: 'AUTH_REQUIRED',
|
|
199
|
+
fix: 'Provide valid authentication credentials',
|
|
200
|
+
relatedDocs: '/docs/authentication',
|
|
201
|
+
},
|
|
202
|
+
]),
|
|
203
|
+
notFound: (resource) => createEnhancedError(`${resource || 'Resource'} not found`, 404, [
|
|
204
|
+
{
|
|
205
|
+
message: 'Resource not found',
|
|
206
|
+
code: 'RESOURCE_NOT_FOUND',
|
|
207
|
+
fix: 'Check the resource ID and endpoint path',
|
|
208
|
+
relatedDocs: '/docs/endpoints',
|
|
209
|
+
},
|
|
210
|
+
]),
|
|
211
|
+
methodNotAllowed: (method) => createEnhancedError(`Method ${method || 'used'} not allowed`, 405, [
|
|
212
|
+
{
|
|
213
|
+
message: 'HTTP method not supported',
|
|
214
|
+
code: 'METHOD_NOT_ALLOWED',
|
|
215
|
+
fix: 'Check allowed HTTP methods for this endpoint',
|
|
216
|
+
relatedDocs: '/docs/http-methods',
|
|
217
|
+
},
|
|
218
|
+
]),
|
|
219
|
+
rateLimitExceeded: (retryAfter) => createEnhancedError('Rate limit exceeded', 429, [
|
|
220
|
+
{
|
|
221
|
+
message: 'Too many requests',
|
|
222
|
+
code: 'RATE_LIMIT_EXCEEDED',
|
|
223
|
+
fix: `Wait ${retryAfter || 'a few seconds'} before retrying`,
|
|
224
|
+
relatedDocs: '/docs/rate-limiting',
|
|
225
|
+
},
|
|
226
|
+
]),
|
|
227
|
+
};
|
package/dist/hazel-app.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import { ShutdownManager } from './shutdown';
|
|
|
8
8
|
import { HealthCheckManager } from './health';
|
|
9
9
|
import { TimeoutOptions } from './middleware/timeout.middleware';
|
|
10
10
|
import { CorsOptions } from './middleware/cors.middleware';
|
|
11
|
+
import { PerformanceHook, PerformanceMetrics } from './performance';
|
|
11
12
|
/** Early HTTP handler (e.g. for GraphQL) - receives raw req/res before body parsing */
|
|
12
13
|
export type EarlyHttpHandler = (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
|
|
13
14
|
/** Proxy handler - runs after body parsing, receives (req, res, context). Returns true if handled. */
|
|
@@ -21,6 +22,7 @@ export declare class HazelApp {
|
|
|
21
22
|
private module;
|
|
22
23
|
private shutdownManager;
|
|
23
24
|
private healthManager;
|
|
25
|
+
private performanceMonitor;
|
|
24
26
|
private requestTimeout;
|
|
25
27
|
private globalPrefix;
|
|
26
28
|
private corsEnabled;
|
|
@@ -37,6 +39,14 @@ export declare class HazelApp {
|
|
|
37
39
|
post(path: string, ...handlers: Array<(req: Request, res: Response) => void>): HazelApp;
|
|
38
40
|
put(path: string, ...handlers: Array<(req: Request, res: Response) => void>): HazelApp;
|
|
39
41
|
delete(path: string, ...handlers: Array<(req: Request, res: Response) => void>): HazelApp;
|
|
42
|
+
addPerformanceHook(hook: PerformanceHook): HazelApp;
|
|
43
|
+
removePerformanceHook(name: string): HazelApp;
|
|
44
|
+
getPerformanceMetrics(): {
|
|
45
|
+
activeRequests: number;
|
|
46
|
+
totalHooks: number;
|
|
47
|
+
averageResponseTime?: number;
|
|
48
|
+
};
|
|
49
|
+
getActiveRequests(): PerformanceMetrics[];
|
|
40
50
|
listen(port: number): Promise<void>;
|
|
41
51
|
private handleRoute;
|
|
42
52
|
/**
|
package/dist/hazel-app.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hazel-app.d.ts","sourceRoot":"","sources":["../src/hazel-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE/D,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI5D,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAuB,MAAM,UAAU,CAAC;AACnE,OAAO,EAAqB,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACpF,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EG;IACH,kBAAkB,IAAI,eAAe;IAIrC,YAAY,IAAI,SAAS;IAIzB;;;OAGG;IACH,SAAS,IAAI,MAAM,GAAG,IAAI;IAI1B,SAAS,IAAI,MAAM;IAInB;;OAEG;IACH,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAK9D;;;OAGG;IACH,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,YAAY,GAAG,IAAI;CAIjE"}
|
package/dist/hazel-app.js
CHANGED
|
@@ -17,6 +17,8 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
17
17
|
const shutdown_1 = require("./shutdown");
|
|
18
18
|
const health_1 = require("./health");
|
|
19
19
|
const timeout_middleware_1 = require("./middleware/timeout.middleware");
|
|
20
|
+
const performance_1 = require("./performance");
|
|
21
|
+
const enhanced_errors_1 = require("./enhanced-errors");
|
|
20
22
|
class HttpResponse {
|
|
21
23
|
constructor(res) {
|
|
22
24
|
this.res = res;
|
|
@@ -98,9 +100,14 @@ class HazelApp {
|
|
|
98
100
|
this.module = new hazel_module_1.HazelModuleInstance(this.moduleType);
|
|
99
101
|
this.shutdownManager = new shutdown_1.ShutdownManager();
|
|
100
102
|
this.healthManager = new health_1.HealthCheckManager();
|
|
103
|
+
this.performanceMonitor = new performance_1.PerformanceMonitor();
|
|
101
104
|
// Register built-in health checks
|
|
102
105
|
this.healthManager.registerCheck(health_1.BuiltInHealthChecks.memoryCheck());
|
|
103
106
|
this.healthManager.registerCheck(health_1.BuiltInHealthChecks.eventLoopCheck());
|
|
107
|
+
// Register default performance hooks
|
|
108
|
+
this.performanceMonitor.addHook(performance_1.BuiltinPerformanceHooks.slowRequestLogger(1000));
|
|
109
|
+
this.performanceMonitor.addHook(performance_1.BuiltinPerformanceHooks.memoryMonitor());
|
|
110
|
+
this.performanceMonitor.addHook(performance_1.BuiltinPerformanceHooks.metricsCollector());
|
|
104
111
|
this.initialize();
|
|
105
112
|
}
|
|
106
113
|
initialize() {
|
|
@@ -140,9 +147,26 @@ class HazelApp {
|
|
|
140
147
|
this.router.delete(path, handlers);
|
|
141
148
|
return this;
|
|
142
149
|
}
|
|
150
|
+
// Performance monitoring methods
|
|
151
|
+
addPerformanceHook(hook) {
|
|
152
|
+
this.performanceMonitor.addHook(hook);
|
|
153
|
+
return this;
|
|
154
|
+
}
|
|
155
|
+
removePerformanceHook(name) {
|
|
156
|
+
this.performanceMonitor.removeHook(name);
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
getPerformanceMetrics() {
|
|
160
|
+
return this.performanceMonitor.getMetrics();
|
|
161
|
+
}
|
|
162
|
+
getActiveRequests() {
|
|
163
|
+
return this.performanceMonitor.getActiveRequests();
|
|
164
|
+
}
|
|
143
165
|
async listen(port) {
|
|
144
166
|
return new Promise((resolve) => {
|
|
145
167
|
this.server = new http_1.Server(async (req, res) => {
|
|
168
|
+
// Start performance monitoring
|
|
169
|
+
const requestId = this.performanceMonitor.startRequest(req);
|
|
146
170
|
const startTime = Date.now();
|
|
147
171
|
const method = req.method || 'GET';
|
|
148
172
|
const url = req.url || '/';
|
|
@@ -154,6 +178,8 @@ class HazelApp {
|
|
|
154
178
|
const status = res.statusCode || 0;
|
|
155
179
|
const statusColor = status >= 500 ? chalk_1.default.red : status >= 400 ? chalk_1.default.yellow : chalk_1.default.green;
|
|
156
180
|
logger_1.default.info(`${chalk_1.default.bold(method)} ${path} ${statusColor(String(status))} ${chalk_1.default.gray(duration + 'ms')}`);
|
|
181
|
+
// End performance monitoring
|
|
182
|
+
this.performanceMonitor.endRequest(requestId, status);
|
|
157
183
|
});
|
|
158
184
|
try {
|
|
159
185
|
if (!req.url) {
|
|
@@ -342,12 +368,15 @@ class HazelApp {
|
|
|
342
368
|
await this.handleRoute(req, res, context);
|
|
343
369
|
}
|
|
344
370
|
catch (error) {
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
371
|
+
// Enhance the error with helpful suggestions
|
|
372
|
+
const enhancedError = enhanced_errors_1.ErrorHandler.enhanceError(error, { method: req.method, url: req.url, userAgent: req.headers['user-agent'] }, requestId);
|
|
373
|
+
enhanced_errors_1.ErrorHandler.logEnhancedError(enhancedError);
|
|
374
|
+
// End performance monitoring with error
|
|
375
|
+
this.performanceMonitor.endRequest(requestId, enhancedError.statusCode || 500, error);
|
|
376
|
+
// Format enhanced error response
|
|
377
|
+
const errorResponse = enhanced_errors_1.ErrorHandler.formatErrorResponse(enhancedError);
|
|
378
|
+
res.writeHead(enhancedError.statusCode || 500, { 'Content-Type': 'application/json' });
|
|
379
|
+
res.end(JSON.stringify(errorResponse));
|
|
351
380
|
}
|
|
352
381
|
});
|
|
353
382
|
this.server.listen(port, async () => {
|
package/dist/hazel-module.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface ModuleOptions {
|
|
|
15
15
|
controllers?: Type<unknown>[];
|
|
16
16
|
providers?: Type<unknown>[];
|
|
17
17
|
exports?: Type<unknown>[];
|
|
18
|
+
lazy?: boolean;
|
|
18
19
|
}
|
|
19
20
|
export declare function HazelModule(options: ModuleOptions): ClassDecorator;
|
|
20
21
|
export declare const Module: typeof HazelModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hazel-module.d.ts","sourceRoot":"","sources":["../src/hazel-module.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAS,MAAM,aAAa,CAAC;AAM/C,4DAA4D;AAC5D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;IACtB,WAAW,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,OAA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CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE,aAAa,GAAG,cAAc,CAIlE;AAGD,eAAO,MAAM,MAAM,oBAAc,CAAC;AAElC,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAa3E;AAED,uEAAuE;AACvE,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,aAAa,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,aAAa,EACxC,OAAO,qCAA2C,GACjD,SAAS,EAAE,CAkBb;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,aAAa,EACxC,OAAO,qCAA2C,GACjD,IAAI,CAAC,OAAO,CAAC,EAAE,CAuBjB;AAED,qBAAa,mBAAmB;IAGlB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAFvC,OAAO,CAAC,SAAS,CAAY;gBAEA,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,aAAa;IAOtE,OAAO,CAAC,UAAU;IAuHlB,YAAY,IAAI,SAAS;CAG1B"}
|
package/dist/hazel-module.js
CHANGED
|
@@ -105,22 +105,24 @@ class HazelModuleInstance {
|
|
|
105
105
|
return typeof val === 'symbol' ? val.toString() : val;
|
|
106
106
|
}));
|
|
107
107
|
metadata.providers.forEach((provider) => {
|
|
108
|
-
// Dynamic module provider: { provide, useFactory?, useClass?, useValue? }
|
|
108
|
+
// Dynamic module provider: { provide, useFactory?, useClass?, useValue?, lazy? }
|
|
109
109
|
if (provider && typeof provider === 'object' && ('provide' in provider || 'token' in provider)) {
|
|
110
110
|
const p = provider;
|
|
111
111
|
const token = p.token ?? p.provide;
|
|
112
|
-
logger_1.default.debug(`Registering provider config for: ${typeof token === 'symbol' ? token.toString() : token}`);
|
|
112
|
+
logger_1.default.debug(`Registering provider config for: ${typeof token === 'symbol' ? token.toString() : token} (lazy: ${p.lazy || false || metadata.lazy})`);
|
|
113
113
|
this.container.registerProvider({
|
|
114
114
|
token,
|
|
115
115
|
useFactory: p.useFactory,
|
|
116
116
|
useClass: p.useClass,
|
|
117
117
|
useValue: p.useValue,
|
|
118
118
|
inject: p.inject,
|
|
119
|
+
lazy: p.lazy || metadata.lazy, // Use provider-specific lazy setting or fall back to module-level
|
|
119
120
|
});
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
122
123
|
const cls = provider;
|
|
123
|
-
|
|
124
|
+
const isLazy = Reflect.getMetadata('hazel:lazy', cls) || metadata.lazy;
|
|
125
|
+
logger_1.default.debug(`Registering provider: ${cls?.name} (lazy: ${isLazy})`);
|
|
124
126
|
// Check if provider is request-scoped
|
|
125
127
|
const scope = Reflect.getMetadata('hazel:scope', cls);
|
|
126
128
|
if (scope === 'request') {
|
|
@@ -131,6 +133,15 @@ class HazelModuleInstance {
|
|
|
131
133
|
scope: container_1.Scope.REQUEST,
|
|
132
134
|
});
|
|
133
135
|
}
|
|
136
|
+
else if (isLazy) {
|
|
137
|
+
// Register as lazy provider
|
|
138
|
+
this.container.registerProvider({
|
|
139
|
+
token: cls,
|
|
140
|
+
useClass: cls,
|
|
141
|
+
scope: container_1.Scope.SINGLETON,
|
|
142
|
+
lazy: true,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
134
145
|
else {
|
|
135
146
|
// Eagerly resolve singleton and transient providers
|
|
136
147
|
this.container.register(cls, this.container.resolve(cls));
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { HealthCheckManager, BuiltInHealthChecks } from './health';
|
|
|
12
12
|
export type { HealthCheck, HealthCheckResult, HealthStatus } from './health';
|
|
13
13
|
export { TimeoutMiddleware } from './middleware/timeout.middleware';
|
|
14
14
|
export type { TimeoutOptions } from './middleware/timeout.middleware';
|
|
15
|
-
export { Controller, Injectable, Service, Get, Post, Put, Delete, Patch, Body, Param, Query, Req, Res, Ip, Host, Headers, HttpCode, Header, Redirect, Inject, UsePipes, UseInterceptors, UseGuards, Public, SkipAuth, AITask, Timeout, Optional, Session, Retry, ApiTags, ApiOperation, SetMetadata, getMetadata, createParamDecorator, CUSTOM_METADATA_PREFIX, type ControllerMetadata, type RouteMetadata, type ControllerOptions, type RouteOptions, type ServiceOptions, type InjectableOptions, type RepositoryOptions, type OnModuleInit, type OnModuleDestroy, type OnApplicationBootstrap, type ExecutionContext, type CanActivate, type RetryDecoratorOptions, type ApiOperationOptions, type ParamDecoratorContext, } from './decorators';
|
|
15
|
+
export { Controller, Injectable, Service, Get, Post, Put, Delete, Patch, Body, Param, Query, Req, Res, Ip, Host, Headers, HttpCode, Header, Redirect, Inject, UsePipes, UseInterceptors, UseGuards, Public, SkipAuth, AITask, Timeout, Optional, Session, Retry, ApiTags, ApiOperation, SetMetadata, getMetadata, createParamDecorator, Lazy, CUSTOM_METADATA_PREFIX, type ControllerMetadata, type RouteMetadata, type ControllerOptions, type RouteOptions, type ServiceOptions, type InjectableOptions, type RepositoryOptions, type OnModuleInit, type OnModuleDestroy, type OnApplicationBootstrap, type ExecutionContext, type CanActivate, type RetryDecoratorOptions, type ApiOperationOptions, type ParamDecoratorContext, } from './decorators';
|
|
16
16
|
export { Container, Scope, type InjectionToken, type Provider } from './container';
|
|
17
17
|
export type { Type, Request, Response, RequestContext, ValidationSchema } from './types';
|
|
18
18
|
export { HttpError, BadRequestError, UnauthorizedError, ForbiddenError, NotFoundError, ConflictError, InternalServerError, HttpException, BadRequestException, UnauthorizedException, ForbiddenException, NotFoundException, ConflictException, InternalServerErrorException, RequestTimeoutError, } from './errors/http.error';
|
|
@@ -38,4 +38,6 @@ export { RequestParser } from './request-parser';
|
|
|
38
38
|
export { RequestContext as RequestContextClass } from './request-context';
|
|
39
39
|
export { HazelResponse } from './hazel-response';
|
|
40
40
|
export { sanitizeHtml, sanitizeString, sanitizeUrl, sanitizeEmail, sanitizeSql, sanitizeObject, escapeHtml, } from './utils/sanitize';
|
|
41
|
+
export { PerformanceMonitor, BuiltinPerformanceHooks, type PerformanceHook, type PerformanceMetrics, type PerformanceOptions, } from './performance';
|
|
42
|
+
export { ErrorHandler, createEnhancedError, EnhancedErrors, type EnhancedError, type ErrorSuggestion, } from './enhanced-errors';
|
|
41
43
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,kBAAkB,CAAC;AAG1B,OAAO,EAAE,QAAQ,EAAE,KAAK,gBAAgB,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,EACL,WAAW,EACX,MAAM,EACN,mBAAmB,EACnB,iBAAiB,EACjB,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG9E,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AACnE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAG7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,YAAY,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAGtE,OAAO,EACL,UAAU,EACV,UAAU,EACV,OAAO,EACP,GAAG,EACH,IAAI,EACJ,GAA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