@navios/core 0.6.0 → 0.7.1

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 (102) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +18 -1
  3. package/docs/README.md +1 -0
  4. package/docs/legacy-compat.md +320 -0
  5. package/docs/testing.md +140 -17
  6. package/lib/index-DW9EPAE6.d.mts +2156 -0
  7. package/lib/index-DW9EPAE6.d.mts.map +1 -0
  8. package/lib/index-pHp-dIGt.d.cts +2156 -0
  9. package/lib/index-pHp-dIGt.d.cts.map +1 -0
  10. package/lib/index.cjs +157 -0
  11. package/lib/index.d.cts +3 -0
  12. package/lib/index.d.mts +3 -190
  13. package/lib/index.mjs +4 -1459
  14. package/lib/legacy-compat/index.cjs +315 -0
  15. package/lib/legacy-compat/index.cjs.map +1 -0
  16. package/lib/legacy-compat/index.d.cts +219 -0
  17. package/lib/legacy-compat/index.d.cts.map +1 -0
  18. package/lib/legacy-compat/index.d.mts +219 -0
  19. package/lib/legacy-compat/index.d.mts.map +1 -0
  20. package/lib/legacy-compat/index.mjs +308 -0
  21. package/lib/legacy-compat/index.mjs.map +1 -0
  22. package/lib/src-DyvCDuKO.mjs +5443 -0
  23. package/lib/src-DyvCDuKO.mjs.map +1 -0
  24. package/lib/src-QnxR5b7c.cjs +5800 -0
  25. package/lib/src-QnxR5b7c.cjs.map +1 -0
  26. package/lib/testing/index.cjs +106 -0
  27. package/lib/testing/index.cjs.map +1 -0
  28. package/lib/testing/index.d.cts +156 -0
  29. package/lib/testing/index.d.cts.map +1 -0
  30. package/lib/testing/index.d.mts +156 -0
  31. package/lib/testing/index.d.mts.map +1 -0
  32. package/lib/testing/index.mjs +100 -0
  33. package/lib/testing/index.mjs.map +1 -0
  34. package/lib/use-guards.decorator-B6q_N0sf.cjs +622 -0
  35. package/lib/use-guards.decorator-B6q_N0sf.cjs.map +1 -0
  36. package/lib/use-guards.decorator-kZ3lNK8v.mjs +454 -0
  37. package/lib/use-guards.decorator-kZ3lNK8v.mjs.map +1 -0
  38. package/package.json +28 -8
  39. package/project.json +2 -2
  40. package/src/attribute.factory.mts +154 -0
  41. package/src/config/config-service.interface.mts +31 -0
  42. package/src/config/config.provider.mts +36 -0
  43. package/src/config/config.service.mts +94 -4
  44. package/src/decorators/controller.decorator.mts +28 -0
  45. package/src/decorators/endpoint.decorator.mts +76 -0
  46. package/src/decorators/header.decorator.mts +19 -0
  47. package/src/decorators/http-code.decorator.mts +20 -0
  48. package/src/decorators/module.decorator.mts +34 -0
  49. package/src/decorators/multipart.decorator.mts +41 -0
  50. package/src/decorators/stream.decorator.mts +33 -0
  51. package/src/decorators/use-guards.decorator.mts +29 -0
  52. package/src/exceptions/bad-request.exception.mts +21 -0
  53. package/src/exceptions/conflict.exception.mts +24 -0
  54. package/src/exceptions/forbidden.exception.mts +23 -0
  55. package/src/exceptions/http.exception.mts +26 -0
  56. package/src/exceptions/internal-server-error.exception.mts +26 -0
  57. package/src/exceptions/not-found.exception.mts +23 -0
  58. package/src/exceptions/unauthorized.exception.mts +23 -0
  59. package/src/index.mts +1 -0
  60. package/src/interfaces/abstract-execution-context.inteface.mts +35 -0
  61. package/src/interfaces/abstract-http-adapter.interface.mts +52 -0
  62. package/src/interfaces/abstract-http-handler-adapter.interface.mts +2 -2
  63. package/src/interfaces/can-activate.mts +31 -0
  64. package/src/interfaces/index.mts +1 -0
  65. package/src/interfaces/navios-module.mts +25 -0
  66. package/src/interfaces/plugin.interface.mts +105 -0
  67. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +420 -0
  68. package/src/legacy-compat/__type-tests__/tsconfig.json +15 -0
  69. package/src/legacy-compat/context-compat.mts +93 -0
  70. package/src/legacy-compat/decorators/controller.decorator.mts +31 -0
  71. package/src/legacy-compat/decorators/endpoint.decorator.mts +99 -0
  72. package/src/legacy-compat/decorators/header.decorator.mts +42 -0
  73. package/src/legacy-compat/decorators/http-code.decorator.mts +38 -0
  74. package/src/legacy-compat/decorators/index.mts +9 -0
  75. package/src/legacy-compat/decorators/module.decorator.mts +37 -0
  76. package/src/legacy-compat/decorators/multipart.decorator.mts +93 -0
  77. package/src/legacy-compat/decorators/stream.decorator.mts +76 -0
  78. package/src/legacy-compat/decorators/use-guards.decorator.mts +80 -0
  79. package/src/legacy-compat/index.mts +40 -0
  80. package/src/logger/console-logger.service.mts +15 -2
  81. package/src/logger/log-levels.mts +9 -0
  82. package/src/logger/logger.service.mts +21 -0
  83. package/src/logger/logger.tokens.mts +23 -0
  84. package/src/navios.application.mts +228 -4
  85. package/src/navios.factory.mts +60 -1
  86. package/src/services/guard-runner.service.mts +12 -11
  87. package/src/services/module-loader.service.mts +118 -12
  88. package/src/stores/index.mts +1 -0
  89. package/src/stores/request-id.store.mts +43 -0
  90. package/src/testing/index.mts +2 -0
  91. package/src/testing/testing-module.mts +231 -0
  92. package/tsconfig.lib.json +1 -1
  93. package/tsconfig.spec.json +3 -0
  94. package/tsdown.config.mts +35 -0
  95. package/vitest.config.mts +6 -0
  96. package/lib/_tsup-dts-rollup.d.mts +0 -1365
  97. package/lib/_tsup-dts-rollup.d.ts +0 -1365
  98. package/lib/index.d.ts +0 -190
  99. package/lib/index.js +0 -1540
  100. package/lib/index.js.map +0 -1
  101. package/lib/index.mjs.map +0 -1
  102. package/tsup.config.mts +0 -13
