@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@navios/core",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "author": {
5
5
  "name": "Oleksandr Hanzha",
6
6
  "email": "alex@granted.name"
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "license": "MIT",
14
14
  "peerDependencies": {
15
- "@navios/builder": "^0.2.0",
16
- "zod": "^3.23.8"
15
+ "@navios/builder": "^0.3.0",
16
+ "zod": "^3.25.0 || ^4.0.0"
17
17
  },
18
18
  "typings": "./lib/index.d.mts",
19
19
  "main": "./lib/index.js",
@@ -31,16 +31,18 @@
31
31
  }
32
32
  },
33
33
  "devDependencies": {
34
- "@navios/builder": "^0.2.0",
35
- "tsx": "^4.19.4",
36
- "typescript": "^5.8.3",
37
- "zod": "^3.24.4"
34
+ "@navios/builder": "^0.3.0",
35
+ "@types/supertest": "^6.0.3",
36
+ "supertest": "^7.1.4",
37
+ "tsx": "^4.20.5",
38
+ "typescript": "^5.9.2",
39
+ "zod": "^4.1.4"
38
40
  },
39
41
  "dependencies": {
40
- "@fastify/cors": "^11.0.1",
42
+ "@fastify/cors": "^11.1.0",
41
43
  "@fastify/multipart": "^9.0.3",
42
- "@navios/di": "^0.1.12",
43
- "fastify": "^5.3.2",
44
- "fastify-type-provider-zod": "^4.0.2"
44
+ "@navios/di": "^0.2.1",
45
+ "fastify": "^5.5.0",
46
+ "fastify-type-provider-zod": "^5.0.3"
45
47
  }
46
48
  }
