@navios/core 1.1.0 → 2.0.0-alpha.0

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 (241) hide show
  1. package/CHANGELOG.md +53 -11
  2. package/README.md +67 -220
  3. package/lib/async-context-6pdlnNLA.d.mts +237 -0
  4. package/lib/async-context-6pdlnNLA.d.mts.map +1 -0
  5. package/lib/async-context-Dqk7pE-D.d.cts +237 -0
  6. package/lib/async-context-Dqk7pE-D.d.cts.map +1 -0
  7. package/lib/attribute-factory-B3VuYnp7.d.cts +70 -0
  8. package/lib/attribute-factory-B3VuYnp7.d.cts.map +1 -0
  9. package/lib/attribute-factory-mKOXoVnV.d.mts +70 -0
  10. package/lib/attribute-factory-mKOXoVnV.d.mts.map +1 -0
  11. package/lib/attribute-value-CjX9ZkLq.cjs +172 -0
  12. package/lib/attribute-value-CjX9ZkLq.cjs.map +1 -0
  13. package/lib/attribute-value-DMEA255r.mjs +119 -0
  14. package/lib/attribute-value-DMEA255r.mjs.map +1 -0
  15. package/lib/basic-execution-context-CeGuhMOz.mjs +246 -0
  16. package/lib/basic-execution-context-CeGuhMOz.mjs.map +1 -0
  17. package/lib/basic-execution-context-DSk5MNtc.cjs +281 -0
  18. package/lib/basic-execution-context-DSk5MNtc.cjs.map +1 -0
  19. package/lib/execution-context-BPD3FeFb.d.mts +71 -0
  20. package/lib/execution-context-BPD3FeFb.d.mts.map +1 -0
  21. package/lib/execution-context-BTJdHhbf.d.cts +71 -0
  22. package/lib/execution-context-BTJdHhbf.d.cts.map +1 -0
  23. package/lib/execution-context-token-BXUKB2hf.cjs +112 -0
  24. package/lib/execution-context-token-BXUKB2hf.cjs.map +1 -0
  25. package/lib/execution-context-token-CrXmTvk2.mjs +77 -0
  26. package/lib/execution-context-token-CrXmTvk2.mjs.map +1 -0
  27. package/lib/index.cjs +1687 -4424
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +838 -3
  30. package/lib/index.d.cts.map +1 -0
  31. package/lib/index.d.mts +838 -3
  32. package/lib/index.d.mts.map +1 -0
  33. package/lib/index.mjs +1573 -4219
  34. package/lib/index.mjs.map +1 -1
  35. package/lib/legacy-compat/index.cjs +72 -371
  36. package/lib/legacy-compat/index.cjs.map +1 -1
  37. package/lib/legacy-compat/index.d.cts +42 -382
  38. package/lib/legacy-compat/index.d.cts.map +1 -1
  39. package/lib/legacy-compat/index.d.mts +41 -382
  40. package/lib/legacy-compat/index.d.mts.map +1 -1
  41. package/lib/legacy-compat/index.mjs +51 -345
  42. package/lib/legacy-compat/index.mjs.map +1 -1
  43. package/lib/module-Bha7GER_.mjs +135 -0
  44. package/lib/module-Bha7GER_.mjs.map +1 -0
  45. package/lib/module-DZewk_2r.cjs +164 -0
  46. package/lib/module-DZewk_2r.cjs.map +1 -0
  47. package/lib/module-graph-DCP9MHG0.cjs +147 -0
  48. package/lib/module-graph-DCP9MHG0.cjs.map +1 -0
  49. package/lib/module-graph-xvVEykFM.mjs +142 -0
  50. package/lib/module-graph-xvVEykFM.mjs.map +1 -0
  51. package/lib/module-metadata-C8S92seK.cjs +95 -0
  52. package/lib/module-metadata-C8S92seK.cjs.map +1 -0
  53. package/lib/module-metadata-k3RTt20x.mjs +66 -0
  54. package/lib/module-metadata-k3RTt20x.mjs.map +1 -0
  55. package/lib/module-options-Dmse0gii.d.mts +51 -0
  56. package/lib/module-options-Dmse0gii.d.mts.map +1 -0
  57. package/lib/module-options-IuDO-p8u.d.cts +51 -0
  58. package/lib/module-options-IuDO-p8u.d.cts.map +1 -0
  59. package/lib/testing/index.cjs +96 -414
  60. package/lib/testing/index.cjs.map +1 -1
  61. package/lib/testing/index.d.cts +25 -385
  62. package/lib/testing/index.d.cts.map +1 -1
  63. package/lib/testing/index.d.mts +24 -385
  64. package/lib/testing/index.d.mts.map +1 -1
  65. package/lib/testing/index.mjs +94 -408
  66. package/lib/testing/index.mjs.map +1 -1
  67. package/lib/transport.cjs +25 -0
  68. package/lib/transport.d.cts +190 -0
  69. package/lib/transport.d.cts.map +1 -0
  70. package/lib/transport.d.mts +190 -0
  71. package/lib/transport.d.mts.map +1 -0
  72. package/lib/transport.mjs +7 -0
  73. package/package.json +37 -17
  74. package/docs/README.md +0 -316
  75. package/docs/adapters.md +0 -308
  76. package/docs/application-setup.md +0 -524
  77. package/docs/attributes.md +0 -689
  78. package/docs/controllers.md +0 -373
  79. package/docs/endpoints.md +0 -444
  80. package/docs/exceptions.md +0 -352
  81. package/docs/guards.md +0 -550
  82. package/docs/legacy-compat.md +0 -356
  83. package/docs/modules.md +0 -377
  84. package/docs/quick-start.md +0 -290
  85. package/docs/services.md +0 -427
  86. package/docs/testing.md +0 -827
  87. package/lib/index-3LcTrbxz.d.mts +0 -3804
  88. package/lib/index-3LcTrbxz.d.mts.map +0 -1
  89. package/lib/index-B14SekVb.d.cts +0 -3804
  90. package/lib/index-B14SekVb.d.cts.map +0 -1
  91. package/lib/navios.factory-CUrO_p6K.cjs +0 -4538
  92. package/lib/navios.factory-CUrO_p6K.cjs.map +0 -1
  93. package/lib/navios.factory-DjUOOVVL.mjs +0 -4151
  94. package/lib/navios.factory-DjUOOVVL.mjs.map +0 -1
  95. package/lib/tokens-BEuBMGGX.cjs +0 -193
  96. package/lib/tokens-BEuBMGGX.cjs.map +0 -1
  97. package/lib/tokens-COyNGV1I.mjs +0 -97
  98. package/lib/tokens-COyNGV1I.mjs.map +0 -1
  99. package/lib/use-guards.decorator-DLmRl2CV.mjs +0 -336
  100. package/lib/use-guards.decorator-DLmRl2CV.mjs.map +0 -1
  101. package/lib/use-guards.decorator-DhumFTk3.cjs +0 -444
  102. package/lib/use-guards.decorator-DhumFTk3.cjs.map +0 -1
  103. package/project.json +0 -66
  104. package/src/__tests__/attribute.factory.spec.mts +0 -300
  105. package/src/__tests__/config.service.spec.mts +0 -43
  106. package/src/__tests__/console-logger.service.spec.mts +0 -312
  107. package/src/__tests__/controller-resolver.spec.mts +0 -229
  108. package/src/__tests__/controller.spec.mts +0 -58
  109. package/src/__tests__/guard-runner.service.spec.mts +0 -399
  110. package/src/__tests__/logger.service.spec.mts +0 -147
  111. package/src/__tests__/responders.spec.mts +0 -340
  112. package/src/__tests__/testing-module.spec.mts +0 -459
  113. package/src/__tests__/unit-testing-module.spec.mts +0 -424
  114. package/src/attribute.factory.mts +0 -325
  115. package/src/config/config-service.interface.mts +0 -47
  116. package/src/config/config.provider.mts +0 -69
  117. package/src/config/config.service.mts +0 -176
  118. package/src/config/index.mts +0 -5
  119. package/src/config/types.mts +0 -58
  120. package/src/config/utils/helpers.mts +0 -23
  121. package/src/config/utils/index.mts +0 -1
  122. package/src/decorators/controller.decorator.mts +0 -81
  123. package/src/decorators/endpoint.decorator.mts +0 -181
  124. package/src/decorators/header.decorator.mts +0 -38
  125. package/src/decorators/http-code.decorator.mts +0 -38
  126. package/src/decorators/index.mts +0 -8
  127. package/src/decorators/module.decorator.mts +0 -106
  128. package/src/decorators/multipart.decorator.mts +0 -169
  129. package/src/decorators/stream.decorator.mts +0 -155
  130. package/src/decorators/use-guards.decorator.mts +0 -73
  131. package/src/exceptions/bad-request.exception.mts +0 -28
  132. package/src/exceptions/conflict.exception.mts +0 -31
  133. package/src/exceptions/forbidden.exception.mts +0 -30
  134. package/src/exceptions/http.exception.mts +0 -33
  135. package/src/exceptions/index.mts +0 -7
  136. package/src/exceptions/internal-server-error.exception.mts +0 -33
  137. package/src/exceptions/not-found.exception.mts +0 -33
  138. package/src/exceptions/unauthorized.exception.mts +0 -30
  139. package/src/factories/adapter.factory.mts +0 -20
  140. package/src/factories/endpoint-adapter.factory.mts +0 -21
  141. package/src/factories/http-adapter.factory.mts +0 -20
  142. package/src/factories/index.mts +0 -8
  143. package/src/factories/multipart-adapter.factory.mts +0 -21
  144. package/src/factories/reply.factory.mts +0 -21
  145. package/src/factories/request.factory.mts +0 -21
  146. package/src/factories/stream-adapter.factory.mts +0 -20
  147. package/src/factories/xml-stream-adapter.factory.mts +0 -20
  148. package/src/index.mts +0 -16
  149. package/src/interfaces/abstract-adapter.interface.mts +0 -32
  150. package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
  151. package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
  152. package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
  153. package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
  154. package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
  155. package/src/interfaces/adapter-environment.interface.mts +0 -74
  156. package/src/interfaces/can-activate.mts +0 -38
  157. package/src/interfaces/http-header.mts +0 -18
  158. package/src/interfaces/index.mts +0 -14
  159. package/src/interfaces/navios-module.mts +0 -28
  160. package/src/interfaces/plugin-context.mts +0 -104
  161. package/src/interfaces/plugin-stage.mts +0 -62
  162. package/src/interfaces/plugin.interface.mts +0 -119
  163. package/src/interfaces/staged-plugin.interface.mts +0 -209
  164. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  165. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  166. package/src/legacy-compat/attribute.factory.mts +0 -351
  167. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  168. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  169. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  170. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  171. package/src/legacy-compat/decorators/index.mts +0 -11
  172. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  173. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  174. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  175. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  176. package/src/legacy-compat/index.mts +0 -57
  177. package/src/logger/README.md +0 -3
  178. package/src/logger/console-logger.service.mts +0 -714
  179. package/src/logger/index.mts +0 -6
  180. package/src/logger/log-levels.mts +0 -21
  181. package/src/logger/logger-service.interface.mts +0 -42
  182. package/src/logger/logger.service.mts +0 -113
  183. package/src/logger/logger.tokens.mts +0 -44
  184. package/src/logger/utils/cli-colors.util.mts +0 -17
  185. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  186. package/src/logger/utils/index.mts +0 -5
  187. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  188. package/src/logger/utils/is-log-level.util.mts +0 -10
  189. package/src/logger/utils/shared.utils.mts +0 -51
  190. package/src/metadata/controller.metadata.mts +0 -79
  191. package/src/metadata/handler.metadata.mts +0 -80
  192. package/src/metadata/index.mts +0 -4
  193. package/src/metadata/module.metadata.mts +0 -116
  194. package/src/metadata/navios-managed.metadata.mts +0 -42
  195. package/src/navios.application.mts +0 -678
  196. package/src/navios.environment.mts +0 -42
  197. package/src/navios.factory.mts +0 -158
  198. package/src/responders/enums/framework-error.enum.mts +0 -38
  199. package/src/responders/enums/index.mts +0 -1
  200. package/src/responders/index.mts +0 -4
  201. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  202. package/src/responders/interfaces/error-response.interface.mts +0 -22
  203. package/src/responders/interfaces/index.mts +0 -3
  204. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  205. package/src/responders/services/error-response-producer.service.mts +0 -143
  206. package/src/responders/services/forbidden-responder.service.mts +0 -77
  207. package/src/responders/services/index.mts +0 -5
  208. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  209. package/src/responders/services/not-found-responder.service.mts +0 -76
  210. package/src/responders/services/validation-error-responder.service.mts +0 -78
  211. package/src/responders/tokens/index.mts +0 -1
  212. package/src/responders/tokens/responder.tokens.mts +0 -84
  213. package/src/services/abstract-handler-adapter.service.mts +0 -366
  214. package/src/services/guard-runner.service.mts +0 -152
  215. package/src/services/index.mts +0 -4
  216. package/src/services/instance-resolver.service.mts +0 -177
  217. package/src/services/module-loader.service.mts +0 -255
  218. package/src/stores/index.mts +0 -1
  219. package/src/stores/request-id.store.mts +0 -85
  220. package/src/testing/index.mts +0 -3
  221. package/src/testing/testing-module.mts +0 -393
  222. package/src/testing/unit-testing-module.mts +0 -298
  223. package/src/tokens/adapter.token.mts +0 -6
  224. package/src/tokens/endpoint-adapter.token.mts +0 -8
  225. package/src/tokens/execution-context.token.mts +0 -9
  226. package/src/tokens/http-adapter.token.mts +0 -8
  227. package/src/tokens/index.mts +0 -10
  228. package/src/tokens/multipart-adapter.token.mts +0 -8
  229. package/src/tokens/navios-options.token.mts +0 -6
  230. package/src/tokens/reply.token.mts +0 -3
  231. package/src/tokens/request.token.mts +0 -3
  232. package/src/tokens/stream-adapter.token.mts +0 -8
  233. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  234. package/src/utils/adapter-supports.util.mts +0 -47
  235. package/src/utils/define-plugin.mts +0 -251
  236. package/src/utils/index.mts +0 -2
  237. package/tsconfig.json +0 -21
  238. package/tsconfig.lib.json +0 -8
  239. package/tsconfig.spec.json +0 -15
  240. package/tsdown.config.mts +0 -35
  241. package/vitest.config.mts +0 -15
