@zenofolio/hyper-decor 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/.mocharc.js +5 -0
  2. package/LICENSE +21 -0
  3. package/README.md +191 -0
  4. package/dist/__internals/constants.d.ts +61 -0
  5. package/dist/__internals/constants.js +72 -0
  6. package/dist/__internals/creators/request.creator.d.ts +12 -0
  7. package/dist/__internals/creators/request.creator.js +53 -0
  8. package/dist/__internals/creators/routes.creator.d.ts +10 -0
  9. package/dist/__internals/creators/routes.creator.js +37 -0
  10. package/dist/__internals/decorator-base.d.ts +30 -0
  11. package/dist/__internals/decorator-base.js +86 -0
  12. package/dist/__internals/helpers/merge-metadata.d.ts +14 -0
  13. package/dist/__internals/helpers/merge-metadata.js +44 -0
  14. package/dist/__internals/helpers/who.helper.d.ts +9 -0
  15. package/dist/__internals/helpers/who.helper.js +19 -0
  16. package/dist/__internals/store.d.ts +10 -0
  17. package/dist/__internals/store.js +17 -0
  18. package/dist/__internals/stores/index.d.ts +15 -0
  19. package/dist/__internals/stores/index.js +37 -0
  20. package/dist/__internals/stores/middleware.store.d.ts +7 -0
  21. package/dist/__internals/stores/middleware.store.js +19 -0
  22. package/dist/__internals/stores/params.store.d.ts +21 -0
  23. package/dist/__internals/stores/params.store.js +65 -0
  24. package/dist/__internals/stores/routes.store.d.ts +17 -0
  25. package/dist/__internals/stores/routes.store.js +43 -0
  26. package/dist/__internals/stores/store.interface.d.ts +8 -0
  27. package/dist/__internals/stores/store.interface.js +2 -0
  28. package/dist/__internals/transform/method.transform.d.ts +2 -0
  29. package/dist/__internals/transform/method.transform.js +20 -0
  30. package/dist/__internals/transform/pass.transfrom.d.ts +1 -0
  31. package/dist/__internals/transform/pass.transfrom.js +2 -0
  32. package/dist/__internals/transform/role.transform.d.ts +7 -0
  33. package/dist/__internals/transform/role.transform.js +86 -0
  34. package/dist/__internals/transform/scope.transfrom.d.ts +7 -0
  35. package/dist/__internals/transform/scope.transfrom.js +72 -0
  36. package/dist/__internals/types.d.ts +8 -0
  37. package/dist/__internals/types.js +2 -0
  38. package/dist/__internals/utils/function.util.d.ts +4 -0
  39. package/dist/__internals/utils/function.util.js +20 -0
  40. package/dist/__internals/utils/mixin.utils.d.ts +11 -0
  41. package/dist/__internals/utils/mixin.utils.js +34 -0
  42. package/dist/__internals/utils/object.util.d.ts +27 -0
  43. package/dist/__internals/utils/object.util.js +72 -0
  44. package/dist/__internals/utils/path.util.d.ts +4 -0
  45. package/dist/__internals/utils/path.util.js +8 -0
  46. package/dist/__internals/utils/router.d.ts +1 -0
  47. package/dist/__internals/utils/router.js +2 -0
  48. package/dist/common/bootstrap.d.ts +3 -0
  49. package/dist/common/bootstrap.js +25 -0
  50. package/dist/common/helpers/index.d.ts +2 -0
  51. package/dist/common/helpers/index.js +18 -0
  52. package/dist/common/helpers/role.d.ts +22 -0
  53. package/dist/common/helpers/role.js +43 -0
  54. package/dist/common/helpers/scopes.d.ts +23 -0
  55. package/dist/common/helpers/scopes.js +47 -0
  56. package/dist/common/openapi/collect-class-data.d.ts +21 -0
  57. package/dist/common/openapi/collect-class-data.js +45 -0
  58. package/dist/common/openapi/collect-function-data.d.ts +32 -0
  59. package/dist/common/openapi/collect-function-data.js +70 -0
  60. package/dist/common/openapi/index.d.ts +2 -0
  61. package/dist/common/openapi/index.js +18 -0
  62. package/dist/constants.d.ts +3 -0
  63. package/dist/constants.js +6 -0
  64. package/dist/decorators/File.d.ts +65 -0
  65. package/dist/decorators/File.js +180 -0
  66. package/dist/decorators/Http.d.ts +55 -0
  67. package/dist/decorators/Http.js +93 -0
  68. package/dist/decorators/HyperApp.d.ts +7 -0
  69. package/dist/decorators/HyperApp.js +262 -0
  70. package/dist/decorators/HyperController.d.ts +2 -0
  71. package/dist/decorators/HyperController.js +19 -0
  72. package/dist/decorators/HyperModule.d.ts +5 -0
  73. package/dist/decorators/HyperModule.js +14 -0
  74. package/dist/decorators/Middleware.d.ts +24 -0
  75. package/dist/decorators/Middleware.js +51 -0
  76. package/dist/decorators/Pass.d.ts +12 -0
  77. package/dist/decorators/Pass.js +29 -0
  78. package/dist/decorators/Role.d.ts +6 -0
  79. package/dist/decorators/Role.js +34 -0
  80. package/dist/decorators/Routes.d.ts +14 -0
  81. package/dist/decorators/Routes.js +21 -0
  82. package/dist/decorators/Scope.d.ts +6 -0
  83. package/dist/decorators/Scope.js +25 -0
  84. package/dist/decorators/index.d.ts +11 -0
  85. package/dist/decorators/index.js +27 -0
  86. package/dist/decorators/types.d.ts +89 -0
  87. package/dist/decorators/types.js +2 -0
  88. package/dist/exeptions/DuplicateControllerPathException.d.ts +14 -0
  89. package/dist/exeptions/DuplicateControllerPathException.js +12 -0
  90. package/dist/exeptions/DuplicatedException.d.ts +8 -0
  91. package/dist/exeptions/DuplicatedException.js +12 -0
  92. package/dist/exeptions/DuplicatedHandlerException.d.ts +4 -0
  93. package/dist/exeptions/DuplicatedHandlerException.js +12 -0
  94. package/dist/exeptions/HyperException.d.ts +7 -0
  95. package/dist/exeptions/HyperException.js +13 -0
  96. package/dist/exeptions/HyperFileException.d.ts +4 -0
  97. package/dist/exeptions/HyperFileException.js +12 -0
  98. package/dist/exeptions/MethodNotFountException.d.ts +4 -0
  99. package/dist/exeptions/MethodNotFountException.js +12 -0
  100. package/dist/exeptions/NotPropertyException.d.ts +6 -0
  101. package/dist/exeptions/NotPropertyException.js +16 -0
  102. package/dist/exeptions/NotRoleException.d.ts +6 -0
  103. package/dist/exeptions/NotRoleException.js +17 -0
  104. package/dist/exeptions/NotScopeException.d.ts +7 -0
  105. package/dist/exeptions/NotScopeException.js +18 -0
  106. package/dist/exeptions/WrongPlaceException.d.ts +8 -0
  107. package/dist/exeptions/WrongPlaceException.js +21 -0
  108. package/dist/exeptions/index.d.ts +8 -0
  109. package/dist/exeptions/index.js +18 -0
  110. package/dist/exeptions/types.d.ts +1 -0
  111. package/dist/exeptions/types.js +2 -0
  112. package/dist/extension.d.ts +1 -0
  113. package/dist/extension.js +41 -0
  114. package/dist/index.d.ts +9 -0
  115. package/dist/index.js +25 -0
  116. package/dist/type.d.ts +10 -0
  117. package/dist/type.js +2 -0
  118. package/hyper-express-decorators.d.ts +16 -0
  119. package/package.json +61 -0
  120. package/tsconfig.json +17 -0
