@zenofolio/hyper-decor 1.0.72 → 1.0.74

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 (118) hide show
  1. package/.agent/rules/philosophy.md +103 -0
  2. package/.agent/rules/writing.md +32 -0
  3. package/README.md +114 -136
  4. package/dist/__internals/constants.d.ts +1 -62
  5. package/dist/__internals/constants.js +3 -69
  6. package/dist/__internals/helpers/merge-metadata.d.ts +2 -3
  7. package/dist/__internals/helpers/merge-metadata.js +31 -7
  8. package/dist/__internals/helpers/prepare.helper.d.ts +4 -10
  9. package/dist/__internals/helpers/prepare.helper.js +316 -271
  10. package/dist/__internals/stores/hyper.store.d.ts +5 -0
  11. package/dist/__internals/stores/hyper.store.js +5 -0
  12. package/dist/__internals/stores/index.d.ts +4 -0
  13. package/dist/__internals/stores/index.js +20 -0
  14. package/dist/__internals/stores/meta.store.d.ts +34 -0
  15. package/dist/__internals/stores/meta.store.js +107 -0
  16. package/dist/__internals/stores/scope.store.d.ts +14 -0
  17. package/dist/__internals/stores/scope.store.js +29 -0
  18. package/dist/__internals/stores/serivces.store.d.ts +1 -0
  19. package/dist/__internals/stores/serivces.store.js +4 -0
  20. package/dist/__internals/transform/middleware.transform.d.ts +1 -1
  21. package/dist/__internals/transform/middleware.transform.js +1 -1
  22. package/dist/__internals/transform/role.transform.d.ts +1 -1
  23. package/dist/__internals/transform/role.transform.js +4 -4
  24. package/dist/__internals/transform/scope.transfrom.d.ts +1 -1
  25. package/dist/__internals/transform/scope.transfrom.js +2 -2
  26. package/dist/__internals/types.d.ts +53 -4
  27. package/dist/common/bootstrap.d.ts +6 -2
  28. package/dist/common/bootstrap.js +44 -10
  29. package/dist/common/transport.d.ts +1 -0
  30. package/dist/common/transport.js +27 -14
  31. package/dist/constants.d.ts +1 -0
  32. package/dist/constants.js +2 -1
  33. package/dist/decorators.d.ts +1 -0
  34. package/dist/decorators.js +17 -0
  35. package/dist/index.d.ts +6 -5
  36. package/dist/index.js +6 -5
  37. package/dist/lib/event/meta.store.d.ts +4 -0
  38. package/dist/lib/event/meta.store.js +5 -0
  39. package/dist/lib/openapi/collectors/class.collector.d.ts +5 -9
  40. package/dist/lib/openapi/collectors/class.collector.js +6 -63
  41. package/dist/lib/openapi/collectors/index.d.ts +3 -4
  42. package/dist/lib/openapi/collectors/index.js +0 -1
  43. package/dist/lib/openapi/collectors/method.collector.d.ts +6 -1
  44. package/dist/lib/openapi/collectors/method.collector.js +92 -59
  45. package/dist/lib/openapi/collectors/schema.collector.d.ts +3 -8
  46. package/dist/lib/openapi/collectors/schema.collector.js +17 -25
  47. package/dist/lib/openapi/constants.d.ts +1 -0
  48. package/dist/lib/openapi/constants.js +2 -2
  49. package/dist/lib/openapi/decorators.d.ts +16 -0
  50. package/dist/lib/openapi/decorators.js +93 -0
  51. package/dist/lib/openapi/index.d.ts +29 -5
  52. package/dist/lib/openapi/index.js +119 -5
  53. package/dist/lib/openapi/metadata.d.ts +7 -0
  54. package/dist/lib/openapi/metadata.js +8 -0
  55. package/dist/lib/openapi/metadata.registry.d.ts +1 -1
  56. package/dist/lib/server/decorators/File.d.ts +37 -0
  57. package/dist/lib/server/decorators/File.js +167 -0
  58. package/dist/lib/server/decorators/Http.d.ts +12 -0
  59. package/dist/lib/server/decorators/Http.js +56 -0
  60. package/dist/lib/server/decorators/HyperApp.d.ts +7 -0
  61. package/dist/lib/server/decorators/HyperApp.js +14 -0
  62. package/dist/lib/server/decorators/HyperController.d.ts +6 -0
  63. package/dist/lib/server/decorators/HyperController.js +27 -0
  64. package/dist/lib/server/decorators/HyperModule.d.ts +6 -0
  65. package/dist/lib/server/decorators/HyperModule.js +13 -0
  66. package/dist/lib/server/decorators/HyperService.d.ts +11 -0
  67. package/dist/lib/server/decorators/HyperService.js +30 -0
  68. package/dist/lib/server/decorators/Messaging.d.ts +8 -0
  69. package/dist/lib/server/decorators/Messaging.js +19 -0
  70. package/dist/lib/server/decorators/Middleware.d.ts +18 -0
  71. package/dist/lib/server/decorators/Middleware.js +52 -0
  72. package/dist/lib/server/decorators/Output.d.ts +6 -0
  73. package/dist/lib/server/decorators/Output.js +14 -0
  74. package/dist/lib/server/decorators/Pass.d.ts +10 -0
  75. package/dist/lib/server/decorators/Pass.js +13 -0
  76. package/dist/lib/server/decorators/Role.d.ts +7 -0
  77. package/dist/lib/server/decorators/Role.js +14 -0
  78. package/dist/lib/server/decorators/Routes.d.ts +14 -0
  79. package/dist/lib/server/decorators/Routes.js +39 -0
  80. package/dist/lib/server/decorators/Scope.d.ts +7 -0
  81. package/dist/lib/server/decorators/Scope.js +14 -0
  82. package/dist/lib/server/decorators/index.d.ts +16 -0
  83. package/dist/lib/server/decorators/index.js +32 -0
  84. package/dist/lib/server/decorators/metadata.d.ts +1 -0
  85. package/dist/lib/server/decorators/metadata.js +5 -0
  86. package/dist/lib/server/decorators/types.d.ts +125 -0
  87. package/dist/lib/server/decorators/types.js +6 -0
  88. package/dist/lib/server/exeptions/DuplicateControllerPathException.d.ts +14 -0
  89. package/dist/lib/server/exeptions/DuplicateControllerPathException.js +12 -0
  90. package/dist/lib/server/exeptions/DuplicatedException.d.ts +8 -0
  91. package/dist/lib/server/exeptions/DuplicatedException.js +12 -0
  92. package/dist/lib/server/exeptions/DuplicatedHandlerException.d.ts +4 -0
  93. package/dist/lib/server/exeptions/DuplicatedHandlerException.js +12 -0
  94. package/dist/lib/server/exeptions/HyperException.d.ts +8 -0
  95. package/dist/lib/server/exeptions/HyperException.js +14 -0
  96. package/dist/lib/server/exeptions/HyperFileException.d.ts +4 -0
  97. package/dist/lib/server/exeptions/HyperFileException.js +12 -0
  98. package/dist/lib/server/exeptions/MethodNotFountException.d.ts +4 -0
  99. package/dist/lib/server/exeptions/MethodNotFountException.js +12 -0
  100. package/dist/lib/server/exeptions/NotPropertyException.d.ts +6 -0
  101. package/dist/lib/server/exeptions/NotPropertyException.js +16 -0
  102. package/dist/lib/server/exeptions/NotRoleException.d.ts +6 -0
  103. package/dist/lib/server/exeptions/NotRoleException.js +17 -0
  104. package/dist/lib/server/exeptions/NotScopeException.d.ts +7 -0
  105. package/dist/lib/server/exeptions/NotScopeException.js +18 -0
  106. package/dist/lib/server/exeptions/WrongPlaceException.d.ts +8 -0
  107. package/dist/lib/server/exeptions/WrongPlaceException.js +21 -0
  108. package/dist/lib/server/exeptions/index.d.ts +8 -0
  109. package/dist/lib/server/exeptions/index.js +18 -0
  110. package/dist/lib/server/exeptions/types.d.ts +1 -0
  111. package/dist/lib/server/exeptions/types.js +2 -0
  112. package/dist/lib/tree/tree.d.ts +36 -0
  113. package/dist/lib/tree/tree.js +106 -0
  114. package/package.json +9 -2
  115. package/scripts/clean.js +55 -55
  116. package/scripts/test-server.ts +85 -85
  117. package/vitest.config.mjs +31 -30
  118. package/vitest.json +0 -0
