@navios/core 0.3.0 → 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 CHANGED
@@ -33,7 +33,7 @@ Define your API in a shared location accessible to both the client and server. T
33
33
  ```ts
34
34
  import { builder } from '@navios/core'
35
35
 
36
- import { z } from 'zod'
36
+ import { z } from 'zod/v4'
37
37
 
38
38
  const api = builder({
39
39
  useDiscriminatorResponse: true,
@@ -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,6 +1,6 @@
1
1
  import { builder } from '@navios/builder'
2
2
 
3
- import { z } from 'zod'
3
+ import { z } from 'zod/v4'
4
4
 
5
5
  export const authApi = builder({
6
6
  useDiscriminatorResponse: true,
@@ -1,4 +1,4 @@
1
- import { z } from 'zod'
1
+ import { z } from 'zod/v4'
2
2
 
3
3
  import { AttributeFactory } from '../../../../src/index.mjs'
4
4
 
@@ -1,4 +1,3 @@
1
- import type { AnyZodObject } from 'zod';
2
1
  import type { BaseEndpointConfig } from '@navios/builder';
3
2
  import { BaseInjectionTokenSchemaType } from '@navios/di';
4
3
  import type { BaseStreamConfig } from '@navios/builder';
@@ -82,9 +81,10 @@ import { syncInject } from '@navios/di';
82
81
  import { UnknownError } from '@navios/di';
83
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 { ZodType } from 'zod';
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.ZodTuple<[], z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
175
- }, "strip", z.ZodTypeAny, {
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 AnyZodObject ? 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 AnyZodObject ? 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>>;
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 AnyZodObject ? 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>>;
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<any, infer Options> ? Promise<z.input<Options[number]>> : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>;
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
- }, "strip", z.ZodTypeAny, {
830
- timestamp?: boolean | undefined;
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
- }, "strip", z.ZodTypeAny, {
952
- timestamp?: boolean | undefined;
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 AnyZodObject ? 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 AnyZodObject ? 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>>;
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 AnyZodObject ? 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>>;
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 AnyZodObject ? 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 AnyZodObject ? 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>;
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 AnyZodObject ? 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>>;
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,4 +1,3 @@
1
- import type { AnyZodObject } from 'zod';
2
1
  import type { BaseEndpointConfig } from '@navios/builder';
3
2
  import { BaseInjectionTokenSchemaType } from '@navios/di';
4
3
  import type { BaseStreamConfig } from '@navios/builder';
@@ -82,9 +81,10 @@ import { syncInject } from '@navios/di';
82
81
  import { UnknownError } from '@navios/di';
83
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 { ZodType } from 'zod';
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.ZodTuple<[], z.ZodUnknown>, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
175
- }, "strip", z.ZodTypeAny, {
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 AnyZodObject ? 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 AnyZodObject ? 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>>;
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 AnyZodObject ? 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>>;
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<any, infer Options> ? Promise<z.input<Options[number]>> : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>;
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
- }, "strip", z.ZodTypeAny, {
830
- timestamp?: boolean | undefined;
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
- }, "strip", z.ZodTypeAny, {
952
- timestamp?: boolean | undefined;
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 AnyZodObject ? 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 AnyZodObject ? 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>>;
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 AnyZodObject ? 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>>;
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 AnyZodObject ? 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 AnyZodObject ? 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>;
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 AnyZodObject ? 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>>;
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 }
package/lib/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var di = require('@navios/di');
4
- var zod = require('zod');
4
+ var v4 = require('zod/v4');
5
5
  var process$1 = require('process');
6
6
  var builder = require('@navios/builder');
7
7
  var util = require('util');
@@ -184,7 +184,7 @@ exports.MultipartAdapterService = class MultipartAdapterService extends (_a2 = e
184
184
  });
185
185
  }
186
186
  const requestSchema = config.requestSchema;
187
- const shape = requestSchema._def.shape();
187
+ const shape = requestSchema._zod.def.shape;
188
188
  const structure = this.analyzeSchema(shape);
189
189
  getters.push(async (target, request) => {
190
190
  const req = {};
@@ -202,9 +202,13 @@ exports.MultipartAdapterService = class MultipartAdapterService extends (_a2 = e
202
202
  }
203
203
  let value;
204
204
  if (part.type === "file") {
205
- value = new File([await part.toBuffer()], part.filename, {
206
- type: part.mimetype
207
- });
205
+ value = new File(
206
+ [await part.toBuffer()],
207
+ part.filename,
208
+ {
209
+ type: part.mimetype
210
+ }
211
+ );
208
212
  } else {
209
213
  value = part.value;
210
214
  if (isObject2 && typeof value === "string") {
@@ -221,15 +225,15 @@ exports.MultipartAdapterService = class MultipartAdapterService extends (_a2 = e
221
225
  return Object.keys(shape).reduce(
222
226
  (target, key) => {
223
227
  let schema = shape[key];
224
- const isOptional = schema instanceof zod.ZodOptional;
228
+ const isOptional = schema instanceof v4.ZodOptional;
225
229
  if (isOptional) {
226
230
  schema = schema.unwrap();
227
231
  }
228
- const isArray = schema instanceof zod.ZodArray;
232
+ const isArray = schema instanceof v4.ZodArray;
229
233
  if (isArray) {
230
234
  schema = schema.element;
231
235
  }
232
- const isObject2 = schema instanceof zod.ZodObject;
236
+ const isObject2 = schema instanceof v4.ZodObject;
233
237
  return {
234
238
  ...target,
235
239
  [key]: {
@@ -1299,10 +1303,10 @@ var LoggerInstance = _LoggerInstance;
1299
1303
 
1300
1304
  // src/logger/logger.factory.mts
1301
1305
  var LoggerInjectionToken = "LoggerInjectionToken";
1302
- var LoggerOptions = zod.z.object({
1303
- context: zod.z.string().optional(),
1304
- options: zod.z.object({
1305
- timestamp: zod.z.boolean().optional()
1306
+ var LoggerOptions = v4.z.object({
1307
+ context: v4.z.string().optional(),
1308
+ options: v4.z.object({
1309
+ timestamp: v4.z.boolean().optional()
1306
1310
  }).optional()
1307
1311
  }).optional();
1308
1312
  var Logger = di.InjectionToken.create(LoggerInjectionToken, LoggerOptions);
@@ -1371,7 +1375,7 @@ var PinoWrapper = class _PinoWrapper {
1371
1375
  };
1372
1376
 
1373
1377
  // src/config/config.service.mts
1374
- var ConfigServiceOptionsSchema = zod.z.record(zod.z.unknown());
1378
+ var ConfigServiceOptionsSchema = v4.z.record(v4.z.string(), v4.z.unknown());
1375
1379
  var ConfigServiceToken = di.InjectionToken.create(Symbol.for("ConfigService"), ConfigServiceOptionsSchema);
1376
1380
  var _ConfigService_decorators, _init10;
1377
1381
  _ConfigService_decorators = [di.Injectable({
@@ -1426,8 +1430,8 @@ __runInitializers(_init10, 1, _ConfigService);
1426
1430
  var ConfigService = _ConfigService;
1427
1431
 
1428
1432
  // src/config/config.provider.mts
1429
- var ConfigProviderOptions = zod.z.object({
1430
- load: zod.z.function().returns(ConfigServiceOptionsSchema)
1433
+ var ConfigProviderOptions = v4.z.object({
1434
+ load: v4.z.function({ output: ConfigServiceOptionsSchema })
1431
1435
  });
1432
1436
  function provideConfig(options) {
1433
1437
  return di.InjectionToken.factory(ConfigServiceToken, async () => options.load());