@navios/core 1.0.0-alpha.4 → 1.1.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 (54) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/README.md +2 -2
  3. package/docs/legacy-compat.md +53 -17
  4. package/docs/quick-start.md +2 -7
  5. package/lib/{index-6S7veHKD.d.mts → index-3LcTrbxz.d.mts} +491 -60
  6. package/lib/index-3LcTrbxz.d.mts.map +1 -0
  7. package/lib/{index-r0i2txmg.d.cts → index-B14SekVb.d.cts} +491 -60
  8. package/lib/index-B14SekVb.d.cts.map +1 -0
  9. package/lib/index.cjs +18 -4
  10. package/lib/index.d.cts +2 -2
  11. package/lib/index.d.mts +2 -2
  12. package/lib/index.mjs +4 -4
  13. package/lib/legacy-compat/index.cjs +3 -3
  14. package/lib/legacy-compat/index.d.cts +1 -1
  15. package/lib/legacy-compat/index.d.mts +1 -1
  16. package/lib/legacy-compat/index.mjs +2 -2
  17. package/lib/{navios.factory-BanZIvtR.cjs → navios.factory-CUrO_p6K.cjs} +461 -57
  18. package/lib/navios.factory-CUrO_p6K.cjs.map +1 -0
  19. package/lib/{navios.factory-C75yZCoD.mjs → navios.factory-DjUOOVVL.mjs} +372 -52
  20. package/lib/navios.factory-DjUOOVVL.mjs.map +1 -0
  21. package/lib/testing/index.cjs +2 -2
  22. package/lib/testing/index.d.cts +1 -1
  23. package/lib/testing/index.d.mts +1 -1
  24. package/lib/testing/index.mjs +2 -2
  25. package/lib/{tokens-BuXXB01L.cjs → tokens-BEuBMGGX.cjs} +18 -21
  26. package/lib/tokens-BEuBMGGX.cjs.map +1 -0
  27. package/lib/{tokens-4J9sredA.mjs → tokens-COyNGV1I.mjs} +17 -20
  28. package/lib/tokens-COyNGV1I.mjs.map +1 -0
  29. package/lib/{use-guards.decorator-BecoQSmE.mjs → use-guards.decorator-DLmRl2CV.mjs} +14 -17
  30. package/lib/use-guards.decorator-DLmRl2CV.mjs.map +1 -0
  31. package/lib/{use-guards.decorator-DgD-kxF5.cjs → use-guards.decorator-DhumFTk3.cjs} +15 -18
  32. package/lib/use-guards.decorator-DhumFTk3.cjs.map +1 -0
  33. package/package.json +2 -2
  34. package/src/__tests__/config.service.spec.mts +1 -1
  35. package/src/interfaces/index.mts +3 -0
  36. package/src/interfaces/plugin-context.mts +104 -0
  37. package/src/interfaces/plugin-stage.mts +62 -0
  38. package/src/interfaces/plugin.interface.mts +42 -62
  39. package/src/interfaces/staged-plugin.interface.mts +209 -0
  40. package/src/metadata/controller.metadata.mts +29 -22
  41. package/src/metadata/module.metadata.mts +33 -25
  42. package/src/navios.application.mts +247 -53
  43. package/src/services/instance-resolver.service.mts +0 -10
  44. package/src/services/module-loader.service.mts +11 -8
  45. package/src/utils/define-plugin.mts +251 -0
  46. package/src/utils/index.mts +1 -0
  47. package/lib/index-6S7veHKD.d.mts.map +0 -1
  48. package/lib/index-r0i2txmg.d.cts.map +0 -1
  49. package/lib/navios.factory-BanZIvtR.cjs.map +0 -1
  50. package/lib/navios.factory-C75yZCoD.mjs.map +0 -1
  51. package/lib/tokens-4J9sredA.mjs.map +0 -1
  52. package/lib/tokens-BuXXB01L.cjs.map +0 -1
  53. package/lib/use-guards.decorator-BecoQSmE.mjs.map +0 -1
  54. package/lib/use-guards.decorator-DgD-kxF5.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,59 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.1.0] - 2026-01-15
