@navios/core 1.0.0-alpha.3 → 1.0.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 (75) hide show
  1. package/CHANGELOG.md +63 -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-BISYCYEG.d.mts → index-C0Sg16Eb.d.cts} +400 -112
  6. package/lib/index-C0Sg16Eb.d.cts.map +1 -0
  7. package/lib/{index-CP80H6Dh.d.cts → index-DySQ6Dpd.d.mts} +400 -112
  8. package/lib/index-DySQ6Dpd.d.mts.map +1 -0
  9. package/lib/index.cjs +4419 -85
  10. package/lib/index.cjs.map +1 -0
  11. package/lib/index.d.cts +2 -2
  12. package/lib/index.d.mts +2 -2
  13. package/lib/index.mjs +4328 -3
  14. package/lib/index.mjs.map +1 -0
  15. package/lib/legacy-compat/index.cjs +5 -4
  16. package/lib/legacy-compat/index.cjs.map +1 -1
  17. package/lib/legacy-compat/index.d.cts +1 -1
  18. package/lib/legacy-compat/index.d.mts +1 -1
  19. package/lib/legacy-compat/index.mjs +2 -1
  20. package/lib/legacy-compat/index.mjs.map +1 -1
  21. package/lib/navios.factory-CO5MB_OK.cjs +4125 -0
  22. package/lib/navios.factory-CO5MB_OK.cjs.map +1 -0
  23. package/lib/navios.factory-D6Y94P9B.mjs +3828 -0
  24. package/lib/navios.factory-D6Y94P9B.mjs.map +1 -0
  25. package/lib/testing/index.cjs +3 -3
  26. package/lib/testing/index.cjs.map +1 -1
  27. package/lib/testing/index.d.cts +1 -1
  28. package/lib/testing/index.d.mts +1 -1
  29. package/lib/testing/index.mjs +2 -2
  30. package/lib/tokens-4J9sredA.mjs +100 -0
  31. package/lib/tokens-4J9sredA.mjs.map +1 -0
  32. package/lib/tokens-CWw9kyeD.cjs +196 -0
  33. package/lib/tokens-CWw9kyeD.cjs.map +1 -0
  34. package/lib/{use-guards.decorator-Be_QUx6b.mjs → use-guards.decorator-BecoQSmE.mjs} +3 -70
  35. package/lib/use-guards.decorator-BecoQSmE.mjs.map +1 -0
  36. package/lib/{use-guards.decorator-DtCGXcWZ.cjs → use-guards.decorator-C4ml9XaT.cjs} +7 -158
  37. package/lib/use-guards.decorator-C4ml9XaT.cjs.map +1 -0
  38. package/package.json +3 -3
  39. package/src/__tests__/config.service.spec.mts +1 -1
  40. package/src/__tests__/console-logger.service.spec.mts +312 -0
  41. package/src/factories/adapter.factory.mts +20 -0
  42. package/src/factories/endpoint-adapter.factory.mts +1 -1
  43. package/src/factories/http-adapter.factory.mts +1 -1
  44. package/src/factories/index.mts +1 -0
  45. package/src/factories/multipart-adapter.factory.mts +1 -1
  46. package/src/factories/reply.factory.mts +1 -1
  47. package/src/factories/request.factory.mts +1 -1
  48. package/src/factories/stream-adapter.factory.mts +1 -1
  49. package/src/factories/xml-stream-adapter.factory.mts +1 -1
  50. package/src/index.mts +1 -0
  51. package/src/interfaces/abstract-adapter.interface.mts +32 -0
  52. package/src/interfaces/abstract-http-adapter.interface.mts +27 -20
  53. package/src/interfaces/adapter-environment.interface.mts +74 -0
  54. package/src/interfaces/index.mts +2 -0
  55. package/src/interfaces/plugin.interface.mts +50 -16
  56. package/src/logger/console-logger.service.mts +97 -7
  57. package/src/metadata/module.metadata.mts +43 -0
  58. package/src/navios.application.mts +172 -60
  59. package/src/navios.environment.mts +22 -12
  60. package/src/navios.factory.mts +31 -10
  61. package/src/services/instance-resolver.service.mts +0 -10
  62. package/src/services/module-loader.service.mts +1 -0
  63. package/src/tokens/adapter.token.mts +6 -0
  64. package/src/tokens/http-adapter.token.mts +1 -1
  65. package/src/tokens/index.mts +1 -0
  66. package/src/utils/adapter-supports.util.mts +47 -0
  67. package/src/utils/index.mts +1 -0
  68. package/lib/index-BISYCYEG.d.mts.map +0 -1
  69. package/lib/index-CP80H6Dh.d.cts.map +0 -1
  70. package/lib/src-CC5lmk_Q.cjs +0 -8187
  71. package/lib/src-CC5lmk_Q.cjs.map +0 -1
  72. package/lib/src-j1cBuAgy.mjs +0 -7746
  73. package/lib/src-j1cBuAgy.mjs.map +0 -1
  74. package/lib/use-guards.decorator-Be_QUx6b.mjs.map +0 -1
  75. package/lib/use-guards.decorator-DtCGXcWZ.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -5,6 +5,69 @@ 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.0.0] - 2026-01-09
