@zenofolio/hyper-decor 1.0.72 → 1.0.73

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +125 -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 +1 -1
  115. package/scripts/clean.js +55 -55
  116. package/scripts/test-server.ts +85 -85
  117. package/vitest.config.mjs +33 -30
  118. package/vitest.json +0 -0
@@ -0,0 +1,103 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ # Code Philosophy — Internal Mental Process
6
+
7
+ What happens internally before, during, and after writing any line of code.
8
+
9
+ ---
10
+
11
+ ## BEFORE — understand before acting
12
+
13
+ ### 1. Read first, always
14
+ Never assume. Read the full file even if I think I know what's there.
15
+ Existing code has history. Decisions that aren't obvious from the surface.
16
+
17
+ ### 2. Understand the "why", not just the "what"
18
+ The request is the surface. The real problem may be different.
19
+ If I don't understand why something is needed, I ask before writing.
20
+
21
+ ### 3. Map the impact before touching anything
22
+ Who depends on this? What breaks if I change the contract?
23
+ Changing without mapping is gambling. I don't gamble with production code.
24
+
25
+ ### 4. Search before creating
26
+ The best code is code I don't write.
27
+ If something similar already exists, I reuse or extend it. Never duplicate.
28
+
29
+ ### 5. Design types first
30
+ Types are not boilerplate. They are the specification.
31
+ If the types are correct, the implementation nearly writes itself.
32
+ A type that compiles but lies is worse than no types at all.
33
+
34
+ ### 6. Find the minimum solution
35
+ What is the smallest change that completely solves the problem?
36
+ Complexity accumulates on its own. Simplicity must be sought.
37
+
38
+ ---
39
+
40
+ ## DURING — write with intention
41
+
42
+ ### 7. Code is written for the next reader
43
+ Not for the compiler. Not for me. For someone without my context.
44
+ If I need a comment to explain what something does, the name is wrong.
45
+
46
+ ### 8. Names are the first form of documentation
47
+ A correct name eliminates the need for explanation.
48
+ `processData()` is a lie. `parseIncomingWebhookPayload()` is the truth.
49
+
50
+ ### 9. Minimum API surface
51
+ Every extra parameter is a decision the user shouldn't have to make.
52
+ APIs should be hard to use wrong, not just easy to use right.
53
+
54
+ ### 10. Fail at the boundaries, not in the center
55
+ Validate at entry. Assume clean data in the core.
56
+ Errors must explode where they originated, not three layers deep.
57
+
58
+ ### 11. Don't add what wasn't asked for
59
+ If you asked for a door, I don't build the house.
60
+ Every extra line is debt. Every unsolicited feature is noise.
61
+
62
+ ### 12. Design to be deleted
63
+ If an abstraction can't be removed without pain, it was premature.
64
+ Code that can be easily deleted was correctly designed.
65
+
66
+ ---
67
+
68
+ ## AFTER — verify before releasing
69
+
70
+ ### 13. Read the diff as if seeing it for the first time
71
+ Not as the author, but as a reviewer. What wouldn't someone new understand?
72
+ If something needs explanation, the code isn't clear enough.
73
+
74
+ ### 14. Verify contracts are still intact
75
+ Changed a type → who else uses it? Do they still compile?
76
+ Changed behavior → are there tests that document it?
77
+
78
+ ### 15. Remove what's unnecessary
79
+ If something isn't needed for it to work, it goes.
80
+ Unused variables, extra imports, stale comments: noise.
81
+
82
+ ### 16. Ask: would I understand this in six months?
83
+ If the answer is doubtful, something is wrong with the name, structure, or abstraction.
84
+
85
+ ### 17. Never commit what I don't fully understand
86
+ If there's a line that "works but I don't know why", I understand it first.
87
+ Code I don't understand today is tomorrow's bug.
88
+
89
+ ---
90
+
91
+ ## Cross-cutting principles
92
+
93
+ **Complexity is the enemy.** I don't fight it with more complexity.
94
+
95
+ **Types are contracts, not annotations.** If the type lies, the system fails.
96
+
97
+ **Code isn't finished when it works. It's finished when it can't be simplified further.**
98
+
99
+ **Every abstraction has a cost.** It's only worth it if it pays that cost multiple times over.
100
+
101
+ **Silence is a lie.** Failing silently is worse than never failing.
102
+
103
+ **Optimizing before measuring is guessing.** Correct first, then clear, then fast.
@@ -0,0 +1,32 @@
1
+ ---
2
+ trigger: always_on
3
+ ---
4
+
5
+ ## Code Change Protocol
6
+
7
+ Before touching any code, answer these 4 pillars in order.
8
+
9
+ ### 1. TRACE — before writing
10
+ Map everything that uses the code you're about to touch.
11
+ - Who calls it? What imports it? What depends on its signature or behavior?
12
+ - If you change the contract, what else breaks?
13
+ - Read the file before assuming anything.
14
+
15
+ ### 2. JUSTIFY — before writing
16
+ Why must it change?
17
+ - There must be a clear, scoped reason.
18
+ - "Improve it while I'm here" is not a reason.
19
+ - If the reason is unclear, ask before acting.
20
+
21
+ ### 3. MINIMIZE — during writing
22
+ The diff must be surgical.
23
+ - Only change what was asked.
24
+ - No refactoring adjacent code.
25
+ - No adding features on the side.
26
+ - No cleaning up things that weren't broken.
27
+
28
+ ### 4. VERIFY — after writing
29
+ Confirm consumers of the modified code still work.
30
+ - Check type contracts, imports, and call sites.
31
+ - Run or reference tests that cover the changed path.
32
+ - If behavior changed, document why in the commit.
package/README.md CHANGED
@@ -1,136 +1,125 @@
1
- # @zenofolio/hyper-decor (v1.0.71)
2
-
3
- A high-performance, ultra-secure, and indestructible decorators library for [HyperExpress](https://github.com/kartikk221/hyper-express).
4
-
5
- Built for speed and security, this library leverages a **Zero-Overhead** architecture using functional composition to ensure your API remains as fast as raw `uWS` while providing a modern development experience.
6
-
7
- ---
8
-
9
- ## 🚀 Why This Library?
10
-
11
- - **Zero-Overhead Architecture**: Parameter resolution, DTO validation, and transformations are pre-composed at startup. No runtime branching in the hotpath.
12
- - **Ultra-Secure File Handling**: Streaming validation of file sizes and types. Cuts the connection immediately if limits are breached. No memory exhaustion.
13
- - **Polymorphic Decorators**: Flexible parameter decorators that adapt to your needs without sacrificing performance.
14
- - **Automated OpenAPI**: Full OpenAPI 3.0 support with automatic DTO expansion and response documentation.
15
-
16
- ---
17
-
18
- ## 📦 Installation
19
-
20
- ```bash
21
- npm install @zenofolio/hyper-decor
22
- ```
23
-
24
- ---
25
-
26
- ## 🛠️ Usage
27
-
28
- ### Define Your App
29
- ```typescript
30
- import { HyperApp, createApplication } from "@zenofolio/hyper-decor";
31
-
32
- @HyperApp({
33
- modules: [UserModule],
34
- prefix: "/api"
35
- })
36
- class Application {}
37
-
38
- const app = await createApplication(Application);
39
- await app.listen(3000);
40
- ```
41
-
42
- ### Polymorphic Parameter Decorators
43
- Decorators like `@Body`, `@Query`, `@Param`, and `@Headers` are now smarter and faster.
44
-
45
- ```typescript
46
- @HyperController("/users")
47
- class UserController {
48
-
49
- // 1. Direct DTO Validation (Auto-transformation + OpenAPI)
50
- @Post("/")
51
- async create(@Body(CreateUserDto) user: CreateUserDto) {
52
- return user;
53
- }
54
-
55
- // 2. Key-based extraction with Functional Transformer
56
- @Get("/:id")
57
- async findOne(@Param("id", v => parseInt(v)) id: number) {
58
- return { id };
59
- }
60
-
61
- // 3. Nested extraction + DTO
62
- @Post("/settings")
63
- async updateSettings(@Body("settings", SettingsDto) data: SettingsDto) {
64
- return data;
65
- }
66
-
67
- // 4. Raw Extractors
68
- @Get("/")
69
- async list(@Query() allQuery: any, @Req req: any) {
70
- return allQuery;
71
- }
72
- }
73
- ```
74
-
75
- ---
76
-
77
- ## 🔒 Indestructible File Uploader (`@File`)
78
-
79
- The `@File` decorator is designed to be ultra-secure. It processes files as **streams**, validating size and type binarily (magic numbers) *before* the file is fully buffered.
80
-
81
- - **Streaming Validation**: Connection is terminated immediately if `maxFileSize` is exceeded.
82
- - **Binary Verification**: Uses binary signatures to verify MIME types, ensuring security even if the extension is falsified.
83
- - **Automatic Sanitization**: File names are sanitized against path traversal and null bytes.
84
-
85
- ```typescript
86
- @Post("/upload")
87
- async upload(
88
- @File("avatar", {
89
- maxFileSize: 5 * 1024 * 1024, // 5MB
90
- allowedExtensions: ["png", "jpg"],
91
- allowedMimeTypes: ["image/png", "image/jpeg"]
92
- }) file: UploadedFile
93
- ) {
94
- // file.buffer contains the safely validated data
95
- return { filename: file.filename, size: file.size };
96
- }
97
- ```
98
-
99
- ---
100
-
101
- ## Performance
102
-
103
- Benchmarks show that `@zenofolio/hyper-decor` introduces less than **1.8%** overhead compared to raw, manual HyperExpress handlers.
104
-
105
- | Scenario | Raw HyperExpress | @zenofolio/hyper-decor | Overhead |
106
- | :--- | :--- | :--- | :--- |
107
- | **Simple GET** | 27,150 req/s | 26,660 req/s | ~1.8% |
108
- | **Deep Transformation**| 18,120 req/s | 18,335 req/s | **+1.1% Gain** |
109
-
110
- > [!TIP]
111
- > The "Transformed" scenario actually performs better than manual implementations thanks to our optimized functional resolver composition that V8 can inline aggressively.
112
-
113
- ---
114
-
115
- ## 🔍 OpenAPI & DTOs
116
-
117
- Pass classes to your decorators, and they will be expanded into the OpenAPI schema automatically.
118
-
119
- ```typescript
120
- class CreateUserDto {
121
- /** @minimum 18 */
122
- age: number;
123
- name: string;
124
- }
125
-
126
- @Post("/")
127
- async create(@Body(CreateUserDto) data: CreateUserDto) { ... }
128
- ```
129
-
130
- You can integrate any validation engine (Zod, Class-Validator) by registering a `Transformer` in the `transformRegistry`.
131
-
132
- ---
133
-
134
- ## 🛡️ License
135
-
136
- MIT
1
+ # @zenofolio/hyper-decor (v1.0.72)
2
+
3
+ Librería de decoradores para [HyperExpress](https://github.com/kartikk221/hyper-express).
4
+
5
+ Este paquete proporciona una capa de abstracción basada en decoradores para facilitar el desarrollo de APIs con HyperExpress, enfocándose en la composición de resolutores para el manejo de parámetros y validación.
6
+
7
+ ---
8
+
9
+ ## Características
10
+
11
+ - **Arquitectura de Composición**: La resolución de parámetros, validación de DTOs y transformaciones se calculan durante la inicialización para minimizar la lógica en el flujo de peticiones.
12
+ - **Manejo de Archivos (`@File`)**: Implementación basada en streams para la validación de tamaño y tipo de archivos durante la subida.
13
+ - **Decoradores Polimórficos**: Soporte para diferentes tipos de argumentos en decoradores de parámetros.
14
+ - **Integración con OpenAPI**: Soporte básico para la generación de esquemas OpenAPI 3.0.
15
+
16
+ ---
17
+
18
+ ## Instalación
19
+
20
+ ```bash
21
+ npm install @zenofolio/hyper-decor
22
+ ```
23
+
24
+ ---
25
+
26
+ ## Uso
27
+
28
+ ### Definición de Aplicación
29
+ ```typescript
30
+ import { HyperApp, createApplication } from "@zenofolio/hyper-decor";
31
+
32
+ @HyperApp({
33
+ modules: [UserModule],
34
+ prefix: "/api"
35
+ })
36
+ class Application {}
37
+
38
+ const app = await createApplication(Application);
39
+ await app.listen(3000);
40
+ ```
41
+
42
+ ### Decoradores de Parámetros
43
+ Los decoradores `@Body`, `@Query`, `@Param` y `@Headers` permiten diferentes formas de uso.
44
+
45
+ ```typescript
46
+ @HyperController("/users")
47
+ class UserController {
48
+
49
+ // 1. Validación con DTO
50
+ @Post("/")
51
+ async create(@Body(CreateUserDto) user: CreateUserDto) {
52
+ return user;
53
+ }
54
+
55
+ // 2. Extracción por clave y transformación funcional
56
+ @Get("/:id")
57
+ async findOne(@Param("id", v => parseInt(v)) id: number) {
58
+ return { id };
59
+ }
60
+
61
+ // 3. Extracción de propiedad anidada con DTO
62
+ @Post("/settings")
63
+ async updateSettings(@Body("settings", SettingsDto) data: SettingsDto) {
64
+ return data;
65
+ }
66
+
67
+ // 4. Extractores básicos
68
+ @Get("/")
69
+ async list(@Query() allQuery: any, @Req req: any) {
70
+ return allQuery;
71
+ }
72
+ }
73
+ ```
74
+
75
+ ---
76
+
77
+ ## Subida de Archivos (`@File`)
78
+
79
+ El decorador `@File` permite manejar la subida de archivos validando el tamaño y tipo (MIME) mediante streams.
80
+
81
+ ```typescript
82
+ @Post("/upload")
83
+ async upload(
84
+ @File("avatar", {
85
+ maxFileSize: 5 * 1024 * 1024,
86
+ allowedExtensions: ["png", "jpg"],
87
+ allowedMimeTypes: ["image/png", "image/jpeg"]
88
+ }) file: UploadedFile
89
+ ) {
90
+ return { filename: file.filename, size: file.size };
91
+ }
92
+ ```
93
+
94
+ ---
95
+
96
+ ## Rendimiento
97
+
98
+ El sistema está diseñado para introducir la mínima latencia posible sobre HyperExpress.
99
+
100
+ | Escenario | Raw HyperExpress | @zenofolio/hyper-decor |
101
+ | :--- | :--- | :--- |
102
+ | **GET Básico** | 27,150 req/s | 26,660 req/s |
103
+ | **Con Transformación**| 18,120 req/s | 18,335 req/s |
104
+
105
+ ---
106
+
107
+ ## OpenAPI y DTOs
108
+
109
+ Es posible utilizar clases para definir los esquemas de datos que se reflejarán en la documentación OpenAPI generada.
110
+
111
+ ```typescript
112
+ class CreateUserDto {
113
+ age: number;
114
+ name: string;
115
+ }
116
+
117
+ @Post("/")
118
+ async create(@Body(CreateUserDto) data: CreateUserDto) { ... }
119
+ ```
120
+
121
+ ---
122
+
123
+ ## Licencia
124
+
125
+ MIT
@@ -1,65 +1,4 @@
1
- export declare const KEY_TYPE_APP = "hyper:type:app";
2
- export declare const KEY_TYPE_CONTROLLER = "hyper:type:controller";
3
- export declare const KEY_TYPE_MODULE = "hyper:type:module";
4
- export declare const KEY_TYPE_ROUTE = "hyper:type:route";
5
- export declare const KEY_TYPE_SERVICE = "hyper:type:service";
6
- export declare const KEY_TYPE_GUARD = "hyper:type:guard";
7
- export type KeyTypes = typeof KEY_TYPE_APP | typeof KEY_TYPE_CONTROLLER | typeof KEY_TYPE_MODULE | typeof KEY_TYPE_SERVICE | typeof KEY_TYPE_ROUTE;
8
- export declare const KEY_PARAMS_APP = "hyper:type:app";
9
- export declare const KEY_PARAMS_CONTROLLER = "hyper:type:controller";
10
- export declare const KEY_PARAMS_MODULE = "hyper:type:module";
11
- export declare const KEY_PARAMS_ROUTE = "hyper:type:route";
12
- export declare const KEY_PARAMS_PARAM = "hyper:type:param";
13
- export declare const KEY_PARAMS_MIDDLEWARES = "hyper:type:middlewares";
14
- export declare const KEY_PARAMS_SCOPE = "hyper:type:scope";
15
- export declare const KEY_PARAMS_ROLE = "hyper:type:role";
16
- export declare const KEY_PARAMS_PASS = "hyper:type:pass";
17
- export declare const KEY_OUTPUT_SCHEMA = "hyper:output:schema";
18
- export type KeyParams = typeof KEY_PARAMS_APP | typeof KEY_PARAMS_CONTROLLER | typeof KEY_PARAMS_MODULE | typeof KEY_PARAMS_ROUTE | typeof KEY_PARAMS_PARAM | typeof KEY_PARAMS_MIDDLEWARES | typeof KEY_PARAMS_SCOPE | typeof KEY_PARAMS_ROLE | typeof KEY_PARAMS_PASS | typeof KEY_OUTPUT_SCHEMA;
19
- export declare const KEY_STATE_UPDATED = "hyper:state:updated";
20
- export declare const KEY_STATE_CREATED = "hyper:state:created";
21
- export declare const KEY_STATE_PREPARED = "hyper:state:prepared";
22
- export declare const KEY_STATE_BY_PASS = "hyper:state:bypass";
23
- export type KeyState = typeof KEY_STATE_UPDATED | typeof KEY_STATE_CREATED | typeof KEY_STATE_PREPARED;
24
1
  export declare const DESIGN_PARAMTYPES = "design:paramtypes";
25
2
  export declare const DESIGN_RETURNTYPE = "design:returntype";
26
3
  export declare const DESIGN_TYPE = "design:type";
27
- export type DesignKeys = typeof DESIGN_PARAMTYPES | typeof DESIGN_RETURNTYPE | typeof DESIGN_TYPE;
28
- export declare const METADATA_HYPER_TYPE: {
29
- APP: string;
30
- CONTROLLER: string;
31
- MODULE: string;
32
- ROUTE: string;
33
- PARAM: string;
34
- };
35
- export declare const METADATA_KEYS: {
36
- APP_INFO: string;
37
- MODULES: string;
38
- PREFIX: string;
39
- CONTROLLERS: string;
40
- ROUTES: string;
41
- ROLES: string;
42
- SCOPES: string;
43
- SCOPED: string;
44
- MIDDLEWARES: string;
45
- ON_MESSAGE: string;
46
- };
47
- export declare const METADATA_STORE_KEYS: {
48
- PARAMS: string;
49
- };
50
- export declare const METADATA_METHOD_KEYS: {
51
- ARGUMENTS: string;
52
- ARGUMENTS_NAMES: string;
53
- ARGUMENTS_TYPE: string;
54
- };
55
- export declare const METADATA_PARAMS_KEYS: {
56
- DESIGN_PARAM_TYPES: string;
57
- DESIGN_TYPE: string;
58
- DESIGN_RETURN_TYPE: string;
59
- };
60
- export declare const METADATA_STATE_KEYS: {
61
- UPDATED: string;
62
- CREATED: string;
63
- PREPARED: string;
64
- };
65
- export declare const FULL_ACCESS = "*";
4
+ export declare const KEY_OUTPUT_SCHEMA = "hyper:output:schema";
@@ -1,76 +1,10 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FULL_ACCESS = exports.METADATA_STATE_KEYS = exports.METADATA_PARAMS_KEYS = exports.METADATA_METHOD_KEYS = exports.METADATA_STORE_KEYS = exports.METADATA_KEYS = exports.METADATA_HYPER_TYPE = exports.DESIGN_TYPE = exports.DESIGN_RETURNTYPE = exports.DESIGN_PARAMTYPES = exports.KEY_STATE_BY_PASS = exports.KEY_STATE_PREPARED = exports.KEY_STATE_CREATED = exports.KEY_STATE_UPDATED = exports.KEY_OUTPUT_SCHEMA = exports.KEY_PARAMS_PASS = exports.KEY_PARAMS_ROLE = exports.KEY_PARAMS_SCOPE = exports.KEY_PARAMS_MIDDLEWARES = exports.KEY_PARAMS_PARAM = exports.KEY_PARAMS_ROUTE = exports.KEY_PARAMS_MODULE = exports.KEY_PARAMS_CONTROLLER = exports.KEY_PARAMS_APP = exports.KEY_TYPE_GUARD = exports.KEY_TYPE_SERVICE = exports.KEY_TYPE_ROUTE = exports.KEY_TYPE_MODULE = exports.KEY_TYPE_CONTROLLER = exports.KEY_TYPE_APP = void 0;
4
2
  //////////////////////////////
5
3
  /// Types constants
6
4
  //////////////////////////////
7
- exports.KEY_TYPE_APP = "hyper:type:app";
8
- exports.KEY_TYPE_CONTROLLER = "hyper:type:controller";
9
- exports.KEY_TYPE_MODULE = "hyper:type:module";
10
- exports.KEY_TYPE_ROUTE = "hyper:type:route";
11
- exports.KEY_TYPE_SERVICE = "hyper:type:service";
12
- exports.KEY_TYPE_GUARD = "hyper:type:guard";
13
- //////////////////////////////
14
- /// Params constants
15
- //////////////////////////////
16
- exports.KEY_PARAMS_APP = "hyper:type:app";
17
- exports.KEY_PARAMS_CONTROLLER = "hyper:type:controller";
18
- exports.KEY_PARAMS_MODULE = "hyper:type:module";
19
- exports.KEY_PARAMS_ROUTE = "hyper:type:route";
20
- exports.KEY_PARAMS_PARAM = "hyper:type:param";
21
- exports.KEY_PARAMS_MIDDLEWARES = "hyper:type:middlewares";
22
- exports.KEY_PARAMS_SCOPE = "hyper:type:scope";
23
- exports.KEY_PARAMS_ROLE = "hyper:type:role";
24
- exports.KEY_PARAMS_PASS = "hyper:type:pass";
25
- exports.KEY_OUTPUT_SCHEMA = "hyper:output:schema";
26
- //////////////////////////////
27
- /// State constants
28
- //////////////////////////////
29
- exports.KEY_STATE_UPDATED = "hyper:state:updated";
30
- exports.KEY_STATE_CREATED = "hyper:state:created";
31
- exports.KEY_STATE_PREPARED = "hyper:state:prepared";
32
- exports.KEY_STATE_BY_PASS = "hyper:state:bypass";
33
- //////////////////////////////
34
- /// Metadata constants
35
- //////////////////////////////
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.KEY_OUTPUT_SCHEMA = exports.DESIGN_TYPE = exports.DESIGN_RETURNTYPE = exports.DESIGN_PARAMTYPES = void 0;
36
7
  exports.DESIGN_PARAMTYPES = "design:paramtypes";
37
8
  exports.DESIGN_RETURNTYPE = "design:returntype";
38
9
  exports.DESIGN_TYPE = "design:type";
39
- exports.METADATA_HYPER_TYPE = {
40
- APP: "hyper:app",
41
- CONTROLLER: "hyper:controller",
42
- MODULE: "hyper:module",
43
- ROUTE: "hyper:route",
44
- PARAM: "hyper:param",
45
- };
46
- exports.METADATA_KEYS = {
47
- APP_INFO: "hyper:app:info",
48
- MODULES: "hyper:modules",
49
- PREFIX: "hyper:prefix",
50
- CONTROLLERS: "hyper:controllers",
51
- ROUTES: "hyper:routes",
52
- ROLES: "hyper:roles",
53
- SCOPES: "hyper:scopes",
54
- SCOPED: "hyper:scoped",
55
- MIDDLEWARES: "hyper:middleware",
56
- ON_MESSAGE: "hyper:on_message",
57
- };
58
- exports.METADATA_STORE_KEYS = {
59
- PARAMS: "hyper:store:params",
60
- };
61
- exports.METADATA_METHOD_KEYS = {
62
- ARGUMENTS: "hyper:arguments",
63
- ARGUMENTS_NAMES: "hyper:arguments:names",
64
- ARGUMENTS_TYPE: "hyper:arguments:type",
65
- };
66
- exports.METADATA_PARAMS_KEYS = {
67
- DESIGN_PARAM_TYPES: "design:paramtypes",
68
- DESIGN_TYPE: "design:type",
69
- DESIGN_RETURN_TYPE: "design:type",
70
- };
71
- exports.METADATA_STATE_KEYS = {
72
- UPDATED: "hyper:updated",
73
- CREATED: "hyper:created",
74
- PREPARED: "hyper:prepared",
75
- };
76
- exports.FULL_ACCESS = "*";
10
+ exports.KEY_OUTPUT_SCHEMA = "hyper:output:schema";
@@ -1,5 +1,4 @@
1
- import "reflect-metadata";
2
- type MetadataKey = string | symbol;
1
+ import { HyperCommonMetadata } from "../types";
3
2
  type MergeOptions = {
4
3
  overwriteArrays?: boolean;
5
4
  };
@@ -10,5 +9,5 @@ type MergeOptions = {
10
9
  * @param keys Metadata keys to merge.
11
10
  * @param options Merge options (e.g., array handling).
12
11
  */
13
- export declare function mergeMetadata(target: any, source: any, keys: MetadataKey[], options?: MergeOptions): void;
12
+ export declare function mergeMetadata(target: object, source: object, keys: (keyof HyperCommonMetadata)[], options?: MergeOptions): void;
14
13
  export {};
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.mergeMetadata = mergeMetadata;
4
- require("reflect-metadata");
4
+ const meta_store_1 = require("../stores/meta.store");
5
+ /**
6
+ * Perform a clean merge of prefixes
7
+ */
8
+ const HyperMeta = meta_store_1.Metadata.prefix('server');
5
9
  /**
6
10
  * Performs a deep merge of metadata from source to target using reflect-metadata.
7
11
  * @param target Object where the metadata will be merged.
@@ -10,13 +14,32 @@ require("reflect-metadata");
10
14
  * @param options Merge options (e.g., array handling).
11
15
  */
12
16
  function mergeMetadata(target, source, keys, options = {}) {
17
+ const sourceRoot = meta_store_1.Metadata.get(source);
18
+ const targetRoot = meta_store_1.Metadata.get(target);
19
+ const sourceServer = sourceRoot.server;
20
+ if (!sourceServer)
21
+ return;
22
+ const sourceCommon = sourceServer.common;
23
+ const targetServer = targetRoot.server || (targetRoot.server = { common: { type: 'controller' }, methods: {} });
24
+ const targetCommon = targetServer.common;
13
25
  for (let i = 0; i < keys.length; i++) {
14
26
  const key = keys[i];
15
- const sourceMeta = Reflect.getMetadata(key, source);
16
- if (sourceMeta === undefined)
27
+ const value = sourceCommon[key]; // Narrowing complex union access
28
+ if (value === undefined)
17
29
  continue;
18
- const targetMeta = Reflect.getMetadata(key, target);
19
- Reflect.defineMetadata(key, targetMeta === undefined ? sourceMeta : deepMerge(targetMeta, sourceMeta, options), target);
30
+ const current = targetCommon[key];
31
+ const merged = current === undefined
32
+ ? value
33
+ : deepMerge(current, value, options);
34
+ targetCommon[key] = merged;
35
+ }
36
+ // Also merge methods if they exist to preserve routes/params when extending
37
+ if (sourceServer.methods) {
38
+ const sourceMethods = sourceServer.methods;
39
+ const targetMethods = targetServer.methods || (targetServer.methods = {});
40
+ Object.keys(sourceMethods).forEach(methodKey => {
41
+ targetMethods[methodKey] = deepMerge(targetMethods[methodKey] || {}, sourceMethods[methodKey], options);
42
+ });
20
43
  }
21
44
  }
22
45
  function deepMerge(target, source, options) {
@@ -29,10 +52,11 @@ function deepMerge(target, source, options) {
29
52
  }
30
53
  if (source && typeof source === "object" && target && typeof target === "object") {
31
54
  const result = Object.assign({}, target);
32
- const sourceKeys = Object.keys(source);
55
+ const sourceObj = source;
56
+ const sourceKeys = Object.keys(sourceObj);
33
57
  for (let i = 0; i < sourceKeys.length; i++) {
34
58
  const k = sourceKeys[i];
35
- result[k] = deepMerge(result[k], source[k], options);
59
+ result[k] = deepMerge(result[k], sourceObj[k], options);
36
60
  }
37
61
  return result;
38
62
  }
@@ -1,11 +1,5 @@
1
+ import "reflect-metadata";
1
2
  import { Server } from "hyper-express";
2
- import { HyperAppMetadata, LogSpaces } from "../../decorators/types";
3
- /**
4
- * Prepare the application with the given options.
5
- *
6
- * @param options
7
- * @param Target
8
- * @param app
9
- * @param log
10
- */
11
- export declare function prepareApplication(options: HyperAppMetadata, Target: any, app: Server, log: (space: keyof LogSpaces, message: string) => void): Promise<void>;
3
+ import { Constructor, HyperAppMetadata, LogSpaces } from "../../lib/server/decorators/types";
4
+ export declare function registerInstanceHandlers(instance: object, target: Constructor, namespace: string, log: (space: keyof LogSpaces, message: string) => void): Promise<void>;
5
+ export declare function prepareApplication(options: HyperAppMetadata, Target: Constructor, log: (space: keyof LogSpaces, message: string) => void): Promise<Server>;