@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,62 +0,0 @@
1
- /**
2
- * Base stage names (without pre:/post: prefix)
3
- */
4
- export const PluginStageBase = {
5
- MODULES_TRAVERSE: 'modules-traverse',
6
- ADAPTER_RESOLVE: 'adapter-resolve',
7
- ADAPTER_SETUP: 'adapter-setup',
8
- MODULES_INIT: 'modules-init',
9
- READY: 'ready',
10
- } as const
11
-
12
- export type PluginStageBase =
13
- (typeof PluginStageBase)[keyof typeof PluginStageBase]
14
-
15
- /**
16
- * Full stage names with pre:/post: prefix
17
- */
18
- export type PluginStage = `pre:${PluginStageBase}` | `post:${PluginStageBase}`
19
-
20
- /**
21
- * Helper to create pre stage name from base
22
- */
23
- export const preStage = <T extends PluginStageBase>(base: T): `pre:${T}` =>
24
- `pre:${base}`
25
-
26
- /**
27
- * Helper to create post stage name from base
28
- */
29
- export const postStage = <T extends PluginStageBase>(base: T): `post:${T}` =>
30
- `post:${base}`
31
-
32
- /**
33
- * All stages as constants for direct access
34
- */
35
- export const PluginStages = {
36
- PRE_MODULES_TRAVERSE: 'pre:modules-traverse',
37
- POST_MODULES_TRAVERSE: 'post:modules-traverse',
38
- PRE_ADAPTER_RESOLVE: 'pre:adapter-resolve',
39
- POST_ADAPTER_RESOLVE: 'post:adapter-resolve',
40
- PRE_ADAPTER_SETUP: 'pre:adapter-setup',
41
- POST_ADAPTER_SETUP: 'post:adapter-setup',
42
- PRE_MODULES_INIT: 'pre:modules-init',
43
- POST_MODULES_INIT: 'post:modules-init',
44
- PRE_READY: 'pre:ready',
45
- POST_READY: 'post:ready',
46
- } as const satisfies Record<string, PluginStage>
47
-
48
- /**
49
- * All stages in execution order
50
- */
51
- export const PLUGIN_STAGES_ORDER: readonly PluginStage[] = [
52
- PluginStages.PRE_MODULES_TRAVERSE,
53
- PluginStages.POST_MODULES_TRAVERSE,
54
- PluginStages.PRE_ADAPTER_RESOLVE,
55
- PluginStages.POST_ADAPTER_RESOLVE,
56
- PluginStages.PRE_ADAPTER_SETUP,
57
- PluginStages.POST_ADAPTER_SETUP,
58
- PluginStages.PRE_MODULES_INIT,
59
- PluginStages.POST_MODULES_INIT,
60
- PluginStages.PRE_READY,
61
- PluginStages.POST_READY,
62
- ] as const
@@ -1,119 +0,0 @@
1
- import type { AbstractAdapterInterface } from './abstract-adapter.interface.mjs'
2
- import type { FullPluginContext, PluginContext } from './plugin-context.mjs'
3
- import type { PluginStage } from './plugin-stage.mjs'
4
- import type { StagedPluginDefinition } from './staged-plugin.interface.mjs'
5
-
6
- // Re-export context types for backward compatibility
7
- export type { PluginContext, FullPluginContext }
8
-
9
- /**
10
- * Base interface for Navios plugins (legacy).
11
- *
12
- * @deprecated Use staged plugins with explicit stage property instead.
13
- * This interface maps to the `post:modules-init` stage.
14
- * See `StagedPlugin` for the new pattern.
15
- *
16
- * Plugins are registered using `app.usePlugin()` and are initialized
17
- * after all modules are loaded but before the server starts listening.
18
- *
19
- * @typeParam TOptions - The type of options the plugin accepts
20
- * @typeParam TAdapter - The adapter type the plugin requires
21
- *
22
- * @example
23
- * ```typescript
24
- * // Legacy pattern (still works, maps to post:modules-init)
25
- * const myPlugin: NaviosPlugin<{ enabled: boolean }> = {
26
- * name: 'my-plugin',
27
- * register: async (context, options) => {
28
- * if (options.enabled) {
29
- * // Register routes, services, etc.
30
- * }
31
- * },
32
- * }
33
- *
34
- * // New pattern (recommended)
35
- * import { definePostModulesInitPlugin } from '@navios/core'
36
- *
37
- * export const defineMyPlugin = definePostModulesInitPlugin()({
38
- * name: 'my-plugin',
39
- * register: async (context, options: { enabled: boolean }) => {
40
- * // ...
41
- * },
42
- * })
43
- * ```
44
- */
45
- export interface NaviosPlugin<
46
- TOptions = unknown,
47
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
48
- > {
49
- /**
50
- * Plugin name for identification and logging.
51
- */
52
- name: string
53
-
54
- /**
55
- * Called after modules are loaded but before the server starts listening.
56
- *
57
- * @param context - The plugin context with access to modules and adapter
58
- * @param options - Plugin-specific configuration options
59
- * @deprecated Use staged plugins with explicit stage property
60
- */
61
- register(
62
- context: PluginContext<TAdapter>,
63
- options: TOptions,
64
- ): Promise<void> | void
65
- }
66
-
67
- /**
68
- * Plugin definition combining a plugin with its options.
69
- *
70
- * @deprecated Use `StagedPluginDefinition` for new plugins.
71
- * This type is kept for backward compatibility with legacy plugins.
72
- *
73
- * @typeParam TOptions - The type of options the plugin accepts
74
- * @typeParam TAdapter - The adapter type the plugin requires
75
- *
76
- * @example
77
- * ```typescript
78
- * // Legacy pattern
79
- * function defineMyPlugin(options: MyPluginOptions): PluginDefinition<MyPluginOptions> {
80
- * return {
81
- * plugin: myPlugin,
82
- * options,
83
- * }
84
- * }
85
- *
86
- * // New pattern (recommended)
87
- * import { definePostModulesInitPlugin } from '@navios/core'
88
- *
89
- * export const defineMyPlugin = definePostModulesInitPlugin()({
90
- * name: 'my-plugin',
91
- * register: (context, options: MyPluginOptions) => { ... },
92
- * })
93
- * ```
94
- */
95
- export interface PluginDefinition<
96
- TOptions = unknown,
97
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
98
- > {
99
- /**
100
- * The plugin instance.
101
- */
102
- plugin: NaviosPlugin<TOptions, TAdapter>
103
-
104
- /**
105
- * Options to pass to the plugin's register function.
106
- */
107
- options: TOptions
108
- }
109
-
110
- /**
111
- * Union of legacy and staged plugin definitions.
112
- * Used internally by `usePlugin()` to accept both patterns.
113
- */
114
- export type AnyPluginDefinition<
115
- TOptions = unknown,
116
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
117
- > =
118
- | PluginDefinition<TOptions, TAdapter>
119
- | StagedPluginDefinition<PluginStage, TOptions, TAdapter>
@@ -1,209 +0,0 @@
1
- import type { AbstractAdapterInterface } from './abstract-adapter.interface.mjs'
2
- import type {
3
- ContainerOnlyContext,
4
- ContextForStage,
5
- FullPluginContext,
6
- ModulesLoadedContext,
7
- } from './plugin-context.mjs'
8
- import type { PluginStage } from './plugin-stage.mjs'
9
-
10
- /**
11
- * Base interface for staged plugins that target a specific lifecycle stage.
12
- *
13
- * @typeParam S - The target stage (e.g., 'pre:adapter-resolve')
14
- * @typeParam TOptions - Plugin options type
15
- * @typeParam TAdapter - Adapter type (only relevant for post-adapter stages)
16
- *
17
- * @example
18
- * ```typescript
19
- * const myPlugin: StagedPlugin<'pre:adapter-resolve', MyOptions> = {
20
- * name: 'my-plugin',
21
- * stage: 'pre:adapter-resolve',
22
- * register: (context, options) => {
23
- * // context is typed as ModulesLoadedContext
24
- * },
25
- * }
26
- * ```
27
- */
28
- export interface StagedPlugin<
29
- S extends PluginStage,
30
- TOptions = unknown,
31
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
32
- > {
33
- /**
34
- * Plugin name for identification and logging.
35
- */
36
- readonly name: string
37
-
38
- /**
39
- * The lifecycle stage this plugin targets.
40
- */
41
- readonly stage: S
42
-
43
- /**
44
- * Called at the specified stage during application initialization.
45
- *
46
- * @param context - Stage-appropriate context
47
- * @param options - Plugin-specific configuration options
48
- */
49
- register(
50
- context: ContextForStage<S, TAdapter>,
51
- options: TOptions,
52
- ): Promise<void> | void
53
- }
54
-
55
- // ============ Convenience Type Aliases for Each Stage ============
56
-
57
- /**
58
- * Plugin that runs before module tree traversal.
59
- * Context: container only
60
- */
61
- export interface PreModulesTraversePlugin<TOptions = unknown>
62
- extends StagedPlugin<'pre:modules-traverse', TOptions, never> {
63
- register(context: ContainerOnlyContext, options: TOptions): Promise<void> | void
64
- }
65
-
66
- /**
67
- * Plugin that runs after module tree traversal.
68
- * Context: container + modules + moduleLoader
69
- */
70
- export interface PostModulesTraversePlugin<TOptions = unknown>
71
- extends StagedPlugin<'post:modules-traverse', TOptions, never> {
72
- register(context: ModulesLoadedContext, options: TOptions): Promise<void> | void
73
- }
74
-
75
- /**
76
- * Plugin that runs before adapter is resolved from container.
77
- * Context: container + modules + moduleLoader (NO adapter yet!)
78
- *
79
- * Use this stage to modify registry/bindings before adapter instantiation.
80
- */
81
- export interface PreAdapterResolvePlugin<TOptions = unknown>
82
- extends StagedPlugin<'pre:adapter-resolve', TOptions, never> {
83
- register(context: ModulesLoadedContext, options: TOptions): Promise<void> | void
84
- }
85
-
86
- /**
87
- * Plugin that runs after adapter is resolved.
88
- * Context: full (container + modules + moduleLoader + adapter)
89
- */
90
- export interface PostAdapterResolvePlugin<
91
- TOptions = unknown,
92
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
93
- > extends StagedPlugin<'post:adapter-resolve', TOptions, TAdapter> {
94
- register(
95
- context: FullPluginContext<TAdapter>,
96
- options: TOptions,
97
- ): Promise<void> | void
98
- }
99
-
100
- /**
101
- * Plugin that runs before adapter setup.
102
- * Context: full
103
- */
104
- export interface PreAdapterSetupPlugin<
105
- TOptions = unknown,
106
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
107
- > extends StagedPlugin<'pre:adapter-setup', TOptions, TAdapter> {
108
- register(
109
- context: FullPluginContext<TAdapter>,
110
- options: TOptions,
111
- ): Promise<void> | void
112
- }
113
-
114
- /**
115
- * Plugin that runs after adapter setup.
116
- * Context: full
117
- */
118
- export interface PostAdapterSetupPlugin<
119
- TOptions = unknown,
120
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
121
- > extends StagedPlugin<'post:adapter-setup', TOptions, TAdapter> {
122
- register(
123
- context: FullPluginContext<TAdapter>,
124
- options: TOptions,
125
- ): Promise<void> | void
126
- }
127
-
128
- /**
129
- * Plugin that runs before modules init (route registration).
130
- * Context: full
131
- */
132
- export interface PreModulesInitPlugin<
133
- TOptions = unknown,
134
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
135
- > extends StagedPlugin<'pre:modules-init', TOptions, TAdapter> {
136
- register(
137
- context: FullPluginContext<TAdapter>,
138
- options: TOptions,
139
- ): Promise<void> | void
140
- }
141
-
142
- /**
143
- * Plugin that runs after modules init (route registration).
144
- * Context: full
145
- *
146
- * This is the default stage for legacy NaviosPlugin implementations.
147
- */
148
- export interface PostModulesInitPlugin<
149
- TOptions = unknown,
150
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
151
- > extends StagedPlugin<'post:modules-init', TOptions, TAdapter> {
152
- register(
153
- context: FullPluginContext<TAdapter>,
154
- options: TOptions,
155
- ): Promise<void> | void
156
- }
157
-
158
- /**
159
- * Plugin that runs before adapter signals ready.
160
- * Context: full
161
- */
162
- export interface PreReadyPlugin<
163
- TOptions = unknown,
164
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
165
- > extends StagedPlugin<'pre:ready', TOptions, TAdapter> {
166
- register(
167
- context: FullPluginContext<TAdapter>,
168
- options: TOptions,
169
- ): Promise<void> | void
170
- }
171
-
172
- /**
173
- * Plugin that runs after adapter signals ready.
174
- * Context: full - this is the final stage, app is fully initialized
175
- */
176
- export interface PostReadyPlugin<
177
- TOptions = unknown,
178
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
179
- > extends StagedPlugin<'post:ready', TOptions, TAdapter> {
180
- register(
181
- context: FullPluginContext<TAdapter>,
182
- options: TOptions,
183
- ): Promise<void> | void
184
- }
185
-
186
- // ============ Plugin Definition Types ============
187
-
188
- /**
189
- * Plugin definition for staged plugins.
190
- *
191
- * @typeParam S - The target stage
192
- * @typeParam TOptions - Plugin options type
193
- * @typeParam TAdapter - Adapter type
194
- */
195
- export interface StagedPluginDefinition<
196
- S extends PluginStage = PluginStage,
197
- TOptions = unknown,
198
- TAdapter extends AbstractAdapterInterface = AbstractAdapterInterface,
199
- > {
200
- /**
201
- * The staged plugin instance.
202
- */
203
- plugin: StagedPlugin<S, TOptions, TAdapter>
204
-
205
- /**
206
- * Options to pass to the plugin's register function.
207
- */
208
- options: TOptions
209
- }