@@ -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,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MiddlewareClass = void 0;
4
+ class MiddlewareClass {
5
+ }
6
+ exports.MiddlewareClass = MiddlewareClass;
@@ -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,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,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, 400);
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
+ }, 403);
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
+ }, 403);
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,36 @@
1
+ import { HyperAppMetadata, HyperModuleMetadata, HyperControllerMetadata, HyperParameterMetadata, RouteMetadata, ImportType, Constructor } from "../server/decorators/types";
2
+ export interface AppTree {
3
+ app: HyperAppMetadata & {
4
+ target: object;
5
+ fullPath: string;
6
+ };
7
+ modules: Record<string, ModuleNode>;
8
+ paths: Record<string, RouteNode[]>;
9
+ openapi?: Record<string, unknown>;
10
+ }
11
+ export interface ModuleNode {
12
+ metadata: HyperModuleMetadata;
13
+ target: object;
14
+ fullPath: string;
15
+ modules: Record<string, ModuleNode>;
16
+ controllers: Record<string, ControllerNode>;
17
+ services: ImportType[];
18
+ openapi?: Record<string, unknown>;
19
+ }
20
+ export interface ControllerNode {
21
+ metadata: HyperControllerMetadata;
22
+ target: object;
23
+ fullPath: string;
24
+ routes: RouteNode[];
25
+ services: ImportType[];
26
+ openapi?: Record<string, unknown>;
27
+ }
28
+ export interface RouteNode extends RouteMetadata {
29
+ fullPath: string;
30
+ params: HyperParameterMetadata['params'];
31
+ openapi?: Record<string, unknown>;
32
+ }
33
+ /**
34
+ * Extracts the complete application metadata tree.
35
+ */
36
+ export declare function getAppTree(Target: Constructor): AppTree;
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getAppTree = getAppTree;
4
+ const meta_store_1 = require("../../__internals/stores/meta.store");
5
+ const metadata_1 = require("../openapi/metadata");
6
+ const path_util_1 = require("../../__internals/utils/path.util");
7
+ const metadata_registry_1 = require("../openapi/metadata.registry");
8
+ /**
9
+ * Extracts the complete application metadata tree.
10
+ */
11
+ function getAppTree(Target) {
12
+ var _a;
13
+ const root = meta_store_1.Metadata.get(Target);
14
+ const common = (_a = root.server) === null || _a === void 0 ? void 0 : _a.common;
15
+ const prefix = (common === null || common === void 0 ? void 0 : common.prefix) || "/";
16
+ const tree = {
17
+ app: Object.assign(Object.assign({}, (common || {})), { target: Target, fullPath: prefix }),
18
+ modules: {},
19
+ paths: {}
20
+ };
21
+ const modules = (common === null || common === void 0 ? void 0 : common.modules) || [];
22
+ modules.forEach(m => {
23
+ const node = getModuleNode(m, prefix, tree.paths);
24
+ tree.modules[m.name] = node;
25
+ });
26
+ // Apply tree processors
27
+ metadata_registry_1.openApiRegistry.getProcessors().forEach(processor => processor(tree));
28
+ return tree;
29
+ }
30
+ function getModuleNode(Target, parentPath = "", globalPaths = {}) {
31
+ var _a;
32
+ const root = meta_store_1.Metadata.get(Target);
33
+ const common = (_a = root.server) === null || _a === void 0 ? void 0 : _a.common;
34
+ const currentPath = (0, path_util_1.join)(parentPath, (common === null || common === void 0 ? void 0 : common.path) || "");
35
+ const openapi = metadata_1.SwaggerMeta.get(Target); // Fixed: Metadata utility now returns root.common
36
+ // Execute custom collectors
37
+ metadata_registry_1.openApiRegistry.getCollectors("class").forEach(collector => {
38
+ const extra = collector(Target);
39
+ if (extra)
40
+ Object.assign(openapi, extra);
41
+ });
42
+ const node = {
43
+ metadata: common,
44
+ target: Target,
45
+ fullPath: currentPath,
46
+ modules: {},
47
+ controllers: {},
48
+ services: ((common === null || common === void 0 ? void 0 : common.imports) || []),
49
+ openapi: openapi
50
+ };
51
+ ((common === null || common === void 0 ? void 0 : common.modules) || []).forEach(m => {
52
+ node.modules[m.name] = getModuleNode(m, currentPath, globalPaths);
53
+ });
54
+ ((common === null || common === void 0 ? void 0 : common.controllers) || []).forEach(c => {
55
+ node.controllers[c.name] = getControllerNode(c, currentPath, globalPaths);
56
+ });
57
+ return node;
58
+ }
59
+ function getControllerNode(Target, parentPath = "", globalPaths = {}) {
60
+ var _a;
61
+ const root = meta_store_1.Metadata.get(Target);
62
+ const common = (_a = root.server) === null || _a === void 0 ? void 0 : _a.common;
63
+ const currentPath = (0, path_util_1.join)(parentPath, (common === null || common === void 0 ? void 0 : common.path) || "");
64
+ const openapi = metadata_1.SwaggerMeta.get(Target);
65
+ const server = root.server || { common: {}, methods: {} };
66
+ const methods = server.methods;
67
+ const routes = Object.keys(methods).map((propertyKey) => {
68
+ var _a;
69
+ const methodMeta = methods[propertyKey];
70
+ const route = methodMeta.route;
71
+ if (!route)
72
+ return null;
73
+ const params = ((_a = methodMeta.params) === null || _a === void 0 ? void 0 : _a.params) || [];
74
+ const fullPath = (0, path_util_1.join)(currentPath, route.path);
75
+ // Get OpenAPI metadata for the method
76
+ const methodOpenApi = (metadata_1.SwaggerMeta.get(Target, propertyKey) || {});
77
+ // Execute custom collectors
78
+ metadata_registry_1.openApiRegistry.getCollectors("method").forEach((collector) => {
79
+ const extra = collector(Target.prototype, propertyKey);
80
+ if (extra)
81
+ Object.assign(methodOpenApi, extra);
82
+ });
83
+ const routeNode = Object.assign(Object.assign({}, route), { fullPath,
84
+ params, openapi: methodOpenApi });
85
+ // Add to global paths map
86
+ if (!globalPaths[fullPath]) {
87
+ globalPaths[fullPath] = [];
88
+ }
89
+ globalPaths[fullPath].push(routeNode);
90
+ return routeNode;
91
+ }).filter(Boolean);
92
+ // Execute custom collectors
93
+ metadata_registry_1.openApiRegistry.getCollectors("class").forEach(collector => {
94
+ const extra = collector(Target);
95
+ if (extra)
96
+ Object.assign(openapi, extra);
97
+ });
98
+ return {
99
+ metadata: common,
100
+ target: Target,
101
+ fullPath: currentPath,
102
+ routes,
103
+ services: (common === null || common === void 0 ? void 0 : common.imports) || [],
104
+ openapi: openapi
105
+ };
106
+ }