@@ -0,0 +1,51 @@
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
+ exports.Middleware = void 0;
7
+ require("reflect-metadata");
8
+ const constants_1 = require("../__internals/constants");
9
+ const stores_1 = __importDefault(require("../__internals/stores"));
10
+ /**
11
+ * Middleware decorator to attach middleware to controllers, modules, and routes.
12
+ */
13
+ const Middleware = (...middleware) => (Target, propertyKey, descriptor) => {
14
+ stores_1.default.define(constants_1.KEY_PARAMS_MIDDLEWARES, middleware, {
15
+ target: Target,
16
+ propertyKey,
17
+ });
18
+ };
19
+ exports.Middleware = Middleware;
20
+ /**
21
+ * Exclude middleware from matching paths.
22
+ *
23
+ * @param expresiosn
24
+ * @param middleware
25
+ * @returns
26
+ */
27
+ exports.Middleware.exclude = (expresiosn, middleware) => {
28
+ return (0, exports.Middleware)((req, res, next) => {
29
+ expresiosn = Array.isArray(expresiosn) ? expresiosn : [expresiosn];
30
+ const excluude = expresiosn.some((exp) => exp.test(req.path));
31
+ if (excluude)
32
+ return next();
33
+ return middleware(req, res, next);
34
+ });
35
+ };
36
+ /**
37
+ * Only run middleware on matching paths.
38
+ *
39
+ * @param expresiosn
40
+ * @param middleware
41
+ * @returns
42
+ */
43
+ exports.Middleware.only = (expresiosn, middleware) => {
44
+ return (0, exports.Middleware)((req, res, next) => {
45
+ expresiosn = Array.isArray(expresiosn) ? expresiosn : [expresiosn];
46
+ const only = expresiosn.some((exp) => exp.test(req.path));
47
+ if (!only)
48
+ return next();
49
+ return middleware(req, res, next);
50
+ });
51
+ };
@@ -0,0 +1,12 @@
1
+ import { Request, Response } from "hyper-express";
2
+ interface PassOptions {
3
+ (req: Request, res: Response): boolean | Promise<boolean>;
4
+ }
5
+ /**
6
+ * This method will pass all checks if the function returns true.
7
+ *
8
+ * @param options
9
+ * @returns
10
+ */
11
+ export declare const Pass: (options: PassOptions) => ClassDecorator & MethodDecorator;
12
+ export {};
@@ -0,0 +1,29 @@
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
+ exports.Pass = void 0;
7
+ const who_helper_1 = __importDefault(require("../__internals/helpers/who.helper"));
8
+ const NotPropertyException_1 = __importDefault(require("../exeptions/NotPropertyException"));
9
+ const constants_1 = require("../__internals/constants");
10
+ /**
11
+ * This method will pass all checks if the function returns true.
12
+ *
13
+ * @param options
14
+ * @returns
15
+ */
16
+ const Pass = (options) => (target, propertyKey, descriptorOrIndex) => {
17
+ const { isProperty, isMethod } = (0, who_helper_1.default)(target, propertyKey, descriptorOrIndex);
18
+ if (isProperty) {
19
+ throw new NotPropertyException_1.default(`${target.constructor.name}.${propertyKey === null || propertyKey === void 0 ? void 0 : propertyKey.toString()}`, target);
20
+ }
21
+ if (isMethod) {
22
+ Reflect.defineMetadata(constants_1.KEY_PARAMS_PASS, options, target, propertyKey);
23
+ }
24
+ else {
25
+ Reflect.defineMetadata(constants_1.KEY_PARAMS_PASS, options, target);
26
+ }
27
+ return target;
28
+ };
29
+ exports.Pass = Pass;
@@ -0,0 +1,6 @@
1
+ import "reflect-metadata";
2
+ import { RoleType } from "./types";
3
+ /**
4
+ * Role decorator for setting role-based access control.
5
+ */
6
+ export declare const Role: <T extends string = string>(roles: RoleType<T>) => (target: any, propertyKey?: any, descriptorOrIndex?: any) => void;
@@ -0,0 +1,34 @@
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
+ exports.Role = void 0;
7
+ require("reflect-metadata");
8
+ const constants_1 = require("../__internals/constants");
9
+ const who_helper_1 = __importDefault(require("../__internals/helpers/who.helper"));
10
+ const stores_1 = __importDefault(require("../__internals/stores"));
11
+ const exeptions_1 = require("../exeptions");
12
+ /**
13
+ * Role decorator for setting role-based access control.
14
+ */
15
+ const Role = (roles) => (target, propertyKey, descriptorOrIndex) => {
16
+ const _roles = Array.isArray(roles) ? roles : [roles];
17
+ if (!_roles.length) {
18
+ exeptions_1.HyperException.throw(`Role decorator must have at least one role.`, "HyperException", {
19
+ target,
20
+ propertyKey,
21
+ descriptorOrIndex,
22
+ });
23
+ }
24
+ const { isProperty, isMethod } = (0, who_helper_1.default)(target, propertyKey, descriptorOrIndex);
25
+ if (isProperty) {
26
+ throw new Error(`Scope decorator cannot be used as parameter decorator in ${target.constructor.name}.${propertyKey}`);
27
+ }
28
+ const list = stores_1.default.list(constants_1.KEY_PARAMS_ROLE, {
29
+ target,
30
+ propertyKey,
31
+ });
32
+ list.set(..._roles);
33
+ };
34
+ exports.Role = Role;
@@ -0,0 +1,14 @@
1
+ import "reflect-metadata";
2
+ export declare const Get: (path?: string) => MethodDecorator & ClassDecorator;
3
+ export declare const Post: (path?: string) => MethodDecorator & ClassDecorator;
4
+ export declare const Put: (path?: string) => MethodDecorator & ClassDecorator;
5
+ export declare const Delete: (path?: string) => MethodDecorator & ClassDecorator;
6
+ export declare const Patch: (path?: string) => MethodDecorator & ClassDecorator;
7
+ export declare const Options: (path?: string) => MethodDecorator & ClassDecorator;
8
+ export declare const Head: (path?: string) => MethodDecorator & ClassDecorator;
9
+ export declare const Trace: (path?: string) => MethodDecorator & ClassDecorator;
10
+ export declare const Any: (path?: string) => MethodDecorator & ClassDecorator;
11
+ export declare const All: (path?: string) => MethodDecorator & ClassDecorator;
12
+ export declare const Connect: (path?: string) => MethodDecorator & ClassDecorator;
13
+ export declare const WS: (path?: string) => MethodDecorator & ClassDecorator;
14
+ export declare const Upgrade: (path?: string) => MethodDecorator & ClassDecorator;
@@ -0,0 +1,21 @@
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
+ 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;
7
+ require("reflect-metadata");
8
+ const routes_creator_1 = __importDefault(require("../__internals/creators/routes.creator"));
9
+ exports.Get = (0, routes_creator_1.default)("get");
10
+ exports.Post = (0, routes_creator_1.default)("post");
11
+ exports.Put = (0, routes_creator_1.default)("put");
12
+ exports.Delete = (0, routes_creator_1.default)("delete");
13
+ exports.Patch = (0, routes_creator_1.default)("patch");
14
+ exports.Options = (0, routes_creator_1.default)("options");
15
+ exports.Head = (0, routes_creator_1.default)("head");
16
+ exports.Trace = (0, routes_creator_1.default)("trace");
17
+ exports.Any = (0, routes_creator_1.default)("any");
18
+ exports.All = (0, routes_creator_1.default)("all");
19
+ exports.Connect = (0, routes_creator_1.default)("connect");
20
+ exports.WS = (0, routes_creator_1.default)("ws");
21
+ exports.Upgrade = (0, routes_creator_1.default)("upgrade");
@@ -0,0 +1,6 @@
1
+ import "reflect-metadata";
2
+ import { ScopeType } from "./types";
3
+ /**
4
+ * Scope decorator for defining access scopes.
5
+ */
6
+ export declare const Scope: <T extends string = string>(scopes: ScopeType<T>) => ClassDecorator & MethodDecorator & ParameterDecorator;
@@ -0,0 +1,25 @@
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
+ exports.Scope = void 0;
7
+ require("reflect-metadata");
8
+ const constants_1 = require("../__internals/constants");
9
+ const who_helper_1 = __importDefault(require("../__internals/helpers/who.helper"));
10
+ const stores_1 = __importDefault(require("../__internals/stores"));
11
+ /**
12
+ * Scope decorator for defining access scopes.
13
+ */
14
+ const Scope = (scopes) => (target, propertyKey, descriptorOrIndex) => {
15
+ const { isProperty, isMethod } = (0, who_helper_1.default)(target, propertyKey, descriptorOrIndex);
16
+ if (isProperty) {
17
+ throw new Error(`Scope decorator cannot be used as parameter decorator in ${target.constructor.name}.${propertyKey}`);
18
+ }
19
+ const list = stores_1.default.list(constants_1.KEY_PARAMS_SCOPE, {
20
+ target,
21
+ propertyKey,
22
+ });
23
+ list.set(...(Array.isArray(scopes) ? scopes : [scopes]));
24
+ };
25
+ exports.Scope = Scope;
@@ -0,0 +1,11 @@
1
+ export * from "./HyperApp";
2
+ export * from "./HyperModule";
3
+ export * from "./HyperController";
4
+ export * from "./Middleware";
5
+ export * from "./Scope";
6
+ export * from "./Role";
7
+ export * from "./Routes";
8
+ export * from "./types";
9
+ export * from "./Http";
10
+ export * from "./Pass";
11
+ export * from "./File";
@@ -0,0 +1,27 @@
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("./HyperApp"), exports);
18
+ __exportStar(require("./HyperModule"), exports);
19
+ __exportStar(require("./HyperController"), exports);
20
+ __exportStar(require("./Middleware"), exports);
21
+ __exportStar(require("./Scope"), exports);
22
+ __exportStar(require("./Role"), exports);
23
+ __exportStar(require("./Routes"), exports);
24
+ __exportStar(require("./types"), exports);
25
+ __exportStar(require("./Http"), exports);
26
+ __exportStar(require("./Pass"), exports);
27
+ __exportStar(require("./File"), exports);
@@ -0,0 +1,89 @@
1
+ import type { MiddlewareHandler, Request, Response, ServerConstructorOptions } from "hyper-express";
2
+ export type Constructor<R extends any = any> = new (...args: any[]) => R;
3
+ export type ConstructorDecorator = (target: Constructor, kay?: any, descriptor?: PropertyDescriptor) => Constructor;
4
+ export type HyperClassDecorator<T> = (options?: T) => ConstructorDecorator;
5
+ export type HyperMethodDecorator<T> = (options?: T) => (target: any, key?: any, descriptor?: PropertyDescriptor) => void;
6
+ export interface LogSpaces {
7
+ controllers: boolean;
8
+ middleware: boolean;
9
+ routes: boolean;
10
+ }
11
+ export interface HyperAppMetadata {
12
+ name?: string;
13
+ version?: string;
14
+ description?: string;
15
+ author?: string;
16
+ license?: string;
17
+ prefix?: string;
18
+ logger?: (...args: any[]) => void;
19
+ logs?: LogSpaces;
20
+ modules: Constructor[];
21
+ imports?: Constructor[];
22
+ options?: ServerConstructorOptions;
23
+ }
24
+ export type HyperAppDecorator = (options?: HyperAppMetadata) => (target: Constructor) => Constructor;
25
+ export type HyperModuleMetadata = {
26
+ path: string;
27
+ name?: string;
28
+ roles?: string[];
29
+ scopes?: string[];
30
+ modules?: Constructor[];
31
+ controllers?: Constructor[];
32
+ imports?: Constructor[];
33
+ };
34
+ export type HyperModuleDecorator = HyperClassDecorator<HyperModuleMetadata>;
35
+ export type HyperControllerMetadata = {
36
+ path?: string;
37
+ roles?: string[];
38
+ scopes?: string[];
39
+ imports?: Constructor[];
40
+ };
41
+ export type HyperControllerDecorator = HyperClassDecorator<HyperControllerMetadata | string>;
42
+ export type ParameterResolver = (req: Request, res: Response) => any | Promise<any>;
43
+ export type HyperParamerMetadata = {
44
+ params: Record<string, {
45
+ index: number;
46
+ type: any;
47
+ key: string;
48
+ name: string;
49
+ method: string;
50
+ resolver: ParameterResolver;
51
+ }[]>;
52
+ };
53
+ export type HyperParamDecorator = (key: string) => (target: any, key: string, index: number) => void;
54
+ export type RoleMap<T> = {
55
+ role: T;
56
+ description: string;
57
+ message?: string;
58
+ };
59
+ /**
60
+ * Type definition for Role decorator.
61
+ * It can accept a single role, an array of roles, or a function that evaluates roles dynamically.
62
+ */
63
+ export type RoleType<T extends string = string> = T | T[] | RoleMap<T> | RoleMap<T>[];
64
+ export type ScopeMap<T> = {
65
+ scope: T;
66
+ description: string;
67
+ message?: string;
68
+ };
69
+ /**
70
+ * Type definition for Scope decorator.
71
+ * It can accept a single scope or multiple scopes as an array of strings.
72
+ */
73
+ export type ScopeType<T extends string = string> = T | T[] | ScopeMap<T> | ScopeMap<T>[];
74
+ /**
75
+ * Type definition for Route metadata.
76
+ * Contains method, path, and handler function name.
77
+ */
78
+ export interface RouteMetadata {
79
+ className: string;
80
+ method: string;
81
+ path: string;
82
+ propertyKey: string;
83
+ handler: (...args: any[]) => any;
84
+ }
85
+ /**
86
+ * Type definition for Middleware.
87
+ * Middleware can be a single handler or an array of handlers.
88
+ */
89
+ export type MiddlewareType = MiddlewareHandler | MiddlewareHandler[];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,8 @@
1
+ import HyperException from "./HyperException";
2
+ export default class DuplicatedException extends HyperException {
3
+ constructor(data: {
4
+ path: string;
5
+ currentNameSpace: string;
6
+ duplicateNameSpace: string;
7
+ });
8
+ }
@@ -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,4 @@
1
+ import HyperException from "./HyperException";
2
+ export default class DuplicatedHandlerException extends HyperException {
3
+ constructor(message: string);
4
+ }
@@ -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,7 @@
1
+ import { ExceptionType } from "./types";
2
+ export default class HyperException extends Error {
3
+ code: ExceptionType;
4
+ additionalInfo: any;
5
+ constructor(message: string, code?: ExceptionType, additionalInfo?: any);
6
+ static throw(message: string, code?: ExceptionType, additionalInfo?: {}): void;
7
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class HyperException extends Error {
4
+ constructor(message, code = "HyperException", additionalInfo = {}) {
5
+ super(message);
6
+ this.code = code;
7
+ this.additionalInfo = additionalInfo;
8
+ }
9
+ static throw(message, code, additionalInfo = {}) {
10
+ throw new this(message, code, additionalInfo);
11
+ }
12
+ }
13
+ exports.default = HyperException;
@@ -0,0 +1,4 @@
1
+ import HyperException from "./HyperException";
2
+ export default class HyperFileException extends HyperException {
3
+ constructor(message: string, additional?: any);
4
+ }
@@ -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);
10
+ }
11
+ }
12
+ exports.default = HyperFileException;
@@ -0,0 +1,4 @@
1
+ import HyperException from "./HyperException";
2
+ export default class MethodNotFountException extends HyperException {
3
+ constructor(className: string, method: string, path: string);
4
+ }
@@ -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,6 @@
1
+ import HyperException from "./HyperException";
2
+ export default class NotPropertyException extends HyperException {
3
+ namespace: string;
4
+ target: any;
5
+ constructor(namespace: string, target: any);
6
+ }
@@ -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;
@@ -0,0 +1,6 @@
1
+ import HyperException from "./HyperException";
2
+ export default class NotRoleException extends HyperException {
3
+ roles: string[];
4
+ requiredRoles: string[];
5
+ constructor(message?: string, roles?: string[], requiredRoles?: string[]);
6
+ }
@@ -0,0 +1,17 @@
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 NotRoleException extends HyperException_1.default {
8
+ constructor(message = `Has not Permission to access this resource`, roles = [], requiredRoles = []) {
9
+ super(message, "NotRoleException", {
10
+ roles,
11
+ requiredRoles,
12
+ });
13
+ this.roles = roles;
14
+ this.requiredRoles = requiredRoles;
15
+ }
16
+ }
17
+ exports.default = NotRoleException;
@@ -0,0 +1,7 @@
1
+ import HyperException from "./HyperException";
2
+ export default class NotScopeException extends HyperException {
3
+ message: string;
4
+ requestScopes: string[];
5
+ requiredScopes: string[];
6
+ constructor(message: string, requestScopes?: string[], requiredScopes?: string[]);
7
+ }
@@ -0,0 +1,18 @@
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 NotScopeException extends HyperException_1.default {
8
+ constructor(message, requestScopes = [], requiredScopes = []) {
9
+ super(message || `You don't have the required scopes to access this resource`, "NotScopeException", {
10
+ requestScopes,
11
+ requiredScopes,
12
+ });
13
+ this.message = message;
14
+ this.requestScopes = requestScopes;
15
+ this.requiredScopes = requiredScopes;
16
+ }
17
+ }
18
+ exports.default = NotScopeException;
@@ -0,0 +1,8 @@
1
+ import HyperException from "./HyperException";
2
+ export default class WrongPlaceException extends HyperException {
3
+ decorator: string;
4
+ as: string;
5
+ namespace: string;
6
+ target: any;
7
+ constructor(decorator: string, as: string, namespace: string, target: any);
8
+ }
@@ -0,0 +1,21 @@
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 WrongPlaceException extends HyperException_1.default {
8
+ constructor(decorator, as, namespace, target) {
9
+ super(`The decorator @${decorator} only can be used as a ${as} decorator. Error => ${namespace}`, "WrongPlaceException", {
10
+ decorator,
11
+ target,
12
+ namespace,
13
+ as,
14
+ });
15
+ this.decorator = decorator;
16
+ this.as = as;
17
+ this.namespace = namespace;
18
+ this.target = target;
19
+ }
20
+ }
21
+ exports.default = WrongPlaceException;
@@ -0,0 +1,8 @@
1
+ import DuplicatedHandlerException from "./DuplicatedHandlerException";
2
+ import DuplicateControllerPathException from "./DuplicateControllerPathException";
3
+ import HyperException from "./HyperException";
4
+ import MethodNotFountException from "./MethodNotFountException";
5
+ import NotRoleException from "./NotRoleException";
6
+ import NotScopeException from "./NotScopeException";
7
+ export type * from "./types";
8
+ export { DuplicatedHandlerException, DuplicateControllerPathException as DuplicatedRouterException, HyperException, NotRoleException, NotScopeException, MethodNotFountException as MethodNotExists, };
@@ -0,0 +1,18 @@
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
+ exports.MethodNotExists = exports.NotScopeException = exports.NotRoleException = exports.HyperException = exports.DuplicatedRouterException = exports.DuplicatedHandlerException = void 0;
7
+ const DuplicatedHandlerException_1 = __importDefault(require("./DuplicatedHandlerException"));
8
+ exports.DuplicatedHandlerException = DuplicatedHandlerException_1.default;
9
+ const DuplicateControllerPathException_1 = __importDefault(require("./DuplicateControllerPathException"));
10
+ exports.DuplicatedRouterException = DuplicateControllerPathException_1.default;
11
+ const HyperException_1 = __importDefault(require("./HyperException"));
12
+ exports.HyperException = HyperException_1.default;
13
+ const MethodNotFountException_1 = __importDefault(require("./MethodNotFountException"));
14
+ exports.MethodNotExists = MethodNotFountException_1.default;
15
+ const NotRoleException_1 = __importDefault(require("./NotRoleException"));
16
+ exports.NotRoleException = NotRoleException_1.default;
17
+ const NotScopeException_1 = __importDefault(require("./NotScopeException"));
18
+ exports.NotScopeException = NotScopeException_1.default;
@@ -0,0 +1 @@
1
+ export type ExceptionType = "DuplicateControllerException" | "DuplicateHandlerException" | "DuplicateRouterException" | "HyperException" | "NotRoleException" | "NotScopeException" | "MethodNotFountException" | "DuplicateControllerPathException" | "DuplicateHandlerException" | "DuplicatedException" | "NotPropertyException" | "WrongPlaceException" | "HyperFileException" | "DpublicateModuleException";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export {};