package/project.json CHANGED
@@ -9,7 +9,12 @@
9
9
  "check": {
10
10
  "executor": "nx:run-commands",
11
11
  "outputs": ["{projectRoot}/dist"],
12
- "inputs": ["^projectSources", "projectSources"],
12
+ "inputs": [
13
+ "^projectSources",
14
+ "projectSources",
15
+ "{projectRoot}/tsconfig.json",
16
+ "{projectRoot}/tsconfig.lib.json"
17
+ ],
13
18
  "options": {
14
19
  "command": ["tsc -b"],
15
20
  "cwd": "packages/core"
@@ -17,7 +22,7 @@
17
22
  },
18
23
  "test:ci": {
19
24
  "executor": "nx:run-commands",
20
- "inputs": ["^projectSources","project"],
25
+ "inputs": ["^projectSources", "project"],
21
26
  "options": {
22
27
  "command": "vitest run",
23
28
  "cwd": "packages/core"
@@ -25,7 +30,7 @@
25
30
  },
26
31
  "build": {
27
32
  "executor": "nx:run-commands",
28
- "inputs": ["projectSources"],
33
+ "inputs": ["projectSources", "{projectRoot}/tsup.config.mts"],
29
34
  "outputs": ["{projectRoot}/lib"],
30
35
  "dependsOn": ["check", "test:ci"],
31
36
  "options": {
@@ -15,7 +15,7 @@ import {
15
15
 
16
16
  describe('ConfigService', () => {
17
17
  it('should be able to get a config value', async () => {
18
- const service = await inject(ConfigServiceToken, env)
18
+ const service = await inject(ConfigServiceToken, { ...env })
19
19
  expect(service).toBeDefined()
20
20
  expect(service.get('NODE_ENV')).toBe(env.NODE_ENV)
21
21
  })
@@ -1,7 +1,7 @@
1
1
  import { builder } from '@navios/builder'
2
2
 
3
3
  import { describe, expect, it } from 'vitest'
4
- import { z } from 'zod'
4
+ import { z } from 'zod/v4'
5
5
 
6
6
  import type { EndpointParams } from '../decorators/index.mjs'
7
7
 
@@ -1,11 +1,11 @@
1
1
  import type { MultipartFile, MultipartValue } from '@fastify/multipart'
2
2
  import type { BaseEndpointConfig } from '@navios/builder'
3
3
  import type { FastifyRequest } from 'fastify'
4
- import type { AnyZodObject, ZodRawShape } from 'zod'
4
+ import type { ZodRawShape } from 'zod/v4'
5
5
 
6
6
  import { Injectable, InjectionToken } from '@navios/di'
7
7
 
8
- import { ZodArray, ZodObject, ZodOptional } from 'zod'
8
+ import { ZodArray, ZodObject, ZodOptional } from 'zod/v4'
9
9
 
10
10
  import type { HandlerMetadata } from '../metadata/index.mjs'
11
11
 
@@ -38,8 +38,8 @@ export class MultipartAdapterService extends EndpointAdapterService {
38
38
  target.urlParams = request.params
39
39
  })
40
40
  }
41
- const requestSchema = config.requestSchema as unknown as AnyZodObject
42
- const shape = requestSchema._def.shape()
41
+ const requestSchema = config.requestSchema as unknown as ZodObject
42
+ const shape = requestSchema._zod.def.shape
43
43
  const structure = this.analyzeSchema(shape)
44
44
  getters.push(async (target, request) => {
45
45
  const req: Record<string, any> = {}
@@ -65,9 +65,13 @@ export class MultipartAdapterService extends EndpointAdapterService {
65
65
  }
66
66
  let value
67
67
  if (part.type === 'file') {
68
- value = new File([await part.toBuffer()], part.filename, {
69
- type: part.mimetype,
70
- })
68
+ value = new File(
69
+ [(await part.toBuffer()) as unknown as ArrayBuffer],
70
+ part.filename,
71
+ {
72
+ type: part.mimetype,
73
+ },
74
+ )
71
75
  } else {
72
76
  value = part.value
73
77
  if (isObject && typeof value === 'string') {
@@ -1,5 +1,5 @@
1
1
  import type { ClassType } from '@navios/di'
2
- import type { z, ZodType } from 'zod'
2
+ import type { z, ZodType } from 'zod/v4'
3
3
 
4
4
  import type {
5
5
  ControllerMetadata,
@@ -2,7 +2,7 @@ import { env } from 'node:process'
2
2
 
3
3
  import { FactoryInjectionToken, InjectionToken } from '@navios/di'
4
4
 
5
- import { z } from 'zod'
5
+ import { z } from 'zod/v4'
6
6
 
7
7
  import type { ConfigServiceOptions } from './config.service.mjs'
8
8
 
@@ -13,7 +13,7 @@ import {
13
13
  } from './config.service.mjs'
14
14
 
15
15
  export const ConfigProviderOptions = z.object({
16
- load: z.function().returns(ConfigServiceOptionsSchema),
16
+ load: z.function({ output: ConfigServiceOptionsSchema }),
17
17
  })
18
18
 
19
19
  export function provideConfig<ConfigMap extends ConfigServiceOptions>(
@@ -1,14 +1,14 @@
1
1
  import { NaviosException } from '@navios/builder'
2
2
  import { Injectable, InjectionToken, syncInject } from '@navios/di'
3
3
 
4
- import { z } from 'zod'
4
+ import { z } from 'zod/v4'
5
5
 
6
6
  import type { ConfigServiceInterface as IConfigService } from './config-service.interface.mjs'
7
7
  import type { Path, PathValue } from './types.mjs'
8
8
 
9
9
  import { Logger } from '../logger/index.mjs'
10
10
 
11
- export const ConfigServiceOptionsSchema = z.record(z.unknown())
11
+ export const ConfigServiceOptionsSchema = z.record(z.string(), z.unknown())
12
12
  export type ConfigServiceOptions = z.infer<typeof ConfigServiceOptionsSchema>
13
13
 
14
14
  export const ConfigServiceToken = InjectionToken.create<
@@ -4,9 +4,9 @@ import type {
4
4
  HttpMethod,
5
5
  Util_FlatObject,
6
6
  } from '@navios/builder'
7
- import type { AnyZodObject, z, ZodType } from 'zod'
7
+ import type { z, ZodObject, ZodType } from 'zod/v4'
8
8
 
9
- import { ZodDiscriminatedUnion } from 'zod'
9
+ import { ZodDiscriminatedUnion } from 'zod/v4'
10
10
 
11
11
  import { EndpointAdapterToken } from '../adapters/index.mjs'
12
12
  import { getEndpointMetadata } from '../metadata/index.mjs'
@@ -17,7 +17,7 @@ export type EndpointParams<
17
17
  },
18
18
  Url extends string = EndpointDeclaration['config']['url'],
19
19
  QuerySchema = EndpointDeclaration['config']['querySchema'],
20
- > = QuerySchema extends AnyZodObject
20
+ > = QuerySchema extends ZodType
21
21
  ? EndpointDeclaration['config']['requestSchema'] extends ZodType
22
22
  ? Util_FlatObject<
23
23
  EndpointFunctionArgs<
@@ -45,7 +45,6 @@ export type EndpointResult<
45
45
  },
46
46
  > =
47
47
  EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<
48
- any,
49
48
  infer Options
50
49
  >
51
50
  ? Promise<z.input<Options[number]>>
@@ -68,13 +67,13 @@ export function Endpoint<
68
67
  }) {
69
68
  return (
70
69
  target: (
71
- params: QuerySchema extends AnyZodObject
70
+ params: QuerySchema extends ZodType
72
71
  ? RequestSchema extends ZodType
73
- ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema>
74
- : EndpointFunctionArgs<Url, QuerySchema, undefined>
72
+ ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema, true>
73
+ : EndpointFunctionArgs<Url, QuerySchema, undefined, true>
75
74
  : RequestSchema extends ZodType
76
- ? EndpointFunctionArgs<Url, undefined, RequestSchema>
77
- : EndpointFunctionArgs<Url, undefined, undefined>,
75
+ ? EndpointFunctionArgs<Url, undefined, RequestSchema, true>
76
+ : EndpointFunctionArgs<Url, undefined, undefined, true>,
78
77
  ) => Promise<z.input<ResponseSchema>>,
79
78
  context: ClassMethodDecoratorContext,
80
79
  ) => {
@@ -4,9 +4,9 @@ import type {
4
4
  HttpMethod,
5
5
  Util_FlatObject,
6
6
  } from '@navios/builder'
7
- import type { AnyZodObject, z, ZodType } from 'zod'
7
+ import type { z, ZodObject, ZodType } from 'zod/v4'
8
8
 
9
- import { ZodDiscriminatedUnion } from 'zod'
9
+ import { ZodDiscriminatedUnion } from 'zod/v4'
10
10
 
11
11
  import { MultipartAdapterToken } from '../adapters/index.mjs'
12
12
  import { getEndpointMetadata } from '../metadata/index.mjs'
@@ -17,7 +17,7 @@ export type MultipartParams<
17
17
  },
18
18
  Url extends string = EndpointDeclaration['config']['url'],
19
19
  QuerySchema = EndpointDeclaration['config']['querySchema'],
20
- > = QuerySchema extends AnyZodObject
20
+ > = QuerySchema extends ZodObject
21
21
  ? EndpointDeclaration['config']['requestSchema'] extends ZodType
22
22
  ? Util_FlatObject<
23
23
  EndpointFunctionArgs<
@@ -68,7 +68,7 @@ export function Multipart<
68
68
  }) {
69
69
  return (
70
70
  target: (
71
- params: QuerySchema extends AnyZodObject
71
+ params: QuerySchema extends ZodObject
72
72
  ? RequestSchema extends ZodType
73
73
  ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema>
74
74
  : EndpointFunctionArgs<Url, QuerySchema, undefined>
@@ -5,7 +5,7 @@ import type {
5
5
  Util_FlatObject,
6
6
  } from '@navios/builder'
7
7
  import type { FastifyReply } from 'fastify'
8
- import type { AnyZodObject, ZodType } from 'zod'
8
+ import type { ZodObject, ZodType } from 'zod/v4'
9
9
 
10
10
  import { StreamAdapterToken } from '../adapters/index.mjs'
11
11
  import { getEndpointMetadata } from '../metadata/index.mjs'
@@ -16,7 +16,7 @@ export type StreamParams<
16
16
  },
17
17
  Url extends string = EndpointDeclaration['config']['url'],
18
18
  QuerySchema = EndpointDeclaration['config']['querySchema'],
19
- > = QuerySchema extends AnyZodObject
19
+ > = QuerySchema extends ZodObject
20
20
  ? EndpointDeclaration['config']['requestSchema'] extends ZodType
21
21
  ? Util_FlatObject<
22
22
  EndpointFunctionArgs<
@@ -48,7 +48,7 @@ export function Stream<
48
48
  }) {
49
49
  return (
50
50
  target: (
51
- params: QuerySchema extends AnyZodObject
51
+ params: QuerySchema extends ZodObject
52
52
  ? RequestSchema extends ZodType
53
53
  ? EndpointFunctionArgs<Url, QuerySchema, RequestSchema>
54
54
  : EndpointFunctionArgs<Url, QuerySchema, undefined>
@@ -1,6 +1,6 @@
1
1
  import { Injectable, InjectableType, InjectionToken } from '@navios/di'
2
2
 
3
- import { z } from 'zod'
3
+ import { z } from 'zod/v4'
4
4
 
5
5
  import type { LoggerService } from './logger-service.interface.mjs'
6
6
 
package/tsconfig.json CHANGED
@@ -4,8 +4,13 @@
4
4
  "module": "Node18",
5
5
  "outDir": "dist"
6
6
  },
7
- "include": ["src/**/*"],
8
7
  "references": [
8
+ {
9
+ "path": "./tsconfig.lib.json"
10
+ },
11
+ {
12
+ "path": "./tsconfig.spec.json"
13
+ },
9
14
  {
10
15
  "path": "../builder"
11
16
  },
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist"
5
+ },
6
+ "include": ["src/**/*"],
7
+ "exclude": ["src/**/*.spec.mts"]
8
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist"
5
+ },
6
+ "include": ["src/**/*.spec.mts", "e2e/**/*.mts", "vitest.config.mts"],
7
+ "references": [
8
+ {
9
+ "path": "./tsconfig.lib.json"
10
+ }
11
+ ]
12
+ }
package/tsup.config.mts CHANGED
@@ -5,6 +5,7 @@ export default defineConfig({
5
5
  outDir: 'lib',
6
6
  format: ['esm', 'cjs'],
7
7
  clean: true,
8
+ tsconfig: 'tsconfig.lib.json',
8
9
  treeshake: 'smallest',
9
10
  sourcemap: true,
10
11
  platform: 'node',