@bool-ts/core 2.2.4 → 2.3.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/constants/index.d.ts +3 -0
- package/dist/constants/keys.d.ts +34 -0
- package/dist/constants/objects.d.ts +505 -0
- package/dist/decorators/arguments.d.ts +2 -3
- package/dist/decorators/container.d.ts +5 -1
- package/dist/decorators/controller.d.ts +1 -1
- package/dist/decorators/guard.d.ts +1 -1
- package/dist/decorators/inject.d.ts +1 -1
- package/dist/decorators/injectable.d.ts +1 -1
- package/dist/decorators/interceptor.d.ts +1 -1
- package/dist/decorators/middleware.d.ts +1 -1
- package/dist/decorators/module.d.ts +1 -1
- package/dist/decorators/webSocket.d.ts +1 -1
- package/dist/decorators/webSocketArguments.d.ts +1 -1
- package/dist/entities/application.d.ts +13 -83
- package/dist/entities/httpRoute.d.ts +0 -2
- package/dist/entities/httpRouter.d.ts +29 -3
- package/dist/entities/httpRouterGroup.d.ts +5 -1
- package/dist/entities/injector.d.ts +2 -2
- package/dist/http/clientError.d.ts +5 -35
- package/dist/http/serverError.d.ts +7 -19
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/index.js.map +30 -28
- package/dist/interfaces/@types.d.ts +114 -0
- package/dist/interfaces/guard.d.ts +2 -1
- package/dist/interfaces/index.d.ts +2 -1
- package/dist/producers/factory.d.ts +1 -1
- package/dist/utils/asyncFunction.d.ts +1 -0
- package/dist/utils/colors.d.ts +30 -0
- package/dist/utils/functions.d.ts +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/socket.d.ts +1 -0
- package/package.json +5 -4
- package/src/constants/index.ts +10 -0
- package/src/constants/objects.ts +291 -0
- package/src/decorators/arguments.ts +3 -5
- package/src/decorators/container.ts +40 -20
- package/src/decorators/controller.ts +2 -2
- package/src/decorators/guard.ts +2 -2
- package/src/decorators/http.ts +1 -1
- package/src/decorators/inject.ts +2 -2
- package/src/decorators/injectable.ts +2 -2
- package/src/decorators/interceptor.ts +2 -2
- package/src/decorators/middleware.ts +2 -2
- package/src/decorators/module.ts +2 -2
- package/src/decorators/webSocket.ts +2 -2
- package/src/decorators/webSocketArguments.ts +1 -1
- package/src/decorators/webSocketEvent.ts +1 -1
- package/src/entities/application.ts +1554 -1559
- package/src/entities/httpRoute.ts +1 -4
- package/src/entities/httpRouter.ts +36 -6
- package/src/entities/httpRouterGroup.ts +16 -5
- package/src/entities/injector.ts +3 -3
- package/src/http/clientError.ts +16 -39
- package/src/http/serverError.ts +17 -22
- package/src/index.ts +12 -2
- package/src/interfaces/@types.ts +171 -0
- package/src/interfaces/guard.ts +7 -1
- package/src/interfaces/index.ts +24 -1
- package/src/producers/factory.ts +1 -1
- package/src/utils/constructor.ts +1 -0
- package/src/utils/functions.ts +13 -0
- package/src/{ultils → utils}/index.ts +1 -0
- /package/{src/ultils/constructor.ts → dist/utils/constructor.d.ts} +0 -0
- /package/src/{keys/index.ts → constants/keys.ts} +0 -0
- /package/src/{ultils → utils}/asyncFunction.ts +0 -0
- /package/src/{ultils → utils}/colors.ts +0 -0
- /package/src/{ultils → utils}/socket.ts +0 -0
|
@@ -1,88 +1,32 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { ICustomValidator } from "../interfaces/customValidator";
|
|
4
|
-
import type { TConstructor } from "../ultils";
|
|
5
|
-
import { parse as QsParse } from "qs";
|
|
6
|
-
type TParamsType = Record<string, string>;
|
|
7
|
-
type TApplicationOptions<AllowedMethods extends Array<THttpMethods> = Array<THttpMethods>> = Required<{
|
|
8
|
-
port: number;
|
|
9
|
-
}> & Partial<{
|
|
10
|
-
config: Record<string | symbol, any> | (() => Record<string | symbol, any>);
|
|
11
|
-
prefix: string;
|
|
12
|
-
debug: boolean;
|
|
13
|
-
log: Partial<{
|
|
14
|
-
methods: AllowedMethods;
|
|
15
|
-
}>;
|
|
16
|
-
queryParser: Parameters<typeof QsParse>[1];
|
|
17
|
-
static: Required<{
|
|
18
|
-
path: string;
|
|
19
|
-
}> & Partial<{
|
|
20
|
-
headers: TParamsType;
|
|
21
|
-
cacheTimeInSeconds: number;
|
|
22
|
-
}>;
|
|
23
|
-
cors: Partial<{
|
|
24
|
-
credentials: boolean;
|
|
25
|
-
origins: string | Array<string>;
|
|
26
|
-
methods: Array<THttpMethods>;
|
|
27
|
-
headers: Array<string>;
|
|
28
|
-
}>;
|
|
29
|
-
}>;
|
|
30
|
-
type TPreLaunch = undefined | Readonly<{
|
|
31
|
-
containerMetadata: TContainerMetadata;
|
|
32
|
-
modulesConverted: Array<TConstructor<unknown>>;
|
|
33
|
-
resolutedContainer?: Awaited<ReturnType<Application["containerResolution"]>>;
|
|
34
|
-
resolutedModules: Array<Awaited<ReturnType<Application["moduleResolution"]>>>;
|
|
35
|
-
webSocketsMap: Map<string, TWebSocketEventHandlerMetadata>;
|
|
36
|
-
}>;
|
|
1
|
+
import type { ICustomValidator, TApplicationOptions, TPreLaunch } from "../interfaces";
|
|
2
|
+
import type { TConstructor } from "../utils";
|
|
37
3
|
export declare class Application<TRootClass extends Object = Object> {
|
|
38
4
|
#private;
|
|
39
5
|
private readonly classConstructor;
|
|
40
6
|
private readonly options;
|
|
41
7
|
constructor(classConstructor: TConstructor<TRootClass>, options: TApplicationOptions);
|
|
42
|
-
useValidator(validator: ICustomValidator): void;
|
|
43
8
|
/**
|
|
44
|
-
*
|
|
9
|
+
* Static method to initialize app and await all reloads.
|
|
10
|
+
* @param classConstructor
|
|
11
|
+
* @param options
|
|
45
12
|
* @returns
|
|
46
13
|
*/
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Start listen app on a port
|
|
50
|
-
* @param port
|
|
51
|
-
*/
|
|
52
|
-
listen(): Promise<void>;
|
|
14
|
+
static create<TRootClass extends Object = Object>(classConstructor: TConstructor<TRootClass>, options: TApplicationOptions): Promise<Application<TRootClass>>;
|
|
53
15
|
/**
|
|
54
|
-
*
|
|
55
|
-
* @param
|
|
56
|
-
* @returns
|
|
57
|
-
*/
|
|
58
|
-
private containerResolution;
|
|
59
|
-
/**
|
|
60
|
-
*
|
|
61
|
-
* @param param0
|
|
62
|
-
* @returns
|
|
63
|
-
*/
|
|
64
|
-
private moduleResolution;
|
|
65
|
-
/**
|
|
66
|
-
*
|
|
67
|
-
* @param data
|
|
68
|
-
* @param zodSchema
|
|
69
|
-
* @param argumentIndex
|
|
70
|
-
* @param funcName
|
|
71
|
-
* @returns
|
|
16
|
+
* Register app validator to execute all validations process in app.
|
|
17
|
+
* @param validator
|
|
72
18
|
*/
|
|
73
|
-
|
|
19
|
+
useValidator(validator: ICustomValidator): void;
|
|
74
20
|
/**
|
|
75
21
|
*
|
|
76
|
-
* @param param0
|
|
77
22
|
* @returns
|
|
78
23
|
*/
|
|
79
|
-
|
|
24
|
+
preLaunch(): Promise<NonNullable<TPreLaunch>>;
|
|
80
25
|
/**
|
|
81
|
-
*
|
|
82
|
-
* @param
|
|
83
|
-
* @returns
|
|
26
|
+
* Start listen app on a port
|
|
27
|
+
* @param port
|
|
84
28
|
*/
|
|
85
|
-
|
|
29
|
+
listen(): Promise<void>;
|
|
86
30
|
/**
|
|
87
31
|
*
|
|
88
32
|
* @param param0
|
|
@@ -95,18 +39,4 @@ export declare class Application<TRootClass extends Object = Object> {
|
|
|
95
39
|
* @returns
|
|
96
40
|
*/
|
|
97
41
|
private finalizeResponse;
|
|
98
|
-
/**
|
|
99
|
-
*
|
|
100
|
-
* @param param0
|
|
101
|
-
* @returns
|
|
102
|
-
*/
|
|
103
|
-
private httpFetcher;
|
|
104
|
-
/**
|
|
105
|
-
*
|
|
106
|
-
* @param bun
|
|
107
|
-
* @param bool
|
|
108
|
-
* @returns
|
|
109
|
-
*/
|
|
110
|
-
private webSocketFetcher;
|
|
111
42
|
}
|
|
112
|
-
export {};
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
+
import type { TCloseInterceptorHandlers, TGuardHandlers, TOpenInterceptorHandlers } from "../interfaces";
|
|
1
2
|
import HttpRoute from "./httpRoute";
|
|
2
3
|
export declare class HttpRouter {
|
|
4
|
+
#private;
|
|
3
5
|
readonly alias: string;
|
|
4
|
-
|
|
5
|
-
constructor({ alias }: {
|
|
6
|
+
constructor({ alias, guardHandlers: guards, openInterceptorHandlers, closeInterceptorHandlers }: {
|
|
6
7
|
alias: string;
|
|
8
|
+
guardHandlers?: TGuardHandlers;
|
|
9
|
+
openInterceptorHandlers?: TOpenInterceptorHandlers;
|
|
10
|
+
closeInterceptorHandlers?: TCloseInterceptorHandlers;
|
|
7
11
|
});
|
|
8
12
|
/**
|
|
9
13
|
*
|
|
10
14
|
* @param alias
|
|
11
15
|
* @returns
|
|
12
16
|
*/
|
|
13
|
-
route(alias
|
|
17
|
+
route({ alias }: {
|
|
18
|
+
alias: string;
|
|
19
|
+
}): HttpRoute;
|
|
14
20
|
/**
|
|
15
21
|
*
|
|
16
22
|
* @param alias
|
|
@@ -21,5 +27,25 @@ export declare class HttpRouter {
|
|
|
21
27
|
*
|
|
22
28
|
*/
|
|
23
29
|
get routes(): Map<string, HttpRoute>;
|
|
30
|
+
get pipes(): Readonly<{
|
|
31
|
+
guardHandlers: Readonly<{
|
|
32
|
+
class: import("..").IGuard;
|
|
33
|
+
func: (...args: any[]) => import("../interfaces").TGuardReturn;
|
|
34
|
+
funcName: "enforce";
|
|
35
|
+
argumentsMetadata: import("..").TArgumentsMetadataCollection;
|
|
36
|
+
}>[];
|
|
37
|
+
openInterceptorHandlers: Readonly<{
|
|
38
|
+
class: import("..").IInterceptor<any, any>;
|
|
39
|
+
func: (...args: any[]) => any;
|
|
40
|
+
funcName: "open";
|
|
41
|
+
argumentsMetadata: import("..").TArgumentsMetadataCollection;
|
|
42
|
+
}>[];
|
|
43
|
+
closeInterceptorHandlers: Readonly<{
|
|
44
|
+
class: import("..").IInterceptor<any, any>;
|
|
45
|
+
func: (...args: any[]) => any;
|
|
46
|
+
funcName: "close";
|
|
47
|
+
argumentsMetadata: import("..").TArgumentsMetadataCollection;
|
|
48
|
+
}>[];
|
|
49
|
+
}>;
|
|
24
50
|
}
|
|
25
51
|
export default HttpRouter;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { THttpMethods } from "../http";
|
|
2
|
+
import type { TCloseInterceptorHandlers, TGuardHandlers, TOpenInterceptorHandlers } from "../interfaces";
|
|
2
3
|
import type { THttpRouteModel } from "./httpRoute";
|
|
3
4
|
import type { HttpRouter } from "./httpRouter";
|
|
4
5
|
export declare class HttpRouterGroup {
|
|
5
|
-
private
|
|
6
|
+
#private;
|
|
6
7
|
add(...routers: Array<HttpRouter>): this;
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
@@ -16,5 +17,8 @@ export declare class HttpRouterGroup {
|
|
|
16
17
|
}): Readonly<{
|
|
17
18
|
parameters: Record<string, string | undefined>;
|
|
18
19
|
model: THttpRouteModel;
|
|
20
|
+
guardHandlers: TGuardHandlers;
|
|
21
|
+
openInterceptorHandlers: TOpenInterceptorHandlers;
|
|
22
|
+
closeInterceptorHandlers: TCloseInterceptorHandlers;
|
|
19
23
|
}> | null;
|
|
20
24
|
}
|
|
@@ -4,7 +4,7 @@ type TDefinition<T = any> = {
|
|
|
4
4
|
} | string | symbol;
|
|
5
5
|
interface IInjector {
|
|
6
6
|
set(key: TDefinition, value: any): void;
|
|
7
|
-
get<T>(definition: TDefinition): T;
|
|
7
|
+
get<T>(definition: TDefinition): T | undefined;
|
|
8
8
|
}
|
|
9
9
|
export declare class Injector implements IInjector {
|
|
10
10
|
private readonly _mapper;
|
|
@@ -17,7 +17,7 @@ export declare class Injector implements IInjector {
|
|
|
17
17
|
*
|
|
18
18
|
* @param definition
|
|
19
19
|
*/
|
|
20
|
-
get<T>(definition: TDefinition):
|
|
20
|
+
get<T>(definition: TDefinition): T | undefined;
|
|
21
21
|
/**
|
|
22
22
|
*
|
|
23
23
|
* @param key
|
|
@@ -1,40 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
403: "FORBIDDEN";
|
|
6
|
-
404: "NOT_FOUND";
|
|
7
|
-
405: "METHOD_NOT_ALLOWED";
|
|
8
|
-
406: "NOT_ACCEPTABLE";
|
|
9
|
-
407: "PROXY_AUTHENCATION_REQUIRED";
|
|
10
|
-
408: "REQUEST_TIMEOUT";
|
|
11
|
-
409: "CONFLICT";
|
|
12
|
-
410: "GONE";
|
|
13
|
-
411: "LENGTH_REQUIRED";
|
|
14
|
-
412: "PRECONDITION_FAILED";
|
|
15
|
-
413: "PAYLOAD_TOO_LARGE";
|
|
16
|
-
414: "URI_TOO_LONG";
|
|
17
|
-
415: "UNSUPPORTED_MEDIA_TYPE";
|
|
18
|
-
416: "RANGE_NOT_SATISFIABLE";
|
|
19
|
-
417: "EXPECTATION_FAILED";
|
|
20
|
-
418: "IM_A_TEAPOT";
|
|
21
|
-
421: "MISDIRECTED_REQUEST";
|
|
22
|
-
422: "UNPROCESSABLE_ENTITY";
|
|
23
|
-
423: "LOCKED";
|
|
24
|
-
424: "FAILED_DEPENDENCY";
|
|
25
|
-
425: "TOO_EARLY_";
|
|
26
|
-
426: "UPGRAGE_REQUIRED";
|
|
27
|
-
428: "PRECONDITION_REQUIRED";
|
|
28
|
-
429: "TOO_MANY_REQUESTS";
|
|
29
|
-
431: "REQUEST_HEADER_FIELDS_TOO_LARGE";
|
|
30
|
-
451: "UNAVAILABLE_FOR_LEGAL_REASONS";
|
|
31
|
-
}>;
|
|
32
|
-
export declare class HttpClientError<T extends keyof typeof httpClientErrors = keyof typeof httpClientErrors, K = unknown> extends Error {
|
|
33
|
-
readonly httpCode: T;
|
|
34
|
-
readonly message: (typeof httpClientErrors)[T] | string;
|
|
1
|
+
import type { TClientErrorStatuses } from "../constants";
|
|
2
|
+
export declare class HttpClientError<K = unknown> extends Error {
|
|
3
|
+
readonly httpCode: TClientErrorStatuses;
|
|
4
|
+
readonly message: string;
|
|
35
5
|
readonly data: K | undefined;
|
|
36
6
|
constructor({ httpCode, data, message }: {
|
|
37
|
-
httpCode:
|
|
7
|
+
httpCode: TClientErrorStatuses;
|
|
38
8
|
data?: K;
|
|
39
9
|
message?: string;
|
|
40
10
|
});
|
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
504: "GATEWAY_TIMEOUT";
|
|
7
|
-
505: "HTTP_VERSION_NOT_SUPPORTED";
|
|
8
|
-
506: "VARIANT_ALSO_NEGOTIATES";
|
|
9
|
-
507: "INSUFFICIENT_STORAGE";
|
|
10
|
-
508: "LOOP_DETECTED";
|
|
11
|
-
510: "NOT_EXTENDED";
|
|
12
|
-
511: "NETWORK_AUTHENTICATION_REQUIRED";
|
|
13
|
-
}>;
|
|
14
|
-
export declare class HttpServerError<T extends keyof typeof httpServerErrors = keyof typeof httpServerErrors, K = any> extends Error {
|
|
15
|
-
readonly httpCode: T;
|
|
16
|
-
readonly message: (typeof httpServerErrors)[T] | string;
|
|
17
|
-
readonly data: K | undefined;
|
|
1
|
+
import type { TServerErrorStatuses } from "../constants";
|
|
2
|
+
export declare class HttpServerError<T = any> extends Error {
|
|
3
|
+
readonly httpCode: TServerErrorStatuses;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
readonly data: T | undefined;
|
|
18
6
|
constructor({ httpCode, data, message }: {
|
|
19
|
-
httpCode:
|
|
20
|
-
data?:
|
|
7
|
+
httpCode: TServerErrorStatuses;
|
|
8
|
+
data?: T;
|
|
21
9
|
message?: string;
|
|
22
10
|
});
|
|
23
11
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
export type { THttpRouteModel } from "./entities";
|
|
3
|
+
export type { IContainer, IContext, IController, ICustomValidator, IGuard, IInterceptor, IMiddleware, IModule, IWebSocket } from "./interfaces";
|
|
4
|
+
export * from "./constants";
|
|
3
5
|
export * from "./decorators";
|
|
4
6
|
export * from "./entities";
|
|
5
7
|
export * from "./http";
|
|
6
|
-
export * from "./interfaces";
|
|
7
|
-
export * as Keys from "./keys";
|
|
8
8
|
export * from "./producers";
|