@@ -0,0 +1,219 @@
1
+ import { $ as CanActivate, B as MultipartResult, H as ModuleOptions, Jt as EndpointParams, L as StreamParams, Yt as EndpointResult, Z as HttpHeader, Zt as ControllerOptions, z as MultipartParams } from "../index-DW9EPAE6.mjs";
2
+ import { ClassType, ClassTypeWithInstance, InjectionToken } from "@navios/di";
3
+ import { ZodObject, ZodType, z as z$1 } from "zod/v4";
4
+ import { BaseEndpointConfig, BaseStreamConfig, EndpointFunctionArgs, HttpMethod } from "@navios/builder";
5
+
6
+ //#region src/legacy-compat/decorators/module.decorator.d.mts
7
+
8
+ /**
9
+ * Legacy-compatible Module decorator.
10
+ *
11
+ * Works with TypeScript experimental decorators (legacy API).
12
+ *
13
+ * @param options - Module configuration options
14
+ * @returns A class decorator compatible with legacy decorator API
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * @Module({
19
+ * controllers: [UserController, AuthController],
20
+ * imports: [DatabaseModule],
21
+ * guards: [AuthGuard],
22
+ * })
23
+ * export class AppModule {}
24
+ * ```
25
+ */
26
+ declare function Module(options?: ModuleOptions): (target: ClassType) => ClassType;
27
+ //#endregion
28
+ //#region src/legacy-compat/decorators/controller.decorator.d.mts
29
+ /**
30
+ * Legacy-compatible Controller decorator.
31
+ *
32
+ * Works with TypeScript experimental decorators (legacy API).
33
+ *
34
+ * @param options - Controller configuration options
35
+ * @returns A class decorator compatible with legacy decorator API
36
+ *
37
+ * @example
38
+ * ```typescript
39
+ * @Controller({ guards: [AuthGuard] })
40
+ * export class UserController {
41
+ * @Endpoint(getUserEndpoint)
42
+ * async getUser() { }
43
+ * }
44
+ * ```
45
+ */
46
+ declare function Controller(options?: ControllerOptions): (target: ClassType) => ClassType;
47
+ //#endregion
48
+ //#region src/legacy-compat/decorators/endpoint.decorator.d.mts
49
+ /**
50
+ * Type helper to constrain a PropertyDescriptor's value to match an endpoint signature.
51
+ * Note: In legacy decorators, type constraints are checked when the decorator is applied,
52
+ * but may not be preserved perfectly when decorators are stacked.
53
+ */
54
+ type EndpointMethodDescriptor<Url extends string, QuerySchema, RequestSchema, ResponseSchema extends ZodType> = TypedPropertyDescriptor<(params: QuerySchema extends ZodType ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true> : EndpointFunctionArgs<Url, QuerySchema, undefined, true> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema, true> : EndpointFunctionArgs<Url, undefined, undefined, true>) => Promise<z$1.input<ResponseSchema>>>;
55
+ /**
56
+ * Legacy-compatible Endpoint decorator.
57
+ *
58
+ * Works with TypeScript experimental decorators (legacy API).
59
+ * Provides type safety by ensuring method signatures match the endpoint configuration.
60
+ *
61
+ * @param endpoint - The endpoint declaration from @navios/builder
62
+ * @returns A method decorator compatible with legacy decorator API
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * @Controller()
67
+ * export class UserController {
68
+ * @Endpoint(getUserEndpoint)
69
+ * async getUser(request: EndpointParams<typeof getUserEndpoint>): EndpointResult<typeof getUserEndpoint> {
70
+ * return { id: '1', name: 'John' }
71
+ * }
72
+ * }
73
+ * ```
74
+ */
75
+ declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
76
+ config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
77
+ }): (target: any, propertyKey: string | symbol, descriptor: EndpointMethodDescriptor<Url, QuerySchema, RequestSchema, ResponseSchema>) => PropertyDescriptor | void;
78
+ //#endregion
79
+ //#region src/legacy-compat/decorators/use-guards.decorator.d.mts
80
+ /**
81
+ * Legacy-compatible UseGuards decorator.
82
+ *
83
+ * Works with TypeScript experimental decorators (legacy API).
84
+ * Can be applied to classes or methods.
85
+ *
86
+ * @param guards - Guard classes or injection tokens to apply
87
+ * @returns A class or method decorator compatible with legacy decorator API
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * // Apply to a controller
92
+ * @Controller()
93
+ * @UseGuards(AuthGuard, RoleGuard)
94
+ * export class UserController { }
95
+ *
96
+ * // Apply to a specific endpoint
97
+ * @Controller()
98
+ * export class UserController {
99
+ * @Endpoint(getUserEndpoint)
100
+ * @UseGuards(AuthGuard)
101
+ * async getUser() { }
102
+ * }
103
+ * ```
104
+ */
105
+ declare function UseGuards(...guards: (ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>)[]): any;
106
+ //#endregion
107
+ //#region src/legacy-compat/decorators/header.decorator.d.mts
108
+ /**
109
+ * Legacy-compatible Header decorator.
110
+ *
111
+ * Works with TypeScript experimental decorators (legacy API).
112
+ *
113
+ * @param name - The header name (e.g., 'Content-Type', 'Cache-Control')
114
+ * @param value - The header value (string, number, or array of strings)
115
+ * @returns A method decorator compatible with legacy decorator API
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * @Controller()
120
+ * export class UserController {
121
+ * @Endpoint(getUserEndpoint)
122
+ * @Header('Cache-Control', 'max-age=3600')
123
+ * async getUser() {
124
+ * return { id: '1', name: 'John' }
125
+ * }
126
+ * }
127
+ * ```
128
+ */
129
+ declare function Header(name: HttpHeader, value: string | number | string[]): <T extends object>(target: T, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
130
+ //#endregion
131
+ //#region src/legacy-compat/decorators/http-code.decorator.d.mts
132
+ /**
133
+ * Legacy-compatible HttpCode decorator.
134
+ *
135
+ * Works with TypeScript experimental decorators (legacy API).
136
+ *
137
+ * @param code - The HTTP status code to return (e.g., 201, 204, 202)
138
+ * @returns A method decorator compatible with legacy decorator API
139
+ *
140
+ * @example
141
+ * ```typescript
142
+ * @Controller()
143
+ * export class UserController {
144
+ * @Endpoint(createUserEndpoint)
145
+ * @HttpCode(201)
146
+ * async createUser() {
147
+ * return { id: '1', name: 'John' }
148
+ * }
149
+ * }
150
+ * ```
151
+ */
152
+ declare function HttpCode(code: number): <T extends object>(target: T, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
153
+ //#endregion
154
+ //#region src/legacy-compat/decorators/multipart.decorator.d.mts
155
+ /**
156
+ * Type helper to constrain a PropertyDescriptor's value to match a multipart endpoint signature.
157
+ * Note: In legacy decorators, type constraints are checked when the decorator is applied,
158
+ * but may not be preserved perfectly when decorators are stacked.
159
+ */
160
+ type MultipartMethodDescriptor<Url extends string, QuerySchema, RequestSchema, ResponseSchema extends ZodType> = TypedPropertyDescriptor<(params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => Promise<z$1.input<ResponseSchema>>>;
161
+ /**
162
+ * Legacy-compatible Multipart decorator.
163
+ *
164
+ * Works with TypeScript experimental decorators (legacy API).
165
+ * Provides type safety by ensuring method signatures match the endpoint configuration.
166
+ *
167
+ * @param endpoint - The multipart endpoint declaration from @navios/builder
168
+ * @returns A method decorator compatible with legacy decorator API
169
+ *
170
+ * @example
171
+ * ```typescript
172
+ * @Controller()
173
+ * export class FileController {
174
+ * @Multipart(uploadFileEndpoint)
175
+ * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>): MultipartResult<typeof uploadFileEndpoint> {
176
+ * const { file } = request.data
177
+ * return { url: 'https://example.com/file.jpg' }
178
+ * }
179
+ * }
180
+ * ```
181
+ */
182
+ declare function Multipart<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
183
+ config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
184
+ }): <T extends object>(target: T, propertyKey: string | symbol, descriptor: MultipartMethodDescriptor<Url, QuerySchema, RequestSchema, ResponseSchema>) => PropertyDescriptor | void;
185
+ //#endregion
186
+ //#region src/legacy-compat/decorators/stream.decorator.d.mts
187
+ /**
188
+ * Type helper to constrain a PropertyDescriptor's value to match a stream endpoint signature.
189
+ * Note: In legacy decorators, type constraints are checked when the decorator is applied,
190
+ * but may not be preserved perfectly when decorators are stacked.
191
+ */
192
+ type StreamMethodDescriptor<Url extends string, QuerySchema, RequestSchema> = TypedPropertyDescriptor<(params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>, reply: any) => Promise<void>>;
193
+ /**
194
+ * Legacy-compatible Stream decorator.
195
+ *
196
+ * Works with TypeScript experimental decorators (legacy API).
197
+ * Provides type safety by ensuring method signatures match the endpoint configuration.
198
+ *
199
+ * @param endpoint - The stream endpoint declaration from @navios/builder
200
+ * @returns A method decorator compatible with legacy decorator API
201
+ *
202
+ * @example
203
+ * ```typescript
204
+ * @Controller()
205
+ * export class FileController {
206
+ * @Stream(downloadFileEndpoint)
207
+ * async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {
208
+ * const { fileId } = request.urlParams
209
+ * // Stream file data to reply
210
+ * }
211
+ * }
212
+ * ```
213
+ */
214
+ declare function Stream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType>(endpoint: {
215
+ config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>;
216
+ }): <T extends object>(target: T, propertyKey: string | symbol, descriptor: StreamMethodDescriptor<Url, QuerySchema, RequestSchema>) => StreamMethodDescriptor<Url, QuerySchema, RequestSchema>;
217
+ //#endregion
218
+ export { Controller, type ControllerOptions, Endpoint, type EndpointParams, type EndpointResult, Header, HttpCode, Module, type ModuleOptions, Multipart, type MultipartParams, type MultipartResult, Stream, type StreamParams, UseGuards };
219
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","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"],"sourcesContent":[],"mappings":";;;;;;;;;;;AAuBA;;;;;;;;ACCA;;;;;;iBDDgB,MAAA,WACL,yBAMgB,cAAS;;;;;;;AAPpC;;;;;;;;ACCA;;;;;iBAAgB,UAAA,WAAoB,6B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BLxCN,CKwC6B,GLxC7B,EKwCkC,WLxClC,EKwC+C,aLxC/C,CAAA,EAAA,GKwC6D,sBLxC7D,CKwC6D,GLxC7D,EKwC6D,WLxC7D,EKwC6D,aLxC7D,CAAA"}
@@ -0,0 +1,308 @@
1
+ import { _ as Controller$1, a as HttpCode$1, i as Module$1, n as Stream$1, o as Header$1, r as Multipart$1, s as Endpoint$1, t as UseGuards$1 } from "../use-guards.decorator-kZ3lNK8v.mjs";
2
+
3
+ //#region src/legacy-compat/context-compat.mts
4
+ /**
5
+ * Compatibility layer for converting legacy decorator signatures to Stage 3 format.
6
+ *
7
+ * This module provides utilities to create mock Stage 3 decorator contexts
8
+ * from legacy decorator arguments, and manages metadata storage using WeakMap.
9
+ */ const classMetadataMap = /* @__PURE__ */ new WeakMap();
10
+ /**
11
+ * Gets the constructor from a prototype (for method decorators).
12
+ */ function getConstructor(prototype) {
13
+ if (!prototype || typeof prototype !== "object") return null;
14
+ const constructor = prototype.constructor;
15
+ if (constructor && typeof constructor === "function") return constructor;
16
+ return null;
17
+ }
18
+ /**
19
+ * Creates a mock ClassDecoratorContext for legacy class decorators.
20
+ */ function createClassContext(target) {
21
+ if (!classMetadataMap.has(target)) classMetadataMap.set(target, {});
22
+ const metadata = classMetadataMap.get(target);
23
+ return {
24
+ kind: "class",
25
+ name: target.name,
26
+ metadata,
27
+ addInitializer() {}
28
+ };
29
+ }
30
+ /**
31
+ * Creates a mock ClassMethodDecoratorContext for legacy method decorators.
32
+ *
33
+ * Note: Method decorators need to share metadata with the class context
34
+ * because endpoint metadata is stored at the class level.
35
+ */ function createMethodContext(target, propertyKey, descriptor) {
36
+ const constructor = getConstructor(target);
37
+ if (!constructor) throw new Error("[Navios] Could not determine class constructor from method decorator target.");
38
+ if (!classMetadataMap.has(constructor)) classMetadataMap.set(constructor, {});
39
+ return {
40
+ kind: "method",
41
+ name: propertyKey,
42
+ metadata: classMetadataMap.get(constructor),
43
+ static: false,
44
+ private: false,
45
+ access: {
46
+ has: () => true,
47
+ get: () => descriptor.value,
48
+ set: () => {}
49
+ },
50
+ addInitializer() {}
51
+ };
52
+ }
53
+
54
+ //#endregion
55
+ //#region src/legacy-compat/decorators/module.decorator.mts
56
+ /**
57
+ * Legacy-compatible Module decorator.
58
+ *
59
+ * Works with TypeScript experimental decorators (legacy API).
60
+ *
61
+ * @param options - Module configuration options
62
+ * @returns A class decorator compatible with legacy decorator API
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * @Module({
67
+ * controllers: [UserController, AuthController],
68
+ * imports: [DatabaseModule],
69
+ * guards: [AuthGuard],
70
+ * })
71
+ * export class AppModule {}
72
+ * ```
73
+ */ function Module(options = {
74
+ controllers: [],
75
+ imports: [],
76
+ guards: []
77
+ }) {
78
+ return function(target) {
79
+ const context = createClassContext(target);
80
+ return Module$1(options)(target, context);
81
+ };
82
+ }
83
+
84
+ //#endregion
85
+ //#region src/legacy-compat/decorators/controller.decorator.mts
86
+ /**
87
+ * Legacy-compatible Controller decorator.
88
+ *
89
+ * Works with TypeScript experimental decorators (legacy API).
90
+ *
91
+ * @param options - Controller configuration options
92
+ * @returns A class decorator compatible with legacy decorator API
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * @Controller({ guards: [AuthGuard] })
97
+ * export class UserController {
98
+ * @Endpoint(getUserEndpoint)
99
+ * async getUser() { }
100
+ * }
101
+ * ```
102
+ */ function Controller(options = {}) {
103
+ return function(target) {
104
+ const context = createClassContext(target);
105
+ return Controller$1(options)(target, context);
106
+ };
107
+ }
108
+
109
+ //#endregion
110
+ //#region src/legacy-compat/decorators/endpoint.decorator.mts
111
+ /**
112
+ * Legacy-compatible Endpoint decorator.
113
+ *
114
+ * Works with TypeScript experimental decorators (legacy API).
115
+ * Provides type safety by ensuring method signatures match the endpoint configuration.
116
+ *
117
+ * @param endpoint - The endpoint declaration from @navios/builder
118
+ * @returns A method decorator compatible with legacy decorator API
119
+ *
120
+ * @example
121
+ * ```typescript
122
+ * @Controller()
123
+ * export class UserController {
124
+ * @Endpoint(getUserEndpoint)
125
+ * async getUser(request: EndpointParams<typeof getUserEndpoint>): EndpointResult<typeof getUserEndpoint> {
126
+ * return { id: '1', name: 'John' }
127
+ * }
128
+ * }
129
+ * ```
130
+ */ function Endpoint(endpoint) {
131
+ return function(target, propertyKey, descriptor) {
132
+ if (!descriptor) throw new Error("[Navios] @Endpoint decorator requires a method descriptor. Make sure experimentalDecorators is enabled.");
133
+ const typedDescriptor = descriptor;
134
+ const context = createMethodContext(target, propertyKey, typedDescriptor);
135
+ const result = Endpoint$1(endpoint)(typedDescriptor.value, context);
136
+ if (result !== typedDescriptor.value) typedDescriptor.value = result;
137
+ return typedDescriptor;
138
+ };
139
+ }
140
+
141
+ //#endregion
142
+ //#region src/legacy-compat/decorators/use-guards.decorator.mts
143
+ /**
144
+ * Legacy-compatible UseGuards decorator.
145
+ *
146
+ * Works with TypeScript experimental decorators (legacy API).
147
+ * Can be applied to classes or methods.
148
+ *
149
+ * @param guards - Guard classes or injection tokens to apply
150
+ * @returns A class or method decorator compatible with legacy decorator API
151
+ *
152
+ * @example
153
+ * ```typescript
154
+ * // Apply to a controller
155
+ * @Controller()
156
+ * @UseGuards(AuthGuard, RoleGuard)
157
+ * export class UserController { }
158
+ *
159
+ * // Apply to a specific endpoint
160
+ * @Controller()
161
+ * export class UserController {
162
+ * @Endpoint(getUserEndpoint)
163
+ * @UseGuards(AuthGuard)
164
+ * async getUser() { }
165
+ * }
166
+ * ```
167
+ */ function UseGuards(...guards) {
168
+ function decoratorImpl(target, propertyKey, descriptor) {
169
+ if (propertyKey !== void 0 && descriptor !== void 0) {
170
+ const context = createMethodContext(target, propertyKey, descriptor);
171
+ const result = UseGuards$1(...guards)(descriptor.value, context);
172
+ if (result !== descriptor.value) descriptor.value = result;
173
+ return descriptor;
174
+ } else {
175
+ const context = createClassContext(target);
176
+ return UseGuards$1(...guards)(target, context);
177
+ }
178
+ }
179
+ return decoratorImpl;
180
+ }
181
+
182
+ //#endregion
183
+ //#region src/legacy-compat/decorators/header.decorator.mts
184
+ /**
185
+ * Legacy-compatible Header decorator.
186
+ *
187
+ * Works with TypeScript experimental decorators (legacy API).
188
+ *
189
+ * @param name - The header name (e.g., 'Content-Type', 'Cache-Control')
190
+ * @param value - The header value (string, number, or array of strings)
191
+ * @returns A method decorator compatible with legacy decorator API
192
+ *
193
+ * @example
194
+ * ```typescript
195
+ * @Controller()
196
+ * export class UserController {
197
+ * @Endpoint(getUserEndpoint)
198
+ * @Header('Cache-Control', 'max-age=3600')
199
+ * async getUser() {
200
+ * return { id: '1', name: 'John' }
201
+ * }
202
+ * }
203
+ * ```
204
+ */ function Header(name, value) {
205
+ return function(target, propertyKey, descriptor) {
206
+ const context = createMethodContext(target, propertyKey, descriptor);
207
+ const result = Header$1(name, value)(descriptor.value, context);
208
+ if (result !== descriptor.value) descriptor.value = result;
209
+ return descriptor;
210
+ };
211
+ }
212
+
213
+ //#endregion
214
+ //#region src/legacy-compat/decorators/http-code.decorator.mts
215
+ /**
216
+ * Legacy-compatible HttpCode decorator.
217
+ *
218
+ * Works with TypeScript experimental decorators (legacy API).
219
+ *
220
+ * @param code - The HTTP status code to return (e.g., 201, 204, 202)
221
+ * @returns A method decorator compatible with legacy decorator API
222
+ *
223
+ * @example
224
+ * ```typescript
225
+ * @Controller()
226
+ * export class UserController {
227
+ * @Endpoint(createUserEndpoint)
228
+ * @HttpCode(201)
229
+ * async createUser() {
230
+ * return { id: '1', name: 'John' }
231
+ * }
232
+ * }
233
+ * ```
234
+ */ function HttpCode(code) {
235
+ return function(target, propertyKey, descriptor) {
236
+ const context = createMethodContext(target, propertyKey, descriptor);
237
+ const result = HttpCode$1(code)(descriptor.value, context);
238
+ if (result !== descriptor.value) descriptor.value = result;
239
+ return descriptor;
240
+ };
241
+ }
242
+
243
+ //#endregion
244
+ //#region src/legacy-compat/decorators/multipart.decorator.mts
245
+ /**
246
+ * Legacy-compatible Multipart decorator.
247
+ *
248
+ * Works with TypeScript experimental decorators (legacy API).
249
+ * Provides type safety by ensuring method signatures match the endpoint configuration.
250
+ *
251
+ * @param endpoint - The multipart endpoint declaration from @navios/builder
252
+ * @returns A method decorator compatible with legacy decorator API
253
+ *
254
+ * @example
255
+ * ```typescript
256
+ * @Controller()
257
+ * export class FileController {
258
+ * @Multipart(uploadFileEndpoint)
259
+ * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>): MultipartResult<typeof uploadFileEndpoint> {
260
+ * const { file } = request.data
261
+ * return { url: 'https://example.com/file.jpg' }
262
+ * }
263
+ * }
264
+ * ```
265
+ */ function Multipart(endpoint) {
266
+ return function(target, propertyKey, descriptor) {
267
+ if (!descriptor) throw new Error("[Navios] @Multipart decorator requires a method descriptor. Make sure experimentalDecorators is enabled.");
268
+ const context = createMethodContext(target, propertyKey, descriptor);
269
+ const result = Multipart$1(endpoint)(descriptor.value, context);
270
+ if (result !== descriptor.value) descriptor.value = result;
271
+ return descriptor;
272
+ };
273
+ }
274
+
275
+ //#endregion
276
+ //#region src/legacy-compat/decorators/stream.decorator.mts
277
+ /**
278
+ * Legacy-compatible Stream decorator.
279
+ *
280
+ * Works with TypeScript experimental decorators (legacy API).
281
+ * Provides type safety by ensuring method signatures match the endpoint configuration.
282
+ *
283
+ * @param endpoint - The stream endpoint declaration from @navios/builder
284
+ * @returns A method decorator compatible with legacy decorator API
285
+ *
286
+ * @example
287
+ * ```typescript
288
+ * @Controller()
289
+ * export class FileController {
290
+ * @Stream(downloadFileEndpoint)
291
+ * async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {
292
+ * const { fileId } = request.urlParams
293
+ * // Stream file data to reply
294
+ * }
295
+ * }
296
+ * ```
297
+ */ function Stream(endpoint) {
298
+ return function(target, propertyKey, descriptor) {
299
+ const context = createMethodContext(target, propertyKey, descriptor);
300
+ const result = Stream$1(endpoint)(descriptor.value, context);
301
+ if (result !== descriptor.value) descriptor.value = result;
302
+ return descriptor;
303
+ };
304
+ }
305
+
306
+ //#endregion
307
+ export { Controller, Endpoint, Header, HttpCode, Module, Multipart, Stream, UseGuards };
308
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["classMetadataMap","WeakMap","getConstructor","prototype","constructor","createClassContext","target","has","set","metadata","get","kind","name","addInitializer","createMethodContext","propertyKey","descriptor","Error","static","private","access","value","Module","OriginalModule","createClassContext","options","controllers","imports","guards","target","context","originalDecorator","Controller","OriginalController","createClassContext","options","target","context","originalDecorator","Endpoint","OriginalEndpoint","createMethodContext","endpoint","target","propertyKey","descriptor","Error","typedDescriptor","context","originalDecorator","result","value","UseGuards","OriginalUseGuards","createClassContext","createMethodContext","guards","decoratorImpl","target","propertyKey","descriptor","undefined","context","originalDecorator","result","value","Header","OriginalHeader","createMethodContext","name","value","target","propertyKey","descriptor","context","originalDecorator","result","HttpCode","OriginalHttpCode","createMethodContext","code","target","propertyKey","descriptor","context","originalDecorator","result","value","Multipart","OriginalMultipart","createMethodContext","endpoint","target","propertyKey","descriptor","Error","context","originalDecorator","result","value","Stream","OriginalStream","createMethodContext","endpoint","target","propertyKey","descriptor","context","originalDecorator","result","value"],"sources":["../../src/legacy-compat/context-compat.mts","../../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"],"sourcesContent":["/**\n * Compatibility layer for converting legacy decorator signatures to Stage 3 format.\n *\n * This module provides utilities to create mock Stage 3 decorator contexts\n * from legacy decorator arguments, and manages metadata storage using WeakMap.\n */\n\nimport type { ClassType } from '@navios/di'\n\n// WeakMap to store metadata for legacy decorators\n// Keyed by class constructor for class decorators\n// For method decorators, we use the class constructor (extracted from the prototype)\nconst classMetadataMap = new WeakMap<ClassType, Record<string | symbol, any>>()\n\n/**\n * Gets the constructor from a prototype (for method decorators).\n */\nfunction getConstructor(prototype: any): ClassType | null {\n if (!prototype || typeof prototype !== 'object') {\n return null\n }\n // In legacy decorators, target is the prototype\n // The constructor is typically available via prototype.constructor\n const constructor = prototype.constructor\n if (constructor && typeof constructor === 'function') {\n return constructor as ClassType\n }\n return null\n}\n\n/**\n * Creates a mock ClassDecoratorContext for legacy class decorators.\n */\nexport function createClassContext(target: ClassType): ClassDecoratorContext {\n // Get or create metadata storage for this class\n if (!classMetadataMap.has(target)) {\n classMetadataMap.set(target, {})\n }\n const metadata = classMetadataMap.get(target)!\n\n return {\n kind: 'class',\n name: target.name,\n metadata,\n addInitializer() {\n // Legacy decorators don't support initializers\n },\n } as ClassDecoratorContext\n}\n\n/**\n * Creates a mock ClassMethodDecoratorContext for legacy method decorators.\n *\n * Note: Method decorators need to share metadata with the class context\n * because endpoint metadata is stored at the class level.\n */\nexport function createMethodContext(\n target: any,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor,\n): ClassMethodDecoratorContext {\n // For method decorators, target is the prototype\n // We need to get the class constructor to access class-level metadata\n const constructor = getConstructor(target)\n if (!constructor) {\n throw new Error(\n '[Navios] Could not determine class constructor from method decorator target.',\n )\n }\n\n // Get or create metadata storage for the class\n // Method decorators share metadata with the class\n if (!classMetadataMap.has(constructor)) {\n classMetadataMap.set(constructor, {})\n }\n const metadata = classMetadataMap.get(constructor)!\n\n return {\n kind: 'method',\n name: propertyKey,\n metadata,\n static: false, // We can't determine this from legacy decorators\n private: false, // We can't determine this from legacy decorators\n access: {\n has: () => true,\n get: () => descriptor.value,\n set: () => {},\n },\n addInitializer() {\n // Legacy decorators don't support initializers\n },\n } as ClassMethodDecoratorContext\n}\n","import type { ClassType } from '@navios/di'\n\nimport { Module as OriginalModule, type ModuleOptions } from '../../decorators/module.decorator.mjs'\nimport { createClassContext } from '../context-compat.mjs'\n\n/**\n * Legacy-compatible Module decorator.\n * \n * Works with TypeScript experimental decorators (legacy API).\n * \n * @param options - Module configuration options\n * @returns A class decorator compatible with legacy decorator API\n * \n * @example\n * ```typescript\n * @Module({\n * controllers: [UserController, AuthController],\n * imports: [DatabaseModule],\n * guards: [AuthGuard],\n * })\n * export class AppModule {}\n * ```\n */\nexport function Module(\n options: ModuleOptions = {\n controllers: [],\n imports: [],\n guards: [],\n },\n) {\n return function (target: ClassType) {\n const context = createClassContext(target)\n const originalDecorator = OriginalModule(options)\n return originalDecorator(target, context)\n }\n}\n\n","import type { ClassType } from '@navios/di'\n\nimport type { ControllerOptions } from '../../decorators/controller.decorator.mjs'\n\nimport { Controller as OriginalController } from '../../decorators/controller.decorator.mjs'\nimport { createClassContext } from '../context-compat.mjs'\n\n/**\n * Legacy-compatible Controller decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - Controller configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * @Controller({ guards: [AuthGuard] })\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * async getUser() { }\n * }\n * ```\n */\nexport function Controller(options: ControllerOptions = {}) {\n return function (target: ClassType) {\n const context = createClassContext(target)\n const originalDecorator = OriginalController(options)\n return originalDecorator(target, context)\n }\n}\n","import type {\n BaseEndpointConfig,\n EndpointFunctionArgs,\n HttpMethod,\n} from '@navios/builder'\nimport type { z, ZodType } from 'zod/v4'\n\nimport { Endpoint as OriginalEndpoint } from '../../decorators/endpoint.decorator.mjs'\nimport { createMethodContext } from '../context-compat.mjs'\n\n/**\n * Type helper to constrain a PropertyDescriptor's value to match an endpoint signature.\n * Note: In legacy decorators, type constraints are checked when the decorator is applied,\n * but may not be preserved perfectly when decorators are stacked.\n */\ntype EndpointMethodDescriptor<\n Url extends string,\n QuerySchema,\n RequestSchema,\n ResponseSchema extends ZodType,\n> = TypedPropertyDescriptor<\n (\n params: QuerySchema extends ZodType\n ? RequestSchema extends ZodType\n ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true>\n : EndpointFunctionArgs<Url, QuerySchema, undefined, true>\n : RequestSchema extends ZodType\n ? EndpointFunctionArgs<Url, undefined, RequestSchema, true>\n : EndpointFunctionArgs<Url, undefined, undefined, true>,\n ) => Promise<z.input<ResponseSchema>>\n>\n\n/**\n * Legacy-compatible Endpoint decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n * Provides type safety by ensuring method signatures match the endpoint configuration.\n *\n * @param endpoint - The endpoint declaration from @navios/builder\n * @returns A method decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * @Controller()\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>): EndpointResult<typeof getUserEndpoint> {\n * return { id: '1', name: 'John' }\n * }\n * }\n * ```\n */\nexport function Endpoint<\n Method extends HttpMethod = HttpMethod,\n Url extends string = string,\n QuerySchema = undefined,\n ResponseSchema extends ZodType = ZodType,\n RequestSchema = ZodType,\n>(endpoint: {\n config: BaseEndpointConfig<\n Method,\n Url,\n QuerySchema,\n ResponseSchema,\n RequestSchema\n >\n}) {\n return function (\n target: any,\n propertyKey: string | symbol,\n descriptor: EndpointMethodDescriptor<\n Url,\n QuerySchema,\n RequestSchema,\n ResponseSchema\n >,\n ): PropertyDescriptor | void {\n if (!descriptor) {\n throw new Error(\n '[Navios] @Endpoint decorator requires a method descriptor. Make sure experimentalDecorators is enabled.',\n )\n }\n // Type check the descriptor value matches expected signature\n const typedDescriptor = descriptor as EndpointMethodDescriptor<\n Url,\n QuerySchema,\n RequestSchema,\n ResponseSchema\n >\n const context = createMethodContext(target, propertyKey, typedDescriptor)\n const originalDecorator = OriginalEndpoint(endpoint)\n // @ts-expect-error - we don't need to type the value\n const result = originalDecorator(typedDescriptor.value, context)\n if (result !== typedDescriptor.value) {\n typedDescriptor.value = result\n }\n return typedDescriptor\n }\n}\n","import type {\n ClassType,\n ClassTypeWithInstance,\n InjectionToken,\n} from '@navios/di'\n\nimport type { CanActivate } from '../../interfaces/index.mjs'\n\nimport { UseGuards as OriginalUseGuards } from '../../decorators/use-guards.decorator.mjs'\nimport { createClassContext, createMethodContext } from '../context-compat.mjs'\n\n/**\n * Legacy-compatible UseGuards decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n * Can be applied to classes or methods.\n *\n * @param guards - Guard classes or injection tokens to apply\n * @returns A class or method decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * // Apply to a controller\n * @Controller()\n * @UseGuards(AuthGuard, RoleGuard)\n * export class UserController { }\n *\n * // Apply to a specific endpoint\n * @Controller()\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * @UseGuards(AuthGuard)\n * async getUser() { }\n * }\n * ```\n */\nexport function UseGuards(\n ...guards: (\n | ClassTypeWithInstance<CanActivate>\n | InjectionToken<CanActivate, undefined>\n )[]\n) {\n // Create the decorator function\n // Note: TypeScript's legacy decorator system has strict type checking for decorators\n // We use a flexible implementation that works for both class and method decorators\n function decoratorImpl(\n target: ClassType | Function,\n propertyKey?: string | symbol,\n descriptor?: PropertyDescriptor,\n ): any {\n // Determine if this is a class or method decorator\n if (propertyKey !== undefined && descriptor !== undefined) {\n // Method decorator\n const context = createMethodContext(\n target as Function,\n propertyKey,\n descriptor,\n )\n const originalDecorator = OriginalUseGuards(...guards)\n const result = originalDecorator(descriptor.value, context)\n if (result !== descriptor.value) {\n descriptor.value = result\n }\n return descriptor\n } else {\n // Class decorator\n const context = createClassContext(target as ClassType)\n const originalDecorator = OriginalUseGuards(...guards)\n return originalDecorator(target as ClassType, context)\n }\n }\n\n // Return with 'any' type to work around TypeScript's strict decorator checking\n // TypeScript's legacy decorator system cannot properly type-check decorators\n // that work as both class and method decorators. The runtime behavior is correct.\n // When used as a class decorator, it returns the class (preserving type at runtime)\n // When used as a method decorator, it returns the PropertyDescriptor\n // @ts-ignore - TypeScript limitation with dual-purpose legacy decorators\n return decoratorImpl as any\n}\n","import type { HttpHeader } from '../../interfaces/index.mjs'\n\nimport { Header as OriginalHeader } from '../../decorators/header.decorator.mjs'\nimport { createMethodContext } from '../context-compat.mjs'\n\n/**\n * Legacy-compatible Header decorator.\n * \n * Works with TypeScript experimental decorators (legacy API).\n * \n * @param name - The header name (e.g., 'Content-Type', 'Cache-Control')\n * @param value - The header value (string, number, or array of strings)\n * @returns A method decorator compatible with legacy decorator API\n * \n * @example\n * ```typescript\n * @Controller()\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * @Header('Cache-Control', 'max-age=3600')\n * async getUser() {\n * return { id: '1', name: 'John' }\n * }\n * }\n * ```\n */\nexport function Header(name: HttpHeader, value: string | number | string[]) {\n return function <T extends object>(\n target: T,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor,\n ) {\n const context = createMethodContext(target, propertyKey, descriptor)\n const originalDecorator = OriginalHeader(name, value)\n const result = originalDecorator(descriptor.value, context)\n if (result !== descriptor.value) {\n descriptor.value = result\n }\n return descriptor\n }\n}\n\n","import { HttpCode as OriginalHttpCode } from '../../decorators/http-code.decorator.mjs'\nimport { createMethodContext } from '../context-compat.mjs'\n\n/**\n * Legacy-compatible HttpCode decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param code - The HTTP status code to return (e.g., 201, 204, 202)\n * @returns A method decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * @Controller()\n * export class UserController {\n * @Endpoint(createUserEndpoint)\n * @HttpCode(201)\n * async createUser() {\n * return { id: '1', name: 'John' }\n * }\n * }\n * ```\n */\nexport function HttpCode(code: number) {\n return function <T extends object>(\n target: T,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor,\n ) {\n const context = createMethodContext(target, propertyKey, descriptor)\n const originalDecorator = OriginalHttpCode(code)\n const result = originalDecorator(descriptor.value, context)\n if (result !== descriptor.value) {\n descriptor.value = result\n }\n return descriptor\n }\n}\n","import type {\n BaseEndpointConfig,\n EndpointFunctionArgs,\n HttpMethod,\n} from '@navios/builder'\nimport type { z, ZodObject, ZodType } from 'zod/v4'\n\nimport { Multipart as OriginalMultipart } from '../../decorators/multipart.decorator.mjs'\nimport { createMethodContext } from '../context-compat.mjs'\n\n/**\n * Type helper to constrain a PropertyDescriptor's value to match a multipart endpoint signature.\n * Note: In legacy decorators, type constraints are checked when the decorator is applied,\n * but may not be preserved perfectly when decorators are stacked.\n */\ntype MultipartMethodDescriptor<\n Url extends string,\n QuerySchema,\n RequestSchema,\n ResponseSchema extends ZodType,\n> = TypedPropertyDescriptor<\n (\n params: QuerySchema extends ZodObject\n ? RequestSchema extends ZodType\n ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema>\n : EndpointFunctionArgs<Url, QuerySchema, undefined>\n : RequestSchema extends ZodType\n ? EndpointFunctionArgs<Url, undefined, RequestSchema>\n : EndpointFunctionArgs<Url, undefined, undefined>,\n ) => Promise<z.input<ResponseSchema>>\n>\n\n/**\n * Legacy-compatible Multipart decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n * Provides type safety by ensuring method signatures match the endpoint configuration.\n *\n * @param endpoint - The multipart endpoint declaration from @navios/builder\n * @returns A method decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * @Controller()\n * export class FileController {\n * @Multipart(uploadFileEndpoint)\n * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>): MultipartResult<typeof uploadFileEndpoint> {\n * const { file } = request.data\n * return { url: 'https://example.com/file.jpg' }\n * }\n * }\n * ```\n */\nexport function Multipart<\n Method extends HttpMethod = HttpMethod,\n Url extends string = string,\n QuerySchema = undefined,\n ResponseSchema extends ZodType = ZodType,\n RequestSchema = ZodType,\n>(endpoint: {\n config: BaseEndpointConfig<\n Method,\n Url,\n QuerySchema,\n ResponseSchema,\n RequestSchema\n >\n}) {\n return function <T extends object>(\n target: T,\n propertyKey: string | symbol,\n descriptor: MultipartMethodDescriptor<\n Url,\n QuerySchema,\n RequestSchema,\n ResponseSchema\n >,\n ): PropertyDescriptor | void {\n if (!descriptor) {\n throw new Error(\n '[Navios] @Multipart decorator requires a method descriptor. Make sure experimentalDecorators is enabled.',\n )\n }\n const context = createMethodContext(target, propertyKey, descriptor)\n const originalDecorator = OriginalMultipart(endpoint)\n // @ts-expect-error - we don't need to type the value\n const result = originalDecorator(descriptor.value, context)\n if (result !== descriptor.value) {\n descriptor.value = result\n }\n return descriptor\n }\n}\n","import type {\n BaseStreamConfig,\n EndpointFunctionArgs,\n HttpMethod,\n} from '@navios/builder'\nimport type { ZodObject, ZodType } from 'zod/v4'\n\nimport { Stream as OriginalStream } from '../../decorators/stream.decorator.mjs'\nimport { createMethodContext } from '../context-compat.mjs'\n\n/**\n * Type helper to constrain a PropertyDescriptor's value to match a stream endpoint signature.\n * Note: In legacy decorators, type constraints are checked when the decorator is applied,\n * but may not be preserved perfectly when decorators are stacked.\n */\ntype StreamMethodDescriptor<\n Url extends string,\n QuerySchema,\n RequestSchema,\n> = TypedPropertyDescriptor<\n (\n params: QuerySchema extends ZodObject\n ? RequestSchema extends ZodType\n ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema>\n : EndpointFunctionArgs<Url, QuerySchema, undefined>\n : RequestSchema extends ZodType\n ? EndpointFunctionArgs<Url, undefined, RequestSchema>\n : EndpointFunctionArgs<Url, undefined, undefined>,\n reply: any,\n ) => Promise<void>\n>\n\n/**\n * Legacy-compatible Stream decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n * Provides type safety by ensuring method signatures match the endpoint configuration.\n *\n * @param endpoint - The stream endpoint declaration from @navios/builder\n * @returns A method decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * @Controller()\n * export class FileController {\n * @Stream(downloadFileEndpoint)\n * async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {\n * const { fileId } = request.urlParams\n * // Stream file data to reply\n * }\n * }\n * ```\n */\nexport function Stream<\n Method extends HttpMethod = HttpMethod,\n Url extends string = string,\n QuerySchema = undefined,\n RequestSchema = ZodType,\n>(endpoint: {\n config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>\n}) {\n return function <T extends object>(\n target: T,\n propertyKey: string | symbol,\n descriptor: StreamMethodDescriptor<Url, QuerySchema, RequestSchema>,\n ) {\n const context = createMethodContext(target, propertyKey, descriptor)\n const originalDecorator = OriginalStream(endpoint)\n // @ts-expect-error - we don't need to type the value\n const result = originalDecorator(descriptor.value, context)\n if (result !== descriptor.value) {\n descriptor.value = result\n }\n return descriptor\n }\n}\n"],"mappings":";;;;;;;;GAYA,MAAMA,mCAAmB,IAAIC,SAAAA;;;GAK7B,SAASC,eAAeC,WAAc;AACpC,KAAI,CAACA,aAAa,OAAOA,cAAc,SACrC,QAAO;CAIT,MAAMC,cAAcD,UAAU;AAC9B,KAAIC,eAAe,OAAOA,gBAAgB,WACxC,QAAOA;AAET,QAAO;;;;GAMT,SAAgBC,mBAAmBC,QAAiB;AAElD,KAAI,CAACN,iBAAiBO,IAAID,OAAAA,CACxBN,kBAAiBQ,IAAIF,QAAQ,EAAC,CAAA;CAEhC,MAAMG,WAAWT,iBAAiBU,IAAIJ,OAAAA;AAEtC,QAAO;EACLK,MAAM;EACNC,MAAMN,OAAOM;EACbH;EACAI,iBAAAA;EAGF;;;;;;;GASF,SAAgBC,oBACdR,QACAS,aACAC,YAA8B;CAI9B,MAAMZ,cAAcF,eAAeI,OAAAA;AACnC,KAAI,CAACF,YACH,OAAM,IAAIa,MACR,+EAAA;AAMJ,KAAI,CAACjB,iBAAiBO,IAAIH,YAAAA,CACxBJ,kBAAiBQ,IAAIJ,aAAa,EAAC,CAAA;AAIrC,QAAO;EACLO,MAAM;EACNC,MAAMG;EACNN,UALeT,iBAAiBU,IAAIN,YAAAA;EAMpCc,QAAQ;EACRC,SAAS;EACTC,QAAQ;GACNb,WAAW;GACXG,WAAWM,WAAWK;GACtBb,WAAK;GACP;EACAK,iBAAAA;EAGF;;;;;;;;;;;;;;;;;;;;;;GCpEF,SAAgBS,OACdG,UAAyB;CACvBC,aAAa,EAAE;CACfC,SAAS,EAAE;CACXC,QAAQ,EAAE;CACX,EAAA;AAED,Q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