9
+
10
+ ### Added
11
+
12
+ - **Stable Release**: First stable release of @navios/core
13
+ - Production-ready framework for building type-safe HTTP servers
14
+ - Comprehensive feature set with unified adapter architecture
15
+ - Full TypeScript support with end-to-end type safety
16
+
17
+ ## [1.0.0-alpha.4] - 2026-01-09
18
+
19
+ ### Added
20
+
21
+ - **Unified Adapter Architecture**: New abstract adapter system supporting multiple adapter types (HTTP, CLI, etc.)
22
+ - `AbstractAdapterInterface` - Base interface for all adapters with lifecycle methods (`setupAdapter`, `onModulesInit`, `ready`, `dispose`)
23
+ - `AdapterEnvironment` - Base interface for adapter environments with type-safe options
24
+ - `HttpAdapterEnvironment` - Extended environment interface for HTTP adapters with server, CORS, multipart, and listen options types
25
+ - `DefaultAdapterEnvironment` - Default environment with unknown types for generic usage
26
+ - `AdapterToken` - New injection token for accessing the current adapter instance
27
+ - `AdapterFactory` - Factory for creating adapter instances from environment definitions
28
+ - **Type-Safe Application Generic**: `NaviosApplication<TEnvironment>` now accepts an environment type parameter
29
+ - All adapter-specific methods (`configure`, `enableCors`, `enableMultipart`, `listen`, `getServer`) are now properly typed based on the environment
30
+ - Environment types provide IntelliSense for adapter-specific options
31
+ - **Enhanced Plugin System**: Plugins are now typed with adapter constraints
32
+ - `NaviosPlugin<TOptions, TAdapter>` - Second type parameter for adapter-specific plugins
33
+ - `PluginContext<TAdapter>` - Typed context with adapter access
34
+ - Plugins can access `context.adapter` instead of `context.server` for better type safety
35
+ - **Module Custom Entries**: New `customEntries` property on `ModuleMetadata` for adapter-specific module data
36
+ - Allows adapters to store custom metadata on modules (e.g., commands for CLI adapter)
37
+ - **Console Logger Tests**: Added comprehensive test suite for `ConsoleLoggerService`
38
+
39
+ ### Changed
40
+
41
+ - **Renamed Environment Methods**: `getHttpToken` renamed to `getToken` for adapter-agnostic naming
42
+ - **Renamed Environment Property**: `httpTokens` renamed to `tokens` in environment definitions
43
+ - **Application Configuration**: New `configure()` method replaces `setupHttpServer()` for pre-init configuration
44
+ - Configuration options are merged with adapter defaults
45
+ - Must be called before `init()` for options to take effect
46
+ - **Plugin Context**: `PluginContext.server` replaced with `PluginContext.adapter` for accessing the adapter instance
47
+ - Use `context.adapter.getServer()` for HTTP server access
48
+ - `context.globalPrefix` removed; use `context.adapter.getGlobalPrefix()` instead
49
+ - **Abstract HTTP Adapter**: `AbstractHttpAdapterInterface` now extends `AbstractAdapterInterface`
50
+ - Added `configure(options)` method for pre-init configuration
51
+ - Method signatures updated for environment-based typing
52
+
53
+ ### Breaking Changes
54
+
55
+ - **Environment Definition Format**: `httpTokens` property renamed to `tokens`
56
+ - Before: `{ httpTokens: new Map([...]) }`
57
+ - After: `{ tokens: new Map([...]) }`
58
+ - **Plugin Context API**: `context.server` and `context.globalPrefix` removed
59
+ - Before: `const server = context.server`
60
+ - After: `const server = context.adapter.getServer()`
61
+ - Before: `const prefix = context.globalPrefix`
62
+ - After: `const prefix = context.adapter.getGlobalPrefix()`
63
+ - **Application Setup**: `setupHttpServer()` replaced with `configure()`
64
+ - Before: `await app.setupHttpServer({ logger: true })`
65
+ - After: `app.configure({ logger: true }); await app.init()`
66
+
67
+ ### Dependencies
68
+
69
+ - Updated to support unified adapter architecture across all packages
70
+
8
71
  ## [1.0.0-alpha.3] - 2026-01-08
9
72
 
10
73
  ### 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>) {