@navios/core 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (234) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/lib/{index-BFwNx9WQ.d.cts → index-BDNl7j1G.d.cts} +666 -292
  3. package/lib/index-BDNl7j1G.d.cts.map +1 -0
  4. package/lib/{index-D657ijFO.d.mts → index-BoP0cWT6.d.mts} +666 -292
  5. package/lib/index-BoP0cWT6.d.mts.map +1 -0
  6. package/lib/index.cjs +15 -6
  7. package/lib/index.d.cts +2 -2
  8. package/lib/index.d.mts +2 -2
  9. package/lib/index.mjs +3 -3
  10. package/lib/legacy-compat/index.cjs +1 -1
  11. package/lib/legacy-compat/index.cjs.map +1 -1
  12. package/lib/legacy-compat/index.d.cts +1 -1
  13. package/lib/legacy-compat/index.d.cts.map +1 -1
  14. package/lib/legacy-compat/index.d.mts +1 -1
  15. package/lib/legacy-compat/index.d.mts.map +1 -1
  16. package/lib/legacy-compat/index.mjs +1 -1
  17. package/lib/legacy-compat/index.mjs.map +1 -1
  18. package/lib/{src-Cb1aTjl0.cjs → src-B6eISODM.cjs} +622 -114
  19. package/lib/src-B6eISODM.cjs.map +1 -0
  20. package/lib/{src-DzPY5s6d.mjs → src-gBAChVRL.mjs} +563 -73
  21. package/lib/src-gBAChVRL.mjs.map +1 -0
  22. package/lib/testing/index.cjs +6 -6
  23. package/lib/testing/index.cjs.map +1 -1
  24. package/lib/testing/index.d.cts +1 -1
  25. package/lib/testing/index.d.mts +1 -1
  26. package/lib/testing/index.mjs +2 -2
  27. package/lib/{use-guards.decorator-DdvUhB03.cjs → use-guards.decorator-COR-9mZY.cjs} +34 -108
  28. package/lib/use-guards.decorator-COR-9mZY.cjs.map +1 -0
  29. package/lib/{use-guards.decorator-kZ3lNK8v.mjs → use-guards.decorator-CUww54Nt.mjs} +14 -94
  30. package/lib/use-guards.decorator-CUww54Nt.mjs.map +1 -0
  31. package/package.json +12 -12
  32. package/src/__tests__/controller-resolver.spec.mts +223 -0
  33. package/src/__tests__/controller.spec.mts +1 -1
  34. package/src/decorators/controller.decorator.mts +11 -6
  35. package/src/decorators/endpoint.decorator.mts +60 -12
  36. package/src/decorators/multipart.decorator.mts +67 -24
  37. package/src/decorators/stream.decorator.mts +65 -24
  38. package/src/interfaces/abstract-http-adapter.interface.mts +52 -0
  39. package/src/interfaces/abstract-http-handler-adapter.interface.mts +31 -1
  40. package/src/interfaces/index.mts +1 -0
  41. package/src/interfaces/plugin.interface.mts +105 -0
  42. package/src/legacy-compat/decorators/endpoint.decorator.mts +1 -1
  43. package/src/legacy-compat/decorators/multipart.decorator.mts +1 -1
  44. package/src/legacy-compat/decorators/stream.decorator.mts +1 -1
  45. package/src/logger/logger.service.mts +3 -3
  46. package/src/navios.application.mts +91 -27
  47. package/src/navios.factory.mts +29 -9
  48. package/src/services/guard-runner.service.mts +46 -9
  49. package/src/services/index.mts +1 -0
  50. package/src/services/instance-resolver.service.mts +186 -0
  51. package/src/services/module-loader.service.mts +102 -1
  52. package/src/stores/request-id.store.mts +45 -3
  53. package/src/tokens/index.mts +1 -0
  54. package/src/tokens/navios-options.token.mts +6 -0
  55. package/lib/index-BFwNx9WQ.d.cts.map +0 -1
  56. package/lib/index-D657ijFO.d.mts.map +0 -1
  57. package/lib/src-Cb1aTjl0.cjs.map +0 -1
  58. package/lib/src-DzPY5s6d.mjs.map +0 -1
  59. package/lib/use-guards.decorator-DdvUhB03.cjs.map +0 -1
  60. package/lib/use-guards.decorator-kZ3lNK8v.mjs.map +0 -1
  61. package/src/attribute.factory.d.mts +0 -175
  62. package/src/attribute.factory.d.mts.map +0 -1
  63. package/src/config/config-service.interface.d.mts +0 -39
  64. package/src/config/config-service.interface.d.mts.map +0 -1
  65. package/src/config/config.provider.d.mts +0 -46
  66. package/src/config/config.provider.d.mts.map +0 -1
  67. package/src/config/config.service.d.mts +0 -108
  68. package/src/config/config.service.d.mts.map +0 -1
  69. package/src/config/index.d.mts +0 -6
  70. package/src/config/index.d.mts.map +0 -1
  71. package/src/config/types.d.mts +0 -13
  72. package/src/config/types.d.mts.map +0 -1
  73. package/src/config/utils/helpers.d.mts +0 -3
  74. package/src/config/utils/helpers.d.mts.map +0 -1
  75. package/src/config/utils/index.d.mts +0 -2
  76. package/src/config/utils/index.d.mts.map +0 -1
  77. package/src/decorators/controller.decorator.d.mts +0 -33
  78. package/src/decorators/controller.decorator.d.mts.map +0 -1
  79. package/src/decorators/endpoint.decorator.d.mts +0 -89
  80. package/src/decorators/endpoint.decorator.d.mts.map +0 -1
  81. package/src/decorators/header.decorator.d.mts +0 -22
  82. package/src/decorators/header.decorator.d.mts.map +0 -1
  83. package/src/decorators/http-code.decorator.d.mts +0 -22
  84. package/src/decorators/http-code.decorator.d.mts.map +0 -1
  85. package/src/decorators/index.d.mts +0 -9
  86. package/src/decorators/index.d.mts.map +0 -1
  87. package/src/decorators/module.decorator.d.mts +0 -42
  88. package/src/decorators/module.decorator.d.mts.map +0 -1
  89. package/src/decorators/multipart.decorator.d.mts +0 -54
  90. package/src/decorators/multipart.decorator.d.mts.map +0 -1
  91. package/src/decorators/stream.decorator.d.mts +0 -42
  92. package/src/decorators/stream.decorator.d.mts.map +0 -1
  93. package/src/decorators/use-guards.decorator.d.mts +0 -33
  94. package/src/decorators/use-guards.decorator.d.mts.map +0 -1
  95. package/src/exceptions/bad-request.exception.d.mts +0 -26
  96. package/src/exceptions/bad-request.exception.d.mts.map +0 -1
  97. package/src/exceptions/conflict.exception.d.mts +0 -29
  98. package/src/exceptions/conflict.exception.d.mts.map +0 -1
  99. package/src/exceptions/forbidden.exception.d.mts +0 -28
  100. package/src/exceptions/forbidden.exception.d.mts.map +0 -1
  101. package/src/exceptions/http.exception.d.mts +0 -33
  102. package/src/exceptions/http.exception.d.mts.map +0 -1
  103. package/src/exceptions/index.d.mts +0 -8
  104. package/src/exceptions/index.d.mts.map +0 -1
  105. package/src/exceptions/internal-server-error.exception.d.mts +0 -31
  106. package/src/exceptions/internal-server-error.exception.d.mts.map +0 -1
  107. package/src/exceptions/not-found.exception.d.mts +0 -30
  108. package/src/exceptions/not-found.exception.d.mts.map +0 -1
  109. package/src/exceptions/unauthorized.exception.d.mts +0 -28
  110. package/src/exceptions/unauthorized.exception.d.mts.map +0 -1
  111. package/src/factories/endpoint-adapter.factory.d.mts +0 -6
  112. package/src/factories/endpoint-adapter.factory.d.mts.map +0 -1
  113. package/src/factories/http-adapter.factory.d.mts +0 -6
  114. package/src/factories/http-adapter.factory.d.mts.map +0 -1
  115. package/src/factories/index.d.mts +0 -8
  116. package/src/factories/index.d.mts.map +0 -1
  117. package/src/factories/multipart-adapter.factory.d.mts +0 -6
  118. package/src/factories/multipart-adapter.factory.d.mts.map +0 -1
  119. package/src/factories/reply.factory.d.mts +0 -6
  120. package/src/factories/reply.factory.d.mts.map +0 -1
  121. package/src/factories/request.factory.d.mts +0 -6
  122. package/src/factories/request.factory.d.mts.map +0 -1
  123. package/src/factories/stream-adapter.factory.d.mts +0 -6
  124. package/src/factories/stream-adapter.factory.d.mts.map +0 -1
  125. package/src/factories/xml-stream-adapter.factory.d.mts +0 -6
  126. package/src/factories/xml-stream-adapter.factory.d.mts.map +0 -1
  127. package/src/index.d.mts +0 -15
  128. package/src/index.d.mts.map +0 -1
  129. package/src/interfaces/abstract-execution-context.inteface.d.mts +0 -44
  130. package/src/interfaces/abstract-execution-context.inteface.d.mts.map +0 -1
  131. package/src/interfaces/abstract-http-adapter.interface.d.mts +0 -15
  132. package/src/interfaces/abstract-http-adapter.interface.d.mts.map +0 -1
  133. package/src/interfaces/abstract-http-cors-options.interface.d.mts +0 -58
  134. package/src/interfaces/abstract-http-cors-options.interface.d.mts.map +0 -1
  135. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts +0 -7
  136. package/src/interfaces/abstract-http-handler-adapter.interface.d.mts.map +0 -1
  137. package/src/interfaces/abstract-http-listen-options.interface.d.mts +0 -5
  138. package/src/interfaces/abstract-http-listen-options.interface.d.mts.map +0 -1
  139. package/src/interfaces/can-activate.d.mts +0 -36
  140. package/src/interfaces/can-activate.d.mts.map +0 -1
  141. package/src/interfaces/http-header.d.mts +0 -10
  142. package/src/interfaces/http-header.d.mts.map +0 -1
  143. package/src/interfaces/index.d.mts +0 -9
  144. package/src/interfaces/index.d.mts.map +0 -1
  145. package/src/interfaces/navios-module.d.mts +0 -29
  146. package/src/interfaces/navios-module.d.mts.map +0 -1
  147. package/src/legacy-compat/context-compat.d.mts +0 -19
  148. package/src/legacy-compat/context-compat.d.mts.map +0 -1
  149. package/src/legacy-compat/decorators/controller.decorator.d.mts +0 -21
  150. package/src/legacy-compat/decorators/controller.decorator.d.mts.map +0 -1
  151. package/src/legacy-compat/decorators/endpoint.decorator.d.mts +0 -33
  152. package/src/legacy-compat/decorators/endpoint.decorator.d.mts.map +0 -1
  153. package/src/legacy-compat/decorators/header.decorator.d.mts +0 -24
  154. package/src/legacy-compat/decorators/header.decorator.d.mts.map +0 -1
  155. package/src/legacy-compat/decorators/http-code.decorator.d.mts +0 -22
  156. package/src/legacy-compat/decorators/http-code.decorator.d.mts.map +0 -1
  157. package/src/legacy-compat/decorators/index.d.mts +0 -9
  158. package/src/legacy-compat/decorators/index.d.mts.map +0 -1
  159. package/src/legacy-compat/decorators/module.decorator.d.mts +0 -22
  160. package/src/legacy-compat/decorators/module.decorator.d.mts.map +0 -1
  161. package/src/legacy-compat/decorators/multipart.decorator.d.mts +0 -34
  162. package/src/legacy-compat/decorators/multipart.decorator.d.mts.map +0 -1
  163. package/src/legacy-compat/decorators/stream.decorator.d.mts +0 -34
  164. package/src/legacy-compat/decorators/stream.decorator.d.mts.map +0 -1
  165. package/src/legacy-compat/decorators/use-guards.decorator.d.mts +0 -29
  166. package/src/legacy-compat/decorators/use-guards.decorator.d.mts.map +0 -1
  167. package/src/legacy-compat/index.d.mts +0 -19
  168. package/src/legacy-compat/index.d.mts.map +0 -1
  169. package/src/logger/console-logger.service.d.mts +0 -196
  170. package/src/logger/console-logger.service.d.mts.map +0 -1
  171. package/src/logger/index.d.mts +0 -7
  172. package/src/logger/index.d.mts.map +0 -1
  173. package/src/logger/log-levels.d.mts +0 -14
  174. package/src/logger/log-levels.d.mts.map +0 -1
  175. package/src/logger/logger-service.interface.d.mts +0 -36
  176. package/src/logger/logger-service.interface.d.mts.map +0 -1
  177. package/src/logger/logger.service.d.mts +0 -57
  178. package/src/logger/logger.service.d.mts.map +0 -1
  179. package/src/logger/logger.tokens.d.mts +0 -36
  180. package/src/logger/logger.tokens.d.mts.map +0 -1
  181. package/src/logger/utils/cli-colors.util.d.mts +0 -10
  182. package/src/logger/utils/cli-colors.util.d.mts.map +0 -1
  183. package/src/logger/utils/filter-log-levelts.util.d.mts +0 -6
  184. package/src/logger/utils/filter-log-levelts.util.d.mts.map +0 -1
  185. package/src/logger/utils/index.d.mts +0 -6
  186. package/src/logger/utils/index.d.mts.map +0 -1
  187. package/src/logger/utils/is-log-level-enabled.d.mts +0 -8
  188. package/src/logger/utils/is-log-level-enabled.d.mts.map +0 -1
  189. package/src/logger/utils/is-log-level.util.d.mts +0 -6
  190. package/src/logger/utils/is-log-level.util.d.mts.map +0 -1
  191. package/src/logger/utils/shared.utils.d.mts +0 -14
  192. package/src/logger/utils/shared.utils.d.mts.map +0 -1
  193. package/src/metadata/controller.metadata.d.mts +0 -13
  194. package/src/metadata/controller.metadata.d.mts.map +0 -1
  195. package/src/metadata/handler.metadata.d.mts +0 -18
  196. package/src/metadata/handler.metadata.d.mts.map +0 -1
  197. package/src/metadata/index.d.mts +0 -4
  198. package/src/metadata/index.d.mts.map +0 -1
  199. package/src/metadata/module.metadata.d.mts +0 -13
  200. package/src/metadata/module.metadata.d.mts.map +0 -1
  201. package/src/navios.application.d.mts +0 -210
  202. package/src/navios.application.d.mts.map +0 -1
  203. package/src/navios.environment.d.mts +0 -11
  204. package/src/navios.environment.d.mts.map +0 -1
  205. package/src/navios.factory.d.mts +0 -68
  206. package/src/navios.factory.d.mts.map +0 -1
  207. package/src/services/guard-runner.service.d.mts +0 -10
  208. package/src/services/guard-runner.service.d.mts.map +0 -1
  209. package/src/services/index.d.mts +0 -3
  210. package/src/services/index.d.mts.map +0 -1
  211. package/src/services/module-loader.service.d.mts +0 -17
  212. package/src/services/module-loader.service.d.mts.map +0 -1
  213. package/src/stores/index.d.mts +0 -2
  214. package/src/stores/index.d.mts.map +0 -1
  215. package/src/stores/request-id.store.d.mts +0 -37
  216. package/src/stores/request-id.store.d.mts.map +0 -1
  217. package/src/tokens/endpoint-adapter.token.d.mts +0 -4
  218. package/src/tokens/endpoint-adapter.token.d.mts.map +0 -1
  219. package/src/tokens/execution-context.token.d.mts +0 -5
  220. package/src/tokens/execution-context.token.d.mts.map +0 -1
  221. package/src/tokens/http-adapter.token.d.mts +0 -4
  222. package/src/tokens/http-adapter.token.d.mts.map +0 -1
  223. package/src/tokens/index.d.mts +0 -9
  224. package/src/tokens/index.d.mts.map +0 -1
  225. package/src/tokens/multipart-adapter.token.d.mts +0 -4
  226. package/src/tokens/multipart-adapter.token.d.mts.map +0 -1
  227. package/src/tokens/reply.token.d.mts +0 -3
  228. package/src/tokens/reply.token.d.mts.map +0 -1
  229. package/src/tokens/request.token.d.mts +0 -3
  230. package/src/tokens/request.token.d.mts.map +0 -1
  231. package/src/tokens/stream-adapter.token.d.mts +0 -4
  232. package/src/tokens/stream-adapter.token.d.mts.map +0 -1
  233. package/src/tokens/xml-stream-adapter.token.d.mts +0 -4
  234. package/src/tokens/xml-stream-adapter.token.d.mts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-guards.decorator-DdvUhB03.cjs","names":["EndpointMetadataKey","Symbol","getAllEndpointMetadata","context","metadata","Set","Error","getEndpointMetadata","target","endpointMetadata","Array","from","find","item","classMethod","name","newMetadata","url","successStatusCode","adapterToken","headers","httpMethod","config","guards","customAttributes","Map","add","getAllEndpointMetadata","ControllerMetadataKey","Symbol","getControllerMetadata","target","context","metadata","endpointsMetadata","newMetadata","endpoints","guards","Set","customAttributes","Map","Error","extractControllerMetadata","hasControllerMetadata","ModuleMetadataKey","Symbol","getModuleMetadata","target","context","metadata","newMetadata","controllers","Set","imports","guards","customAttributes","Map","Error","extractModuleMetadata","name","hasModuleMetadata","Injectable","InjectableScope","InjectionToken","getControllerMetadata","Controller","guards","target","context","kind","Error","token","create","metadata","controllerMetadata","guard","Array","from","reverse","add","scope","Request","InjectionToken","EndpointAdapterToken","create","InjectionToken","ExecutionContextInjectionToken","ExecutionContext","create","InjectionToken","HttpAdapterToken","create","InjectionToken","MultipartAdapterToken","create","InjectionToken","Reply","create","InjectionToken","Request","create","InjectionToken","StreamAdapterToken","create","InjectionToken","XmlStreamAdapterToken","create","getEndpointMetadata","EndpointAdapterToken","Endpoint","endpoint","target","context","kind","Error","config","metadata","endpointMetadata","url","method","adapterToken","classMethod","name","httpMethod","getEndpointMetadata","Header","name","value","target","context","kind","Error","metadata","headers","getEndpointMetadata","HttpCode","code","target","context","kind","Error","metadata","successStatusCode","Injectable","InjectableScope","InjectionToken","getModuleMetadata","Module","controllers","imports","guards","target","context","kind","Error","token","create","moduleMetadata","controller","add","importedModule","guard","Array","from","reverse","scope","Singleton","getEndpointMetadata","MultipartAdapterToken","Multipart","endpoint","target","context","Error","kind","config","metadata","endpointMetadata","url","method","adapterToken","classMethod","name","httpMethod","getEndpointMetadata","StreamAdapterToken","Stream","endpoint","target","context","Error","kind","config","metadata","endpointMetadata","url","method","adapterToken","classMethod","name","httpMethod","getControllerMetadata","getEndpointMetadata","UseGuards","guards","target","context","kind","controllerMetadata","guard","reverse","add","endpointMetadata","Error"],"sources":["../src/metadata/handler.metadata.mts","../src/metadata/controller.metadata.mts","../src/metadata/module.metadata.mts","../src/decorators/controller.decorator.mts","../src/tokens/endpoint-adapter.token.mts","../src/tokens/execution-context.token.mts","../src/tokens/http-adapter.token.mts","../src/tokens/multipart-adapter.token.mts","../src/tokens/reply.token.mts","../src/tokens/request.token.mts","../src/tokens/stream-adapter.token.mts","../src/tokens/xml-stream-adapter.token.mts","../src/decorators/endpoint.decorator.mts","../src/decorators/header.decorator.mts","../src/decorators/http-code.decorator.mts","../src/decorators/module.decorator.mts","../src/decorators/multipart.decorator.mts","../src/decorators/stream.decorator.mts","../src/decorators/use-guards.decorator.mts"],"sourcesContent":["import type { HttpMethod } from '@navios/builder'\nimport type { ClassTypeWithInstance, InjectionToken } from '@navios/di'\n\nimport type {\n AbstractHttpHandlerAdapterInterface,\n CanActivate,\n HttpHeader,\n} from '../interfaces/index.mjs'\n\nexport const EndpointMetadataKey = Symbol('EndpointMetadataKey')\n\nexport interface HandlerMetadata<Config = null> {\n classMethod: string\n url: string\n successStatusCode: number\n adapterToken:\n | InjectionToken<AbstractHttpHandlerAdapterInterface, undefined>\n | ClassTypeWithInstance<AbstractHttpHandlerAdapterInterface>\n | null\n headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>\n httpMethod: HttpMethod\n config: Config\n guards: Set<\n ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>\n >\n customAttributes: Map<string | symbol, any>\n}\n\nexport function getAllEndpointMetadata(\n context: ClassMethodDecoratorContext | ClassDecoratorContext,\n): Set<HandlerMetadata<any>> {\n if (context.metadata) {\n const metadata = context.metadata[EndpointMetadataKey] as\n | Set<HandlerMetadata>\n | undefined\n if (metadata) {\n return metadata\n } else {\n context.metadata[EndpointMetadataKey] = new Set<HandlerMetadata<any>>()\n return context.metadata[EndpointMetadataKey] as Set<HandlerMetadata<any>>\n }\n }\n throw new Error('[Navios] Wrong environment.')\n}\n\nexport function getEndpointMetadata<Config = any>(\n target: Function,\n context: ClassMethodDecoratorContext,\n): HandlerMetadata<Config> {\n if (context.metadata) {\n const metadata = getAllEndpointMetadata(context)\n if (metadata) {\n const endpointMetadata = Array.from(metadata).find(\n (item) => item.classMethod === target.name,\n )\n if (endpointMetadata) {\n return endpointMetadata\n } else {\n const newMetadata: HandlerMetadata<Config> = {\n classMethod: target.name,\n url: '',\n successStatusCode: 200,\n adapterToken: null,\n headers: {},\n httpMethod: 'GET',\n // @ts-expect-error We are using a generic type here\n config: null,\n guards: new Set<\n | ClassTypeWithInstance<CanActivate>\n | InjectionToken<CanActivate, undefined>\n >(),\n customAttributes: new Map<string | symbol, any>(),\n }\n metadata.add(newMetadata)\n return newMetadata\n }\n }\n }\n throw new Error('[Navios] Wrong environment.')\n}\n","import type {\n ClassType,\n ClassTypeWithInstance,\n InjectionToken,\n} from '@navios/di'\n\nimport type { CanActivate } from '../interfaces/index.mjs'\nimport type { HandlerMetadata } from './handler.metadata.mjs'\n\nimport { getAllEndpointMetadata } from './handler.metadata.mjs'\n\nexport const ControllerMetadataKey = Symbol('ControllerMetadataKey')\n\nexport interface ControllerMetadata {\n endpoints: Set<HandlerMetadata>\n guards: Set<\n ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>\n >\n customAttributes: Map<string | symbol, any>\n}\n\nexport function getControllerMetadata(\n target: ClassType,\n context: ClassDecoratorContext,\n): ControllerMetadata {\n if (context.metadata) {\n const metadata = context.metadata[ControllerMetadataKey] as\n | ControllerMetadata\n | undefined\n if (metadata) {\n return metadata\n } else {\n const endpointsMetadata = getAllEndpointMetadata(context)\n const newMetadata: ControllerMetadata = {\n endpoints: endpointsMetadata,\n guards: new Set<\n | ClassTypeWithInstance<CanActivate>\n | InjectionToken<CanActivate, undefined>\n >(),\n customAttributes: new Map<string | symbol, any>(),\n }\n context.metadata[ControllerMetadataKey] = newMetadata\n // @ts-expect-error We add a custom metadata key to the target\n target[ControllerMetadataKey] = newMetadata\n return newMetadata\n }\n }\n throw new Error('[Navios] Wrong environment.')\n}\n\nexport function extractControllerMetadata(\n target: ClassType,\n): ControllerMetadata {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[ControllerMetadataKey] as\n | ControllerMetadata\n | undefined\n if (!metadata) {\n throw new Error(\n '[Navios] Controller metadata not found. Make sure to use @Controller decorator.',\n )\n }\n return metadata\n}\n\nexport function hasControllerMetadata(target: ClassType): boolean {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[ControllerMetadataKey] as\n | ControllerMetadata\n | undefined\n return !!metadata\n}\n","import type {\n ClassType,\n ClassTypeWithInstance,\n InjectionToken,\n} from '@navios/di'\n\nimport type { CanActivate } from '../index.mjs'\n\nexport const ModuleMetadataKey = Symbol('ControllerMetadataKey')\n\nexport interface ModuleMetadata {\n controllers: Set<ClassType>\n imports: Set<ClassType>\n guards: Set<\n ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>\n >\n customAttributes: Map<string | symbol, any>\n}\n\nexport function getModuleMetadata(\n target: ClassType,\n context: ClassDecoratorContext,\n): ModuleMetadata {\n if (context.metadata) {\n const metadata = context.metadata[ModuleMetadataKey] as\n | ModuleMetadata\n | undefined\n if (metadata) {\n return metadata\n } else {\n const newMetadata: ModuleMetadata = {\n controllers: new Set<ClassType>(),\n imports: new Set<ClassType>(),\n guards: new Set<\n | ClassTypeWithInstance<CanActivate>\n | InjectionToken<CanActivate, undefined>\n >(),\n customAttributes: new Map<string | symbol, any>(),\n }\n context.metadata[ModuleMetadataKey] = newMetadata\n // @ts-expect-error We add a custom metadata key to the target\n target[ModuleMetadataKey] = newMetadata\n return newMetadata\n }\n }\n throw new Error('[Navios] Wrong environment.')\n}\n\nexport function extractModuleMetadata(target: ClassType): ModuleMetadata {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[ModuleMetadataKey] as ModuleMetadata | undefined\n if (!metadata) {\n throw new Error(\n `[Navios] Module metadata not found for ${target.name}. Make sure to use @Module decorator.`,\n )\n }\n return metadata\n}\n\nexport function hasModuleMetadata(target: ClassType): boolean {\n // @ts-expect-error We add a custom metadata key to the target\n return !!target[ModuleMetadataKey]\n}\n","import type { ClassType } from '@navios/di'\n\nimport { Injectable, InjectableScope, InjectionToken } from '@navios/di'\n\nimport { getControllerMetadata } from '../metadata/index.mjs'\n\n/**\n * Options for configuring a Navios controller.\n */\nexport interface ControllerOptions {\n /**\n * Guards to apply to all endpoints in this controller.\n * Guards are executed in reverse order (last guard first).\n */\n guards?: ClassType[] | Set<ClassType>\n}\n\n/**\n * Decorator that marks a class as a Navios controller.\n * \n * Controllers handle HTTP requests and define endpoints.\n * They are request-scoped by default, meaning a new instance is created for each request.\n * \n * @param options - Controller configuration options\n * @returns A class decorator\n * \n * @example\n * ```typescript\n * @Controller({ guards: [AuthGuard] })\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>) {\n * // Handle request\n * }\n * }\n * ```\n */\nexport function Controller({ guards }: ControllerOptions = {}) {\n return function (target: ClassType, context: ClassDecoratorContext) {\n if (context.kind !== 'class') {\n throw new Error(\n '[Navios] @Controller decorator can only be used on classes.',\n )\n }\n const token = InjectionToken.create(target)\n if (context.metadata) {\n const controllerMetadata = getControllerMetadata(target, context)\n if (guards) {\n for (const guard of Array.from(guards).reverse()) {\n controllerMetadata.guards.add(guard)\n }\n }\n }\n return Injectable({\n token,\n scope: InjectableScope.Request,\n })(target, context)\n }\n}\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpHandlerAdapterInterface } from '../interfaces/index.mjs'\n\nexport const EndpointAdapterToken =\n InjectionToken.create<AbstractHttpHandlerAdapterInterface>(\n 'EndpointAdapterToken',\n )\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractExecutionContext } from '../interfaces/index.mjs'\n\nexport const ExecutionContextInjectionToken = 'ExecutionContextInjectionToken'\n\nexport const ExecutionContext = InjectionToken.create<AbstractExecutionContext>(\n ExecutionContextInjectionToken,\n)\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpAdapterInterface } from '../interfaces/index.mjs'\n\nexport const HttpAdapterToken =\n InjectionToken.create<AbstractHttpAdapterInterface<any, any, any, any>>(\n 'HttpAdapterToken',\n )\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpHandlerAdapterInterface } from '../interfaces/index.mjs'\n\nexport const MultipartAdapterToken =\n InjectionToken.create<AbstractHttpHandlerAdapterInterface>(\n 'MultipartAdapterToken',\n )\n","import { InjectionToken } from '@navios/di'\n\nexport const Reply = InjectionToken.create<any>('ReplyToken')\n","import { InjectionToken } from '@navios/di'\n\nexport const Request = InjectionToken.create<any>('RequestToken')\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpHandlerAdapterInterface } from '../interfaces/index.mjs'\n\nexport const StreamAdapterToken =\n InjectionToken.create<AbstractHttpHandlerAdapterInterface>(\n 'StreamAdapterToken',\n )\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpHandlerAdapterInterface } from '../interfaces/index.mjs'\n\nexport const XmlStreamAdapterToken =\n InjectionToken.create<AbstractHttpHandlerAdapterInterface>(\n 'XmlStreamAdapterToken',\n )\n","import type {\n BaseEndpointConfig,\n EndpointFunctionArgs,\n HttpMethod,\n Util_FlatObject,\n} from '@navios/builder'\nimport type { z, ZodType } from 'zod/v4'\n\nimport { ZodDiscriminatedUnion } from 'zod/v4'\n\nimport { getEndpointMetadata } from '../metadata/index.mjs'\nimport { EndpointAdapterToken } from '../tokens/index.mjs'\n\n/**\n * Extracts the typed parameters for an endpoint handler function.\n *\n * This utility type extracts URL parameters, query parameters, and request body\n * from an endpoint declaration and flattens them into a single object.\n *\n * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder\n *\n * @example\n * ```typescript\n * const getUserEndpoint = api.declareEndpoint({\n * method: 'get',\n * url: '/users/$userId',\n * querySchema: z.object({ include: z.string().optional() }),\n * responseSchema: z.object({ id: z.string(), name: z.string() }),\n * })\n *\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>) {\n * // request.urlParams.userId is typed as string\n * // request.query.include is typed as string | undefined\n * }\n * ```\n */\nexport type EndpointParams<\n EndpointDeclaration extends {\n config: BaseEndpointConfig<any, any, any, any, any>\n },\n Url extends string = EndpointDeclaration['config']['url'],\n QuerySchema = EndpointDeclaration['config']['querySchema'],\n> = QuerySchema extends ZodType\n ? EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n QuerySchema,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n undefined,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>\n\n/**\n * Extracts the typed return value for an endpoint handler function.\n *\n * This utility type extracts the response schema from an endpoint declaration\n * and returns the appropriate Promise type.\n *\n * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder\n *\n * @example\n * ```typescript\n * const getUserEndpoint = api.declareEndpoint({\n * method: 'get',\n * url: '/users/$userId',\n * responseSchema: z.object({ id: z.string(), name: z.string() }),\n * })\n *\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>): EndpointResult<typeof getUserEndpoint> {\n * return { id: '1', name: 'John' } // Type-checked against responseSchema\n * }\n * ```\n */\nexport type EndpointResult<\n EndpointDeclaration extends {\n config: BaseEndpointConfig<any, any, any, any, any>\n },\n> =\n EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<\n infer Options\n >\n ? Promise<z.input<Options[number]>>\n : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>\n\n/**\n * Decorator that marks a method as an HTTP endpoint.\n *\n * The endpoint must be defined using @navios/builder's `declareEndpoint` method.\n * This ensures type safety and consistency between client and server.\n *\n * @param endpoint - The endpoint declaration from @navios/builder\n * @returns A method decorator\n *\n * @example\n * ```typescript\n * import { builder } from '@navios/builder'\n *\n * const api = builder()\n * const getUserEndpoint = api.declareEndpoint({\n * method: 'get',\n * url: '/users/$userId',\n * responseSchema: z.object({ id: z.string(), name: z.string() }),\n * })\n *\n * @Controller()\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>) {\n * const { userId } = request.urlParams\n * return { id: userId, 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 (\n target: (\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 context: ClassMethodDecoratorContext,\n ) => {\n if (context.kind !== 'method') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on methods.',\n )\n }\n const config = endpoint.config\n if (context.metadata) {\n let endpointMetadata = getEndpointMetadata<BaseEndpointConfig>(\n target,\n context,\n )\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(\n `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`,\n )\n }\n // @ts-expect-error We don't need to set correctly in the metadata\n endpointMetadata.config = config\n endpointMetadata.adapterToken = EndpointAdapterToken\n endpointMetadata.classMethod = target.name\n endpointMetadata.httpMethod = config.method\n endpointMetadata.url = config.url\n }\n return target\n }\n}\n","import type { HttpHeader } from '../interfaces/index.mjs'\n\nimport { getEndpointMetadata } from '../metadata/index.mjs'\n\n/**\n * Decorator that sets a custom HTTP response header for an endpoint.\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\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 <T extends Function>(\n target: T,\n context: ClassMethodDecoratorContext,\n ) => {\n if (context.kind !== 'method') {\n throw new Error('[Navios] Header decorator can only be used on methods.')\n }\n const metadata = getEndpointMetadata(target, context)\n\n metadata.headers[name] = value\n\n return target\n }\n}\n","import { getEndpointMetadata } from '../metadata/index.mjs'\n\n/**\n * Decorator that sets a custom HTTP status code for successful responses.\n * \n * By default, endpoints return 200 OK. Use this decorator to return a different status code.\n * \n * @param code - The HTTP status code to return (e.g., 201, 204, 202)\n * @returns A method decorator\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 <T extends Function>(\n target: T,\n context: ClassMethodDecoratorContext,\n ) => {\n if (context.kind !== 'method') {\n throw new Error(\n '[Navios] HttpCode decorator can only be used on methods.',\n )\n }\n const metadata = getEndpointMetadata(target, context)\n metadata.successStatusCode = code\n\n return target\n }\n}\n","import type { ClassType } from '@navios/di'\n\nimport { Injectable, InjectableScope, InjectionToken } from '@navios/di'\n\nimport { getModuleMetadata } from '../metadata/index.mjs'\n\n/**\n * Options for configuring a Navios module.\n */\nexport interface ModuleOptions {\n /**\n * Controllers to register in this module.\n * Controllers handle HTTP requests and define endpoints.\n */\n controllers?: ClassType[] | Set<ClassType>\n /**\n * Other modules to import into this module.\n * Imported modules' controllers and services become available.\n */\n imports?: ClassType[] | Set<ClassType>\n /**\n * Guards to apply to all controllers in this module.\n * Guards are executed in reverse order (last guard first).\n */\n guards?: ClassType[] | Set<ClassType>\n}\n\n/**\n * Decorator that marks a class as a Navios module.\n * \n * Modules are the basic building blocks of a Navios application.\n * They organize controllers, services, and other modules into logical units.\n * \n * @param options - Module configuration options\n * @returns A class decorator\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 { controllers = [], imports = [], guards = [] }: ModuleOptions = {\n controllers: [],\n imports: [],\n guards: [],\n },\n) {\n return (target: ClassType, context: ClassDecoratorContext) => {\n if (context.kind !== 'class') {\n throw new Error('[Navios] @Module decorator can only be used on classes.')\n }\n // Register the module in the service locator\n const token = InjectionToken.create(target)\n const moduleMetadata = getModuleMetadata(target, context)\n for (const controller of controllers) {\n moduleMetadata.controllers.add(controller)\n }\n for (const importedModule of imports) {\n moduleMetadata.imports.add(importedModule)\n }\n for (const guard of Array.from(guards).reverse()) {\n moduleMetadata.guards.add(guard)\n }\n\n return Injectable({\n token,\n scope: InjectableScope.Singleton,\n })(target, context)\n }\n}\n","import type {\n BaseEndpointConfig,\n EndpointFunctionArgs,\n HttpMethod,\n Util_FlatObject,\n} from '@navios/builder'\nimport type { z, ZodObject, ZodType } from 'zod/v4'\n\nimport { ZodDiscriminatedUnion } from 'zod/v4'\n\nimport { getEndpointMetadata } from '../metadata/index.mjs'\nimport { MultipartAdapterToken } from '../tokens/index.mjs'\n\n/**\n * Extracts the typed parameters for a multipart endpoint handler function.\n * \n * Similar to `EndpointParams`, but specifically for multipart/form-data endpoints.\n * \n * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder\n */\nexport type MultipartParams<\n EndpointDeclaration extends {\n config: BaseEndpointConfig<any, any, any, any, any>\n },\n Url extends string = EndpointDeclaration['config']['url'],\n QuerySchema = EndpointDeclaration['config']['querySchema'],\n> = QuerySchema extends ZodObject\n ? EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n QuerySchema,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n undefined,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>\n\n/**\n * Extracts the typed return value for a multipart endpoint handler function.\n * \n * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder\n */\nexport type MultipartResult<\n EndpointDeclaration extends {\n config: BaseEndpointConfig<any, any, any, any, any>\n },\n> =\n EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<\n infer Options\n >\n ? Promise<z.input<Options[number]>>\n : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>\n\n/**\n * Decorator that marks a method as a multipart/form-data endpoint.\n * \n * Use this decorator for endpoints that handle file uploads or form data.\n * The endpoint must be defined using @navios/builder's `declareMultipart` method.\n * \n * @param endpoint - The multipart endpoint declaration from @navios/builder\n * @returns A method decorator\n * \n * @example\n * ```typescript\n * const uploadFileEndpoint = api.declareMultipart({\n * method: 'post',\n * url: '/upload',\n * requestSchema: z.object({ file: z.instanceof(File) }),\n * responseSchema: z.object({ url: z.string() }),\n * })\n * \n * @Controller()\n * export class FileController {\n * @Multipart(uploadFileEndpoint)\n * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>) {\n * const { file } = request.data\n * // Handle file upload\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 (\n target: (\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 context: ClassMethodDecoratorContext,\n ) => {\n if (typeof target !== 'function') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on functions.',\n )\n }\n if (context.kind !== 'method') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on methods.',\n )\n }\n const config = endpoint.config\n if (context.metadata) {\n let endpointMetadata = getEndpointMetadata<BaseEndpointConfig>(\n target,\n context,\n )\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(\n `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`,\n )\n }\n // @ts-expect-error We don't need to set correctly in the metadata\n endpointMetadata.config = config\n endpointMetadata.adapterToken = MultipartAdapterToken\n endpointMetadata.classMethod = target.name\n endpointMetadata.httpMethod = config.method\n endpointMetadata.url = config.url\n }\n return target\n }\n}\n","import type {\n BaseStreamConfig,\n EndpointFunctionArgs,\n HttpMethod,\n Util_FlatObject,\n} from '@navios/builder'\nimport type { ZodObject, ZodType } from 'zod/v4'\n\nimport { getEndpointMetadata } from '../metadata/index.mjs'\nimport { StreamAdapterToken } from '../tokens/index.mjs'\n\n/**\n * Extracts the typed parameters for a stream endpoint handler function.\n * \n * Similar to `EndpointParams`, but specifically for streaming endpoints.\n * \n * @typeParam EndpointDeclaration - The stream endpoint declaration from @navios/builder\n */\nexport type StreamParams<\n EndpointDeclaration extends {\n config: BaseStreamConfig<any, any, any, any>\n },\n Url extends string = EndpointDeclaration['config']['url'],\n QuerySchema = EndpointDeclaration['config']['querySchema'],\n> = QuerySchema extends ZodObject\n ? EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n QuerySchema,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n undefined,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>\n\n/**\n * Decorator that marks a method as a streaming endpoint.\n * \n * Use this decorator for endpoints that stream data (e.g., file downloads, SSE).\n * The endpoint must be defined using @navios/builder's `declareStream` method.\n * \n * @param endpoint - The stream endpoint declaration from @navios/builder\n * @returns A method decorator\n * \n * @example\n * ```typescript\n * const downloadFileEndpoint = api.declareStream({\n * method: 'get',\n * url: '/files/$fileId',\n * })\n * \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 (\n target: (\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 context: ClassMethodDecoratorContext,\n ) => {\n if (typeof target !== 'function') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on functions.',\n )\n }\n if (context.kind !== 'method') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on methods.',\n )\n }\n const config = endpoint.config\n if (context.metadata) {\n let endpointMetadata = getEndpointMetadata<BaseStreamConfig>(\n target,\n context,\n )\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(\n `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`,\n )\n }\n // @ts-expect-error We don't need to set correctly in the metadata\n endpointMetadata.config = config\n endpointMetadata.adapterToken = StreamAdapterToken\n endpointMetadata.classMethod = target.name\n endpointMetadata.httpMethod = config.method\n endpointMetadata.url = config.url\n }\n return target\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 {\n getControllerMetadata,\n getEndpointMetadata,\n} from '../metadata/index.mjs'\n\n/**\n * Decorator that applies guards to a controller or endpoint.\n * \n * Guards are used for authentication, authorization, and request validation.\n * They implement the `CanActivate` interface and are executed before the endpoint handler.\n * Guards can be applied at the module, controller, or endpoint level.\n * \n * @param guards - Guard classes or injection tokens to apply\n * @returns A class or method decorator\n * \n * @example\n * ```typescript\n * // Apply to a controller\n * @Controller()\n * @UseGuards(AuthGuard, RoleGuard)\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * async getUser() { }\n * }\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 return function <T extends Function>(\n target: T,\n context: ClassMethodDecoratorContext | ClassDecoratorContext,\n ): T {\n if (context.kind === 'class') {\n const controllerMetadata = getControllerMetadata(\n target as unknown as ClassType,\n context,\n )\n for (const guard of guards.reverse()) {\n controllerMetadata.guards.add(guard)\n }\n } else if (context.kind === 'method') {\n const endpointMetadata = getEndpointMetadata(target, context)\n for (const guard of guards.reverse()) {\n endpointMetadata.guards.add(guard)\n }\n } else {\n throw new Error(\n '[Navios] @UseGuards decorator can only be used on classes or methods.',\n )\n }\n return target\n }\n}\n"],"mappings":";;;;AASA,MAAaA,sBAAsBC,OAAO,sBAAA;AAmB1C,SAAgBC,uBACdC,SAA4D;AAE5D,KAAIA,QAAQC,UAAU;EACpB,MAAMA,WAAW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pointMetadata","context","metadata","Set","Error","getEndpointMetadata","target","endpointMetadata","Array","from","find","item","classMethod","name","newMetadata","url","successStatusCode","adapterToken","headers","httpMethod","config","guards","customAttributes","Map","add","getAllEndpointMetadata","ControllerMetadataKey","Symbol","getControllerMetadata","target","context","metadata","endpointsMetadata","newMetadata","endpoints","guards","Set","customAttributes","Map","Error","extractControllerMetadata","hasControllerMetadata","ModuleMetadataKey","Symbol","getModuleMetadata","target","context","metadata","newMetadata","controllers","Set","imports","guards","customAttributes","Map","Error","extractModuleMetadata","name","hasModuleMetadata","Injectable","InjectableScope","InjectionToken","getControllerMetadata","Controller","guards","target","context","kind","Error","token","create","metadata","controllerMetadata","guard","Array","from","reverse","add","scope","Request","InjectionToken","EndpointAdapterToken","create","InjectionToken","ExecutionContextInjectionToken","ExecutionContext","create","InjectionToken","HttpAdapterToken","create","InjectionToken","MultipartAdapterToken","create","InjectionToken","Reply","create","InjectionToken","Request","create","InjectionToken","StreamAdapterToken","create","InjectionToken","XmlStreamAdapterToken","create","getEndpointMetadata","EndpointAdapterToken","Endpoint","endpoint","target","context","kind","Error","config","metadata","endpointMetadata","url","method","adapterToken","classMethod","name","httpMethod","getEndpointMetadata","Header","name","value","target","context","kind","Error","metadata","headers","getEndpointMetadata","HttpCode","code","target","context","kind","Error","metadata","successStatusCode","Injectable","InjectableScope","InjectionToken","getModuleMetadata","Module","controllers","imports","guards","target","context","kind","Error","token","create","moduleMetadata","controller","add","importedModule","guard","Array","from","reverse","scope","Singleton","getEndpointMetadata","MultipartAdapterToken","Multipart","endpoint","target","context","Error","kind","config","metadata","endpointMetadata","url","method","adapterToken","classMethod","name","httpMethod","getEndpointMetadata","StreamAdapterToken","Stream","endpoint","target","context","Error","kind","config","metadata","endpointMetadata","url","method","adapterToken","classMethod","name","httpMethod","getControllerMetadata","getEndpointMetadata","UseGuards","guards","target","context","kind","controllerMetadata","guard","reverse","add","endpointMetadata","Error"],"sources":["../src/metadata/handler.metadata.mts","../src/metadata/controller.metadata.mts","../src/metadata/module.metadata.mts","../src/decorators/controller.decorator.mts","../src/tokens/endpoint-adapter.token.mts","../src/tokens/execution-context.token.mts","../src/tokens/http-adapter.token.mts","../src/tokens/multipart-adapter.token.mts","../src/tokens/reply.token.mts","../src/tokens/request.token.mts","../src/tokens/stream-adapter.token.mts","../src/tokens/xml-stream-adapter.token.mts","../src/decorators/endpoint.decorator.mts","../src/decorators/header.decorator.mts","../src/decorators/http-code.decorator.mts","../src/decorators/module.decorator.mts","../src/decorators/multipart.decorator.mts","../src/decorators/stream.decorator.mts","../src/decorators/use-guards.decorator.mts"],"sourcesContent":["import type { HttpMethod } from '@navios/builder'\nimport type { ClassTypeWithInstance, InjectionToken } from '@navios/di'\n\nimport type {\n AbstractHttpHandlerAdapterInterface,\n CanActivate,\n HttpHeader,\n} from '../interfaces/index.mjs'\n\nexport const EndpointMetadataKey = Symbol('EndpointMetadataKey')\n\nexport interface HandlerMetadata<Config = null> {\n classMethod: string\n url: string\n successStatusCode: number\n adapterToken:\n | InjectionToken<AbstractHttpHandlerAdapterInterface, undefined>\n | ClassTypeWithInstance<AbstractHttpHandlerAdapterInterface>\n | null\n headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>\n httpMethod: HttpMethod\n config: Config\n guards: Set<\n ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>\n >\n customAttributes: Map<string | symbol, any>\n}\n\nexport function getAllEndpointMetadata(\n context: ClassMethodDecoratorContext | ClassDecoratorContext,\n): Set<HandlerMetadata<any>> {\n if (context.metadata) {\n const metadata = context.metadata[EndpointMetadataKey] as\n | Set<HandlerMetadata>\n | undefined\n if (metadata) {\n return metadata\n } else {\n context.metadata[EndpointMetadataKey] = new Set<HandlerMetadata<any>>()\n return context.metadata[EndpointMetadataKey] as Set<HandlerMetadata<any>>\n }\n }\n throw new Error('[Navios] Wrong environment.')\n}\n\nexport function getEndpointMetadata<Config = any>(\n target: Function,\n context: ClassMethodDecoratorContext,\n): HandlerMetadata<Config> {\n if (context.metadata) {\n const metadata = getAllEndpointMetadata(context)\n if (metadata) {\n const endpointMetadata = Array.from(metadata).find(\n (item) => item.classMethod === target.name,\n )\n if (endpointMetadata) {\n return endpointMetadata\n } else {\n const newMetadata: HandlerMetadata<Config> = {\n classMethod: target.name,\n url: '',\n successStatusCode: 200,\n adapterToken: null,\n headers: {},\n httpMethod: 'GET',\n // @ts-expect-error We are using a generic type here\n config: null,\n guards: new Set<\n | ClassTypeWithInstance<CanActivate>\n | InjectionToken<CanActivate, undefined>\n >(),\n customAttributes: new Map<string | symbol, any>(),\n }\n metadata.add(newMetadata)\n return newMetadata\n }\n }\n }\n throw new Error('[Navios] Wrong environment.')\n}\n","import type {\n ClassType,\n ClassTypeWithInstance,\n InjectionToken,\n} from '@navios/di'\n\nimport type { CanActivate } from '../interfaces/index.mjs'\nimport type { HandlerMetadata } from './handler.metadata.mjs'\n\nimport { getAllEndpointMetadata } from './handler.metadata.mjs'\n\nexport const ControllerMetadataKey = Symbol('ControllerMetadataKey')\n\nexport interface ControllerMetadata {\n endpoints: Set<HandlerMetadata>\n guards: Set<\n ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>\n >\n customAttributes: Map<string | symbol, any>\n}\n\nexport function getControllerMetadata(\n target: ClassType,\n context: ClassDecoratorContext,\n): ControllerMetadata {\n if (context.metadata) {\n const metadata = context.metadata[ControllerMetadataKey] as\n | ControllerMetadata\n | undefined\n if (metadata) {\n return metadata\n } else {\n const endpointsMetadata = getAllEndpointMetadata(context)\n const newMetadata: ControllerMetadata = {\n endpoints: endpointsMetadata,\n guards: new Set<\n | ClassTypeWithInstance<CanActivate>\n | InjectionToken<CanActivate, undefined>\n >(),\n customAttributes: new Map<string | symbol, any>(),\n }\n context.metadata[ControllerMetadataKey] = newMetadata\n // @ts-expect-error We add a custom metadata key to the target\n target[ControllerMetadataKey] = newMetadata\n return newMetadata\n }\n }\n throw new Error('[Navios] Wrong environment.')\n}\n\nexport function extractControllerMetadata(\n target: ClassType,\n): ControllerMetadata {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[ControllerMetadataKey] as\n | ControllerMetadata\n | undefined\n if (!metadata) {\n throw new Error(\n '[Navios] Controller metadata not found. Make sure to use @Controller decorator.',\n )\n }\n return metadata\n}\n\nexport function hasControllerMetadata(target: ClassType): boolean {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[ControllerMetadataKey] as\n | ControllerMetadata\n | undefined\n return !!metadata\n}\n","import type {\n ClassType,\n ClassTypeWithInstance,\n InjectionToken,\n} from '@navios/di'\n\nimport type { CanActivate } from '../index.mjs'\n\nexport const ModuleMetadataKey = Symbol('ControllerMetadataKey')\n\nexport interface ModuleMetadata {\n controllers: Set<ClassType>\n imports: Set<ClassType>\n guards: Set<\n ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>\n >\n customAttributes: Map<string | symbol, any>\n}\n\nexport function getModuleMetadata(\n target: ClassType,\n context: ClassDecoratorContext,\n): ModuleMetadata {\n if (context.metadata) {\n const metadata = context.metadata[ModuleMetadataKey] as\n | ModuleMetadata\n | undefined\n if (metadata) {\n return metadata\n } else {\n const newMetadata: ModuleMetadata = {\n controllers: new Set<ClassType>(),\n imports: new Set<ClassType>(),\n guards: new Set<\n | ClassTypeWithInstance<CanActivate>\n | InjectionToken<CanActivate, undefined>\n >(),\n customAttributes: new Map<string | symbol, any>(),\n }\n context.metadata[ModuleMetadataKey] = newMetadata\n // @ts-expect-error We add a custom metadata key to the target\n target[ModuleMetadataKey] = newMetadata\n return newMetadata\n }\n }\n throw new Error('[Navios] Wrong environment.')\n}\n\nexport function extractModuleMetadata(target: ClassType): ModuleMetadata {\n // @ts-expect-error We add a custom metadata key to the target\n const metadata = target[ModuleMetadataKey] as ModuleMetadata | undefined\n if (!metadata) {\n throw new Error(\n `[Navios] Module metadata not found for ${target.name}. Make sure to use @Module decorator.`,\n )\n }\n return metadata\n}\n\nexport function hasModuleMetadata(target: ClassType): boolean {\n // @ts-expect-error We add a custom metadata key to the target\n return !!target[ModuleMetadataKey]\n}\n","import type { ClassType } from '@navios/di'\n\nimport { Injectable, InjectableScope, InjectionToken } from '@navios/di'\n\nimport { getControllerMetadata } from '../metadata/index.mjs'\n\n/**\n * Options for configuring a Navios controller.\n */\nexport interface ControllerOptions {\n /**\n * Guards to apply to all endpoints in this controller.\n * Guards are executed in reverse order (last guard first).\n */\n guards?: ClassType[] | Set<ClassType>\n}\n\n/**\n * Decorator that marks a class as a Navios controller.\n * \n * Controllers handle HTTP requests and define endpoints.\n * They are request-scoped by default, meaning a new instance is created for each request.\n * \n * @param options - Controller configuration options\n * @returns A class decorator\n * \n * @example\n * ```typescript\n * @Controller({ guards: [AuthGuard] })\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>) {\n * // Handle request\n * }\n * }\n * ```\n */\nexport function Controller({ guards }: ControllerOptions = {}) {\n return function (target: ClassType, context: ClassDecoratorContext) {\n if (context.kind !== 'class') {\n throw new Error(\n '[Navios] @Controller decorator can only be used on classes.',\n )\n }\n const token = InjectionToken.create(target)\n if (context.metadata) {\n const controllerMetadata = getControllerMetadata(target, context)\n if (guards) {\n for (const guard of Array.from(guards).reverse()) {\n controllerMetadata.guards.add(guard)\n }\n }\n }\n return Injectable({\n token,\n scope: InjectableScope.Request,\n })(target, context)\n }\n}\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpHandlerAdapterInterface } from '../interfaces/index.mjs'\n\nexport const EndpointAdapterToken =\n InjectionToken.create<AbstractHttpHandlerAdapterInterface>(\n 'EndpointAdapterToken',\n )\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractExecutionContext } from '../interfaces/index.mjs'\n\nexport const ExecutionContextInjectionToken = 'ExecutionContextInjectionToken'\n\nexport const ExecutionContext = InjectionToken.create<AbstractExecutionContext>(\n ExecutionContextInjectionToken,\n)\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpAdapterInterface } from '../interfaces/index.mjs'\n\nexport const HttpAdapterToken =\n InjectionToken.create<AbstractHttpAdapterInterface<any, any, any, any>>(\n 'HttpAdapterToken',\n )\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpHandlerAdapterInterface } from '../interfaces/index.mjs'\n\nexport const MultipartAdapterToken =\n InjectionToken.create<AbstractHttpHandlerAdapterInterface>(\n 'MultipartAdapterToken',\n )\n","import { InjectionToken } from '@navios/di'\n\nexport const Reply = InjectionToken.create<any>('ReplyToken')\n","import { InjectionToken } from '@navios/di'\n\nexport const Request = InjectionToken.create<any>('RequestToken')\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpHandlerAdapterInterface } from '../interfaces/index.mjs'\n\nexport const StreamAdapterToken =\n InjectionToken.create<AbstractHttpHandlerAdapterInterface>(\n 'StreamAdapterToken',\n )\n","import { InjectionToken } from '@navios/di'\n\nimport type { AbstractHttpHandlerAdapterInterface } from '../interfaces/index.mjs'\n\nexport const XmlStreamAdapterToken =\n InjectionToken.create<AbstractHttpHandlerAdapterInterface>(\n 'XmlStreamAdapterToken',\n )\n","import type {\n BaseEndpointConfig,\n EndpointFunctionArgs,\n HttpMethod,\n Util_FlatObject,\n} from '@navios/builder'\nimport type { z, ZodType } from 'zod/v4'\n\nimport { ZodDiscriminatedUnion } from 'zod/v4'\n\nimport { getEndpointMetadata } from '../metadata/index.mjs'\nimport { EndpointAdapterToken } from '../tokens/index.mjs'\n\n/**\n * Extracts the typed parameters for an endpoint handler function.\n *\n * This utility type extracts URL parameters, query parameters, and request body\n * from an endpoint declaration and flattens them into a single object.\n *\n * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder\n *\n * @example\n * ```typescript\n * const getUserEndpoint = api.declareEndpoint({\n * method: 'get',\n * url: '/users/$userId',\n * querySchema: z.object({ include: z.string().optional() }),\n * responseSchema: z.object({ id: z.string(), name: z.string() }),\n * })\n *\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>) {\n * // request.urlParams.userId is typed as string\n * // request.query.include is typed as string | undefined\n * }\n * ```\n */\nexport type EndpointParams<\n EndpointDeclaration extends {\n config: BaseEndpointConfig<any, any, any, any, any>\n },\n Url extends string = EndpointDeclaration['config']['url'],\n QuerySchema = EndpointDeclaration['config']['querySchema'],\n> = QuerySchema extends ZodType\n ? EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n QuerySchema,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n undefined,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>\n\n/**\n * Extracts the typed return value for an endpoint handler function.\n *\n * This utility type extracts the response schema from an endpoint declaration\n * and returns the appropriate Promise type.\n *\n * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder\n *\n * @example\n * ```typescript\n * const getUserEndpoint = api.declareEndpoint({\n * method: 'get',\n * url: '/users/$userId',\n * responseSchema: z.object({ id: z.string(), name: z.string() }),\n * })\n *\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>): EndpointResult<typeof getUserEndpoint> {\n * return { id: '1', name: 'John' } // Type-checked against responseSchema\n * }\n * ```\n */\nexport type EndpointResult<\n EndpointDeclaration extends {\n config: BaseEndpointConfig<any, any, any, any, any>\n },\n> =\n EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<\n infer Options\n >\n ? Promise<z.input<Options[number]>>\n : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>\n\n/**\n * Decorator that marks a method as an HTTP endpoint.\n *\n * The endpoint must be defined using @navios/builder's `declareEndpoint` method.\n * This ensures type safety and consistency between client and server.\n *\n * @param endpoint - The endpoint declaration from @navios/builder\n * @returns A method decorator\n *\n * @example\n * ```typescript\n * import { builder } from '@navios/builder'\n *\n * const api = builder()\n * const getUserEndpoint = api.declareEndpoint({\n * method: 'get',\n * url: '/users/$userId',\n * responseSchema: z.object({ id: z.string(), name: z.string() }),\n * })\n *\n * @Controller()\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * async getUser(request: EndpointParams<typeof getUserEndpoint>) {\n * const { userId } = request.urlParams\n * return { id: userId, 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 (\n target: (\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 context: ClassMethodDecoratorContext,\n ) => {\n if (context.kind !== 'method') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on methods.',\n )\n }\n const config = endpoint.config\n if (context.metadata) {\n let endpointMetadata = getEndpointMetadata<BaseEndpointConfig>(\n target,\n context,\n )\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(\n `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`,\n )\n }\n // @ts-expect-error We don't need to set correctly in the metadata\n endpointMetadata.config = config\n endpointMetadata.adapterToken = EndpointAdapterToken\n endpointMetadata.classMethod = target.name\n endpointMetadata.httpMethod = config.method\n endpointMetadata.url = config.url\n }\n return target\n }\n}\n","import type { HttpHeader } from '../interfaces/index.mjs'\n\nimport { getEndpointMetadata } from '../metadata/index.mjs'\n\n/**\n * Decorator that sets a custom HTTP response header for an endpoint.\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\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 <T extends Function>(\n target: T,\n context: ClassMethodDecoratorContext,\n ) => {\n if (context.kind !== 'method') {\n throw new Error('[Navios] Header decorator can only be used on methods.')\n }\n const metadata = getEndpointMetadata(target, context)\n\n metadata.headers[name] = value\n\n return target\n }\n}\n","import { getEndpointMetadata } from '../metadata/index.mjs'\n\n/**\n * Decorator that sets a custom HTTP status code for successful responses.\n * \n * By default, endpoints return 200 OK. Use this decorator to return a different status code.\n * \n * @param code - The HTTP status code to return (e.g., 201, 204, 202)\n * @returns A method decorator\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 <T extends Function>(\n target: T,\n context: ClassMethodDecoratorContext,\n ) => {\n if (context.kind !== 'method') {\n throw new Error(\n '[Navios] HttpCode decorator can only be used on methods.',\n )\n }\n const metadata = getEndpointMetadata(target, context)\n metadata.successStatusCode = code\n\n return target\n }\n}\n","import type { ClassType } from '@navios/di'\n\nimport { Injectable, InjectableScope, InjectionToken } from '@navios/di'\n\nimport { getModuleMetadata } from '../metadata/index.mjs'\n\n/**\n * Options for configuring a Navios module.\n */\nexport interface ModuleOptions {\n /**\n * Controllers to register in this module.\n * Controllers handle HTTP requests and define endpoints.\n */\n controllers?: ClassType[] | Set<ClassType>\n /**\n * Other modules to import into this module.\n * Imported modules' controllers and services become available.\n */\n imports?: ClassType[] | Set<ClassType>\n /**\n * Guards to apply to all controllers in this module.\n * Guards are executed in reverse order (last guard first).\n */\n guards?: ClassType[] | Set<ClassType>\n}\n\n/**\n * Decorator that marks a class as a Navios module.\n * \n * Modules are the basic building blocks of a Navios application.\n * They organize controllers, services, and other modules into logical units.\n * \n * @param options - Module configuration options\n * @returns A class decorator\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 { controllers = [], imports = [], guards = [] }: ModuleOptions = {\n controllers: [],\n imports: [],\n guards: [],\n },\n) {\n return (target: ClassType, context: ClassDecoratorContext) => {\n if (context.kind !== 'class') {\n throw new Error('[Navios] @Module decorator can only be used on classes.')\n }\n // Register the module in the service locator\n const token = InjectionToken.create(target)\n const moduleMetadata = getModuleMetadata(target, context)\n for (const controller of controllers) {\n moduleMetadata.controllers.add(controller)\n }\n for (const importedModule of imports) {\n moduleMetadata.imports.add(importedModule)\n }\n for (const guard of Array.from(guards).reverse()) {\n moduleMetadata.guards.add(guard)\n }\n\n return Injectable({\n token,\n scope: InjectableScope.Singleton,\n })(target, context)\n }\n}\n","import type {\n BaseEndpointConfig,\n EndpointFunctionArgs,\n HttpMethod,\n Util_FlatObject,\n} from '@navios/builder'\nimport type { z, ZodObject, ZodType } from 'zod/v4'\n\nimport { ZodDiscriminatedUnion } from 'zod/v4'\n\nimport { getEndpointMetadata } from '../metadata/index.mjs'\nimport { MultipartAdapterToken } from '../tokens/index.mjs'\n\n/**\n * Extracts the typed parameters for a multipart endpoint handler function.\n * \n * Similar to `EndpointParams`, but specifically for multipart/form-data endpoints.\n * \n * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder\n */\nexport type MultipartParams<\n EndpointDeclaration extends {\n config: BaseEndpointConfig<any, any, any, any, any>\n },\n Url extends string = EndpointDeclaration['config']['url'],\n QuerySchema = EndpointDeclaration['config']['querySchema'],\n> = QuerySchema extends ZodObject\n ? EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n QuerySchema,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n undefined,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>\n\n/**\n * Extracts the typed return value for a multipart endpoint handler function.\n * \n * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder\n */\nexport type MultipartResult<\n EndpointDeclaration extends {\n config: BaseEndpointConfig<any, any, any, any, any>\n },\n> =\n EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<\n infer Options\n >\n ? Promise<z.input<Options[number]>>\n : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>\n\n/**\n * Decorator that marks a method as a multipart/form-data endpoint.\n * \n * Use this decorator for endpoints that handle file uploads or form data.\n * The endpoint must be defined using @navios/builder's `declareMultipart` method.\n * \n * @param endpoint - The multipart endpoint declaration from @navios/builder\n * @returns A method decorator\n * \n * @example\n * ```typescript\n * const uploadFileEndpoint = api.declareMultipart({\n * method: 'post',\n * url: '/upload',\n * requestSchema: z.object({ file: z.instanceof(File) }),\n * responseSchema: z.object({ url: z.string() }),\n * })\n * \n * @Controller()\n * export class FileController {\n * @Multipart(uploadFileEndpoint)\n * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>) {\n * const { file } = request.data\n * // Handle file upload\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 (\n target: (\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 context: ClassMethodDecoratorContext,\n ) => {\n if (typeof target !== 'function') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on functions.',\n )\n }\n if (context.kind !== 'method') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on methods.',\n )\n }\n const config = endpoint.config\n if (context.metadata) {\n let endpointMetadata = getEndpointMetadata<BaseEndpointConfig>(\n target,\n context,\n )\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(\n `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`,\n )\n }\n // @ts-expect-error We don't need to set correctly in the metadata\n endpointMetadata.config = config\n endpointMetadata.adapterToken = MultipartAdapterToken\n endpointMetadata.classMethod = target.name\n endpointMetadata.httpMethod = config.method\n endpointMetadata.url = config.url\n }\n return target\n }\n}\n","import type {\n BaseStreamConfig,\n EndpointFunctionArgs,\n HttpMethod,\n Util_FlatObject,\n} from '@navios/builder'\nimport type { ZodObject, ZodType } from 'zod/v4'\n\nimport { getEndpointMetadata } from '../metadata/index.mjs'\nimport { StreamAdapterToken } from '../tokens/index.mjs'\n\n/**\n * Extracts the typed parameters for a stream endpoint handler function.\n * \n * Similar to `EndpointParams`, but specifically for streaming endpoints.\n * \n * @typeParam EndpointDeclaration - The stream endpoint declaration from @navios/builder\n */\nexport type StreamParams<\n EndpointDeclaration extends {\n config: BaseStreamConfig<any, any, any, any>\n },\n Url extends string = EndpointDeclaration['config']['url'],\n QuerySchema = EndpointDeclaration['config']['querySchema'],\n> = QuerySchema extends ZodObject\n ? EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n QuerySchema,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>>\n : EndpointDeclaration['config']['requestSchema'] extends ZodType\n ? Util_FlatObject<\n EndpointFunctionArgs<\n Url,\n undefined,\n EndpointDeclaration['config']['requestSchema'],\n true\n >\n >\n : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>\n\n/**\n * Decorator that marks a method as a streaming endpoint.\n * \n * Use this decorator for endpoints that stream data (e.g., file downloads, SSE).\n * The endpoint must be defined using @navios/builder's `declareStream` method.\n * \n * @param endpoint - The stream endpoint declaration from @navios/builder\n * @returns A method decorator\n * \n * @example\n * ```typescript\n * const downloadFileEndpoint = api.declareStream({\n * method: 'get',\n * url: '/files/$fileId',\n * })\n * \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 (\n target: (\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 context: ClassMethodDecoratorContext,\n ) => {\n if (typeof target !== 'function') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on functions.',\n )\n }\n if (context.kind !== 'method') {\n throw new Error(\n '[Navios] Endpoint decorator can only be used on methods.',\n )\n }\n const config = endpoint.config\n if (context.metadata) {\n let endpointMetadata = getEndpointMetadata<BaseStreamConfig>(\n target,\n context,\n )\n if (endpointMetadata.config && endpointMetadata.config.url) {\n throw new Error(\n `[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`,\n )\n }\n // @ts-expect-error We don't need to set correctly in the metadata\n endpointMetadata.config = config\n endpointMetadata.adapterToken = StreamAdapterToken\n endpointMetadata.classMethod = target.name\n endpointMetadata.httpMethod = config.method\n endpointMetadata.url = config.url\n }\n return target\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 {\n getControllerMetadata,\n getEndpointMetadata,\n} from '../metadata/index.mjs'\n\n/**\n * Decorator that applies guards to a controller or endpoint.\n * \n * Guards are used for authentication, authorization, and request validation.\n * They implement the `CanActivate` interface and are executed before the endpoint handler.\n * Guards can be applied at the module, controller, or endpoint level.\n * \n * @param guards - Guard classes or injection tokens to apply\n * @returns A class or method decorator\n * \n * @example\n * ```typescript\n * // Apply to a controller\n * @Controller()\n * @UseGuards(AuthGuard, RoleGuard)\n * export class UserController {\n * @Endpoint(getUserEndpoint)\n * async getUser() { }\n * }\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 return function <T extends Function>(\n target: T,\n context: ClassMethodDecoratorContext | ClassDecoratorContext,\n ): T {\n if (context.kind === 'class') {\n const controllerMetadata = getControllerMetadata(\n target as unknown as ClassType,\n context,\n )\n for (const guard of guards.reverse()) {\n controllerMetadata.guards.add(guard)\n }\n } else if (context.kind === 'method') {\n const endpointMetadata = getEndpointMetadata(target, context)\n for (const guard of guards.reverse()) {\n endpointMetadata.guards.add(guard)\n }\n } else {\n throw new Error(\n '[Navios] @UseGuards decorator can only be used on classes or methods.',\n )\n }\n return target\n }\n}\n"],"mappings":";;;AASA,MAAaA,sBAAsBC,OAAO,sBAAA;AAmB1C,SAAgBC,uBACdC,SAA4D;AAE5D,KAAIA,QAAQC,UAAU;EACpB,MAAMA,WAAWD,QAAQC,SAASJ;AAGlC,MAAII,SACF,QAAOA;OACF;AACLD,WAAQC,SAASJ,uCAAuB,IAAIK,KAAAA;AAC5C,UAAOF,QAAQC,SAASJ;;;AAG5B,OAAM,IAAIM,MAAM,8BAAA;;AAGlB,SAAgBC,oBACdC,QACAL,SAAoC;AAEpC,KAAIA,QAAQC,UAAU;EACpB,MAAMA,WAAWF,uBAAuBC,QAAAA;AACxC,MAAIC,UAAU;GACZ,MAAMK,mBAAmBC,MAAMC,KAAKP,SAAAA,CAAUQ,MAC3CC,SAASA,KAAKC,gBAAgBN,OAAOO,KAAI;AAE5C,OAAIN,iBACF,QAAOA;QACF;IACL,MAAMO,cAAuC;KAC3CF,aAAaN,OAAOO;KACpBE,KAAK;KACLC,mBAAmB;KACnBC,cAAc;KACdC,SAAS,EAAC;KACVC,YAAY;KAEZC,QAAQ;KACRC,wBAAQ,IAAIlB,KAAAA;KAIZmB,kCAAkB,IAAIC,KAAAA;KACxB;AACArB,aAASsB,IAAIV,YAAAA;AACb,WAAOA;;;;AAIb,OAAM,IAAIV,MAAM,8BAAA;;;;;ACnElB,MAAasB,wBAAwBC,OAAO,wBAAA;AAU5C,SAAgBC,sBACdC,QACAC,SAA8B;AAE9B,KAAIA,QAAQC,UAAU;EACpB,MAAMA,WAAWD,QAAQC,SAASL;AAGlC,MAAIK,SACF,QAAOA;OACF;GAEL,MAAME,cAAkC;IACtCC,WAFwBT,uBAAuBK,QAAAA;IAG/CK,wBAAQ,IAAIC,KAAAA;IAIZC,kCAAkB,IAAIC,KAAAA;IACxB;AACAR,WAAQC,SAASL,yBAAyBO;AAE1CJ,UAAOH,yBAAyBO;AAChC,UAAOA;;;AAGX,O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M,SAAO,CAChCE,kBAAiBR,OAAOO,IAAIF,MAAAA;QAG9B,OAAM,IAAII,MACR,wEAAA;AAGJ,SAAOR"}
@@ -1,175 +0,0 @@
1
- import type { z, ZodType } from 'zod/v4';
2
- import type { ControllerMetadata, HandlerMetadata, ModuleMetadata } from './metadata/index.mjs';
3
- /**
4
- * Type for a class attribute decorator without a value.
5
- *
6
- * Attributes are custom metadata decorators that can be applied to modules,
7
- * controllers, and endpoints.
8
- */
9
- export type ClassAttribute = (() => <T>(target: T, context: ClassDecoratorContext | ClassMethodDecoratorContext) => T) & {
10
- token: symbol;
11
- };
12
- /**
13
- * Type for a class attribute decorator with a validated value.
14
- *
15
- * @typeParam T - The Zod schema type for validation
16
- */
17
- export type ClassSchemaAttribute<T extends ZodType> = ((value: z.input<T>) => <T>(target: T, context: ClassDecoratorContext | ClassMethodDecoratorContext) => T) & {
18
- token: symbol;
19
- schema: ZodType;
20
- };
21
- /**
22
- * Factory for creating custom attribute decorators.
23
- *
24
- * Attributes allow you to add custom metadata to modules, controllers, and endpoints.
25
- * This is useful for cross-cutting concerns like rate limiting, caching, API versioning, etc.
26
- *
27
- * @example
28
- * ```typescript
29
- * // Create a simple boolean attribute
30
- * const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
31
- *
32
- * // Use it as a decorator
33
- * @Controller()
34
- * @Public()
35
- * export class PublicController { }
36
- *
37
- * // Check if attribute exists
38
- * if (AttributeFactory.has(Public, controllerMetadata)) {
39
- * // Skip authentication
40
- * }
41
- * ```
42
- *
43
- * @example
44
- * ```typescript
45
- * // Create an attribute with a validated value
46
- * const RateLimit = AttributeFactory.createAttribute(
47
- * Symbol.for('RateLimit'),
48
- * z.object({ requests: z.number(), window: z.number() })
49
- * )
50
- *
51
- * // Use it with a value
52
- * @Endpoint(apiEndpoint)
53
- * @RateLimit({ requests: 100, window: 60000 })
54
- * async handler() { }
55
- *
56
- * // Get the value
57
- * const limit = AttributeFactory.get(RateLimit, endpointMetadata)
58
- * // limit is typed as { requests: number, window: number } | null
59
- * ```
60
- */
61
- export declare class AttributeFactory {
62
- /**
63
- * Creates a simple attribute decorator without a value.
64
- *
65
- * @param token - A unique symbol to identify this attribute
66
- * @returns A decorator function that can be applied to classes or methods
67
- *
68
- * @example
69
- * ```typescript
70
- * const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
71
- *
72
- * @Public()
73
- * @Controller()
74
- * export class PublicController { }
75
- * ```
76
- */
77
- static createAttribute(token: symbol): ClassAttribute;
78
- /**
79
- * Creates an attribute decorator with a validated value.
80
- *
81
- * @param token - A unique symbol to identify this attribute
82
- * @param schema - A Zod schema to validate the attribute value
83
- * @returns A decorator function that accepts a value and can be applied to classes or methods
84
- *
85
- * @example
86
- * ```typescript
87
- * const RateLimit = AttributeFactory.createAttribute(
88
- * Symbol.for('RateLimit'),
89
- * z.object({ requests: z.number(), window: z.number() })
90
- * )
91
- *
92
- * @RateLimit({ requests: 100, window: 60000 })
93
- * @Endpoint(apiEndpoint)
94
- * async handler() { }
95
- * ```
96
- */
97
- static createAttribute<T extends ZodType>(token: symbol, schema: T): ClassSchemaAttribute<T>;
98
- /**
99
- * Gets the value of an attribute from metadata.
100
- *
101
- * Returns `null` if the attribute is not present.
102
- * For simple attributes (without values), returns `true` if present.
103
- *
104
- * @param attribute - The attribute decorator
105
- * @param target - The metadata object (module, controller, or handler)
106
- * @returns The attribute value, `true` for simple attributes, or `null` if not found
107
- *
108
- * @example
109
- * ```typescript
110
- * const isPublic = AttributeFactory.get(Public, controllerMetadata)
111
- * // isPublic is true | null
112
- *
113
- * const rateLimit = AttributeFactory.get(RateLimit, endpointMetadata)
114
- * // rateLimit is { requests: number, window: number } | null
115
- * ```
116
- */
117
- static get(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): true | null;
118
- static get<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): z.output<T> | null;
119
- /**
120
- * Gets all values of an attribute from metadata (useful when an attribute can appear multiple times).
121
- *
122
- * Returns `null` if the attribute is not present.
123
- *
124
- * @param attribute - The attribute decorator
125
- * @param target - The metadata object (module, controller, or handler)
126
- * @returns An array of attribute values, or `null` if not found
127
- *
128
- * @example
129
- * ```typescript
130
- * const tags = AttributeFactory.getAll(Tag, endpointMetadata)
131
- * // tags is string[] | null
132
- * ```
133
- */
134
- static getAll(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<true> | null;
135
- static getAll<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<z.output<T>> | null;
136
- /**
137
- * Gets the last value of an attribute from an array of metadata objects.
138
- *
139
- * Searches from the end of the array backwards, useful for finding the most
140
- * specific attribute value (e.g., endpoint-level overrides module-level).
141
- *
142
- * @param attribute - The attribute decorator
143
- * @param target - An array of metadata objects (typically [module, controller, handler])
144
- * @returns The last attribute value found, or `null` if not found
145
- *
146
- * @example
147
- * ```typescript
148
- * // Check attribute hierarchy: endpoint -> controller -> module
149
- * const rateLimit = AttributeFactory.getLast(RateLimit, [
150
- * moduleMetadata,
151
- * controllerMetadata,
152
- * endpointMetadata
153
- * ])
154
- * ```
155
- */
156
- static getLast(attribute: ClassAttribute, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): true | null;
157
- static getLast<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): z.output<T> | null;
158
- /**
159
- * Checks if an attribute is present on the metadata object.
160
- *
161
- * @param attribute - The attribute decorator
162
- * @param target - The metadata object (module, controller, or handler)
163
- * @returns `true` if the attribute is present, `false` otherwise
164
- *
165
- * @example
166
- * ```typescript
167
- * if (AttributeFactory.has(Public, controllerMetadata)) {
168
- * // Skip authentication
169
- * }
170
- * ```
171
- */
172
- static has(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
173
- static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
174
- }
175
- //# sourceMappingURL=attribute.factory.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"attribute.factory.d.mts","sourceRoot":"","sources":["attribute.factory.mts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,CAAC,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAExC,OAAO,KAAK,EACV,kBAAkB,EAClB,eAAe,EACf,cAAc,EACf,MAAM,sBAAsB,CAAA;AAU7B;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,MAAM,CAAC,CAAC,EACpC,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,qBAAqB,GAAG,2BAA2B,KACzD,CAAC,CAAC,GAAG;IACR,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,CAAC,CAAC,SAAS,OAAO,IAAI,CAAC,CACrD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KACd,CAAC,CAAC,EACL,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,qBAAqB,GAAG,2BAA2B,KACzD,CAAC,CAAC,GAAG;IACR,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,OAAO,CAAA;CAChB,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,qBAAa,gBAAgB;IAC3B;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc;IACrD;;;;;;;;;;;;;;;;;;OAkBG;IACH,MAAM,CAAC,eAAe,CAAC,CAAC,SAAS,OAAO,EACtC,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,CAAC,GACR,oBAAoB,CAAC,CAAC,CAAC;IAgD1B;;;;;;;;;;;;;;;;;;OAkBG;IACH,M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,CAAC,GAAG,CACR,SAAS,EAAE,cAAc,EACzB,MAAM,EAAE,cAAc,GAAG,kBAAkB,GAAG,eAAe,CAAC,GAAG,CAAC,GACjE,OAAO;IACV,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,OAAO,EAC1B,SAAS,EAAE,oBAAoB,CAAC,CAAC,CAAC,EAClC,MAAM,EAAE,cAAc,GAAG,kBAAkB,GAAG,eAAe,CAAC,GAAG,CAAC,GACjE,OAAO;CAOX"}
@@ -1,39 +0,0 @@
1
- import type { Path, PathValue } from './types.mjs';
2
- /**
3
- * Interface for configuration service implementations.
4
- *
5
- * Provides type-safe access to configuration values with support for nested paths.
6
- *
7
- * @typeParam Config - The configuration object type
8
- */
9
- export interface ConfigServiceInterface<Config = Record<string, unknown>> {
10
- /**
11
- * Gets the entire configuration object.
12
- */
13
- getConfig: () => Config;
14
- /**
15
- * Gets a configuration value by key path. Returns `null` if not found.
16
- *
17
- * @param key - Dot-separated path to the configuration value (e.g., 'database.host')
18
- * @returns The configuration value or `null` if not found
19
- */
20
- get: <Key extends Path<Config>>(key: Key) => PathValue<Config, Key> | null;
21
- /**
22
- * Gets a configuration value by key path, or returns a default value if not found.
23
- *
24
- * @param key - Dot-separated path to the configuration value
25
- * @param defaultValue - Default value to return if the key is not found
26
- * @returns The configuration value or the default value
27
- */
28
- getOrDefault: <Key extends Path<Config>>(key: Key, defaultValue: PathValue<Config, Key>) => PathValue<Config, Key>;
29
- /**
30
- * Gets a configuration value by key path, or throws an error if not found.
31
- *
32
- * @param key - Dot-separated path to the configuration value
33
- * @param errorMessage - Optional custom error message
34
- * @returns The configuration value
35
- * @throws Error if the key is not found
36
- */
37
- getOrThrow: <Key extends Path<Config>>(key: Key, errorMessage?: string) => PathValue<Config, Key>;
38
- }
39
- //# sourceMappingURL=config-service.interface.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-service.interface.d.mts","sourceRoot":"","sources":["config-service.interface.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAElD;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACtE;;OAEG;IACH,SAAS,EAAE,MAAM,MAAM,CAAA;IACvB;;;;;OAKG;IACH,GAAG,EAAE,CAAC,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,KAAK,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAA;IAE1E;;;;;;OAMG;IACH,YAAY,EAAE,CAAC,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,EACrC,GAAG,EAAE,GAAG,EACR,YAAY,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,KACjC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAE3B;;;;;;;OAOG;IACH,UAAU,EAAE,CAAC,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,EACnC,GAAG,EAAE,GAAG,EACR,YAAY,CAAC,EAAE,MAAM,KAClB,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5B"}
@@ -1,46 +0,0 @@
1
- import { FactoryInjectionToken } from '@navios/di';
2
- import { z } from 'zod/v4';
3
- import type { ConfigServiceOptions } from './config.service.mjs';
4
- import { ConfigService, ConfigServiceOptionsSchema } from './config.service.mjs';
5
- /**
6
- * Schema for configuration provider options.
7
- */
8
- export declare const ConfigProviderOptions: z.ZodObject<{
9
- load: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
10
- }, z.core.$strip>;
11
- /**
12
- * Creates a factory injection token for ConfigService that loads configuration asynchronously.
13
- *
14
- * Use this when you need to load configuration from a file, database, or other async source.
15
- *
16
- * @param options - Configuration provider options
17
- * @param options.load - Async function that loads and returns the configuration object
18
- * @returns A factory injection token for ConfigService
19
- *
20
- * @example
21
- * ```typescript
22
- * const MyConfigService = provideConfig({
23
- * load: async () => {
24
- * const config = await loadConfigFromFile('config.json')
25
- * return config
26
- * },
27
- * })
28
- *
29
- * // Use in module setup
30
- * container.bind(ConfigServiceToken).toFactory(configProvider)
31
- * ```
32
- */
33
- export declare function provideConfig<ConfigMap extends ConfigServiceOptions>(options: z.input<typeof ConfigProviderOptions>): FactoryInjectionToken<ConfigService<ConfigMap>, typeof ConfigServiceOptionsSchema>;
34
- /**
35
- * Pre-configured ConfigService provider that uses environment variables.
36
- *
37
- * Provides a ConfigService instance bound to `process.env`.
38
- *
39
- * @example
40
- * ```typescript
41
- * // Use environment variables as configuration
42
- * container.bind(ConfigServiceToken).toValue(EnvConfigProvider)
43
- * ```
44
- */
45
- export declare const EnvConfigProvider: import("@navios/di").BoundInjectionToken<ConfigService<Record<string, string>>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
46
- //# sourceMappingURL=config.provider.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.provider.d.mts","sourceRoot":"","sources":["config.provider.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAkB,MAAM,YAAY,CAAA;AAElE,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAA;AAEhE,OAAO,EACL,aAAa,EACb,0BAA0B,EAE3B,MAAM,sBAAsB,CAAA;AAE7B;;GAEG;AACH,eAAO,MAAM,qBAAqB;;iBAEhC,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,SAAS,SAAS,oBAAoB,EAClE,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,GAC7C,qBAAqB,CACtB,aAAa,CAAC,SAAS,CAAC,EACxB,OAAO,0BAA0B,CAClC,CAEA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,yHAK5B,CAAA"}
@@ -1,108 +0,0 @@
1
- import { InjectionToken } from '@navios/di';
2
- import { z } from 'zod/v4';
3
- import type { ConfigServiceInterface as IConfigService } from './config-service.interface.mjs';
4
- import type { Path, PathValue } from './types.mjs';
5
- /**
6
- * Schema for validating configuration service options.
7
- */
8
- export declare const ConfigServiceOptionsSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
9
- /**
10
- * Type for configuration service options.
11
- */
12
- export type ConfigServiceOptions = z.infer<typeof ConfigServiceOptionsSchema>;
13
- /**
14
- * Injection token for ConfigService.
15
- */
16
- export declare const ConfigServiceToken: InjectionToken<IConfigService<Record<string, unknown>>, z.ZodRecord<z.ZodString, z.ZodUnknown>, true>;
17
- /**
18
- * Service for managing application configuration with type-safe access.
19
- *
20
- * Provides methods to access configuration values using dot-notation paths
21
- * with full TypeScript type inference.
22
- *
23
- * @typeParam Config - The configuration object type
24
- *
25
- * @example
26
- * ```typescript
27
- * interface AppConfig {
28
- * database: {
29
- * host: string
30
- * port: number
31
- * }
32
- * api: {
33
- * timeout: number
34
- * }
35
- * }
36
- *
37
- * @Injectable()
38
- * export class DatabaseService {
39
- * private config = inject(MyConfigService)
40
- *
41
- * connect() {
42
- * const host = this.config.getOrThrow('database.host')
43
- * const port = this.config.getOrDefault('database.port', 5432)
44
- * // host is typed as string, port is typed as number
45
- * }
46
- * }
47
- * ```
48
- */
49
- export declare class ConfigService<Config extends ConfigServiceOptions = Record<string, unknown>> implements IConfigService<Config> {
50
- private config;
51
- private readonly logger;
52
- /**
53
- * Creates a new ConfigService instance.
54
- *
55
- * @param config - The configuration object
56
- */
57
- constructor(config?: Config);
58
- /**
59
- * Gets the entire configuration object.
60
- *
61
- * @returns The complete configuration object
62
- */
63
- getConfig(): Config;
64
- /**
65
- * Gets a configuration value by key path.
66
- *
67
- * Returns `null` if the key is not found or if any part of the path is invalid.
68
- *
69
- * @param key - Dot-separated path to the configuration value (e.g., 'database.host')
70
- * @returns The configuration value or `null` if not found
71
- *
72
- * @example
73
- * ```typescript
74
- * const host = config.get('database.host') // string | null
75
- * const port = config.get('database.port') // number | null
76
- * ```
77
- */
78
- get<Key extends Path<Config>>(key: Key): PathValue<Config, Key> | null;
79
- /**
80
- * Gets a configuration value by key path, or returns a default value if not found.
81
- *
82
- * @param key - Dot-separated path to the configuration value
83
- * @param defaultValue - Default value to return if the key is not found
84
- * @returns The configuration value or the default value
85
- *
86
- * @example
87
- * ```typescript
88
- * const port = config.getOrDefault('database.port', 5432) // number
89
- * ```
90
- */
91
- getOrDefault<Key extends Path<Config>>(key: Key, defaultValue: PathValue<Config, Key>): PathValue<Config, Key>;
92
- /**
93
- * Gets a configuration value by key path, or throws an error if not found.
94
- *
95
- * @param key - Dot-separated path to the configuration value
96
- * @param errorMessage - Optional custom error message
97
- * @returns The configuration value
98
- * @throws Error if the key is not found
99
- *
100
- * @example
101
- * ```typescript
102
- * const host = config.getOrThrow('database.host') // string (throws if not found)
103
- * const apiKey = config.getOrThrow('api.key', 'API key is required') // string
104
- * ```
105
- */
106
- getOrThrow<Key extends Path<Config>>(key: Key, errorMessage?: string): PathValue<Config, Key>;
107
- }
108
- //# sourceMappingURL=config.service.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.service.d.mts","sourceRoot":"","sources":["config.service.mts"],"names":[],"mappings":"AACA,OAAO,EAAsB,cAAc,EAAE,MAAM,YAAY,CAAA;AAE/D,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAA;AAE1B,OAAO,KAAK,EAAE,sBAAsB,IAAI,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAC9F,OAAO,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAIlD;;GAEG;AACH,eAAO,MAAM,0BAA0B,wCAAoC,CAAA;AAC3E;;GAEG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAE7E;;GAEG;AACH,eAAO,MAAM,kBAAkB,uGAG2B,CAAA;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qBAGa,aAAa,CACxB,MAAM,SAAS,oBAAoB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAC7D,YAAW,cAAc,CAAC,MAAM,CAAC;IAUrB,OAAO,CAAC,MAAM;IAT1B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAErB;IAEF;;;;OAIG;gBACiB,MAAM,GAAE,MAAqB;IAEjD;;;;OAIG;IACH,SAAS,IAAI,MAAM;IAInB;;;;;;;;;;;;;OAaG;IACH,GAAG,CAAC,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,EAAE,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;IA0BtE;;;;;;;;;;;OAWG;IACH,YAAY,CAAC,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,EACnC,GAAG,EAAE,GAAG,EACR,YAAY,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC,GACnC,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;IAKzB;;;;;;;;;;;;;OAaG;IACH,UAAU,CAAC,GAAG,SAAS,IAAI,CAAC,MAAM,CAAC,EACjC,GAAG,EAAE,GAAG,EACR,YAAY,CAAC,EAAE,MAAM,GACpB,SAAS,CAAC,MAAM,EAAE,GAAG,CAAC;CAa1B"}
@@ -1,6 +0,0 @@
1
- export * from './utils/index.mjs';
2
- export * from './config.provider.mjs';
3
- export * from './config.service.mjs';
4
- export * from './config-service.interface.mjs';
5
- export * from './types.mjs';
6
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["index.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AACpC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,aAAa,CAAA"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Evaluates to `true` if `T` is `any`. `false` otherwise.
3
- * (c) https://stackoverflow.com/a/68633327/5290447
4
- */
5
- type IsAny<T> = unknown extends T ? [keyof T] extends [never] ? false : true : false;
6
- type ExcludedParts = 'services' | 'mailer' | 'aws' | 'computedTimeRates' | 'aiModelsRates';
7
- type ExcludedKeys = 'computedTimeRates' | 'aiModelsRates' | 'aiModel';
8
- export type PathImpl<T, Key extends keyof T> = Key extends string ? Key extends ExcludedKeys ? never : IsAny<T[Key]> extends true ? never : T[Key] extends string ? never : T[Key] extends any[] ? never : T[Key] extends Record<string, any> ? Key extends ExcludedParts ? `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never;
9
- export type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
10
- export type Path<T> = keyof T extends string ? PathImpl2<T> extends infer P ? P extends string | keyof T ? P : keyof T : keyof T : never;
11
- export type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
12
-
13
- //# sourceMappingURL=types.d.mts.map