9
+
10
+ ### Added
11
+
12
+ - **Staged Plugin System**: New comprehensive plugin lifecycle with 10 stages for fine-grained control over application initialization
13
+ - `pre:modules-traverse` - Before module tree traversal (container only)
14
+ - `post:modules-traverse` - After module tree traversal (modules available)
15
+ - `pre:adapter-resolve` - Before adapter is resolved from container (ideal for DI modifications)
16
+ - `post:adapter-resolve` - After adapter is resolved
17
+ - `pre:adapter-setup` - Before adapter setup
18
+ - `post:adapter-setup` - After adapter setup
19
+ - `pre:modules-init` - Before route registration
20
+ - `post:modules-init` - After route registration (legacy plugin default)
21
+ - `pre:ready` - Before adapter signals ready
22
+ - `post:ready` - After adapter signals ready (app fully initialized)
23
+ - **Stage-Specific Context Types**: Each stage provides appropriate context
24
+ - `ContainerOnlyContext` - Container access only (early stages)
25
+ - `ModulesLoadedContext` - Container + modules + moduleLoader (pre-adapter stages)
26
+ - `FullPluginContext<TAdapter>` - Full context with typed adapter (post-adapter stages)
27
+ - **Plugin Factory Functions**: Convenient factory functions for creating staged plugins
28
+ - `definePreModulesTraversePlugin()` - Create pre:modules-traverse plugins
29
+ - `definePostModulesTraversePlugin()` - Create post:modules-traverse plugins
30
+ - `definePreAdapterResolvePlugin()` - Create pre:adapter-resolve plugins (ideal for instrumentation)
31
+ - `definePostAdapterResolvePlugin<TAdapter>()()` - Create post:adapter-resolve plugins
32
+ - `definePreAdapterSetupPlugin<TAdapter>()()` - Create pre:adapter-setup plugins
33
+ - `definePostAdapterSetupPlugin<TAdapter>()()` - Create post:adapter-setup plugins
34
+ - `definePreModulesInitPlugin<TAdapter>()()` - Create pre:modules-init plugins
35
+ - `definePostModulesInitPlugin<TAdapter>()()` - Create post:modules-init plugins
36
+ - `definePreReadyPlugin<TAdapter>()()` - Create pre:ready plugins
37
+ - `definePostReadyPlugin<TAdapter>()()` - Create post:ready plugins
38
+ - **Plugin Stage Constants**: `PluginStages` object with all stage names as constants
39
+ - **Stage Order Array**: `PLUGIN_STAGES_ORDER` array defining execution order
40
+
41
+ ### Changed
42
+
43
+ - **Legacy Plugin Deprecation**: `NaviosPlugin` interface now deprecated in favor of staged plugins
44
+ - Legacy plugins automatically map to `post:modules-init` stage
45
+ - `PluginDefinition` type deprecated in favor of `StagedPluginDefinition`
46
+ - **Plugin Context Types**: `PluginContext` type deprecated, use stage-specific context types instead
47
+
48
+ ### Dependencies
49
+
50
+ - Updated internal plugin execution to support staged lifecycle
51
+
52
+ ## [1.0.0] - 2026-01-09
53
+
54
+ ### Added
55
+
56
+ - **Stable Release**: First stable release of @navios/core
57
+ - Production-ready framework for building type-safe HTTP servers
58
+ - Comprehensive feature set with unified adapter architecture
59
+ - Full TypeScript support with end-to-end type safety
60
+
8
61
  ## [1.0.0-alpha.4] - 2026-01-09
9
62
 
10
63
  ### Added
package/README.md CHANGED
@@ -169,14 +169,14 @@ Create your first Controller:
169
169
  ```ts
170
170
  import type { EndpointParams } from '@navios/core'
171
171
 
172
- import { Controller, Endpoint, syncInject } from '@navios/core'
172
+ import { Controller, Endpoint, inject } from '@navios/core'
173
173
 
174
174
  import { AuthService } from './auth.service.mjs'
175
175
 
176
176
  @Controller()
177
177
  export class AuthController {
178
178
  // Inject the LoginService
179
- loginService = syncInject(LoginService)
179
+ loginService = inject(LoginService)
180
180
 
181
181
  @Endpoint(login)
182
182
  async login(request: EndpointParams<typeof login>) {
@@ -21,7 +21,16 @@ No additional installation is required. The legacy-compat decorators are include
21
21
  To use legacy-compatible decorators, import them from the `legacy-compat` subpath:
22
22
 
23
23
  ```typescript
