@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.
- package/.agent/rules/philosophy.md +103 -0
- package/.agent/rules/writing.md +32 -0
- package/README.md +103 -201
- package/dist/__internals/constants.d.ts +1 -62
- package/dist/__internals/constants.js +3 -69
- package/dist/__internals/helpers/merge-metadata.d.ts +2 -3
- package/dist/__internals/helpers/merge-metadata.js +31 -7
- package/dist/__internals/helpers/prepare.helper.d.ts +4 -10
- package/dist/__internals/helpers/prepare.helper.js +325 -281
- package/dist/__internals/stores/hyper.store.d.ts +5 -0
- package/dist/__internals/stores/hyper.store.js +5 -0
- package/dist/__internals/stores/index.d.ts +4 -0
- package/dist/{lib/openapi/helpers → __internals/stores}/index.js +4 -7
- package/dist/__internals/stores/meta.store.d.ts +34 -0
- package/dist/__internals/stores/meta.store.js +107 -0
- package/dist/{stores → __internals/stores}/scope.store.d.ts +1 -1
- package/dist/__internals/transform/middleware.transform.d.ts +1 -1
- package/dist/__internals/transform/middleware.transform.js +1 -1
- package/dist/__internals/transform/role.transform.d.ts +1 -1
- package/dist/__internals/transform/role.transform.js +4 -4
- package/dist/__internals/transform/scope.transfrom.d.ts +1 -1
- package/dist/__internals/transform/scope.transfrom.js +2 -2
- package/dist/__internals/types.d.ts +53 -4
- package/dist/common/bootstrap.d.ts +6 -2
- package/dist/common/bootstrap.js +49 -10
- package/dist/common/testing.d.ts +56 -0
- package/dist/common/testing.js +193 -0
- package/dist/common/transport.d.ts +1 -0
- package/dist/common/transport.js +27 -14
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -1
- package/dist/decorators.d.ts +1 -0
- package/dist/{stores/index.js → decorators.js} +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +7 -5
- package/dist/lib/event/meta.store.d.ts +4 -0
- package/dist/lib/event/meta.store.js +5 -0
- package/dist/lib/openapi/collectors/class.collector.d.ts +5 -9
- package/dist/lib/openapi/collectors/class.collector.js +6 -63
- package/dist/lib/openapi/collectors/index.d.ts +3 -4
- package/dist/lib/openapi/collectors/index.js +0 -1
- package/dist/lib/openapi/collectors/method.collector.d.ts +6 -1
- package/dist/lib/openapi/collectors/method.collector.js +92 -59
- package/dist/lib/openapi/collectors/schema.collector.d.ts +3 -8
- package/dist/lib/openapi/collectors/schema.collector.js +17 -25
- package/dist/lib/openapi/constants.d.ts +1 -0
- package/dist/lib/openapi/constants.js +2 -2
- package/dist/lib/openapi/decorators.d.ts +16 -0
- package/dist/lib/openapi/decorators.js +93 -0
- package/dist/lib/openapi/index.d.ts +29 -5
- package/dist/lib/openapi/index.js +119 -5
- package/dist/lib/openapi/metadata.d.ts +7 -0
- package/dist/lib/openapi/metadata.js +8 -0
- package/dist/lib/openapi/metadata.registry.d.ts +1 -1
- package/dist/lib/server/decorators/File.d.ts +37 -0
- package/dist/{decorators → lib/server/decorators}/File.js +62 -75
- package/dist/lib/server/decorators/Http.d.ts +12 -0
- package/dist/lib/server/decorators/Http.js +56 -0
- package/dist/lib/server/decorators/HyperApp.d.ts +7 -0
- package/dist/lib/server/decorators/HyperApp.js +14 -0
- package/dist/lib/server/decorators/HyperController.d.ts +6 -0
- package/dist/lib/server/decorators/HyperController.js +15 -0
- package/dist/lib/server/decorators/HyperModule.d.ts +6 -0
- package/dist/lib/server/decorators/HyperModule.js +13 -0
- package/dist/lib/server/decorators/HyperService.d.ts +12 -0
- package/dist/lib/server/decorators/HyperService.js +30 -0
- package/dist/lib/server/decorators/Messaging.d.ts +8 -0
- package/dist/lib/server/decorators/Messaging.js +19 -0
- package/dist/{decorators → lib/server/decorators}/Middleware.d.ts +5 -12
- package/dist/lib/server/decorators/Middleware.js +52 -0
- package/dist/lib/server/decorators/Output.d.ts +6 -0
- package/dist/lib/server/decorators/Output.js +14 -0
- package/dist/lib/server/decorators/Pass.d.ts +10 -0
- package/dist/lib/server/decorators/Pass.js +13 -0
- package/dist/lib/server/decorators/Role.d.ts +7 -0
- package/dist/lib/server/decorators/Role.js +14 -0
- package/dist/lib/server/decorators/Routes.d.ts +14 -0
- package/dist/lib/server/decorators/Routes.js +39 -0
- package/dist/lib/server/decorators/Scope.d.ts +7 -0
- package/dist/lib/server/decorators/Scope.js +14 -0
- package/dist/{decorators → lib/server/decorators}/index.d.ts +6 -4
- package/dist/{decorators → lib/server/decorators}/index.js +6 -4
- package/dist/lib/server/decorators/metadata.d.ts +1 -0
- package/dist/lib/server/decorators/metadata.js +5 -0
- package/dist/{decorators → lib/server/decorators}/types.d.ts +16 -15
- package/dist/{exeptions → lib/server/exeptions}/HyperException.d.ts +2 -1
- package/dist/{exeptions → lib/server/exeptions}/HyperException.js +2 -1
- package/dist/{exeptions → lib/server/exeptions}/HyperFileException.js +1 -1
- package/dist/{exeptions → lib/server/exeptions}/NotRoleException.js +1 -1
- package/dist/{exeptions → lib/server/exeptions}/NotScopeException.js +1 -1
- package/dist/{__internals/helpers/tree.helper.d.ts → lib/tree/tree.d.ts} +12 -12
- package/dist/lib/tree/tree.js +106 -0
- package/package.json +10 -2
- package/scripts/clean.js +54 -54
- package/scripts/test-server.ts +85 -85
- package/vitest.config.mjs +1 -1
- package/debug.txt +0 -1
- package/dist/__internals/creators/request.creator.d.ts +0 -11
- package/dist/__internals/creators/request.creator.js +0 -55
- package/dist/__internals/creators/routes.creator.d.ts +0 -9
- package/dist/__internals/creators/routes.creator.js +0 -39
- package/dist/__internals/decorator-base.d.ts +0 -30
- package/dist/__internals/decorator-base.js +0 -122
- package/dist/__internals/helpers/imports.helper.d.ts +0 -8
- package/dist/__internals/helpers/imports.helper.js +0 -92
- package/dist/__internals/helpers/tree.helper.js +0 -81
- package/dist/__internals/stores/metadata.store.d.ts +0 -15
- package/dist/__internals/stores/metadata.store.js +0 -37
- package/dist/decorators/File.d.ts +0 -65
- package/dist/decorators/Http.d.ts +0 -62
- package/dist/decorators/Http.js +0 -139
- package/dist/decorators/HyperApp.d.ts +0 -3
- package/dist/decorators/HyperApp.js +0 -96
- package/dist/decorators/HyperController.d.ts +0 -2
- package/dist/decorators/HyperController.js +0 -20
- package/dist/decorators/HyperModule.d.ts +0 -5
- package/dist/decorators/HyperModule.js +0 -14
- package/dist/decorators/HyperService.d.ts +0 -15
- package/dist/decorators/HyperService.js +0 -29
- package/dist/decorators/Messaging.d.ts +0 -10
- package/dist/decorators/Messaging.js +0 -22
- package/dist/decorators/Middleware.js +0 -65
- package/dist/decorators/Output.d.ts +0 -9
- package/dist/decorators/Output.js +0 -18
- package/dist/decorators/Pass.d.ts +0 -15
- package/dist/decorators/Pass.js +0 -32
- package/dist/decorators/Role.d.ts +0 -6
- package/dist/decorators/Role.js +0 -34
- package/dist/decorators/Routes.d.ts +0 -15
- package/dist/decorators/Routes.js +0 -21
- package/dist/decorators/Scope.d.ts +0 -6
- package/dist/decorators/Scope.js +0 -25
- package/dist/decorators/Transform.d.ts +0 -14
- package/dist/decorators/Transform.js +0 -18
- package/dist/lib/openapi/collectors/param.collector.d.ts +0 -2
- package/dist/lib/openapi/collectors/param.collector.js +0 -64
- package/dist/lib/openapi/decorators/api-bearer-auth.decorator.d.ts +0 -2
- package/dist/lib/openapi/decorators/api-bearer-auth.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-method.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-method.decorator.js +0 -11
- package/dist/lib/openapi/decorators/api-parameter.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-parameter.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-request-body.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-request-body.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-response.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-response.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-security.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-security.decorator.js +0 -10
- package/dist/lib/openapi/decorators/api-tag.decorator.d.ts +0 -3
- package/dist/lib/openapi/decorators/api-tag.decorator.js +0 -13
- package/dist/lib/openapi/decorators/index.d.ts +0 -7
- package/dist/lib/openapi/decorators/index.js +0 -23
- package/dist/lib/openapi/helpers/index.d.ts +0 -7
- package/dist/lib/openapi/helpers/method.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/method.helper.js +0 -20
- package/dist/lib/openapi/helpers/openapi.helper.d.ts +0 -7
- package/dist/lib/openapi/helpers/openapi.helper.js +0 -51
- package/dist/lib/openapi/helpers/parameter.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/parameter.helper.js +0 -16
- package/dist/lib/openapi/helpers/request-body.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/request-body.helper.js +0 -9
- package/dist/lib/openapi/helpers/response.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/response.helper.js +0 -18
- package/dist/lib/openapi/helpers/security.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/security.helper.js +0 -17
- package/dist/lib/openapi/helpers/tag.helper.d.ts +0 -3
- package/dist/lib/openapi/helpers/tag.helper.js +0 -10
- package/dist/stores/index.d.ts +0 -1
- package/vitest.json +0 -0
- /package/dist/{stores → __internals/stores}/scope.store.js +0 -0
- /package/dist/__internals/stores/{service.store.d.ts → serivces.store.d.ts} +0 -0
- /package/dist/__internals/stores/{service.store.js → serivces.store.js} +0 -0
- /package/dist/{decorators → lib/server/decorators}/types.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicateControllerPathException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicateControllerPathException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicatedException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicatedException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicatedHandlerException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/DuplicatedHandlerException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/HyperFileException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/MethodNotFountException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/MethodNotFountException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/NotPropertyException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/NotPropertyException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/NotRoleException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/NotScopeException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/WrongPlaceException.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/WrongPlaceException.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/index.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/index.js +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/types.d.ts +0 -0
- /package/dist/{exeptions → lib/server/exeptions}/types.js +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,254 +1,156 @@
|
|
|
1
|
-
#
|
|
2
|
-
A simple decorators library for Hyper Express
|
|
1
|
+
# @zenofolio/hyper-decor
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
This is a personal library designed to make it easier for me to create fast APIs. Maybe it can be helpful for someone else too.
|
|
3
|
+
Librería de decoradores para [HyperExpress](https://github.com/kartikk221/hyper-express).
|
|
6
4
|
|
|
7
|
-
|
|
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.
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
- [HyperExpress](https://github.com/kartikk221/hyper-express)
|
|
7
|
+
---
|
|
11
8
|
|
|
9
|
+
## Características
|
|
12
10
|
|
|
13
|
-
|
|
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.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
- `@HyperApp` – Defines the application module.
|
|
17
|
-
- `@HyperModule` – Creates a module with controllers.
|
|
18
|
-
- `@HyperController` – Defines a controller within a module.
|
|
16
|
+
---
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
- `@Body(validator?)` – Retrieves and optionally validates the request body.
|
|
22
|
-
- `@Query(name?: string)` – Extracts query parameters from the request.
|
|
23
|
-
- `@Param(name?: string)` – Extracts route parameters from the request.
|
|
18
|
+
## Instalación
|
|
24
19
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
### Middleware & Access Control
|
|
29
|
-
- `@Middleware` – Attaches middleware to a route or controller.
|
|
30
|
-
- `@Role(["ADMIN", "SUPERVISOR"])` – Ensures the request is valid for users with any of the specified roles.
|
|
31
|
-
- `@Scope` – Defines permissions for specific actions.
|
|
32
|
-
|
|
33
|
-
### Route Methods (`@Routes`)
|
|
34
|
-
- `@Get` – Handles GET requests.
|
|
35
|
-
- `@Post` – Handles POST requests.
|
|
36
|
-
- `@Put` – Handles PUT requests.
|
|
37
|
-
- `@Delete` – Handles DELETE requests.
|
|
38
|
-
- `@Patch` – Handles PATCH requests.
|
|
39
|
-
- `@Options` – Handles OPTIONS requests.
|
|
40
|
-
- `@Head` – Handles HEAD requests.
|
|
41
|
-
- `@Trace` – Handles TRACE requests.
|
|
42
|
-
- `@Any` – Handles any type of HTTP request.
|
|
43
|
-
- `@All` – Handles all HTTP requests.
|
|
44
|
-
- `@Connect` – Handles CONNECT requests.
|
|
45
|
-
- `@WS` – Handles WebSocket requests.
|
|
46
|
-
- `@Upgrade` – Handles HTTP upgrade requests.
|
|
47
|
-
|
|
48
|
-
### Custom Parameter Decorators
|
|
49
|
-
Use `createCustomRequestDecorator` if you want to create custom parameter decorators for requests.
|
|
50
|
-
|
|
51
|
-
#### Example: Zod Schema
|
|
52
|
-
|
|
53
|
-
```typescript
|
|
54
|
-
const Parser = <T extends any>(schema: ZodSchema<T> | ZodEffects<any>) =>
|
|
55
|
-
createCustomRequestDecorator(
|
|
56
|
-
'Parser',
|
|
57
|
-
async (request) => schema.parse(await request.json())
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// Use the decorator
|
|
61
|
-
|
|
62
|
-
const userScheme = z.object({
|
|
63
|
-
name: z.string(),
|
|
64
|
-
email: z.string().email(),
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
type UserScheme = z.infer<typeof userScheme>;
|
|
68
|
-
|
|
69
|
-
@HyperController()
|
|
70
|
-
class ParserController {
|
|
71
|
-
@Post()
|
|
72
|
-
async create(
|
|
73
|
-
@Parser(userScheme) user: UserScheme,
|
|
74
|
-
@Res response: Response
|
|
75
|
-
) {
|
|
76
|
-
response.json(user);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
20
|
+
```bash
|
|
21
|
+
npm install @zenofolio/hyper-decor
|
|
79
22
|
```
|
|
80
23
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
This package extends the `hyper-express/Request` class by adding methods that help manage roles and scopes for requests.
|
|
24
|
+
---
|
|
84
25
|
|
|
85
|
-
|
|
86
|
-
- `req.setRole(role)` – Assigns a role to the request.
|
|
87
|
-
- `req.hasRole(role)` – Checks if the request has the specified role.
|
|
88
|
-
- `req.setScopes(scopes)` – Assigns scopes to the request.
|
|
89
|
-
- `req.hasScopes(scopes)` – Checks if the request has the specified scopes.
|
|
90
|
-
- `req.setRoleScopes(role, scopes)` – Sets both the role and the scopes in one method.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
### examples
|
|
26
|
+
## Uso
|
|
94
27
|
|
|
28
|
+
### Definición de Aplicación
|
|
95
29
|
```typescript
|
|
30
|
+
import { HyperApp, createApplication } from "@zenofolio/hyper-decor";
|
|
96
31
|
|
|
97
|
-
@
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
req.setRole("ADMIN");
|
|
101
|
-
|
|
102
|
-
// Assigning scopes to the request
|
|
103
|
-
req.setScopes(["read", "write"]);
|
|
104
|
-
|
|
105
|
-
// set role and scopes
|
|
106
|
-
// req.setRoleScopes("ADMIN", ["read", "write"]);
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// Check if the request has the "ADMIN" role
|
|
110
|
-
// if (req.hasRole("ADMIN")) {
|
|
111
|
-
// res.send("Role: ADMIN is assigned");
|
|
112
|
-
// }
|
|
113
|
-
|
|
114
|
-
// Check if the request has the "write" scope
|
|
115
|
-
// if (req.hasScopes(["write"])) {
|
|
116
|
-
// res.send("Scope: write is granted");
|
|
117
|
-
// }
|
|
118
|
-
|
|
119
|
-
next();
|
|
120
|
-
})
|
|
121
|
-
@HyperModule({
|
|
122
|
-
path: 'users'
|
|
32
|
+
@HyperApp({
|
|
33
|
+
modules: [UserModule],
|
|
34
|
+
prefix: "/api"
|
|
123
35
|
})
|
|
124
|
-
class
|
|
36
|
+
class Application {}
|
|
125
37
|
|
|
38
|
+
const app = await createApplication(Application);
|
|
39
|
+
await app.listen(3000);
|
|
126
40
|
```
|
|
127
41
|
|
|
128
|
-
|
|
42
|
+
### Decoradores de Parámetros
|
|
43
|
+
Los decoradores `@Body`, `@Query`, `@Param` y `@Headers` permiten diferentes formas de uso.
|
|
129
44
|
|
|
130
|
-
`@HyperController` - Simple versioned controller
|
|
131
45
|
```typescript
|
|
132
|
-
@HyperController("
|
|
133
|
-
class
|
|
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
|
+
}
|
|
134
54
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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 };
|
|
138
59
|
}
|
|
139
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
|
+
}
|
|
140
72
|
}
|
|
141
73
|
```
|
|
142
74
|
|
|
143
|
-
|
|
144
|
-
```typescript
|
|
145
|
-
@HyperModule({
|
|
146
|
-
path: "users",
|
|
147
|
-
controllers: [TestController]
|
|
148
|
-
})
|
|
149
|
-
class UserModule {}
|
|
150
|
-
```
|
|
75
|
+
---
|
|
151
76
|
|
|
77
|
+
## Subida de Archivos (`@File`)
|
|
152
78
|
|
|
79
|
+
El decorador `@File` permite manejar la subida de archivos validando el tamaño y tipo (MIME) mediante streams.
|
|
153
80
|
|
|
154
|
-
`@HyperApp` - define application
|
|
155
81
|
```typescript
|
|
156
|
-
@
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
})
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
console.log("This method will be called after the app is prepared");
|
|
166
|
-
}
|
|
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 };
|
|
167
91
|
}
|
|
168
92
|
```
|
|
169
93
|
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
const app = await createApplication(Application)
|
|
173
|
-
await app.listen(3000);
|
|
174
|
-
|
|
175
|
-
```
|
|
94
|
+
---
|
|
176
95
|
|
|
177
|
-
|
|
96
|
+
## OpenAPI y DTOs
|
|
178
97
|
|
|
179
|
-
|
|
98
|
+
Es posible utilizar clases para definir los esquemas de datos que se reflejarán en la documentación OpenAPI generada.
|
|
180
99
|
|
|
100
|
+
```typescript
|
|
101
|
+
class CreateUserDto {
|
|
102
|
+
age: number;
|
|
103
|
+
name: string;
|
|
104
|
+
}
|
|
181
105
|
|
|
182
|
-
|
|
106
|
+
@Post("/")
|
|
107
|
+
async create(@Body(CreateUserDto) data: CreateUserDto) { ... }
|
|
108
|
+
```
|
|
183
109
|
|
|
184
|
-
|
|
185
|
-
- [Middleware](./examples/middleware.ts)
|
|
186
|
-
- [File](./examples//upload-file.ts)
|
|
110
|
+
---
|
|
187
111
|
|
|
188
|
-
##
|
|
189
|
-
You can use `@HyperService()` with `tsyringe` to inject dependencies into controllers or other services.
|
|
112
|
+
## Testing
|
|
190
113
|
|
|
191
|
-
|
|
192
|
-
import { injectable } from "tsyringe";
|
|
114
|
+
`@zenofolio/hyper-decor` incluye una utilidad potente y fácil de usar inspirada en NestJS para facilitar el testing de servicios, módulos y controladores.
|
|
193
115
|
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
class UserService {
|
|
197
|
-
getUsers() { return ["User1", "User2"]; }
|
|
198
|
-
}
|
|
116
|
+
### HyperTest
|
|
117
|
+
La clase `HyperTest` permite crear entornos de prueba aislados con soporte completo para el ciclo de vida `onInit` de forma recursiva.
|
|
199
118
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
119
|
+
#### 1. Bootstrap de una línea (Simplicidad total)
|
|
120
|
+
Ideal para pruebas rápidas de integración de una aplicación, módulo o servicio.
|
|
121
|
+
```typescript
|
|
122
|
+
import { HyperTest } from "@zenofolio/hyper-decor";
|
|
203
123
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
res.json(this.userService.getUsers());
|
|
207
|
-
}
|
|
208
|
-
}
|
|
124
|
+
const module = await HyperTest.create(AppModule);
|
|
125
|
+
const service = await module.get(MyService);
|
|
209
126
|
```
|
|
210
127
|
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
128
|
+
#### 2. Sobrescritura de Proveedores (Mocks)
|
|
129
|
+
Puedes reemplazar dependencias fácilmente usando el API de construcción (builder).
|
|
214
130
|
```typescript
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
return data;
|
|
222
|
-
},
|
|
223
|
-
getOpenApiSchema: (schema) => {
|
|
224
|
-
if (schema._type === "zod") {
|
|
225
|
-
return { type: "object", properties: { /* derived from schema */ } };
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
const app = await createApplication(Application);
|
|
231
|
-
app.useTransform(ZodTransformer); // Register your custom transformer globally
|
|
131
|
+
const module = await HyperTest.createTestingModule({
|
|
132
|
+
imports: [AppModule]
|
|
133
|
+
})
|
|
134
|
+
.overrideProvider(AuthService).useValue(mockAuth)
|
|
135
|
+
.compile();
|
|
232
136
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
@Post("/")
|
|
236
|
-
@Transform({ _type: "zod" /* pass your schema */ })
|
|
237
|
-
createUser(@Body() data: any, @Res() res: Response) {
|
|
238
|
-
res.json(data); // `data` is automatically intercepted and transformed!
|
|
239
|
-
}
|
|
240
|
-
}
|
|
137
|
+
const service = module.get(AuthService);
|
|
138
|
+
const app = await module.createHyperApplication();
|
|
241
139
|
```
|
|
242
140
|
|
|
243
|
-
|
|
244
|
-
|
|
141
|
+
#### 3. Soporte para Clases Abstractas e Inyección Profunda
|
|
142
|
+
El sistema soporta la resolución de implementaciones a través de clases abstractas como tokens y garantiza que todo el árbol de dependencias ejecute su `onInit` antes de comenzar la prueba.
|
|
245
143
|
|
|
144
|
+
### Reset del Contenedor
|
|
145
|
+
Para evitar la persistencia de instancias entre tests, `HyperTest` proporciona una utilidad de limpieza.
|
|
246
146
|
```typescript
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
console.log(openApiDoc.info.title, openApiDoc.paths);
|
|
147
|
+
beforeEach(() => {
|
|
148
|
+
HyperTest.reset();
|
|
149
|
+
});
|
|
251
150
|
```
|
|
252
151
|
|
|
253
|
-
|
|
254
|
-
|
|
152
|
+
---
|
|
153
|
+
|
|
154
|
+
## Licencia
|
|
155
|
+
|
|
156
|
+
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
|
|
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
|
|
8
|
-
exports.
|
|
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.
|
|
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 "
|
|
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:
|
|
12
|
+
export declare function mergeMetadata(target: object, source: object, keys: (keyof HyperCommonMetadata)[], options?: MergeOptions): void;
|
|
14
13
|
export {};
|