@navios/core 1.1.0 → 2.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/CHANGELOG.md +53 -11
  2. package/README.md +67 -220
  3. package/lib/async-context-6pdlnNLA.d.mts +237 -0
  4. package/lib/async-context-6pdlnNLA.d.mts.map +1 -0
  5. package/lib/async-context-Dqk7pE-D.d.cts +237 -0
  6. package/lib/async-context-Dqk7pE-D.d.cts.map +1 -0
  7. package/lib/attribute-factory-B3VuYnp7.d.cts +70 -0
  8. package/lib/attribute-factory-B3VuYnp7.d.cts.map +1 -0
  9. package/lib/attribute-factory-mKOXoVnV.d.mts +70 -0
  10. package/lib/attribute-factory-mKOXoVnV.d.mts.map +1 -0
  11. package/lib/attribute-value-CjX9ZkLq.cjs +172 -0
  12. package/lib/attribute-value-CjX9ZkLq.cjs.map +1 -0
  13. package/lib/attribute-value-DMEA255r.mjs +119 -0
  14. package/lib/attribute-value-DMEA255r.mjs.map +1 -0
  15. package/lib/basic-execution-context-CeGuhMOz.mjs +246 -0
  16. package/lib/basic-execution-context-CeGuhMOz.mjs.map +1 -0
  17. package/lib/basic-execution-context-DSk5MNtc.cjs +281 -0
  18. package/lib/basic-execution-context-DSk5MNtc.cjs.map +1 -0
  19. package/lib/execution-context-BPD3FeFb.d.mts +71 -0
  20. package/lib/execution-context-BPD3FeFb.d.mts.map +1 -0
  21. package/lib/execution-context-BTJdHhbf.d.cts +71 -0
  22. package/lib/execution-context-BTJdHhbf.d.cts.map +1 -0
  23. package/lib/execution-context-token-BXUKB2hf.cjs +112 -0
  24. package/lib/execution-context-token-BXUKB2hf.cjs.map +1 -0
  25. package/lib/execution-context-token-CrXmTvk2.mjs +77 -0
  26. package/lib/execution-context-token-CrXmTvk2.mjs.map +1 -0
  27. package/lib/index.cjs +1687 -4424
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +838 -3
  30. package/lib/index.d.cts.map +1 -0
  31. package/lib/index.d.mts +838 -3
  32. package/lib/index.d.mts.map +1 -0
  33. package/lib/index.mjs +1573 -4219
  34. package/lib/index.mjs.map +1 -1
  35. package/lib/legacy-compat/index.cjs +72 -371
  36. package/lib/legacy-compat/index.cjs.map +1 -1
  37. package/lib/legacy-compat/index.d.cts +42 -382
  38. package/lib/legacy-compat/index.d.cts.map +1 -1
  39. package/lib/legacy-compat/index.d.mts +41 -382
  40. package/lib/legacy-compat/index.d.mts.map +1 -1
  41. package/lib/legacy-compat/index.mjs +51 -345
  42. package/lib/legacy-compat/index.mjs.map +1 -1
  43. package/lib/module-Bha7GER_.mjs +135 -0
  44. package/lib/module-Bha7GER_.mjs.map +1 -0
  45. package/lib/module-DZewk_2r.cjs +164 -0
  46. package/lib/module-DZewk_2r.cjs.map +1 -0
  47. package/lib/module-graph-DCP9MHG0.cjs +147 -0
  48. package/lib/module-graph-DCP9MHG0.cjs.map +1 -0
  49. package/lib/module-graph-xvVEykFM.mjs +142 -0
  50. package/lib/module-graph-xvVEykFM.mjs.map +1 -0
  51. package/lib/module-metadata-C8S92seK.cjs +95 -0
  52. package/lib/module-metadata-C8S92seK.cjs.map +1 -0
  53. package/lib/module-metadata-k3RTt20x.mjs +66 -0
  54. package/lib/module-metadata-k3RTt20x.mjs.map +1 -0
  55. package/lib/module-options-Dmse0gii.d.mts +51 -0
  56. package/lib/module-options-Dmse0gii.d.mts.map +1 -0
  57. package/lib/module-options-IuDO-p8u.d.cts +51 -0
  58. package/lib/module-options-IuDO-p8u.d.cts.map +1 -0
  59. package/lib/testing/index.cjs +96 -414
  60. package/lib/testing/index.cjs.map +1 -1
  61. package/lib/testing/index.d.cts +25 -385
  62. package/lib/testing/index.d.cts.map +1 -1
  63. package/lib/testing/index.d.mts +24 -385
  64. package/lib/testing/index.d.mts.map +1 -1
  65. package/lib/testing/index.mjs +94 -408
  66. package/lib/testing/index.mjs.map +1 -1
  67. package/lib/transport.cjs +25 -0
  68. package/lib/transport.d.cts +190 -0
  69. package/lib/transport.d.cts.map +1 -0
  70. package/lib/transport.d.mts +190 -0
  71. package/lib/transport.d.mts.map +1 -0
  72. package/lib/transport.mjs +7 -0
  73. package/package.json +37 -17
  74. package/docs/README.md +0 -316
  75. package/docs/adapters.md +0 -308
  76. package/docs/application-setup.md +0 -524
  77. package/docs/attributes.md +0 -689
  78. package/docs/controllers.md +0 -373
  79. package/docs/endpoints.md +0 -444
  80. package/docs/exceptions.md +0 -352
  81. package/docs/guards.md +0 -550
  82. package/docs/legacy-compat.md +0 -356
  83. package/docs/modules.md +0 -377
  84. package/docs/quick-start.md +0 -290
  85. package/docs/services.md +0 -427
  86. package/docs/testing.md +0 -827
  87. package/lib/index-3LcTrbxz.d.mts +0 -3804
  88. package/lib/index-3LcTrbxz.d.mts.map +0 -1
  89. package/lib/index-B14SekVb.d.cts +0 -3804
  90. package/lib/index-B14SekVb.d.cts.map +0 -1
  91. package/lib/navios.factory-CUrO_p6K.cjs +0 -4538
  92. package/lib/navios.factory-CUrO_p6K.cjs.map +0 -1
  93. package/lib/navios.factory-DjUOOVVL.mjs +0 -4151
  94. package/lib/navios.factory-DjUOOVVL.mjs.map +0 -1
  95. package/lib/tokens-BEuBMGGX.cjs +0 -193
  96. package/lib/tokens-BEuBMGGX.cjs.map +0 -1
  97. package/lib/tokens-COyNGV1I.mjs +0 -97
  98. package/lib/tokens-COyNGV1I.mjs.map +0 -1
  99. package/lib/use-guards.decorator-DLmRl2CV.mjs +0 -336
  100. package/lib/use-guards.decorator-DLmRl2CV.mjs.map +0 -1
  101. package/lib/use-guards.decorator-DhumFTk3.cjs +0 -444
  102. package/lib/use-guards.decorator-DhumFTk3.cjs.map +0 -1
  103. package/project.json +0 -66
  104. package/src/__tests__/attribute.factory.spec.mts +0 -300
  105. package/src/__tests__/config.service.spec.mts +0 -43
  106. package/src/__tests__/console-logger.service.spec.mts +0 -312
  107. package/src/__tests__/controller-resolver.spec.mts +0 -229
  108. package/src/__tests__/controller.spec.mts +0 -58
  109. package/src/__tests__/guard-runner.service.spec.mts +0 -399
  110. package/src/__tests__/logger.service.spec.mts +0 -147
  111. package/src/__tests__/responders.spec.mts +0 -340
  112. package/src/__tests__/testing-module.spec.mts +0 -459
  113. package/src/__tests__/unit-testing-module.spec.mts +0 -424
  114. package/src/attribute.factory.mts +0 -325
  115. package/src/config/config-service.interface.mts +0 -47
  116. package/src/config/config.provider.mts +0 -69
  117. package/src/config/config.service.mts +0 -176
  118. package/src/config/index.mts +0 -5
  119. package/src/config/types.mts +0 -58
  120. package/src/config/utils/helpers.mts +0 -23
  121. package/src/config/utils/index.mts +0 -1
  122. package/src/decorators/controller.decorator.mts +0 -81
  123. package/src/decorators/endpoint.decorator.mts +0 -181
  124. package/src/decorators/header.decorator.mts +0 -38
  125. package/src/decorators/http-code.decorator.mts +0 -38
  126. package/src/decorators/index.mts +0 -8
  127. package/src/decorators/module.decorator.mts +0 -106
  128. package/src/decorators/multipart.decorator.mts +0 -169
  129. package/src/decorators/stream.decorator.mts +0 -155
  130. package/src/decorators/use-guards.decorator.mts +0 -73
  131. package/src/exceptions/bad-request.exception.mts +0 -28
  132. package/src/exceptions/conflict.exception.mts +0 -31
  133. package/src/exceptions/forbidden.exception.mts +0 -30
  134. package/src/exceptions/http.exception.mts +0 -33
  135. package/src/exceptions/index.mts +0 -7
  136. package/src/exceptions/internal-server-error.exception.mts +0 -33
  137. package/src/exceptions/not-found.exception.mts +0 -33
  138. package/src/exceptions/unauthorized.exception.mts +0 -30
  139. package/src/factories/adapter.factory.mts +0 -20
  140. package/src/factories/endpoint-adapter.factory.mts +0 -21
  141. package/src/factories/http-adapter.factory.mts +0 -20
  142. package/src/factories/index.mts +0 -8
  143. package/src/factories/multipart-adapter.factory.mts +0 -21
  144. package/src/factories/reply.factory.mts +0 -21
  145. package/src/factories/request.factory.mts +0 -21
  146. package/src/factories/stream-adapter.factory.mts +0 -20
  147. package/src/factories/xml-stream-adapter.factory.mts +0 -20
  148. package/src/index.mts +0 -16
  149. package/src/interfaces/abstract-adapter.interface.mts +0 -32
  150. package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
  151. package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
  152. package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
  153. package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
  154. package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
  155. package/src/interfaces/adapter-environment.interface.mts +0 -74
  156. package/src/interfaces/can-activate.mts +0 -38
  157. package/src/interfaces/http-header.mts +0 -18
  158. package/src/interfaces/index.mts +0 -14
  159. package/src/interfaces/navios-module.mts +0 -28
  160. package/src/interfaces/plugin-context.mts +0 -104
  161. package/src/interfaces/plugin-stage.mts +0 -62
  162. package/src/interfaces/plugin.interface.mts +0 -119
  163. package/src/interfaces/staged-plugin.interface.mts +0 -209
  164. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  165. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  166. package/src/legacy-compat/attribute.factory.mts +0 -351
  167. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  168. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  169. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  170. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  171. package/src/legacy-compat/decorators/index.mts +0 -11
  172. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  173. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  174. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  175. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  176. package/src/legacy-compat/index.mts +0 -57
  177. package/src/logger/README.md +0 -3
  178. package/src/logger/console-logger.service.mts +0 -714
  179. package/src/logger/index.mts +0 -6
  180. package/src/logger/log-levels.mts +0 -21
  181. package/src/logger/logger-service.interface.mts +0 -42
  182. package/src/logger/logger.service.mts +0 -113
  183. package/src/logger/logger.tokens.mts +0 -44
  184. package/src/logger/utils/cli-colors.util.mts +0 -17
  185. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  186. package/src/logger/utils/index.mts +0 -5
  187. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  188. package/src/logger/utils/is-log-level.util.mts +0 -10
  189. package/src/logger/utils/shared.utils.mts +0 -51
  190. package/src/metadata/controller.metadata.mts +0 -79
  191. package/src/metadata/handler.metadata.mts +0 -80
  192. package/src/metadata/index.mts +0 -4
  193. package/src/metadata/module.metadata.mts +0 -116
  194. package/src/metadata/navios-managed.metadata.mts +0 -42
  195. package/src/navios.application.mts +0 -678
  196. package/src/navios.environment.mts +0 -42
  197. package/src/navios.factory.mts +0 -158
  198. package/src/responders/enums/framework-error.enum.mts +0 -38
  199. package/src/responders/enums/index.mts +0 -1
  200. package/src/responders/index.mts +0 -4
  201. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  202. package/src/responders/interfaces/error-response.interface.mts +0 -22
  203. package/src/responders/interfaces/index.mts +0 -3
  204. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  205. package/src/responders/services/error-response-producer.service.mts +0 -143
  206. package/src/responders/services/forbidden-responder.service.mts +0 -77
  207. package/src/responders/services/index.mts +0 -5
  208. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  209. package/src/responders/services/not-found-responder.service.mts +0 -76
  210. package/src/responders/services/validation-error-responder.service.mts +0 -78
  211. package/src/responders/tokens/index.mts +0 -1
  212. package/src/responders/tokens/responder.tokens.mts +0 -84
  213. package/src/services/abstract-handler-adapter.service.mts +0 -366
  214. package/src/services/guard-runner.service.mts +0 -152
  215. package/src/services/index.mts +0 -4
  216. package/src/services/instance-resolver.service.mts +0 -177
  217. package/src/services/module-loader.service.mts +0 -255
  218. package/src/stores/index.mts +0 -1
  219. package/src/stores/request-id.store.mts +0 -85
  220. package/src/testing/index.mts +0 -3
  221. package/src/testing/testing-module.mts +0 -393
  222. package/src/testing/unit-testing-module.mts +0 -298
  223. package/src/tokens/adapter.token.mts +0 -6
  224. package/src/tokens/endpoint-adapter.token.mts +0 -8
  225. package/src/tokens/execution-context.token.mts +0 -9
  226. package/src/tokens/http-adapter.token.mts +0 -8
  227. package/src/tokens/index.mts +0 -10
  228. package/src/tokens/multipart-adapter.token.mts +0 -8
  229. package/src/tokens/navios-options.token.mts +0 -6
  230. package/src/tokens/reply.token.mts +0 -3
  231. package/src/tokens/request.token.mts +0 -3
  232. package/src/tokens/stream-adapter.token.mts +0 -8
  233. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  234. package/src/utils/adapter-supports.util.mts +0 -47
  235. package/src/utils/define-plugin.mts +0 -251
  236. package/src/utils/index.mts +0 -2
  237. package/tsconfig.json +0 -21
  238. package/tsconfig.lib.json +0 -8
  239. package/tsconfig.spec.json +0 -15
  240. package/tsdown.config.mts +0 -35
  241. package/vitest.config.mts +0 -15
