@zenofolio/hyper-decor 1.0.7 → 1.0.8

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 (192) hide show
  1. package/.agent/rules/philosophy.md +103 -0
  2. package/.agent/rules/writing.md +32 -0
  3. package/README.md +103 -201
  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 +325 -281
  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/{lib/openapi/helpers → __internals/stores}/index.js +4 -7
  14. package/dist/__internals/stores/meta.store.d.ts +34 -0
  15. package/dist/__internals/stores/meta.store.js +107 -0
  16. package/dist/{stores → __internals/stores}/scope.store.d.ts +1 -1
  17. package/dist/__internals/transform/middleware.transform.d.ts +1 -1
  18. package/dist/__internals/transform/middleware.transform.js +1 -1
  19. package/dist/__internals/transform/role.transform.d.ts +1 -1
  20. package/dist/__internals/transform/role.transform.js +4 -4
  21. package/dist/__internals/transform/scope.transfrom.d.ts +1 -1
  22. package/dist/__internals/transform/scope.transfrom.js +2 -2
  23. package/dist/__internals/types.d.ts +53 -4
  24. package/dist/common/bootstrap.d.ts +6 -2
  25. package/dist/common/bootstrap.js +49 -10
  26. package/dist/common/testing.d.ts +56 -0
  27. package/dist/common/testing.js +193 -0
  28. package/dist/common/transport.d.ts +1 -0
  29. package/dist/common/transport.js +27 -14
  30. package/dist/constants.d.ts +1 -0
  31. package/dist/constants.js +2 -1
  32. package/dist/decorators.d.ts +1 -0
  33. package/dist/{stores/index.js → decorators.js} +1 -1
  34. package/dist/index.d.ts +7 -5
  35. package/dist/index.js +7 -5
  36. package/dist/lib/event/meta.store.d.ts +4 -0
  37. package/dist/lib/event/meta.store.js +5 -0
  38. package/dist/lib/openapi/collectors/class.collector.d.ts +5 -9
  39. package/dist/lib/openapi/collectors/class.collector.js +6 -63
  40. package/dist/lib/openapi/collectors/index.d.ts +3 -4
  41. package/dist/lib/openapi/collectors/index.js +0 -1
  42. package/dist/lib/openapi/collectors/method.collector.d.ts +6 -1
  43. package/dist/lib/openapi/collectors/method.collector.js +92 -59
  44. package/dist/lib/openapi/collectors/schema.collector.d.ts +3 -8
  45. package/dist/lib/openapi/collectors/schema.collector.js +17 -25
  46. package/dist/lib/openapi/constants.d.ts +1 -0
  47. package/dist/lib/openapi/constants.js +2 -2
  48. package/dist/lib/openapi/decorators.d.ts +16 -0
  49. package/dist/lib/openapi/decorators.js +93 -0
  50. package/dist/lib/openapi/index.d.ts +29 -5
  51. package/dist/lib/openapi/index.js +119 -5
  52. package/dist/lib/openapi/metadata.d.ts +7 -0
  53. package/dist/lib/openapi/metadata.js +8 -0
  54. package/dist/lib/openapi/metadata.registry.d.ts +1 -1
  55. package/dist/lib/server/decorators/File.d.ts +37 -0
  56. package/dist/{decorators → lib/server/decorators}/File.js +62 -75
  57. package/dist/lib/server/decorators/Http.d.ts +12 -0
  58. package/dist/lib/server/decorators/Http.js +56 -0
  59. package/dist/lib/server/decorators/HyperApp.d.ts +7 -0
  60. package/dist/lib/server/decorators/HyperApp.js +14 -0
  61. package/dist/lib/server/decorators/HyperController.d.ts +6 -0
  62. package/dist/lib/server/decorators/HyperController.js +15 -0
  63. package/dist/lib/server/decorators/HyperModule.d.ts +6 -0
  64. package/dist/lib/server/decorators/HyperModule.js +13 -0
  65. package/dist/lib/server/decorators/HyperService.d.ts +12 -0
  66. package/dist/lib/server/decorators/HyperService.js +30 -0
  67. package/dist/lib/server/decorators/Messaging.d.ts +8 -0
  68. package/dist/lib/server/decorators/Messaging.js +19 -0
  69. package/dist/{decorators → lib/server/decorators}/Middleware.d.ts +5 -12
  70. package/dist/lib/server/decorators/Middleware.js +52 -0
  71. package/dist/lib/server/decorators/Output.d.ts +6 -0
  72. package/dist/lib/server/decorators/Output.js +14 -0
  73. package/dist/lib/server/decorators/Pass.d.ts +10 -0
  74. package/dist/lib/server/decorators/Pass.js +13 -0
  75. package/dist/lib/server/decorators/Role.d.ts +7 -0
  76. package/dist/lib/server/decorators/Role.js +14 -0
  77. package/dist/lib/server/decorators/Routes.d.ts +14 -0
  78. package/dist/lib/server/decorators/Routes.js +39 -0
  79. package/dist/lib/server/decorators/Scope.d.ts +7 -0
  80. package/dist/lib/server/decorators/Scope.js +14 -0
  81. package/dist/{decorators → lib/server/decorators}/index.d.ts +6 -4
  82. package/dist/{decorators → lib/server/decorators}/index.js +6 -4
  83. package/dist/lib/server/decorators/metadata.d.ts +1 -0
  84. package/dist/lib/server/decorators/metadata.js +5 -0
  85. package/dist/{decorators → lib/server/decorators}/types.d.ts +16 -15
  86. package/dist/{exeptions → lib/server/exeptions}/HyperException.d.ts +2 -1
  87. package/dist/{exeptions → lib/server/exeptions}/HyperException.js +2 -1
  88. package/dist/{exeptions → lib/server/exeptions}/HyperFileException.js +1 -1
  89. package/dist/{exeptions → lib/server/exeptions}/NotRoleException.js +1 -1
  90. package/dist/{exeptions → lib/server/exeptions}/NotScopeException.js +1 -1
  91. package/dist/{__internals/helpers/tree.helper.d.ts → lib/tree/tree.d.ts} +12 -12
  92. package/dist/lib/tree/tree.js +106 -0
  93. package/package.json +10 -2
  94. package/scripts/clean.js +54 -54
  95. package/scripts/test-server.ts +85 -85
  96. package/vitest.config.mjs +1 -1
  97. package/debug.txt +0 -1
  98. package/dist/__internals/creators/request.creator.d.ts +0 -11
  99. package/dist/__internals/creators/request.creator.js +0 -55
  100. package/dist/__internals/creators/routes.creator.d.ts +0 -9
  101. package/dist/__internals/creators/routes.creator.js +0 -39
  102. package/dist/__internals/decorator-base.d.ts +0 -30
  103. package/dist/__internals/decorator-base.js +0 -122
  104. package/dist/__internals/helpers/imports.helper.d.ts +0 -8
  105. package/dist/__internals/helpers/imports.helper.js +0 -92
  106. package/dist/__internals/helpers/tree.helper.js +0 -81
  107. package/dist/__internals/stores/metadata.store.d.ts +0 -15
  108. package/dist/__internals/stores/metadata.store.js +0 -37
  109. package/dist/decorators/File.d.ts +0 -65
  110. package/dist/decorators/Http.d.ts +0 -62
  111. package/dist/decorators/Http.js +0 -139
  112. package/dist/decorators/HyperApp.d.ts +0 -3
  113. package/dist/decorators/HyperApp.js +0 -96
  114. package/dist/decorators/HyperController.d.ts +0 -2
  115. package/dist/decorators/HyperController.js +0 -20
  116. package/dist/decorators/HyperModule.d.ts +0 -5
  117. package/dist/decorators/HyperModule.js +0 -14
  118. package/dist/decorators/HyperService.d.ts +0 -15
  119. package/dist/decorators/HyperService.js +0 -29
  120. package/dist/decorators/Messaging.d.ts +0 -10
  121. package/dist/decorators/Messaging.js +0 -22
  122. package/dist/decorators/Middleware.js +0 -65
  123. package/dist/decorators/Output.d.ts +0 -9
  124. package/dist/decorators/Output.js +0 -18
  125. package/dist/decorators/Pass.d.ts +0 -15
  126. package/dist/decorators/Pass.js +0 -32
  127. package/dist/decorators/Role.d.ts +0 -6
  128. package/dist/decorators/Role.js +0 -34
  129. package/dist/decorators/Routes.d.ts +0 -15
  130. package/dist/decorators/Routes.js +0 -21
  131. package/dist/decorators/Scope.d.ts +0 -6
  132. package/dist/decorators/Scope.js +0 -25
  133. package/dist/decorators/Transform.d.ts +0 -14
  134. package/dist/decorators/Transform.js +0 -18
  135. package/dist/lib/openapi/collectors/param.collector.d.ts +0 -2
  136. package/dist/lib/openapi/collectors/param.collector.js +0 -64
  137. package/dist/lib/openapi/decorators/api-bearer-auth.decorator.d.ts +0 -2
  138. package/dist/lib/openapi/decorators/api-bearer-auth.decorator.js +0 -10
  139. package/dist/lib/openapi/decorators/api-method.decorator.d.ts +0 -3
  140. package/dist/lib/openapi/decorators/api-method.decorator.js +0 -11
  141. package/dist/lib/openapi/decorators/api-parameter.decorator.d.ts +0 -3
  142. package/dist/lib/openapi/decorators/api-parameter.decorator.js +0 -10
  143. package/dist/lib/openapi/decorators/api-request-body.decorator.d.ts +0 -3
  144. package/dist/lib/openapi/decorators/api-request-body.decorator.js +0 -10
  145. package/dist/lib/openapi/decorators/api-response.decorator.d.ts +0 -3
  146. package/dist/lib/openapi/decorators/api-response.decorator.js +0 -10
  147. package/dist/lib/openapi/decorators/api-security.decorator.d.ts +0 -3
  148. package/dist/lib/openapi/decorators/api-security.decorator.js +0 -10
  149. package/dist/lib/openapi/decorators/api-tag.decorator.d.ts +0 -3
  150. package/dist/lib/openapi/decorators/api-tag.decorator.js +0 -13
  151. package/dist/lib/openapi/decorators/index.d.ts +0 -7
  152. package/dist/lib/openapi/decorators/index.js +0 -23
  153. package/dist/lib/openapi/helpers/index.d.ts +0 -7
  154. package/dist/lib/openapi/helpers/method.helper.d.ts +0 -3
  155. package/dist/lib/openapi/helpers/method.helper.js +0 -20
  156. package/dist/lib/openapi/helpers/openapi.helper.d.ts +0 -7
  157. package/dist/lib/openapi/helpers/openapi.helper.js +0 -51
  158. package/dist/lib/openapi/helpers/parameter.helper.d.ts +0 -3
  159. package/dist/lib/openapi/helpers/parameter.helper.js +0 -16
  160. package/dist/lib/openapi/helpers/request-body.helper.d.ts +0 -3
  161. package/dist/lib/openapi/helpers/request-body.helper.js +0 -9
  162. package/dist/lib/openapi/helpers/response.helper.d.ts +0 -3
  163. package/dist/lib/openapi/helpers/response.helper.js +0 -18
  164. package/dist/lib/openapi/helpers/security.helper.d.ts +0 -3
  165. package/dist/lib/openapi/helpers/security.helper.js +0 -17
  166. package/dist/lib/openapi/helpers/tag.helper.d.ts +0 -3
  167. package/dist/lib/openapi/helpers/tag.helper.js +0 -10
  168. package/dist/stores/index.d.ts +0 -1
  169. package/vitest.json +0 -0
  170. /package/dist/{stores → __internals/stores}/scope.store.js +0 -0
  171. /package/dist/__internals/stores/{service.store.d.ts → serivces.store.d.ts} +0 -0
  172. /package/dist/__internals/stores/{service.store.js → serivces.store.js} +0 -0
  173. /package/dist/{decorators → lib/server/decorators}/types.js +0 -0
  174. /package/dist/{exeptions → lib/server/exeptions}/DuplicateControllerPathException.d.ts +0 -0
  175. /package/dist/{exeptions → lib/server/exeptions}/DuplicateControllerPathException.js +0 -0
  176. /package/dist/{exeptions → lib/server/exeptions}/DuplicatedException.d.ts +0 -0
  177. /package/dist/{exeptions → lib/server/exeptions}/DuplicatedException.js +0 -0
  178. /package/dist/{exeptions → lib/server/exeptions}/DuplicatedHandlerException.d.ts +0 -0
  179. /package/dist/{exeptions → lib/server/exeptions}/DuplicatedHandlerException.js +0 -0
  180. /package/dist/{exeptions → lib/server/exeptions}/HyperFileException.d.ts +0 -0
  181. /package/dist/{exeptions → lib/server/exeptions}/MethodNotFountException.d.ts +0 -0
  182. /package/dist/{exeptions → lib/server/exeptions}/MethodNotFountException.js +0 -0
  183. /package/dist/{exeptions → lib/server/exeptions}/NotPropertyException.d.ts +0 -0
  184. /package/dist/{exeptions → lib/server/exeptions}/NotPropertyException.js +0 -0
  185. /package/dist/{exeptions → lib/server/exeptions}/NotRoleException.d.ts +0 -0
  186. /package/dist/{exeptions → lib/server/exeptions}/NotScopeException.d.ts +0 -0
  187. /package/dist/{exeptions → lib/server/exeptions}/WrongPlaceException.d.ts +0 -0
  188. /package/dist/{exeptions → lib/server/exeptions}/WrongPlaceException.js +0 -0
  189. /package/dist/{exeptions → lib/server/exeptions}/index.d.ts +0 -0
  190. /package/dist/{exeptions → lib/server/exeptions}/index.js +0 -0
  191. /package/dist/{exeptions → lib/server/exeptions}/types.d.ts +0 -0
  192. /package/dist/{exeptions → lib/server/exeptions}/types.js +0 -0
