@webpieces/http-api 0.2.15 → 0.2.16
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/package.json +1 -1
- package/src/decorators.d.ts +2 -1
- package/src/decorators.js +2 -1
- package/src/decorators.js.map +1 -1
- package/src/errors.d.ts +118 -0
- package/src/errors.js +175 -0
- package/src/errors.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +25 -1
- package/src/index.js.map +1 -1
package/package.json
CHANGED
package/src/decorators.d.ts
CHANGED
|
@@ -18,7 +18,8 @@ export declare class RouteMetadata {
|
|
|
18
18
|
path: string;
|
|
19
19
|
methodName: string;
|
|
20
20
|
parameterTypes?: any[];
|
|
21
|
-
|
|
21
|
+
controllerClassName?: string;
|
|
22
|
+
constructor(httpMethod: string, path: string, methodName: string, parameterTypes?: any[], controllerClassName?: string);
|
|
22
23
|
}
|
|
23
24
|
/**
|
|
24
25
|
* Mark a class as an API interface.
|
package/src/decorators.js
CHANGED
|
@@ -26,11 +26,12 @@ exports.METADATA_KEYS = {
|
|
|
26
26
|
* Used by both server-side routing and client-side HTTP client generation.
|
|
27
27
|
*/
|
|
28
28
|
class RouteMetadata {
|
|
29
|
-
constructor(httpMethod, path, methodName, parameterTypes) {
|
|
29
|
+
constructor(httpMethod, path, methodName, parameterTypes, controllerClassName) {
|
|
30
30
|
this.httpMethod = httpMethod;
|
|
31
31
|
this.path = path;
|
|
32
32
|
this.methodName = methodName;
|
|
33
33
|
this.parameterTypes = parameterTypes;
|
|
34
|
+
this.controllerClassName = controllerClassName;
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
exports.RouteMetadata = RouteMetadata;
|
package/src/decorators.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../../../../packages/http/http-api/src/decorators.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"decorators.js","sourceRoot":"","sources":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,CAAC,KAAK,IAAI,CAAC;AAC/E,CAAC","sourcesContent":["import 'reflect-metadata';\n\n/**\n * Metadata keys for storing API routing information.\n * These keys are used by both server-side (routing) and client-side (client generation).\n */\nexport const METADATA_KEYS = {\n API_INTERFACE: 'webpieces:api-interface',\n ROUTES: 'webpieces:routes',\n HTTP_METHOD: 'webpieces:http-method',\n PATH: 'webpieces:path',\n};\n\n/**\n * Route metadata stored on methods.\n * Used by both server-side routing and client-side HTTP client generation.\n */\nexport class RouteMetadata {\n httpMethod: string;\n path: string;\n methodName: string;\n parameterTypes?: any[];\n controllerClassName?: string;\n\n constructor(\n httpMethod: string,\n path: string,\n methodName: string,\n parameterTypes?: any[],\n controllerClassName?: string,\n ) {\n this.httpMethod = httpMethod;\n this.path = path;\n this.methodName = methodName;\n this.parameterTypes = parameterTypes;\n this.controllerClassName = controllerClassName;\n }\n}\n\n/**\n * Mark a class as an API interface.\n * Similar to Java's JAX-RS interface pattern.\n *\n * This decorator is used by:\n * - Server: RESTApiRoutes reads it to validate API interfaces\n * - Client: Client generator reads it to identify API interfaces\n *\n * Usage:\n * ```typescript\n * @ApiInterface()\n * abstract class SaveApiPrototype {\n * @Post()\n * @Path('/search/item')\n * save(request: SaveRequest): Promise<SaveResponse> {\n * throw new Error('Must be implemented');\n * }\n * }\n * ```\n */\nexport function ApiInterface(): ClassDecorator {\n return (target: any) => {\n Reflect.defineMetadata(METADATA_KEYS.API_INTERFACE, true, target);\n\n // Initialize routes array if not exists\n if (!Reflect.hasMetadata(METADATA_KEYS.ROUTES, target)) {\n Reflect.defineMetadata(METADATA_KEYS.ROUTES, [], target);\n }\n };\n}\n\n/**\n * Internal helper to mark a method with an HTTP method.\n * Used by @Get, @Post, @Put, @Delete, @Patch decorators.\n */\nfunction httpMethod(method: string): MethodDecorator {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n // For static methods, target is the constructor itself\n // For instance methods, target is the prototype\n const metadataTarget = typeof target === 'function' ? target : target.constructor;\n\n const existingMetadata = Reflect.getMetadata(METADATA_KEYS.ROUTES, metadataTarget) || [];\n\n // Find or create route metadata for this method\n let routeMetadata = existingMetadata.find(\n (r: RouteMetadata) => r.methodName === propertyKey,\n );\n\n if (!routeMetadata) {\n routeMetadata = new RouteMetadata('', '', propertyKey as string);\n existingMetadata.push(routeMetadata);\n }\n\n routeMetadata.httpMethod = method;\n\n // Get parameter types\n const paramTypes = Reflect.getMetadata('design:paramtypes', target, propertyKey);\n if (paramTypes) {\n routeMetadata.parameterTypes = paramTypes;\n }\n\n Reflect.defineMetadata(METADATA_KEYS.ROUTES, existingMetadata, metadataTarget);\n };\n}\n\n/**\n * @Get decorator for GET requests.\n * Usage: @Get()\n */\nexport function Get(): MethodDecorator {\n return httpMethod('GET');\n}\n\n/**\n * @Post decorator for POST requests.\n * Usage: @Post()\n */\nexport function Post(): MethodDecorator {\n return httpMethod('POST');\n}\n\n/**\n * @Put decorator for PUT requests.\n * Usage: @Put()\n */\nexport function Put(): MethodDecorator {\n return httpMethod('PUT');\n}\n\n/**\n * @Delete decorator for DELETE requests.\n * Usage: @Delete()\n */\nexport function Delete(): MethodDecorator {\n return httpMethod('DELETE');\n}\n\n/**\n * @Patch decorator for PATCH requests.\n * Usage: @Patch()\n */\nexport function Patch(): MethodDecorator {\n return httpMethod('PATCH');\n}\n\n/**\n * @Path decorator to specify the route path.\n * Similar to JAX-RS @Path annotation.\n *\n * This decorator is used by:\n * - Server: To register routes at the specified path\n * - Client: To make HTTP requests to the specified path\n *\n * Usage:\n * ```typescript\n * @Post()\n * @Path('/search/item')\n * save(request: SaveRequest): Promise<SaveResponse> {\n * throw new Error('Must be implemented');\n * }\n * ```\n */\nexport function Path(path: string): MethodDecorator {\n return (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) => {\n // For static methods, target is the constructor itself\n // For instance methods, target is the prototype\n const metadataTarget = typeof target === 'function' ? target : target.constructor;\n\n const existingMetadata = Reflect.getMetadata(METADATA_KEYS.ROUTES, metadataTarget) || [];\n\n // Find or create route metadata for this method\n let routeMetadata = existingMetadata.find(\n (r: RouteMetadata) => r.methodName === propertyKey,\n );\n\n if (!routeMetadata) {\n routeMetadata = new RouteMetadata('', '', propertyKey as string);\n existingMetadata.push(routeMetadata);\n }\n\n routeMetadata.path = path;\n\n Reflect.defineMetadata(METADATA_KEYS.ROUTES, existingMetadata, metadataTarget);\n };\n}\n\n/**\n * Helper function to get all routes from an API interface class.\n * Used by both server-side routing and client-side client generation.\n */\nexport function getRoutes(apiClass: any): RouteMetadata[] {\n const routes = Reflect.getMetadata(METADATA_KEYS.ROUTES, apiClass);\n return routes || [];\n}\n\n/**\n * Helper function to check if a class is an API interface.\n * Used by both server-side routing and client-side client generation.\n */\nexport function isApiInterface(apiClass: any): boolean {\n return Reflect.getMetadata(METADATA_KEYS.API_INTERFACE, apiClass) === true;\n}\n"]}
|
package/src/errors.d.ts
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP Error classes for webpieces-ts.
|
|
3
|
+
* These errors are used throughout the framework for consistent error handling.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* ProtocolError - Data class for error response body.
|
|
7
|
+
* This is what gets serialized and sent to the client.
|
|
8
|
+
*/
|
|
9
|
+
export declare class ProtocolError {
|
|
10
|
+
message?: string;
|
|
11
|
+
subType?: string;
|
|
12
|
+
field?: string;
|
|
13
|
+
waitSeconds?: number;
|
|
14
|
+
name?: string;
|
|
15
|
+
guiAlertMessage?: string;
|
|
16
|
+
errorCode?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* HttpError - Base error class with HTTP status code.
|
|
20
|
+
* All specific HTTP errors extend this class.
|
|
21
|
+
*/
|
|
22
|
+
export declare class HttpError extends Error {
|
|
23
|
+
code: number;
|
|
24
|
+
subType?: string;
|
|
25
|
+
readonly httpCause?: Error;
|
|
26
|
+
constructor(message: string, code: number, subType?: string, cause?: Error);
|
|
27
|
+
}
|
|
28
|
+
export declare const ENTITY_NOT_FOUND = "EntityNotFoundError";
|
|
29
|
+
export declare const WRONG_LOGIN_TYPE = "wrongLoginType";
|
|
30
|
+
export declare const WRONG_LOGIN = "wronglogin";
|
|
31
|
+
export declare const NOT_APPROVED = "notapproved";
|
|
32
|
+
export declare const EMAIL_NOT_CONFIRMED = "email_not_confirmed";
|
|
33
|
+
export declare const WRONG_DOMAIN = "wrongdomain";
|
|
34
|
+
export declare const WRONG_COMPANY = "wrongcompany";
|
|
35
|
+
export declare const NO_REG_CODE = "noregcode";
|
|
36
|
+
/**
|
|
37
|
+
* HttpNotFoundError - 404 Not Found.
|
|
38
|
+
*/
|
|
39
|
+
export declare class HttpNotFoundError extends HttpError {
|
|
40
|
+
constructor(message: string, cause?: Error);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* EndpointNotFoundError - 404 for missing endpoints.
|
|
44
|
+
*/
|
|
45
|
+
export declare class EndpointNotFoundError extends HttpNotFoundError {
|
|
46
|
+
constructor(message: string, cause?: Error);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* HttpBadRequestError - 400 Bad Request.
|
|
50
|
+
* Used for validation errors with optional field and GUI message.
|
|
51
|
+
*/
|
|
52
|
+
export declare class HttpBadRequestError extends HttpError {
|
|
53
|
+
field?: string;
|
|
54
|
+
guiMessage?: string;
|
|
55
|
+
constructor(message: string, field?: string, guiMessage?: string, cause?: Error);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* HttpUnauthorizedError - 401 Unauthorized.
|
|
59
|
+
*/
|
|
60
|
+
export declare class HttpUnauthorizedError extends HttpError {
|
|
61
|
+
constructor(message: string, subType?: string, cause?: Error);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* HttpForbiddenError - 403 Forbidden.
|
|
65
|
+
*/
|
|
66
|
+
export declare class HttpForbiddenError extends HttpError {
|
|
67
|
+
constructor(message: string, cause?: Error);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* HttpTimeoutError - 408 Request Timeout.
|
|
71
|
+
*/
|
|
72
|
+
export declare class HttpTimeoutError extends HttpError {
|
|
73
|
+
constructor(message: string, cause?: Error);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* HttpBadGatewayError - 502 Bad Gateway.
|
|
77
|
+
*/
|
|
78
|
+
export declare class HttpBadGatewayError extends HttpError {
|
|
79
|
+
constructor(message: string, cause?: Error);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* HttpGatewayTimeoutError - 504 Gateway Timeout.
|
|
83
|
+
* SHOULD NOT BE USED SERVER SIDE SINCE ALBs will return 504 and it will not be translated
|
|
84
|
+
* to json body 'ProtocolError'.
|
|
85
|
+
*/
|
|
86
|
+
export declare class HttpGatewayTimeoutError extends HttpError {
|
|
87
|
+
constructor(message: string, cause?: Error);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* HttpInternalServerError - 500 Internal Server Error.
|
|
91
|
+
*/
|
|
92
|
+
export declare class HttpInternalServerError extends HttpError {
|
|
93
|
+
constructor(message: string, cause?: Error);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* HttpVendorError - 598 Vendor Error.
|
|
97
|
+
* Custom status code for vendor/external service errors with retry hint.
|
|
98
|
+
*/
|
|
99
|
+
export declare class HttpVendorError extends HttpError {
|
|
100
|
+
waitSeconds: number;
|
|
101
|
+
constructor(message: string, waitSeconds?: number, cause?: Error);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* HttpUserError - User validation error with 2xx status code.
|
|
105
|
+
*
|
|
106
|
+
* Uses HTTP 266 (non-standard 2xx code) intentionally because:
|
|
107
|
+
* 1. User validation errors are "successful" from server perspective - user just made a mistake
|
|
108
|
+
* 2. Browser DevTools show 4xx/5xx codes in RED, which is confusing for user validation
|
|
109
|
+
* 3. Allows error to propagate up the stack via throw without triggering error monitoring
|
|
110
|
+
* 4. Avoids polluting logs with "errors" that are actually expected user behavior
|
|
111
|
+
*
|
|
112
|
+
* This is a deliberate design pattern - do NOT change to 4xx codes.
|
|
113
|
+
* Examples: "Email already exists", "Invalid password format", "Required field missing"
|
|
114
|
+
*/
|
|
115
|
+
export declare class HttpUserError extends HttpError {
|
|
116
|
+
errorCode?: string;
|
|
117
|
+
constructor(message: string, errorCode?: string, cause?: Error);
|
|
118
|
+
}
|
package/src/errors.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* HTTP Error classes for webpieces-ts.
|
|
4
|
+
* These errors are used throughout the framework for consistent error handling.
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.HttpUserError = exports.HttpVendorError = exports.HttpInternalServerError = exports.HttpGatewayTimeoutError = exports.HttpBadGatewayError = exports.HttpTimeoutError = exports.HttpForbiddenError = exports.HttpUnauthorizedError = exports.HttpBadRequestError = exports.EndpointNotFoundError = exports.HttpNotFoundError = exports.NO_REG_CODE = exports.WRONG_COMPANY = exports.WRONG_DOMAIN = exports.EMAIL_NOT_CONFIRMED = exports.NOT_APPROVED = exports.WRONG_LOGIN = exports.WRONG_LOGIN_TYPE = exports.ENTITY_NOT_FOUND = exports.HttpError = exports.ProtocolError = void 0;
|
|
8
|
+
/**
|
|
9
|
+
* ProtocolError - Data class for error response body.
|
|
10
|
+
* This is what gets serialized and sent to the client.
|
|
11
|
+
*/
|
|
12
|
+
class ProtocolError {
|
|
13
|
+
}
|
|
14
|
+
exports.ProtocolError = ProtocolError;
|
|
15
|
+
/**
|
|
16
|
+
* HttpError - Base error class with HTTP status code.
|
|
17
|
+
* All specific HTTP errors extend this class.
|
|
18
|
+
*/
|
|
19
|
+
class HttpError extends Error {
|
|
20
|
+
constructor(message, code, subType, cause) {
|
|
21
|
+
super(message);
|
|
22
|
+
this.code = code;
|
|
23
|
+
this.subType = subType;
|
|
24
|
+
this.httpCause = cause;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.HttpError = HttpError;
|
|
28
|
+
// Error subtype constants
|
|
29
|
+
exports.ENTITY_NOT_FOUND = 'EntityNotFoundError';
|
|
30
|
+
exports.WRONG_LOGIN_TYPE = 'wrongLoginType';
|
|
31
|
+
exports.WRONG_LOGIN = 'wronglogin';
|
|
32
|
+
exports.NOT_APPROVED = 'notapproved';
|
|
33
|
+
exports.EMAIL_NOT_CONFIRMED = 'email_not_confirmed';
|
|
34
|
+
exports.WRONG_DOMAIN = 'wrongdomain';
|
|
35
|
+
exports.WRONG_COMPANY = 'wrongcompany';
|
|
36
|
+
exports.NO_REG_CODE = 'noregcode';
|
|
37
|
+
/**
|
|
38
|
+
* HttpNotFoundError - 404 Not Found.
|
|
39
|
+
*/
|
|
40
|
+
class HttpNotFoundError extends HttpError {
|
|
41
|
+
constructor(message, cause) {
|
|
42
|
+
super(message, 404, undefined, cause);
|
|
43
|
+
this.name = exports.ENTITY_NOT_FOUND;
|
|
44
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.HttpNotFoundError = HttpNotFoundError;
|
|
48
|
+
/**
|
|
49
|
+
* EndpointNotFoundError - 404 for missing endpoints.
|
|
50
|
+
*/
|
|
51
|
+
class EndpointNotFoundError extends HttpNotFoundError {
|
|
52
|
+
constructor(message, cause) {
|
|
53
|
+
super(message, cause);
|
|
54
|
+
this.name = 'EndpointNotFoundError';
|
|
55
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.EndpointNotFoundError = EndpointNotFoundError;
|
|
59
|
+
/**
|
|
60
|
+
* HttpBadRequestError - 400 Bad Request.
|
|
61
|
+
* Used for validation errors with optional field and GUI message.
|
|
62
|
+
*/
|
|
63
|
+
class HttpBadRequestError extends HttpError {
|
|
64
|
+
constructor(message, field, guiMessage, cause) {
|
|
65
|
+
super(message, 400, undefined, cause);
|
|
66
|
+
this.name = 'BadRequest';
|
|
67
|
+
this.field = field;
|
|
68
|
+
this.guiMessage = guiMessage;
|
|
69
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.HttpBadRequestError = HttpBadRequestError;
|
|
73
|
+
/**
|
|
74
|
+
* HttpUnauthorizedError - 401 Unauthorized.
|
|
75
|
+
*/
|
|
76
|
+
class HttpUnauthorizedError extends HttpError {
|
|
77
|
+
constructor(message, subType, cause) {
|
|
78
|
+
super(message, 401, subType, cause);
|
|
79
|
+
this.name = 'Unauthorized';
|
|
80
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
exports.HttpUnauthorizedError = HttpUnauthorizedError;
|
|
84
|
+
/**
|
|
85
|
+
* HttpForbiddenError - 403 Forbidden.
|
|
86
|
+
*/
|
|
87
|
+
class HttpForbiddenError extends HttpError {
|
|
88
|
+
constructor(message, cause) {
|
|
89
|
+
super(message, 403, undefined, cause);
|
|
90
|
+
this.name = 'Forbidden';
|
|
91
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.HttpForbiddenError = HttpForbiddenError;
|
|
95
|
+
/**
|
|
96
|
+
* HttpTimeoutError - 408 Request Timeout.
|
|
97
|
+
*/
|
|
98
|
+
class HttpTimeoutError extends HttpError {
|
|
99
|
+
constructor(message, cause) {
|
|
100
|
+
super(message, 408, undefined, cause);
|
|
101
|
+
this.name = 'Timeout';
|
|
102
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
exports.HttpTimeoutError = HttpTimeoutError;
|
|
106
|
+
/**
|
|
107
|
+
* HttpBadGatewayError - 502 Bad Gateway.
|
|
108
|
+
*/
|
|
109
|
+
class HttpBadGatewayError extends HttpError {
|
|
110
|
+
constructor(message, cause) {
|
|
111
|
+
super(message, 502, undefined, cause);
|
|
112
|
+
this.name = 'HttpBadGatewayError';
|
|
113
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.HttpBadGatewayError = HttpBadGatewayError;
|
|
117
|
+
/**
|
|
118
|
+
* HttpGatewayTimeoutError - 504 Gateway Timeout.
|
|
119
|
+
* SHOULD NOT BE USED SERVER SIDE SINCE ALBs will return 504 and it will not be translated
|
|
120
|
+
* to json body 'ProtocolError'.
|
|
121
|
+
*/
|
|
122
|
+
class HttpGatewayTimeoutError extends HttpError {
|
|
123
|
+
constructor(message, cause) {
|
|
124
|
+
super(message, 504, undefined, cause);
|
|
125
|
+
this.name = 'HttpGatewayTimeoutError';
|
|
126
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
exports.HttpGatewayTimeoutError = HttpGatewayTimeoutError;
|
|
130
|
+
/**
|
|
131
|
+
* HttpInternalServerError - 500 Internal Server Error.
|
|
132
|
+
*/
|
|
133
|
+
class HttpInternalServerError extends HttpError {
|
|
134
|
+
constructor(message, cause) {
|
|
135
|
+
super(message, 500, undefined, cause);
|
|
136
|
+
this.name = 'InternalServerError';
|
|
137
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
exports.HttpInternalServerError = HttpInternalServerError;
|
|
141
|
+
/**
|
|
142
|
+
* HttpVendorError - 598 Vendor Error.
|
|
143
|
+
* Custom status code for vendor/external service errors with retry hint.
|
|
144
|
+
*/
|
|
145
|
+
class HttpVendorError extends HttpError {
|
|
146
|
+
constructor(message, waitSeconds = 30, cause) {
|
|
147
|
+
super(message, 598, undefined, cause);
|
|
148
|
+
this.waitSeconds = waitSeconds;
|
|
149
|
+
this.name = 'VendorError';
|
|
150
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.HttpVendorError = HttpVendorError;
|
|
154
|
+
/**
|
|
155
|
+
* HttpUserError - User validation error with 2xx status code.
|
|
156
|
+
*
|
|
157
|
+
* Uses HTTP 266 (non-standard 2xx code) intentionally because:
|
|
158
|
+
* 1. User validation errors are "successful" from server perspective - user just made a mistake
|
|
159
|
+
* 2. Browser DevTools show 4xx/5xx codes in RED, which is confusing for user validation
|
|
160
|
+
* 3. Allows error to propagate up the stack via throw without triggering error monitoring
|
|
161
|
+
* 4. Avoids polluting logs with "errors" that are actually expected user behavior
|
|
162
|
+
*
|
|
163
|
+
* This is a deliberate design pattern - do NOT change to 4xx codes.
|
|
164
|
+
* Examples: "Email already exists", "Invalid password format", "Required field missing"
|
|
165
|
+
*/
|
|
166
|
+
class HttpUserError extends HttpError {
|
|
167
|
+
constructor(message, errorCode, cause) {
|
|
168
|
+
super(message, 266, 'USER_ERROR', cause);
|
|
169
|
+
this.name = 'UserError';
|
|
170
|
+
this.errorCode = errorCode;
|
|
171
|
+
Object.setPrototypeOf(this, new.target.prototype);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.HttpUserError = HttpUserError;
|
|
175
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../../../packages/http/http-api/src/errors.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;GAGG;AACH,MAAa,aAAa;CAQzB;AARD,sCAQC;AAED;;;GAGG;AACH,MAAa,SAAU,SAAQ,KAAK;IAKhC,YACI,OAAe,EACf,IAAY,EACZ,OAAgB,EAChB,KAAa;QAEb,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;CACJ;AAhBD,8BAgBC;AAED,0BAA0B;AACb,QAAA,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CAAC,IAAI,GAAG,WAAW,CAAC;QACxB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACtD,CAAC;CACJ;AATD,sCASC","sourcesContent":["/**\n * HTTP Error classes for webpieces-ts.\n * These errors are used throughout the framework for consistent error handling.\n */\n\n/**\n * ProtocolError - Data class for error response body.\n * This is what gets serialized and sent to the client.\n */\nexport class ProtocolError {\n public message?: string;\n public subType?: string;\n public field?: string;\n public waitSeconds?: number;\n public name?: string;\n public guiAlertMessage?: string;\n public errorCode?: string;\n}\n\n/**\n * HttpError - Base error class with HTTP status code.\n * All specific HTTP errors extend this class.\n */\nexport class HttpError extends Error {\n public code: number;\n public subType?: string;\n public readonly httpCause?: Error;\n\n constructor(\n message: string,\n code: number,\n subType?: string,\n cause?: Error,\n ) {\n super(message);\n this.code = code;\n this.subType = subType;\n this.httpCause = cause;\n }\n}\n\n// Error subtype constants\nexport const ENTITY_NOT_FOUND = 'EntityNotFoundError';\nexport const WRONG_LOGIN_TYPE = 'wrongLoginType';\nexport const WRONG_LOGIN = 'wronglogin';\nexport const NOT_APPROVED = 'notapproved';\nexport const EMAIL_NOT_CONFIRMED = 'email_not_confirmed';\nexport const WRONG_DOMAIN = 'wrongdomain';\nexport const WRONG_COMPANY = 'wrongcompany';\nexport const NO_REG_CODE = 'noregcode';\n\n/**\n * HttpNotFoundError - 404 Not Found.\n */\nexport class HttpNotFoundError extends HttpError {\n constructor(message: string, cause?: Error) {\n super(message, 404, undefined, cause);\n this.name = ENTITY_NOT_FOUND;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * EndpointNotFoundError - 404 for missing endpoints.\n */\nexport class EndpointNotFoundError extends HttpNotFoundError {\n constructor(message: string, cause?: Error) {\n super(message, cause);\n this.name = 'EndpointNotFoundError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * HttpBadRequestError - 400 Bad Request.\n * Used for validation errors with optional field and GUI message.\n */\nexport class HttpBadRequestError extends HttpError {\n public field?: string;\n public guiMessage?: string;\n\n constructor(message: string, field?: string, guiMessage?: string, cause?: Error) {\n super(message, 400, undefined, cause);\n this.name = 'BadRequest';\n this.field = field;\n this.guiMessage = guiMessage;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * HttpUnauthorizedError - 401 Unauthorized.\n */\nexport class HttpUnauthorizedError extends HttpError {\n constructor(message: string, subType?: string, cause?: Error) {\n super(message, 401, subType, cause);\n this.name = 'Unauthorized';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * HttpForbiddenError - 403 Forbidden.\n */\nexport class HttpForbiddenError extends HttpError {\n constructor(message: string, cause?: Error) {\n super(message, 403, undefined, cause);\n this.name = 'Forbidden';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * HttpTimeoutError - 408 Request Timeout.\n */\nexport class HttpTimeoutError extends HttpError {\n constructor(message: string, cause?: Error) {\n super(message, 408, undefined, cause);\n this.name = 'Timeout';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * HttpBadGatewayError - 502 Bad Gateway.\n */\nexport class HttpBadGatewayError extends HttpError {\n constructor(message: string, cause?: Error) {\n super(message, 502, undefined, cause);\n this.name = 'HttpBadGatewayError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * HttpGatewayTimeoutError - 504 Gateway Timeout.\n * SHOULD NOT BE USED SERVER SIDE SINCE ALBs will return 504 and it will not be translated\n * to json body 'ProtocolError'.\n */\nexport class HttpGatewayTimeoutError extends HttpError {\n constructor(message: string, cause?: Error) {\n super(message, 504, undefined, cause);\n this.name = 'HttpGatewayTimeoutError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * HttpInternalServerError - 500 Internal Server Error.\n */\nexport class HttpInternalServerError extends HttpError {\n constructor(message: string, cause?: Error) {\n super(message, 500, undefined, cause);\n this.name = 'InternalServerError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * HttpVendorError - 598 Vendor Error.\n * Custom status code for vendor/external service errors with retry hint.\n */\nexport class HttpVendorError extends HttpError {\n constructor(\n message: string,\n public waitSeconds = 30,\n cause?: Error,\n ) {\n super(message, 598, undefined, cause);\n this.name = 'VendorError';\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n\n/**\n * HttpUserError - User validation error with 2xx status code.\n *\n * Uses HTTP 266 (non-standard 2xx code) intentionally because:\n * 1. User validation errors are \"successful\" from server perspective - user just made a mistake\n * 2. Browser DevTools show 4xx/5xx codes in RED, which is confusing for user validation\n * 3. Allows error to propagate up the stack via throw without triggering error monitoring\n * 4. Avoids polluting logs with \"errors\" that are actually expected user behavior\n *\n * This is a deliberate design pattern - do NOT change to 4xx codes.\n * Examples: \"Email already exists\", \"Invalid password format\", \"Required field missing\"\n */\nexport class HttpUserError extends HttpError {\n public errorCode?: string;\n\n constructor(message: string, errorCode?: string, cause?: Error) {\n super(message, 266, 'USER_ERROR', cause);\n this.name = 'UserError';\n this.errorCode = errorCode;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n"]}
|
package/src/index.d.ts
CHANGED
|
@@ -18,3 +18,4 @@
|
|
|
18
18
|
*/
|
|
19
19
|
export { ApiInterface, Get, Post, Put, Delete, Patch, Path, getRoutes, isApiInterface, RouteMetadata, METADATA_KEYS, } from './decorators';
|
|
20
20
|
export { ValidateImplementation } from './validators';
|
|
21
|
+
export { ProtocolError, HttpError, HttpNotFoundError, EndpointNotFoundError, HttpBadRequestError, HttpUnauthorizedError, HttpForbiddenError, HttpTimeoutError, HttpBadGatewayError, HttpGatewayTimeoutError, HttpInternalServerError, HttpVendorError, HttpUserError, ENTITY_NOT_FOUND, WRONG_LOGIN_TYPE, WRONG_LOGIN, NOT_APPROVED, EMAIL_NOT_CONFIRMED, WRONG_DOMAIN, WRONG_COMPANY, NO_REG_CODE, } from './errors';
|
package/src/index.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.METADATA_KEYS = exports.RouteMetadata = exports.isApiInterface = exports.getRoutes = exports.Path = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = exports.ApiInterface = void 0;
|
|
21
|
+
exports.NO_REG_CODE = exports.WRONG_COMPANY = exports.WRONG_DOMAIN = exports.EMAIL_NOT_CONFIRMED = exports.NOT_APPROVED = exports.WRONG_LOGIN = exports.WRONG_LOGIN_TYPE = exports.ENTITY_NOT_FOUND = exports.HttpUserError = exports.HttpVendorError = exports.HttpInternalServerError = exports.HttpGatewayTimeoutError = exports.HttpBadGatewayError = exports.HttpTimeoutError = exports.HttpForbiddenError = exports.HttpUnauthorizedError = exports.HttpBadRequestError = exports.EndpointNotFoundError = exports.HttpNotFoundError = exports.HttpError = exports.ProtocolError = exports.METADATA_KEYS = exports.RouteMetadata = exports.isApiInterface = exports.getRoutes = exports.Path = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = exports.ApiInterface = void 0;
|
|
22
22
|
// API definition decorators
|
|
23
23
|
var decorators_1 = require("./decorators");
|
|
24
24
|
Object.defineProperty(exports, "ApiInterface", { enumerable: true, get: function () { return decorators_1.ApiInterface; } });
|
|
@@ -32,4 +32,28 @@ Object.defineProperty(exports, "getRoutes", { enumerable: true, get: function ()
|
|
|
32
32
|
Object.defineProperty(exports, "isApiInterface", { enumerable: true, get: function () { return decorators_1.isApiInterface; } });
|
|
33
33
|
Object.defineProperty(exports, "RouteMetadata", { enumerable: true, get: function () { return decorators_1.RouteMetadata; } });
|
|
34
34
|
Object.defineProperty(exports, "METADATA_KEYS", { enumerable: true, get: function () { return decorators_1.METADATA_KEYS; } });
|
|
35
|
+
// HTTP errors
|
|
36
|
+
var errors_1 = require("./errors");
|
|
37
|
+
Object.defineProperty(exports, "ProtocolError", { enumerable: true, get: function () { return errors_1.ProtocolError; } });
|
|
38
|
+
Object.defineProperty(exports, "HttpError", { enumerable: true, get: function () { return errors_1.HttpError; } });
|
|
39
|
+
Object.defineProperty(exports, "HttpNotFoundError", { enumerable: true, get: function () { return errors_1.HttpNotFoundError; } });
|
|
40
|
+
Object.defineProperty(exports, "EndpointNotFoundError", { enumerable: true, get: function () { return errors_1.EndpointNotFoundError; } });
|
|
41
|
+
Object.defineProperty(exports, "HttpBadRequestError", { enumerable: true, get: function () { return errors_1.HttpBadRequestError; } });
|
|
42
|
+
Object.defineProperty(exports, "HttpUnauthorizedError", { enumerable: true, get: function () { return errors_1.HttpUnauthorizedError; } });
|
|
43
|
+
Object.defineProperty(exports, "HttpForbiddenError", { enumerable: true, get: function () { return errors_1.HttpForbiddenError; } });
|
|
44
|
+
Object.defineProperty(exports, "HttpTimeoutError", { enumerable: true, get: function () { return errors_1.HttpTimeoutError; } });
|
|
45
|
+
Object.defineProperty(exports, "HttpBadGatewayError", { enumerable: true, get: function () { return errors_1.HttpBadGatewayError; } });
|
|
46
|
+
Object.defineProperty(exports, "HttpGatewayTimeoutError", { enumerable: true, get: function () { return errors_1.HttpGatewayTimeoutError; } });
|
|
47
|
+
Object.defineProperty(exports, "HttpInternalServerError", { enumerable: true, get: function () { return errors_1.HttpInternalServerError; } });
|
|
48
|
+
Object.defineProperty(exports, "HttpVendorError", { enumerable: true, get: function () { return errors_1.HttpVendorError; } });
|
|
49
|
+
Object.defineProperty(exports, "HttpUserError", { enumerable: true, get: function () { return errors_1.HttpUserError; } });
|
|
50
|
+
// Error subtype constants
|
|
51
|
+
Object.defineProperty(exports, "ENTITY_NOT_FOUND", { enumerable: true, get: function () { return errors_1.ENTITY_NOT_FOUND; } });
|
|
52
|
+
Object.defineProperty(exports, "WRONG_LOGIN_TYPE", { enumerable: true, get: function () { return errors_1.WRONG_LOGIN_TYPE; } });
|
|
53
|
+
Object.defineProperty(exports, "WRONG_LOGIN", { enumerable: true, get: function () { return errors_1.WRONG_LOGIN; } });
|
|
54
|
+
Object.defineProperty(exports, "NOT_APPROVED", { enumerable: true, get: function () { return errors_1.NOT_APPROVED; } });
|
|
55
|
+
Object.defineProperty(exports, "EMAIL_NOT_CONFIRMED", { enumerable: true, get: function () { return errors_1.EMAIL_NOT_CONFIRMED; } });
|
|
56
|
+
Object.defineProperty(exports, "WRONG_DOMAIN", { enumerable: true, get: function () { return errors_1.WRONG_DOMAIN; } });
|
|
57
|
+
Object.defineProperty(exports, "WRONG_COMPANY", { enumerable: true, get: function () { return errors_1.WRONG_COMPANY; } });
|
|
58
|
+
Object.defineProperty(exports, "NO_REG_CODE", { enumerable: true, get: function () { return errors_1.NO_REG_CODE; } });
|
|
35
59
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-api/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,4BAA4B;AAC5B,2CAYsB;AAXlB,0GAAA,YAAY,OAAA;AACZ,iGAAA,GAAG,OAAA;AACH,kGAAA,IAAI,OAAA;AACJ,iGAAA,GAAG,OAAA;AACH,oGAAA,MAAM,OAAA;AACN,mGAAA,KAAK,OAAA;AACL,kGAAA,IAAI,OAAA;AACJ,uGAAA,SAAS,OAAA;AACT,4GAAA,cAAc,OAAA;AACd,2GAAA,aAAa,OAAA;AACb,2GAAA,aAAa,OAAA","sourcesContent":["/**\n * @webpieces/http-api\n *\n * Core HTTP API definition package.\n * Contains decorators and utilities for defining HTTP APIs.\n *\n * This package is used by:\n * - @webpieces/http-routing (server-side): Routes HTTP requests to controllers\n * - @webpieces/http-client (client-side): Generates HTTP clients from API definitions\n *\n * Architecture:\n * ```\n * http-api (defines the contract)\n * ↑\n * ├── http-routing (server: contract → handlers)\n * └── http-client (client: contract → HTTP requests)\n * ```\n */\n\n// API definition decorators\nexport {\n ApiInterface,\n Get,\n Post,\n Put,\n Delete,\n Patch,\n Path,\n getRoutes,\n isApiInterface,\n RouteMetadata,\n METADATA_KEYS,\n} from './decorators';\n\n// Type validators\nexport { ValidateImplementation } from './validators';\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/http/http-api/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAEH,4BAA4B;AAC5B,2CAYsB;AAXlB,0GAAA,YAAY,OAAA;AACZ,iGAAA,GAAG,OAAA;AACH,kGAAA,IAAI,OAAA;AACJ,iGAAA,GAAG,OAAA;AACH,oGAAA,MAAM,OAAA;AACN,mGAAA,KAAK,OAAA;AACL,kGAAA,IAAI,OAAA;AACJ,uGAAA,SAAS,OAAA;AACT,4GAAA,cAAc,OAAA;AACd,2GAAA,aAAa,OAAA;AACb,2GAAA,aAAa,OAAA;AAMjB,cAAc;AACd,mCAuBkB;AAtBd,uGAAA,aAAa,OAAA;AACb,mGAAA,SAAS,OAAA;AACT,2GAAA,iBAAiB,OAAA;AACjB,+GAAA,qBAAqB,OAAA;AACrB,6GAAA,mBAAmB,OAAA;AACnB,+GAAA,qBAAqB,OAAA;AACrB,4GAAA,kBAAkB,OAAA;AAClB,0GAAA,gBAAgB,OAAA;AAChB,6GAAA,mBAAmB,OAAA;AACnB,iHAAA,uBAAuB,OAAA;AACvB,iHAAA,uBAAuB,OAAA;AACvB,yGAAA,eAAe,OAAA;AACf,uGAAA,aAAa,OAAA;AACb,0BAA0B;AAC1B,0GAAA,gBAAgB,OAAA;AAChB,0GAAA,gBAAgB,OAAA;AAChB,qGAAA,WAAW,OAAA;AACX,sGAAA,YAAY,OAAA;AACZ,6GAAA,mBAAmB,OAAA;AACnB,sGAAA,YAAY,OAAA;AACZ,uGAAA,aAAa,OAAA;AACb,qGAAA,WAAW,OAAA","sourcesContent":["/**\n * @webpieces/http-api\n *\n * Core HTTP API definition package.\n * Contains decorators and utilities for defining HTTP APIs.\n *\n * This package is used by:\n * - @webpieces/http-routing (server-side): Routes HTTP requests to controllers\n * - @webpieces/http-client (client-side): Generates HTTP clients from API definitions\n *\n * Architecture:\n * ```\n * http-api (defines the contract)\n * ↑\n * ├── http-routing (server: contract → handlers)\n * └── http-client (client: contract → HTTP requests)\n * ```\n */\n\n// API definition decorators\nexport {\n ApiInterface,\n Get,\n Post,\n Put,\n Delete,\n Patch,\n Path,\n getRoutes,\n isApiInterface,\n RouteMetadata,\n METADATA_KEYS,\n} from './decorators';\n\n// Type validators\nexport { ValidateImplementation } from './validators';\n\n// HTTP errors\nexport {\n ProtocolError,\n HttpError,\n HttpNotFoundError,\n EndpointNotFoundError,\n HttpBadRequestError,\n HttpUnauthorizedError,\n HttpForbiddenError,\n HttpTimeoutError,\n HttpBadGatewayError,\n HttpGatewayTimeoutError,\n HttpInternalServerError,\n HttpVendorError,\n HttpUserError,\n // Error subtype constants\n ENTITY_NOT_FOUND,\n WRONG_LOGIN_TYPE,\n WRONG_LOGIN,\n NOT_APPROVED,\n EMAIL_NOT_CONFIRMED,\n WRONG_DOMAIN,\n WRONG_COMPANY,\n NO_REG_CODE,\n} from './errors';\n"]}
|