@@ -1,393 +1,53 @@
1
- import { $n as ModuleMetadata, Ct as MultipartResult, St as MultipartParams, Tt as ModuleOptions, ar as ControllerMetadata, bt as StreamParams, dr as HandlerMetadata, gr as EndpointResult, hr as EndpointParams, in as HttpHeader, on as CanActivate, vr as ControllerOptions } from "../index-B14SekVb.cjs";
2
- import { ClassType, ClassTypeWithInstance, InjectionToken } from "@navios/di";
3
- import { ZodType, z as z$1 } from "zod/v4";
4
- import { BaseEndpointOptions, EndpointHandler, EndpointOptions, RequestArgs, StreamHandler } from "@navios/builder";
5
- import { Factory, FactoryOptions, Injectable, InjectableOptions, createClassContext, createMethodContext } from "@navios/di/legacy-compat";
6
-
7
- //#region src/legacy-compat/decorators/module.decorator.d.mts
8
-
9
1
  /**
10
- * Legacy-compatible Module decorator.
2
+ * Decorators for projects that keep `experimentalDecorators: true`
3
+ * (TypeScript legacy decorators). Projects that use standard decorators,
4
+ * including under Bun, use the main entry point instead.
11
5
  *
12
- * Works with TypeScript experimental decorators (legacy API).
13
- *
14
- * @param options - Module configuration options
15
- * @returns A class decorator compatible with legacy decorator API
16
- *
17
- * @example
18
- * ```typescript
19
- * @Module({
20
- * controllers: [UserController, AuthController],
21
- * imports: [DatabaseModule],
22
- * guards: [AuthGuard],
23
- * })
24
- * export class AppModule {}
25
- * ```
26
- */
27
- declare function Module(options?: ModuleOptions): (target: ClassType) => ClassType;
28
- //#endregion
29
- //#region src/legacy-compat/decorators/controller.decorator.d.mts
30
- /**
31
- * Legacy-compatible Controller decorator.
32
- *
33
- * Works with TypeScript experimental decorators (legacy API).
34
- *
35
- * @param options - Controller configuration options
36
- * @returns A class decorator compatible with legacy decorator API
37
- *
38
- * @example
39
- * ```typescript
40
- * @Controller({ guards: [AuthGuard] })
41
- * export class UserController {
42
- * @Endpoint(getUserEndpoint)
43
- * async getUser() { }
44
- * }
45
- * ```
46
- */
47
- declare function Controller(options?: ControllerOptions): (target: ClassType) => ClassType;
48
- //#endregion
49
- //#region src/legacy-compat/decorators/endpoint.decorator.d.mts
50
- /**
51
- * Type helper to constrain a PropertyDescriptor's value to match an endpoint signature.
52
- * Note: In legacy decorators, type constraints are checked when the decorator is applied,
53
- * but may not be preserved perfectly when decorators are stacked.
54
- */
55
- type EndpointMethodDescriptor<Config extends EndpointOptions> = TypedPropertyDescriptor<(params: RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>) => Promise<z$1.input<Config['responseSchema']>>>;
56
- /**
57
- * Legacy-compatible Endpoint decorator.
58
- *
59
- * Works with TypeScript experimental decorators (legacy API).
60
- * Provides type safety by ensuring method signatures match the endpoint configuration.
61
- *
62
- * @param endpoint - The endpoint declaration from @navios/builder
63
- * @returns A method decorator compatible with legacy decorator API
64
- *
65
- * @example
66
- * ```typescript
67
- * @Controller()
68
- * export class UserController {
69
- * @Endpoint(getUserEndpoint)
70
- * async getUser(request: EndpointParams<typeof getUserEndpoint>): EndpointResult<typeof getUserEndpoint> {
71
- * return { id: '1', name: 'John' }
72
- * }
73
- * }
74
- * ```
75
- */
76
- declare function Endpoint<const Config extends EndpointOptions>(endpoint: EndpointHandler<Config, false>): (target: any, propertyKey: string | symbol, descriptor: EndpointMethodDescriptor<Config>) => PropertyDescriptor | void;
77
- //#endregion
78
- //#region src/legacy-compat/decorators/use-guards.decorator.d.mts
79
- /**
80
- * Legacy-compatible UseGuards decorator.
81
- *
82
- * Works with TypeScript experimental decorators (legacy API).
83
- * Can be applied to classes or methods.
84
- *
85
- * @param guards - Guard classes or injection tokens to apply
86
- * @returns A class or method decorator compatible with legacy decorator API
87
- *
88
- * @example
89
- * ```typescript
90
- * // Apply to a controller
91
- * @Controller()
92
- * @UseGuards(AuthGuard, RoleGuard)
93
- * export class UserController { }
94
- *
95
- * // Apply to a specific endpoint
96
- * @Controller()
97
- * export class UserController {
98
- * @Endpoint(getUserEndpoint)
99
- * @UseGuards(AuthGuard)
100
- * async getUser() { }
101
- * }
102
- * ```
103
- */
104
- declare function UseGuards(...guards: (ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>)[]): any;
105
- //#endregion
106
- //#region src/legacy-compat/decorators/header.decorator.d.mts
107
- /**
108
- * Legacy-compatible Header decorator.
109
- *
110
- * Works with TypeScript experimental decorators (legacy API).
111
- *
112
- * @param name - The header name (e.g., 'Content-Type', 'Cache-Control')
113
- * @param value - The header value (string, number, or array of strings)
114
- * @returns A method decorator compatible with legacy decorator API
115
- *
116
- * @example
117
- * ```typescript
118
- * @Controller()
119
- * export class UserController {
120
- * @Endpoint(getUserEndpoint)
121
- * @Header('Cache-Control', 'max-age=3600')
122
- * async getUser() {
123
- * return { id: '1', name: 'John' }
124
- * }
125
- * }
126
- * ```
127
- */
128
- declare function Header(name: HttpHeader, value: string | number | string[]): <T extends object>(target: T, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
129
- //#endregion
130
- //#region src/legacy-compat/decorators/http-code.decorator.d.mts
131
- /**
132
- * Legacy-compatible HttpCode decorator.
133
- *
134
- * Works with TypeScript experimental decorators (legacy API).
135
- *
136
- * @param code - The HTTP status code to return (e.g., 201, 204, 202)
137
- * @returns A method decorator compatible with legacy decorator API
138
- *
139
- * @example
140
- * ```typescript
141
- * @Controller()
142
- * export class UserController {
143
- * @Endpoint(createUserEndpoint)
144
- * @HttpCode(201)
145
- * async createUser() {
146
- * return { id: '1', name: 'John' }
147
- * }
148
- * }
149
- * ```
150
- */
151
- declare function HttpCode(code: number): <T extends object>(target: T, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
152
- //#endregion
153
- //#region src/legacy-compat/decorators/multipart.decorator.d.mts
154
- /**
155
- * Type helper to constrain a PropertyDescriptor's value to match a multipart endpoint signature.
156
- * Note: In legacy decorators, type constraints are checked when the decorator is applied,
157
- * but may not be preserved perfectly when decorators are stacked.
6
+ * Each one adapts the legacy decorator signature and calls the same
7
+ * implementation as the standard decorator of the same name, so behaviour is
8
+ * identical.
158
9
  */
159
- type MultipartMethodDescriptor<Config extends EndpointOptions> = TypedPropertyDescriptor<(params: RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>) => Promise<z$1.input<Config['responseSchema']>>>;
10
+ import "../execution-context-BTJdHhbf.cjs";
11
+ import { o as InterceptorClass, r as GuardClass, t as ModuleOptions } from "../module-options-IuDO-p8u.cjs";
12
+ import { ClassType, InferInput, StandardSchemaV1 } from "@navios/di";
13
+ import { Factory, Injectable, createClassContext, createMethodContext } from "@navios/di/legacy-compat";
14
+ import { n as AttributeFactory$1, t as AttributeApplication } from "../attribute-factory-B3VuYnp7.cjs";
15
+ type StandardDecorator = (target: any, context: any) => any;
16
+ /** A decorator that accepts every legacy call shape. */
17
+ type LegacyAnyDecorator = (target: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => any;
160
18
  /**
161
- * Legacy-compatible Multipart decorator.
162
- *
163
- * Works with TypeScript experimental decorators (legacy API).
164
- * Provides type safety by ensuring method signatures match the endpoint configuration.
165
- *
166
- * @param endpoint - The multipart endpoint declaration from @navios/builder
167
- * @returns A method decorator compatible with legacy decorator API
168
- *
169
- * @example
170
- * ```typescript
171
- * @Controller()
172
- * export class FileController {
173
- * @Multipart(uploadFileEndpoint)
174
- * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>): MultipartResult<typeof uploadFileEndpoint> {
175
- * const { file } = request.data
176
- * return { url: 'https://example.com/file.jpg' }
177
- * }
178
- * }
179
- * ```
19
+ * Turns a standard decorator into one that accepts the legacy call shapes:
20
+ * `(constructor)`, `(prototype, key, descriptor)` and `(prototype, key)`.
180
21
  */
181
- declare function Multipart<const Config extends EndpointOptions>(endpoint: EndpointHandler<Config, false>): <T extends object>(target: T, propertyKey: string | symbol, descriptor: MultipartMethodDescriptor<Config>) => PropertyDescriptor | void;
182
- //#endregion
183
- //#region src/legacy-compat/decorators/stream.decorator.d.mts
22
+ export declare function legacy(decorator: StandardDecorator): (target: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => any;
184
23
  /**
185
- * Type helper to constrain a PropertyDescriptor's value to match a stream endpoint signature.
186
- * Supports both with and without reply parameter (Bun doesn't use reply parameter).
187
- * Note: In legacy decorators, type constraints are checked when the decorator is applied,
188
- * but may not be preserved perfectly when decorators are stacked.
24
+ * An attribute application usable as a legacy decorator and in
25
+ * `handler(endpoint, { attributes: [...] }, fn)`.
189
26
  */
190
- type StreamMethodDescriptor<Config extends BaseEndpointOptions> = TypedPropertyDescriptor<(params: RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>, reply: any) => any> | TypedPropertyDescriptor<(params: RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>) => any>;
191
- /**
192
- * Legacy-compatible Stream decorator.
193
- *
194
- * Works with TypeScript experimental decorators (legacy API).
195
- * Provides type safety by ensuring method signatures match the endpoint configuration.
196
- *
197
- * @param endpoint - The stream endpoint declaration from @navios/builder
198
- * @returns A method decorator compatible with legacy decorator API
199
- *
200
- * @example
201
- * ```typescript
202
- * @Controller()
203
- * export class FileController {
204
- * @Stream(downloadFileEndpoint)
205
- * async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {
206
- * const { fileId } = request.urlParams
207
- * // Stream file data to reply
208
- * }
209
- * }
210
- * ```
211
- */
212
- declare function Stream<const Config extends BaseEndpointOptions>(endpoint: StreamHandler<Config, false>): (target: any, propertyKey: string | symbol, descriptor: StreamMethodDescriptor<Config>) => PropertyDescriptor | void;
213
- //#endregion
214
- //#region src/legacy-compat/attribute.factory.d.mts
215
- /**
216
- * Type for a legacy class/method attribute decorator without a value.
217
- *
218
- * Attributes are custom metadata decorators that can be applied to modules,
219
- * controllers, and endpoints.
220
- */
221
- type LegacyClassAttribute = {
222
- (): ClassDecorator & MethodDecorator;
223
- token: symbol;
224
- };
27
+ type LegacyAttributeApplication = LegacyAnyDecorator & Pick<AttributeApplication, 'token' | 'value'>;
28
+ interface LegacyClassAttribute {
29
+ (): LegacyAttributeApplication;
30
+ readonly token: symbol;
31
+ }
32
+ interface LegacyClassSchemaAttribute<Schema extends StandardSchemaV1> {
33
+ (value: InferInput<Schema>): LegacyAttributeApplication;
34
+ readonly token: symbol;
35
+ readonly schema: Schema;
36
+ }
37
+ declare function createAttribute(token: symbol): LegacyClassAttribute;
38
+ declare function createAttribute<Schema extends StandardSchemaV1>(token: symbol, schema: Schema): LegacyClassSchemaAttribute<Schema>;
225
39
  /**
226
- * Type for a legacy class/method attribute decorator with a validated value.
227
- *
228
- * @typeParam S - The Zod schema type for validation
40
+ * `AttributeFactory` whose attributes are legacy decorators. Reading
41
+ * (`get`, `getAll`, `has`) is the same as the standard one.
229
42
  */
230
- type LegacyClassSchemaAttribute<S extends ZodType> = {
231
- (value: z$1.input<S>): ClassDecorator & MethodDecorator;
232
- token: symbol;
233
- schema: ZodType;
43
+ export declare const AttributeFactory: {
44
+ createAttribute: typeof createAttribute;
45
+ get: typeof AttributeFactory$1.get;
46
+ getAll: typeof AttributeFactory$1.getAll;
47
+ has: typeof AttributeFactory$1.has;
234
48
  };
235
- /**
236
- * Legacy-compatible factory for creating custom attribute decorators.
237
- *
238
- * Works with TypeScript experimental decorators (legacy API).
239
- *
240
- * Attributes allow you to add custom metadata to modules, controllers, and endpoints.
241
- * This is useful for cross-cutting concerns like rate limiting, caching, API versioning, etc.
242
- *
243
- * @example
244
- * ```typescript
245
- * // Create a simple boolean attribute
246
- * const Public = LegacyAttributeFactory.createAttribute(Symbol.for('Public'))
247
- *
248
- * // Use it as a decorator
249
- * @Controller()
250
- * @Public()
251
- * export class PublicController { }
252
- *
253
- * // Check if attribute exists
254
- * if (LegacyAttributeFactory.has(Public, controllerMetadata)) {
255
- * // Skip authentication
256
- * }
257
- * ```
258
- *
259
- * @example
260
- * ```typescript
261
- * // Create an attribute with a validated value
262
- * const RateLimit = LegacyAttributeFactory.createAttribute(
263
- * Symbol.for('RateLimit'),
264
- * z.object({ requests: z.number(), window: z.number() })
265
- * )
266
- *
267
- * // Use it with a value
268
- * @Endpoint(apiEndpoint)
269
- * @RateLimit({ requests: 100, window: 60000 })
270
- * async handler() { }
271
- *
272
- * // Get the value
273
- * const limit = LegacyAttributeFactory.get(RateLimit, endpointMetadata)
274
- * // limit is typed as { requests: number, window: number } | null
275
- * ```
276
- */
277
- declare class LegacyAttributeFactory {
278
- /**
279
- * Creates a simple attribute decorator without a value.
280
- *
281
- * @param token - A unique symbol to identify this attribute
282
- * @returns A decorator function that can be applied to classes or methods
283
- *
284
- * @example
285
- * ```typescript
286
- * const Public = LegacyAttributeFactory.createAttribute(Symbol.for('Public'))
287
- *
288
- * @Public()
289
- * @Controller()
290
- * export class PublicController { }
291
- * ```
292
- */
293
- static createAttribute(token: symbol): LegacyClassAttribute;
294
- /**
295
- * Creates an attribute decorator with a validated value.
296
- *
297
- * @param token - A unique symbol to identify this attribute
298
- * @param schema - A Zod schema to validate the attribute value
299
- * @returns A decorator function that accepts a value and can be applied to classes or methods
300
- *
301
- * @example
302
- * ```typescript
303
- * const RateLimit = LegacyAttributeFactory.createAttribute(
304
- * Symbol.for('RateLimit'),
305
- * z.object({ requests: z.number(), window: z.number() })
306
- * )
307
- *
308
- * @RateLimit({ requests: 100, window: 60000 })
309
- * @Endpoint(apiEndpoint)
310
- * async handler() { }
311
- * ```
312
- */
313
- static createAttribute<T extends ZodType>(token: symbol, schema: T): LegacyClassSchemaAttribute<T>;
314
- /**
315
- * Gets the value of an attribute from metadata.
316
- *
317
- * Returns `null` if the attribute is not present.
318
- * For simple attributes (without values), returns `true` if present.
319
- *
320
- * @param attribute - The attribute decorator
321
- * @param target - The metadata object (module, controller, or handler)
322
- * @returns The attribute value, `true` for simple attributes, or `null` if not found
323
- *
324
- * @example
325
- * ```typescript
326
- * const isPublic = LegacyAttributeFactory.get(Public, controllerMetadata)
327
- * // isPublic is true | null
328
- *
329
- * const rateLimit = LegacyAttributeFactory.get(RateLimit, endpointMetadata)
330
- * // rateLimit is { requests: number, window: number } | null
331
- * ```
332
- */
333
- static get(attribute: LegacyClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): true | null;
334
- static get<T extends ZodType>(attribute: LegacyClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): z$1.output<T> | null;
335
- /**
336
- * Gets all values of an attribute from metadata (useful when an attribute can appear multiple times).
337
- *
338
- * Returns `null` if the attribute is not present.
339
- *
340
- * @param attribute - The attribute decorator
341
- * @param target - The metadata object (module, controller, or handler)
342
- * @returns An array of attribute values, or `null` if not found
343
- *
344
- * @example
345
- * ```typescript
346
- * const tags = LegacyAttributeFactory.getAll(Tag, endpointMetadata)
347
- * // tags is string[] | null
348
- * ```
349
- */
350
- static getAll(attribute: LegacyClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<true> | null;
351
- static getAll<T extends ZodType>(attribute: LegacyClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<z$1.output<T>> | null;
352
- /**
353
- * Gets the last value of an attribute from an array of metadata objects.
354
- *
355
- * Searches from the end of the array backwards, useful for finding the most
356
- * specific attribute value (e.g., endpoint-level overrides module-level).
357
- *
358
- * @param attribute - The attribute decorator
359
- * @param target - An array of metadata objects (typically [module, controller, handler])
360
- * @returns The last attribute value found, or `null` if not found
361
- *
362
- * @example
363
- * ```typescript
364
- * // Check attribute hierarchy: endpoint -> controller -> module
365
- * const rateLimit = LegacyAttributeFactory.getLast(RateLimit, [
366
- * moduleMetadata,
367
- * controllerMetadata,
368
- * endpointMetadata
369
- * ])
370
- * ```
371
- */
372
- static getLast(attribute: LegacyClassAttribute, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): true | null;
373
- static getLast<T extends ZodType>(attribute: LegacyClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): z$1.output<T> | null;
374
- /**
375
- * Checks if an attribute is present on the metadata object.
376
- *
377
- * @param attribute - The attribute decorator
378
- * @param target - The metadata object (module, controller, or handler)
379
- * @returns `true` if the attribute is present, `false` otherwise
380
- *
381
- * @example
382
- * ```typescript
383
- * if (LegacyAttributeFactory.has(Public, controllerMetadata)) {
384
- * // Skip authentication
385
- * }
386
- * ```
387
- */
388
- static has(attribute: LegacyClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
389
- static has<T extends ZodType>(attribute: LegacyClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
390
- }
391
- //#endregion
392
- export { LegacyAttributeFactory as AttributeFactory, LegacyAttributeFactory, Controller, type ControllerOptions, Endpoint, type EndpointParams, type EndpointResult, Factory, type FactoryOptions, Header, HttpCode, Injectable, type InjectableOptions, type LegacyClassAttribute, type LegacyClassSchemaAttribute, Module, type ModuleOptions, Multipart, type MultipartParams, type MultipartResult, Stream, type StreamParams, UseGuards, createClassContext, createMethodContext };
49
+ export declare function Module(options?: ModuleOptions): <T extends ClassType>(target: T) => T;
50
+ export declare function UseGuards(...guards: GuardClass[]): LegacyAnyDecorator;
51
+ export declare function UseInterceptors(...interceptors: InterceptorClass[]): LegacyAnyDecorator;
52
+ export { Factory, Injectable, type LegacyAnyDecorator, type LegacyAttributeApplication, type LegacyClassAttribute, type LegacyClassSchemaAttribute, type ModuleOptions, type StandardDecorator, createClassContext, createMethodContext };
393
53
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/legacy-compat/decorators/module.decorator.mts","../../src/legacy-compat/decorators/controller.decorator.mts","../../src/legacy-compat/decorators/endpoint.decorator.mts","../../src/legacy-compat/decorators/use-guards.decorator.mts","../../src/legacy-compat/decorators/header.decorator.mts","../../src/legacy-compat/decorators/http-code.decorator.mts","../../src/legacy-compat/decorators/multipart.decorator.mts","../../src/legacy-compat/decorators/stream.decorator.mts","../../src/legacy-compat/attribute.factory.mts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;AAuBA;;;;;;;;ACCA;;;;;iBDDgB,MAAA,WACL,yBAMgB,cAAS;;;;;;;;AAPpC;;;;;;;;ACCA;;;;AACoC,iBADpB,UAAA,CACoB,OAAA,CAAA,EADA,iBACA,CAAA,EAAA,CAAA,MAAA,EAAT,SAAS,EAAA,GAAA,SAAA;;;;;;;;ADFpC,KERK,wBFQiB,CAAA,eERuB,eFQvB,CAAA,GEPpB,uBFOoB,CAAA,CAAA,MAAA,EELR,WFKQ,CEJd,MFIc,CAAA,KAAA,CAAA,EEHd,MFGc,CAAA,aAAA,CAAA,EEFd,MFEc,CAAA,eAAA,CAAA,EEDd,MFCc,CAAA,iBAAA,CAAA,EAAA,IAAA,CAAA,EAAA,GEEb,OFFa,CEEL,GAAA,CAAE,KFFG,CEEG,MFFH,CAAA,gBAAA,CAAA,CAAA,CAAA,CAAA;;;;;;;;ACCtB;;;;;;;;AClB+B;;;;;AAgBvB,iBA0BQ,QA1BR,CAAA,qBA0BsC,eA1BtC,CAAA,CAAA,QAAA,EA2BI,eA3BJ,CA2BoB,MA3BpB,EAAA,KAAA,CAAA,C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EAsCf,GAAA,CAAE,MAtCa,CAsCN,CAtCM,CAAA,GAAA,IAAA;EAAT;;;;;;;;;;;;;;EAmEI,OAAA,GAAA,CAAA,SAAA,EAAA,oBAAA,EAAA,MAAA,EACH,cADG,GACc,kBADd,GACmC,eADnC,CAAA,GAAA,CAAA,CAAA,EAAA,OAAA;EACH,OAAA,GAAA,CAAA,UAEW,OAFX,CAAA,CAAA,SAAA,EAGG,0BAHH,CAG8B,CAH9B,CAAA,EAAA,MAAA,EAIA,cAJA,GAIiB,kBAJjB,GAIsC,eAJtC,CAAA,GAAA,CAAA,CAAA,EAAA,OAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/legacy-compat/legacy-decorator.mts","../../src/legacy-compat/attribute-factory.mts","../../src/legacy-compat/module.mts","../../src/legacy-compat/use-guards.mts","../../src/legacy-compat/use-interceptors.mts"],"mappings":";;;;;;;;;;;;;;KAIY,qBAAqB,aAAa;;KAGlC,sBACV,aACA,+BACA,aAAa;;;;;wBAOC,OAAO,WAAW,qBAAiB,aAC9B,+BAA+B,aAAe;;;;;KCFvD,6BAA6B,qBACvC,KAAK;UAEU;MACX;WACK;;UAGM,2BAA2B,eAAe;GACxD,OAAO,WAAW,UAAU;WACpB;WACA,QAAQ;;iBAGV,gBAAgB,gBAAgB;iBAChC,gBAAgB,eAAe,kBACtC,eACA,QAAQ,SACP,2BAA2B;;;;;qBAmBjB;;;;;;wBC7CG,OAAO,UAAS,iBACa,UAAU,WAAW,QAAQ,MAAM;wBCDhE,aAAa,QAAQ,eAAe;wBCApC,mBAAmB,cAAc,qBAAqB"}