@@ -1,96 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.HyperApp = void 0;
13
- require("reflect-metadata");
14
- const hyper_express_1 = require("hyper-express");
15
- const tsyringe_1 = require("tsyringe");
16
- const constants_1 = require("../__internals/constants");
17
- const decorator_base_1 = require("../__internals/decorator-base");
18
- const merge_metadata_1 = require("../__internals/helpers/merge-metadata");
19
- const transform_registry_1 = require("../__internals/transform/transform.registry");
20
- const prepare_helper_1 = require("../__internals/helpers/prepare.helper");
21
- const HyperApp = (options) => (0, decorator_base_1.DecoratorHelper)({
22
- type: constants_1.KEY_TYPE_APP,
23
- key: constants_1.KEY_PARAMS_APP,
24
- options: Object.assign({ modules: [], logger: console.log }, options),
25
- }, (options, Target) => {
26
- return class extends hyper_express_1.Server {
27
- constructor(...args) {
28
- super(options.options);
29
- this.listArguments = [];
30
- this.storeLogs = {};
31
- this.listArguments = args;
32
- }
33
- /** Registers an agnostic transformer (Zod, Joi, etc.) */
34
- useTransform(transformer) {
35
- transform_registry_1.transformRegistry.register(transformer);
36
- return this;
37
- }
38
- prepare() {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- tsyringe_1.container.registerInstance(hyper_express_1.Server, this);
41
- this.mergeMetadata(Target);
42
- yield this.applyOptions(Target);
43
- });
44
- }
45
- /** Fusiona los metadatos relevantes al Target */
46
- mergeMetadata(targetPrototype) {
47
- (0, merge_metadata_1.mergeMetadata)(targetPrototype, this.constructor, [
48
- constants_1.KEY_PARAMS_MIDDLEWARES,
49
- constants_1.KEY_PARAMS_SCOPE,
50
- constants_1.KEY_PARAMS_ROLE,
51
- constants_1.KEY_PARAMS_PASS,
52
- ]);
53
- }
54
- /** Aplica las opciones y prepara la instancia del Target */
55
- applyOptions(Target) {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- yield (0, prepare_helper_1.prepareApplication)(options, Target, this, this.log.bind(this));
58
- const target = Reflect.construct(Target, this.listArguments);
59
- if (target && typeof target === 'object' && 'onPrepare' in target) {
60
- target.onPrepare();
61
- }
62
- this.showLogs();
63
- });
64
- }
65
- /** Maneja los logs respetando las opciones configuradas */
66
- log(space, message) {
67
- var _a;
68
- var _b;
69
- if (((_a = options.logs) === null || _a === void 0 ? void 0 : _a[space]) === false)
70
- return;
71
- ((_b = this.storeLogs)[space] || (_b[space] = [])).push(`- ${message}`);
72
- }
73
- showLogs() {
74
- var _a, _b, _c;
75
- const content = ["\n\n"];
76
- content.push("/////////////////////////////");
77
- content.push(`- HyperExpress Application`);
78
- content.push(`- ${(_a = options.name) !== null && _a !== void 0 ? _a : "Hyper App"} - ${(_b = options.version) !== null && _b !== void 0 ? _b : "1.0.0"}`);
79
- content.push("/////////////////////////////\n");
80
- content.push("\nLogs:");
81
- Object.entries(this.storeLogs).forEach(([space, logs]) => {
82
- if (!logs.length)
83
- return;
84
- content.push(`- [${space.toUpperCase()}]`);
85
- logs.forEach((log) => content.push(` ${log}`));
86
- content.push("");
87
- });
88
- (_c = options.logger) === null || _c === void 0 ? void 0 : _c.call(this, content.join("\n"));
89
- this.storeLogs = {};
90
- }
91
- };
92
- });
93
- exports.HyperApp = HyperApp;
94
- //////////////////////////////////
95
- /// Private methods
96
- //////////////////////////////////
@@ -1,2 +0,0 @@
1
- import { HyperControllerMetadata } from "./types";
2
- export declare const HyperController: (options?: HyperControllerMetadata | string) => ClassDecorator;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HyperController = void 0;
4
- const decorator_base_1 = require("../__internals/decorator-base");
5
- const constants_1 = require("../__internals/constants");
6
- const HyperController = (options) => {
7
- var _a, _b, _c, _d;
8
- const isString = typeof options === "string";
9
- return (0, decorator_base_1.DecoratorHelper)({
10
- type: constants_1.KEY_TYPE_CONTROLLER,
11
- key: constants_1.KEY_PARAMS_CONTROLLER,
12
- options: {
13
- path: isString ? options : (_a = options === null || options === void 0 ? void 0 : options.path) !== null && _a !== void 0 ? _a : "/",
14
- roles: isString ? [] : (_b = options === null || options === void 0 ? void 0 : options.roles) !== null && _b !== void 0 ? _b : [],
15
- scopes: isString ? [] : (_c = options === null || options === void 0 ? void 0 : options.scopes) !== null && _c !== void 0 ? _c : [],
16
- imports: isString ? [] : (_d = options === null || options === void 0 ? void 0 : options.imports) !== null && _d !== void 0 ? _d : [],
17
- },
18
- });
19
- };
20
- exports.HyperController = HyperController;
@@ -1,5 +0,0 @@
1
- import { HyperModuleDecorator } from "./types";
2
- /**
3
- * Decorator to define a module with controllers and services.
4
- */
5
- export declare const HyperModule: HyperModuleDecorator;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HyperModule = void 0;
4
- const constants_1 = require("../__internals/constants");
5
- const decorator_base_1 = require("../__internals/decorator-base");
6
- /**
7
- * Decorator to define a module with controllers and services.
8
- */
9
- const HyperModule = (options) => (0, decorator_base_1.DecoratorHelper)({
10
- type: constants_1.KEY_PARAMS_MODULE,
11
- key: constants_1.KEY_PARAMS_MODULE,
12
- options,
13
- });
14
- exports.HyperModule = HyperModule;
@@ -1,15 +0,0 @@
1
- import { Constructor } from "./types";
2
- interface ServiceDecoratorOptions {
3
- singleton?: boolean;
4
- token?: string | symbol;
5
- }
6
- /**
7
- * HyperService decorator is used to register a class as a service in the tsyringe container.
8
- *
9
- * No matter where this decorator is applied, the class will be registered in the tsyringe container
10
- * and included in the service store to be launched when the application starts.
11
- *
12
- * @param options.singleton - Whether to register as a singleton (default: true)
13
- */
14
- export declare const HyperService: ({ token, singleton, }?: ServiceDecoratorOptions) => (target: Constructor) => void;
15
- export {};
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HyperService = void 0;
4
- const tsyringe_1 = require("tsyringe");
5
- const service_store_1 = require("../__internals/stores/service.store");
6
- /**
7
- * HyperService decorator is used to register a class as a service in the tsyringe container.
8
- *
9
- * No matter where this decorator is applied, the class will be registered in the tsyringe container
10
- * and included in the service store to be launched when the application starts.
11
- *
12
- * @param options.singleton - Whether to register as a singleton (default: true)
13
- */
14
- const HyperService = ({ token, singleton = true, } = {}) => {
15
- return (target) => {
16
- const useToken = token !== null && token !== void 0 ? token : target;
17
- (0, tsyringe_1.injectable)()(target);
18
- if (!tsyringe_1.container.isRegistered(useToken)) {
19
- if (singleton) {
20
- tsyringe_1.container.registerSingleton(useToken, target);
21
- }
22
- else {
23
- tsyringe_1.container.register(useToken, { useClass: target });
24
- }
25
- }
26
- service_store_1.serviceStore.add(target);
27
- };
28
- };
29
- exports.HyperService = HyperService;
@@ -1,10 +0,0 @@
1
- export interface OnMessageMetadata {
2
- topic: string;
3
- propertyKey: string;
4
- }
5
- /**
6
- * OnMessage decorator for subscribing to topics.
7
- *
8
- * @param topic The topic or pattern to listen to (e.g. "user.created", "user.*")
9
- */
10
- export declare const OnMessage: (topic: string) => (target: any, propertyKey: string | symbol | any, descriptor?: any) => void;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.OnMessage = void 0;
4
- const constants_1 = require("../__internals/constants");
5
- const decorator_base_1 = require("../__internals/decorator-base");
6
- /**
7
- * OnMessage decorator for subscribing to topics.
8
- *
9
- * @param topic The topic or pattern to listen to (e.g. "user.created", "user.*")
10
- */
11
- const OnMessage = (topic) => {
12
- return (target, propertyKey, descriptor) => {
13
- var _a;
14
- const existing = (_a = Reflect.getMetadata(constants_1.METADATA_KEYS.ON_MESSAGE, target.constructor)) !== null && _a !== void 0 ? _a : [];
15
- existing.push({
16
- topic,
17
- propertyKey: propertyKey.toString(),
18
- });
19
- (0, decorator_base_1.defineDecorData)(constants_1.METADATA_KEYS.ON_MESSAGE, existing, target.constructor);
20
- };
21
- };
22
- exports.OnMessage = OnMessage;
@@ -1,65 +0,0 @@
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 metadata_store_1 = __importDefault(require("../__internals/stores/metadata.store"));
10
- /**
11
- * Middleware decorator to attach middleware to controllers, modules, and routes.
12
- */
13
- const Middleware = (...middleware) => (Target, propertyKey) => {
14
- metadata_store_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 expressions
24
- * @param middleware
25
- * @returns
26
- */
27
- exports.Middleware.exclude =
28
- (expressions, middleware) => (Target, propertyKey) => {
29
- metadata_store_1.default.define(constants_1.KEY_PARAMS_MIDDLEWARES, buildHandler("exclude", expressions, middleware), {
30
- target: Target,
31
- propertyKey,
32
- });
33
- };
34
- /**
35
- * Only run middleware on matching paths.
36
- *
37
- * @param expresiosn
38
- * @param middleware
39
- * @returns
40
- */
41
- exports.Middleware.only =
42
- (expressions, middleware) => (Target, propertyKey) => {
43
- metadata_store_1.default.define(constants_1.KEY_PARAMS_MIDDLEWARES, buildHandler("only", expressions, middleware), {
44
- target: Target,
45
- propertyKey,
46
- });
47
- };
48
- /**
49
- *
50
- * Helper function to build middleware handlers for "only" and "exclude" modes.
51
- *
52
- * @param mode
53
- * @param expresions
54
- * @returns
55
- */
56
- const buildHandler = (mode, expressions, middleware) => {
57
- const matchers = Array.isArray(expressions) ? expressions : [expressions];
58
- return (req, res, next) => {
59
- const matches = matchers.some((rx) => rx.test(req.path));
60
- if ((mode === "only" && !matches) || (mode === "exclude" && matches)) {
61
- return next();
62
- }
63
- return middleware(req, res, next);
64
- };
65
- };
@@ -1,9 +0,0 @@
1
- import "reflect-metadata";
2
- /**
3
- * Decorator to explicitly mark a method for response transformation and OpenAPI documentation.
4
- *
5
- * @param schema The schema or DTO class for the successful response (200).
6
- * @example
7
- * \@Output(UserDto)
8
- */
9
- export declare function Output(schema?: any): (target: any, propertyKey?: any, descriptor?: PropertyDescriptor) => void;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Output = Output;
4
- require("reflect-metadata");
5
- const decorator_base_1 = require("../__internals/decorator-base");
6
- const constants_1 = require("../__internals/constants");
7
- /**
8
- * Decorator to explicitly mark a method for response transformation and OpenAPI documentation.
9
- *
10
- * @param schema The schema or DTO class for the successful response (200).
11
- * @example
12
- * \@Output(UserDto)
13
- */
14
- function Output(schema) {
15
- return (target, propertyKey, descriptor) => {
16
- (0, decorator_base_1.defineDecorData)(constants_1.KEY_OUTPUT_SCHEMA, schema, target, propertyKey);
17
- };
18
- }
@@ -1,15 +0,0 @@
1
- import { Request, Response } from "hyper-express";
2
- interface PassOptions {
3
- (req: Request, res: Response): boolean | Promise<boolean>;
4
- }
5
- /**
6
- * Pass decorator
7
- *
8
- * This decorator allows bypassing checks when the provided function returns `true`.
9
- * It can be applied to classes or methods, but not to properties.
10
- *
11
- * @param options - A function that returns true to allow bypassing
12
- * @returns A class or method decorator
13
- */
14
- export declare const Pass: (options: PassOptions) => ClassDecorator & MethodDecorator;
15
- export {};
@@ -1,32 +0,0 @@
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
- * Pass decorator
12
- *
13
- * This decorator allows bypassing checks when the provided function returns `true`.
14
- * It can be applied to classes or methods, but not to properties.
15
- *
16
- * @param options - A function that returns true to allow bypassing
17
- * @returns A class or method decorator
18
- */
19
- const Pass = (options) => (target, propertyKey, descriptorOrIndex) => {
20
- const { isProperty, isMethod } = (0, who_helper_1.default)(target, propertyKey, descriptorOrIndex);
21
- if (isProperty) {
22
- throw new NotPropertyException_1.default(`${target.constructor.name}.${propertyKey === null || propertyKey === void 0 ? void 0 : propertyKey.toString()}`, target);
23
- }
24
- if (isMethod) {
25
- Reflect.defineMetadata(constants_1.KEY_PARAMS_PASS, options, target, propertyKey);
26
- }
27
- else {
28
- Reflect.defineMetadata(constants_1.KEY_PARAMS_PASS, options, target);
29
- }
30
- return target;
31
- };
32
- exports.Pass = Pass;
@@ -1,6 +0,0 @@
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;
@@ -1,34 +0,0 @@
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 exeptions_1 = require("../exeptions");
9
- const who_helper_1 = __importDefault(require("../__internals/helpers/who.helper"));
10
- const constants_1 = require("../__internals/constants");
11
- const metadata_store_1 = __importDefault(require("../__internals/stores/metadata.store"));
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 } = (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 = metadata_store_1.default.list(constants_1.KEY_PARAMS_ROLE, {
29
- target,
30
- propertyKey,
31
- });
32
- list.set(..._roles);
33
- };
34
- exports.Role = Role;
@@ -1,15 +0,0 @@
1
- import "reflect-metadata";
2
- import { WSRouteOptions } from "hyper-express/types";
3
- export declare const Get: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
4
- export declare const Post: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
5
- export declare const Put: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
6
- export declare const Delete: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
7
- export declare const Patch: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
8
- export declare const Options: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
9
- export declare const Head: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
10
- export declare const Trace: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
11
- export declare const Any: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
12
- export declare const All: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
13
- export declare const Connect: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
14
- export declare const WS: (path?: string, options?: WSRouteOptions | undefined) => MethodDecorator & ClassDecorator;
15
- export declare const Upgrade: (path?: string, options?: undefined) => MethodDecorator & ClassDecorator;
@@ -1,21 +0,0 @@
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");
@@ -1,6 +0,0 @@
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;
@@ -1,25 +0,0 @@
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 metadata_store_1 = __importDefault(require("../__internals/stores/metadata.store"));
11
- /**
12
- * Scope decorator for defining access scopes.
13
- */
14
- const Scope = (scopes) => (target, propertyKey, descriptorOrIndex) => {
15
- const { isProperty } = (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 = metadata_store_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;
@@ -1,14 +0,0 @@
1
- import "reflect-metadata";
2
- export interface TransformOptions {
3
- /**
4
- * Where to extract the data from. Defaults to 'body'.
5
- */
6
- from?: 'body' | 'query' | 'params' | 'headers';
7
- }
8
- /**
9
- * Agnostic decorator to transform/validate request data using a registered transformer.
10
- *
11
- * @param schema The schema or object to be used by the registered transformer.
12
- * @param options Transformation options.
13
- */
14
- export declare function Transform(schema: any, options?: TransformOptions): (target: any, propertyKey: any) => void;
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Transform = Transform;
4
- require("reflect-metadata");
5
- const constants_1 = require("../__internals/constants");
6
- const decorator_base_1 = require("../__internals/decorator-base");
7
- /**
8
- * Agnostic decorator to transform/validate request data using a registered transformer.
9
- *
10
- * @param schema The schema or object to be used by the registered transformer.
11
- * @param options Transformation options.
12
- */
13
- function Transform(schema, options = {}) {
14
- return (target, propertyKey) => {
15
- const data = { schema, options };
16
- (0, decorator_base_1.defineDecorData)(constants_1.KEY_PARAMS_TRANSFORM, data, target, propertyKey);
17
- };
18
- }
@@ -1,2 +0,0 @@
1
- import { OpenApiParameter } from "../types";
2
- export declare function collectParameterMetadata(target: any, methodName: string): OpenApiParameter[];
@@ -1,64 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.collectParameterMetadata = collectParameterMetadata;
4
- const constants_1 = require("../constants");
5
- const constants_2 = require("../../../__internals/constants");
6
- const transform_registry_1 = require("../../../__internals/transform/transform.registry");
7
- const function_util_1 = require("../../../__internals/utils/function.util");
8
- function collectParameterMetadata(target, methodName) {
9
- const parameters = Reflect.getMetadata(constants_1.PARAMETERS, target, methodName) || [];
10
- const hyperParams = Reflect.getMetadata(constants_2.KEY_PARAMS_PARAM, target[methodName]);
11
- if (hyperParams && hyperParams.params[methodName]) {
12
- hyperParams.params[methodName].forEach((p) => {
13
- // Ignore body, req, res as they are not standard "parameters" in OpenAPI terms (body is separate)
14
- if (['req', 'res', 'body', 'BODY'].includes(p.key))
15
- return;
16
- const locationMap = {
17
- 'query': 'query',
18
- 'params': 'path',
19
- 'headers': 'header',
20
- 'cookie': 'cookie'
21
- };
22
- const location = locationMap[p.key] || 'query';
23
- if (p.isWholeSource && p.schema) {
24
- const schema = transform_registry_1.transformRegistry.getOpenApiSchema(p.schema);
25
- if (schema && schema.properties) {
26
- Object.keys(schema.properties).forEach((propKey) => {
27
- parameters.push({
28
- name: propKey,
29
- in: location,
30
- required: (schema.required || []).includes(propKey),
31
- schema: schema.properties[propKey]
32
- });
33
- });
34
- }
35
- }
36
- else {
37
- parameters.push({
38
- name: p.name,
39
- in: location,
40
- required: true, // TODO: detect optionality from design:paramtypes or metadata
41
- schema: p.schema ? transform_registry_1.transformRegistry.getOpenApiSchema(p.schema) : { type: 'string' }
42
- });
43
- }
44
- });
45
- }
46
- // Fallback to design:paramtypes if no hyper-decor metadata found
47
- if (parameters.length === 0) {
48
- const methodParams = Reflect.getMetadata("design:paramtypes", target, methodName) || [];
49
- const paramNames = (0, function_util_1.extractArgsNames)(target[methodName]);
50
- methodParams.forEach((paramType, index) => {
51
- var _a;
52
- const name = paramNames && paramNames[index] ? paramNames[index] : `param${index}`;
53
- parameters.push({
54
- name,
55
- in: "query",
56
- required: true,
57
- schema: {
58
- type: ((_a = paramType === null || paramType === void 0 ? void 0 : paramType.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'number' ? 'number' : 'string',
59
- },
60
- });
61
- });
62
- }
63
- return parameters;
64
- }
@@ -1,2 +0,0 @@
1
- import 'reflect-metadata';
2
- export declare function ApiBearerAuth(name?: string): (target: any, propertyKey?: any, descriptor?: any) => void;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiBearerAuth = ApiBearerAuth;
4
- require("reflect-metadata");
5
- const security_helper_1 = require("../helpers/security.helper");
6
- function ApiBearerAuth(name = 'bearerAuth') {
7
- return (target, propertyKey, descriptor) => {
8
- (0, security_helper_1.apiSecurity)(target, { [name]: [] }, propertyKey);
9
- };
10
- }
@@ -1,3 +0,0 @@
1
- import "reflect-metadata";
2
- import { Operation } from "../types";
3
- export declare function ApiMethod(options: Partial<Operation>): <T>(target: any, propertyKey?: any, descriptor?: TypedPropertyDescriptor<T>) => any;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiMethod = ApiMethod;
4
- require("reflect-metadata");
5
- const method_helper_1 = require("../helpers/method.helper");
6
- function ApiMethod(options) {
7
- return (target, propertyKey, descriptor) => {
8
- (0, method_helper_1.apimethod)(target, propertyKey, options);
9
- return descriptor;
10
- };
11
- }
@@ -1,3 +0,0 @@
1
- import 'reflect-metadata';
2
- import { OpenApiParameter } from '../types';
3
- export declare function ApiParameter(options: OpenApiParameter): (target: any, propertyKey: any) => void;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiParameter = ApiParameter;
4
- require("reflect-metadata");
5
- const parameter_helper_1 = require("../helpers/parameter.helper");
6
- function ApiParameter(options) {
7
- return (target, propertyKey) => {
8
- (0, parameter_helper_1.apiParameter)(target, propertyKey, options);
9
- };
10
- }
@@ -1,3 +0,0 @@
1
- import 'reflect-metadata';
2
- import { RequestBody } from '../types';
3
- export declare function ApiRequestBody(options: RequestBody): (target: any, propertyKey: any) => void;