@navios/core 1.0.0-alpha.2 → 1.0.0-alpha.3
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/CHANGELOG.md +36 -0
- package/lib/{index-BJjk2X1S.d.mts → index-BISYCYEG.d.mts} +435 -180
- package/lib/index-BISYCYEG.d.mts.map +1 -0
- package/lib/{index-DZ6NU03y.d.cts → index-CP80H6Dh.d.cts} +435 -180
- package/lib/index-CP80H6Dh.d.cts.map +1 -0
- package/lib/index.cjs +3 -2
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +2 -2
- package/lib/legacy-compat/index.cjs +38 -124
- package/lib/legacy-compat/index.cjs.map +1 -1
- package/lib/legacy-compat/index.d.cts +4 -60
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +4 -60
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/legacy-compat/index.mjs +12 -118
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/lib/{src-C46ePe3d.cjs → src-CC5lmk_Q.cjs} +167 -2
- package/lib/src-CC5lmk_Q.cjs.map +1 -0
- package/lib/{src-K2k0riYJ.mjs → src-j1cBuAgy.mjs} +162 -3
- package/lib/src-j1cBuAgy.mjs.map +1 -0
- package/lib/testing/index.cjs +2 -2
- package/lib/testing/index.d.cts +1 -1
- package/lib/testing/index.d.mts +1 -1
- package/lib/testing/index.mjs +1 -1
- package/lib/{use-guards.decorator-B6tghdxM.cjs → use-guards.decorator-DtCGXcWZ.cjs} +2 -2
- package/lib/{use-guards.decorator-B6tghdxM.cjs.map → use-guards.decorator-DtCGXcWZ.cjs.map} +1 -1
- package/package.json +2 -2
- package/src/__tests__/attribute.factory.spec.mts +300 -0
- package/src/__tests__/guard-runner.service.spec.mts +399 -0
- package/src/__tests__/logger.service.spec.mts +147 -0
- package/src/__tests__/responders.spec.mts +6 -5
- package/src/interfaces/abstract-http-handler-adapter.interface.mts +86 -2
- package/src/legacy-compat/attribute.factory.mts +2 -2
- package/src/legacy-compat/decorators/controller.decorator.mts +1 -1
- package/src/legacy-compat/decorators/endpoint.decorator.mts +1 -1
- package/src/legacy-compat/decorators/header.decorator.mts +2 -1
- package/src/legacy-compat/decorators/http-code.decorator.mts +2 -1
- package/src/legacy-compat/decorators/index.mts +2 -2
- package/src/legacy-compat/decorators/module.decorator.mts +1 -1
- package/src/legacy-compat/decorators/multipart.decorator.mts +1 -1
- package/src/legacy-compat/decorators/stream.decorator.mts +1 -1
- package/src/legacy-compat/decorators/use-guards.decorator.mts +1 -1
- package/src/legacy-compat/index.mts +10 -5
- package/src/services/abstract-handler-adapter.service.mts +366 -0
- package/src/services/index.mts +1 -0
- package/lib/index-BJjk2X1S.d.mts.map +0 -1
- package/lib/index-DZ6NU03y.d.cts.map +0 -1
- package/lib/src-C46ePe3d.cjs.map +0 -1
- package/lib/src-K2k0riYJ.mjs.map +0 -1
- package/src/legacy-compat/context-compat.mts +0 -95
- package/src/legacy-compat/decorators/factory.decorator.mts +0 -37
- package/src/legacy-compat/decorators/injectable.decorator.mts +0 -41
|
@@ -1,60 +1,6 @@
|
|
|
1
1
|
import { M as getEndpointMetadata, O as getControllerMetadata, T as hasModuleMetadata, a as HttpCode$1, b as getManagedMetadata, i as Module$1, k as hasControllerMetadata, n as Stream$1, o as Header$1, r as Multipart$1, s as Endpoint$1, t as UseGuards$1, v as Controller$1, w as getModuleMetadata, x as hasManagedMetadata } from "../use-guards.decorator-Be_QUx6b.mjs";
|
|
2
|
-
import { Factory as
|
|
2
|
+
import { Factory, Injectable, createClassContext, createClassContext as createClassContext$1, createMethodContext, createMethodContext as createMethodContext$1 } from "@navios/di/legacy-compat";
|
|
3
3
|
|
|
4
|
-
//#region src/legacy-compat/context-compat.mts
|
|
5
|
-
/**
|
|
6
|
-
* Compatibility layer for converting legacy decorator signatures to Stage 3 format.
|
|
7
|
-
*
|
|
8
|
-
* This module provides utilities to create mock Stage 3 decorator contexts
|
|
9
|
-
* from legacy decorator arguments, and manages metadata storage using WeakMap.
|
|
10
|
-
*/ const classMetadataMap = /* @__PURE__ */ new WeakMap();
|
|
11
|
-
/**
|
|
12
|
-
* Gets the constructor from a prototype (for method decorators).
|
|
13
|
-
*/ function getConstructor(prototype) {
|
|
14
|
-
if (!prototype || typeof prototype !== "object") return null;
|
|
15
|
-
const constructor = prototype.constructor;
|
|
16
|
-
if (constructor && typeof constructor === "function") return constructor;
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* Creates a mock ClassDecoratorContext for legacy class decorators.
|
|
21
|
-
* @internal
|
|
22
|
-
*/ function createClassContext(target) {
|
|
23
|
-
if (!classMetadataMap.has(target)) classMetadataMap.set(target, {});
|
|
24
|
-
const metadata = classMetadataMap.get(target);
|
|
25
|
-
return {
|
|
26
|
-
kind: "class",
|
|
27
|
-
name: target.name,
|
|
28
|
-
metadata,
|
|
29
|
-
addInitializer() {}
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Creates a mock ClassMethodDecoratorContext for legacy method decorators.
|
|
34
|
-
*
|
|
35
|
-
* Note: Method decorators need to share metadata with the class context
|
|
36
|
-
* because endpoint metadata is stored at the class level.
|
|
37
|
-
* @internal
|
|
38
|
-
*/ function createMethodContext(target, propertyKey, descriptor) {
|
|
39
|
-
const constructor = getConstructor(target);
|
|
40
|
-
if (!constructor) throw new Error("[Navios] Could not determine class constructor from method decorator target.");
|
|
41
|
-
if (!classMetadataMap.has(constructor)) classMetadataMap.set(constructor, {});
|
|
42
|
-
return {
|
|
43
|
-
kind: "method",
|
|
44
|
-
name: propertyKey,
|
|
45
|
-
metadata: classMetadataMap.get(constructor),
|
|
46
|
-
static: false,
|
|
47
|
-
private: false,
|
|
48
|
-
access: {
|
|
49
|
-
has: () => true,
|
|
50
|
-
get: () => descriptor.value,
|
|
51
|
-
set: () => {}
|
|
52
|
-
},
|
|
53
|
-
addInitializer() {}
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
58
4
|
//#region src/legacy-compat/decorators/module.decorator.mts
|
|
59
5
|
/**
|
|
60
6
|
* Legacy-compatible Module decorator.
|
|
@@ -79,7 +25,7 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
79
25
|
guards: []
|
|
80
26
|
}) {
|
|
81
27
|
return function(target) {
|
|
82
|
-
const context = createClassContext(target);
|
|
28
|
+
const context = createClassContext$1(target);
|
|
83
29
|
return Module$1(options)(target, context);
|
|
84
30
|
};
|
|
85
31
|
}
|
|
@@ -104,7 +50,7 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
104
50
|
* ```
|
|
105
51
|
*/ function Controller(options = {}) {
|
|
106
52
|
return function(target) {
|
|
107
|
-
const context = createClassContext(target);
|
|
53
|
+
const context = createClassContext$1(target);
|
|
108
54
|
return Controller$1(options)(target, context);
|
|
109
55
|
};
|
|
110
56
|
}
|
|
@@ -134,7 +80,7 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
134
80
|
return function(target, propertyKey, descriptor) {
|
|
135
81
|
if (!descriptor) throw new Error("[Navios] @Endpoint decorator requires a method descriptor. Make sure experimentalDecorators is enabled.");
|
|
136
82
|
const typedDescriptor = descriptor;
|
|
137
|
-
const context = createMethodContext(target, propertyKey, typedDescriptor);
|
|
83
|
+
const context = createMethodContext$1(target, propertyKey, typedDescriptor);
|
|
138
84
|
const result = Endpoint$1(endpoint)(typedDescriptor.value, context);
|
|
139
85
|
if (result !== typedDescriptor.value) typedDescriptor.value = result;
|
|
140
86
|
return typedDescriptor;
|
|
@@ -170,12 +116,12 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
170
116
|
*/ function UseGuards(...guards) {
|
|
171
117
|
function decoratorImpl(target, propertyKey, descriptor) {
|
|
172
118
|
if (propertyKey !== void 0 && descriptor !== void 0) {
|
|
173
|
-
const context = createMethodContext(target, propertyKey, descriptor);
|
|
119
|
+
const context = createMethodContext$1(target, propertyKey, descriptor);
|
|
174
120
|
const result = UseGuards$1(...guards)(descriptor.value, context);
|
|
175
121
|
if (result !== descriptor.value) descriptor.value = result;
|
|
176
122
|
return descriptor;
|
|
177
123
|
} else {
|
|
178
|
-
const context = createClassContext(target);
|
|
124
|
+
const context = createClassContext$1(target);
|
|
179
125
|
return UseGuards$1(...guards)(target, context);
|
|
180
126
|
}
|
|
181
127
|
}
|
|
@@ -206,7 +152,7 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
206
152
|
* ```
|
|
207
153
|
*/ function Header(name, value) {
|
|
208
154
|
return function(target, propertyKey, descriptor) {
|
|
209
|
-
const context = createMethodContext(target, propertyKey, descriptor);
|
|
155
|
+
const context = createMethodContext$1(target, propertyKey, descriptor);
|
|
210
156
|
const result = Header$1(name, value)(descriptor.value, context);
|
|
211
157
|
if (result !== descriptor.value) descriptor.value = result;
|
|
212
158
|
return descriptor;
|
|
@@ -236,7 +182,7 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
236
182
|
* ```
|
|
237
183
|
*/ function HttpCode(code) {
|
|
238
184
|
return function(target, propertyKey, descriptor) {
|
|
239
|
-
const context = createMethodContext(target, propertyKey, descriptor);
|
|
185
|
+
const context = createMethodContext$1(target, propertyKey, descriptor);
|
|
240
186
|
const result = HttpCode$1(code)(descriptor.value, context);
|
|
241
187
|
if (result !== descriptor.value) descriptor.value = result;
|
|
242
188
|
return descriptor;
|
|
@@ -268,7 +214,7 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
268
214
|
*/ function Multipart(endpoint) {
|
|
269
215
|
return function(target, propertyKey, descriptor) {
|
|
270
216
|
if (!descriptor) throw new Error("[Navios] @Multipart decorator requires a method descriptor. Make sure experimentalDecorators is enabled.");
|
|
271
|
-
const context = createMethodContext(target, propertyKey, descriptor);
|
|
217
|
+
const context = createMethodContext$1(target, propertyKey, descriptor);
|
|
272
218
|
const result = Multipart$1(endpoint)(descriptor.value, context);
|
|
273
219
|
if (result !== descriptor.value) descriptor.value = result;
|
|
274
220
|
return descriptor;
|
|
@@ -301,65 +247,13 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
301
247
|
return function(target, propertyKey, descriptor) {
|
|
302
248
|
if (!descriptor || !descriptor.value) throw new Error("[Navios] @Stream decorator requires a method descriptor. Make sure experimentalDecorators is enabled.");
|
|
303
249
|
const typedDescriptor = descriptor;
|
|
304
|
-
const context = createMethodContext(target, propertyKey, typedDescriptor);
|
|
250
|
+
const context = createMethodContext$1(target, propertyKey, typedDescriptor);
|
|
305
251
|
const result = Stream$1(endpoint)(typedDescriptor.value, context);
|
|
306
252
|
if (result && result !== typedDescriptor.value) typedDescriptor.value = result;
|
|
307
253
|
return typedDescriptor;
|
|
308
254
|
};
|
|
309
255
|
}
|
|
310
256
|
|
|
311
|
-
//#endregion
|
|
312
|
-
//#region src/legacy-compat/decorators/injectable.decorator.mts
|
|
313
|
-
/**
|
|
314
|
-
* Legacy-compatible Injectable decorator.
|
|
315
|
-
*
|
|
316
|
-
* Works with TypeScript experimental decorators (legacy API).
|
|
317
|
-
*
|
|
318
|
-
* @param options - Injectable configuration options
|
|
319
|
-
* @returns A class decorator compatible with legacy decorator API
|
|
320
|
-
*
|
|
321
|
-
* @example
|
|
322
|
-
* ```typescript
|
|
323
|
-
* @Injectable()
|
|
324
|
-
* export class UserService {
|
|
325
|
-
* getUser(id: string) {
|
|
326
|
-
* return { id, name: 'John' }
|
|
327
|
-
* }
|
|
328
|
-
* }
|
|
329
|
-
* ```
|
|
330
|
-
*/ function Injectable(options = {}) {
|
|
331
|
-
return function(target) {
|
|
332
|
-
const context = createClassContext(target);
|
|
333
|
-
return (Object.keys(options).length === 0 ? Injectable$1() : Injectable$1(options))(target, context);
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
//#endregion
|
|
338
|
-
//#region src/legacy-compat/decorators/factory.decorator.mts
|
|
339
|
-
/**
|
|
340
|
-
* Legacy-compatible Factory decorator.
|
|
341
|
-
*
|
|
342
|
-
* Works with TypeScript experimental decorators (legacy API).
|
|
343
|
-
*
|
|
344
|
-
* @param options - Factory configuration options
|
|
345
|
-
* @returns A class decorator compatible with legacy decorator API
|
|
346
|
-
*
|
|
347
|
-
* @example
|
|
348
|
-
* ```typescript
|
|
349
|
-
* @Factory()
|
|
350
|
-
* export class DatabaseConnectionFactory {
|
|
351
|
-
* create() {
|
|
352
|
-
* return { host: 'localhost', port: 5432 }
|
|
353
|
-
* }
|
|
354
|
-
* }
|
|
355
|
-
* ```
|
|
356
|
-
*/ function Factory(options = {}) {
|
|
357
|
-
return function(target) {
|
|
358
|
-
const context = createClassContext(target);
|
|
359
|
-
return (Object.keys(options).length === 0 ? Factory$1() : Factory$1(options))(target, context);
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
|
|
363
257
|
//#endregion
|
|
364
258
|
//#region src/legacy-compat/attribute.factory.mts
|
|
365
259
|
/**
|
|
@@ -408,7 +302,7 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
408
302
|
const res = (value) => {
|
|
409
303
|
function decorator(target, propertyKey, descriptor) {
|
|
410
304
|
if (propertyKey !== void 0 && descriptor !== void 0) {
|
|
411
|
-
const context = createMethodContext(target, propertyKey, descriptor);
|
|
305
|
+
const context = createMethodContext$1(target, propertyKey, descriptor);
|
|
412
306
|
const metadata = getEndpointMetadata(descriptor.value, context);
|
|
413
307
|
if (schema) {
|
|
414
308
|
const validatedValue = schema.safeParse(value);
|
|
@@ -421,7 +315,7 @@ import { Factory as Factory$1, Injectable as Injectable$1 } from "@navios/di";
|
|
|
421
315
|
const isModule = hasModuleMetadata(target);
|
|
422
316
|
const isManaged = hasManagedMetadata(target);
|
|
423
317
|
if (!isController && !isModule && !isManaged) throw new Error("[Navios] Attribute can only be applied to classes with @Controller, @Module, or other Navios-managed decorators");
|
|
424
|
-
const context = createClassContext(target);
|
|
318
|
+
const context = createClassContext$1(target);
|
|
425
319
|
const metadata = isController ? getControllerMetadata(target, context) : isModule ? getModuleMetadata(target, context) : isManaged ? getManagedMetadata(target) : null;
|
|
426
320
|
if (!metadata) throw new Error("[Navios] Could not determine metadata for attribute target");
|
|
427
321
|
if (schema) {
|
|
@@ -1 +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","value","Error","typedDescriptor","context","originalDecorator","result","Injectable","OriginalInjectable","createClassContext","options","target","context","originalDecorator","Object","keys","length","Factory","OriginalFactory","createClassContext","options","target","context","originalDecorator","Object","keys","length","getControllerMetadata","getEndpointMetadata","getModuleMetadata","hasControllerMetadata","hasModuleMetadata","getManagedMetadata","hasManagedMetadata","createClassContext","createMethodContext","LegacyAttributeFactory","createAttribute","token","schema","res","value","decorator","target","propertyKey","descriptor","isMethodDecorator","undefined","context","metadata","validatedValue","safeParse","success","Error","toString","error","customAttributes","set","data","isController","isModule","isManaged","get","attribute","getAll","values","Array","from","entries","filter","key","map","length","getLast","i","has","AttributeFactory"],"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","../../src/legacy-compat/decorators/injectable.decorator.mts","../../src/legacy-compat/decorators/factory.decorator.mts","../../src/legacy-compat/attribute.factory.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 * @internal\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 * @internal\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 EndpointHandler,\n EndpointOptions,\n RequestArgs,\n} from '@navios/builder'\nimport type { z } 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<Config extends EndpointOptions> =\n TypedPropertyDescriptor<\n (\n params: RequestArgs<\n Config['url'],\n Config['querySchema'],\n Config['requestSchema'],\n Config['urlParamsSchema'],\n true\n >,\n ) => Promise<z.input<Config['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<const Config extends EndpointOptions>(\n endpoint: EndpointHandler<Config, false>,\n) {\n return function (\n target: any,\n propertyKey: string | symbol,\n descriptor: EndpointMethodDescriptor<Config>,\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<Config>\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 as any\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 EndpointHandler,\n EndpointOptions,\n RequestArgs,\n} from '@navios/builder'\nimport type { z } 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<Config extends EndpointOptions> =\n TypedPropertyDescriptor<\n (\n params: RequestArgs<\n Config['url'],\n Config['querySchema'],\n Config['requestSchema'],\n Config['urlParamsSchema'],\n true\n >,\n ) => Promise<z.input<Config['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<const Config extends EndpointOptions>(\n endpoint: EndpointHandler<Config, false>,\n) {\n return function <T extends object>(\n target: T,\n propertyKey: string | symbol,\n descriptor: MultipartMethodDescriptor<Config>,\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 as any\n }\n return descriptor\n }\n}\n","import type {\n BaseEndpointOptions,\n RequestArgs,\n StreamHandler,\n} from '@navios/builder'\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 * Supports both with and without reply parameter (Bun doesn't use reply parameter).\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<Config extends BaseEndpointOptions> =\n | TypedPropertyDescriptor<\n (\n params: RequestArgs<\n Config['url'],\n Config['querySchema'],\n Config['requestSchema'],\n Config['urlParamsSchema'],\n true\n >,\n reply: any,\n ) => any\n >\n | TypedPropertyDescriptor<\n (\n params: RequestArgs<\n Config['url'],\n Config['querySchema'],\n Config['requestSchema'],\n Config['urlParamsSchema'],\n true\n >,\n ) => any\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<const Config extends BaseEndpointOptions>(\n endpoint: StreamHandler<Config, false>,\n) {\n return function (\n target: any,\n propertyKey: string | symbol,\n descriptor: StreamMethodDescriptor<Config>,\n ): PropertyDescriptor | void {\n if (!descriptor || !descriptor.value) {\n throw new Error(\n '[Navios] @Stream 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 StreamMethodDescriptor<Config>\n const context = createMethodContext(target, propertyKey, typedDescriptor)\n const originalDecorator = OriginalStream(endpoint)\n // Stage3 decorator returns void in type signature but actually returns the function\n // We know value is defined because we checked above\n const result = originalDecorator(typedDescriptor.value!, context) as\n | typeof typedDescriptor.value\n | void\n if (result && result !== typedDescriptor.value) {\n typedDescriptor.value = result as any\n }\n return typedDescriptor\n }\n}\n","import type { ClassType } from '@navios/di'\n\nimport {\n Injectable as OriginalInjectable,\n type InjectableOptions,\n} from '@navios/di'\n\nimport { createClassContext } from '../context-compat.mjs'\n\nexport type { InjectableOptions }\n\n/**\n * Legacy-compatible Injectable decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - Injectable configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * @Injectable()\n * export class UserService {\n * getUser(id: string) {\n * return { id, name: 'John' }\n * }\n * }\n * ```\n */\nexport function Injectable(options: InjectableOptions = {}) {\n return function (target: ClassType) {\n const context = createClassContext(target)\n // Use the no-args overload when options is empty, otherwise pass options\n const originalDecorator =\n Object.keys(options).length === 0\n ? OriginalInjectable()\n : // @ts-expect-error - InjectableOptions is a union type, we let runtime handle it\n OriginalInjectable(options)\n return originalDecorator(target, context)\n }\n}\n","import type { ClassType, FactoryOptions } from '@navios/di'\n\nimport { Factory as OriginalFactory } from '@navios/di'\n\nimport { createClassContext } from '../context-compat.mjs'\n\nexport type { FactoryOptions }\n\n/**\n * Legacy-compatible Factory decorator.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * @param options - Factory configuration options\n * @returns A class decorator compatible with legacy decorator API\n *\n * @example\n * ```typescript\n * @Factory()\n * export class DatabaseConnectionFactory {\n * create() {\n * return { host: 'localhost', port: 5432 }\n * }\n * }\n * ```\n */\nexport function Factory(options: FactoryOptions = {}) {\n return function (target: ClassType) {\n const context = createClassContext(target)\n // Use the no-args overload when options is empty, otherwise pass options\n const originalDecorator =\n Object.keys(options).length === 0\n ? OriginalFactory()\n : OriginalFactory(options)\n return originalDecorator(target, context)\n }\n}\n","import type { z, ZodType } from 'zod/v4'\nimport type { ClassType } from '@navios/di'\n\nimport type {\n ControllerMetadata,\n HandlerMetadata,\n ModuleMetadata,\n} from '../metadata/index.mjs'\n\nimport {\n getControllerMetadata,\n getEndpointMetadata,\n getModuleMetadata,\n hasControllerMetadata,\n hasModuleMetadata,\n} from '../metadata/index.mjs'\nimport {\n getManagedMetadata,\n hasManagedMetadata,\n} from '../metadata/navios-managed.metadata.mjs'\nimport { createClassContext, createMethodContext } from './context-compat.mjs'\n\n/**\n * Type for a legacy class/method attribute decorator without a value.\n *\n * Attributes are custom metadata decorators that can be applied to modules,\n * controllers, and endpoints.\n */\nexport type LegacyClassAttribute = {\n (): ClassDecorator & MethodDecorator\n token: symbol\n}\n\n/**\n * Type for a legacy class/method attribute decorator with a validated value.\n *\n * @typeParam S - The Zod schema type for validation\n */\nexport type LegacyClassSchemaAttribute<S extends ZodType> = {\n (value: z.input<S>): ClassDecorator & MethodDecorator\n token: symbol\n schema: ZodType\n}\n\n/**\n * Legacy-compatible factory for creating custom attribute decorators.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * Attributes allow you to add custom metadata to modules, controllers, and endpoints.\n * This is useful for cross-cutting concerns like rate limiting, caching, API versioning, etc.\n *\n * @example\n * ```typescript\n * // Create a simple boolean attribute\n * const Public = LegacyAttributeFactory.createAttribute(Symbol.for('Public'))\n *\n * // Use it as a decorator\n * @Controller()\n * @Public()\n * export class PublicController { }\n *\n * // Check if attribute exists\n * if (LegacyAttributeFactory.has(Public, controllerMetadata)) {\n * // Skip authentication\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Create an attribute with a validated value\n * const RateLimit = LegacyAttributeFactory.createAttribute(\n * Symbol.for('RateLimit'),\n * z.object({ requests: z.number(), window: z.number() })\n * )\n *\n * // Use it with a value\n * @Endpoint(apiEndpoint)\n * @RateLimit({ requests: 100, window: 60000 })\n * async handler() { }\n *\n * // Get the value\n * const limit = LegacyAttributeFactory.get(RateLimit, endpointMetadata)\n * // limit is typed as { requests: number, window: number } | null\n * ```\n */\nexport class LegacyAttributeFactory {\n /**\n * Creates a simple attribute decorator without a value.\n *\n * @param token - A unique symbol to identify this attribute\n * @returns A decorator function that can be applied to classes or methods\n *\n * @example\n * ```typescript\n * const Public = LegacyAttributeFactory.createAttribute(Symbol.for('Public'))\n *\n * @Public()\n * @Controller()\n * export class PublicController { }\n * ```\n */\n static createAttribute(token: symbol): LegacyClassAttribute\n /**\n * Creates an attribute decorator with a validated value.\n *\n * @param token - A unique symbol to identify this attribute\n * @param schema - A Zod schema to validate the attribute value\n * @returns A decorator function that accepts a value and can be applied to classes or methods\n *\n * @example\n * ```typescript\n * const RateLimit = LegacyAttributeFactory.createAttribute(\n * Symbol.for('RateLimit'),\n * z.object({ requests: z.number(), window: z.number() })\n * )\n *\n * @RateLimit({ requests: 100, window: 60000 })\n * @Endpoint(apiEndpoint)\n * async handler() { }\n * ```\n */\n static createAttribute<T extends ZodType>(\n token: symbol,\n schema: T,\n ): LegacyClassSchemaAttribute<T>\n\n static createAttribute(token: symbol, schema?: ZodType) {\n const res = (value?: unknown) => {\n // Return a decorator that can handle both class and method targets\n function decorator(target: any): any\n function decorator(\n target: any,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor,\n ): PropertyDescriptor\n function decorator(\n target: any,\n propertyKey?: string | symbol,\n descriptor?: PropertyDescriptor,\n ): any {\n const isMethodDecorator =\n propertyKey !== undefined && descriptor !== undefined\n\n if (isMethodDecorator) {\n // Method decorator - apply to endpoint\n const context = createMethodContext(target, propertyKey, descriptor)\n const metadata = getEndpointMetadata(descriptor.value, context)\n\n if (schema) {\n const validatedValue = schema.safeParse(value)\n if (!validatedValue.success) {\n throw new Error(\n `[Navios] Invalid value for attribute ${token.toString()}: ${validatedValue.error}`,\n )\n }\n metadata.customAttributes.set(token, validatedValue.data)\n } else {\n metadata.customAttributes.set(token, true)\n }\n return descriptor\n } else {\n // Class decorator\n const isController = hasControllerMetadata(target as ClassType)\n const isModule = hasModuleMetadata(target as ClassType)\n const isManaged = hasManagedMetadata(target as ClassType)\n\n if (!isController && !isModule && !isManaged) {\n throw new Error(\n '[Navios] Attribute can only be applied to classes with @Controller, @Module, or other Navios-managed decorators',\n )\n }\n\n const context = createClassContext(target)\n const metadata = isController\n ? getControllerMetadata(target, context)\n : isModule\n ? getModuleMetadata(target, context)\n : isManaged\n ? getManagedMetadata(target)!\n : null\n\n if (!metadata) {\n throw new Error(\n '[Navios] Could not determine metadata for attribute target',\n )\n }\n\n if (schema) {\n const validatedValue = schema.safeParse(value)\n if (!validatedValue.success) {\n throw new Error(\n `[Navios] Invalid value for attribute ${token.toString()}: ${validatedValue.error}`,\n )\n }\n metadata.customAttributes.set(token, validatedValue.data)\n } else {\n metadata.customAttributes.set(token, true)\n }\n return target\n }\n }\n return decorator\n }\n res.token = token\n if (schema) {\n res.schema = schema\n }\n return res\n }\n\n /**\n * Gets the value of an attribute from metadata.\n *\n * Returns `null` if the attribute is not present.\n * For simple attributes (without values), returns `true` if present.\n *\n * @param attribute - The attribute decorator\n * @param target - The metadata object (module, controller, or handler)\n * @returns The attribute value, `true` for simple attributes, or `null` if not found\n *\n * @example\n * ```typescript\n * const isPublic = LegacyAttributeFactory.get(Public, controllerMetadata)\n * // isPublic is true | null\n *\n * const rateLimit = LegacyAttributeFactory.get(RateLimit, endpointMetadata)\n * // rateLimit is { requests: number, window: number } | null\n * ```\n */\n static get(\n attribute: LegacyClassAttribute,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): true | null\n static get<T extends ZodType>(\n attribute: LegacyClassSchemaAttribute<T>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): z.output<T> | null\n static get(\n attribute: LegacyClassAttribute | LegacyClassSchemaAttribute<any>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ) {\n return target.customAttributes.get(attribute.token) ?? null\n }\n\n /**\n * Gets all values of an attribute from metadata (useful when an attribute can appear multiple times).\n *\n * Returns `null` if the attribute is not present.\n *\n * @param attribute - The attribute decorator\n * @param target - The metadata object (module, controller, or handler)\n * @returns An array of attribute values, or `null` if not found\n *\n * @example\n * ```typescript\n * const tags = LegacyAttributeFactory.getAll(Tag, endpointMetadata)\n * // tags is string[] | null\n * ```\n */\n static getAll(\n attribute: LegacyClassAttribute,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): Array<true> | null\n static getAll<T extends ZodType>(\n attribute: LegacyClassSchemaAttribute<T>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): Array<z.output<T>> | null\n static getAll(\n attribute: LegacyClassAttribute | LegacyClassSchemaAttribute<any>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ) {\n const values = Array.from(target.customAttributes.entries())\n .filter(([key]) => key === attribute.token)\n .map(([, value]) => value)\n return values.length > 0 ? values : null\n }\n\n /**\n * Gets the last value of an attribute from an array of metadata objects.\n *\n * Searches from the end of the array backwards, useful for finding the most\n * specific attribute value (e.g., endpoint-level overrides module-level).\n *\n * @param attribute - The attribute decorator\n * @param target - An array of metadata objects (typically [module, controller, handler])\n * @returns The last attribute value found, or `null` if not found\n *\n * @example\n * ```typescript\n * // Check attribute hierarchy: endpoint -> controller -> module\n * const rateLimit = LegacyAttributeFactory.getLast(RateLimit, [\n * moduleMetadata,\n * controllerMetadata,\n * endpointMetadata\n * ])\n * ```\n */\n static getLast(\n attribute: LegacyClassAttribute,\n target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[],\n ): true | null\n static getLast<T extends ZodType>(\n attribute: LegacyClassSchemaAttribute<T>,\n target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[],\n ): z.output<T> | null\n static getLast(\n attribute: LegacyClassAttribute | LegacyClassSchemaAttribute<any>,\n target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[],\n ) {\n for (let i = target.length - 1; i >= 0; i--) {\n const value = target[i].customAttributes.get(attribute.token)\n if (value) {\n return value\n }\n }\n return null\n }\n\n /**\n * Checks if an attribute is present on the metadata object.\n *\n * @param attribute - The attribute decorator\n * @param target - The metadata object (module, controller, or handler)\n * @returns `true` if the attribute is present, `false` otherwise\n *\n * @example\n * ```typescript\n * if (LegacyAttributeFactory.has(Public, controllerMetadata)) {\n * // Skip authentication\n * }\n * ```\n */\n static has(\n attribute: LegacyClassAttribute,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): boolean\n static has<T extends ZodType>(\n attribute: LegacyClassSchemaAttribute<T>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): boolean\n static has(\n attribute: LegacyClassAttribute | LegacyClassSchemaAttribute<any>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ) {\n return target.customAttributes.has(attribute.token)\n }\n}\n\n// Re-export as AttributeFactory for convenience\nexport { LegacyAttributeFactory as AttributeFactory }\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;;;;;GAOT,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;;;;;;;;GAUF,SAAgBC,oBACdR,QACAS,aACAC,YAA8B;CAI9B,MAAMZ,cAAcF,eAAeI,OAAAA;AACnC,KAAI,CAACF,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AK,CACzCiC,KAAK,GAAG9B,WAAWA,MAAAA;AACtB,SAAOwB,OAAOO,SAAS,IAAIP,SAAS;;CA+BtC,OAAOQ,QACLV,WACApB,QACA;AACA,OAAK,IAAI+B,IAAI/B,OAAO6B,SAAS,GAAGE,KAAK,GAAGA,KAAK;GAC3C,MAAMjC,QAAQE,OAAO+B,GAAGlB,iBAAiBM,IAAIC,UAAUzB,MAAK;AAC5D,OAAIG,MACF,QAAOA;;AAGX,SAAO;;CAyBT,OAAOkC,IACLZ,WACApB,QACA;AACA,SAAOA,OAAOa,iBAAiBmB,IAAIZ,UAAUzB,MAAK"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["createClassContext","Module","OriginalModule","options","controllers","imports","guards","target","context","originalDecorator","createClassContext","Controller","OriginalController","options","target","context","originalDecorator","createMethodContext","Endpoint","OriginalEndpoint","endpoint","target","propertyKey","descriptor","Error","typedDescriptor","context","originalDecorator","result","value","createClassContext","createMethodContext","UseGuards","OriginalUseGuards","guards","decoratorImpl","target","propertyKey","descriptor","undefined","context","originalDecorator","result","value","createMethodContext","Header","OriginalHeader","name","value","target","propertyKey","descriptor","context","originalDecorator","result","createMethodContext","HttpCode","OriginalHttpCode","code","target","propertyKey","descriptor","context","originalDecorator","result","value","createMethodContext","Multipart","OriginalMultipart","endpoint","target","propertyKey","descriptor","Error","context","originalDecorator","result","value","createMethodContext","Stream","OriginalStream","endpoint","target","propertyKey","descriptor","value","Error","typedDescriptor","context","originalDecorator","result","createClassContext","createMethodContext","getControllerMetadata","getEndpointMetadata","getModuleMetadata","hasControllerMetadata","hasModuleMetadata","getManagedMetadata","hasManagedMetadata","LegacyAttributeFactory","createAttribute","token","schema","res","value","decorator","target","propertyKey","descriptor","isMethodDecorator","undefined","context","metadata","validatedValue","safeParse","success","Error","toString","error","customAttributes","set","data","isController","isModule","isManaged","get","attribute","getAll","values","Array","from","entries","filter","key","map","length","getLast","i","has","AttributeFactory"],"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":["import type { ClassType } from '@navios/di'\nimport { createClassContext } from '@navios/di/legacy-compat'\n\nimport { Module as OriginalModule, type ModuleOptions } from '../../decorators/module.decorator.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'\nimport { createClassContext } from '@navios/di/legacy-compat'\n\nimport type { ControllerOptions } from '../../decorators/controller.decorator.mjs'\n\nimport { Controller as OriginalController } from '../../decorators/controller.decorator.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 EndpointHandler,\n EndpointOptions,\n RequestArgs,\n} from '@navios/builder'\nimport { createMethodContext } from '@navios/di/legacy-compat'\nimport type { z } from 'zod/v4'\n\nimport { Endpoint as OriginalEndpoint } from '../../decorators/endpoint.decorator.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<Config extends EndpointOptions> =\n TypedPropertyDescriptor<\n (\n params: RequestArgs<\n Config['url'],\n Config['querySchema'],\n Config['requestSchema'],\n Config['urlParamsSchema'],\n true\n >,\n ) => Promise<z.input<Config['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<const Config extends EndpointOptions>(\n endpoint: EndpointHandler<Config, false>,\n) {\n return function (\n target: any,\n propertyKey: string | symbol,\n descriptor: EndpointMethodDescriptor<Config>,\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<Config>\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 as any\n }\n return typedDescriptor\n }\n}\n","import type {\n ClassType,\n ClassTypeWithInstance,\n InjectionToken,\n} from '@navios/di'\nimport { createClassContext, createMethodContext } from '@navios/di/legacy-compat'\n\nimport type { CanActivate } from '../../interfaces/index.mjs'\n\nimport { UseGuards as OriginalUseGuards } from '../../decorators/use-guards.decorator.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 { createMethodContext } from '@navios/di/legacy-compat'\n\nimport type { HttpHeader } from '../../interfaces/index.mjs'\n\nimport { Header as OriginalHeader } from '../../decorators/header.decorator.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 { createMethodContext } from '@navios/di/legacy-compat'\n\nimport { HttpCode as OriginalHttpCode } from '../../decorators/http-code.decorator.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 EndpointHandler,\n EndpointOptions,\n RequestArgs,\n} from '@navios/builder'\nimport { createMethodContext } from '@navios/di/legacy-compat'\nimport type { z } from 'zod/v4'\n\nimport { Multipart as OriginalMultipart } from '../../decorators/multipart.decorator.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<Config extends EndpointOptions> =\n TypedPropertyDescriptor<\n (\n params: RequestArgs<\n Config['url'],\n Config['querySchema'],\n Config['requestSchema'],\n Config['urlParamsSchema'],\n true\n >,\n ) => Promise<z.input<Config['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<const Config extends EndpointOptions>(\n endpoint: EndpointHandler<Config, false>,\n) {\n return function <T extends object>(\n target: T,\n propertyKey: string | symbol,\n descriptor: MultipartMethodDescriptor<Config>,\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 as any\n }\n return descriptor\n }\n}\n","import type {\n BaseEndpointOptions,\n RequestArgs,\n StreamHandler,\n} from '@navios/builder'\nimport { createMethodContext } from '@navios/di/legacy-compat'\n\nimport { Stream as OriginalStream } from '../../decorators/stream.decorator.mjs'\n\n/**\n * Type helper to constrain a PropertyDescriptor's value to match a stream endpoint signature.\n * Supports both with and without reply parameter (Bun doesn't use reply parameter).\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<Config extends BaseEndpointOptions> =\n | TypedPropertyDescriptor<\n (\n params: RequestArgs<\n Config['url'],\n Config['querySchema'],\n Config['requestSchema'],\n Config['urlParamsSchema'],\n true\n >,\n reply: any,\n ) => any\n >\n | TypedPropertyDescriptor<\n (\n params: RequestArgs<\n Config['url'],\n Config['querySchema'],\n Config['requestSchema'],\n Config['urlParamsSchema'],\n true\n >,\n ) => any\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<const Config extends BaseEndpointOptions>(\n endpoint: StreamHandler<Config, false>,\n) {\n return function (\n target: any,\n propertyKey: string | symbol,\n descriptor: StreamMethodDescriptor<Config>,\n ): PropertyDescriptor | void {\n if (!descriptor || !descriptor.value) {\n throw new Error(\n '[Navios] @Stream 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 StreamMethodDescriptor<Config>\n const context = createMethodContext(target, propertyKey, typedDescriptor)\n const originalDecorator = OriginalStream(endpoint)\n // Stage3 decorator returns void in type signature but actually returns the function\n // We know value is defined because we checked above\n const result = originalDecorator(typedDescriptor.value!, context) as\n | typeof typedDescriptor.value\n | void\n if (result && result !== typedDescriptor.value) {\n typedDescriptor.value = result as any\n }\n return typedDescriptor\n }\n}\n","import type { ClassType } from '@navios/di'\nimport { createClassContext, createMethodContext } from '@navios/di/legacy-compat'\nimport type { z, ZodType } from 'zod/v4'\n\nimport type {\n ControllerMetadata,\n HandlerMetadata,\n ModuleMetadata,\n} from '../metadata/index.mjs'\n\nimport {\n getControllerMetadata,\n getEndpointMetadata,\n getModuleMetadata,\n hasControllerMetadata,\n hasModuleMetadata,\n} from '../metadata/index.mjs'\nimport {\n getManagedMetadata,\n hasManagedMetadata,\n} from '../metadata/navios-managed.metadata.mjs'\n\n/**\n * Type for a legacy class/method attribute decorator without a value.\n *\n * Attributes are custom metadata decorators that can be applied to modules,\n * controllers, and endpoints.\n */\nexport type LegacyClassAttribute = {\n (): ClassDecorator & MethodDecorator\n token: symbol\n}\n\n/**\n * Type for a legacy class/method attribute decorator with a validated value.\n *\n * @typeParam S - The Zod schema type for validation\n */\nexport type LegacyClassSchemaAttribute<S extends ZodType> = {\n (value: z.input<S>): ClassDecorator & MethodDecorator\n token: symbol\n schema: ZodType\n}\n\n/**\n * Legacy-compatible factory for creating custom attribute decorators.\n *\n * Works with TypeScript experimental decorators (legacy API).\n *\n * Attributes allow you to add custom metadata to modules, controllers, and endpoints.\n * This is useful for cross-cutting concerns like rate limiting, caching, API versioning, etc.\n *\n * @example\n * ```typescript\n * // Create a simple boolean attribute\n * const Public = LegacyAttributeFactory.createAttribute(Symbol.for('Public'))\n *\n * // Use it as a decorator\n * @Controller()\n * @Public()\n * export class PublicController { }\n *\n * // Check if attribute exists\n * if (LegacyAttributeFactory.has(Public, controllerMetadata)) {\n * // Skip authentication\n * }\n * ```\n *\n * @example\n * ```typescript\n * // Create an attribute with a validated value\n * const RateLimit = LegacyAttributeFactory.createAttribute(\n * Symbol.for('RateLimit'),\n * z.object({ requests: z.number(), window: z.number() })\n * )\n *\n * // Use it with a value\n * @Endpoint(apiEndpoint)\n * @RateLimit({ requests: 100, window: 60000 })\n * async handler() { }\n *\n * // Get the value\n * const limit = LegacyAttributeFactory.get(RateLimit, endpointMetadata)\n * // limit is typed as { requests: number, window: number } | null\n * ```\n */\nexport class LegacyAttributeFactory {\n /**\n * Creates a simple attribute decorator without a value.\n *\n * @param token - A unique symbol to identify this attribute\n * @returns A decorator function that can be applied to classes or methods\n *\n * @example\n * ```typescript\n * const Public = LegacyAttributeFactory.createAttribute(Symbol.for('Public'))\n *\n * @Public()\n * @Controller()\n * export class PublicController { }\n * ```\n */\n static createAttribute(token: symbol): LegacyClassAttribute\n /**\n * Creates an attribute decorator with a validated value.\n *\n * @param token - A unique symbol to identify this attribute\n * @param schema - A Zod schema to validate the attribute value\n * @returns A decorator function that accepts a value and can be applied to classes or methods\n *\n * @example\n * ```typescript\n * const RateLimit = LegacyAttributeFactory.createAttribute(\n * Symbol.for('RateLimit'),\n * z.object({ requests: z.number(), window: z.number() })\n * )\n *\n * @RateLimit({ requests: 100, window: 60000 })\n * @Endpoint(apiEndpoint)\n * async handler() { }\n * ```\n */\n static createAttribute<T extends ZodType>(\n token: symbol,\n schema: T,\n ): LegacyClassSchemaAttribute<T>\n\n static createAttribute(token: symbol, schema?: ZodType) {\n const res = (value?: unknown) => {\n // Return a decorator that can handle both class and method targets\n function decorator(target: any): any\n function decorator(\n target: any,\n propertyKey: string | symbol,\n descriptor: PropertyDescriptor,\n ): PropertyDescriptor\n function decorator(\n target: any,\n propertyKey?: string | symbol,\n descriptor?: PropertyDescriptor,\n ): any {\n const isMethodDecorator =\n propertyKey !== undefined && descriptor !== undefined\n\n if (isMethodDecorator) {\n // Method decorator - apply to endpoint\n const context = createMethodContext(target, propertyKey, descriptor)\n const metadata = getEndpointMetadata(descriptor.value, context)\n\n if (schema) {\n const validatedValue = schema.safeParse(value)\n if (!validatedValue.success) {\n throw new Error(\n `[Navios] Invalid value for attribute ${token.toString()}: ${validatedValue.error}`,\n )\n }\n metadata.customAttributes.set(token, validatedValue.data)\n } else {\n metadata.customAttributes.set(token, true)\n }\n return descriptor\n } else {\n // Class decorator\n const isController = hasControllerMetadata(target as ClassType)\n const isModule = hasModuleMetadata(target as ClassType)\n const isManaged = hasManagedMetadata(target as ClassType)\n\n if (!isController && !isModule && !isManaged) {\n throw new Error(\n '[Navios] Attribute can only be applied to classes with @Controller, @Module, or other Navios-managed decorators',\n )\n }\n\n const context = createClassContext(target)\n const metadata = isController\n ? getControllerMetadata(target, context)\n : isModule\n ? getModuleMetadata(target, context)\n : isManaged\n ? getManagedMetadata(target)!\n : null\n\n if (!metadata) {\n throw new Error(\n '[Navios] Could not determine metadata for attribute target',\n )\n }\n\n if (schema) {\n const validatedValue = schema.safeParse(value)\n if (!validatedValue.success) {\n throw new Error(\n `[Navios] Invalid value for attribute ${token.toString()}: ${validatedValue.error}`,\n )\n }\n metadata.customAttributes.set(token, validatedValue.data)\n } else {\n metadata.customAttributes.set(token, true)\n }\n return target\n }\n }\n return decorator\n }\n res.token = token\n if (schema) {\n res.schema = schema\n }\n return res\n }\n\n /**\n * Gets the value of an attribute from metadata.\n *\n * Returns `null` if the attribute is not present.\n * For simple attributes (without values), returns `true` if present.\n *\n * @param attribute - The attribute decorator\n * @param target - The metadata object (module, controller, or handler)\n * @returns The attribute value, `true` for simple attributes, or `null` if not found\n *\n * @example\n * ```typescript\n * const isPublic = LegacyAttributeFactory.get(Public, controllerMetadata)\n * // isPublic is true | null\n *\n * const rateLimit = LegacyAttributeFactory.get(RateLimit, endpointMetadata)\n * // rateLimit is { requests: number, window: number } | null\n * ```\n */\n static get(\n attribute: LegacyClassAttribute,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): true | null\n static get<T extends ZodType>(\n attribute: LegacyClassSchemaAttribute<T>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): z.output<T> | null\n static get(\n attribute: LegacyClassAttribute | LegacyClassSchemaAttribute<any>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ) {\n return target.customAttributes.get(attribute.token) ?? null\n }\n\n /**\n * Gets all values of an attribute from metadata (useful when an attribute can appear multiple times).\n *\n * Returns `null` if the attribute is not present.\n *\n * @param attribute - The attribute decorator\n * @param target - The metadata object (module, controller, or handler)\n * @returns An array of attribute values, or `null` if not found\n *\n * @example\n * ```typescript\n * const tags = LegacyAttributeFactory.getAll(Tag, endpointMetadata)\n * // tags is string[] | null\n * ```\n */\n static getAll(\n attribute: LegacyClassAttribute,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): Array<true> | null\n static getAll<T extends ZodType>(\n attribute: LegacyClassSchemaAttribute<T>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): Array<z.output<T>> | null\n static getAll(\n attribute: LegacyClassAttribute | LegacyClassSchemaAttribute<any>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ) {\n const values = Array.from(target.customAttributes.entries())\n .filter(([key]) => key === attribute.token)\n .map(([, value]) => value)\n return values.length > 0 ? values : null\n }\n\n /**\n * Gets the last value of an attribute from an array of metadata objects.\n *\n * Searches from the end of the array backwards, useful for finding the most\n * specific attribute value (e.g., endpoint-level overrides module-level).\n *\n * @param attribute - The attribute decorator\n * @param target - An array of metadata objects (typically [module, controller, handler])\n * @returns The last attribute value found, or `null` if not found\n *\n * @example\n * ```typescript\n * // Check attribute hierarchy: endpoint -> controller -> module\n * const rateLimit = LegacyAttributeFactory.getLast(RateLimit, [\n * moduleMetadata,\n * controllerMetadata,\n * endpointMetadata\n * ])\n * ```\n */\n static getLast(\n attribute: LegacyClassAttribute,\n target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[],\n ): true | null\n static getLast<T extends ZodType>(\n attribute: LegacyClassSchemaAttribute<T>,\n target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[],\n ): z.output<T> | null\n static getLast(\n attribute: LegacyClassAttribute | LegacyClassSchemaAttribute<any>,\n target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[],\n ) {\n for (let i = target.length - 1; i >= 0; i--) {\n const value = target[i].customAttributes.get(attribute.token)\n if (value) {\n return value\n }\n }\n return null\n }\n\n /**\n * Checks if an attribute is present on the metadata object.\n *\n * @param attribute - The attribute decorator\n * @param target - The metadata object (module, controller, or handler)\n * @returns `true` if the attribute is present, `false` otherwise\n *\n * @example\n * ```typescript\n * if (LegacyAttributeFactory.has(Public, controllerMetadata)) {\n * // Skip authentication\n * }\n * ```\n */\n static has(\n attribute: LegacyClassAttribute,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): boolean\n static has<T extends ZodType>(\n attribute: LegacyClassSchemaAttribute<T>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ): boolean\n static has(\n attribute: LegacyClassAttribute | LegacyClassSchemaAttribute<any>,\n target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>,\n ) {\n return target.customAttributes.has(attribute.token)\n }\n}\n\n// Re-export as AttributeFactory for convenience\nexport { LegacyAttributeFactory as AttributeFactory }\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;GAuBA,SAAgBC,OACdE,UAAyB;CACvBC,aAAa,EAAE;CACfC,SAAS,EAAE;CACXC,QAAQ,EAAE;CACX,EAAA;AAED,QAAO,SAAUC,QAAiB;EAChC,MAAMC,UAAUR,qBAAmBO,OAAAA;AAEnC,SAD0BL,SAAeC,QAAAA,CAChBI,QAAQC,QAAAA;;;;;;;;;;;;;;;;;;;;;;GCTrC,SAAgBG,WAAWE,UAA6B,EAAE,EAAA;AACxD,QAAO,SAAUC,QAAiB;EAChC,MAAMC,UAAUL,qBAAmBI,OAAAA;AAEnC,SAD0BF,aAAmBC,QAAAA,CACpBC,QAAQC,QAAAA;;;;;;;;;;;;;;;;;;;;;;;;;GCoBrC,SAAgBG,SACdE,UAAwC;AAExC,QAAO,SACLC,QACAC,aACAC,YAA4C;AAE5C,MAAI,CAACA,WACH,OAAM,IAAIC,MACR,0GAAA;EAIJ,MAAMC,kBAAkBF;EACxB,MAAMG,UAAUT,sBAAoBI,QAAQC,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KAAK;GAC3C,MAAMjC,QAAQE,OAAO+B,GAAGlB,iBAAiBM,IAAIC,UAAUzB,MAAK;AAC5D,OAAIG,MACF,QAAOA;;AAGX,SAAO;;CAyBT,OAAOkC,IACLZ,WACApB,QACA;AACA,SAAOA,OAAOa,iBAAiBmB,IAAIZ,UAAUzB,MAAK"}
|
|
@@ -25,7 +25,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
const require_use_guards_decorator = require('./use-guards.decorator-
|
|
28
|
+
const require_use_guards_decorator = require('./use-guards.decorator-DtCGXcWZ.cjs');
|
|
29
29
|
let _navios_di = require("@navios/di");
|
|
30
30
|
let node_process = require("node:process");
|
|
31
31
|
let zod_v4 = require("zod/v4");
|
|
@@ -3802,6 +3802,165 @@ var InstanceResolverService = class {
|
|
|
3802
3802
|
* @deprecated Use InstanceResolverService instead
|
|
3803
3803
|
*/ const ControllerResolverService = _InstanceResolverService;
|
|
3804
3804
|
|
|
3805
|
+
//#endregion
|
|
3806
|
+
//#region src/services/abstract-handler-adapter.service.mts
|
|
3807
|
+
const defaultOptions = {
|
|
3808
|
+
adapter: [],
|
|
3809
|
+
validateResponses: true,
|
|
3810
|
+
enableRequestId: false
|
|
3811
|
+
};
|
|
3812
|
+
/**
|
|
3813
|
+
* Abstract base class for HTTP handler adapter services.
|
|
3814
|
+
*
|
|
3815
|
+
* Provides shared logic for:
|
|
3816
|
+
* - Controller resolution (singleton vs request-scoped)
|
|
3817
|
+
* - Argument formatting (sync/async detection)
|
|
3818
|
+
* - Handler generation with static/dynamic branching
|
|
3819
|
+
* - Standardized error handling
|
|
3820
|
+
*
|
|
3821
|
+
* Adapters implement abstract methods for framework-specific behavior:
|
|
3822
|
+
* - Request parsing (query, body, URL params)
|
|
3823
|
+
* - Response creation
|
|
3824
|
+
* - Schema provision
|
|
3825
|
+
*
|
|
3826
|
+
* Supports all adapter types:
|
|
3827
|
+
* - Endpoint adapters: JSON request/response with validation
|
|
3828
|
+
* - Stream adapters: Streaming responses with extra context
|
|
3829
|
+
* - Multipart adapters: Form data parsing (extends endpoint)
|
|
3830
|
+
*
|
|
3831
|
+
* @typeParam TRequest - Framework request type (BunRequest, FastifyRequest)
|
|
3832
|
+
* @typeParam TReply - Framework reply type (void for Bun, FastifyReply)
|
|
3833
|
+
* @typeParam TConfig - Endpoint configuration type
|
|
3834
|
+
*/ var AbstractHandlerAdapterService = class {
|
|
3835
|
+
instanceResolver = (0, _navios_di.inject)(_InstanceResolverService);
|
|
3836
|
+
options = (0, _navios_di.optional)(require_use_guards_decorator.NaviosOptionsToken) ?? defaultOptions;
|
|
3837
|
+
/**
|
|
3838
|
+
* Prepares argument getters for parsing request data.
|
|
3839
|
+
*
|
|
3840
|
+
* Public alias for createArgumentGetters to satisfy interface contracts.
|
|
3841
|
+
* Subclasses should override createArgumentGetters instead.
|
|
3842
|
+
*
|
|
3843
|
+
* @param handlerMetadata - Handler metadata with schemas and configuration
|
|
3844
|
+
* @returns Array of getter functions
|
|
3845
|
+
*/ prepareArguments(handlerMetadata) {
|
|
3846
|
+
return this.createArgumentGetters(handlerMetadata);
|
|
3847
|
+
}
|
|
3848
|
+
/**
|
|
3849
|
+
* Checks if the handler has any validation schemas defined.
|
|
3850
|
+
*
|
|
3851
|
+
* Override in subclasses to add additional schema checks
|
|
3852
|
+
* (e.g., response schema validation for endpoint adapters).
|
|
3853
|
+
*
|
|
3854
|
+
* @param handlerMetadata - Handler metadata with configuration
|
|
3855
|
+
* @returns true if handler has schemas
|
|
3856
|
+
*/ hasSchema(handlerMetadata) {
|
|
3857
|
+
const config = handlerMetadata.config;
|
|
3858
|
+
return !!config.requestSchema || !!config.querySchema;
|
|
3859
|
+
}
|
|
3860
|
+
/**
|
|
3861
|
+
* Provides schema information for the framework's validation system.
|
|
3862
|
+
*
|
|
3863
|
+
* Override in subclasses for frameworks that support schema registration
|
|
3864
|
+
* (e.g., Fastify). Default returns empty object (suitable for Bun).
|
|
3865
|
+
*
|
|
3866
|
+
* @param handlerMetadata - Handler metadata with configuration
|
|
3867
|
+
* @returns Schema object for framework registration
|
|
3868
|
+
*/ provideSchema(_handlerMetadata) {
|
|
3869
|
+
return {};
|
|
3870
|
+
}
|
|
3871
|
+
/**
|
|
3872
|
+
* Creates a request handler function for the endpoint.
|
|
3873
|
+
*
|
|
3874
|
+
* This method orchestrates the entire handler creation:
|
|
3875
|
+
* 1. Prepares argument getters for request parsing
|
|
3876
|
+
* 2. Builds optimized formatArguments function (sync/async)
|
|
3877
|
+
* 3. Resolves the controller (singleton vs request-scoped)
|
|
3878
|
+
* 4. Creates appropriate handler (static or dynamic)
|
|
3879
|
+
*
|
|
3880
|
+
* @param controller - Controller class containing the handler method
|
|
3881
|
+
* @param handlerMetadata - Handler metadata with configuration
|
|
3882
|
+
* @returns Handler result (static or dynamic)
|
|
3883
|
+
*/ async provideHandler(controller, handlerMetadata) {
|
|
3884
|
+
const getters = this.createArgumentGetters(handlerMetadata);
|
|
3885
|
+
const formatArguments = this.buildFormatArguments(getters);
|
|
3886
|
+
const hasArguments = getters.length > 0;
|
|
3887
|
+
const context = {
|
|
3888
|
+
methodName: handlerMetadata.classMethod,
|
|
3889
|
+
statusCode: handlerMetadata.successStatusCode,
|
|
3890
|
+
headers: handlerMetadata.headers,
|
|
3891
|
+
handlerMetadata,
|
|
3892
|
+
hasArguments
|
|
3893
|
+
};
|
|
3894
|
+
const resolution = await this.instanceResolver.resolve(controller);
|
|
3895
|
+
if (resolution.cached) {
|
|
3896
|
+
const cachedController = resolution.instance;
|
|
3897
|
+
const boundMethod = cachedController[context.methodName].bind(cachedController);
|
|
3898
|
+
return this.createStaticHandler(boundMethod, formatArguments, context);
|
|
3899
|
+
}
|
|
3900
|
+
return this.createDynamicHandler(resolution, formatArguments, context);
|
|
3901
|
+
}
|
|
3902
|
+
/**
|
|
3903
|
+
* Builds a formatArguments function from argument getters.
|
|
3904
|
+
*
|
|
3905
|
+
* Automatically detects sync vs async getters and optimizes accordingly:
|
|
3906
|
+
* - If all getters are sync: returns sync function (no Promise overhead)
|
|
3907
|
+
* - If any getter is async: returns async function with Promise.all
|
|
3908
|
+
* - If no getters: returns frozen empty object (zero allocation)
|
|
3909
|
+
*
|
|
3910
|
+
* This method is public to allow composition-based adapters (like XML adapter)
|
|
3911
|
+
* to reuse the optimized formatArguments logic without inheritance.
|
|
3912
|
+
*
|
|
3913
|
+
* @param getters - Array of argument getter functions
|
|
3914
|
+
* @returns Function to format arguments from request
|
|
3915
|
+
*/ buildFormatArguments(getters) {
|
|
3916
|
+
if (getters.length === 0) {
|
|
3917
|
+
const emptyArgs = Object.freeze({});
|
|
3918
|
+
return () => emptyArgs;
|
|
3919
|
+
}
|
|
3920
|
+
if (getters.some((g) => g.constructor.name === "AsyncFunction")) return async (request) => {
|
|
3921
|
+
const argument = {};
|
|
3922
|
+
const promises = [];
|
|
3923
|
+
for (const getter of getters) {
|
|
3924
|
+
const res = getter(argument, request);
|
|
3925
|
+
if (res instanceof Promise) promises.push(res);
|
|
3926
|
+
}
|
|
3927
|
+
await Promise.all(promises);
|
|
3928
|
+
return argument;
|
|
3929
|
+
};
|
|
3930
|
+
return (request) => {
|
|
3931
|
+
const argument = {};
|
|
3932
|
+
for (const getter of getters) getter(argument, request);
|
|
3933
|
+
return argument;
|
|
3934
|
+
};
|
|
3935
|
+
}
|
|
3936
|
+
/**
|
|
3937
|
+
* Checks if the URL pattern contains URL parameters.
|
|
3938
|
+
*
|
|
3939
|
+
* @param config - Endpoint configuration
|
|
3940
|
+
* @returns true if URL contains '$' parameter markers
|
|
3941
|
+
*/ hasUrlParams(config) {
|
|
3942
|
+
return config.url.includes("$");
|
|
3943
|
+
}
|
|
3944
|
+
/**
|
|
3945
|
+
* Wraps handler execution with standardized error handling.
|
|
3946
|
+
*
|
|
3947
|
+
* Re-throws HttpExceptions as-is for framework error handlers.
|
|
3948
|
+
* Other errors are re-thrown for global error handling.
|
|
3949
|
+
*
|
|
3950
|
+
* @param fn - Handler function to wrap
|
|
3951
|
+
* @returns Wrapped function with error handling
|
|
3952
|
+
*/ wrapWithErrorHandling(fn) {
|
|
3953
|
+
return async (...args) => {
|
|
3954
|
+
try {
|
|
3955
|
+
return await fn(...args);
|
|
3956
|
+
} catch (error) {
|
|
3957
|
+
if (error && typeof error === "object" && "statusCode" in error) throw error;
|
|
3958
|
+
throw error;
|
|
3959
|
+
}
|
|
3960
|
+
};
|
|
3961
|
+
}
|
|
3962
|
+
};
|
|
3963
|
+
|
|
3805
3964
|
//#endregion
|
|
3806
3965
|
//#region src/services/guard-runner.service.mts
|
|
3807
3966
|
function applyDecs2203RFactory$10() {
|
|
@@ -7611,6 +7770,12 @@ var NaviosApplication = class {
|
|
|
7611
7770
|
};
|
|
7612
7771
|
|
|
7613
7772
|
//#endregion
|
|
7773
|
+
Object.defineProperty(exports, 'AbstractHandlerAdapterService', {
|
|
7774
|
+
enumerable: true,
|
|
7775
|
+
get: function () {
|
|
7776
|
+
return AbstractHandlerAdapterService;
|
|
7777
|
+
}
|
|
7778
|
+
});
|
|
7614
7779
|
Object.defineProperty(exports, 'AttributeFactory', {
|
|
7615
7780
|
enumerable: true,
|
|
7616
7781
|
get: function () {
|
|
@@ -8019,4 +8184,4 @@ Object.defineProperty(exports, 'yellow', {
|
|
|
8019
8184
|
return yellow;
|
|
8020
8185
|
}
|
|
8021
8186
|
});
|
|
8022
|
-
//# sourceMappingURL=src-
|
|
8187
|
+
//# sourceMappingURL=src-CC5lmk_Q.cjs.map
|