@navios/core 0.1.7 → 0.1.8
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/dist/_tsup-dts-rollup.d.mts +8 -0
- package/dist/_tsup-dts-rollup.d.ts +8 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/package.json +1 -1
- package/src/decorators/endpoint.decorator.mts +14 -0
|
@@ -21,6 +21,7 @@ import { ResolveFastifyRequestType } from 'fastify/types/type-provider.js';
|
|
|
21
21
|
import { RouteGenericInterface } from 'fastify';
|
|
22
22
|
import { ServerResponse } from 'http';
|
|
23
23
|
import { z } from 'zod';
|
|
24
|
+
import { ZodDiscriminatedUnion } from 'zod';
|
|
24
25
|
import { ZodOptional } from 'zod';
|
|
25
26
|
import type { ZodType } from 'zod';
|
|
26
27
|
|
|
@@ -438,6 +439,13 @@ export { EndpointParams }
|
|
|
438
439
|
export { EndpointParams as EndpointParams_alias_1 }
|
|
439
440
|
export { EndpointParams as EndpointParams_alias_2 }
|
|
440
441
|
|
|
442
|
+
declare type EndpointResult<EndpointDeclaration extends {
|
|
443
|
+
config: BaseEndpointConfig<any, any, any, any, any>;
|
|
444
|
+
}> = EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<any, infer Options> ? Promise<z.input<Options[number]>> : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>;
|
|
445
|
+
export { EndpointResult }
|
|
446
|
+
export { EndpointResult as EndpointResult_alias_1 }
|
|
447
|
+
export { EndpointResult as EndpointResult_alias_2 }
|
|
448
|
+
|
|
441
449
|
declare enum EndpointType {
|
|
442
450
|
Unknown = "unknown",
|
|
443
451
|
Config = "config",
|
|
@@ -21,6 +21,7 @@ import { ResolveFastifyRequestType } from 'fastify/types/type-provider.js';
|
|
|
21
21
|
import { RouteGenericInterface } from 'fastify';
|
|
22
22
|
import { ServerResponse } from 'http';
|
|
23
23
|
import { z } from 'zod';
|
|
24
|
+
import { ZodDiscriminatedUnion } from 'zod';
|
|
24
25
|
import { ZodOptional } from 'zod';
|
|
25
26
|
import type { ZodType } from 'zod';
|
|
26
27
|
|
|
@@ -438,6 +439,13 @@ export { EndpointParams }
|
|
|
438
439
|
export { EndpointParams as EndpointParams_alias_1 }
|
|
439
440
|
export { EndpointParams as EndpointParams_alias_2 }
|
|
440
441
|
|
|
442
|
+
declare type EndpointResult<EndpointDeclaration extends {
|
|
443
|
+
config: BaseEndpointConfig<any, any, any, any, any>;
|
|
444
|
+
}> = EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<any, infer Options> ? Promise<z.input<Options[number]>> : Promise<z.input<EndpointDeclaration['config']['responseSchema']>>;
|
|
445
|
+
export { EndpointResult }
|
|
446
|
+
export { EndpointResult as EndpointResult_alias_1 }
|
|
447
|
+
export { EndpointResult as EndpointResult_alias_2 }
|
|
448
|
+
|
|
441
449
|
declare enum EndpointType {
|
|
442
450
|
Unknown = "unknown",
|
|
443
451
|
Config = "config",
|
package/dist/index.d.mts
CHANGED
|
@@ -14,6 +14,7 @@ export { Controller } from './_tsup-dts-rollup.mjs';
|
|
|
14
14
|
export { ControllerOptions } from './_tsup-dts-rollup.mjs';
|
|
15
15
|
export { Endpoint } from './_tsup-dts-rollup.mjs';
|
|
16
16
|
export { EndpointParams } from './_tsup-dts-rollup.mjs';
|
|
17
|
+
export { EndpointResult } from './_tsup-dts-rollup.mjs';
|
|
17
18
|
export { Header } from './_tsup-dts-rollup.mjs';
|
|
18
19
|
export { HttpCode } from './_tsup-dts-rollup.mjs';
|
|
19
20
|
export { Module } from './_tsup-dts-rollup.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export { Controller } from './_tsup-dts-rollup.js';
|
|
|
14
14
|
export { ControllerOptions } from './_tsup-dts-rollup.js';
|
|
15
15
|
export { Endpoint } from './_tsup-dts-rollup.js';
|
|
16
16
|
export { EndpointParams } from './_tsup-dts-rollup.js';
|
|
17
|
+
export { EndpointResult } from './_tsup-dts-rollup.js';
|
|
17
18
|
export { Header } from './_tsup-dts-rollup.js';
|
|
18
19
|
export { HttpCode } from './_tsup-dts-rollup.js';
|
|
19
20
|
export { Module } from './_tsup-dts-rollup.js';
|
package/dist/index.js
CHANGED
|
@@ -1944,6 +1944,7 @@ function Controller({ guards } = {}) {
|
|
|
1944
1944
|
}
|
|
1945
1945
|
|
|
1946
1946
|
// packages/core/src/decorators/endpoint.decorator.mts
|
|
1947
|
+
var import_zod4 = require("zod");
|
|
1947
1948
|
function Endpoint(endpoint) {
|
|
1948
1949
|
return (target, context) => {
|
|
1949
1950
|
if (typeof target !== "function") {
|
package/dist/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -5,6 +5,8 @@ import type {
|
|
|
5
5
|
} from '@navios/common'
|
|
6
6
|
import type { AnyZodObject, z, ZodType } from 'zod'
|
|
7
7
|
|
|
8
|
+
import { ZodDiscriminatedUnion } from 'zod'
|
|
9
|
+
|
|
8
10
|
import { EndpointType, getEndpointMetadata } from '../metadata/index.mjs'
|
|
9
11
|
|
|
10
12
|
export type EndpointParams<
|
|
@@ -29,6 +31,18 @@ export type EndpointParams<
|
|
|
29
31
|
>
|
|
30
32
|
: EndpointFunctionArgs<Url, undefined, undefined>
|
|
31
33
|
|
|
34
|
+
export type EndpointResult<
|
|
35
|
+
EndpointDeclaration extends {
|
|
36
|
+
config: BaseEndpointConfig<any, any, any, any, any>
|
|
37
|
+
},
|
|
38
|
+
> =
|
|
39
|
+
EndpointDeclaration['config']['responseSchema'] extends ZodDiscriminatedUnion<
|
|
40
|
+
any,
|
|
41
|
+
infer Options
|
|
42
|
+
>
|
|
43
|
+
? Promise<z.input<Options[number]>>
|
|
44
|
+
: Promise<z.input<EndpointDeclaration['config']['responseSchema']>>
|
|
45
|
+
|
|
32
46
|
export function Endpoint<
|
|
33
47
|
Method extends HttpMethod = HttpMethod,
|
|
34
48
|
Url extends string = string,
|