@navios/core 0.2.2 → 0.4.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.
- package/README.md +8 -4
- package/e2e/endpoints/get.spec.mts +97 -0
- package/e2e/endpoints/post.spec.mts +113 -0
- package/examples/simple-test/api/index.mts +2 -2
- package/examples/simple-test/src/acl/public.attribute.mts +1 -1
- package/lib/_tsup-dts-rollup.d.mts +22 -54
- package/lib/_tsup-dts-rollup.d.ts +22 -54
- package/lib/index.js +21 -17
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +13 -9
- package/lib/index.mjs.map +1 -1
- package/package.json +13 -11
- package/project.json +8 -3
- package/src/__tests__/config.service.spec.mts +1 -1
- package/src/__tests__/controller.spec.mts +2 -2
- package/src/adapters/endpoint-adapter.service.mts +1 -1
- package/src/adapters/multipart-adapter.service.mts +12 -8
- package/src/adapters/stream-adapter.service.mts +1 -1
- package/src/attribute.factory.mts +1 -1
- package/src/config/config.provider.mts +2 -2
- package/src/config/config.service.mts +3 -3
- package/src/decorators/endpoint.decorator.mts +9 -10
- package/src/decorators/multipart.decorator.mts +5 -5
- package/src/decorators/stream.decorator.mts +4 -4
- package/src/logger/logger.factory.mts +1 -1
- package/src/metadata/handler.metadata.mts +1 -1
- package/tsconfig.json +7 -2
- package/tsconfig.lib.json +8 -0
- package/tsconfig.spec.json +12 -0
- package/tsup.config.mts +1 -0
package/README.md
CHANGED
|
@@ -23,7 +23,6 @@ It uses Fastify under the hood, which is a fast and low-overhead web framework f
|
|
|
23
23
|
- **Service**: A service is a class that defines the business logic for a specific resource. It is used to separate the business logic from the controller and provide a clear structure for your API.
|
|
24
24
|
- **Guard**: A guard is a class that is used to validate incoming requests and ensure that they meet certain criteria. Guards can be used to validate request parameters, headers, and body. They can also be used to check authentication and authorization.
|
|
25
25
|
- **Attribute**: An attribute is a decorator that is used to add metadata to a class or method. Attributes can be used in guards, controllers, modules, and endpoints to provide additional information about the class or method.
|
|
26
|
-
|
|
27
26
|
|
|
28
27
|
## Getting Started
|
|
29
28
|
|
|
@@ -33,7 +32,8 @@ Define your API in a shared location accessible to both the client and server. T
|
|
|
33
32
|
|
|
34
33
|
```ts
|
|
35
34
|
import { builder } from '@navios/core'
|
|
36
|
-
|
|
35
|
+
|
|
36
|
+
import { z } from 'zod/v4'
|
|
37
37
|
|
|
38
38
|
const api = builder({
|
|
39
39
|
useDiscriminatorResponse: true,
|
|
@@ -66,7 +66,7 @@ const login = api.declareEndpoint({
|
|
|
66
66
|
### Create your server
|
|
67
67
|
|
|
68
68
|
```bash
|
|
69
|
-
yarn install --save @navios/core @navios/
|
|
69
|
+
yarn install --save @navios/core @navios/builder zod
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
Create AuthService:
|
|
@@ -86,7 +86,9 @@ export class LoginService {
|
|
|
86
86
|
Create your first Controller:
|
|
87
87
|
|
|
88
88
|
```ts
|
|
89
|
-
import {
|
|
89
|
+
import type { EndpointParams } from '@navios/core'
|
|
90
|
+
|
|
91
|
+
import { Controller, Endpoint, syncInject } from '@navios/core'
|
|
90
92
|
|
|
91
93
|
import { AuthService } from './auth.service.mjs'
|
|
92
94
|
|
|
@@ -111,6 +113,7 @@ export class AuthController {
|
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
```
|
|
116
|
+
|
|
114
117
|
Create your AppModule:
|
|
115
118
|
|
|
116
119
|
```ts
|
|
@@ -128,6 +131,7 @@ Create your server:
|
|
|
128
131
|
|
|
129
132
|
```ts
|
|
130
133
|
import { NaviosFactory } from '@navios/core'
|
|
134
|
+
|
|
131
135
|
import { AppModule } from './src/app.module.mjs'
|
|
132
136
|
|
|
133
137
|
export async function boot() {
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { builder } from '@navios/builder'
|
|
2
|
+
|
|
3
|
+
import supertest from 'supertest'
|
|
4
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
|
|
5
|
+
import { z } from 'zod/v4'
|
|
6
|
+
|
|
7
|
+
import type { EndpointParams } from '../../src/index.mjs'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
Controller,
|
|
11
|
+
Endpoint,
|
|
12
|
+
Module,
|
|
13
|
+
NaviosApplication,
|
|
14
|
+
NaviosFactory,
|
|
15
|
+
} from '../../src/index.mjs'
|
|
16
|
+
|
|
17
|
+
describe('GET variants', () => {
|
|
18
|
+
let server: NaviosApplication
|
|
19
|
+
|
|
20
|
+
const simple = builder().declareEndpoint({
|
|
21
|
+
url: '/simple',
|
|
22
|
+
method: 'GET',
|
|
23
|
+
responseSchema: z.object({
|
|
24
|
+
message: z.string(),
|
|
25
|
+
}),
|
|
26
|
+
})
|
|
27
|
+
const withUrlParams = builder().declareEndpoint({
|
|
28
|
+
url: '/with-url-params/$id',
|
|
29
|
+
method: 'GET',
|
|
30
|
+
responseSchema: z.object({
|
|
31
|
+
id: z.string(),
|
|
32
|
+
}),
|
|
33
|
+
})
|
|
34
|
+
const withQueryParams = builder().declareEndpoint({
|
|
35
|
+
url: '/with-query-params',
|
|
36
|
+
method: 'GET',
|
|
37
|
+
responseSchema: z.object({
|
|
38
|
+
name: z.string(),
|
|
39
|
+
}),
|
|
40
|
+
querySchema: z.object({
|
|
41
|
+
name: z.string(),
|
|
42
|
+
}),
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
@Controller()
|
|
46
|
+
class SomethingController {
|
|
47
|
+
@Endpoint(simple)
|
|
48
|
+
async getSomething(req: EndpointParams<typeof simple>) {
|
|
49
|
+
return { message: 'Hello, world!' }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@Endpoint(withUrlParams)
|
|
53
|
+
async getWithUrlParams(req: EndpointParams<typeof withUrlParams>) {
|
|
54
|
+
return { id: req.urlParams.id as string }
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
@Endpoint(withQueryParams)
|
|
58
|
+
async getWithQueryParams(req: EndpointParams<typeof withQueryParams>) {
|
|
59
|
+
return { name: req.params.name as string }
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
@Module({
|
|
64
|
+
controllers: [SomethingController],
|
|
65
|
+
})
|
|
66
|
+
class SomethingModule {}
|
|
67
|
+
|
|
68
|
+
beforeAll(async () => {
|
|
69
|
+
server = await NaviosFactory.create(SomethingModule)
|
|
70
|
+
await server.init()
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
afterAll(async () => {
|
|
74
|
+
await server.close()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
it('should return 200', async () => {
|
|
78
|
+
const response = await supertest(server.getServer().server).get('/simple')
|
|
79
|
+
expect(response.status).toBe(200)
|
|
80
|
+
expect(response.body.message).toBe('Hello, world!')
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('should return 200 with url params', async () => {
|
|
84
|
+
const response = await supertest(server.getServer().server).get(
|
|
85
|
+
'/with-url-params/123',
|
|
86
|
+
)
|
|
87
|
+
expect(response.status).toBe(200)
|
|
88
|
+
expect(response.body.id).toBe('123')
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
it('should return 200 with query params', async () => {
|
|
92
|
+
const response = await supertest(server.getServer().server).get(
|
|
93
|
+
'/with-query-params?name=John',
|
|
94
|
+
)
|
|
95
|
+
expect(response.status).toBe(200)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { builder } from '@navios/builder'
|
|
2
|
+
|
|
3
|
+
import supertest from 'supertest'
|
|
4
|
+
import { afterAll, beforeAll, describe, expect, it } from 'vitest'
|
|
5
|
+
import { z } from 'zod/v4'
|
|
6
|
+
|
|
7
|
+
import type { EndpointParams } from '../../src/index.mjs'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
Controller,
|
|
11
|
+
Endpoint,
|
|
12
|
+
Module,
|
|
13
|
+
NaviosApplication,
|
|
14
|
+
NaviosFactory,
|
|
15
|
+
} from '../../src/index.mjs'
|
|
16
|
+
|
|
17
|
+
describe('POST variants', () => {
|
|
18
|
+
let server: NaviosApplication
|
|
19
|
+
|
|
20
|
+
const simple = builder().declareEndpoint({
|
|
21
|
+
url: '/simple',
|
|
22
|
+
method: 'POST',
|
|
23
|
+
responseSchema: z.object({
|
|
24
|
+
message: z.string(),
|
|
25
|
+
}),
|
|
26
|
+
})
|
|
27
|
+
const withUrlParams = builder().declareEndpoint({
|
|
28
|
+
url: '/with-url-params/$id',
|
|
29
|
+
method: 'POST',
|
|
30
|
+
responseSchema: z.object({
|
|
31
|
+
id: z.string(),
|
|
32
|
+
}),
|
|
33
|
+
})
|
|
34
|
+
const withRequestAndQueryParams = builder().declareEndpoint({
|
|
35
|
+
url: '/with-request-and-query-params',
|
|
36
|
+
method: 'POST',
|
|
37
|
+
requestSchema: z.object({
|
|
38
|
+
foo: z.string(),
|
|
39
|
+
}),
|
|
40
|
+
responseSchema: z.object({
|
|
41
|
+
foo: z.string(),
|
|
42
|
+
bar: z.string(),
|
|
43
|
+
}),
|
|
44
|
+
querySchema: z.object({
|
|
45
|
+
bar: z.string(),
|
|
46
|
+
}),
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
@Controller()
|
|
50
|
+
class SomethingController {
|
|
51
|
+
@Endpoint(simple)
|
|
52
|
+
async getSomething(req: EndpointParams<typeof simple>) {
|
|
53
|
+
return { message: 'Hello, world!' }
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@Endpoint(withUrlParams)
|
|
57
|
+
async getWithUrlParams(req: EndpointParams<typeof withUrlParams>) {
|
|
58
|
+
return { id: req.urlParams.id as string }
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Endpoint(withRequestAndQueryParams)
|
|
62
|
+
async getWithQueryParams(
|
|
63
|
+
req: EndpointParams<typeof withRequestAndQueryParams>,
|
|
64
|
+
) {
|
|
65
|
+
return {
|
|
66
|
+
foo: req.data.foo as string,
|
|
67
|
+
bar: req.params.bar as string,
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@Module({
|
|
73
|
+
controllers: [SomethingController],
|
|
74
|
+
})
|
|
75
|
+
class SomethingModule {}
|
|
76
|
+
|
|
77
|
+
beforeAll(async () => {
|
|
78
|
+
server = await NaviosFactory.create(SomethingModule)
|
|
79
|
+
await server.init()
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
afterAll(async () => {
|
|
83
|
+
await server.close()
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
it('should return 200', async () => {
|
|
87
|
+
const response = await supertest(server.getServer().server).post('/simple')
|
|
88
|
+
expect(response.status).toBe(200)
|
|
89
|
+
expect(response.body.message).toBe('Hello, world!')
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
it('should return 200 with url params', async () => {
|
|
93
|
+
const response = await supertest(server.getServer().server).post(
|
|
94
|
+
'/with-url-params/123',
|
|
95
|
+
)
|
|
96
|
+
expect(response.status).toBe(200)
|
|
97
|
+
expect(response.body.id).toBe('123')
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
it('should return 200 with query params', async () => {
|
|
101
|
+
const response = await supertest(server.getServer().server)
|
|
102
|
+
.post('/with-request-and-query-params')
|
|
103
|
+
.send({
|
|
104
|
+
foo: 'John',
|
|
105
|
+
})
|
|
106
|
+
.query({
|
|
107
|
+
bar: 'Doe',
|
|
108
|
+
})
|
|
109
|
+
expect(response.status).toBe(200)
|
|
110
|
+
expect(response.body.foo).toBe('John')
|
|
111
|
+
expect(response.body.bar).toBe('Doe')
|
|
112
|
+
})
|
|
113
|
+
})
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BaseEndpointConfig } from '@navios/common';
|
|
1
|
+
import type { BaseEndpointConfig } from '@navios/builder';
|
|
3
2
|
import { BaseInjectionTokenSchemaType } from '@navios/di';
|
|
4
|
-
import type { BaseStreamConfig } from '@navios/
|
|
3
|
+
import type { BaseStreamConfig } from '@navios/builder';
|
|
5
4
|
import { BoundInjectionToken } from '@navios/di';
|
|
6
5
|
import { ChannelEmitter } from '@navios/di';
|
|
7
6
|
import { ClassType } from '@navios/di';
|
|
@@ -11,7 +10,7 @@ import { ClassTypeWithInstanceAndArgument } from '@navios/di';
|
|
|
11
10
|
import { ClassTypeWithInstanceAndOptionalArgument } from '@navios/di';
|
|
12
11
|
import { ClassTypeWithOptionalArgument } from '@navios/di';
|
|
13
12
|
import { CreateInjectorsOptions } from '@navios/di';
|
|
14
|
-
import type { EndpointFunctionArgs } from '@navios/
|
|
13
|
+
import type { EndpointFunctionArgs } from '@navios/builder';
|
|
15
14
|
import { ErrorsEnum } from '@navios/di';
|
|
16
15
|
import { EventEmitter } from '@navios/di';
|
|
17
16
|
import { EventEmitterInterface } from '@navios/di';
|
|
@@ -40,7 +39,7 @@ import { getInjectableToken } from '@navios/di';
|
|
|
40
39
|
import { getInjectors } from '@navios/di';
|
|
41
40
|
import { globalRegistry } from '@navios/di';
|
|
42
41
|
import type { HttpHeader } from 'fastify/types/utils.js';
|
|
43
|
-
import type { HttpMethod } from '@navios/
|
|
42
|
+
import type { HttpMethod } from '@navios/builder';
|
|
44
43
|
import { IncomingMessage } from 'http';
|
|
45
44
|
import { inject } from '@navios/di';
|
|
46
45
|
import { Injectable } from '@navios/di';
|
|
@@ -80,11 +79,12 @@ import { ServiceLocatorInstanceHolderStatus } from '@navios/di';
|
|
|
80
79
|
import { ServiceLocatorManager } from '@navios/di';
|
|
81
80
|
import { syncInject } from '@navios/di';
|
|
82
81
|
import { UnknownError } from '@navios/di';
|
|
83
|
-
import type { Util_FlatObject } from '@navios/
|
|
82
|
+
import type { Util_FlatObject } from '@navios/builder';
|
|
84
83
|
import { wrapSyncInit } from '@navios/di';
|
|
85
|
-
import { z } from 'zod';
|
|
86
|
-
import { ZodDiscriminatedUnion } from 'zod';
|
|
87
|
-
import type {
|
|
84
|
+
import { z } from 'zod/v4';
|
|
85
|
+
import { ZodDiscriminatedUnion } from 'zod/v4';
|
|
86
|
+
import type { ZodObject } from 'zod/v4';
|
|
87
|
+
import type { ZodType } from 'zod/v4';
|
|
88
88
|
|
|
89
89
|
declare const addLeadingSlash: (path?: string) => string;
|
|
90
90
|
export { addLeadingSlash }
|
|
@@ -171,12 +171,8 @@ export { clc as clc_alias_2 }
|
|
|
171
171
|
export { clc as clc_alias_3 }
|
|
172
172
|
|
|
173
173
|
declare const ConfigProviderOptions: z.ZodObject<{
|
|
174
|
-
load: z.ZodFunction<z.
|
|
175
|
-
},
|
|
176
|
-
load: (...args: unknown[]) => Record<string, unknown>;
|
|
177
|
-
}, {
|
|
178
|
-
load: (...args: unknown[]) => Record<string, unknown>;
|
|
179
|
-
}>;
|
|
174
|
+
load: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
175
|
+
}, z.core.$strip>;
|
|
180
176
|
export { ConfigProviderOptions }
|
|
181
177
|
export { ConfigProviderOptions as ConfigProviderOptions_alias_1 }
|
|
182
178
|
export { ConfigProviderOptions as ConfigProviderOptions_alias_2 }
|
|
@@ -465,7 +461,7 @@ export { CreateInjectorsOptions }
|
|
|
465
461
|
|
|
466
462
|
declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
|
|
467
463
|
config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
|
|
468
|
-
}): (target: (params: QuerySchema extends
|
|
464
|
+
}): (target: (params: QuerySchema extends ZodType ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true> : EndpointFunctionArgs<Url, QuerySchema, undefined, true> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema, true> : EndpointFunctionArgs<Url, undefined, undefined, true>) => Promise<z.input<ResponseSchema>>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodType ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true> : EndpointFunctionArgs<Url, QuerySchema, undefined, true> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema, true> : EndpointFunctionArgs<Url, undefined, undefined, true>) => Promise<z.input<ResponseSchema>>;
|
|
469
465
|
export { Endpoint }
|
|
470
466
|
export { Endpoint as Endpoint_alias_1 }
|
|
471
467
|
export { Endpoint as Endpoint_alias_2 }
|
|
@@ -491,14 +487,14 @@ export { EndpointMetadataKey as EndpointMetadataKey_alias_2 }
|
|
|
491
487
|
|
|
492
488
|
declare type EndpointParams<EndpointDeclaration extends {
|
|
493
489
|
config: BaseEndpointConfig<any, any, any, any, any>;
|
|
494
|
-
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends
|
|
490
|
+
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodType ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
|
|
495
491
|
export { EndpointParams }
|
|
496
492
|
export { EndpointParams as EndpointParams_alias_1 }
|
|
497
493
|
export { EndpointParams as EndpointParams_alias_2 }
|
|
498
494
|
|
|
499
495
|
declare type EndpointResult<EndpointDeclaration extends {
|
|
500
496
|
config: BaseEndpointConfig<any, any, any, any, any>;
|
|
501
|
-
}> = EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<
|
|
497
|
+
}> = EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<infer Options> ? Promise<z.input<Options[number]>> : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>;
|
|
502
498
|
export { EndpointResult }
|
|
503
499
|
export { EndpointResult as EndpointResult_alias_1 }
|
|
504
500
|
export { EndpointResult as EndpointResult_alias_2 }
|
|
@@ -826,22 +822,8 @@ declare const Logger: InjectionToken<LoggerInstance, z.ZodOptional<z.ZodObject<{
|
|
|
826
822
|
context: z.ZodOptional<z.ZodString>;
|
|
827
823
|
options: z.ZodOptional<z.ZodObject<{
|
|
828
824
|
timestamp: z.ZodOptional<z.ZodBoolean>;
|
|
829
|
-
},
|
|
830
|
-
|
|
831
|
-
}, {
|
|
832
|
-
timestamp?: boolean | undefined;
|
|
833
|
-
}>>;
|
|
834
|
-
}, "strip", z.ZodTypeAny, {
|
|
835
|
-
options?: {
|
|
836
|
-
timestamp?: boolean | undefined;
|
|
837
|
-
} | undefined;
|
|
838
|
-
context?: string | undefined;
|
|
839
|
-
}, {
|
|
840
|
-
options?: {
|
|
841
|
-
timestamp?: boolean | undefined;
|
|
842
|
-
} | undefined;
|
|
843
|
-
context?: string | undefined;
|
|
844
|
-
}>>, false>;
|
|
825
|
+
}, z.core.$strip>>;
|
|
826
|
+
}, z.core.$strip>>, false>;
|
|
845
827
|
export { Logger }
|
|
846
828
|
export { Logger as Logger_alias_1 }
|
|
847
829
|
export { Logger as Logger_alias_2 }
|
|
@@ -948,22 +930,8 @@ declare const LoggerOptions: z.ZodOptional<z.ZodObject<{
|
|
|
948
930
|
context: z.ZodOptional<z.ZodString>;
|
|
949
931
|
options: z.ZodOptional<z.ZodObject<{
|
|
950
932
|
timestamp: z.ZodOptional<z.ZodBoolean>;
|
|
951
|
-
},
|
|
952
|
-
|
|
953
|
-
}, {
|
|
954
|
-
timestamp?: boolean | undefined;
|
|
955
|
-
}>>;
|
|
956
|
-
}, "strip", z.ZodTypeAny, {
|
|
957
|
-
options?: {
|
|
958
|
-
timestamp?: boolean | undefined;
|
|
959
|
-
} | undefined;
|
|
960
|
-
context?: string | undefined;
|
|
961
|
-
}, {
|
|
962
|
-
options?: {
|
|
963
|
-
timestamp?: boolean | undefined;
|
|
964
|
-
} | undefined;
|
|
965
|
-
context?: string | undefined;
|
|
966
|
-
}>>;
|
|
933
|
+
}, z.core.$strip>>;
|
|
934
|
+
}, z.core.$strip>>;
|
|
967
935
|
export { LoggerOptions }
|
|
968
936
|
export { LoggerOptions as LoggerOptions_alias_1 }
|
|
969
937
|
export { LoggerOptions as LoggerOptions_alias_2 }
|
|
@@ -1062,7 +1030,7 @@ export { ModuleOptions as ModuleOptions_alias_2 }
|
|
|
1062
1030
|
|
|
1063
1031
|
declare function Multipart<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
|
|
1064
1032
|
config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
|
|
1065
|
-
}): (target: (params: QuerySchema extends
|
|
1033
|
+
}): (target: (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => Promise<z.input<ResponseSchema>>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => Promise<z.input<ResponseSchema>>;
|
|
1066
1034
|
export { Multipart }
|
|
1067
1035
|
export { Multipart as Multipart_alias_1 }
|
|
1068
1036
|
export { Multipart as Multipart_alias_2 }
|
|
@@ -1084,7 +1052,7 @@ export { MultipartAdapterToken as MultipartAdapterToken_alias_2 }
|
|
|
1084
1052
|
|
|
1085
1053
|
declare type MultipartParams<EndpointDeclaration extends {
|
|
1086
1054
|
config: BaseEndpointConfig<any, any, any, any, any>;
|
|
1087
|
-
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends
|
|
1055
|
+
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
|
|
1088
1056
|
export { MultipartParams }
|
|
1089
1057
|
export { MultipartParams as MultipartParams_alias_1 }
|
|
1090
1058
|
export { MultipartParams as MultipartParams_alias_2 }
|
|
@@ -1253,7 +1221,7 @@ export { ServiceLocatorManager }
|
|
|
1253
1221
|
|
|
1254
1222
|
declare function Stream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType>(endpoint: {
|
|
1255
1223
|
config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>;
|
|
1256
|
-
}): (target: (params: QuerySchema extends
|
|
1224
|
+
}): (target: (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>, reply: FastifyReply) => Promise<void>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>, reply: FastifyReply) => Promise<void>;
|
|
1257
1225
|
export { Stream }
|
|
1258
1226
|
export { Stream as Stream_alias_1 }
|
|
1259
1227
|
export { Stream as Stream_alias_2 }
|
|
@@ -1275,7 +1243,7 @@ export { StreamAdapterToken as StreamAdapterToken_alias_2 }
|
|
|
1275
1243
|
|
|
1276
1244
|
declare type StreamParams<EndpointDeclaration extends {
|
|
1277
1245
|
config: BaseStreamConfig<any, any, any, any>;
|
|
1278
|
-
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends
|
|
1246
|
+
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
|
|
1279
1247
|
export { StreamParams }
|
|
1280
1248
|
export { StreamParams as StreamParams_alias_1 }
|
|
1281
1249
|
export { StreamParams as StreamParams_alias_2 }
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BaseEndpointConfig } from '@navios/common';
|
|
1
|
+
import type { BaseEndpointConfig } from '@navios/builder';
|
|
3
2
|
import { BaseInjectionTokenSchemaType } from '@navios/di';
|
|
4
|
-
import type { BaseStreamConfig } from '@navios/
|
|
3
|
+
import type { BaseStreamConfig } from '@navios/builder';
|
|
5
4
|
import { BoundInjectionToken } from '@navios/di';
|
|
6
5
|
import { ChannelEmitter } from '@navios/di';
|
|
7
6
|
import { ClassType } from '@navios/di';
|
|
@@ -11,7 +10,7 @@ import { ClassTypeWithInstanceAndArgument } from '@navios/di';
|
|
|
11
10
|
import { ClassTypeWithInstanceAndOptionalArgument } from '@navios/di';
|
|
12
11
|
import { ClassTypeWithOptionalArgument } from '@navios/di';
|
|
13
12
|
import { CreateInjectorsOptions } from '@navios/di';
|
|
14
|
-
import type { EndpointFunctionArgs } from '@navios/
|
|
13
|
+
import type { EndpointFunctionArgs } from '@navios/builder';
|
|
15
14
|
import { ErrorsEnum } from '@navios/di';
|
|
16
15
|
import { EventEmitter } from '@navios/di';
|
|
17
16
|
import { EventEmitterInterface } from '@navios/di';
|
|
@@ -40,7 +39,7 @@ import { getInjectableToken } from '@navios/di';
|
|
|
40
39
|
import { getInjectors } from '@navios/di';
|
|
41
40
|
import { globalRegistry } from '@navios/di';
|
|
42
41
|
import type { HttpHeader } from 'fastify/types/utils.js';
|
|
43
|
-
import type { HttpMethod } from '@navios/
|
|
42
|
+
import type { HttpMethod } from '@navios/builder';
|
|
44
43
|
import { IncomingMessage } from 'http';
|
|
45
44
|
import { inject } from '@navios/di';
|
|
46
45
|
import { Injectable } from '@navios/di';
|
|
@@ -80,11 +79,12 @@ import { ServiceLocatorInstanceHolderStatus } from '@navios/di';
|
|
|
80
79
|
import { ServiceLocatorManager } from '@navios/di';
|
|
81
80
|
import { syncInject } from '@navios/di';
|
|
82
81
|
import { UnknownError } from '@navios/di';
|
|
83
|
-
import type { Util_FlatObject } from '@navios/
|
|
82
|
+
import type { Util_FlatObject } from '@navios/builder';
|
|
84
83
|
import { wrapSyncInit } from '@navios/di';
|
|
85
|
-
import { z } from 'zod';
|
|
86
|
-
import { ZodDiscriminatedUnion } from 'zod';
|
|
87
|
-
import type {
|
|
84
|
+
import { z } from 'zod/v4';
|
|
85
|
+
import { ZodDiscriminatedUnion } from 'zod/v4';
|
|
86
|
+
import type { ZodObject } from 'zod/v4';
|
|
87
|
+
import type { ZodType } from 'zod/v4';
|
|
88
88
|
|
|
89
89
|
declare const addLeadingSlash: (path?: string) => string;
|
|
90
90
|
export { addLeadingSlash }
|
|
@@ -171,12 +171,8 @@ export { clc as clc_alias_2 }
|
|
|
171
171
|
export { clc as clc_alias_3 }
|
|
172
172
|
|
|
173
173
|
declare const ConfigProviderOptions: z.ZodObject<{
|
|
174
|
-
load: z.ZodFunction<z.
|
|
175
|
-
},
|
|
176
|
-
load: (...args: unknown[]) => Record<string, unknown>;
|
|
177
|
-
}, {
|
|
178
|
-
load: (...args: unknown[]) => Record<string, unknown>;
|
|
179
|
-
}>;
|
|
174
|
+
load: z.ZodFunction<z.core.$ZodFunctionArgs, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
175
|
+
}, z.core.$strip>;
|
|
180
176
|
export { ConfigProviderOptions }
|
|
181
177
|
export { ConfigProviderOptions as ConfigProviderOptions_alias_1 }
|
|
182
178
|
export { ConfigProviderOptions as ConfigProviderOptions_alias_2 }
|
|
@@ -465,7 +461,7 @@ export { CreateInjectorsOptions }
|
|
|
465
461
|
|
|
466
462
|
declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
|
|
467
463
|
config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
|
|
468
|
-
}): (target: (params: QuerySchema extends
|
|
464
|
+
}): (target: (params: QuerySchema extends ZodType ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true> : EndpointFunctionArgs<Url, QuerySchema, undefined, true> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema, true> : EndpointFunctionArgs<Url, undefined, undefined, true>) => Promise<z.input<ResponseSchema>>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodType ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true> : EndpointFunctionArgs<Url, QuerySchema, undefined, true> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema, true> : EndpointFunctionArgs<Url, undefined, undefined, true>) => Promise<z.input<ResponseSchema>>;
|
|
469
465
|
export { Endpoint }
|
|
470
466
|
export { Endpoint as Endpoint_alias_1 }
|
|
471
467
|
export { Endpoint as Endpoint_alias_2 }
|
|
@@ -491,14 +487,14 @@ export { EndpointMetadataKey as EndpointMetadataKey_alias_2 }
|
|
|
491
487
|
|
|
492
488
|
declare type EndpointParams<EndpointDeclaration extends {
|
|
493
489
|
config: BaseEndpointConfig<any, any, any, any, any>;
|
|
494
|
-
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends
|
|
490
|
+
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodType ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
|
|
495
491
|
export { EndpointParams }
|
|
496
492
|
export { EndpointParams as EndpointParams_alias_1 }
|
|
497
493
|
export { EndpointParams as EndpointParams_alias_2 }
|
|
498
494
|
|
|
499
495
|
declare type EndpointResult<EndpointDeclaration extends {
|
|
500
496
|
config: BaseEndpointConfig<any, any, any, any, any>;
|
|
501
|
-
}> = EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<
|
|
497
|
+
}> = EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<infer Options> ? Promise<z.input<Options[number]>> : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>;
|
|
502
498
|
export { EndpointResult }
|
|
503
499
|
export { EndpointResult as EndpointResult_alias_1 }
|
|
504
500
|
export { EndpointResult as EndpointResult_alias_2 }
|
|
@@ -826,22 +822,8 @@ declare const Logger: InjectionToken<LoggerInstance, z.ZodOptional<z.ZodObject<{
|
|
|
826
822
|
context: z.ZodOptional<z.ZodString>;
|
|
827
823
|
options: z.ZodOptional<z.ZodObject<{
|
|
828
824
|
timestamp: z.ZodOptional<z.ZodBoolean>;
|
|
829
|
-
},
|
|
830
|
-
|
|
831
|
-
}, {
|
|
832
|
-
timestamp?: boolean | undefined;
|
|
833
|
-
}>>;
|
|
834
|
-
}, "strip", z.ZodTypeAny, {
|
|
835
|
-
options?: {
|
|
836
|
-
timestamp?: boolean | undefined;
|
|
837
|
-
} | undefined;
|
|
838
|
-
context?: string | undefined;
|
|
839
|
-
}, {
|
|
840
|
-
options?: {
|
|
841
|
-
timestamp?: boolean | undefined;
|
|
842
|
-
} | undefined;
|
|
843
|
-
context?: string | undefined;
|
|
844
|
-
}>>, false>;
|
|
825
|
+
}, z.core.$strip>>;
|
|
826
|
+
}, z.core.$strip>>, false>;
|
|
845
827
|
export { Logger }
|
|
846
828
|
export { Logger as Logger_alias_1 }
|
|
847
829
|
export { Logger as Logger_alias_2 }
|
|
@@ -948,22 +930,8 @@ declare const LoggerOptions: z.ZodOptional<z.ZodObject<{
|
|
|
948
930
|
context: z.ZodOptional<z.ZodString>;
|
|
949
931
|
options: z.ZodOptional<z.ZodObject<{
|
|
950
932
|
timestamp: z.ZodOptional<z.ZodBoolean>;
|
|
951
|
-
},
|
|
952
|
-
|
|
953
|
-
}, {
|
|
954
|
-
timestamp?: boolean | undefined;
|
|
955
|
-
}>>;
|
|
956
|
-
}, "strip", z.ZodTypeAny, {
|
|
957
|
-
options?: {
|
|
958
|
-
timestamp?: boolean | undefined;
|
|
959
|
-
} | undefined;
|
|
960
|
-
context?: string | undefined;
|
|
961
|
-
}, {
|
|
962
|
-
options?: {
|
|
963
|
-
timestamp?: boolean | undefined;
|
|
964
|
-
} | undefined;
|
|
965
|
-
context?: string | undefined;
|
|
966
|
-
}>>;
|
|
933
|
+
}, z.core.$strip>>;
|
|
934
|
+
}, z.core.$strip>>;
|
|
967
935
|
export { LoggerOptions }
|
|
968
936
|
export { LoggerOptions as LoggerOptions_alias_1 }
|
|
969
937
|
export { LoggerOptions as LoggerOptions_alias_2 }
|
|
@@ -1062,7 +1030,7 @@ export { ModuleOptions as ModuleOptions_alias_2 }
|
|
|
1062
1030
|
|
|
1063
1031
|
declare function Multipart<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
|
|
1064
1032
|
config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
|
|
1065
|
-
}): (target: (params: QuerySchema extends
|
|
1033
|
+
}): (target: (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => Promise<z.input<ResponseSchema>>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>) => Promise<z.input<ResponseSchema>>;
|
|
1066
1034
|
export { Multipart }
|
|
1067
1035
|
export { Multipart as Multipart_alias_1 }
|
|
1068
1036
|
export { Multipart as Multipart_alias_2 }
|
|
@@ -1084,7 +1052,7 @@ export { MultipartAdapterToken as MultipartAdapterToken_alias_2 }
|
|
|
1084
1052
|
|
|
1085
1053
|
declare type MultipartParams<EndpointDeclaration extends {
|
|
1086
1054
|
config: BaseEndpointConfig<any, any, any, any, any>;
|
|
1087
|
-
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends
|
|
1055
|
+
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
|
|
1088
1056
|
export { MultipartParams }
|
|
1089
1057
|
export { MultipartParams as MultipartParams_alias_1 }
|
|
1090
1058
|
export { MultipartParams as MultipartParams_alias_2 }
|
|
@@ -1253,7 +1221,7 @@ export { ServiceLocatorManager }
|
|
|
1253
1221
|
|
|
1254
1222
|
declare function Stream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType>(endpoint: {
|
|
1255
1223
|
config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>;
|
|
1256
|
-
}): (target: (params: QuerySchema extends
|
|
1224
|
+
}): (target: (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>, reply: FastifyReply) => Promise<void>, context: ClassMethodDecoratorContext) => (params: QuerySchema extends ZodObject ? RequestSchema extends ZodType ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema> : EndpointFunctionArgs<Url, QuerySchema, undefined> : RequestSchema extends ZodType ? EndpointFunctionArgs<Url, undefined, RequestSchema> : EndpointFunctionArgs<Url, undefined, undefined>, reply: FastifyReply) => Promise<void>;
|
|
1257
1225
|
export { Stream }
|
|
1258
1226
|
export { Stream as Stream_alias_1 }
|
|
1259
1227
|
export { Stream as Stream_alias_2 }
|
|
@@ -1275,7 +1243,7 @@ export { StreamAdapterToken as StreamAdapterToken_alias_2 }
|
|
|
1275
1243
|
|
|
1276
1244
|
declare type StreamParams<EndpointDeclaration extends {
|
|
1277
1245
|
config: BaseStreamConfig<any, any, any, any>;
|
|
1278
|
-
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends
|
|
1246
|
+
}, Url extends string = EndpointDeclaration['config']['url'], QuerySchema = EndpointDeclaration['config']['querySchema']> = QuerySchema extends ZodObject ? EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, QuerySchema, undefined, true>> : EndpointDeclaration['config']['requestSchema'] extends ZodType ? Util_FlatObject<EndpointFunctionArgs<Url, undefined, EndpointDeclaration['config']['requestSchema'], true>> : Util_FlatObject<EndpointFunctionArgs<Url, undefined, undefined, true>>;
|
|
1279
1247
|
export { StreamParams }
|
|
1280
1248
|
export { StreamParams as StreamParams_alias_1 }
|
|
1281
1249
|
export { StreamParams as StreamParams_alias_2 }
|