24
- import { Module, Controller, Endpoint, UseGuards, Header, HttpCode, Multipart, Stream } from '@navios/core/legacy-compat'
24
+ import {
25
+ Controller,
26
+ Endpoint,
27
+ Header,
28
+ HttpCode,
29
+ Module,
30
+ Multipart,
31
+ Stream,
32
+ UseGuards,
33
+ } from '@navios/core/legacy-compat'
25
34
  ```
26
35
 
27
36
  ## Available Decorators
@@ -65,12 +74,16 @@ export class UserController {
65
74
  Defines an HTTP endpoint with type-safe request/response schemas. Must be applied to methods.
66
75
 
67
76
  ```typescript
68
- import { Controller, Endpoint, type EndpointParams, type EndpointResult } from '@navios/core/legacy-compat'
77
+ import type { EndpointParams, EndpointResult } from '@navios/core/legacy-compat'
78
+
79
+ import { Controller, Endpoint } from '@navios/core/legacy-compat'
69
80
 
70
81
  @Controller()
71
82
  export class UserController {
72
83
  @Endpoint(getUserEndpoint)
73
- async getUser(request: EndpointParams<typeof getUserEndpoint>): Promise<EndpointResult<typeof getUserEndpoint>> {
84
+ async getUser(
85
+ request: EndpointParams<typeof getUserEndpoint>,
86
+ ): Promise<EndpointResult<typeof getUserEndpoint>> {
74
87
  const { id } = request
75
88
  return { id, name: 'John Doe' }
76
89
  }
@@ -82,12 +95,19 @@ export class UserController {
82
95
  Defines a multipart/form-data endpoint for file uploads. Must be applied to methods.
83
96
 
84
97
  ```typescript
85
- import { Controller, Multipart, type MultipartParams, type MultipartResult } from '@navios/core/legacy-compat'
98
+ import type {
99
+ MultipartParams,
100
+ MultipartResult,
101
+ } from '@navios/core/legacy-compat'
102
+
103
+ import { Controller, Multipart } from '@navios/core/legacy-compat'
86
104
 
87
105
  @Controller()
88
106
  export class FileController {
89
107
  @Multipart(uploadFileEndpoint)
90
- async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>): Promise<MultipartResult<typeof uploadFileEndpoint>> {
108
+ async uploadFile(
109
+ request: MultipartParams<typeof uploadFileEndpoint>,
110
+ ): Promise<MultipartResult<typeof uploadFileEndpoint>> {
91
111
  const { file } = request.data
92
112
  return { url: 'https://example.com/file.jpg' }
93
113
  }
@@ -99,12 +119,17 @@ export class FileController {
99
119
  Defines a streaming endpoint. Must be applied to methods.
100
120
 
101
121
  ```typescript
102
- import { Controller, Stream, type StreamParams } from '@navios/core/legacy-compat'
122
+ import type { StreamParams } from '@navios/core/legacy-compat'
123
+
124
+ import { Controller, Stream } from '@navios/core/legacy-compat'
103
125
 
104
126
  @Controller()
105
127
  export class FileController {
106
128
  @Stream(downloadFileEndpoint)
107
- async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any): Promise<void> {
129
+ async downloadFile(
130
+ request: StreamParams<typeof downloadFileEndpoint>,
131
+ reply: any,
132
+ ): Promise<void> {
108
133
  const { fileId } = request.urlParams
109
134
  // Stream file data to reply
110
135
  }
@@ -176,10 +201,10 @@ The legacy-compat module also exports type utilities for working with endpoints:
176
201
 
177
202
  ```typescript
178
203
  import type {
179
- ModuleOptions,
180
204
  ControllerOptions,
181
205
  EndpointParams,
182
206
  EndpointResult,
207
+ ModuleOptions,
183
208
  MultipartParams,
184
209
  MultipartResult,
185
210
  StreamParams,
@@ -191,9 +216,18 @@ import type {
191
216
  Here's a complete example using legacy-compatible decorators:
192
217
 
193
218
  ```typescript
219
+ import type { EndpointParams, EndpointResult } from '@navios/core/legacy-compat'
220
+
194
221
  import { builder } from '@navios/builder'
195
- import { Module, Controller, Endpoint, UseGuards, HttpCode, type EndpointParams, type EndpointResult } from '@navios/core/legacy-compat'
196
- import { Injectable, syncInject } from '@navios/core'
222
+ import { inject, Injectable } from '@navios/core'
223
+ import {
224
+ Controller,
225
+ Endpoint,
226
+ HttpCode,
227
+ Module,
228
+ UseGuards,
229
+ } from '@navios/core/legacy-compat'
230
+
197
231
  import { z } from 'zod/v4'
198
232
 
199
233
  // Define API endpoints
@@ -239,17 +273,21 @@ export class UserService {
239
273
  @Controller()
240
274
  @UseGuards(AuthGuard)
241
275
  export class UserController {
242
- userService = syncInject(UserService)
276
+ userService = inject(UserService)
243
277
 
244
278
  @Endpoint(getUserEndpoint)
245
- async getUser(request: EndpointParams<typeof getUserEndpoint>): Promise<EndpointResult<typeof getUserEndpoint>> {
279
+ async getUser(
280
+ request: EndpointParams<typeof getUserEndpoint>,
281
+ ): Promise<EndpointResult<typeof getUserEndpoint>> {
246
282
  const { id } = request.urlParams
247
283
  return await this.userService.findById(id)
248
284
  }
249
285
 
250
286
  @Endpoint(createUserEndpoint)
251
287
  @HttpCode(201)
252
- async createUser(request: EndpointParams<typeof createUserEndpoint>): Promise<EndpointResult<typeof createUserEndpoint>> {
288
+ async createUser(
289
+ request: EndpointParams<typeof createUserEndpoint>,
290
+ ): Promise<EndpointResult<typeof createUserEndpoint>> {
253
291
  const { name, email } = request.body
254
292
  return await this.userService.create({ name, email })
255
293
  }
@@ -270,10 +308,9 @@ If you're migrating from standard decorators to legacy-compatible decorators:
270
308
 
271
309
  ```typescript
272
310
  // Before
273
- import { Module, Controller, Endpoint } from '@navios/core'
274
-
311
+ import { Controller, Endpoint, Module } from '@navios/core'
275
312
  // After
276
- import { Module, Controller, Endpoint } from '@navios/core/legacy-compat'
313
+ import { Controller, Endpoint, Module } from '@navios/core/legacy-compat'
277
314
  ```
278
315
 
279
316
  2. Ensure your `tsconfig.json` has `experimentalDecorators` enabled:
@@ -317,4 +354,3 @@ The `emitDecoratorMetadata` option is optional but recommended for better runtim
317
354
  - Legacy-compatible decorators are fully compatible with all Navios features including guards, attributes, dependency injection, and adapters
318
355
  - You can mix legacy-compatible decorators with standard decorators in the same project, but it's recommended to use one approach consistently
319
356
  - The legacy-compat module is maintained alongside the standard decorators and receives the same updates and bug fixes
320
-
@@ -117,19 +117,14 @@ Create a user controller (`controllers/user.controller.ts`):
117
117
  ```ts
118
118
  import type { EndpointParams } from '@navios/core'
119
119
 
120
- import {
121
- Controller,
122
- Endpoint,
123
- NotFoundException,
124
- syncInject,
125
- } from '@navios/core'
120
+ import { Controller, Endpoint, inject, NotFoundException } from '@navios/core'
126
121
 
127
122
  import { createUserEndpoint, getUserEndpoint } from '../api/index.js'
128
123
  import { UserService } from '../services/user.service.js'
129
124
 
130
125
  @Controller()
131
126
  export class UserController {
132
- private userService = syncInject(UserService)
127
+ private userService = inject(UserService)
133
128
 
134
129
  @Endpoint(createUserEndpoint)
135
130
  async createUser(request: EndpointParams<typeof createUserEndpoint>) {