@zenofolio/hyper-decor 1.0.71 → 1.0.73
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/.agent/rules/philosophy.md +103 -0
- package/.agent/rules/writing.md +32 -0
- package/README.md +78 -207
- package/dist/__internals/constants.d.ts +1 -62
- package/dist/__internals/constants.js +3 -69
- package/dist/__internals/creators/request.creator.d.ts +1 -10
- package/dist/__internals/creators/request.creator.js +141 -23
- package/dist/__internals/helpers/merge-metadata.d.ts +2 -3
- package/dist/__internals/helpers/merge-metadata.js +31 -7
- package/dist/__internals/helpers/prepare.helper.d.ts +4 -10
- package/dist/__internals/helpers/prepare.helper.js +316 -283
- package/dist/__internals/stores/hyper.store.d.ts +5 -0
- package/dist/__internals/stores/hyper.store.js +5 -0
- package/dist/__internals/stores/index.d.ts +4 -0
- package/dist/__internals/stores/index.js +20 -0
- package/dist/__internals/stores/meta.store.d.ts +34 -0
- package/dist/__internals/stores/meta.store.js +107 -0
- package/dist/__internals/stores/scope.store.d.ts +14 -0
- package/dist/__internals/stores/scope.store.js +29 -0
- package/dist/__internals/stores/serivces.store.d.ts +1 -0
- package/dist/__internals/stores/serivces.store.js +4 -0
- package/dist/__internals/transform/middleware.transform.d.ts +1 -1
- package/dist/__internals/transform/middleware.transform.js +1 -1
- package/dist/__internals/transform/role.transform.d.ts +1 -1
- package/dist/__internals/transform/role.transform.js +4 -4
- package/dist/__internals/transform/scope.transfrom.d.ts +1 -1
- package/dist/__internals/transform/scope.transfrom.js +2 -2
- package/dist/__internals/types.d.ts +53 -4
- package/dist/common/bootstrap.d.ts +6 -2
- package/dist/common/bootstrap.js +44 -10
- package/dist/common/transport.d.ts +1 -0
- package/dist/common/transport.js +27 -14
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -1
- package/dist/decorators/Http.d.ts +3 -43
- package/dist/decorators/Http.js +9 -103
- package/dist/decorators.d.ts +1 -0
- package/dist/decorators.js +17 -0
- package/dist/index.d.ts +6 -5
- package/dist/index.js +6 -5
- package/dist/lib/event/meta.store.d.ts +4 -0
- package/dist/lib/event/meta.store.js +5 -0
- package/dist/lib/openapi/collectors/class.collector.d.ts +5 -9
- package/dist/lib/openapi/collectors/class.collector.js +6 -63
- package/dist/lib/openapi/collectors/index.d.ts +3 -4
- package/dist/lib/openapi/collectors/index.js +0 -1
- package/dist/lib/openapi/collectors/method.collector.d.ts +6 -1
- package/dist/lib/openapi/collectors/method.collector.js +92 -59
- package/dist/lib/openapi/collectors/schema.collector.d.ts +3 -8
- package/dist/lib/openapi/collectors/schema.collector.js +17 -25
- package/dist/lib/openapi/constants.d.ts +1 -0
- package/dist/lib/openapi/constants.js +2 -2
- package/dist/lib/openapi/decorators.d.ts +16 -0
- package/dist/lib/openapi/decorators.js +93 -0
- package/dist/lib/openapi/index.d.ts +29 -5
- package/dist/lib/openapi/index.js +119 -5
- package/dist/lib/openapi/metadata.d.ts +7 -0
- package/dist/lib/openapi/metadata.js +8 -0
- package/dist/lib/openapi/metadata.registry.d.ts +1 -1
- package/dist/lib/server/decorators/File.d.ts +37 -0
- package/dist/lib/server/decorators/File.js +167 -0
- package/dist/lib/server/decorators/Http.d.ts +12 -0
- package/dist/lib/server/decorators/Http.js +56 -0
- package/dist/lib/server/decorators/HyperApp.d.ts +7 -0
- package/dist/lib/server/decorators/HyperApp.js +14 -0
- package/dist/lib/server/decorators/HyperController.d.ts +6 -0
- package/dist/lib/server/decorators/HyperController.js +27 -0
- package/dist/lib/server/decorators/HyperModule.d.ts +6 -0
- package/dist/lib/server/decorators/HyperModule.js +13 -0
- package/dist/lib/server/decorators/HyperService.d.ts +11 -0
- package/dist/lib/server/decorators/HyperService.js +30 -0
- package/dist/lib/server/decorators/Messaging.d.ts +8 -0
- package/dist/lib/server/decorators/Messaging.js +19 -0
- package/dist/lib/server/decorators/Middleware.d.ts +18 -0
- package/dist/lib/server/decorators/Middleware.js +52 -0
- package/dist/lib/server/decorators/Output.d.ts +6 -0
- package/dist/lib/server/decorators/Output.js +14 -0
- package/dist/lib/server/decorators/Pass.d.ts +10 -0
- package/dist/lib/server/decorators/Pass.js +13 -0
- package/dist/lib/server/decorators/Role.d.ts +7 -0
- package/dist/lib/server/decorators/Role.js +14 -0
- package/dist/lib/server/decorators/Routes.d.ts +14 -0
- package/dist/lib/server/decorators/Routes.js +39 -0
- package/dist/lib/server/decorators/Scope.d.ts +7 -0
- package/dist/lib/server/decorators/Scope.js +14 -0
- package/dist/lib/server/decorators/index.d.ts +16 -0
- package/dist/lib/server/decorators/index.js +32 -0
- package/dist/lib/server/decorators/metadata.d.ts +1 -0
- package/dist/lib/server/decorators/metadata.js +5 -0
- package/dist/lib/server/decorators/types.d.ts +125 -0
- package/dist/lib/server/decorators/types.js +6 -0
- package/dist/lib/server/exeptions/DuplicateControllerPathException.d.ts +14 -0
- package/dist/lib/server/exeptions/DuplicateControllerPathException.js +12 -0
- package/dist/lib/server/exeptions/DuplicatedException.d.ts +8 -0
- package/dist/lib/server/exeptions/DuplicatedException.js +12 -0
- package/dist/lib/server/exeptions/DuplicatedHandlerException.d.ts +4 -0
- package/dist/lib/server/exeptions/DuplicatedHandlerException.js +12 -0
- package/dist/lib/server/exeptions/HyperException.d.ts +8 -0
- package/dist/lib/server/exeptions/HyperException.js +14 -0
- package/dist/lib/server/exeptions/HyperFileException.d.ts +4 -0
- package/dist/lib/server/exeptions/HyperFileException.js +12 -0
- package/dist/lib/server/exeptions/MethodNotFountException.d.ts +4 -0
- package/dist/lib/server/exeptions/MethodNotFountException.js +12 -0
- package/dist/lib/server/exeptions/NotPropertyException.d.ts +6 -0
- package/dist/lib/server/exeptions/NotPropertyException.js +16 -0
- package/dist/lib/server/exeptions/NotRoleException.d.ts +6 -0
- package/dist/lib/server/exeptions/NotRoleException.js +17 -0
- package/dist/lib/server/exeptions/NotScopeException.d.ts +7 -0
- package/dist/lib/server/exeptions/NotScopeException.js +18 -0
- package/dist/lib/server/exeptions/WrongPlaceException.d.ts +8 -0
- package/dist/lib/server/exeptions/WrongPlaceException.js +21 -0
- package/dist/lib/server/exeptions/index.d.ts +8 -0
- package/dist/lib/server/exeptions/index.js +18 -0
- package/dist/lib/server/exeptions/types.d.ts +1 -0
- package/dist/lib/server/exeptions/types.js +2 -0
- package/dist/lib/tree/tree.d.ts +36 -0
- package/dist/lib/tree/tree.js +106 -0
- package/package.json +1 -1
- package/scripts/clean.js +55 -55
- package/scripts/test-server.ts +85 -85
- package/vitest.config.mjs +33 -30
- package/vitest.json +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HyperService = HyperService;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const tsyringe_1 = require("tsyringe");
|
|
6
|
+
const metadata_1 = require("./metadata");
|
|
7
|
+
/**
|
|
8
|
+
* 🚀 HyperService Decorator
|
|
9
|
+
* Purely injects metadata and registers the class in the DI container.
|
|
10
|
+
*/
|
|
11
|
+
function HyperService({ token, singleton = true, } = {}) {
|
|
12
|
+
return (Target) => {
|
|
13
|
+
const useToken = token !== null && token !== void 0 ? token : Target;
|
|
14
|
+
// 1. DI Registration
|
|
15
|
+
(0, tsyringe_1.injectable)()(Target);
|
|
16
|
+
if (!tsyringe_1.container.isRegistered(useToken)) {
|
|
17
|
+
if (singleton) {
|
|
18
|
+
tsyringe_1.container.registerSingleton(useToken, Target);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
tsyringe_1.container.register(useToken, { useClass: Target });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
// 2. Hierarchical Metadata Injection
|
|
25
|
+
metadata_1.HyperMeta.set(Target, undefined, {
|
|
26
|
+
type: 'service',
|
|
27
|
+
});
|
|
28
|
+
return Target;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
/**
|
|
3
|
+
* 🚀 OnMessage Decorator
|
|
4
|
+
* Purely injects message subscription metadata into the method.
|
|
5
|
+
*
|
|
6
|
+
* @param topic The topic or pattern to listen to (e.g. "user.created", "user.*")
|
|
7
|
+
*/
|
|
8
|
+
export declare const OnMessage: (topic: string) => (target: any, propertyKey: any) => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OnMessage = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const metadata_1 = require("./metadata");
|
|
6
|
+
/**
|
|
7
|
+
* 🚀 OnMessage Decorator
|
|
8
|
+
* Purely injects message subscription metadata into the method.
|
|
9
|
+
*
|
|
10
|
+
* @param topic The topic or pattern to listen to (e.g. "user.created", "user.*")
|
|
11
|
+
*/
|
|
12
|
+
const OnMessage = (topic) => {
|
|
13
|
+
return (target, propertyKey) => {
|
|
14
|
+
metadata_1.HyperMeta.set(target, propertyKey, {
|
|
15
|
+
onMessage: { topic }
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
exports.OnMessage = OnMessage;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { MiddlewareHandler } from "hyper-express";
|
|
3
|
+
import { MiddlewareType } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* 🚀 Middleware Decorator
|
|
6
|
+
* Purely injects middleware metadata into the target class or method.
|
|
7
|
+
*/
|
|
8
|
+
export declare const Middleware: {
|
|
9
|
+
(...middleware: MiddlewareType[]): any;
|
|
10
|
+
/**
|
|
11
|
+
* Exclude middleware from matching paths.
|
|
12
|
+
*/
|
|
13
|
+
exclude(expressions: RegExp | RegExp[], middleware: MiddlewareHandler): any;
|
|
14
|
+
/**
|
|
15
|
+
* Only run middleware on matching paths.
|
|
16
|
+
*/
|
|
17
|
+
only(expressions: RegExp | RegExp[], middleware: MiddlewareHandler): any;
|
|
18
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Middleware = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const metadata_1 = require("./metadata");
|
|
6
|
+
/**
|
|
7
|
+
* 🚀 Middleware Decorator
|
|
8
|
+
* Purely injects middleware metadata into the target class or method.
|
|
9
|
+
*/
|
|
10
|
+
const Middleware = (...middleware) => (target, propertyKey) => {
|
|
11
|
+
const current = metadata_1.HyperMeta.get(target, propertyKey);
|
|
12
|
+
const existing = current.middlewares || [];
|
|
13
|
+
metadata_1.HyperMeta.set(target, propertyKey, {
|
|
14
|
+
middlewares: [...existing, ...middleware]
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
exports.Middleware = Middleware;
|
|
18
|
+
/**
|
|
19
|
+
* Exclude middleware from matching paths.
|
|
20
|
+
*/
|
|
21
|
+
exports.Middleware.exclude = (expressions, middleware) => (target, propertyKey) => {
|
|
22
|
+
const handler = buildHandler("exclude", expressions, middleware);
|
|
23
|
+
const current = metadata_1.HyperMeta.get(target, propertyKey);
|
|
24
|
+
const existing = current.middlewares || [];
|
|
25
|
+
metadata_1.HyperMeta.set(target, propertyKey, {
|
|
26
|
+
middlewares: [...existing, handler]
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Only run middleware on matching paths.
|
|
31
|
+
*/
|
|
32
|
+
exports.Middleware.only = (expressions, middleware) => (target, propertyKey) => {
|
|
33
|
+
const handler = buildHandler("only", expressions, middleware);
|
|
34
|
+
const current = metadata_1.HyperMeta.get(target, propertyKey);
|
|
35
|
+
const existing = current.middlewares || [];
|
|
36
|
+
metadata_1.HyperMeta.set(target, propertyKey, {
|
|
37
|
+
middlewares: [...existing, handler]
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Helper function to build middleware handlers for "only" and "exclude" modes.
|
|
42
|
+
*/
|
|
43
|
+
const buildHandler = (mode, expressions, middleware) => {
|
|
44
|
+
const matchers = Array.isArray(expressions) ? expressions : [expressions];
|
|
45
|
+
return (req, res, next) => {
|
|
46
|
+
const matches = matchers.some((rx) => rx.test(req.path));
|
|
47
|
+
if ((mode === "only" && !matches) || (mode === "exclude" && matches)) {
|
|
48
|
+
return next();
|
|
49
|
+
}
|
|
50
|
+
return middleware(req, res, next);
|
|
51
|
+
};
|
|
52
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Output = Output;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const metadata_1 = require("./metadata");
|
|
6
|
+
/**
|
|
7
|
+
* 🚀 Output Decorator
|
|
8
|
+
* Purely injects output schema metadata into the method.
|
|
9
|
+
*/
|
|
10
|
+
function Output(schema) {
|
|
11
|
+
return (target, propertyKey) => {
|
|
12
|
+
metadata_1.HyperMeta.set(target, propertyKey, { output: schema });
|
|
13
|
+
};
|
|
14
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { Request, Response } from "hyper-express";
|
|
3
|
+
export interface PassOptions {
|
|
4
|
+
(req: Request, res: Response): boolean | Promise<boolean>;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 🚀 Pass Decorator
|
|
8
|
+
* Purely injects pass metadata into the target class or method.
|
|
9
|
+
*/
|
|
10
|
+
export declare const Pass: (options?: PassOptions | boolean) => any;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pass = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const metadata_1 = require("./metadata");
|
|
6
|
+
/**
|
|
7
|
+
* 🚀 Pass Decorator
|
|
8
|
+
* Purely injects pass metadata into the target class or method.
|
|
9
|
+
*/
|
|
10
|
+
const Pass = (options = true) => (target, propertyKey) => {
|
|
11
|
+
metadata_1.HyperMeta.set(target, propertyKey, { pass: options });
|
|
12
|
+
};
|
|
13
|
+
exports.Pass = Pass;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { RoleType } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* 🚀 Role Decorator
|
|
5
|
+
* Purely injects role metadata into the target class or method.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Role: <T extends string = string>(roles: RoleType<T>) => (target: any, propertyKey?: any) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Role = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const metadata_1 = require("./metadata");
|
|
6
|
+
/**
|
|
7
|
+
* 🚀 Role Decorator
|
|
8
|
+
* Purely injects role metadata into the target class or method.
|
|
9
|
+
*/
|
|
10
|
+
const Role = (roles) => (target, propertyKey) => {
|
|
11
|
+
const _roles = Array.isArray(roles) ? roles : [roles];
|
|
12
|
+
metadata_1.HyperMeta.set(target, propertyKey, { roles: _roles });
|
|
13
|
+
};
|
|
14
|
+
exports.Role = Role;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
export declare const Get: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
3
|
+
export declare const Post: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
4
|
+
export declare const Put: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
5
|
+
export declare const Delete: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
6
|
+
export declare const Patch: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
7
|
+
export declare const Options: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
8
|
+
export declare const Head: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
9
|
+
export declare const Trace: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
10
|
+
export declare const Any: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
11
|
+
export declare const All: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
12
|
+
export declare const Connect: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
13
|
+
export declare const WS: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
14
|
+
export declare const Upgrade: (path?: string, options?: Record<string, unknown> | undefined) => (target: object, propertyKey?: any) => void;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Upgrade = exports.WS = exports.Connect = exports.All = exports.Any = exports.Trace = exports.Head = exports.Options = exports.Patch = exports.Delete = exports.Put = exports.Post = exports.Get = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const metadata_1 = require("./metadata");
|
|
6
|
+
/**
|
|
7
|
+
* 🛠️ Helper to create route decorators
|
|
8
|
+
*/
|
|
9
|
+
function createRouteDecorator(method) {
|
|
10
|
+
return (path = "/", options) => {
|
|
11
|
+
return (target, propertyKey) => {
|
|
12
|
+
const returnType = Reflect.getMetadata("design:returntype", target, propertyKey);
|
|
13
|
+
metadata_1.HyperMeta.set(target, propertyKey, {
|
|
14
|
+
route: {
|
|
15
|
+
method,
|
|
16
|
+
path,
|
|
17
|
+
propertyKey: propertyKey,
|
|
18
|
+
options: options,
|
|
19
|
+
},
|
|
20
|
+
reflection: {
|
|
21
|
+
output: returnType
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
exports.Get = createRouteDecorator("get");
|
|
28
|
+
exports.Post = createRouteDecorator("post");
|
|
29
|
+
exports.Put = createRouteDecorator("put");
|
|
30
|
+
exports.Delete = createRouteDecorator("delete");
|
|
31
|
+
exports.Patch = createRouteDecorator("patch");
|
|
32
|
+
exports.Options = createRouteDecorator("options");
|
|
33
|
+
exports.Head = createRouteDecorator("head");
|
|
34
|
+
exports.Trace = createRouteDecorator("trace");
|
|
35
|
+
exports.Any = createRouteDecorator("any");
|
|
36
|
+
exports.All = createRouteDecorator("all");
|
|
37
|
+
exports.Connect = createRouteDecorator("connect");
|
|
38
|
+
exports.WS = createRouteDecorator("ws");
|
|
39
|
+
exports.Upgrade = createRouteDecorator("upgrade");
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { ScopeType } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* 🚀 Scope Decorator
|
|
5
|
+
* Purely injects scope metadata into the target class or method.
|
|
6
|
+
*/
|
|
7
|
+
export declare const Scope: <T extends string = string>(scopes: ScopeType<T>) => (target: any, propertyKey?: any) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scope = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const metadata_1 = require("./metadata");
|
|
6
|
+
/**
|
|
7
|
+
* 🚀 Scope Decorator
|
|
8
|
+
* Purely injects scope metadata into the target class or method.
|
|
9
|
+
*/
|
|
10
|
+
const Scope = (scopes) => (target, propertyKey) => {
|
|
11
|
+
const _scopes = Array.isArray(scopes) ? scopes : [scopes];
|
|
12
|
+
metadata_1.HyperMeta.set(target, propertyKey, { scopes: _scopes });
|
|
13
|
+
};
|
|
14
|
+
exports.Scope = Scope;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export * from "./metadata";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export * from "./HyperApp";
|
|
4
|
+
export * from "./HyperModule";
|
|
5
|
+
export * from "./HyperController";
|
|
6
|
+
export * from "./HyperService";
|
|
7
|
+
export * from "./Routes";
|
|
8
|
+
export * from "./Http";
|
|
9
|
+
export * from "./Role";
|
|
10
|
+
export * from "./Scope";
|
|
11
|
+
export * from "./Output";
|
|
12
|
+
export * from "./Middleware";
|
|
13
|
+
export * from "./Pass";
|
|
14
|
+
export * from "./File";
|
|
15
|
+
export * from "./Messaging";
|
|
16
|
+
export * from "./Output";
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./metadata"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
19
|
+
__exportStar(require("./HyperApp"), exports);
|
|
20
|
+
__exportStar(require("./HyperModule"), exports);
|
|
21
|
+
__exportStar(require("./HyperController"), exports);
|
|
22
|
+
__exportStar(require("./HyperService"), exports);
|
|
23
|
+
__exportStar(require("./Routes"), exports);
|
|
24
|
+
__exportStar(require("./Http"), exports);
|
|
25
|
+
__exportStar(require("./Role"), exports);
|
|
26
|
+
__exportStar(require("./Scope"), exports);
|
|
27
|
+
__exportStar(require("./Output"), exports);
|
|
28
|
+
__exportStar(require("./Middleware"), exports);
|
|
29
|
+
__exportStar(require("./Pass"), exports);
|
|
30
|
+
__exportStar(require("./File"), exports);
|
|
31
|
+
__exportStar(require("./Messaging"), exports);
|
|
32
|
+
__exportStar(require("./Output"), exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HyperMeta } from "../../../__internals/stores/hyper.store";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HyperMeta = void 0;
|
|
4
|
+
var hyper_store_1 = require("../../../__internals/stores/hyper.store");
|
|
5
|
+
Object.defineProperty(exports, "HyperMeta", { enumerable: true, get: function () { return hyper_store_1.HyperMeta; } });
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import type { MiddlewareHandler, MiddlewareNext, Request, Response, ServerConstructorOptions } from "hyper-express";
|
|
2
|
+
import { InjectionToken, RegistrationOptions } from "tsyringe";
|
|
3
|
+
import { IMessageTransport } from "../../../common/transport";
|
|
4
|
+
export interface OnInit {
|
|
5
|
+
onInit(): Promise<any>;
|
|
6
|
+
}
|
|
7
|
+
export interface IsSingleton {
|
|
8
|
+
isSingleton(): boolean;
|
|
9
|
+
}
|
|
10
|
+
export type Constructor<R = object> = new (...args: any[]) => R;
|
|
11
|
+
export type ImportObject = {
|
|
12
|
+
token: InjectionToken;
|
|
13
|
+
useClass?: Constructor;
|
|
14
|
+
useValue?: any;
|
|
15
|
+
useFactory?: (...args: any[]) => any;
|
|
16
|
+
useToken?: InjectionToken;
|
|
17
|
+
options?: RegistrationOptions;
|
|
18
|
+
};
|
|
19
|
+
export type ImportType = Constructor<Partial<OnInit> & Partial<IsSingleton>> | InjectionToken | ImportObject;
|
|
20
|
+
export type ConstructorDecorator = (target: Constructor, kay?: any, descriptor?: PropertyDescriptor) => Constructor;
|
|
21
|
+
export type HyperClassDecorator<T> = (options?: T) => ConstructorDecorator;
|
|
22
|
+
export type HyperMethodDecorator<T> = (options?: T) => (target: any, key?: any, descriptor?: PropertyDescriptor) => void;
|
|
23
|
+
export interface LogSpaces {
|
|
24
|
+
modules: boolean;
|
|
25
|
+
controllers: boolean;
|
|
26
|
+
middleware: boolean;
|
|
27
|
+
routes: boolean;
|
|
28
|
+
messaging: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface IHyperHooks {
|
|
31
|
+
onBeforeInit?(instance: any, token: any, context: any): void | Promise<void>;
|
|
32
|
+
onAfterInit?(instance: any, token: any, context: any): void | Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
export interface HyperAppMetadata {
|
|
35
|
+
name?: string;
|
|
36
|
+
version?: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
author?: string;
|
|
39
|
+
license?: string;
|
|
40
|
+
prefix?: string;
|
|
41
|
+
logger?: (...args: any[]) => void;
|
|
42
|
+
logs?: Partial<LogSpaces>;
|
|
43
|
+
modules: Constructor[];
|
|
44
|
+
imports?: ImportType[];
|
|
45
|
+
options?: ServerConstructorOptions;
|
|
46
|
+
uwsOptions?: any;
|
|
47
|
+
transports?: IMessageTransport[];
|
|
48
|
+
hooks?: IHyperHooks | Constructor<IHyperHooks>;
|
|
49
|
+
}
|
|
50
|
+
export interface HyperAppDecorator {
|
|
51
|
+
(options?: HyperAppMetadata): (target: Constructor) => Constructor;
|
|
52
|
+
}
|
|
53
|
+
export type HyperModuleMetadata = {
|
|
54
|
+
path?: string;
|
|
55
|
+
name?: string;
|
|
56
|
+
roles?: string[];
|
|
57
|
+
scopes?: string[];
|
|
58
|
+
modules?: Constructor[];
|
|
59
|
+
controllers?: Constructor[];
|
|
60
|
+
imports?: ImportType[];
|
|
61
|
+
};
|
|
62
|
+
export type HyperModuleDecorator = HyperClassDecorator<HyperModuleMetadata>;
|
|
63
|
+
export type HyperControllerMetadata = {
|
|
64
|
+
path?: string;
|
|
65
|
+
roles?: string[];
|
|
66
|
+
scopes?: string[];
|
|
67
|
+
imports?: ImportType[];
|
|
68
|
+
};
|
|
69
|
+
export type HyperControllerDecorator = HyperClassDecorator<HyperControllerMetadata | string>;
|
|
70
|
+
export type ParameterResolver = (req: Request, res: Response) => any | Promise<any>;
|
|
71
|
+
export type HyperParameterMetadata = {
|
|
72
|
+
params: {
|
|
73
|
+
index: number;
|
|
74
|
+
type: Constructor | Function;
|
|
75
|
+
source?: "body" | "query" | "params" | "headers" | "req" | "res";
|
|
76
|
+
picker?: string;
|
|
77
|
+
schema?: object | Function;
|
|
78
|
+
isWholeSource?: boolean;
|
|
79
|
+
name?: string;
|
|
80
|
+
decorator: string;
|
|
81
|
+
resolver?: ParameterResolver;
|
|
82
|
+
}[];
|
|
83
|
+
};
|
|
84
|
+
export type HyperParamDecorator = (key: string) => (target: any, key: string, index: number) => void;
|
|
85
|
+
export type RoleMap<T> = {
|
|
86
|
+
role: T;
|
|
87
|
+
description: string;
|
|
88
|
+
message?: string;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Type definition for Role decorator.
|
|
92
|
+
* It can accept a single role, an array of roles, or a function that evaluates roles dynamically.
|
|
93
|
+
*/
|
|
94
|
+
export type RoleType<T extends string = string> = T | T[] | RoleMap<T> | RoleMap<T>[];
|
|
95
|
+
export type ScopeMap<T extends string = string> = {
|
|
96
|
+
scope: T;
|
|
97
|
+
description: string;
|
|
98
|
+
message?: string;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Type definition for Scope decorator.
|
|
102
|
+
* It can accept a single scope or multiple scopes as an array of strings.
|
|
103
|
+
*/
|
|
104
|
+
export type ScopeType<T extends string = string> = T | T[] | ScopeMap<T> | ScopeMap<T>[];
|
|
105
|
+
/**
|
|
106
|
+
* Type definition for Route metadata.
|
|
107
|
+
* Contains method, path, and other configuration for a specific method.
|
|
108
|
+
*/
|
|
109
|
+
export interface RouteMetadata {
|
|
110
|
+
method: string;
|
|
111
|
+
path: string;
|
|
112
|
+
propertyKey: string;
|
|
113
|
+
options?: Record<string, unknown>;
|
|
114
|
+
}
|
|
115
|
+
export declare abstract class MiddlewareClass {
|
|
116
|
+
abstract handle(req: Request, res: Response, next: MiddlewareNext): void;
|
|
117
|
+
}
|
|
118
|
+
export interface MiddlewareClassConstructor {
|
|
119
|
+
new (...args: any[]): MiddlewareClass;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Type definition for Middleware.
|
|
123
|
+
* Middleware can be a single handler or an array of handlers.
|
|
124
|
+
*/
|
|
125
|
+
export type MiddlewareType = MiddlewareHandler | MiddlewareClassConstructor;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import HyperException from "./HyperException";
|
|
2
|
+
export default class DuplicateControllerPathException extends HyperException {
|
|
3
|
+
constructor(data: {
|
|
4
|
+
path: string;
|
|
5
|
+
current: {
|
|
6
|
+
module: string;
|
|
7
|
+
controller: string;
|
|
8
|
+
};
|
|
9
|
+
duplicate: {
|
|
10
|
+
module: string;
|
|
11
|
+
controller: string;
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
+
class DuplicateControllerPathException extends HyperException_1.default {
|
|
8
|
+
constructor(data) {
|
|
9
|
+
super(`Duplicate controller path: '${data.path}' in ${data.current.module}/${data.current.controller} and ${data.duplicate.module} controller: ${data.duplicate.controller}`, "DuplicateControllerPathException", data);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = DuplicateControllerPathException;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
+
class DuplicatedException extends HyperException_1.default {
|
|
8
|
+
constructor(data) {
|
|
9
|
+
super(`Duplicate at path: '${data.path}' in ${data.currentNameSpace} and ${data.duplicateNameSpace}`, "DuplicatedException", data);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = DuplicatedException;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
+
class DuplicatedHandlerException extends HyperException_1.default {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message, "DuplicateHandlerException");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = DuplicatedHandlerException;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ExceptionType } from "./types";
|
|
2
|
+
export default class HyperException extends Error {
|
|
3
|
+
code: ExceptionType;
|
|
4
|
+
additionalInfo: any;
|
|
5
|
+
status: number;
|
|
6
|
+
constructor(message: string, code?: ExceptionType, additionalInfo?: any, status?: number);
|
|
7
|
+
static throw(message: string, code?: ExceptionType, additionalInfo?: {}): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class HyperException extends Error {
|
|
4
|
+
constructor(message, code = "HyperException", additionalInfo = {}, status = 500) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.additionalInfo = additionalInfo;
|
|
8
|
+
this.status = status;
|
|
9
|
+
}
|
|
10
|
+
static throw(message, code, additionalInfo = {}) {
|
|
11
|
+
throw new this(message, code, additionalInfo);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = HyperException;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
+
class HyperFileException extends HyperException_1.default {
|
|
8
|
+
constructor(message, additional) {
|
|
9
|
+
super(message, "HyperFileException", additional, 400);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = HyperFileException;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
+
class MethodNotFountException extends HyperException_1.default {
|
|
8
|
+
constructor(className, method, path) {
|
|
9
|
+
super(`Method ${method} not exists in ${className} for path ${path}`, "MethodNotFountException");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.default = MethodNotFountException;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const HyperException_1 = __importDefault(require("./HyperException"));
|
|
7
|
+
class NotPropertyException extends HyperException_1.default {
|
|
8
|
+
constructor(namespace, target) {
|
|
9
|
+
super(`This decorator cannot be used as a property decorator in ${namespace}`, "NotPropertyException", {
|
|
10
|
+
target,
|
|
11
|
+
});
|
|
12
|
+
this.namespace = namespace;
|
|
13
|
+
this.target = target;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.default = NotPropertyException;
|