@@ -1,3804 +0,0 @@
1
- import * as _navios_di0 from "@navios/di";
2
- import { AnyInjectableType, BoundInjectionToken, ClassType, ClassTypeWithArgument, ClassTypeWithInstance, Container, FactoryContext, FactoryInjectionToken, InjectableScope, InjectionToken, InjectionTokenSchemaType, Registry, ScopedContainer } from "@navios/di";
3
- import z, { ZodDiscriminatedUnion, ZodObject, ZodType, z as z$1 } from "zod/v4";
4
- import { BaseEndpointOptions, EndpointHandler, EndpointOptions, HttpMethod, RequestArgs, StreamHandler } from "@navios/builder";
5
- import { InspectOptions } from "util";
6
- import { OutgoingHttpHeaders } from "http";
7
-
8
- //#region src/config/utils/helpers.d.mts
9
- declare function envInt(key: keyof NodeJS.ProcessEnv, defaultValue: number): number;
10
- declare function envString<DefaultValue extends string | undefined, Ensured = (DefaultValue extends string ? true : false)>(key: keyof NodeJS.ProcessEnv, defaultValue?: DefaultValue): Ensured extends true ? string : string | undefined;
11
- //#endregion
12
- //#region src/config/types.d.mts
13
- /**
14
- * Evaluates to `true` if `T` is `any`. `false` otherwise.
15
- * (c) https://stackoverflow.com/a/68633327/5290447
16
- */
17
- type IsAny<T> = unknown extends T ? [keyof T] extends [never] ? false : true : false;
18
- type ExcludedParts = 'services' | 'mailer' | 'aws' | 'computedTimeRates' | 'aiModelsRates';
19
- type ExcludedKeys = 'computedTimeRates' | 'aiModelsRates' | 'aiModel';
20
- type PathImpl<T, Key$1 extends keyof T> = Key$1 extends string ? Key$1 extends ExcludedKeys ? never : IsAny<T[Key$1]> extends true ? never : T[Key$1] extends string ? never : T[Key$1] extends any[] ? never : T[Key$1] extends Record<string, any> ? Key$1 extends ExcludedParts ? `${Key$1}.${Exclude<keyof T[Key$1], keyof any[]> & string}` : `${Key$1}.${PathImpl<T[Key$1], Exclude<keyof T[Key$1], keyof any[]>> & string}` | `${Key$1}.${Exclude<keyof T[Key$1], keyof any[]> & string}` : never : never;
21
- type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
22
- type Path<T> = keyof T extends string ? PathImpl2<T> extends infer P ? P extends string | keyof T ? P : keyof T : keyof T : never;
23
- 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;
24
- //#endregion
25
- //#region src/config/config-service.interface.d.mts
26
- /**
27
- * Interface for configuration service implementations.
28
- *
29
- * Provides type-safe access to configuration values with support for nested paths.
30
- *
31
- * @typeParam Config - The configuration object type
32
- */
33
- interface ConfigServiceInterface<Config = Record<string, unknown>> {
34
- /**
35
- * Gets the entire configuration object.
36
- */
37
- getConfig: () => Config;
38
- /**
39
- * Gets a configuration value by key path. Returns `null` if not found.
40
- *
41
- * @param key - Dot-separated path to the configuration value (e.g., 'database.host')
42
- * @returns The configuration value or `null` if not found
43
- */
44
- get: <Key$1 extends Path<Config>>(key: Key$1) => PathValue<Config, Key$1> | null;
45
- /**
46
- * Gets a configuration value by key path, or returns a default value if not found.
47
- *
48
- * @param key - Dot-separated path to the configuration value
49
- * @param defaultValue - Default value to return if the key is not found
50
- * @returns The configuration value or the default value
51
- */
52
- getOrDefault: <Key$1 extends Path<Config>>(key: Key$1, defaultValue: PathValue<Config, Key$1>) => PathValue<Config, Key$1>;
53
- /**
54
- * Gets a configuration value by key path, or throws an error if not found.
55
- *
56
- * @param key - Dot-separated path to the configuration value
57
- * @param errorMessage - Optional custom error message
58
- * @returns The configuration value
59
- * @throws Error if the key is not found
60
- */
61
- getOrThrow: <Key$1 extends Path<Config>>(key: Key$1, errorMessage?: string) => PathValue<Config, Key$1>;
62
- }
63
- //#endregion
64
- //#region src/config/config.service.d.mts
65
- /**
66
- * Schema for validating configuration service options.
67
- */
68
- declare const ConfigServiceOptionsSchema: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
69
- /**
70
- * Type for configuration service options.
71
- */
72
- type ConfigServiceOptions = z$1.infer<typeof ConfigServiceOptionsSchema>;
73
- /**
74
- * Injection token for ConfigService.
75
- */
76
- declare const ConfigServiceToken: InjectionToken<ConfigServiceInterface<Record<string, unknown>>, z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>, true>;
77
- /**
78
- * Service for managing application configuration with type-safe access.
79
- *
80
- * Provides methods to access configuration values using dot-notation paths
81
- * with full TypeScript type inference.
82
- *
83
- * @typeParam Config - The configuration object type
84
- *
85
- * @example
86
- * ```typescript
87
- * interface AppConfig {
88
- * database: {
89
- * host: string
90
- * port: number
91
- * }
92
- * api: {
93
- * timeout: number
94
- * }
95
- * }
96
- *
97
- * @Injectable()
98
- * export class DatabaseService {
99
- * private config = inject(MyConfigService)
100
- *
101
- * connect() {
102
- * const host = this.config.getOrThrow('database.host')
103
- * const port = this.config.getOrDefault('database.port', 5432)
104
- * // host is typed as string, port is typed as number
105
- * }
106
- * }
107
- * ```
108
- */
109
- declare class ConfigService<Config extends ConfigServiceOptions = Record<string, unknown>> implements ConfigServiceInterface<Config> {
110
- private config;
111
- private readonly logger;
112
- /**
113
- * Creates a new ConfigService instance.
114
- *
115
- * @param config - The configuration object
116
- */
117
- constructor(config?: Config);
118
- /**
119
- * Gets the entire configuration object.
120
- *
121
- * @returns The complete configuration object
122
- */
123
- getConfig(): Config;
124
- /**
125
- * Gets a configuration value by key path.
126
- *
127
- * Returns `null` if the key is not found or if any part of the path is invalid.
128
- *
129
- * @param key - Dot-separated path to the configuration value (e.g., 'database.host')
130
- * @returns The configuration value or `null` if not found
131
- *
132
- * @example
133
- * ```typescript
134
- * const host = config.get('database.host') // string | null
135
- * const port = config.get('database.port') // number | null
136
- * ```
137
- */
138
- get<Key$1 extends Path<Config>>(key: Key$1): PathValue<Config, Key$1> | null;
139
- /**
140
- * Gets a configuration value by key path, or returns a default value if not found.
141
- *
142
- * @param key - Dot-separated path to the configuration value
143
- * @param defaultValue - Default value to return if the key is not found
144
- * @returns The configuration value or the default value
145
- *
146
- * @example
147
- * ```typescript
148
- * const port = config.getOrDefault('database.port', 5432) // number
149
- * ```
150
- */
151
- getOrDefault<Key$1 extends Path<Config>>(key: Key$1, defaultValue: PathValue<Config, Key$1>): PathValue<Config, Key$1>;
152
- /**
153
- * Gets a configuration value by key path, or throws an error if not found.
154
- *
155
- * @param key - Dot-separated path to the configuration value
156
- * @param errorMessage - Optional custom error message
157
- * @returns The configuration value
158
- * @throws Error if the key is not found
159
- *
160
- * @example
161
- * ```typescript
162
- * const host = config.getOrThrow('database.host') // string (throws if not found)
163
- * const apiKey = config.getOrThrow('api.key', 'API key is required') // string
164
- * ```
165
- */
166
- getOrThrow<Key$1 extends Path<Config>>(key: Key$1, errorMessage?: string): PathValue<Config, Key$1>;
167
- }
168
- //#endregion
169
- //#region src/config/config.provider.d.mts
170
- /**
171
- * Schema for configuration provider options.
172
- */
173
- declare const ConfigProviderOptions: z$1.ZodObject<{
174
- load: z$1.ZodFunction<z$1.core.$ZodFunctionArgs, z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
175
- }, z$1.core.$strip>;
176
- /**
177
- * Creates a factory injection token for ConfigService that loads configuration asynchronously.
178
- *
179
- * Use this when you need to load configuration from a file, database, or other async source.
180
- *
181
- * @param options - Configuration provider options
182
- * @param options.load - Async function that loads and returns the configuration object
183
- * @returns A factory injection token for ConfigService
184
- *
185
- * @example
186
- * ```typescript
187
- * const MyConfigService = provideConfig({
188
- * load: async () => {
189
- * const config = await loadConfigFromFile('config.json')
190
- * return config
191
- * },
192
- * })
193
- *
194
- * // Use in module setup
195
- * container.bind(ConfigServiceToken).toFactory(configProvider)
196
- * ```
197
- */
198
- declare function provideConfig<ConfigMap extends ConfigServiceOptions>(options: z$1.input<typeof ConfigProviderOptions>): FactoryInjectionToken<ConfigService<ConfigMap>, typeof ConfigServiceOptionsSchema>;
199
- /**
200
- * Pre-configured ConfigService provider that uses environment variables.
201
- *
202
- * Provides a ConfigService instance bound to `process.env`.
203
- *
204
- * @example
205
- * ```typescript
206
- * // Use environment variables as configuration
207
- * container.bind(ConfigServiceToken).toValue(EnvConfigProvider)
208
- * ```
209
- */
210
- declare const EnvConfigProvider: _navios_di0.BoundInjectionToken<ConfigService<Record<string, string>>, z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>>;
211
- //#endregion
212
- //#region src/decorators/controller.decorator.d.mts
213
- /**
214
- * Options for configuring a Navios controller.
215
- */
216
- interface ControllerOptions {
217
- /**
218
- * Guards to apply to all endpoints in this controller.
219
- * Guards are executed in reverse order (last guard first).
220
- */
221
- guards?: ClassType[] | Set<ClassType>;
222
- /**
223
- * Registry to use for the controller.
224
- * Registry is used to store the controller and its endpoints.
225
- */
226
- registry?: Registry;
227
- /**
228
- * Priority to use for the controller.
229
- * Priority is used to sort the controller in the registry.
230
- */
231
- priority?: number;
232
- /**
233
- * Scope to use for the controller.
234
- * Scope is used to determine the scope of the controller.
235
- */
236
- scope?: InjectableScope;
237
- }
238
- /**
239
- * Decorator that marks a class as a Navios controller.
240
- *
241
- * Controllers handle HTTP requests and define endpoints.
242
- * They are request-scoped by default, meaning a new instance is created for each request.
243
- *
244
- * @param options - Controller configuration options
245
- * @returns A class decorator
246
- *
247
- * @example
248
- * ```typescript
249
- * @Controller({ guards: [AuthGuard] })
250
- * export class UserController {
251
- * @Endpoint(getUserEndpoint)
252
- * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
253
- * // Handle request
254
- * }
255
- * }
256
- * ```
257
- */
258
- declare function Controller({
259
- guards,
260
- registry,
261
- priority,
262
- scope
263
- }?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
264
- //#endregion
265
- //#region src/decorators/endpoint.decorator.d.mts
266
- /**
267
- * Extracts the typed parameters for an endpoint handler function.
268
- *
269
- * This utility type extracts URL parameters, query parameters, and request body
270
- * from an endpoint declaration and flattens them into a single object.
271
- *
272
- * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
273
- *
274
- * @example
275
- * ```typescript
276
- * const getUserEndpoint = api.declareEndpoint({
277
- * method: 'get',
278
- * url: '/users/$userId',
279
- * querySchema: z.object({ include: z.string().optional() }),
280
- * responseSchema: z.object({ id: z.string(), name: z.string() }),
281
- * })
282
- *
283
- * @Endpoint(getUserEndpoint)
284
- * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
285
- * // request.urlParams.userId is typed as string
286
- * // request.query.include is typed as string | undefined
287
- * }
288
- * ```
289
- */
290
- type EndpointParams<EndpointDeclaration extends EndpointHandler<Config, false>, Config extends EndpointOptions = EndpointDeclaration['config']> = RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>;
291
- /**
292
- * Extracts the typed return value for an endpoint handler function.
293
- *
294
- * This utility type extracts the response schema from an endpoint declaration
295
- * and returns the appropriate Promise type.
296
- *
297
- * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
298
- *
299
- * @example
300
- * ```typescript
301
- * const getUserEndpoint = api.declareEndpoint({
302
- * method: 'get',
303
- * url: '/users/$userId',
304
- * responseSchema: z.object({ id: z.string(), name: z.string() }),
305
- * })
306
- *
307
- * @Endpoint(getUserEndpoint)
308
- * async getUser(request: EndpointParams<typeof getUserEndpoint>): EndpointResult<typeof getUserEndpoint> {
309
- * return { id: '1', name: 'John' } // Type-checked against responseSchema
310
- * }
311
- * ```
312
- */
313
- type EndpointResult<EndpointDeclaration extends {
314
- config: EndpointOptions;
315
- }> = EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<infer Options> ? Promise<z$1.input<Options[number]>> : Promise<z$1.input<EndpointDeclaration['config']['responseSchema']>>;
316
- /**
317
- * Decorator that marks a method as an HTTP endpoint.
318
- *
319
- * The endpoint must be defined using @navios/builder's `declareEndpoint` method.
320
- * This ensures type safety and consistency between client and server.
321
- *
322
- * @param endpoint - The endpoint declaration from @navios/builder
323
- * @returns A method decorator
324
- *
325
- * @example
326
- * ```typescript
327
- * import { builder } from '@navios/builder'
328
- *
329
- * const api = builder()
330
- * const getUserEndpoint = api.declareEndpoint({
331
- * method: 'get',
332
- * url: '/users/$userId',
333
- * responseSchema: z.object({ id: z.string(), name: z.string() }),
334
- * })
335
- *
336
- * @Controller()
337
- * export class UserController {
338
- * @Endpoint(getUserEndpoint)
339
- * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
340
- * const { userId } = request.urlParams
341
- * return { id: userId, name: 'John' }
342
- * }
343
- * }
344
- * ```
345
- */
346
- declare function Endpoint<const Config extends EndpointOptions>(endpoint: EndpointHandler<Config, false>): (target: (params: RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>) => Promise<z$1.input<Config['responseSchema']>> | z$1.input<Config['responseSchema']>, context: ClassMethodDecoratorContext) => void;
347
- declare function Endpoint<const Config extends EndpointOptions>(endpoint: EndpointHandler<Config, false>): (target: () => Promise<z$1.input<Config['responseSchema']>> | z$1.input<Config['responseSchema']>, context: ClassMethodDecoratorContext) => void;
348
- //#endregion
349
- //#region src/metadata/handler.metadata.d.mts
350
- declare const EndpointMetadataKey: unique symbol;
351
- interface HandlerMetadata<Config = null> {
352
- classMethod: string;
353
- url: string;
354
- successStatusCode: number;
355
- adapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface, undefined> | ClassTypeWithInstance<AbstractHttpHandlerAdapterInterface> | null;
356
- headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
357
- httpMethod: HttpMethod;
358
- config: Config;
359
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
360
- customAttributes: Map<string | symbol, any>;
361
- }
362
- declare function getAllEndpointMetadata(context: ClassMethodDecoratorContext | ClassDecoratorContext): Set<HandlerMetadata<any>>;
363
- declare function getEndpointMetadata<Config = any>(target: Function, context: ClassMethodDecoratorContext): HandlerMetadata<Config>;
364
- //#endregion
365
- //#region src/metadata/controller.metadata.d.mts
366
- declare const ControllerMetadataKey: unique symbol;
367
- interface ControllerMetadata {
368
- /**
369
- * The name of the controller class.
370
- */
371
- name: string;
372
- endpoints: Set<HandlerMetadata>;
373
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
374
- customAttributes: Map<string | symbol, any>;
375
- }
376
- declare function getControllerMetadata(target: ClassType, context: ClassDecoratorContext): ControllerMetadata;
377
- declare function extractControllerMetadata(target: ClassType): ControllerMetadata;
378
- declare function hasControllerMetadata(target: ClassType): boolean;
379
- //#endregion
380
- //#region src/metadata/module.metadata.d.mts
381
- declare const ModuleMetadataKey: unique symbol;
382
- interface ModuleMetadata {
383
- /**
384
- * The name of the module class.
385
- */
386
- name: string;
387
- controllers: Set<ClassType>;
388
- imports: Set<ClassType>;
389
- guards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
390
- overrides: Set<ClassType>;
391
- customAttributes: Map<string | symbol, any>;
392
- /**
393
- * Extensible entries for adapter-specific data.
394
- * Adapters can store custom metadata using symbol keys.
395
- *
396
- * @example
397
- * ```typescript
398
- * const CommandEntryKey = Symbol('CommandEntryKey')
399
- * metadata.customEntries.set(CommandEntryKey, new Set([Command1, Command2]))
400
- * ```
401
- */
402
- customEntries: Map<symbol, unknown>;
403
- }
404
- declare function getModuleMetadata(target: ClassType, context: ClassDecoratorContext): ModuleMetadata;
405
- declare function extractModuleMetadata(target: ClassType): ModuleMetadata;
406
- declare function hasModuleMetadata(target: ClassType): boolean;
407
- /**
408
- * Type-safe helper to get or create a custom entry in module metadata.
409
- * Adapters use this to store their own metadata in modules.
410
- *
411
- * @param metadata - The module metadata object
412
- * @param key - Symbol key for the custom entry
413
- * @param defaultValue - Factory function to create default value if entry doesn't exist
414
- * @returns The existing or newly created entry value
415
- *
416
- * @example
417
- * ```typescript
418
- * const CommandEntryKey = Symbol('CommandEntryKey')
419
- * const commands = getModuleCustomEntry<Set<ClassType>>(
420
- * metadata,
421
- * CommandEntryKey,
422
- * () => new Set(),
423
- * )
424
- * commands.add(MyCommand)
425
- * ```
426
- */
427
- declare function getModuleCustomEntry<T>(metadata: ModuleMetadata, key: symbol, defaultValue: () => T): T;
428
- //#endregion
429
- //#region src/metadata/navios-managed.metadata.d.mts
430
- /**
431
- * Symbol used to identify Navios-managed classes (Controller, Module, MessageController, etc.).
432
- * This allows AttributeFactory to work with any Navios-managed class type generically.
433
- */
434
- declare const NaviosManagedMetadataKey: unique symbol;
435
- /**
436
- * Interface for metadata that has custom attributes.
437
- * Used by Navios-managed classes (Controller, Module, MessageController, etc.).
438
- */
439
- interface ManagedMetadata {
440
- customAttributes: Map<string | symbol, any>;
441
- }
442
- /**
443
- * Gets managed metadata from a class if it exists.
444
- * This is a generic function that works with any Navios-managed class type.
445
- *
446
- * @param target - The class to check
447
- * @returns The metadata with customAttributes, or null if not managed
448
- */
449
- declare function getManagedMetadata(target: ClassType): ManagedMetadata | null;
450
- /**
451
- * Checks if a class is Navios-managed (has managed metadata).
452
- *
453
- * @param target - The class to check
454
- * @returns true if the class is Navios-managed
455
- */
456
- declare function hasManagedMetadata(target: ClassType): boolean;
457
- //#endregion
458
- //#region src/interfaces/abstract-adapter.interface.d.mts
459
- /**
460
- * Base interface for all Navios adapters (HTTP, CLI, etc.).
461
- *
462
- * Adapters implement this interface to provide runtime-specific functionality.
463
- * This interface defines the common lifecycle methods shared across all adapter types.
464
- */
465
- interface AbstractAdapterInterface {
466
- /**
467
- * Sets up the adapter with the provided options.
468
- * Called during application initialization before modules are initialized.
469
- */
470
- setupAdapter(options: unknown): Promise<void>;
471
- /**
472
- * Called after all modules are loaded.
473
- * Adapters use this to register routes, commands, or other module-based functionality.
474
- */
475
- onModulesInit(modules: Map<string, ModuleMetadata>): Promise<void>;
476
- /**
477
- * Signals that the adapter is ready to handle requests/commands.
478
- * Called after onModulesInit completes.
479
- */
480
- ready(): Promise<void>;
481
- /**
482
- * Disposes of the adapter and cleans up resources.
483
- */
484
- dispose(): Promise<void>;
485
- }
486
- //#endregion
487
- //#region src/interfaces/abstract-execution-context.inteface.d.mts
488
- /**
489
- * Interface providing access to the execution context during request handling.
490
- *
491
- * The execution context provides access to metadata and request/reply objects
492
- * for the current request. It is available in guards and can be injected into
493
- * services if needed.
494
- *
495
- * @example
496
- * ```typescript
497
- * @Injectable()
498
- * export class AuthGuard implements CanActivate {
499
- * async canActivate(context: AbstractExecutionContext): Promise<boolean> {
500
- * const request = context.getRequest()
501
- * const handler = context.getHandler()
502
- * // Access request and handler metadata
503
- * return true
504
- * }
505
- * }
506
- * ```
507
- */
508
- interface AbstractExecutionContext {
509
- /**
510
- * Gets the metadata for the module containing the current endpoint.
511
- */
512
- getModule(): ModuleMetadata;
513
- /**
514
- * Gets the metadata for the controller containing the current endpoint.
515
- */
516
- getController(): ControllerMetadata;
517
- /**
518
- * Gets the metadata for the current endpoint handler.
519
- */
520
- getHandler(): HandlerMetadata;
521
- /**
522
- * Gets the HTTP request object (adapter-specific).
523
- */
524
- getRequest(): any;
525
- /**
526
- * Gets the HTTP reply object (adapter-specific).
527
- */
528
- getReply(): any;
529
- }
530
- //#endregion
531
- //#region src/interfaces/adapter-environment.interface.d.mts
532
- /**
533
- * Base interface for adapter environments.
534
- *
535
- * All adapter environments extend this interface to provide
536
- * type-safe access to adapter-specific configuration options.
537
- */
538
- interface AdapterEnvironment {
539
- /**
540
- * Adapter setup/configuration options type
541
- */
542
- options: unknown;
543
- /**
544
- * Adapter type
545
- */
546
- adapter: AbstractAdapterInterface;
547
- }
548
- /**
549
- * Environment interface for HTTP adapters.
550
- *
551
- * Each HTTP adapter (Fastify, Bun, etc.) implements this interface to provide
552
- * type-safe access to HTTP-specific types throughout the application.
553
- *
554
- * @example
555
- * ```typescript
556
- * // Using with a specific adapter
557
- * import { FastifyEnvironment } from '@navios/adapter-fastify'
558
- *
559
- * const app = await NaviosFactory.create<FastifyEnvironment>(AppModule, {
560
- * adapter: defineFastifyEnvironment(),
561
- * })
562
- *
563
- * // All methods are now type-safe for Fastify
564
- * app.configure({ trustProxy: true })
565
- * app.enableCors({ origin: true }) // FastifyCorsOptions
566
- * const server = app.getServer() // FastifyInstance
567
- * await app.listen({ port: 3000 }) // FastifyListenOptions
568
- * ```
569
- */
570
- interface HttpAdapterEnvironment extends AdapterEnvironment {
571
- /**
572
- * The underlying HTTP server instance type (e.g., FastifyInstance, Bun.Server)
573
- */
574
- server: unknown;
575
- /**
576
- * CORS configuration options type
577
- */
578
- corsOptions: unknown;
579
- /**
580
- * Multipart form data configuration options type
581
- */
582
- multipartOptions: unknown;
583
- /**
584
- * Server listen options type (port, host, etc.)
585
- */
586
- listenOptions: unknown;
587
- }
588
- /**
589
- * Default environment with unknown types.
590
- *
591
- * Forces users to specify an Environment generic for type-safe adapter access.
592
- * When no generic is provided to `NaviosApplication` or `NaviosFactory.create()`,
593
- * this default is used, resulting in `unknown` types for all adapter-specific
594
- * methods.
595
- */
596
- interface DefaultAdapterEnvironment extends AdapterEnvironment {
597
- options: unknown;
598
- }
599
- //#endregion
600
- //#region src/interfaces/abstract-http-adapter.interface.d.mts
601
- /**
602
- * Interface for HTTP adapters extending the base adapter interface.
603
- *
604
- * Adapters implement this interface to provide runtime-specific HTTP server
605
- * functionality (Fastify, Bun, etc.).
606
- *
607
- * @typeParam Environment - The adapter environment providing type-safe access to
608
- * server instance, CORS options, listen options, etc.
609
- */
610
- interface AbstractHttpAdapterInterface<Environment extends HttpAdapterEnvironment = HttpAdapterEnvironment> extends AbstractAdapterInterface {
611
- /**
612
- * Sets up the adapter with the provided options.
613
- * Called during application initialization before modules are initialized.
614
- */
615
- setupAdapter(options: Environment['options']): Promise<void>;
616
- /**
617
- * Called after all modules are loaded to register routes.
618
- */
619
- onModulesInit(modules: Map<string, ModuleMetadata>): Promise<void>;
620
- /**
621
- * Signals that the server is ready to accept requests.
622
- */
623
- ready(): Promise<void>;
624
- /**
625
- * Disposes of the server and cleans up resources.
626
- */
627
- dispose(): Promise<void>;
628
- /**
629
- * Returns the underlying HTTP server instance.
630
- */
631
- getServer(): Environment['server'];
632
- /**
633
- * Sets a global prefix for all routes.
634
- */
635
- setGlobalPrefix(prefix: string): void;
636
- /**
637
- * Gets the current global prefix.
638
- * Returns empty string if no prefix is set.
639
- */
640
- getGlobalPrefix(): string;
641
- /**
642
- * Enables CORS with the specified options.
643
- */
644
- enableCors(options: Environment['corsOptions']): void;
645
- /**
646
- * Enables multipart form data handling.
647
- */
648
- enableMultipart(options: Environment['multipartOptions']): void;
649
- /**
650
- * Starts the server and listens for incoming requests.
651
- */
652
- listen(options: Environment['listenOptions']): Promise<string>;
653
- /**
654
- * Configures the adapter with additional options before init.
655
- *
656
- * This method allows setting adapter-specific configuration options
657
- * before the server is initialized. Options set via configure() are
658
- * merged with options passed to setupAdapter().
659
- *
660
- * Must be called before setupAdapter().
661
- */
662
- configure(options: Partial<Environment['options']>): void;
663
- }
664
- //#endregion
665
- //#region src/logger/utils/cli-colors.util.d.mts
666
- declare const clc: {
667
- bold: (text: string) => string;
668
- green: (text: string) => string;
669
- yellow: (text: string) => string;
670
- red: (text: string) => string;
671
- magentaBright: (text: string) => string;
672
- cyanBright: (text: string) => string;
673
- };
674
- declare const yellow: (text: string) => string;
675
- //#endregion
676
- //#region src/logger/log-levels.d.mts
677
- /**
678
- * Available log levels in order of severity (lowest to highest).
679
- */
680
- declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
681
- /**
682
- * Log level type.
683
- *
684
- * Represents the severity level of a log message.
685
- * Levels are: 'verbose', 'debug', 'log', 'warn', 'error', 'fatal'
686
- *
687
- * @publicApi
688
- */
689
- type LogLevel = (typeof LOG_LEVELS)[number];
690
- //#endregion
691
- //#region src/logger/utils/filter-log-levelts.util.d.mts
692
- /**
693
- * @publicApi
694
- */
695
- declare function filterLogLevels(parseableString?: string): LogLevel[];
696
- //#endregion
697
- //#region src/logger/utils/is-log-level.util.d.mts
698
- /**
699
- * @publicApi
700
- */
701
- declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
702
- //#endregion
703
- //#region src/logger/utils/is-log-level-enabled.d.mts
704
- /**
705
- * Checks if target level is enabled.
706
- * @param targetLevel target level
707
- * @param logLevels array of enabled log levels
708
- */
709
- declare function isLogLevelEnabled(targetLevel: LogLevel, logLevels: LogLevel[] | undefined): boolean;
710
- //#endregion
711
- //#region src/logger/utils/shared.utils.d.mts
712
- declare const isUndefined: (obj: any) => obj is undefined;
713
- declare const isObject: (fn: any) => fn is object;
714
- declare const isPlainObject: (fn: any) => fn is object;
715
- declare const addLeadingSlash: (path?: string) => string;
716
- declare const normalizePath: (path?: string) => string;
717
- declare const stripEndSlash: (path: string) => string;
718
- declare const isFunction: (val: any) => val is Function;
719
- declare const isString: (val: any) => val is string;
720
- declare const isNumber: (val: any) => val is number;
721
- declare const isConstructor: (val: any) => boolean;
722
- declare const isNil: (val: any) => val is null | undefined;
723
- declare const isEmpty: (array: any) => boolean;
724
- declare const isSymbol: (val: any) => val is symbol;
725
- //#endregion
726
- //#region src/logger/logger-service.interface.d.mts
727
- /**
728
- * @publicApi
729
- */
730
- interface LoggerService {
731
- /**
732
- * Write a 'log' level log.
733
- */
734
- log(message: any, ...optionalParams: any[]): any;
735
- /**
736
- * Write an 'error' level log.
737
- */
738
- error(message: any, ...optionalParams: any[]): any;
739
- /**
740
- * Write a 'warn' level log.
741
- */
742
- warn(message: any, ...optionalParams: any[]): any;
743
- /**
744
- * Write a 'debug' level log.
745
- */
746
- debug?(message: any, ...optionalParams: any[]): any;
747
- /**
748
- * Write a 'verbose' level log.
749
- */
750
- verbose?(message: any, ...optionalParams: any[]): any;
751
- /**
752
- * Write a 'fatal' level log.
753
- */
754
- fatal?(message: any, ...optionalParams: any[]): any;
755
- /**
756
- * Set log levels.
757
- * @param levels log levels
758
- */
759
- setLogLevels?(levels: LogLevel[]): any;
760
- }
761
- //#endregion
762
- //#region src/logger/console-logger.service.d.mts
763
- /**
764
- * @publicApi
765
- */
766
- interface ConsoleLoggerOptions {
767
- /**
768
- * Enabled log levels.
769
- */
770
- logLevels?: LogLevel[];
771
- /**
772
- * If enabled, will print timestamp difference between current and previous log message.
773
- * Note: This option is not used when `json` is enabled.
774
- * @default false
775
- */
776
- showTimeDiff?: boolean;
777
- /**
778
- * A prefix to be used for each log message.
779
- * Note: This option is not used when `json` is enabled.
780
- */
781
- prefix?: string;
782
- /**
783
- * If true, will print the process ID in the log message.
784
- * Note: This option is not used when `json` is enabled.
785
- * @default true
786
- */
787
- showPid?: boolean;
788
- /**
789
- * If true, will print the log level in the log message.
790
- * Note: This option is not used when `json` is enabled.
791
- * @default true
792
- */
793
- showLogLevel?: boolean;
794
- /**
795
- * If true, will print the prefix/app name in the log message.
796
- * Note: This option is not used when `json` is enabled.
797
- * @default true
798
- */
799
- showPrefix?: boolean;
800
- /**
801
- * If true, will print the context in the log message.
802
- * Note: This option is not used when `json` is enabled.
803
- * @default true
804
- */
805
- showContext?: boolean;
806
- /**
807
- * If true, will print the absolute timestamp in the log message.
808
- * Note: This option is not used when `json` is enabled.
809
- * @default true
810
- */
811
- showTimestamp?: boolean;
812
- /**
813
- * If enabled, will add a request ID to the log message.
814
- */
815
- requestId?: boolean;
816
- /**
817
- * If enabled, will print the log message in JSON format.
818
- */
819
- json?: boolean;
820
- /**
821
- * If enabled, will print the log message in color.
822
- * Default true if json is disabled, false otherwise
823
- */
824
- colors?: boolean;
825
- /**
826
- * The context of the logger.
827
- */
828
- context?: string;
829
- /**
830
- * If enabled, will print the log message in a single line, even if it is an object with multiple properties.
831
- * If set to a number, the most n inner elements are united on a single line as long as all properties fit into breakLength. Short array elements are also grouped together.
832
- * Default true when `json` is enabled, false otherwise.
833
- */
834
- compact?: boolean | number;
835
- /**
836
- * Specifies the maximum number of Array, TypedArray, Map, Set, WeakMap, and WeakSet elements to include when formatting.
837
- * Set to null or Infinity to show all elements. Set to 0 or negative to show no elements.
838
- * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
839
- * @default 100
840
- */
841
- maxArrayLength?: number;
842
- /**
843
- * Specifies the maximum number of characters to include when formatting.
844
- * Set to null or Infinity to show all elements. Set to 0 or negative to show no characters.
845
- * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
846
- * @default 10000.
847
- */
848
- maxStringLength?: number;
849
- /**
850
- * If enabled, will sort keys while formatting objects.
851
- * Can also be a custom sorting function.
852
- * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
853
- * @default false
854
- */
855
- sorted?: boolean | ((a: string, b: string) => number);
856
- /**
857
- * Specifies the number of times to recurse while formatting object. T
858
- * This is useful for inspecting large objects. To recurse up to the maximum call stack size pass Infinity or null.
859
- * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
860
- * @default 5
861
- */
862
- depth?: number;
863
- /**
864
- * If true, object's non-enumerable symbols and properties are included in the formatted result.
865
- * WeakMap and WeakSet entries are also included as well as user defined prototype properties
866
- * @default false
867
- */
868
- showHidden?: boolean;
869
- /**
870
- * The length at which input values are split across multiple lines. Set to Infinity to format the input as a single line (in combination with "compact" set to true).
871
- * Default Infinity when "compact" is true, 80 otherwise.
872
- * Ignored when `json` is enabled, colors are disabled, and `compact` is set to true as it produces a parseable JSON output.
873
- */
874
- breakLength?: number;
875
- }
876
- /**
877
- * @publicApi
878
- */
879
- declare class ConsoleLogger implements LoggerService {
880
- /**
881
- * Creates a new ConsoleLogger instance with the given options.
882
- * This is a convenience method that instantiates and sets up the logger in one call.
883
- */
884
- static create(): ConsoleLogger;
885
- static create(context: string): ConsoleLogger;
886
- static create(options: ConsoleLoggerOptions): ConsoleLogger;
887
- static create(context: string, options: ConsoleLoggerOptions): ConsoleLogger;
888
- /**
889
- * The options of the logger.
890
- */
891
- protected options: ConsoleLoggerOptions;
892
- /**
893
- * The context of the logger (can be set manually or automatically inferred).
894
- */
895
- protected context?: string;
896
- /**
897
- * The original context of the logger (set in the constructor).
898
- */
899
- protected originalContext?: string;
900
- /**
901
- * The options used for the "inspect" method.
902
- */
903
- protected inspectOptions: InspectOptions;
904
- /**
905
- * The last timestamp at which the log message was printed.
906
- */
907
- protected lastTimestampAt?: number;
908
- setup(): void;
909
- setup(context: string): void;
910
- setup(options: ConsoleLoggerOptions): void;
911
- setup(context: string, options: ConsoleLoggerOptions): void;
912
- /**
913
- * Write a 'log' level log, if the configured level allows for it.
914
- * Prints to `stdout` with newline.
915
- */
916
- log(message: any, context?: string): void;
917
- log(message: any, ...optionalParams: [...any, string?]): void;
918
- /**
919
- * Write an 'error' level log, if the configured level allows for it.
920
- * Prints to `stderr` with newline.
921
- */
922
- error(message: any, stackOrContext?: string): void;
923
- error(message: any, stack?: string, context?: string): void;
924
- error(message: any, ...optionalParams: [...any, string?, string?]): void;
925
- /**
926
- * Write a 'warn' level log, if the configured level allows for it.
927
- * Prints to `stdout` with newline.
928
- */
929
- warn(message: any, context?: string): void;
930
- warn(message: any, ...optionalParams: [...any, string?]): void;
931
- /**
932
- * Write a 'debug' level log, if the configured level allows for it.
933
- * Prints to `stdout` with newline.
934
- */
935
- debug(message: any, context?: string): void;
936
- debug(message: any, ...optionalParams: [...any, string?]): void;
937
- /**
938
- * Write a 'verbose' level log, if the configured level allows for it.
939
- * Prints to `stdout` with newline.
940
- */
941
- verbose(message: any, context?: string): void;
942
- verbose(message: any, ...optionalParams: [...any, string?]): void;
943
- /**
944
- * Write a 'fatal' level log, if the configured level allows for it.
945
- * Prints to `stdout` with newline.
946
- */
947
- fatal(message: any, context?: string): void;
948
- fatal(message: any, ...optionalParams: [...any, string?]): void;
949
- /**
950
- * Set log levels
951
- * @param levels log levels
952
- */
953
- setLogLevels(levels: LogLevel[]): void;
954
- /**
955
- * Set logger context
956
- * @param context context
957
- */
958
- setContext(context: string): void;
959
- /**
960
- * Resets the logger context to the value that was passed in the constructor.
961
- */
962
- resetContext(): void;
963
- isLevelEnabled(level: LogLevel): boolean;
964
- /**
965
- * Gets the current request ID from the AsyncLocalStorage store.
966
- * Only returns a value if the requestId option is enabled.
967
- */
968
- protected getCurrentRequestId(): string | undefined;
969
- protected getTimestamp(): string;
970
- protected printMessages(messages: unknown[], context?: string, logLevel?: LogLevel, requestId?: string, writeStreamType?: 'stdout' | 'stderr', errorStack?: unknown): void;
971
- protected printAsJson(message: unknown, options: {
972
- context: string;
973
- logLevel: LogLevel;
974
- writeStreamType?: 'stdout' | 'stderr';
975
- errorStack?: unknown;
976
- requestId?: string;
977
- }): void;
978
- protected formatPid(pid: number): string;
979
- protected formatContext(context: string): string;
980
- protected formatMessage(logLevel: LogLevel, message: unknown, pidMessage: string, formattedLogLevel: string, contextMessage: string, timestampDiff: string, requestId?: string): string;
981
- protected getRequestId(requestId?: string): string;
982
- protected stringifyMessage(message: unknown, logLevel: LogLevel): string;
983
- protected colorize(message: string, logLevel: LogLevel): string;
984
- protected printStackTrace(stack: string): void;
985
- protected updateAndGetTimestampDiff(): string;
986
- protected formatTimestampDiff(timestampDiff: number): string;
987
- protected getInspectOptions(): InspectOptions;
988
- protected stringifyReplacer(key: string, value: unknown): unknown;
989
- private getContextAndMessagesToPrint;
990
- private getContextAndStackAndMessagesToPrint;
991
- private isStackFormat;
992
- private getColorByLogLevel;
993
- }
994
- //#endregion
995
- //#region src/logger/logger.service.d.mts
996
- /**
997
- * Logger service instance that can be injected into services and controllers.
998
- *
999
- * Provides contextualized logging with automatic context injection.
1000
- * The context is set when the logger is injected using the `inject` function.
1001
- *
1002
- * @example
1003
- * ```typescript
1004
- * @Injectable()
1005
- * export class UserService {
1006
- * private logger = inject(Logger, { context: UserService.name })
1007
- *
1008
- * async findUser(id: string) {
1009
- * this.logger.log(`Finding user ${id}`)
1010
- * // Logs with context: [UserService]
1011
- * }
1012
- * }
1013
- * ```
1014
- */
1015
- declare class LoggerInstance implements LoggerService {
1016
- protected localInstance: LoggerService;
1017
- protected context?: string;
1018
- constructor(config?: LoggerOptions);
1019
- /**
1020
- * Write an 'error' level log.
1021
- */
1022
- error(message: any, stack?: string, context?: string): void;
1023
- error(message: any, ...optionalParams: [...any, string?, string?]): void;
1024
- /**
1025
- * Write a 'log' level log.
1026
- */
1027
- log(message: any, context?: string): void;
1028
- log(message: any, ...optionalParams: [...any, string?]): void;
1029
- /**
1030
- * Write a 'warn' level log.
1031
- */
1032
- warn(message: any, context?: string): void;
1033
- warn(message: any, ...optionalParams: [...any, string?]): void;
1034
- /**
1035
- * Write a 'debug' level log.
1036
- */
1037
- debug(message: any, context?: string): void;
1038
- debug(message: any, ...optionalParams: [...any, string?]): void;
1039
- /**
1040
- * Write a 'verbose' level log.
1041
- */
1042
- verbose(message: any, context?: string): void;
1043
- verbose(message: any, ...optionalParams: [...any, string?]): void;
1044
- /**
1045
- * Write a 'fatal' level log.
1046
- */
1047
- fatal(message: any, context?: string): void;
1048
- fatal(message: any, ...optionalParams: [...any, string?]): void;
1049
- }
1050
- //#endregion
1051
- //#region src/logger/logger.tokens.d.mts
1052
- /**
1053
- * Injection token for the logger output service.
1054
- *
1055
- * This token is used to provide a custom logger implementation.
1056
- * By default, it's bound to ConsoleLogger.
1057
- */
1058
- declare const LoggerOutput: InjectionToken<LoggerService, undefined, false>;
1059
- /**
1060
- * Schema for logger options.
1061
- */
1062
- declare const loggerOptionsSchema: z.ZodOptional<z.ZodObject<{
1063
- context: z.ZodOptional<z.ZodString>;
1064
- }, z.core.$strip>>;
1065
- /**
1066
- * Options for creating a logger instance.
1067
- */
1068
- type LoggerOptions = z.infer<typeof loggerOptionsSchema>;
1069
- /**
1070
- * Injection token for the Logger service.
1071
- *
1072
- * Use this token to inject a contextualized logger instance.
1073
- *
1074
- * @example
1075
- * ```typescript
1076
- * const logger = inject(Logger, { context: 'MyService' })
1077
- * logger.log('Hello world') // Logs with context: [MyService]
1078
- * ```
1079
- */
1080
- declare const Logger: InjectionToken<LoggerInstance, z.ZodOptional<z.ZodObject<{
1081
- context: z.ZodOptional<z.ZodString>;
1082
- }, z.core.$strip>>, false>;
1083
- //#endregion
1084
- //#region src/interfaces/abstract-http-cors-options.interface.d.mts
1085
- interface ArrayOfValueOrArray<T> extends Array<ValueOrArray<T>> {}
1086
- type OriginType = string | boolean | RegExp;
1087
- type ValueOrArray<T> = T | ArrayOfValueOrArray<T>;
1088
- interface AbstractHttpCorsOptions {
1089
- /**
1090
- * Configures the Access-Control-Allow-Origin CORS header.
1091
- */
1092
- origin?: ValueOrArray<OriginType>;
1093
- /**
1094
- * Configures the Access-Control-Allow-Credentials CORS header.
1095
- * Set to true to pass the header, otherwise it is omitted.
1096
- */
1097
- credentials?: boolean;
1098
- /**
1099
- * Configures the Access-Control-Expose-Headers CORS header.
1100
- * Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range')
1101
- * or an array (ex: ['Content-Range', 'X-Content-Range']).
1102
- * If not specified, no custom headers are exposed.
1103
- */
1104
- exposedHeaders?: string | string[];
1105
- /**
1106
- * Configures the Access-Control-Allow-Headers CORS header.
1107
- * Expects a comma-delimited string (ex: 'Content-Type,Authorization')
1108
- * or an array (ex: ['Content-Type', 'Authorization']). If not
1109
- * specified, defaults to reflecting the headers specified in the
1110
- * request's Access-Control-Request-Headers header.
1111
- */
1112
- allowedHeaders?: string | string[];
1113
- /**
1114
- * Configures the Access-Control-Allow-Methods CORS header.
1115
- * Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: ['GET', 'PUT', 'POST']).
1116
- */
1117
- methods?: string | string[];
1118
- /**
1119
- * Configures the Access-Control-Max-Age CORS header.
1120
- * Set to an integer to pass the header, otherwise it is omitted.
1121
- */
1122
- maxAge?: number;
1123
- /**
1124
- * Configures the Cache-Control header for CORS preflight responses.
1125
- * Set to an integer to pass the header as `Cache-Control: max-age=${cacheControl}`,
1126
- * or set to a string to pass the header as `Cache-Control: ${cacheControl}` (fully define
1127
- * the header value), otherwise the header is omitted.
1128
- */
1129
- cacheControl?: number | string;
1130
- /**
1131
- * Sets the Fastify log level specifically for the internal OPTIONS route
1132
- * used to handle CORS preflight requests. For example, setting this to `'silent'`
1133
- * will prevent these requests from being logged.
1134
- * Useful for reducing noise in application logs.
1135
- * Default: inherits Fastify's global log level.
1136
- */
1137
- logLevel?: LogLevel;
1138
- }
1139
- //#endregion
1140
- //#region src/interfaces/abstract-http-handler-adapter.interface.d.mts
1141
- /**
1142
- * Static handler result - handler can be called without a scoped container.
1143
- * Used when the controller and all its dependencies are singletons.
1144
- */
1145
- type StaticHandler<TRequest = any, TReply = any> = {
1146
- isStatic: true;
1147
- handler: (request: TRequest, reply: TReply) => Promise<any>;
1148
- };
1149
- /**
1150
- * Dynamic handler result - handler requires a scoped container for resolution.
1151
- * Used when the controller or its dependencies need per-request resolution.
1152
- */
1153
- type DynamicHandler<TRequest = any, TReply = any> = {
1154
- isStatic: false;
1155
- handler: (scoped: ScopedContainer, request: TRequest, reply: TReply) => Promise<any>;
1156
- };
1157
- /**
1158
- * Handler result returned by provideHandler.
1159
- * Can be either static (pre-resolved) or dynamic (needs scoped container).
1160
- */
1161
- type HandlerResult<TRequest = any, TReply = any> = StaticHandler<TRequest, TReply> | DynamicHandler<TRequest, TReply>;
1162
- /**
1163
- * Function type for argument getters that extract data from requests.
1164
- * Each getter populates a target object with data from the request.
1165
- */
1166
- type ArgumentGetterFn<TRequest = any> = (target: Record<string, any>, request: TRequest) => void | Promise<void>;
1167
- /**
1168
- * Function type for formatting arguments from a request.
1169
- * Built from argument getters, optimized for sync/async handling.
1170
- */
1171
- type FormatArgumentsFn$1<TRequest = any> = (request: TRequest) => Record<string, any> | Promise<Record<string, any>>;
1172
- /**
1173
- * Interface for HTTP handler adapter services.
1174
- *
1175
- * Adapters handle different types of HTTP requests (REST, streaming, multipart)
1176
- * and are responsible for:
1177
- * - Parsing and validating request data
1178
- * - Creating handler functions
1179
- * - Formatting responses
1180
- * - Providing schema information (for frameworks like Fastify)
1181
- */
1182
- interface AbstractHttpHandlerAdapterInterface<TRequest = any> {
1183
- /**
1184
- * Prepares argument getters for parsing request data.
1185
- *
1186
- * Creates functions that extract and validate data from the request,
1187
- * populating a target object with validated arguments.
1188
- *
1189
- * @param handlerMetadata - The handler metadata with schemas and configuration.
1190
- * @returns An array of getter functions that populate request arguments.
1191
- */
1192
- prepareArguments?: (handlerMetadata: HandlerMetadata<any>) => ArgumentGetterFn<TRequest>[];
1193
- /**
1194
- * Builds a formatArguments function from argument getters.
1195
- *
1196
- * Automatically detects sync vs async getters and optimizes accordingly:
1197
- * - If all getters are sync: returns sync function (no Promise overhead)
1198
- * - If any getter is async: returns async function with Promise.all
1199
- * - If no getters: returns frozen empty object (zero allocation)
1200
- *
1201
- * This method is useful for composition-based adapters that need to
1202
- * build formatArguments without duplicating the optimization logic.
1203
- *
1204
- * @param getters - Array of argument getter functions
1205
- * @returns Function to format arguments from request
1206
- */
1207
- buildFormatArguments?: (getters: ArgumentGetterFn<TRequest>[]) => FormatArgumentsFn$1<TRequest>;
1208
- /**
1209
- * Checks if the handler has any validation schemas defined.
1210
- *
1211
- * @param handlerMetadata - The handler metadata containing configuration.
1212
- * @returns `true` if the handler has any schemas (request, query, response).
1213
- */
1214
- hasSchema?: (handlerMetadata: HandlerMetadata<any>) => boolean;
1215
- /**
1216
- * Provides schema information for the framework's validation system.
1217
- *
1218
- * For frameworks like Fastify, this returns route schema objects.
1219
- * For frameworks like Bun, this typically returns an empty object.
1220
- *
1221
- * @param handlerMetadata - The handler metadata containing configuration.
1222
- * @returns Schema information for framework registration.
1223
- */
1224
- provideSchema?: (handlerMetadata: HandlerMetadata<any>) => Record<string, any>;
1225
- /**
1226
- * Creates a request handler function for the endpoint.
1227
- *
1228
- * This is the core method that generates the actual handler function
1229
- * that will be called when a request matches the endpoint.
1230
- *
1231
- * @param controller - The controller class containing the handler method.
1232
- * @param handlerMetadata - The handler metadata with configuration and schemas.
1233
- * @returns A handler result that is either static or dynamic.
1234
- */
1235
- provideHandler: (controller: ClassType, handlerMetadata: HandlerMetadata<any>) => Promise<HandlerResult>;
1236
- }
1237
- //#endregion
1238
- //#region src/interfaces/abstract-http-listen-options.interface.d.mts
1239
- interface AbstractHttpListenOptions {
1240
- port: number;
1241
- host?: string;
1242
- }
1243
- //#endregion
1244
- //#region src/interfaces/can-activate.d.mts
1245
- /**
1246
- * Interface that guards must implement to control access to endpoints.
1247
- *
1248
- * Guards are used for authentication, authorization, and request validation.
1249
- * They are executed before the endpoint handler and can prevent the request
1250
- * from proceeding by returning `false` or throwing an exception.
1251
- *
1252
- * @example
1253
- * ```typescript
1254
- * @Injectable()
1255
- * export class AuthGuard implements CanActivate {
1256
- * async canActivate(context: AbstractExecutionContext): Promise<boolean> {
1257
- * const request = context.getRequest()
1258
- * const token = request.headers.authorization
1259
- *
1260
- * if (!token) {
1261
- * throw new UnauthorizedException('Authentication required')
1262
- * }
1263
- *
1264
- * // Validate token
1265
- * return true
1266
- * }
1267
- * }
1268
- * ```
1269
- */
1270
- interface CanActivate {
1271
- /**
1272
- * Determines if the current request can proceed to the endpoint handler.
1273
- *
1274
- * @param executionContext - The execution context containing request, reply, and metadata
1275
- * @returns `true` if the request can proceed, `false` otherwise. Can also throw an exception.
1276
- */
1277
- canActivate(executionContext: AbstractExecutionContext): Promise<boolean> | boolean;
1278
- }
1279
- //#endregion
1280
- //#region src/interfaces/http-header.d.mts
1281
- type OmitIndexSignature<T> = { [K in keyof T as string extends K ? never : number extends K ? never : K]: T[K] };
1282
- /**
1283
- * HTTP header strings
1284
- * Use this type only for input values, not for output values.
1285
- */
1286
- type HttpHeader = keyof OmitIndexSignature<OutgoingHttpHeaders> | (string & Record<never, never>);
1287
- //#endregion
1288
- //#region src/interfaces/navios-module.d.mts
1289
- /**
1290
- * Interface that all Navios modules must implement.
1291
- *
1292
- * Modules decorated with @Module() should implement this interface to receive
1293
- * lifecycle hooks.
1294
- *
1295
- * @example
1296
- * ```typescript
1297
- * @Module({
1298
- * controllers: [UserController],
1299
- * })
1300
- * export class AppModule implements NaviosModule {
1301
- * async onModuleInit() {
1302
- * console.log('AppModule initialized')
1303
- * // Perform initialization logic
1304
- * }
1305
- * }
1306
- * ```
1307
- */
1308
- interface NaviosModule {
1309
- /**
1310
- * Optional lifecycle hook called after the module is initialized.
1311
- *
1312
- * This is called after all modules are loaded and the HTTP server is set up
1313
- * (if an adapter is configured), but before the server starts listening.
1314
- */
1315
- onModuleInit?: () => Promise<void> | void;
1316
- }
1317
- //#endregion
1318
- //#region src/interfaces/plugin-stage.d.mts
1319
- /**
1320
- * Base stage names (without pre:/post: prefix)
1321
- */
1322
- declare const PluginStageBase: {
1323
- readonly MODULES_TRAVERSE: "modules-traverse";
1324
- readonly ADAPTER_RESOLVE: "adapter-resolve";
1325
- readonly ADAPTER_SETUP: "adapter-setup";
1326
- readonly MODULES_INIT: "modules-init";
1327
- readonly READY: "ready";
1328
- };
1329
- type PluginStageBase = (typeof PluginStageBase)[keyof typeof PluginStageBase];
1330
- /**
1331
- * Full stage names with pre:/post: prefix
1332
- */
1333
- type PluginStage = `pre:${PluginStageBase}` | `post:${PluginStageBase}`;
1334
- /**
1335
- * Helper to create pre stage name from base
1336
- */
1337
- declare const preStage: <T extends PluginStageBase>(base: T) => `pre:${T}`;
1338
- /**
1339
- * Helper to create post stage name from base
1340
- */
1341
- declare const postStage: <T extends PluginStageBase>(base: T) => `post:${T}`;
1342
- /**
1343
- * All stages as constants for direct access
1344
- */
1345
- declare const PluginStages: {
1346
- readonly PRE_MODULES_TRAVERSE: "pre:modules-traverse";
1347
- readonly POST_MODULES_TRAVERSE: "post:modules-traverse";
1348
- readonly PRE_ADAPTER_RESOLVE: "pre:adapter-resolve";
1349
- readonly POST_ADAPTER_RESOLVE: "post:adapter-resolve";
1350
- readonly PRE_ADAPTER_SETUP: "pre:adapter-setup";
1351
- readonly POST_ADAPTER_SETUP: "post:adapter-setup";
1352
- readonly PRE_MODULES_INIT: "pre:modules-init";
1353
- readonly POST_MODULES_INIT: "post:modules-init";
1354
- readonly PRE_READY: "pre:ready";
1355
- readonly POST_READY: "post:ready";
1356
- };
1357
- /**
1358
- * All stages in execution order
1359
- */
1360
- declare const PLUGIN_STAGES_ORDER: readonly PluginStage[];
1361
- //#endregion
1362
- //#region src/services/module-loader.service.d.mts
1363
- /**
1364
- * Extension definition for dynamically adding to the module tree.
1365
- * Used by plugins to inject controllers or entire modules.
1366
- */
1367
- interface ModuleExtension {
1368
- /**
1369
- * Module class to add. If provided, the module and all its
1370
- * controllers/imports will be processed.
1371
- */
1372
- module?: ClassTypeWithInstance<NaviosModule>;
1373
- /**
1374
- * Controllers to add directly without a wrapper module.
1375
- * Will be registered under a synthetic module named after the plugin.
1376
- */
1377
- controllers?: ClassType[];
1378
- /**
1379
- * Name for the synthetic module when using controllers directly.
1380
- * Required if `controllers` is provided without `module`.
1381
- */
1382
- moduleName?: string;
1383
- }
1384
- declare class ModuleLoaderService {
1385
- private logger;
1386
- protected container: Container;
1387
- private modulesMetadata;
1388
- private loadedModules;
1389
- private initialized;
1390
- loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;
1391
- /**
1392
- * Extends the module tree with additional modules or controllers.
1393
- *
1394
- * This method is designed to be called by plugins during registration,
1395
- * which happens after initial module loading but before route registration.
1396
- *
1397
- * @param extensions - Array of module extensions to add
1398
- * @throws Error if not initialized (loadModules must be called first)
1399
- *
1400
- * @example
1401
- * ```typescript
1402
- * // In plugin registration
1403
- * const moduleLoader = await context.container.get(ModuleLoaderService)
1404
- * await moduleLoader.extendModules([{
1405
- * controllers: [OpenApiJsonController, OpenApiYamlController],
1406
- * moduleName: 'OpenApiBunModule',
1407
- * }])
1408
- * ```
1409
- */
1410
- extendModules(extensions: ModuleExtension[]): Promise<void>;
1411
- /**
1412
- * Registers controllers under a synthetic module.
1413
- * Used when plugins want to add controllers without a full module class.
1414
- */
1415
- private registerControllers;
1416
- private traverseModules;
1417
- private validateOverrides;
1418
- private mergeMetadata;
1419
- getAllModules(): Map<string, ModuleMetadata>;
1420
- dispose(): void;
1421
- }
1422
- //#endregion
1423
- //#region src/interfaces/plugin-context.d.mts
1424
- /**
1425
- * Container-only context available at early stages.
1426
- * Available at: pre:modules-traverse
1427
- */
1428
- interface ContainerOnlyContext {
1429
- /**
1430
- * The dependency injection container.
1431
- */
1432
- container: Container;
1433
- }
1434
- /**
1435
- * Context with modules loaded.
1436
- * Available at: post:modules-traverse, pre:adapter-resolve
1437
- */
1438
- interface ModulesLoadedContext extends ContainerOnlyContext {
1439
- /**
1440
- * All loaded modules with their metadata.
1441
- * Keys are module class names, values are their metadata.
1442
- */
1443
- modules: Map<string, ModuleMetadata>;
1444
- /**
1445
- * Module loader service for extending the module tree.
1446
- * Use `moduleLoader.extendModules()` to add controllers dynamically.
1447
- */
1448
- moduleLoader: ModuleLoaderService;
1449
- }
1450
- /**
1451
- * Full context with adapter available.
1452
- * Available at: post:adapter-resolve and all later stages
1453
- *
1454
- * @typeParam TAdapter - The adapter type, defaults to AbstractAdapterInterface
1455
- */
1456
- interface FullPluginContext<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> extends ModulesLoadedContext {
1457
- /**
1458
- * The current adapter instance.
1459
- * Use type guards or cast to adapter-specific types for HTTP methods.
1460
- */
1461
- adapter: TAdapter;
1462
- }
1463
- /**
1464
- * Maps each plugin stage to its available context type.
1465
- *
1466
- * @typeParam TAdapter - The adapter type for stages that have adapter access
1467
- */
1468
- interface PluginStageContextMap<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> {
1469
- 'pre:modules-traverse': ContainerOnlyContext;
1470
- 'post:modules-traverse': ModulesLoadedContext;
1471
- 'pre:adapter-resolve': ModulesLoadedContext;
1472
- 'post:adapter-resolve': FullPluginContext<TAdapter>;
1473
- 'pre:adapter-setup': FullPluginContext<TAdapter>;
1474
- 'post:adapter-setup': FullPluginContext<TAdapter>;
1475
- 'pre:modules-init': FullPluginContext<TAdapter>;
1476
- 'post:modules-init': FullPluginContext<TAdapter>;
1477
- 'pre:ready': FullPluginContext<TAdapter>;
1478
- 'post:ready': FullPluginContext<TAdapter>;
1479
- }
1480
- /**
1481
- * Helper type to get the context type for a specific stage.
1482
- *
1483
- * @typeParam S - The plugin stage
1484
- * @typeParam TAdapter - The adapter type for stages that have adapter access
1485
- *
1486
- * @example
1487
- * ```typescript
1488
- * type MyContext = ContextForStage<'pre:adapter-resolve'>
1489
- * // MyContext is ModulesLoadedContext (no adapter)
1490
- *
1491
- * type FullContext = ContextForStage<'post:modules-init', BunApplicationService>
1492
- * // FullContext has typed adapter
1493
- * ```
1494
- */
1495
- type ContextForStage<S extends PluginStage, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> = PluginStageContextMap<TAdapter>[S];
1496
- /**
1497
- * Context provided to plugins during registration.
1498
- *
1499
- * @deprecated Use stage-specific context types (ContainerOnlyContext,
1500
- * ModulesLoadedContext, FullPluginContext) for better type safety.
1501
- * This is an alias for FullPluginContext for backward compatibility.
1502
- *
1503
- * @typeParam TAdapter - The adapter type, defaults to AbstractAdapterInterface
1504
- */
1505
- type PluginContext<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> = FullPluginContext<TAdapter>;
1506
- //#endregion
1507
- //#region src/interfaces/staged-plugin.interface.d.mts
1508
- /**
1509
- * Base interface for staged plugins that target a specific lifecycle stage.
1510
- *
1511
- * @typeParam S - The target stage (e.g., 'pre:adapter-resolve')
1512
- * @typeParam TOptions - Plugin options type
1513
- * @typeParam TAdapter - Adapter type (only relevant for post-adapter stages)
1514
- *
1515
- * @example
1516
- * ```typescript
1517
- * const myPlugin: StagedPlugin<'pre:adapter-resolve', MyOptions> = {
1518
- * name: 'my-plugin',
1519
- * stage: 'pre:adapter-resolve',
1520
- * register: (context, options) => {
1521
- * // context is typed as ModulesLoadedContext
1522
- * },
1523
- * }
1524
- * ```
1525
- */
1526
- interface StagedPlugin<S extends PluginStage, TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> {
1527
- /**
1528
- * Plugin name for identification and logging.
1529
- */
1530
- readonly name: string;
1531
- /**
1532
- * The lifecycle stage this plugin targets.
1533
- */
1534
- readonly stage: S;
1535
- /**
1536
- * Called at the specified stage during application initialization.
1537
- *
1538
- * @param context - Stage-appropriate context
1539
- * @param options - Plugin-specific configuration options
1540
- */
1541
- register(context: ContextForStage<S, TAdapter>, options: TOptions): Promise<void> | void;
1542
- }
1543
- /**
1544
- * Plugin that runs before module tree traversal.
1545
- * Context: container only
1546
- */
1547
- interface PreModulesTraversePlugin<TOptions = unknown> extends StagedPlugin<'pre:modules-traverse', TOptions, never> {
1548
- register(context: ContainerOnlyContext, options: TOptions): Promise<void> | void;
1549
- }
1550
- /**
1551
- * Plugin that runs after module tree traversal.
1552
- * Context: container + modules + moduleLoader
1553
- */
1554
- interface PostModulesTraversePlugin<TOptions = unknown> extends StagedPlugin<'post:modules-traverse', TOptions, never> {
1555
- register(context: ModulesLoadedContext, options: TOptions): Promise<void> | void;
1556
- }
1557
- /**
1558
- * Plugin that runs before adapter is resolved from container.
1559
- * Context: container + modules + moduleLoader (NO adapter yet!)
1560
- *
1561
- * Use this stage to modify registry/bindings before adapter instantiation.
1562
- */
1563
- interface PreAdapterResolvePlugin<TOptions = unknown> extends StagedPlugin<'pre:adapter-resolve', TOptions, never> {
1564
- register(context: ModulesLoadedContext, options: TOptions): Promise<void> | void;
1565
- }
1566
- /**
1567
- * Plugin that runs after adapter is resolved.
1568
- * Context: full (container + modules + moduleLoader + adapter)
1569
- */
1570
- interface PostAdapterResolvePlugin<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> extends StagedPlugin<'post:adapter-resolve', TOptions, TAdapter> {
1571
- register(context: FullPluginContext<TAdapter>, options: TOptions): Promise<void> | void;
1572
- }
1573
- /**
1574
- * Plugin that runs before adapter setup.
1575
- * Context: full
1576
- */
1577
- interface PreAdapterSetupPlugin<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> extends StagedPlugin<'pre:adapter-setup', TOptions, TAdapter> {
1578
- register(context: FullPluginContext<TAdapter>, options: TOptions): Promise<void> | void;
1579
- }
1580
- /**
1581
- * Plugin that runs after adapter setup.
1582
- * Context: full
1583
- */
1584
- interface PostAdapterSetupPlugin<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> extends StagedPlugin<'post:adapter-setup', TOptions, TAdapter> {
1585
- register(context: FullPluginContext<TAdapter>, options: TOptions): Promise<void> | void;
1586
- }
1587
- /**
1588
- * Plugin that runs before modules init (route registration).
1589
- * Context: full
1590
- */
1591
- interface PreModulesInitPlugin<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> extends StagedPlugin<'pre:modules-init', TOptions, TAdapter> {
1592
- register(context: FullPluginContext<TAdapter>, options: TOptions): Promise<void> | void;
1593
- }
1594
- /**
1595
- * Plugin that runs after modules init (route registration).
1596
- * Context: full
1597
- *
1598
- * This is the default stage for legacy NaviosPlugin implementations.
1599
- */
1600
- interface PostModulesInitPlugin<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> extends StagedPlugin<'post:modules-init', TOptions, TAdapter> {
1601
- register(context: FullPluginContext<TAdapter>, options: TOptions): Promise<void> | void;
1602
- }
1603
- /**
1604
- * Plugin that runs before adapter signals ready.
1605
- * Context: full
1606
- */
1607
- interface PreReadyPlugin<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> extends StagedPlugin<'pre:ready', TOptions, TAdapter> {
1608
- register(context: FullPluginContext<TAdapter>, options: TOptions): Promise<void> | void;
1609
- }
1610
- /**
1611
- * Plugin that runs after adapter signals ready.
1612
- * Context: full - this is the final stage, app is fully initialized
1613
- */
1614
- interface PostReadyPlugin<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> extends StagedPlugin<'post:ready', TOptions, TAdapter> {
1615
- register(context: FullPluginContext<TAdapter>, options: TOptions): Promise<void> | void;
1616
- }
1617
- /**
1618
- * Plugin definition for staged plugins.
1619
- *
1620
- * @typeParam S - The target stage
1621
- * @typeParam TOptions - Plugin options type
1622
- * @typeParam TAdapter - Adapter type
1623
- */
1624
- interface StagedPluginDefinition<S extends PluginStage = PluginStage, TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> {
1625
- /**
1626
- * The staged plugin instance.
1627
- */
1628
- plugin: StagedPlugin<S, TOptions, TAdapter>;
1629
- /**
1630
- * Options to pass to the plugin's register function.
1631
- */
1632
- options: TOptions;
1633
- }
1634
- //#endregion
1635
- //#region src/interfaces/plugin.interface.d.mts
1636
- /**
1637
- * Base interface for Navios plugins (legacy).
1638
- *
1639
- * @deprecated Use staged plugins with explicit stage property instead.
1640
- * This interface maps to the `post:modules-init` stage.
1641
- * See `StagedPlugin` for the new pattern.
1642
- *
1643
- * Plugins are registered using `app.usePlugin()` and are initialized
1644
- * after all modules are loaded but before the server starts listening.
1645
- *
1646
- * @typeParam TOptions - The type of options the plugin accepts
1647
- * @typeParam TAdapter - The adapter type the plugin requires
1648
- *
1649
- * @example
1650
- * ```typescript
1651
- * // Legacy pattern (still works, maps to post:modules-init)
1652
- * const myPlugin: NaviosPlugin<{ enabled: boolean }> = {
1653
- * name: 'my-plugin',
1654
- * register: async (context, options) => {
1655
- * if (options.enabled) {
1656
- * // Register routes, services, etc.
1657
- * }
1658
- * },
1659
- * }
1660
- *
1661
- * // New pattern (recommended)
1662
- * import { definePostModulesInitPlugin } from '@navios/core'
1663
- *
1664
- * export const defineMyPlugin = definePostModulesInitPlugin()({
1665
- * name: 'my-plugin',
1666
- * register: async (context, options: { enabled: boolean }) => {
1667
- * // ...
1668
- * },
1669
- * })
1670
- * ```
1671
- */
1672
- interface NaviosPlugin<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> {
1673
- /**
1674
- * Plugin name for identification and logging.
1675
- */
1676
- name: string;
1677
- /**
1678
- * Called after modules are loaded but before the server starts listening.
1679
- *
1680
- * @param context - The plugin context with access to modules and adapter
1681
- * @param options - Plugin-specific configuration options
1682
- * @deprecated Use staged plugins with explicit stage property
1683
- */
1684
- register(context: PluginContext<TAdapter>, options: TOptions): Promise<void> | void;
1685
- }
1686
- /**
1687
- * Plugin definition combining a plugin with its options.
1688
- *
1689
- * @deprecated Use `StagedPluginDefinition` for new plugins.
1690
- * This type is kept for backward compatibility with legacy plugins.
1691
- *
1692
- * @typeParam TOptions - The type of options the plugin accepts
1693
- * @typeParam TAdapter - The adapter type the plugin requires
1694
- *
1695
- * @example
1696
- * ```typescript
1697
- * // Legacy pattern
1698
- * function defineMyPlugin(options: MyPluginOptions): PluginDefinition<MyPluginOptions> {
1699
- * return {
1700
- * plugin: myPlugin,
1701
- * options,
1702
- * }
1703
- * }
1704
- *
1705
- * // New pattern (recommended)
1706
- * import { definePostModulesInitPlugin } from '@navios/core'
1707
- *
1708
- * export const defineMyPlugin = definePostModulesInitPlugin()({
1709
- * name: 'my-plugin',
1710
- * register: (context, options: MyPluginOptions) => { ... },
1711
- * })
1712
- * ```
1713
- */
1714
- interface PluginDefinition<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> {
1715
- /**
1716
- * The plugin instance.
1717
- */
1718
- plugin: NaviosPlugin<TOptions, TAdapter>;
1719
- /**
1720
- * Options to pass to the plugin's register function.
1721
- */
1722
- options: TOptions;
1723
- }
1724
- /**
1725
- * Union of legacy and staged plugin definitions.
1726
- * Used internally by `usePlugin()` to accept both patterns.
1727
- */
1728
- type AnyPluginDefinition<TOptions = unknown, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface> = PluginDefinition<TOptions, TAdapter> | StagedPluginDefinition<PluginStage, TOptions, TAdapter>;
1729
- //#endregion
1730
- //#region src/decorators/header.decorator.d.mts
1731
- /**
1732
- * Decorator that sets a custom HTTP response header for an endpoint.
1733
- *
1734
- * @param name - The header name (e.g., 'Content-Type', 'Cache-Control')
1735
- * @param value - The header value (string, number, or array of strings)
1736
- * @returns A method decorator
1737
- *
1738
- * @example
1739
- * ```typescript
1740
- * @Controller()
1741
- * export class UserController {
1742
- * @Endpoint(getUserEndpoint)
1743
- * @Header('Cache-Control', 'max-age=3600')
1744
- * async getUser() {
1745
- * return { id: '1', name: 'John' }
1746
- * }
1747
- * }
1748
- * ```
1749
- */
1750
- declare function Header(name: HttpHeader, value: string | number | string[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
1751
- //#endregion
1752
- //#region src/decorators/http-code.decorator.d.mts
1753
- /**
1754
- * Decorator that sets a custom HTTP status code for successful responses.
1755
- *
1756
- * By default, endpoints return 200 OK. Use this decorator to return a different status code.
1757
- *
1758
- * @param code - The HTTP status code to return (e.g., 201, 204, 202)
1759
- * @returns A method decorator
1760
- *
1761
- * @example
1762
- * ```typescript
1763
- * @Controller()
1764
- * export class UserController {
1765
- * @Endpoint(createUserEndpoint)
1766
- * @HttpCode(201)
1767
- * async createUser() {
1768
- * return { id: '1', name: 'John' }
1769
- * }
1770
- * }
1771
- * ```
1772
- */
1773
- declare function HttpCode(code: number): <T extends Function>(target: T, context: ClassMethodDecoratorContext) => T;
1774
- //#endregion
1775
- //#region src/decorators/module.decorator.d.mts
1776
- /**
1777
- * Options for configuring a Navios module.
1778
- */
1779
- interface ModuleOptions {
1780
- /**
1781
- * Controllers to register in this module.
1782
- * Controllers handle HTTP requests and define endpoints.
1783
- */
1784
- controllers?: ClassType[] | Set<ClassType>;
1785
- /**
1786
- * Other modules to import into this module.
1787
- * Imported modules' controllers and services become available.
1788
- */
1789
- imports?: ClassType[] | Set<ClassType>;
1790
- /**
1791
- * Guards to apply to all controllers in this module.
1792
- * Guards are executed in reverse order (last guard first).
1793
- */
1794
- guards?: ClassType[] | Set<ClassType>;
1795
- /**
1796
- * Service override classes to import for side effects.
1797
- * These classes are imported to ensure their @Injectable decorators execute,
1798
- * allowing them to register with the DI system. Overrides should use the same
1799
- * InjectionToken as the original service with a higher priority.
1800
- */
1801
- overrides?: ClassType[] | Set<ClassType>;
1802
- /**
1803
- * Priority to use for the module.
1804
- * Priority is used to sort the module in the registry.
1805
- */
1806
- priority?: number;
1807
- /**
1808
- * Registry to use for the module.
1809
- * Registry is used to store the module and its controllers.
1810
- */
1811
- registry?: Registry;
1812
- }
1813
- /**
1814
- * Decorator that marks a class as a Navios module.
1815
- *
1816
- * Modules are the basic building blocks of a Navios application.
1817
- * They organize controllers, services, and other modules into logical units.
1818
- *
1819
- * @param options - Module configuration options
1820
- * @returns A class decorator
1821
- *
1822
- * @example
1823
- * ```typescript
1824
- * @Module({
1825
- * controllers: [UserController, AuthController],
1826
- * imports: [DatabaseModule],
1827
- * guards: [AuthGuard],
1828
- * })
1829
- * export class AppModule {}
1830
- * ```
1831
- */
1832
- declare function Module({
1833
- controllers,
1834
- imports,
1835
- guards,
1836
- overrides,
1837
- priority,
1838
- registry
1839
- }?: ModuleOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
1840
- //#endregion
1841
- //#region src/decorators/multipart.decorator.d.mts
1842
- /**
1843
- * Extracts the typed parameters for a multipart endpoint handler function.
1844
- *
1845
- * Similar to `EndpointParams`, but specifically for multipart/form-data endpoints.
1846
- *
1847
- * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
1848
- */
1849
- type MultipartParams<EndpointDeclaration extends {
1850
- config: EndpointOptions;
1851
- }, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? RequestArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], EndpointDeclaration['config']['urlParamsSchema'], true> : RequestArgs<Url, QuerySchema, undefined, EndpointDeclaration['config']['urlParamsSchema'], true> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? RequestArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], EndpointDeclaration['config']['urlParamsSchema'], true> : RequestArgs<Url, undefined, undefined, EndpointDeclaration['config']['urlParamsSchema'], true>;
1852
- /**
1853
- * Extracts the typed return value for a multipart endpoint handler function.
1854
- *
1855
- * @typeParam EndpointDeclaration - The endpoint declaration from @navios/builder
1856
- */
1857
- type MultipartResult<EndpointDeclaration extends {
1858
- config: EndpointOptions;
1859
- }> = EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<infer Options> ? Promise<z$1.input<Options[number]>> : Promise<z$1.input<EndpointDeclaration['config']['responseSchema']>>;
1860
- /**
1861
- * Decorator that marks a method as a multipart/form-data endpoint.
1862
- *
1863
- * Use this decorator for endpoints that handle file uploads or form data.
1864
- * The endpoint must be defined using @navios/builder's `declareMultipart` method.
1865
- *
1866
- * @param endpoint - The multipart endpoint declaration from @navios/builder
1867
- * @returns A method decorator
1868
- *
1869
- * @example
1870
- * ```typescript
1871
- * const uploadFileEndpoint = api.declareMultipart({
1872
- * method: 'post',
1873
- * url: '/upload',
1874
- * requestSchema: z.object({ file: z.instanceof(File) }),
1875
- * responseSchema: z.object({ url: z.string() }),
1876
- * })
1877
- *
1878
- * @Controller()
1879
- * export class FileController {
1880
- * @Multipart(uploadFileEndpoint)
1881
- * async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>) {
1882
- * const { file } = request.data
1883
- * // Handle file upload
1884
- * return { url: 'https://example.com/file.jpg' }
1885
- * }
1886
- * }
1887
- * ```
1888
- */
1889
- declare function Multipart<Config extends EndpointOptions>(endpoint: {
1890
- config: Config;
1891
- }): (target: (params: RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>) => Promise<z$1.input<Config['responseSchema']>> | z$1.input<Config['responseSchema']>, context: ClassMethodDecoratorContext) => void;
1892
- declare function Multipart<Config extends EndpointOptions>(endpoint: {
1893
- config: Config;
1894
- }): (target: () => Promise<z$1.input<Config['responseSchema']>> | z$1.input<Config['responseSchema']>, context: ClassMethodDecoratorContext) => void;
1895
- //#endregion
1896
- //#region src/decorators/stream.decorator.d.mts
1897
- /**
1898
- * Extracts the typed parameters for a stream endpoint handler function.
1899
- *
1900
- * Similar to `EndpointParams`, but specifically for streaming endpoints.
1901
- *
1902
- * @typeParam EndpointDeclaration - The stream endpoint declaration from @navios/builder
1903
- */
1904
- type StreamParams<EndpointDeclaration extends StreamHandler<Config, false>, Config extends BaseEndpointOptions = EndpointDeclaration['config'], Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? RequestArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], EndpointDeclaration['config']['urlParamsSchema'], true> : RequestArgs<Url, QuerySchema, undefined, EndpointDeclaration['config']['urlParamsSchema'], true> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? RequestArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], EndpointDeclaration['config']['urlParamsSchema'], true> : RequestArgs<Url, undefined, undefined, EndpointDeclaration['config']['urlParamsSchema'], true>;
1905
- /**
1906
- * Decorator that marks a method as a streaming endpoint.
1907
- *
1908
- * Use this decorator for endpoints that stream data (e.g., file downloads, SSE).
1909
- * The endpoint must be defined using @navios/builder's `declareStream` method.
1910
- *
1911
- * @param endpoint - The stream endpoint declaration from @navios/builder
1912
- * @returns A method decorator
1913
- *
1914
- * @example
1915
- * ```typescript
1916
- * const downloadFileEndpoint = api.declareStream({
1917
- * method: 'get',
1918
- * url: '/files/$fileId',
1919
- * })
1920
- *
1921
- * @Controller()
1922
- * export class FileController {
1923
- * @Stream(downloadFileEndpoint)
1924
- * async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {
1925
- * const { fileId } = request.urlParams
1926
- * // Stream file data to reply
1927
- * }
1928
- * }
1929
- * ```
1930
- */
1931
- declare function Stream<Config extends BaseEndpointOptions>(endpoint: {
1932
- config: Config;
1933
- }): (target: (params: RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>, reply: any) => any, context: ClassMethodDecoratorContext) => void;
1934
- declare function Stream<Config extends BaseEndpointOptions>(endpoint: {
1935
- config: Config;
1936
- }): (target: (params: RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>) => any, context: ClassMethodDecoratorContext) => void;
1937
- declare function Stream<Config extends BaseEndpointOptions>(endpoint: {
1938
- config: Config;
1939
- }): (target: () => any, context: ClassMethodDecoratorContext) => void;
1940
- //#endregion
1941
- //#region src/decorators/use-guards.decorator.d.mts
1942
- /**
1943
- * Decorator that applies guards to a controller or endpoint.
1944
- *
1945
- * Guards are used for authentication, authorization, and request validation.
1946
- * They implement the `CanActivate` interface and are executed before the endpoint handler.
1947
- * Guards can be applied at the module, controller, or endpoint level.
1948
- *
1949
- * @param guards - Guard classes or injection tokens to apply
1950
- * @returns A class or method decorator
1951
- *
1952
- * @example
1953
- * ```typescript
1954
- * // Apply to a controller
1955
- * @Controller()
1956
- * @UseGuards(AuthGuard, RoleGuard)
1957
- * export class UserController {
1958
- * @Endpoint(getUserEndpoint)
1959
- * async getUser() { }
1960
- * }
1961
- *
1962
- * // Apply to a specific endpoint
1963
- * @Controller()
1964
- * export class UserController {
1965
- * @Endpoint(getUserEndpoint)
1966
- * @UseGuards(AuthGuard)
1967
- * async getUser() { }
1968
- * }
1969
- * ```
1970
- */
1971
- declare function UseGuards(...guards: (ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>)[]): <T extends Function>(target: T, context: ClassMethodDecoratorContext | ClassDecoratorContext) => T;
1972
- //#endregion
1973
- //#region src/exceptions/http.exception.d.mts
1974
- /**
1975
- * Base exception class for all HTTP exceptions in Navios.
1976
- *
1977
- * All HTTP exception classes extend this base class. When thrown from an endpoint handler,
1978
- * Navios will automatically convert it to an appropriate HTTP response with the specified
1979
- * status code and response body.
1980
- *
1981
- * @example
1982
- * ```typescript
1983
- * @Endpoint(getUserEndpoint)
1984
- * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
1985
- * const user = await this.userService.findById(request.urlParams.userId)
1986
- * if (!user) {
1987
- * throw new HttpException(404, 'User not found')
1988
- * }
1989
- * return user
1990
- * }
1991
- * ```
1992
- */
1993
- declare class HttpException {
1994
- readonly statusCode: number;
1995
- readonly response: string | object;
1996
- readonly error?: Error | undefined;
1997
- /**
1998
- * Creates a new HttpException instance.
1999
- *
2000
- * @param statusCode - HTTP status code (e.g., 400, 404, 500)
2001
- * @param response - Response body (string or object)
2002
- * @param error - Optional underlying error for logging/debugging
2003
- */
2004
- constructor(statusCode: number, response: string | object, error?: Error | undefined);
2005
- }
2006
- //#endregion
2007
- //#region src/exceptions/bad-request.exception.d.mts
2008
- /**
2009
- * Exception that represents a 400 Bad Request HTTP error.
2010
- *
2011
- * Use this exception when the client's request is malformed or invalid.
2012
- *
2013
- * @example
2014
- * ```typescript
2015
- * @Endpoint(createUserEndpoint)
2016
- * async createUser(request: EndpointParams<typeof createUserEndpoint>) {
2017
- * if (!request.data.email) {
2018
- * throw new BadRequestException('Email is required')
2019
- * }
2020
- * // ...
2021
- * }
2022
- * ```
2023
- */
2024
- declare class BadRequestException extends HttpException {
2025
- /**
2026
- * Creates a new BadRequestException.
2027
- *
2028
- * @param message - Error message or response object
2029
- */
2030
- constructor(message: string | object);
2031
- }
2032
- //#endregion
2033
- //#region src/exceptions/forbidden.exception.d.mts
2034
- /**
2035
- * Exception that represents a 403 Forbidden HTTP error.
2036
- *
2037
- * Use this exception when the client is authenticated but does not have
2038
- * permission to access the requested resource.
2039
- *
2040
- * @example
2041
- * ```typescript
2042
- * @Endpoint(deleteUserEndpoint)
2043
- * @UseGuards(AuthGuard, RoleGuard)
2044
- * async deleteUser(request: EndpointParams<typeof deleteUserEndpoint>) {
2045
- * if (!this.userService.hasPermission(request.user, 'delete')) {
2046
- * throw new ForbiddenException('Insufficient permissions')
2047
- * }
2048
- * // ...
2049
- * }
2050
- * ```
2051
- */
2052
- declare class ForbiddenException extends HttpException {
2053
- /**
2054
- * Creates a new ForbiddenException.
2055
- *
2056
- * @param message - Error message
2057
- */
2058
- constructor(message: string);
2059
- }
2060
- //#endregion
2061
- //#region src/exceptions/internal-server-error.exception.d.mts
2062
- /**
2063
- * Exception that represents a 500 Internal Server Error HTTP error.
2064
- *
2065
- * Use this exception when an unexpected error occurs on the server.
2066
- * Generally, you should let unhandled errors bubble up rather than catching
2067
- * and rethrowing as InternalServerErrorException, as Navios will handle them appropriately.
2068
- *
2069
- * @example
2070
- * ```typescript
2071
- * @Endpoint(processPaymentEndpoint)
2072
- * async processPayment(request: EndpointParams<typeof processPaymentEndpoint>) {
2073
- * try {
2074
- * return await this.paymentService.process(request.data)
2075
- * } catch (error) {
2076
- * this.logger.error('Payment processing failed', error)
2077
- * throw new InternalServerErrorException('Payment processing failed', error)
2078
- * }
2079
- * }
2080
- * ```
2081
- */
2082
- declare class InternalServerErrorException extends HttpException {
2083
- /**
2084
- * Creates a new InternalServerErrorException.
2085
- *
2086
- * @param message - Error message or response object
2087
- * @param error - Optional underlying error for logging
2088
- */
2089
- constructor(message: string | object, error?: Error);
2090
- }
2091
- //#endregion
2092
- //#region src/exceptions/not-found.exception.d.mts
2093
- /**
2094
- * Exception that represents a 404 Not Found HTTP error.
2095
- *
2096
- * Use this exception when the requested resource does not exist.
2097
- *
2098
- * @example
2099
- * ```typescript
2100
- * @Endpoint(getUserEndpoint)
2101
- * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
2102
- * const user = await this.userService.findById(request.urlParams.userId)
2103
- * if (!user) {
2104
- * throw new NotFoundException('User not found')
2105
- * }
2106
- * return user
2107
- * }
2108
- * ```
2109
- */
2110
- declare class NotFoundException extends HttpException {
2111
- readonly response: string | object;
2112
- readonly error?: Error | undefined;
2113
- /**
2114
- * Creates a new NotFoundException.
2115
- *
2116
- * @param response - Error message or response object
2117
- * @param error - Optional underlying error for logging
2118
- */
2119
- constructor(response: string | object, error?: Error | undefined);
2120
- }
2121
- //#endregion
2122
- //#region src/exceptions/unauthorized.exception.d.mts
2123
- /**
2124
- * Exception that represents a 401 Unauthorized HTTP error.
2125
- *
2126
- * Use this exception when the client is not authenticated or authentication failed.
2127
- *
2128
- * @example
2129
- * ```typescript
2130
- * @Endpoint(getUserEndpoint)
2131
- * @UseGuards(AuthGuard)
2132
- * async getUser(request: EndpointParams<typeof getUserEndpoint>) {
2133
- * if (!request.headers.authorization) {
2134
- * throw new UnauthorizedException('Authentication required')
2135
- * }
2136
- * // ...
2137
- * }
2138
- * ```
2139
- */
2140
- declare class UnauthorizedException extends HttpException {
2141
- /**
2142
- * Creates a new UnauthorizedException.
2143
- *
2144
- * @param message - Error message or response object
2145
- * @param error - Optional underlying error for logging
2146
- */
2147
- constructor(message: string | object, error?: Error);
2148
- }
2149
- //#endregion
2150
- //#region src/exceptions/conflict.exception.d.mts
2151
- /**
2152
- * Exception that represents a 409 Conflict HTTP error.
2153
- *
2154
- * Use this exception when the request conflicts with the current state of the resource
2155
- * (e.g., trying to create a resource that already exists).
2156
- *
2157
- * @example
2158
- * ```typescript
2159
- * @Endpoint(createUserEndpoint)
2160
- * async createUser(request: EndpointParams<typeof createUserEndpoint>) {
2161
- * const existing = await this.userService.findByEmail(request.data.email)
2162
- * if (existing) {
2163
- * throw new ConflictException('User with this email already exists')
2164
- * }
2165
- * // ...
2166
- * }
2167
- * ```
2168
- */
2169
- declare class ConflictException extends HttpException {
2170
- /**
2171
- * Creates a new ConflictException.
2172
- *
2173
- * @param message - Error message or response object
2174
- * @param error - Optional underlying error for logging
2175
- */
2176
- constructor(message: string | object, error?: Error);
2177
- }
2178
- //#endregion
2179
- //#region src/responders/enums/framework-error.enum.d.mts
2180
- /**
2181
- * Enumeration of framework-level error types.
2182
- * Used to explicitly specify which error responder should handle an error.
2183
- *
2184
- * @example
2185
- * ```typescript
2186
- * // In adapter error handling
2187
- * if (error instanceof ZodError) {
2188
- * return errorProducer.respond(FrameworkError.ValidationError, error)
2189
- * }
2190
- * return errorProducer.handleUnknown(error)
2191
- * ```
2192
- */
2193
- declare enum FrameworkError {
2194
- /**
2195
- * Resource not found (HTTP 404).
2196
- * Use when a requested resource does not exist.
2197
- */
2198
- NotFound = "NotFound",
2199
- /**
2200
- * Forbidden (HTTP 403).
2201
- * Use when access to a resource is denied (e.g., guard rejection).
2202
- */
2203
- Forbidden = "Forbidden",
2204
- /**
2205
- * Internal server error (HTTP 500).
2206
- * Use for unexpected errors that don't fit other categories.
2207
- */
2208
- InternalServerError = "InternalServerError",
2209
- /**
2210
- * Validation error (HTTP 400).
2211
- * Use when request data fails validation (e.g., Zod errors).
2212
- */
2213
- ValidationError = "ValidationError",
2214
- }
2215
- //#endregion
2216
- //#region src/responders/interfaces/problem-details.interface.d.mts
2217
- /**
2218
- * RFC 7807 Problem Details for HTTP APIs
2219
- * @see https://tools.ietf.org/html/rfc7807
2220
- */
2221
- interface ProblemDetails {
2222
- /**
2223
- * A URI reference that identifies the problem type.
2224
- * When dereferenced, it should provide human-readable documentation.
2225
- * @default 'about:blank'
2226
- */
2227
- type?: string;
2228
- /**
2229
- * A short, human-readable summary of the problem type.
2230
- * It should not change from occurrence to occurrence.
2231
- */
2232
- title: string;
2233
- /**
2234
- * The HTTP status code for this occurrence of the problem.
2235
- */
2236
- status: number;
2237
- /**
2238
- * A human-readable explanation specific to this occurrence of the problem.
2239
- */
2240
- detail?: string;
2241
- /**
2242
- * Additional extension members.
2243
- * Custom properties can be added to provide more context.
2244
- */
2245
- [key: string]: unknown;
2246
- }
2247
- //#endregion
2248
- //#region src/responders/interfaces/error-response.interface.d.mts
2249
- /**
2250
- * Represents a complete error response that can be sent to the client.
2251
- * Includes the status code, payload (RFC 7807 Problem Details), and headers.
2252
- */
2253
- interface ErrorResponse {
2254
- /**
2255
- * HTTP status code for the response.
2256
- */
2257
- statusCode: number;
2258
- /**
2259
- * RFC 7807 Problem Details payload.
2260
- */
2261
- payload: ProblemDetails;
2262
- /**
2263
- * HTTP headers to include in the response.
2264
- */
2265
- headers: Record<string, string>;
2266
- }
2267
- //#endregion
2268
- //#region src/responders/interfaces/error-responder.interface.d.mts
2269
- /**
2270
- * Interface for error responders that convert errors to HTTP responses.
2271
- * Each responder handles a specific type of framework error and produces
2272
- * an RFC 7807 compliant response.
2273
- *
2274
- * Implementations are registered with low priority (-10) so they can be
2275
- * easily overridden by consumers.
2276
- *
2277
- * @example
2278
- * ```typescript
2279
- * @Injectable({
2280
- * token: InternalServerErrorResponderToken,
2281
- * priority: 0, // Override default implementation
2282
- * })
2283
- * export class CustomInternalErrorResponder implements ErrorResponder {
2284
- * getResponse(error: unknown, description?: string): ErrorResponse {
2285
- * return {
2286
- * statusCode: 500,
2287
- * payload: {
2288
- * type: 'https://api.myapp.com/errors/server-error',
2289
- * title: 'Server Error',
2290
- * status: 500,
2291
- * detail: description ?? 'An unexpected error occurred',
2292
- * },
2293
- * headers: { 'Content-Type': 'application/problem+json' },
2294
- * }
2295
- * }
2296
- * }
2297
- * ```
2298
- */
2299
- interface ErrorResponder {
2300
- /**
2301
- * Converts an error to an ErrorResponse with RFC 7807 Problem Details.
2302
- *
2303
- * @param error - The original error that was thrown
2304
- * @param description - Optional custom description to include in the response
2305
- * @returns ErrorResponse with status code, payload, and headers
2306
- */
2307
- getResponse(error: unknown, description?: string): ErrorResponse;
2308
- }
2309
- //#endregion
2310
- //#region src/responders/services/error-response-producer.service.d.mts
2311
- /**
2312
- * Service for producing standardized error responses.
2313
- *
2314
- * This service coordinates error responders to produce RFC 7807 compliant
2315
- * Problem Details responses. Adapters use this service to convert errors
2316
- * into standardized HTTP responses.
2317
- *
2318
- * The caller explicitly specifies which type of error response to produce
2319
- * via the FrameworkError enum, giving full control to the adapter.
2320
- *
2321
- * @example Usage in an adapter:
2322
- * ```typescript
2323
- * @Injectable()
2324
- * class MyAdapter {
2325
- * private errorProducer = inject(ErrorResponseProducerService)
2326
- *
2327
- * handleError(error: unknown): Response {
2328
- * if (error instanceof ZodError) {
2329
- * const response = this.errorProducer.respond(
2330
- * FrameworkError.ValidationError,
2331
- * error,
2332
- * )
2333
- * return new Response(JSON.stringify(response.payload), {
2334
- * status: response.statusCode,
2335
- * headers: response.headers,
2336
- * })
2337
- * }
2338
- *
2339
- * // Fallback for unknown errors
2340
- * const response = this.errorProducer.handleUnknown(error)
2341
- * return new Response(JSON.stringify(response.payload), {
2342
- * status: response.statusCode,
2343
- * headers: response.headers,
2344
- * })
2345
- * }
2346
- * }
2347
- * ```
2348
- */
2349
- declare class ErrorResponseProducerService {
2350
- private readonly forbiddenResponder;
2351
- private readonly internalServerErrorResponder;
2352
- private readonly notFoundResponder;
2353
- private readonly validationErrorResponder;
2354
- /**
2355
- * Produces an error response for a specific framework error type.
2356
- *
2357
- * @param type - The type of framework error (from FrameworkError enum)
2358
- * @param error - The original error that was thrown
2359
- * @param description - Optional custom description to include in the response
2360
- * @returns ErrorResponse with status code, RFC 7807 payload, and headers
2361
- */
2362
- respond(type: FrameworkError, error: unknown, description?: string): ErrorResponse;
2363
- /**
2364
- * Handles unknown errors by producing an Internal Server Error response.
2365
- *
2366
- * Use this as a fallback when the error type is not known or doesn't
2367
- * match any specific framework error type.
2368
- *
2369
- * @param error - The original error that was thrown
2370
- * @param description - Optional custom description to include in the response
2371
- * @returns ErrorResponse with 500 status code
2372
- */
2373
- handleUnknown(error: unknown, description?: string): ErrorResponse;
2374
- /**
2375
- * Convenience method to produce a Not Found error response.
2376
- *
2377
- * @param error - The original error that was thrown
2378
- * @param description - Optional custom description
2379
- * @returns ErrorResponse with 404 status code
2380
- */
2381
- notFound(error: unknown, description?: string): ErrorResponse;
2382
- /**
2383
- * Convenience method to produce a Validation Error response.
2384
- *
2385
- * @param error - The original error (typically a ZodError)
2386
- * @param description - Optional custom description
2387
- * @returns ErrorResponse with 400 status code
2388
- */
2389
- validationError(error: unknown, description?: string): ErrorResponse;
2390
- /**
2391
- * Convenience method to produce an Internal Server Error response.
2392
- *
2393
- * @param error - The original error
2394
- * @param description - Optional custom description
2395
- * @returns ErrorResponse with 500 status code
2396
- */
2397
- internalServerError(error: unknown, description?: string): ErrorResponse;
2398
- /**
2399
- * Convenience method to produce a Forbidden error response.
2400
- *
2401
- * @param error - The original error
2402
- * @param description - Optional custom description
2403
- * @returns ErrorResponse with 403 status code
2404
- */
2405
- forbidden(error: unknown, description?: string): ErrorResponse;
2406
- }
2407
- //#endregion
2408
- //#region src/responders/services/forbidden-responder.service.d.mts
2409
- /**
2410
- * Default responder for forbidden errors (HTTP 403).
2411
- *
2412
- * Converts errors to RFC 7807 Problem Details format.
2413
- * Used when access to a resource is denied (e.g., guard rejection).
2414
- * Registered with low priority (-10) so it can be easily overridden.
2415
- *
2416
- * @example Override with custom implementation:
2417
- * ```typescript
2418
- * @Injectable({
2419
- * token: ForbiddenResponderToken,
2420
- * priority: 0,
2421
- * })
2422
- * export class CustomForbiddenResponder implements ErrorResponder {
2423
- * getResponse(error: unknown, description?: string): ErrorResponse {
2424
- * return {
2425
- * statusCode: 403,
2426
- * payload: {
2427
- * type: 'https://api.myapp.com/errors/forbidden',
2428
- * title: 'Access Denied',
2429
- * status: 403,
2430
- * detail: description ?? 'You do not have permission to access this resource',
2431
- * },
2432
- * headers: { 'Content-Type': 'application/problem+json' },
2433
- * }
2434
- * }
2435
- * }
2436
- * ```
2437
- */
2438
- declare class ForbiddenResponderService implements ErrorResponder {
2439
- getResponse(error: unknown, description?: string): ErrorResponse;
2440
- private createResponse;
2441
- }
2442
- //#endregion
2443
- //#region src/responders/services/internal-server-error-responder.service.d.mts
2444
- /**
2445
- * Default responder for internal server errors (HTTP 500).
2446
- *
2447
- * Converts generic errors to RFC 7807 Problem Details format.
2448
- * Registered with low priority (-10) so it can be easily overridden.
2449
- *
2450
- * @example Override with custom implementation:
2451
- * ```typescript
2452
- * @Injectable({
2453
- * token: InternalServerErrorResponderToken,
2454
- * priority: 0,
2455
- * })
2456
- * export class CustomInternalErrorResponder implements ErrorResponder {
2457
- * getResponse(error: unknown, description?: string): ErrorResponse {
2458
- * return {
2459
- * statusCode: 500,
2460
- * payload: {
2461
- * type: 'https://api.myapp.com/errors/server-error',
2462
- * title: 'Server Error',
2463
- * status: 500,
2464
- * detail: description ?? 'An unexpected error occurred',
2465
- * },
2466
- * headers: { 'Content-Type': 'application/problem+json' },
2467
- * }
2468
- * }
2469
- * }
2470
- * ```
2471
- */
2472
- declare class InternalServerErrorResponderService implements ErrorResponder {
2473
- getResponse(error: unknown, description?: string): ErrorResponse;
2474
- }
2475
- //#endregion
2476
- //#region src/responders/services/not-found-responder.service.d.mts
2477
- /**
2478
- * Default responder for not found errors (HTTP 404).
2479
- *
2480
- * Converts errors to RFC 7807 Problem Details format.
2481
- * Registered with low priority (-10) so it can be easily overridden.
2482
- *
2483
- * @example Override with custom implementation:
2484
- * ```typescript
2485
- * @Injectable({
2486
- * token: NotFoundResponderToken,
2487
- * priority: 0,
2488
- * })
2489
- * export class CustomNotFoundResponder implements ErrorResponder {
2490
- * getResponse(error: unknown, description?: string): ErrorResponse {
2491
- * return {
2492
- * statusCode: 404,
2493
- * payload: {
2494
- * type: 'https://api.myapp.com/errors/not-found',
2495
- * title: 'Resource Not Found',
2496
- * status: 404,
2497
- * detail: description ?? 'The requested resource was not found',
2498
- * },
2499
- * headers: { 'Content-Type': 'application/problem+json' },
2500
- * }
2501
- * }
2502
- * }
2503
- * ```
2504
- */
2505
- declare class NotFoundResponderService implements ErrorResponder {
2506
- getResponse(error: unknown, description?: string): ErrorResponse;
2507
- private createResponse;
2508
- }
2509
- //#endregion
2510
- //#region src/responders/services/validation-error-responder.service.d.mts
2511
- /**
2512
- * Default responder for validation errors (HTTP 400).
2513
- *
2514
- * Converts Zod validation errors to RFC 7807 Problem Details format.
2515
- * Includes the structured validation errors from treeifyError.
2516
- * Registered with low priority (-10) so it can be easily overridden.
2517
- *
2518
- * @example Override with custom implementation:
2519
- * ```typescript
2520
- * @Injectable({
2521
- * token: ValidationErrorResponderToken,
2522
- * priority: 0,
2523
- * })
2524
- * export class CustomValidationResponder implements ErrorResponder {
2525
- * getResponse(error: unknown, description?: string): ErrorResponse {
2526
- * const zodError = error as ZodError
2527
- * return {
2528
- * statusCode: 422, // Use 422 instead of 400
2529
- * payload: {
2530
- * type: 'https://api.myapp.com/errors/validation',
2531
- * title: 'Unprocessable Entity',
2532
- * status: 422,
2533
- * detail: description ?? 'Validation failed',
2534
- * issues: zodError.issues,
2535
- * },
2536
- * headers: { 'Content-Type': 'application/problem+json' },
2537
- * }
2538
- * }
2539
- * }
2540
- * ```
2541
- */
2542
- declare class ValidationErrorResponderService implements ErrorResponder {
2543
- getResponse(error: unknown, description?: string): ErrorResponse;
2544
- }
2545
- //#endregion
2546
- //#region src/responders/tokens/responder.tokens.d.mts
2547
- /**
2548
- * Injection token for the Internal Server Error responder.
2549
- * Default implementation returns HTTP 500 with RFC 7807 Problem Details.
2550
- *
2551
- * @example Override with custom implementation:
2552
- * ```typescript
2553
- * @Injectable({
2554
- * token: InternalServerErrorResponderToken,
2555
- * priority: 0, // Higher than default -10
2556
- * })
2557
- * export class CustomInternalErrorResponder implements ErrorResponder {
2558
- * getResponse(error: unknown, description?: string): ErrorResponse {
2559
- * // Custom implementation
2560
- * }
2561
- * }
2562
- * ```
2563
- */
2564
- declare const InternalServerErrorResponderToken: InjectionToken<ErrorResponder, undefined, false>;
2565
- /**
2566
- * Injection token for the Not Found responder.
2567
- * Default implementation returns HTTP 404 with RFC 7807 Problem Details.
2568
- *
2569
- * @example Override with custom implementation:
2570
- * ```typescript
2571
- * @Injectable({
2572
- * token: NotFoundResponderToken,
2573
- * priority: 0, // Higher than default -10
2574
- * })
2575
- * export class CustomNotFoundResponder implements ErrorResponder {
2576
- * getResponse(error: unknown, description?: string): ErrorResponse {
2577
- * // Custom implementation
2578
- * }
2579
- * }
2580
- * ```
2581
- */
2582
- declare const NotFoundResponderToken: InjectionToken<ErrorResponder, undefined, false>;
2583
- /**
2584
- * Injection token for the Validation Error responder.
2585
- * Default implementation returns HTTP 400 with RFC 7807 Problem Details
2586
- * and includes validation errors from ZodError.
2587
- *
2588
- * @example Override with custom implementation:
2589
- * ```typescript
2590
- * @Injectable({
2591
- * token: ValidationErrorResponderToken,
2592
- * priority: 0, // Higher than default -10
2593
- * })
2594
- * export class CustomValidationResponder implements ErrorResponder {
2595
- * getResponse(error: unknown, description?: string): ErrorResponse {
2596
- * // Custom implementation
2597
- * }
2598
- * }
2599
- * ```
2600
- */
2601
- declare const ValidationErrorResponderToken: InjectionToken<ErrorResponder, undefined, false>;
2602
- /**
2603
- * Injection token for the Forbidden responder.
2604
- * Default implementation returns HTTP 403 with RFC 7807 Problem Details.
2605
- *
2606
- * @example Override with custom implementation:
2607
- * ```typescript
2608
- * @Injectable({
2609
- * token: ForbiddenResponderToken,
2610
- * priority: 0, // Higher than default -10
2611
- * })
2612
- * export class CustomForbiddenResponder implements ErrorResponder {
2613
- * getResponse(error: unknown, description?: string): ErrorResponse {
2614
- * // Custom implementation
2615
- * }
2616
- * }
2617
- * ```
2618
- */
2619
- declare const ForbiddenResponderToken: InjectionToken<ErrorResponder, undefined, false>;
2620
- //#endregion
2621
- //#region src/navios.environment.d.mts
2622
- interface NaviosEnvironmentOptions {
2623
- tokens?: Map<InjectionToken<any, undefined>, AnyInjectableType>;
2624
- }
2625
- //#endregion
2626
- //#region src/navios.application.d.mts
2627
- /**
2628
- * Options for configuring the Navios application context.
2629
- * These options control the application configuration.
2630
- */
2631
- interface NaviosApplicationOptions {
2632
- /**
2633
- * Specifies the logger to use. Pass `false` to turn off logging.
2634
- *
2635
- * - `LoggerService` instance: Use a custom logger implementation
2636
- * - `LogLevel[]`: Enable specific log levels (e.g., ['error', 'warn', 'log'])
2637
- * - `false`: Disable logging completely
2638
- */
2639
- logger?: LoggerService | LogLevel[] | false;
2640
- /**
2641
- * Specifies a custom registry to use. Useful for testing.
2642
- * If not provided, a new Registry will be created.
2643
- */
2644
- registry?: Registry;
2645
- /**
2646
- * Specifies a custom container to use. Useful for testing.
2647
- * If not provided, a new Container will be created.
2648
- */
2649
- container?: Container;
2650
- /**
2651
- * Adapter environment(s) to use for the application.
2652
- * Can be a single adapter or an array of adapters.
2653
- *
2654
- * @example
2655
- * ```typescript
2656
- * adapter: defineFastifyEnvironment()
2657
- * // or
2658
- * adapter: [defineFastifyEnvironment()]
2659
- * ```
2660
- */
2661
- adapter: NaviosEnvironmentOptions | NaviosEnvironmentOptions[];
2662
- /**
2663
- * Whether to validate response schemas.
2664
- * When `false`, response schema validation is skipped for better performance.
2665
- * @default true
2666
- */
2667
- validateResponses?: boolean;
2668
- /**
2669
- * Whether to enable request ID propagation via AsyncLocalStorage.
2670
- * When `true`, request IDs are available via `getRequestId()` throughout the request.
2671
- * @default false
2672
- */
2673
- enableRequestId?: boolean;
2674
- }
2675
- /**
2676
- * Main application class for Navios.
2677
- *
2678
- * This class represents a Navios application instance and provides methods
2679
- * for initializing, configuring, and managing the application lifecycle.
2680
- *
2681
- * @example
2682
- * ```typescript
2683
- * const app = await NaviosFactory.create(AppModule, {
2684
- * adapter: defineFastifyEnvironment(),
2685
- * })
2686
- *
2687
- * app.setGlobalPrefix('/api')
2688
- * app.enableCors({ origin: ['http://localhost:3000'] })
2689
- * await app.init()
2690
- * await app.listen({ port: 3000, host: '0.0.0.0' })
2691
- * ```
2692
- */
2693
- declare class NaviosApplication<Environment extends AdapterEnvironment = DefaultAdapterEnvironment> {
2694
- private environment;
2695
- private moduleLoader;
2696
- private adapter;
2697
- private logger;
2698
- protected container: Container;
2699
- private appModule;
2700
- private options;
2701
- /**
2702
- * Plugin storage organized by stage for efficient execution.
2703
- * Each stage has a Set of plugin definitions.
2704
- */
2705
- private plugins;
2706
- /**
2707
- * Queue of adapter configuration methods to apply after adapter resolution.
2708
- * Allows calling methods like enableCors() before init().
2709
- */
2710
- private pendingAdapterCalls;
2711
- /**
2712
- * Indicates whether the application has been initialized.
2713
- * Set to `true` after `init()` completes successfully.
2714
- */
2715
- isInitialized: boolean;
2716
- /**
2717
- * Sets up the application with the provided module and options.
2718
- * This is called automatically by NaviosFactory.create().
2719
- *
2720
- * Note: Adapter resolution has been moved to init() to allow
2721
- * plugins to modify the container/registry before adapter instantiation.
2722
- *
2723
- * @param appModule - The root application module
2724
- * @param options - Application configuration options
2725
- * @internal
2726
- */
2727
- setup(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): Promise<void>;
2728
- /**
2729
- * Gets the dependency injection container used by this application.
2730
- *
2731
- * @returns The Container instance
2732
- */
2733
- getContainer(): Container;
2734
- /**
2735
- * Returns the current adapter instance.
2736
- *
2737
- * @returns The adapter instance
2738
- * @throws Error if adapter is not initialized
2739
- */
2740
- getAdapter(): Environment['adapter'];
2741
- /**
2742
- * Registers one or more plugins for initialization during the application lifecycle.
2743
- *
2744
- * Plugins can target specific stages or use the legacy interface (defaults to post:modules-init).
2745
- * Plugins are executed in stage order, and within a stage in registration order.
2746
- *
2747
- * @param definitions - Single plugin definition or array of definitions
2748
- * @returns this for method chaining
2749
- *
2750
- * @example
2751
- * ```typescript
2752
- * // Single plugin (legacy or staged)
2753
- * app.usePlugin(defineOpenApiPlugin({ info: { title: 'My API', version: '1.0.0' } }))
2754
- *
2755
- * // Multiple plugins in one call
2756
- * app.usePlugin([
2757
- * defineOtelPlugin({ serviceName: 'my-service' }),
2758
- * defineOpenApiPlugin({ info: { title: 'My API', version: '1.0.0' } }),
2759
- * ])
2760
- *
2761
- * // Staged plugin with explicit stage
2762
- * app.usePlugin(definePreAdapterResolvePlugin({
2763
- * name: 'early-setup',
2764
- * register: (ctx) => { ... },
2765
- * })({}))
2766
- * ```
2767
- */
2768
- usePlugin<TOptions, TAdapter extends AbstractAdapterInterface>(definitions: AnyPluginDefinition<TOptions, TAdapter> | AnyPluginDefinition<TOptions, TAdapter>[]): this;
2769
- /**
2770
- * Resolves the stage for a plugin definition.
2771
- * Staged plugins use their explicit stage, legacy plugins default to post:modules-init.
2772
- */
2773
- private resolvePluginStage;
2774
- /**
2775
- * Initializes the application.
2776
- *
2777
- * This method executes the following lifecycle stages:
2778
- * 1. pre:modules-traverse → Load modules → post:modules-traverse
2779
- * 2. pre:adapter-resolve → Resolve adapter → post:adapter-resolve
2780
- * 3. pre:adapter-setup → Setup adapter → post:adapter-setup
2781
- * 4. pre:modules-init → Initialize modules → post:modules-init
2782
- * 5. pre:ready → Ready signal → post:ready
2783
- *
2784
- * Must be called before `listen()`.
2785
- *
2786
- * @throws Error if app module is not set
2787
- *
2788
- * @example
2789
- * ```typescript
2790
- * const app = await NaviosFactory.create(AppModule, {
2791
- * adapter: defineFastifyEnvironment(),
2792
- * })
2793
- * await app.init()
2794
- * await app.listen({ port: 3000 })
2795
- * ```
2796
- */
2797
- init(): Promise<void>;
2798
- /**
2799
- * Wraps an operation with pre/post plugin stage execution.
2800
- *
2801
- * @param baseName - The base stage name (e.g., 'modules-traverse')
2802
- * @param operation - The operation to execute between pre/post stages
2803
- */
2804
- private wrapStage;
2805
- /**
2806
- * Executes all plugins registered for a specific stage.
2807
- *
2808
- * @param stage - The lifecycle stage to execute plugins for
2809
- */
2810
- private executePluginStage;
2811
- /**
2812
- * Builds the appropriate context object for a given stage.
2813
- *
2814
- * @param stage - The lifecycle stage
2815
- * @returns Context object with stage-appropriate properties
2816
- */
2817
- private buildContextForStage;
2818
- private initModules;
2819
- /**
2820
- * Applies any pending adapter configuration calls that were queued
2821
- * before the adapter was resolved.
2822
- */
2823
- private applyPendingAdapterCalls;
2824
- /**
2825
- * Gets a service instance from the dependency injection container.
2826
- *
2827
- * This is a shorthand for `app.getContainer().get(token)`.
2828
- *
2829
- * @param token - The injection token or class to resolve
2830
- * @returns Promise resolving to the service instance
2831
- *
2832
- * @example
2833
- * ```typescript
2834
- * const userService = await app.get(UserService)
2835
- * const config = await app.get(ConfigToken)
2836
- * ```
2837
- */
2838
- get<T extends ClassType>(token: T): Promise<InstanceType<T>>;
2839
- get<T extends ClassTypeWithArgument<R>, R>(token: T, args: R): Promise<InstanceType<T>>;
2840
- get<T, S extends InjectionTokenSchemaType>(token: InjectionToken<T, S>, args: z$1.input<S>): Promise<T>;
2841
- get<T, S extends InjectionTokenSchemaType, R extends boolean>(token: InjectionToken<T, S, R>): Promise<T>;
2842
- get<T>(token: InjectionToken<T, undefined>): Promise<T>;
2843
- get<T>(token: BoundInjectionToken<T, any>): Promise<T>;
2844
- get<T>(token: FactoryInjectionToken<T, any>): Promise<T>;
2845
- /**
2846
- * Configures the adapter with additional options before initialization.
2847
- *
2848
- * This method allows setting adapter-specific configuration options
2849
- * before the adapter is initialized. Must be called before `init()`.
2850
- *
2851
- * @param options - Adapter-specific configuration options
2852
- * @returns this for method chaining
2853
- * @throws Error if called after init() or if adapter doesn't support configure
2854
- *
2855
- * @example
2856
- * ```typescript
2857
- * // With Fastify adapter
2858
- * app.configure({ trustProxy: true, logger: true })
2859
- *
2860
- * // With Bun adapter
2861
- * app.configure({ development: true })
2862
- * ```
2863
- */
2864
- configure(options: Partial<Environment['options']>): this;
2865
- /**
2866
- * Enables CORS (Cross-Origin Resource Sharing) for the application.
2867
- *
2868
- * @param options - CORS configuration options (adapter-specific)
2869
- * @throws Error if adapter doesn't support enableCors
2870
- *
2871
- * @example
2872
- * ```typescript
2873
- * app.enableCors({
2874
- * origin: ['http://localhost:3000', 'https://example.com'],
2875
- * methods: ['GET', 'POST', 'PUT', 'DELETE'],
2876
- * credentials: true,
2877
- * })
2878
- * ```
2879
- */
2880
- enableCors(options: Environment extends HttpAdapterEnvironment ? Environment['corsOptions'] : never): void;
2881
- /**
2882
- * Enables multipart/form-data support for file uploads.
2883
- *
2884
- * @param options - Multipart configuration options (adapter-specific)
2885
- * @throws Error if adapter doesn't support enableMultipart
2886
- *
2887
- * @example
2888
- * ```typescript
2889
- * app.enableMultipart({
2890
- * limits: {
2891
- * fileSize: 1024 * 1024 * 10, // 10MB
2892
- * },
2893
- * })
2894
- * ```
2895
- */
2896
- enableMultipart(options: Environment extends HttpAdapterEnvironment ? Environment['multipartOptions'] : never): void;
2897
- /**
2898
- * Sets a global prefix for all routes.
2899
- *
2900
- * @param prefix - The prefix to prepend to all route URLs (e.g., '/api')
2901
- * @throws Error if adapter doesn't support setGlobalPrefix
2902
- *
2903
- * @example
2904
- * ```typescript
2905
- * app.setGlobalPrefix('/api/v1')
2906
- * // All routes will be prefixed with /api/v1
2907
- * ```
2908
- */
2909
- setGlobalPrefix(prefix: string): void;
2910
- /**
2911
- * Gets the underlying HTTP server instance.
2912
- *
2913
- * The type of the returned server depends on the adapter used:
2914
- * - Fastify adapter: Returns FastifyInstance
2915
- * - Bun adapter: Returns Bun.Server
2916
- *
2917
- * @returns The HTTP server instance
2918
- * @throws Error if adapter doesn't support getServer
2919
- *
2920
- * @example
2921
- * ```typescript
2922
- * const server = app.getServer()
2923
- * // Use adapter-specific server methods
2924
- * ```
2925
- */
2926
- getServer(): Environment extends HttpAdapterEnvironment ? Environment['server'] : never;
2927
- /**
2928
- * Starts the HTTP server and begins listening for requests.
2929
- *
2930
- * @param options - Listen options (port, host, etc.)
2931
- * @throws Error if adapter doesn't support listen
2932
- *
2933
- * @example
2934
- * ```typescript
2935
- * await app.listen({ port: 3000, host: '0.0.0.0' })
2936
- * ```
2937
- */
2938
- listen(options: Environment extends HttpAdapterEnvironment ? Environment['listenOptions'] : never): Promise<string>;
2939
- /**
2940
- * Disposes of application resources.
2941
- *
2942
- * Cleans up the adapter and module loader.
2943
- * This method is called automatically by `close()`.
2944
- */
2945
- dispose(): Promise<void>;
2946
- /**
2947
- * Closes the application and cleans up all resources.
2948
- *
2949
- * This is an alias for `dispose()`.
2950
- *
2951
- * @example
2952
- * ```typescript
2953
- * // Graceful shutdown
2954
- * process.on('SIGTERM', async () => {
2955
- * await app.close()
2956
- * process.exit(0)
2957
- * })
2958
- * ```
2959
- */
2960
- close(): Promise<void>;
2961
- }
2962
- //#endregion
2963
- //#region src/services/instance-resolver.service.d.mts
2964
- /**
2965
- * Result of instance resolution attempt.
2966
- * Contains either a cached singleton instance or a resolver function
2967
- * that can be used to get a fresh instance per request.
2968
- */
2969
- interface InstanceResolution<T = any> {
2970
- /**
2971
- * Whether the instance was successfully cached as a singleton.
2972
- * If true, `instance` contains the cached instance.
2973
- * If false, the class has request-scoped dependencies and
2974
- * must be resolved per-request using `resolve()`.
2975
- */
2976
- cached: boolean;
2977
- /**
2978
- * The cached instance (only available if `cached` is true).
2979
- */
2980
- instance: T | null;
2981
- /**
2982
- * Resolves the instance from a scoped container.
2983
- * Use this when `cached` is false to get a fresh instance per request.
2984
- */
2985
- resolve: (scoped: ScopedContainer) => Promise<T>;
2986
- }
2987
- /**
2988
- * Result of resolving multiple instances.
2989
- * Contains either all cached singleton instances or a resolver function.
2990
- */
2991
- interface MultiInstanceResolution<T = any> {
2992
- /**
2993
- * Whether ALL instances were successfully cached as singletons.
2994
- * If true, `instances` contains all cached instances.
2995
- * If false, at least one class has request-scoped dependencies.
2996
- */
2997
- cached: boolean;
2998
- /**
2999
- * The cached instances (only available if `cached` is true).
3000
- * Order matches the input array order.
3001
- */
3002
- instances: T[] | null;
3003
- /**
3004
- * The original class types for dynamic resolution.
3005
- */
3006
- classTypes: ClassType[];
3007
- /**
3008
- * Resolves all instances from a scoped container.
3009
- * Use this when `cached` is false to get fresh instances per request.
3010
- */
3011
- resolve: (scoped: ScopedContainer) => Promise<T[]>;
3012
- }
3013
- /**
3014
- * Service responsible for resolving class instances with automatic scope detection.
3015
- *
3016
- * This service attempts to resolve classes as singletons from the root container.
3017
- * If resolution fails (because the class has request-scoped dependencies),
3018
- * it automatically updates the class's scope to Request and provides a
3019
- * resolver function for per-request instantiation.
3020
- *
3021
- * This enables optimal performance:
3022
- * - Classes without request-scoped deps stay as singletons (faster)
3023
- * - Classes with request-scoped deps are automatically promoted to request scope
3024
- *
3025
- * @example
3026
- * ```ts
3027
- * const resolution = await instanceResolver.resolve(UserController)
3028
- *
3029
- * if (resolution.cached) {
3030
- * // Use cached singleton
3031
- * return resolution.instance.handleRequest(req)
3032
- * } else {
3033
- * // Resolve per request
3034
- * const controller = await resolution.resolve(scopedContainer)
3035
- * return controller.handleRequest(req)
3036
- * }
3037
- * ```
3038
- */
3039
- declare class InstanceResolverService {
3040
- private container;
3041
- /**
3042
- * Attempts to resolve a class instance, automatically detecting if it needs
3043
- * request scope based on its dependencies.
3044
- *
3045
- * @param classType - The class to resolve
3046
- * @returns A resolution result containing either a cached instance or resolver function
3047
- */
3048
- resolve<T>(classType: ClassType): Promise<InstanceResolution<T>>;
3049
- /**
3050
- * Attempts to resolve multiple class instances, automatically detecting if any need
3051
- * request scope based on their dependencies.
3052
- *
3053
- * Returns `cached: true` only if ALL classes can be resolved as singletons.
3054
- * If any class has request-scoped dependencies, returns `cached: false`.
3055
- *
3056
- * @param classTypes - The classes to resolve
3057
- * @returns A resolution result containing either all cached instances or resolver function
3058
- */
3059
- resolveMany<T>(classTypes: ClassType[]): Promise<MultiInstanceResolution<T>>;
3060
- }
3061
- //#endregion
3062
- //#region src/services/abstract-handler-adapter.service.d.mts
3063
- /**
3064
- * Function type for argument getters that extract data from requests.
3065
- * Re-exported from interface for convenience in adapter implementations.
3066
- */
3067
- type ArgumentGetter<TRequest> = ArgumentGetterFn<TRequest>;
3068
- /**
3069
- * Internal alias for FormatArgumentsFn from interface.
3070
- * Not re-exported to avoid duplicate exports - use FormatArgumentsFn from interfaces instead.
3071
- */
3072
- type FormatArgumentsFn<TRequest> = FormatArgumentsFn$1<TRequest>;
3073
- /**
3074
- * Static handler - can be called without a scoped container.
3075
- */
3076
- type AbstractStaticHandler<TRequest, TReply = void> = {
3077
- isStatic: true;
3078
- handler: (request: TRequest, reply: TReply) => Promise<any>;
3079
- };
3080
- /**
3081
- * Dynamic handler - requires a scoped container for resolution.
3082
- */
3083
- type AbstractDynamicHandler<TRequest, TReply = void> = {
3084
- isStatic: false;
3085
- handler: (scoped: ScopedContainer, request: TRequest, reply: TReply) => Promise<any>;
3086
- };
3087
- /**
3088
- * Handler result - either static or dynamic.
3089
- */
3090
- type AbstractHandlerResult<TRequest, TReply = void> = AbstractStaticHandler<TRequest, TReply> | AbstractDynamicHandler<TRequest, TReply>;
3091
- /**
3092
- * Context passed to handler creation methods.
3093
- */
3094
- interface HandlerContext<TConfig extends BaseEndpointOptions = BaseEndpointOptions> {
3095
- methodName: string;
3096
- statusCode: number;
3097
- headers: Partial<Record<HttpHeader, number | string | string[] | undefined>>;
3098
- handlerMetadata: HandlerMetadata<TConfig>;
3099
- hasArguments: boolean;
3100
- }
3101
- /**
3102
- * Abstract base class for HTTP handler adapter services.
3103
- *
3104
- * Provides shared logic for:
3105
- * - Controller resolution (singleton vs request-scoped)
3106
- * - Argument formatting (sync/async detection)
3107
- * - Handler generation with static/dynamic branching
3108
- * - Standardized error handling
3109
- *
3110
- * Adapters implement abstract methods for framework-specific behavior:
3111
- * - Request parsing (query, body, URL params)
3112
- * - Response creation
3113
- * - Schema provision
3114
- *
3115
- * Supports all adapter types:
3116
- * - Endpoint adapters: JSON request/response with validation
3117
- * - Stream adapters: Streaming responses with extra context
3118
- * - Multipart adapters: Form data parsing (extends endpoint)
3119
- *
3120
- * @typeParam TRequest - Framework request type (BunRequest, FastifyRequest)
3121
- * @typeParam TReply - Framework reply type (void for Bun, FastifyReply)
3122
- * @typeParam TConfig - Endpoint configuration type
3123
- */
3124
- declare abstract class AbstractHandlerAdapterService<TRequest, TReply = void, TConfig extends BaseEndpointOptions = BaseEndpointOptions> {
3125
- protected instanceResolver: InstanceResolverService;
3126
- protected options: NaviosApplicationOptions;
3127
- /**
3128
- * Creates argument getter functions for extracting data from requests.
3129
- *
3130
- * Each getter populates a target object with data from the request
3131
- * (query params, body, URL params, etc.).
3132
- *
3133
- * Implementation varies by adapter type:
3134
- * - Endpoint: JSON body parsing with schema validation
3135
- * - Stream: Same as endpoint (body + query + url params)
3136
- * - Multipart: FormData/multipart stream parsing
3137
- *
3138
- * @param handlerMetadata - Handler metadata with schemas and configuration
3139
- * @returns Array of getter functions
3140
- */
3141
- protected abstract createArgumentGetters(handlerMetadata: HandlerMetadata<TConfig>): ArgumentGetter<TRequest>[];
3142
- /**
3143
- * Creates a static handler for singleton controllers.
3144
- *
3145
- * Implementation varies by adapter type:
3146
- * - Endpoint: Invoke method(args), serialize response as JSON
3147
- * - Stream: Invoke method(args, streamContext), return Response/use reply
3148
- *
3149
- * @param boundMethod - Pre-bound controller method
3150
- * @param formatArguments - Function to format request arguments
3151
- * @param context - Handler context with metadata
3152
- * @returns Static handler result
3153
- */
3154
- protected abstract createStaticHandler(boundMethod: (...args: any[]) => Promise<any>, formatArguments: FormatArgumentsFn<TRequest>, context: HandlerContext<TConfig>): AbstractStaticHandler<TRequest, TReply>;
3155
- /**
3156
- * Creates a dynamic handler for request-scoped controllers.
3157
- *
3158
- * Implementation varies by adapter type:
3159
- * - Endpoint: Resolve controller per-request, invoke method(args)
3160
- * - Stream: Resolve controller per-request, invoke method(args, streamContext)
3161
- *
3162
- * @param resolution - Instance resolution with resolve function
3163
- * @param formatArguments - Function to format request arguments
3164
- * @param context - Handler context with metadata
3165
- * @returns Dynamic handler result
3166
- */
3167
- protected abstract createDynamicHandler(resolution: InstanceResolution, formatArguments: FormatArgumentsFn<TRequest>, context: HandlerContext<TConfig>): AbstractDynamicHandler<TRequest, TReply>;
3168
- /**
3169
- * Prepares argument getters for parsing request data.
3170
- *
3171
- * Public alias for createArgumentGetters to satisfy interface contracts.
3172
- * Subclasses should override createArgumentGetters instead.
3173
- *
3174
- * @param handlerMetadata - Handler metadata with schemas and configuration
3175
- * @returns Array of getter functions
3176
- */
3177
- prepareArguments(handlerMetadata: HandlerMetadata<TConfig>): ArgumentGetter<TRequest>[];
3178
- /**
3179
- * Checks if the handler has any validation schemas defined.
3180
- *
3181
- * Override in subclasses to add additional schema checks
3182
- * (e.g., response schema validation for endpoint adapters).
3183
- *
3184
- * @param handlerMetadata - Handler metadata with configuration
3185
- * @returns true if handler has schemas
3186
- */
3187
- hasSchema(handlerMetadata: HandlerMetadata<TConfig>): boolean;
3188
- /**
3189
- * Provides schema information for the framework's validation system.
3190
- *
3191
- * Override in subclasses for frameworks that support schema registration
3192
- * (e.g., Fastify). Default returns empty object (suitable for Bun).
3193
- *
3194
- * @param handlerMetadata - Handler metadata with configuration
3195
- * @returns Schema object for framework registration
3196
- */
3197
- provideSchema(_handlerMetadata: HandlerMetadata<TConfig>): Record<string, any>;
3198
- /**
3199
- * Creates a request handler function for the endpoint.
3200
- *
3201
- * This method orchestrates the entire handler creation:
3202
- * 1. Prepares argument getters for request parsing
3203
- * 2. Builds optimized formatArguments function (sync/async)
3204
- * 3. Resolves the controller (singleton vs request-scoped)
3205
- * 4. Creates appropriate handler (static or dynamic)
3206
- *
3207
- * @param controller - Controller class containing the handler method
3208
- * @param handlerMetadata - Handler metadata with configuration
3209
- * @returns Handler result (static or dynamic)
3210
- */
3211
- provideHandler(controller: ClassType, handlerMetadata: HandlerMetadata<TConfig>): Promise<AbstractHandlerResult<TRequest, TReply>>;
3212
- /**
3213
- * Builds a formatArguments function from argument getters.
3214
- *
3215
- * Automatically detects sync vs async getters and optimizes accordingly:
3216
- * - If all getters are sync: returns sync function (no Promise overhead)
3217
- * - If any getter is async: returns async function with Promise.all
3218
- * - If no getters: returns frozen empty object (zero allocation)
3219
- *
3220
- * This method is public to allow composition-based adapters (like XML adapter)
3221
- * to reuse the optimized formatArguments logic without inheritance.
3222
- *
3223
- * @param getters - Array of argument getter functions
3224
- * @returns Function to format arguments from request
3225
- */
3226
- buildFormatArguments(getters: ArgumentGetter<TRequest>[]): FormatArgumentsFn<TRequest>;
3227
- /**
3228
- * Checks if the URL pattern contains URL parameters.
3229
- *
3230
- * @param config - Endpoint configuration
3231
- * @returns true if URL contains '$' parameter markers
3232
- */
3233
- protected hasUrlParams(config: TConfig): boolean;
3234
- /**
3235
- * Wraps handler execution with standardized error handling.
3236
- *
3237
- * Re-throws HttpExceptions as-is for framework error handlers.
3238
- * Other errors are re-thrown for global error handling.
3239
- *
3240
- * @param fn - Handler function to wrap
3241
- * @returns Wrapped function with error handling
3242
- */
3243
- protected wrapWithErrorHandling<T extends (...args: any[]) => Promise<any>>(fn: T): T;
3244
- }
3245
- //#endregion
3246
- //#region src/services/guard-runner.service.d.mts
3247
- declare class GuardRunnerService {
3248
- private readonly errorProducer;
3249
- private readonly logger;
3250
- /**
3251
- * Runs guards that need to be resolved from a scoped container.
3252
- * Use this when guards have request-scoped dependencies.
3253
- */
3254
- runGuards(allGuards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>, executionContext: AbstractExecutionContext, context: ScopedContainer): Promise<boolean>;
3255
- /**
3256
- * Runs pre-resolved guard instances.
3257
- * Use this when all guards are singletons and have been pre-resolved at startup.
3258
- */
3259
- runGuardsStatic(guardInstances: CanActivate[], executionContext: AbstractExecutionContext): Promise<boolean>;
3260
- /**
3261
- * Shared guard execution logic.
3262
- * Iterates through guard instances and calls canActivate on each.
3263
- */
3264
- private executeGuards;
3265
- makeContext(moduleMetadata: ModuleMetadata, controllerMetadata: ControllerMetadata, endpoint: HandlerMetadata): Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
3266
- }
3267
- //#endregion
3268
- //#region src/stores/request-id.store.d.mts
3269
- /**
3270
- * Generates a simple incremental request ID.
3271
- * Much faster than crypto.randomUUID() and sufficient for request tracking.
3272
- *
3273
- * @returns A unique request ID string (e.g., "req-1", "req-2", ...)
3274
- */
3275
- declare function generateRequestId(): string;
3276
- /**
3277
- * Enables or disables request ID propagation.
3278
- * Called by NaviosFactory based on the enableRequestId option.
3279
- *
3280
- * @param enabled - Whether to enable request ID propagation
3281
- */
3282
- declare function setRequestIdEnabled(enabled: boolean): void;
3283
- /**
3284
- * Runs a function with a request ID in the async local storage context.
3285
- * If request ID propagation is disabled, the function is called directly
3286
- * without AsyncLocalStorage overhead.
3287
- *
3288
- * @param requestId - The request ID to set for this context
3289
- * @param fn - The function to run within this context
3290
- * @returns The return value of the function
3291
- */
3292
- declare function runWithRequestId<R>(requestId: string, fn: () => R): R;
3293
- /**
3294
- * Gets the current request ID from the async local storage context.
3295
- *
3296
- * @returns The current request ID, or undefined if not in a request context
3297
- */
3298
- declare function getRequestId(): string | undefined;
3299
- //#endregion
3300
- //#region src/tokens/adapter.token.d.mts
3301
- declare const AdapterToken: InjectionToken<AbstractAdapterInterface, undefined, false>;
3302
- //#endregion
3303
- //#region src/tokens/endpoint-adapter.token.d.mts
3304
- declare const EndpointAdapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface<any>, undefined, false>;
3305
- //#endregion
3306
- //#region src/tokens/execution-context.token.d.mts
3307
- declare const ExecutionContextInjectionToken = "ExecutionContextInjectionToken";
3308
- declare const ExecutionContext: InjectionToken<AbstractExecutionContext, undefined, false>;
3309
- //#endregion
3310
- //#region src/tokens/http-adapter.token.d.mts
3311
- declare const HttpAdapterToken: InjectionToken<AbstractHttpAdapterInterface<HttpAdapterEnvironment>, undefined, false>;
3312
- //#endregion
3313
- //#region src/tokens/multipart-adapter.token.d.mts
3314
- declare const MultipartAdapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface<any>, undefined, false>;
3315
- //#endregion
3316
- //#region src/tokens/navios-options.token.d.mts
3317
- declare const NaviosOptionsToken: InjectionToken<NaviosApplicationOptions, undefined, false>;
3318
- //#endregion
3319
- //#region src/tokens/reply.token.d.mts
3320
- declare const Reply: InjectionToken<any, undefined, false>;
3321
- //#endregion
3322
- //#region src/tokens/request.token.d.mts
3323
- declare const Request: InjectionToken<any, undefined, false>;
3324
- //#endregion
3325
- //#region src/tokens/stream-adapter.token.d.mts
3326
- declare const StreamAdapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface<any>, undefined, false>;
3327
- //#endregion
3328
- //#region src/tokens/xml-stream-adapter.token.d.mts
3329
- declare const XmlStreamAdapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface<any>, undefined, false>;
3330
- //#endregion
3331
- //#region src/utils/adapter-supports.util.d.mts
3332
- /**
3333
- * Type guard to check if adapter implements a specific method.
3334
- * Narrows the adapter type to include the method.
3335
- *
3336
- * @example
3337
- * ```typescript
3338
- * if (adapterSupports(adapter, 'getServer')) {
3339
- * const server = adapter.getServer() // TypeScript knows this exists
3340
- * }
3341
- * ```
3342
- */
3343
- declare function adapterSupports<TAdapter extends AbstractAdapterInterface, TMethod extends string>(adapter: TAdapter | null, method: TMethod): adapter is TAdapter & Record<TMethod, (...args: unknown[]) => unknown>;
3344
- /**
3345
- * Asserts adapter supports a method, throws if not.
3346
- * Narrows type after assertion.
3347
- *
3348
- * @example
3349
- * ```typescript
3350
- * assertAdapterSupports(adapter, 'enableCors')
3351
- * adapter.enableCors(options) // TypeScript knows this exists
3352
- * ```
3353
- */
3354
- declare function assertAdapterSupports<TAdapter extends AbstractAdapterInterface, TMethod extends string>(adapter: TAdapter | null, method: TMethod): asserts adapter is TAdapter & Record<TMethod, (...args: unknown[]) => unknown>;
3355
- //#endregion
3356
- //#region src/utils/define-plugin.d.mts
3357
- interface PluginConfig<TContext, TOptions> {
3358
- name: string;
3359
- register: (context: TContext, options: TOptions) => Promise<void> | void;
3360
- }
3361
- /**
3362
- * Define a plugin that runs before modules are traversed.
3363
- *
3364
- * Context: container only
3365
- *
3366
- * Use this stage for early DI setup before any modules are loaded.
3367
- *
3368
- * @example
3369
- * ```typescript
3370
- * export const defineEarlySetupPlugin = definePreModulesTraversePlugin({
3371
- * name: 'early-setup',
3372
- * register: (context, options: { key: string }) => {
3373
- * context.container.addInstance(SomeToken, options.key)
3374
- * },
3375
- * })
3376
- *
3377
- * // Usage
3378
- * app.usePlugin(defineEarlySetupPlugin({ key: 'value' }))
3379
- * ```
3380
- */
3381
- declare const definePreModulesTraversePlugin: <TOptions, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<ContainerOnlyContext, TOptions>) => (options: TOptions) => StagedPluginDefinition<"pre:modules-traverse", TOptions, TAdapter>;
3382
- /**
3383
- * Define a plugin that runs after modules are traversed.
3384
- *
3385
- * Context: container + modules + moduleLoader
3386
- *
3387
- * Use this stage to inspect loaded modules or extend the module tree.
3388
- *
3389
- * @example
3390
- * ```typescript
3391
- * export const defineModuleInspectorPlugin = definePostModulesTraversePlugin({
3392
- * name: 'module-inspector',
3393
- * register: (context, options) => {
3394
- * console.log('Loaded modules:', context.modules.size)
3395
- * },
3396
- * })
3397
- * ```
3398
- */
3399
- declare const definePostModulesTraversePlugin: <TOptions, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<ModulesLoadedContext, TOptions>) => (options: TOptions) => StagedPluginDefinition<"post:modules-traverse", TOptions, TAdapter>;
3400
- /**
3401
- * Define a plugin that runs before adapter is resolved from container.
3402
- *
3403
- * Context: container + modules + moduleLoader (NO adapter yet!)
3404
- *
3405
- * Use this stage to modify registry/bindings before adapter instantiation.
3406
- * This is ideal for instrumentation, service wrapping, or changing DI bindings.
3407
- *
3408
- * @example
3409
- * ```typescript
3410
- * export const defineOtelPlugin = definePreAdapterResolvePlugin({
3411
- * name: 'otel',
3412
- * register: (context, options: OtelOptions) => {
3413
- * const registry = context.container.getRegistry()
3414
- * // Modify registry before adapter is created
3415
- * },
3416
- * })
3417
- *
3418
- * // Usage
3419
- * app.usePlugin(defineOtelPlugin({ serviceName: 'my-app' }))
3420
- * ```
3421
- */
3422
- declare const definePreAdapterResolvePlugin: <TOptions, TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<ModulesLoadedContext, TOptions>) => (options: TOptions) => StagedPluginDefinition<"pre:adapter-resolve", TOptions, TAdapter>;
3423
- /**
3424
- * Define a plugin that runs after adapter is resolved.
3425
- *
3426
- * Context: full (container + modules + moduleLoader + adapter)
3427
- *
3428
- * @example
3429
- * ```typescript
3430
- * export const defineAdapterConfigPlugin = definePostAdapterResolvePlugin<
3431
- * { prefix: string },
3432
- * BunApplicationServiceInterface
3433
- * >()({
3434
- * name: 'adapter-config',
3435
- * register: (context, options) => {
3436
- * context.adapter.setGlobalPrefix(options.prefix)
3437
- * },
3438
- * })
3439
- * ```
3440
- */
3441
- declare function definePostAdapterResolvePlugin<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(): <TOptions, TAdapter_1 extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<FullPluginContext<TAdapter>, TOptions>) => (options: TOptions) => StagedPluginDefinition<"post:adapter-resolve", TOptions, TAdapter_1>;
3442
- /**
3443
- * Define a plugin that runs before adapter setup.
3444
- *
3445
- * Context: full
3446
- */
3447
- declare function definePreAdapterSetupPlugin<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(): <TOptions, TAdapter_1 extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<FullPluginContext<TAdapter>, TOptions>) => (options: TOptions) => StagedPluginDefinition<"pre:adapter-setup", TOptions, TAdapter_1>;
3448
- /**
3449
- * Define a plugin that runs after adapter setup.
3450
- *
3451
- * Context: full
3452
- */
3453
- declare function definePostAdapterSetupPlugin<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(): <TOptions, TAdapter_1 extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<FullPluginContext<TAdapter>, TOptions>) => (options: TOptions) => StagedPluginDefinition<"post:adapter-setup", TOptions, TAdapter_1>;
3454
- /**
3455
- * Define a plugin that runs before modules init (route registration).
3456
- *
3457
- * Context: full
3458
- */
3459
- declare function definePreModulesInitPlugin<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(): <TOptions, TAdapter_1 extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<FullPluginContext<TAdapter>, TOptions>) => (options: TOptions) => StagedPluginDefinition<"pre:modules-init", TOptions, TAdapter_1>;
3460
- /**
3461
- * Define a plugin that runs after modules init (route registration).
3462
- *
3463
- * Context: full
3464
- *
3465
- * This is the default stage for legacy NaviosPlugin implementations.
3466
- *
3467
- * @example
3468
- * ```typescript
3469
- * export const defineOpenApiPlugin = definePostModulesInitPlugin<
3470
- * BunApplicationServiceInterface
3471
- * >()({
3472
- * name: 'openapi',
3473
- * register: async (context, options: OpenApiOptions) => {
3474
- * // Routes are registered, can generate OpenAPI docs
3475
- * },
3476
- * })
3477
- * ```
3478
- */
3479
- declare function definePostModulesInitPlugin<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(): <TOptions, TAdapter_1 extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<FullPluginContext<TAdapter>, TOptions>) => (options: TOptions) => StagedPluginDefinition<"post:modules-init", TOptions, TAdapter_1>;
3480
- /**
3481
- * Define a plugin that runs before adapter signals ready.
3482
- *
3483
- * Context: full
3484
- */
3485
- declare function definePreReadyPlugin<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(): <TOptions, TAdapter_1 extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<FullPluginContext<TAdapter>, TOptions>) => (options: TOptions) => StagedPluginDefinition<"pre:ready", TOptions, TAdapter_1>;
3486
- /**
3487
- * Define a plugin that runs after adapter signals ready.
3488
- *
3489
- * Context: full - this is the final stage, app is fully initialized
3490
- *
3491
- * @example
3492
- * ```typescript
3493
- * export const defineStartupLogPlugin = definePostReadyPlugin()({
3494
- * name: 'startup-log',
3495
- * register: (context) => {
3496
- * console.log('Application fully initialized!')
3497
- * },
3498
- * })
3499
- * ```
3500
- */
3501
- declare function definePostReadyPlugin<TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface>(): <TOptions, TAdapter_1 extends AbstractAdapterInterface = AbstractAdapterInterface>(config: PluginConfig<FullPluginContext<TAdapter>, TOptions>) => (options: TOptions) => StagedPluginDefinition<"post:ready", TOptions, TAdapter_1>;
3502
- //#endregion
3503
- //#region src/attribute.factory.d.mts
3504
- /**
3505
- * Type for a class attribute decorator without a value.
3506
- *
3507
- * Attributes are custom metadata decorators that can be applied to modules,
3508
- * controllers, and endpoints.
3509
- */
3510
- type ClassAttribute = (() => <T>(target: T, context: ClassDecoratorContext | ClassMethodDecoratorContext) => T) & {
3511
- token: symbol;
3512
- };
3513
- /**
3514
- * Type for a class attribute decorator with a validated value.
3515
- *
3516
- * @typeParam T - The Zod schema type for validation
3517
- */
3518
- type ClassSchemaAttribute<T extends ZodType> = ((value: z$1.input<T>) => <T>(target: T, context: ClassDecoratorContext | ClassMethodDecoratorContext) => T) & {
3519
- token: symbol;
3520
- schema: ZodType;
3521
- };
3522
- /**
3523
- * Factory for creating custom attribute decorators.
3524
- *
3525
- * Attributes allow you to add custom metadata to modules, controllers, and endpoints.
3526
- * This is useful for cross-cutting concerns like rate limiting, caching, API versioning, etc.
3527
- *
3528
- * @example
3529
- * ```typescript
3530
- * // Create a simple boolean attribute
3531
- * const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
3532
- *
3533
- * // Use it as a decorator
3534
- * @Controller()
3535
- * @Public()
3536
- * export class PublicController { }
3537
- *
3538
- * // Check if attribute exists
3539
- * if (AttributeFactory.has(Public, controllerMetadata)) {
3540
- * // Skip authentication
3541
- * }
3542
- * ```
3543
- *
3544
- * @example
3545
- * ```typescript
3546
- * // Create an attribute with a validated value
3547
- * const RateLimit = AttributeFactory.createAttribute(
3548
- * Symbol.for('RateLimit'),
3549
- * z.object({ requests: z.number(), window: z.number() })
3550
- * )
3551
- *
3552
- * // Use it with a value
3553
- * @Endpoint(apiEndpoint)
3554
- * @RateLimit({ requests: 100, window: 60000 })
3555
- * async handler() { }
3556
- *
3557
- * // Get the value
3558
- * const limit = AttributeFactory.get(RateLimit, endpointMetadata)
3559
- * // limit is typed as { requests: number, window: number } | null
3560
- * ```
3561
- */
3562
- declare class AttributeFactory {
3563
- /**
3564
- * Creates a simple attribute decorator without a value.
3565
- *
3566
- * @param token - A unique symbol to identify this attribute
3567
- * @returns A decorator function that can be applied to classes or methods
3568
- *
3569
- * @example
3570
- * ```typescript
3571
- * const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
3572
- *
3573
- * @Public()
3574
- * @Controller()
3575
- * export class PublicController { }
3576
- * ```
3577
- */
3578
- static createAttribute(token: symbol): ClassAttribute;
3579
- /**
3580
- * Creates an attribute decorator with a validated value.
3581
- *
3582
- * @param token - A unique symbol to identify this attribute
3583
- * @param schema - A Zod schema to validate the attribute value
3584
- * @returns A decorator function that accepts a value and can be applied to classes or methods
3585
- *
3586
- * @example
3587
- * ```typescript
3588
- * const RateLimit = AttributeFactory.createAttribute(
3589
- * Symbol.for('RateLimit'),
3590
- * z.object({ requests: z.number(), window: z.number() })
3591
- * )
3592
- *
3593
- * @RateLimit({ requests: 100, window: 60000 })
3594
- * @Endpoint(apiEndpoint)
3595
- * async handler() { }
3596
- * ```
3597
- */
3598
- static createAttribute<T extends ZodType>(token: symbol, schema: T): ClassSchemaAttribute<T>;
3599
- /**
3600
- * Gets the value of an attribute from metadata.
3601
- *
3602
- * Returns `null` if the attribute is not present.
3603
- * For simple attributes (without values), returns `true` if present.
3604
- *
3605
- * @param attribute - The attribute decorator
3606
- * @param target - The metadata object (module, controller, or handler)
3607
- * @returns The attribute value, `true` for simple attributes, or `null` if not found
3608
- *
3609
- * @example
3610
- * ```typescript
3611
- * const isPublic = AttributeFactory.get(Public, controllerMetadata)
3612
- * // isPublic is true | null
3613
- *
3614
- * const rateLimit = AttributeFactory.get(RateLimit, endpointMetadata)
3615
- * // rateLimit is { requests: number, window: number } | null
3616
- * ```
3617
- */
3618
- static get(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): true | null;
3619
- static get<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): z$1.output<T> | null;
3620
- /**
3621
- * Gets all values of an attribute from metadata (useful when an attribute can appear multiple times).
3622
- *
3623
- * Returns `null` if the attribute is not present.
3624
- *
3625
- * @param attribute - The attribute decorator
3626
- * @param target - The metadata object (module, controller, or handler)
3627
- * @returns An array of attribute values, or `null` if not found
3628
- *
3629
- * @example
3630
- * ```typescript
3631
- * const tags = AttributeFactory.getAll(Tag, endpointMetadata)
3632
- * // tags is string[] | null
3633
- * ```
3634
- */
3635
- static getAll(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<true> | null;
3636
- static getAll<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<z$1.output<T>> | null;
3637
- /**
3638
- * Gets the last value of an attribute from an array of metadata objects.
3639
- *
3640
- * Searches from the end of the array backwards, useful for finding the most
3641
- * specific attribute value (e.g., endpoint-level overrides module-level).
3642
- *
3643
- * @param attribute - The attribute decorator
3644
- * @param target - An array of metadata objects (typically [module, controller, handler])
3645
- * @returns The last attribute value found, or `null` if not found
3646
- *
3647
- * @example
3648
- * ```typescript
3649
- * // Check attribute hierarchy: endpoint -> controller -> module
3650
- * const rateLimit = AttributeFactory.getLast(RateLimit, [
3651
- * moduleMetadata,
3652
- * controllerMetadata,
3653
- * endpointMetadata
3654
- * ])
3655
- * ```
3656
- */
3657
- static getLast(attribute: ClassAttribute, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): true | null;
3658
- static getLast<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): z$1.output<T> | null;
3659
- /**
3660
- * Checks if an attribute is present on the metadata object.
3661
- *
3662
- * @param attribute - The attribute decorator
3663
- * @param target - The metadata object (module, controller, or handler)
3664
- * @returns `true` if the attribute is present, `false` otherwise
3665
- *
3666
- * @example
3667
- * ```typescript
3668
- * if (AttributeFactory.has(Public, controllerMetadata)) {
3669
- * // Skip authentication
3670
- * }
3671
- * ```
3672
- */
3673
- static has(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
3674
- static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
3675
- }
3676
- //#endregion
3677
- //#region src/factories/adapter.factory.d.mts
3678
- declare class AdapterFactory {
3679
- private readonly environment;
3680
- create(ctx: FactoryContext): Promise<any>;
3681
- }
3682
- //#endregion
3683
- //#region src/factories/endpoint-adapter.factory.d.mts
3684
- declare class EndpointAdapterFactory {
3685
- private readonly environment;
3686
- create(ctx: FactoryContext): Promise<any>;
3687
- }
3688
- //#endregion
3689
- //#region src/factories/http-adapter.factory.d.mts
3690
- declare class HttpAdapterFactory {
3691
- private readonly environment;
3692
- create(ctx: FactoryContext): Promise<any>;
3693
- }
3694
- //#endregion
3695
- //#region src/factories/multipart-adapter.factory.d.mts
3696
- declare class MultipartAdapterFactory {
3697
- private readonly environment;
3698
- create(ctx: FactoryContext): Promise<any>;
3699
- }
3700
- //#endregion
3701
- //#region src/factories/request.factory.d.mts
3702
- declare class RequestFactory {
3703
- private readonly environment;
3704
- create(ctx: FactoryContext): Promise<any>;
3705
- }
3706
- //#endregion
3707
- //#region src/factories/reply.factory.d.mts
3708
- declare class ReplyFactory {
3709
- private readonly environment;
3710
- create(ctx: FactoryContext): Promise<any>;
3711
- }
3712
- //#endregion
3713
- //#region src/factories/stream-adapter.factory.d.mts
3714
- declare class StreamAdapterFactory {
3715
- private readonly environment;
3716
- create(ctx: FactoryContext): Promise<any>;
3717
- }
3718
- //#endregion
3719
- //#region src/factories/xml-stream-adapter.factory.d.mts
3720
- declare class XmlStreamAdapterFactory {
3721
- private readonly environment;
3722
- create(ctx: FactoryContext): Promise<any>;
3723
- }
3724
- //#endregion
3725
- //#region src/navios.factory.d.mts
3726
- /**
3727
- * Factory class for creating and configuring Navios applications.
3728
- *
3729
- * This is the main entry point for bootstrapping a Navios application.
3730
- * It handles dependency injection container setup, adapter registration,
3731
- * and logger configuration.
3732
- *
3733
- * @example
3734
- * ```typescript
3735
- * import { NaviosFactory } from '@navios/core'
3736
- * import { defineFastifyEnvironment } from '@navios/adapter-fastify'
3737
- *
3738
- * const app = await NaviosFactory.create(AppModule, {
3739
- * adapter: defineFastifyEnvironment(),
3740
- * logger: ['log', 'error', 'warn'],
3741
- * })
3742
- *
3743
- * await app.init()
3744
- * await app.listen({ port: 3000 })
3745
- * ```
3746
- */
3747
- declare class NaviosFactory {
3748
- /**
3749
- * Creates a new Navios application instance.
3750
- *
3751
- * This method sets up the dependency injection container, registers the adapter,
3752
- * configures logging, and initializes the application with the provided module.
3753
- *
3754
- * @typeParam Environment - Adapter environment interface for type-safe access
3755
- * to adapter-specific features. When specified, methods like `getServer()`,
3756
- * `enableCors()`, `listen()`, and `configure()` will have proper types.
3757
- *
3758
- * @param appModule - The root application module class decorated with @Module()
3759
- * @param options - Configuration options for the application
3760
- * @param options.adapter - Adapter environment (required for server functionality)
3761
- * @param options.logger - Logger configuration. Can be:
3762
- * - A LoggerService instance for custom logging
3763
- * - An array of LogLevel strings to enable specific log levels
3764
- * - `false` to disable logging
3765
- * @param options.container - Optional custom dependency injection container (useful for testing)
3766
- * @returns A configured NaviosApplication instance ready to be initialized
3767
- *
3768
- * @example
3769
- * ```typescript
3770
- * // Basic setup with Fastify adapter
3771
- * const app = await NaviosFactory.create(AppModule, {
3772
- * adapter: defineFastifyEnvironment(),
3773
- * })
3774
- *
3775
- * // Type-safe setup with Fastify environment
3776
- * import { FastifyEnvironment } from '@navios/adapter-fastify'
3777
- *
3778
- * const app = await NaviosFactory.create<FastifyEnvironment>(AppModule, {
3779
- * adapter: defineFastifyEnvironment(),
3780
- * })
3781
- * app.configure({ trustProxy: true })
3782
- * const server = app.getServer() // FastifyInstance
3783
- *
3784
- * // With custom logger configuration
3785
- * const app = await NaviosFactory.create(AppModule, {
3786
- * adapter: defineFastifyEnvironment(),
3787
- * logger: ['error', 'warn', 'log'],
3788
- * })
3789
- *
3790
- * // With custom container for testing
3791
- * const container = new Container()
3792
- * const app = await NaviosFactory.create(AppModule, {
3793
- * adapter: defineFastifyEnvironment(),
3794
- * container,
3795
- * })
3796
- * ```
3797
- */
3798
- static create<Environment extends AdapterEnvironment = DefaultAdapterEnvironment>(appModule: ClassTypeWithInstance<NaviosModule>, options?: NaviosApplicationOptions): Promise<NaviosApplication<Environment>>;
3799
- private static registerEnvironment;
3800
- private static registerLoggerConfiguration;
3801
- }
3802
- //#endregion
3803
- export { InternalServerErrorResponderToken as $, ModuleMetadata as $n, PluginStageBase as $t, MultipartAdapterToken as A, isPlainObject as An, PathValue as Ar, PluginDefinition as At, GuardRunnerService as B, LogLevel as Bn, PreReadyPlugin as Bt, adapterSupports as C, addLeadingSlash as Cn, ConfigServiceOptions as Cr, MultipartResult as Ct, Request as D, isNil as Dn, Path as Dr, Header as Dt, StreamAdapterToken as E, isFunction as En, ConfigServiceInterface as Er, HttpCode as Et, AdapterToken as F, stripEndSlash as Fn, PostReadyPlugin as Ft, ArgumentGetter as G, DefaultAdapterEnvironment as Gn, FullPluginContext as Gt, AbstractHandlerAdapterService as H, yellow as Hn, StagedPluginDefinition as Ht, generateRequestId as I, isLogLevelEnabled as In, PreAdapterResolvePlugin as It, InstanceResolverService as J, AbstractAdapterInterface as Jn, PluginStageContextMap as Jt, HandlerContext as K, HttpAdapterEnvironment as Kn, ModulesLoadedContext as Kt, getRequestId as L, isLogLevel as Ln, PreAdapterSetupPlugin as Lt, ExecutionContext as M, isSymbol as Mn, envString as Mr, PostAdapterSetupPlugin as Mt, ExecutionContextInjectionToken as N, isUndefined as Nn, PostModulesInitPlugin as Nt, Reply as O, isNumber as On, PathImpl as Or, AnyPluginDefinition as Ot, EndpointAdapterToken as P, normalizePath as Pn, PostModulesTraversePlugin as Pt, ForbiddenResponderToken as Q, hasManagedMetadata as Qn, PluginStage as Qt, runWithRequestId as R, filterLogLevels as Rn, PreModulesInitPlugin as Rt, definePreReadyPlugin as S, LoggerService as Sn, ConfigService as Sr, MultipartParams as St, XmlStreamAdapterToken as T, isEmpty as Tn, ConfigServiceToken as Tr, ModuleOptions as Tt, AbstractHandlerResult as U, AbstractHttpAdapterInterface as Un, ContainerOnlyContext as Ut, AbstractDynamicHandler as V, clc as Vn, StagedPlugin as Vt, AbstractStaticHandler as W, AdapterEnvironment as Wn, ContextForStage as Wt, NaviosApplication as X, NaviosManagedMetadataKey as Xn, ModuleLoaderService as Xt, MultiInstanceResolution as Y, ManagedMetadata as Yn, ModuleExtension as Yt, NaviosApplicationOptions as Z, getManagedMetadata as Zn, PLUGIN_STAGES_ORDER as Zt, definePostReadyPlugin as _, LoggerOutput as _n, Controller as _r, HttpException as _t, RequestFactory as a, OmitIndexSignature as an, ControllerMetadata as ar, ForbiddenResponderService as at, definePreModulesInitPlugin as b, ConsoleLogger as bn, EnvConfigProvider as br, StreamParams as bt, EndpointAdapterFactory as c, AbstractHttpHandlerAdapterInterface as cn, getControllerMetadata as cr, ErrorResponse as ct, ClassAttribute as d, FormatArgumentsFn$1 as dn, HandlerMetadata as dr, ConflictException as dt, PluginStages as en, ModuleMetadataKey as er, NotFoundResponderToken as et, ClassSchemaAttribute as f, HandlerResult as fn, getAllEndpointMetadata as fr, UnauthorizedException as ft, definePostModulesTraversePlugin as g, LoggerOptions as gn, EndpointResult as gr, BadRequestException as gt, definePostModulesInitPlugin as h, Logger as hn, EndpointParams as hr, ForbiddenException as ht, ReplyFactory as i, HttpHeader as in, hasModuleMetadata as ir, InternalServerErrorResponderService as it, HttpAdapterToken as j, isString as jn, envInt as jr, PostAdapterResolvePlugin as jt, NaviosOptionsToken as k, isObject as kn, PathImpl2 as kr, NaviosPlugin as kt, AdapterFactory as l, ArgumentGetterFn as ln, hasControllerMetadata as lr, ProblemDetails as lt, definePostAdapterSetupPlugin as m, AbstractHttpCorsOptions as mn, Endpoint as mr, InternalServerErrorException as mt, XmlStreamAdapterFactory as n, preStage as nn, getModuleCustomEntry as nr, ValidationErrorResponderService as nt, MultipartAdapterFactory as o, CanActivate as on, ControllerMetadataKey as or, ErrorResponseProducerService as ot, definePostAdapterResolvePlugin as p, StaticHandler as pn, getEndpointMetadata as pr, NotFoundException as pt, InstanceResolution as q, AbstractExecutionContext as qn, PluginContext as qt, StreamAdapterFactory as r, NaviosModule as rn, getModuleMetadata as rr, NotFoundResponderService as rt, HttpAdapterFactory as s, AbstractHttpListenOptions as sn, extractControllerMetadata as sr, ErrorResponder as st, NaviosFactory as t, postStage as tn, extractModuleMetadata as tr, ValidationErrorResponderToken as tt, AttributeFactory as u, DynamicHandler as un, EndpointMetadataKey as ur, FrameworkError as ut, definePreAdapterResolvePlugin as v, loggerOptionsSchema as vn, ControllerOptions as vr, UseGuards as vt, assertAdapterSupports as w, isConstructor as wn, ConfigServiceOptionsSchema as wr, Module as wt, definePreModulesTraversePlugin as x, ConsoleLoggerOptions as xn, provideConfig as xr, Multipart as xt, definePreAdapterSetupPlugin as y, LoggerInstance as yn, ConfigProviderOptions as yr, Stream as yt, setRequestIdEnabled as z, LOG_LEVELS as zn, PreModulesTraversePlugin as zt };
3804
- //# sourceMappingURL=index-3LcTrbxz.d.mts.map