@navios/core 1.1.0 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/CHANGELOG.md +85 -13
  2. package/README.md +69 -220
  3. package/lib/async-context-BAdt7bno.d.mts +239 -0
  4. package/lib/async-context-BAdt7bno.d.mts.map +1 -0
  5. package/lib/async-context-RsWmy2Hi.d.cts +239 -0
  6. package/lib/async-context-RsWmy2Hi.d.cts.map +1 -0
  7. package/lib/attribute-factory-BW1kgBqf.d.mts +70 -0
  8. package/lib/attribute-factory-BW1kgBqf.d.mts.map +1 -0
  9. package/lib/attribute-factory-DqN4x5XM.d.cts +70 -0
  10. package/lib/attribute-factory-DqN4x5XM.d.cts.map +1 -0
  11. package/lib/attribute-value-BNiJjxl1.mjs +225 -0
  12. package/lib/attribute-value-BNiJjxl1.mjs.map +1 -0
  13. package/lib/attribute-value-Cux5HhOL.cjs +314 -0
  14. package/lib/attribute-value-Cux5HhOL.cjs.map +1 -0
  15. package/lib/basic-execution-context-5uq2DvEA.cjs +318 -0
  16. package/lib/basic-execution-context-5uq2DvEA.cjs.map +1 -0
  17. package/lib/basic-execution-context-u1VktGoM.mjs +277 -0
  18. package/lib/basic-execution-context-u1VktGoM.mjs.map +1 -0
  19. package/lib/execution-context-BVSmLkYp.d.cts +71 -0
  20. package/lib/execution-context-BVSmLkYp.d.cts.map +1 -0
  21. package/lib/execution-context-C5F9rojO.d.mts +71 -0
  22. package/lib/execution-context-C5F9rojO.d.mts.map +1 -0
  23. package/lib/execution-context-token--cKS4cJv.cjs +270 -0
  24. package/lib/execution-context-token--cKS4cJv.cjs.map +1 -0
  25. package/lib/execution-context-token-Cb3M3Ao0.mjs +223 -0
  26. package/lib/execution-context-token-Cb3M3Ao0.mjs.map +1 -0
  27. package/lib/index.cjs +1672 -4426
  28. package/lib/index.cjs.map +1 -1
  29. package/lib/index.d.cts +842 -3
  30. package/lib/index.d.cts.map +1 -0
  31. package/lib/index.d.mts +842 -3
  32. package/lib/index.d.mts.map +1 -0
  33. package/lib/index.mjs +1559 -4221
  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-Bz83ZnJ5.cjs +173 -0
  44. package/lib/module-Bz83ZnJ5.cjs.map +1 -0
  45. package/lib/module-options-CSqQUSTm.d.mts +51 -0
  46. package/lib/module-options-CSqQUSTm.d.mts.map +1 -0
  47. package/lib/module-options-DSRBri4J.d.cts +51 -0
  48. package/lib/module-options-DSRBri4J.d.cts.map +1 -0
  49. package/lib/module-zPXwR2qp.mjs +138 -0
  50. package/lib/module-zPXwR2qp.mjs.map +1 -0
  51. package/lib/settled-within-B6gpu2XW.cjs +32 -0
  52. package/lib/settled-within-B6gpu2XW.cjs.map +1 -0
  53. package/lib/settled-within-Bc2pj8WB.mjs +21 -0
  54. package/lib/settled-within-Bc2pj8WB.mjs.map +1 -0
  55. package/lib/testing/index.cjs +74 -414
  56. package/lib/testing/index.cjs.map +1 -1
  57. package/lib/testing/index.d.cts +25 -385
  58. package/lib/testing/index.d.cts.map +1 -1
  59. package/lib/testing/index.d.mts +24 -385
  60. package/lib/testing/index.d.mts.map +1 -1
  61. package/lib/testing/index.mjs +72 -408
  62. package/lib/testing/index.mjs.map +1 -1
  63. package/lib/transport.cjs +36 -0
  64. package/lib/transport.d.cts +254 -0
  65. package/lib/transport.d.cts.map +1 -0
  66. package/lib/transport.d.mts +254 -0
  67. package/lib/transport.d.mts.map +1 -0
  68. package/lib/transport.mjs +6 -0
  69. package/package.json +37 -17
  70. package/docs/README.md +0 -316
  71. package/docs/adapters.md +0 -308
  72. package/docs/application-setup.md +0 -524
  73. package/docs/attributes.md +0 -689
  74. package/docs/controllers.md +0 -373
  75. package/docs/endpoints.md +0 -444
  76. package/docs/exceptions.md +0 -352
  77. package/docs/guards.md +0 -550
  78. package/docs/legacy-compat.md +0 -356
  79. package/docs/modules.md +0 -377
  80. package/docs/quick-start.md +0 -290
  81. package/docs/services.md +0 -427
  82. package/docs/testing.md +0 -827
  83. package/lib/index-3LcTrbxz.d.mts +0 -3804
  84. package/lib/index-3LcTrbxz.d.mts.map +0 -1
  85. package/lib/index-B14SekVb.d.cts +0 -3804
  86. package/lib/index-B14SekVb.d.cts.map +0 -1
  87. package/lib/navios.factory-CUrO_p6K.cjs +0 -4538
  88. package/lib/navios.factory-CUrO_p6K.cjs.map +0 -1
  89. package/lib/navios.factory-DjUOOVVL.mjs +0 -4151
  90. package/lib/navios.factory-DjUOOVVL.mjs.map +0 -1
  91. package/lib/tokens-BEuBMGGX.cjs +0 -193
  92. package/lib/tokens-BEuBMGGX.cjs.map +0 -1
  93. package/lib/tokens-COyNGV1I.mjs +0 -97
  94. package/lib/tokens-COyNGV1I.mjs.map +0 -1
  95. package/lib/use-guards.decorator-DLmRl2CV.mjs +0 -336
  96. package/lib/use-guards.decorator-DLmRl2CV.mjs.map +0 -1
  97. package/lib/use-guards.decorator-DhumFTk3.cjs +0 -444
  98. package/lib/use-guards.decorator-DhumFTk3.cjs.map +0 -1
  99. package/project.json +0 -66
  100. package/src/__tests__/attribute.factory.spec.mts +0 -300
  101. package/src/__tests__/config.service.spec.mts +0 -43
  102. package/src/__tests__/console-logger.service.spec.mts +0 -312
  103. package/src/__tests__/controller-resolver.spec.mts +0 -229
  104. package/src/__tests__/controller.spec.mts +0 -58
  105. package/src/__tests__/guard-runner.service.spec.mts +0 -399
  106. package/src/__tests__/logger.service.spec.mts +0 -147
  107. package/src/__tests__/responders.spec.mts +0 -340
  108. package/src/__tests__/testing-module.spec.mts +0 -459
  109. package/src/__tests__/unit-testing-module.spec.mts +0 -424
  110. package/src/attribute.factory.mts +0 -325
  111. package/src/config/config-service.interface.mts +0 -47
  112. package/src/config/config.provider.mts +0 -69
  113. package/src/config/config.service.mts +0 -176
  114. package/src/config/index.mts +0 -5
  115. package/src/config/types.mts +0 -58
  116. package/src/config/utils/helpers.mts +0 -23
  117. package/src/config/utils/index.mts +0 -1
  118. package/src/decorators/controller.decorator.mts +0 -81
  119. package/src/decorators/endpoint.decorator.mts +0 -181
  120. package/src/decorators/header.decorator.mts +0 -38
  121. package/src/decorators/http-code.decorator.mts +0 -38
  122. package/src/decorators/index.mts +0 -8
  123. package/src/decorators/module.decorator.mts +0 -106
  124. package/src/decorators/multipart.decorator.mts +0 -169
  125. package/src/decorators/stream.decorator.mts +0 -155
  126. package/src/decorators/use-guards.decorator.mts +0 -73
  127. package/src/exceptions/bad-request.exception.mts +0 -28
  128. package/src/exceptions/conflict.exception.mts +0 -31
  129. package/src/exceptions/forbidden.exception.mts +0 -30
  130. package/src/exceptions/http.exception.mts +0 -33
  131. package/src/exceptions/index.mts +0 -7
  132. package/src/exceptions/internal-server-error.exception.mts +0 -33
  133. package/src/exceptions/not-found.exception.mts +0 -33
  134. package/src/exceptions/unauthorized.exception.mts +0 -30
  135. package/src/factories/adapter.factory.mts +0 -20
  136. package/src/factories/endpoint-adapter.factory.mts +0 -21
  137. package/src/factories/http-adapter.factory.mts +0 -20
  138. package/src/factories/index.mts +0 -8
  139. package/src/factories/multipart-adapter.factory.mts +0 -21
  140. package/src/factories/reply.factory.mts +0 -21
  141. package/src/factories/request.factory.mts +0 -21
  142. package/src/factories/stream-adapter.factory.mts +0 -20
  143. package/src/factories/xml-stream-adapter.factory.mts +0 -20
  144. package/src/index.mts +0 -16
  145. package/src/interfaces/abstract-adapter.interface.mts +0 -32
  146. package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
  147. package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
  148. package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
  149. package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
  150. package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
  151. package/src/interfaces/adapter-environment.interface.mts +0 -74
  152. package/src/interfaces/can-activate.mts +0 -38
  153. package/src/interfaces/http-header.mts +0 -18
  154. package/src/interfaces/index.mts +0 -14
  155. package/src/interfaces/navios-module.mts +0 -28
  156. package/src/interfaces/plugin-context.mts +0 -104
  157. package/src/interfaces/plugin-stage.mts +0 -62
  158. package/src/interfaces/plugin.interface.mts +0 -119
  159. package/src/interfaces/staged-plugin.interface.mts +0 -209
  160. package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
  161. package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
  162. package/src/legacy-compat/attribute.factory.mts +0 -351
  163. package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
  164. package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
  165. package/src/legacy-compat/decorators/header.decorator.mts +0 -43
  166. package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
  167. package/src/legacy-compat/decorators/index.mts +0 -11
  168. package/src/legacy-compat/decorators/module.decorator.mts +0 -37
  169. package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
  170. package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
  171. package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
  172. package/src/legacy-compat/index.mts +0 -57
  173. package/src/logger/README.md +0 -3
  174. package/src/logger/console-logger.service.mts +0 -714
  175. package/src/logger/index.mts +0 -6
  176. package/src/logger/log-levels.mts +0 -21
  177. package/src/logger/logger-service.interface.mts +0 -42
  178. package/src/logger/logger.service.mts +0 -113
  179. package/src/logger/logger.tokens.mts +0 -44
  180. package/src/logger/utils/cli-colors.util.mts +0 -17
  181. package/src/logger/utils/filter-log-levelts.util.mts +0 -29
  182. package/src/logger/utils/index.mts +0 -5
  183. package/src/logger/utils/is-log-level-enabled.mts +0 -33
  184. package/src/logger/utils/is-log-level.util.mts +0 -10
  185. package/src/logger/utils/shared.utils.mts +0 -51
  186. package/src/metadata/controller.metadata.mts +0 -79
  187. package/src/metadata/handler.metadata.mts +0 -80
  188. package/src/metadata/index.mts +0 -4
  189. package/src/metadata/module.metadata.mts +0 -116
  190. package/src/metadata/navios-managed.metadata.mts +0 -42
  191. package/src/navios.application.mts +0 -678
  192. package/src/navios.environment.mts +0 -42
  193. package/src/navios.factory.mts +0 -158
  194. package/src/responders/enums/framework-error.enum.mts +0 -38
  195. package/src/responders/enums/index.mts +0 -1
  196. package/src/responders/index.mts +0 -4
  197. package/src/responders/interfaces/error-responder.interface.mts +0 -42
  198. package/src/responders/interfaces/error-response.interface.mts +0 -22
  199. package/src/responders/interfaces/index.mts +0 -3
  200. package/src/responders/interfaces/problem-details.interface.mts +0 -34
  201. package/src/responders/services/error-response-producer.service.mts +0 -143
  202. package/src/responders/services/forbidden-responder.service.mts +0 -77
  203. package/src/responders/services/index.mts +0 -5
  204. package/src/responders/services/internal-server-error-responder.service.mts +0 -57
  205. package/src/responders/services/not-found-responder.service.mts +0 -76
  206. package/src/responders/services/validation-error-responder.service.mts +0 -78
  207. package/src/responders/tokens/index.mts +0 -1
  208. package/src/responders/tokens/responder.tokens.mts +0 -84
  209. package/src/services/abstract-handler-adapter.service.mts +0 -366
  210. package/src/services/guard-runner.service.mts +0 -152
  211. package/src/services/index.mts +0 -4
  212. package/src/services/instance-resolver.service.mts +0 -177
  213. package/src/services/module-loader.service.mts +0 -255
  214. package/src/stores/index.mts +0 -1
  215. package/src/stores/request-id.store.mts +0 -85
  216. package/src/testing/index.mts +0 -3
  217. package/src/testing/testing-module.mts +0 -393
  218. package/src/testing/unit-testing-module.mts +0 -298
  219. package/src/tokens/adapter.token.mts +0 -6
  220. package/src/tokens/endpoint-adapter.token.mts +0 -8
  221. package/src/tokens/execution-context.token.mts +0 -9
  222. package/src/tokens/http-adapter.token.mts +0 -8
  223. package/src/tokens/index.mts +0 -10
  224. package/src/tokens/multipart-adapter.token.mts +0 -8
  225. package/src/tokens/navios-options.token.mts +0 -6
  226. package/src/tokens/reply.token.mts +0 -3
  227. package/src/tokens/request.token.mts +0 -3
  228. package/src/tokens/stream-adapter.token.mts +0 -8
  229. package/src/tokens/xml-stream-adapter.token.mts +0 -8
  230. package/src/utils/adapter-supports.util.mts +0 -47
  231. package/src/utils/define-plugin.mts +0 -251
  232. package/src/utils/index.mts +0 -2
  233. package/tsconfig.json +0 -21
  234. package/tsconfig.lib.json +0 -8
  235. package/tsconfig.spec.json +0 -15
  236. package/tsdown.config.mts +0 -35
  237. 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
- }