@navios/core 1.0.0 → 2.0.0-alpha.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/CHANGELOG.md +97 -11
- package/README.md +67 -220
- package/lib/async-context-6pdlnNLA.d.mts +237 -0
- package/lib/async-context-6pdlnNLA.d.mts.map +1 -0
- package/lib/async-context-Dqk7pE-D.d.cts +237 -0
- package/lib/async-context-Dqk7pE-D.d.cts.map +1 -0
- package/lib/attribute-factory-B3VuYnp7.d.cts +70 -0
- package/lib/attribute-factory-B3VuYnp7.d.cts.map +1 -0
- package/lib/attribute-factory-mKOXoVnV.d.mts +70 -0
- package/lib/attribute-factory-mKOXoVnV.d.mts.map +1 -0
- package/lib/attribute-value-CjX9ZkLq.cjs +172 -0
- package/lib/attribute-value-CjX9ZkLq.cjs.map +1 -0
- package/lib/attribute-value-DMEA255r.mjs +119 -0
- package/lib/attribute-value-DMEA255r.mjs.map +1 -0
- package/lib/basic-execution-context-CeGuhMOz.mjs +246 -0
- package/lib/basic-execution-context-CeGuhMOz.mjs.map +1 -0
- package/lib/basic-execution-context-DSk5MNtc.cjs +281 -0
- package/lib/basic-execution-context-DSk5MNtc.cjs.map +1 -0
- package/lib/execution-context-BPD3FeFb.d.mts +71 -0
- package/lib/execution-context-BPD3FeFb.d.mts.map +1 -0
- package/lib/execution-context-BTJdHhbf.d.cts +71 -0
- package/lib/execution-context-BTJdHhbf.d.cts.map +1 -0
- package/lib/execution-context-token-BXUKB2hf.cjs +112 -0
- package/lib/execution-context-token-BXUKB2hf.cjs.map +1 -0
- package/lib/execution-context-token-CrXmTvk2.mjs +77 -0
- package/lib/execution-context-token-CrXmTvk2.mjs.map +1 -0
- package/lib/index.cjs +1687 -4409
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +838 -3
- package/lib/index.d.cts.map +1 -0
- package/lib/index.d.mts +838 -3
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +1573 -4219
- package/lib/index.mjs.map +1 -1
- package/lib/legacy-compat/index.cjs +72 -371
- package/lib/legacy-compat/index.cjs.map +1 -1
- package/lib/legacy-compat/index.d.cts +42 -382
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +41 -382
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/legacy-compat/index.mjs +51 -345
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/lib/module-Bha7GER_.mjs +135 -0
- package/lib/module-Bha7GER_.mjs.map +1 -0
- package/lib/module-DZewk_2r.cjs +164 -0
- package/lib/module-DZewk_2r.cjs.map +1 -0
- package/lib/module-graph-DCP9MHG0.cjs +147 -0
- package/lib/module-graph-DCP9MHG0.cjs.map +1 -0
- package/lib/module-graph-xvVEykFM.mjs +142 -0
- package/lib/module-graph-xvVEykFM.mjs.map +1 -0
- package/lib/module-metadata-C8S92seK.cjs +95 -0
- package/lib/module-metadata-C8S92seK.cjs.map +1 -0
- package/lib/module-metadata-k3RTt20x.mjs +66 -0
- package/lib/module-metadata-k3RTt20x.mjs.map +1 -0
- package/lib/module-options-Dmse0gii.d.mts +51 -0
- package/lib/module-options-Dmse0gii.d.mts.map +1 -0
- package/lib/module-options-IuDO-p8u.d.cts +51 -0
- package/lib/module-options-IuDO-p8u.d.cts.map +1 -0
- package/lib/testing/index.cjs +96 -414
- package/lib/testing/index.cjs.map +1 -1
- package/lib/testing/index.d.cts +25 -385
- package/lib/testing/index.d.cts.map +1 -1
- package/lib/testing/index.d.mts +24 -385
- package/lib/testing/index.d.mts.map +1 -1
- package/lib/testing/index.mjs +94 -408
- package/lib/testing/index.mjs.map +1 -1
- package/lib/transport.cjs +25 -0
- package/lib/transport.d.cts +190 -0
- package/lib/transport.d.cts.map +1 -0
- package/lib/transport.d.mts +190 -0
- package/lib/transport.d.mts.map +1 -0
- package/lib/transport.mjs +7 -0
- package/package.json +37 -17
- package/docs/README.md +0 -316
- package/docs/adapters.md +0 -308
- package/docs/application-setup.md +0 -524
- package/docs/attributes.md +0 -689
- package/docs/controllers.md +0 -373
- package/docs/endpoints.md +0 -444
- package/docs/exceptions.md +0 -352
- package/docs/guards.md +0 -550
- package/docs/legacy-compat.md +0 -356
- package/docs/modules.md +0 -377
- package/docs/quick-start.md +0 -290
- package/docs/services.md +0 -427
- package/docs/testing.md +0 -827
- package/lib/index-C0Sg16Eb.d.cts +0 -3365
- package/lib/index-C0Sg16Eb.d.cts.map +0 -1
- package/lib/index-DySQ6Dpd.d.mts +0 -3365
- package/lib/index-DySQ6Dpd.d.mts.map +0 -1
- package/lib/navios.factory-CO5MB_OK.cjs +0 -4125
- package/lib/navios.factory-CO5MB_OK.cjs.map +0 -1
- package/lib/navios.factory-D6Y94P9B.mjs +0 -3828
- package/lib/navios.factory-D6Y94P9B.mjs.map +0 -1
- package/lib/tokens-4J9sredA.mjs +0 -100
- package/lib/tokens-4J9sredA.mjs.map +0 -1
- package/lib/tokens-CWw9kyeD.cjs +0 -196
- package/lib/tokens-CWw9kyeD.cjs.map +0 -1
- package/lib/use-guards.decorator-BecoQSmE.mjs +0 -339
- package/lib/use-guards.decorator-BecoQSmE.mjs.map +0 -1
- package/lib/use-guards.decorator-C4ml9XaT.cjs +0 -447
- package/lib/use-guards.decorator-C4ml9XaT.cjs.map +0 -1
- package/project.json +0 -66
- package/src/__tests__/attribute.factory.spec.mts +0 -300
- package/src/__tests__/config.service.spec.mts +0 -43
- package/src/__tests__/console-logger.service.spec.mts +0 -312
- package/src/__tests__/controller-resolver.spec.mts +0 -229
- package/src/__tests__/controller.spec.mts +0 -58
- package/src/__tests__/guard-runner.service.spec.mts +0 -399
- package/src/__tests__/logger.service.spec.mts +0 -147
- package/src/__tests__/responders.spec.mts +0 -340
- package/src/__tests__/testing-module.spec.mts +0 -459
- package/src/__tests__/unit-testing-module.spec.mts +0 -424
- package/src/attribute.factory.mts +0 -325
- package/src/config/config-service.interface.mts +0 -47
- package/src/config/config.provider.mts +0 -69
- package/src/config/config.service.mts +0 -176
- package/src/config/index.mts +0 -5
- package/src/config/types.mts +0 -58
- package/src/config/utils/helpers.mts +0 -23
- package/src/config/utils/index.mts +0 -1
- package/src/decorators/controller.decorator.mts +0 -81
- package/src/decorators/endpoint.decorator.mts +0 -181
- package/src/decorators/header.decorator.mts +0 -38
- package/src/decorators/http-code.decorator.mts +0 -38
- package/src/decorators/index.mts +0 -8
- package/src/decorators/module.decorator.mts +0 -106
- package/src/decorators/multipart.decorator.mts +0 -169
- package/src/decorators/stream.decorator.mts +0 -155
- package/src/decorators/use-guards.decorator.mts +0 -73
- package/src/exceptions/bad-request.exception.mts +0 -28
- package/src/exceptions/conflict.exception.mts +0 -31
- package/src/exceptions/forbidden.exception.mts +0 -30
- package/src/exceptions/http.exception.mts +0 -33
- package/src/exceptions/index.mts +0 -7
- package/src/exceptions/internal-server-error.exception.mts +0 -33
- package/src/exceptions/not-found.exception.mts +0 -33
- package/src/exceptions/unauthorized.exception.mts +0 -30
- package/src/factories/adapter.factory.mts +0 -20
- package/src/factories/endpoint-adapter.factory.mts +0 -21
- package/src/factories/http-adapter.factory.mts +0 -20
- package/src/factories/index.mts +0 -8
- package/src/factories/multipart-adapter.factory.mts +0 -21
- package/src/factories/reply.factory.mts +0 -21
- package/src/factories/request.factory.mts +0 -21
- package/src/factories/stream-adapter.factory.mts +0 -20
- package/src/factories/xml-stream-adapter.factory.mts +0 -20
- package/src/index.mts +0 -16
- package/src/interfaces/abstract-adapter.interface.mts +0 -32
- package/src/interfaces/abstract-execution-context.inteface.mts +0 -48
- package/src/interfaces/abstract-http-adapter.interface.mts +0 -79
- package/src/interfaces/abstract-http-cors-options.interface.mts +0 -59
- package/src/interfaces/abstract-http-handler-adapter.interface.mts +0 -127
- package/src/interfaces/abstract-http-listen-options.interface.mts +0 -4
- package/src/interfaces/adapter-environment.interface.mts +0 -74
- package/src/interfaces/can-activate.mts +0 -38
- package/src/interfaces/http-header.mts +0 -18
- package/src/interfaces/index.mts +0 -11
- package/src/interfaces/navios-module.mts +0 -28
- package/src/interfaces/plugin.interface.mts +0 -139
- package/src/legacy-compat/__type-tests__/legacy-decorators.spec-d.mts +0 -521
- package/src/legacy-compat/__type-tests__/tsconfig.json +0 -15
- package/src/legacy-compat/attribute.factory.mts +0 -351
- package/src/legacy-compat/decorators/controller.decorator.mts +0 -31
- package/src/legacy-compat/decorators/endpoint.decorator.mts +0 -73
- package/src/legacy-compat/decorators/header.decorator.mts +0 -43
- package/src/legacy-compat/decorators/http-code.decorator.mts +0 -39
- package/src/legacy-compat/decorators/index.mts +0 -11
- package/src/legacy-compat/decorators/module.decorator.mts +0 -37
- package/src/legacy-compat/decorators/multipart.decorator.mts +0 -72
- package/src/legacy-compat/decorators/stream.decorator.mts +0 -89
- package/src/legacy-compat/decorators/use-guards.decorator.mts +0 -80
- package/src/legacy-compat/index.mts +0 -57
- package/src/logger/README.md +0 -3
- package/src/logger/console-logger.service.mts +0 -714
- package/src/logger/index.mts +0 -6
- package/src/logger/log-levels.mts +0 -21
- package/src/logger/logger-service.interface.mts +0 -42
- package/src/logger/logger.service.mts +0 -113
- package/src/logger/logger.tokens.mts +0 -44
- package/src/logger/utils/cli-colors.util.mts +0 -17
- package/src/logger/utils/filter-log-levelts.util.mts +0 -29
- package/src/logger/utils/index.mts +0 -5
- package/src/logger/utils/is-log-level-enabled.mts +0 -33
- package/src/logger/utils/is-log-level.util.mts +0 -10
- package/src/logger/utils/shared.utils.mts +0 -51
- package/src/metadata/controller.metadata.mts +0 -72
- package/src/metadata/handler.metadata.mts +0 -80
- package/src/metadata/index.mts +0 -4
- package/src/metadata/module.metadata.mts +0 -108
- package/src/metadata/navios-managed.metadata.mts +0 -42
- package/src/navios.application.mts +0 -484
- package/src/navios.environment.mts +0 -42
- package/src/navios.factory.mts +0 -158
- package/src/responders/enums/framework-error.enum.mts +0 -38
- package/src/responders/enums/index.mts +0 -1
- package/src/responders/index.mts +0 -4
- package/src/responders/interfaces/error-responder.interface.mts +0 -42
- package/src/responders/interfaces/error-response.interface.mts +0 -22
- package/src/responders/interfaces/index.mts +0 -3
- package/src/responders/interfaces/problem-details.interface.mts +0 -34
- package/src/responders/services/error-response-producer.service.mts +0 -143
- package/src/responders/services/forbidden-responder.service.mts +0 -77
- package/src/responders/services/index.mts +0 -5
- package/src/responders/services/internal-server-error-responder.service.mts +0 -57
- package/src/responders/services/not-found-responder.service.mts +0 -76
- package/src/responders/services/validation-error-responder.service.mts +0 -78
- package/src/responders/tokens/index.mts +0 -1
- package/src/responders/tokens/responder.tokens.mts +0 -84
- package/src/services/abstract-handler-adapter.service.mts +0 -366
- package/src/services/guard-runner.service.mts +0 -152
- package/src/services/index.mts +0 -4
- package/src/services/instance-resolver.service.mts +0 -177
- package/src/services/module-loader.service.mts +0 -252
- package/src/stores/index.mts +0 -1
- package/src/stores/request-id.store.mts +0 -85
- package/src/testing/index.mts +0 -3
- package/src/testing/testing-module.mts +0 -393
- package/src/testing/unit-testing-module.mts +0 -298
- package/src/tokens/adapter.token.mts +0 -6
- package/src/tokens/endpoint-adapter.token.mts +0 -8
- package/src/tokens/execution-context.token.mts +0 -9
- package/src/tokens/http-adapter.token.mts +0 -8
- package/src/tokens/index.mts +0 -10
- package/src/tokens/multipart-adapter.token.mts +0 -8
- package/src/tokens/navios-options.token.mts +0 -6
- package/src/tokens/reply.token.mts +0 -3
- package/src/tokens/request.token.mts +0 -3
- package/src/tokens/stream-adapter.token.mts +0 -8
- package/src/tokens/xml-stream-adapter.token.mts +0 -8
- package/src/utils/adapter-supports.util.mts +0 -47
- package/src/utils/index.mts +0 -1
- package/tsconfig.json +0 -21
- package/tsconfig.lib.json +0 -8
- package/tsconfig.spec.json +0 -15
- package/tsdown.config.mts +0 -35
- package/vitest.config.mts +0 -15
|
@@ -1,393 +1,52 @@
|
|
|
1
|
-
import { Et as CanActivate, Fn as EndpointParams, In as EndpointResult, Rn as ControllerOptions, Tn as ControllerMetadata, ft as MultipartParams, ht as ModuleOptions, jn as HandlerMetadata, pt as MultipartResult, ut as StreamParams, wt as HttpHeader, yn as ModuleMetadata } from "../index-DySQ6Dpd.mjs";
|
|
2
|
-
import { ClassType, ClassTypeWithInstance, InjectionToken } from "@navios/di";
|
|
3
|
-
import { ZodType, z as z$1 } from "zod/v4";
|
|
4
|
-
import { BaseEndpointOptions, EndpointHandler, EndpointOptions, RequestArgs, StreamHandler } from "@navios/builder";
|
|
5
|
-
import { Factory, FactoryOptions, Injectable, InjectableOptions, createClassContext, createMethodContext } from "@navios/di/legacy-compat";
|
|
6
|
-
|
|
7
|
-
//#region src/legacy-compat/decorators/module.decorator.d.mts
|
|
8
|
-
|
|
9
1
|
/**
|
|
10
|
-
*
|
|
2
|
+
* Decorators for projects that keep `experimentalDecorators: true`
|
|
3
|
+
* (TypeScript legacy decorators). Projects that use standard decorators,
|
|
4
|
+
* including under Bun, use the main entry point instead.
|
|
11
5
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @returns A class decorator compatible with legacy decorator API
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
* ```typescript
|
|
19
|
-
* @Module({
|
|
20
|
-
* controllers: [UserController, AuthController],
|
|
21
|
-
* imports: [DatabaseModule],
|
|
22
|
-
* guards: [AuthGuard],
|
|
23
|
-
* })
|
|
24
|
-
* export class AppModule {}
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
declare function Module(options?: ModuleOptions): (target: ClassType) => ClassType;
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region src/legacy-compat/decorators/controller.decorator.d.mts
|
|
30
|
-
/**
|
|
31
|
-
* Legacy-compatible Controller decorator.
|
|
32
|
-
*
|
|
33
|
-
* Works with TypeScript experimental decorators (legacy API).
|
|
34
|
-
*
|
|
35
|
-
* @param options - Controller configuration options
|
|
36
|
-
* @returns A class decorator compatible with legacy decorator API
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* ```typescript
|
|
40
|
-
* @Controller({ guards: [AuthGuard] })
|
|
41
|
-
* export class UserController {
|
|
42
|
-
* @Endpoint(getUserEndpoint)
|
|
43
|
-
* async getUser() { }
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
declare function Controller(options?: ControllerOptions): (target: ClassType) => ClassType;
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region src/legacy-compat/decorators/endpoint.decorator.d.mts
|
|
50
|
-
/**
|
|
51
|
-
* Type helper to constrain a PropertyDescriptor's value to match an endpoint signature.
|
|
52
|
-
* Note: In legacy decorators, type constraints are checked when the decorator is applied,
|
|
53
|
-
* but may not be preserved perfectly when decorators are stacked.
|
|
54
|
-
*/
|
|
55
|
-
type EndpointMethodDescriptor<Config extends EndpointOptions> = TypedPropertyDescriptor<(params: RequestArgs<Config['url'], Config['querySchema'], Config['requestSchema'], Config['urlParamsSchema'], true>) => Promise<z$1.input<Config['responseSchema']>>>;
|
|
56
|
-
/**
|
|
57
|
-
* Legacy-compatible Endpoint decorator.
|
|
58
|
-
*
|
|
59
|
-
* Works with TypeScript experimental decorators (legacy API).
|
|
60
|
-
* Provides type safety by ensuring method signatures match the endpoint configuration.
|
|
61
|
-
*
|
|
62
|
-
* @param endpoint - The endpoint declaration from @navios/builder
|
|
63
|
-
* @returns A method decorator compatible with legacy decorator API
|
|
64
|
-
*
|
|
65
|
-
* @example
|
|
66
|
-
* ```typescript
|
|
67
|
-
* @Controller()
|
|
68
|
-
* export class UserController {
|
|
69
|
-
* @Endpoint(getUserEndpoint)
|
|
70
|
-
* async getUser(request: EndpointParams<typeof getUserEndpoint>): EndpointResult<typeof getUserEndpoint> {
|
|
71
|
-
* return { id: '1', name: 'John' }
|
|
72
|
-
* }
|
|
73
|
-
* }
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
declare function Endpoint<const Config extends EndpointOptions>(endpoint: EndpointHandler<Config, false>): (target: any, propertyKey: string | symbol, descriptor: EndpointMethodDescriptor<Config>) => PropertyDescriptor | void;
|
|
77
|
-
//#endregion
|
|
78
|
-
//#region src/legacy-compat/decorators/use-guards.decorator.d.mts
|
|
79
|
-
/**
|
|
80
|
-
* Legacy-compatible UseGuards decorator.
|
|
81
|
-
*
|
|
82
|
-
* Works with TypeScript experimental decorators (legacy API).
|
|
83
|
-
* Can be applied to classes or methods.
|
|
84
|
-
*
|
|
85
|
-
* @param guards - Guard classes or injection tokens to apply
|
|
86
|
-
* @returns A class or method decorator compatible with legacy decorator API
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```typescript
|
|
90
|
-
* // Apply to a controller
|
|
91
|
-
* @Controller()
|
|
92
|
-
* @UseGuards(AuthGuard, RoleGuard)
|
|
93
|
-
* export class UserController { }
|
|
94
|
-
*
|
|
95
|
-
* // Apply to a specific endpoint
|
|
96
|
-
* @Controller()
|
|
97
|
-
* export class UserController {
|
|
98
|
-
* @Endpoint(getUserEndpoint)
|
|
99
|
-
* @UseGuards(AuthGuard)
|
|
100
|
-
* async getUser() { }
|
|
101
|
-
* }
|
|
102
|
-
* ```
|
|
103
|
-
*/
|
|
104
|
-
declare function UseGuards(...guards: (ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>)[]): any;
|
|
105
|
-
//#endregion
|
|
106
|
-
//#region src/legacy-compat/decorators/header.decorator.d.mts
|
|
107
|
-
/**
|
|
108
|
-
* Legacy-compatible Header decorator.
|
|
109
|
-
*
|
|
110
|
-
* Works with TypeScript experimental decorators (legacy API).
|
|
111
|
-
*
|
|
112
|
-
* @param name - The header name (e.g., 'Content-Type', 'Cache-Control')
|
|
113
|
-
* @param value - The header value (string, number, or array of strings)
|
|
114
|
-
* @returns A method decorator compatible with legacy decorator API
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* ```typescript
|
|
118
|
-
* @Controller()
|
|
119
|
-
* export class UserController {
|
|
120
|
-
* @Endpoint(getUserEndpoint)
|
|
121
|
-
* @Header('Cache-Control', 'max-age=3600')
|
|
122
|
-
* async getUser() {
|
|
123
|
-
* return { id: '1', name: 'John' }
|
|
124
|
-
* }
|
|
125
|
-
* }
|
|
126
|
-
* ```
|
|
127
|
-
*/
|
|
128
|
-
declare function Header(name: HttpHeader, value: string | number | string[]): <T extends object>(target: T, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region src/legacy-compat/decorators/http-code.decorator.d.mts
|
|
131
|
-
/**
|
|
132
|
-
* Legacy-compatible HttpCode decorator.
|
|
133
|
-
*
|
|
134
|
-
* Works with TypeScript experimental decorators (legacy API).
|
|
135
|
-
*
|
|
136
|
-
* @param code - The HTTP status code to return (e.g., 201, 204, 202)
|
|
137
|
-
* @returns A method decorator compatible with legacy decorator API
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```typescript
|
|
141
|
-
* @Controller()
|
|
142
|
-
* export class UserController {
|
|
143
|
-
* @Endpoint(createUserEndpoint)
|
|
144
|
-
* @HttpCode(201)
|
|
145
|
-
* async createUser() {
|
|
146
|
-
* return { id: '1', name: 'John' }
|
|
147
|
-
* }
|
|
148
|
-
* }
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
declare function HttpCode(code: number): <T extends object>(target: T, propertyKey: string | symbol, descriptor: PropertyDescriptor) => PropertyDescriptor;
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/legacy-compat/decorators/multipart.decorator.d.mts
|
|
154
|
-
/**
|
|
155
|
-
* Type helper to constrain a PropertyDescriptor's value to match a multipart endpoint signature.
|
|
156
|
-
* Note: In legacy decorators, type constraints are checked when the decorator is applied,
|
|
157
|
-
* but may not be preserved perfectly when decorators are stacked.
|
|
6
|
+
* Each one adapts the legacy decorator signature and calls the same
|
|
7
|
+
* implementation as the standard decorator of the same name, so behaviour is
|
|
8
|
+
* identical.
|
|
158
9
|
*/
|
|
159
|
-
|
|
10
|
+
import { Factory, Injectable, createClassContext, createMethodContext } from "@navios/di/legacy-compat";
|
|
11
|
+
import { o as InterceptorClass, r as GuardClass, t as ModuleOptions } from "../module-options-Dmse0gii.mjs";
|
|
12
|
+
import { ClassType, InferInput, StandardSchemaV1 } from "@navios/di";
|
|
13
|
+
import { n as AttributeFactory$1, t as AttributeApplication } from "../attribute-factory-mKOXoVnV.mjs";
|
|
14
|
+
type StandardDecorator = (target: any, context: any) => any;
|
|
15
|
+
/** A decorator that accepts every legacy call shape. */
|
|
16
|
+
type LegacyAnyDecorator = (target: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => any;
|
|
160
17
|
/**
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
* Works with TypeScript experimental decorators (legacy API).
|
|
164
|
-
* Provides type safety by ensuring method signatures match the endpoint configuration.
|
|
165
|
-
*
|
|
166
|
-
* @param endpoint - The multipart endpoint declaration from @navios/builder
|
|
167
|
-
* @returns A method decorator compatible with legacy decorator API
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```typescript
|
|
171
|
-
* @Controller()
|
|
172
|
-
* export class FileController {
|
|
173
|
-
* @Multipart(uploadFileEndpoint)
|
|
174
|
-
* async uploadFile(request: MultipartParams<typeof uploadFileEndpoint>): MultipartResult<typeof uploadFileEndpoint> {
|
|
175
|
-
* const { file } = request.data
|
|
176
|
-
* return { url: 'https://example.com/file.jpg' }
|
|
177
|
-
* }
|
|
178
|
-
* }
|
|
179
|
-
* ```
|
|
18
|
+
* Turns a standard decorator into one that accepts the legacy call shapes:
|
|
19
|
+
* `(constructor)`, `(prototype, key, descriptor)` and `(prototype, key)`.
|
|
180
20
|
*/
|
|
181
|
-
declare function
|
|
182
|
-
//#endregion
|
|
183
|
-
//#region src/legacy-compat/decorators/stream.decorator.d.mts
|
|
21
|
+
export declare function legacy(decorator: StandardDecorator): (target: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => any;
|
|
184
22
|
/**
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
* Note: In legacy decorators, type constraints are checked when the decorator is applied,
|
|
188
|
-
* but may not be preserved perfectly when decorators are stacked.
|
|
23
|
+
* An attribute application usable as a legacy decorator and in
|
|
24
|
+
* `handler(endpoint, { attributes: [...] }, fn)`.
|
|
189
25
|
*/
|
|
190
|
-
type
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
* @Controller()
|
|
203
|
-
* export class FileController {
|
|
204
|
-
* @Stream(downloadFileEndpoint)
|
|
205
|
-
* async downloadFile(request: StreamParams<typeof downloadFileEndpoint>, reply: any) {
|
|
206
|
-
* const { fileId } = request.urlParams
|
|
207
|
-
* // Stream file data to reply
|
|
208
|
-
* }
|
|
209
|
-
* }
|
|
210
|
-
* ```
|
|
211
|
-
*/
|
|
212
|
-
declare function Stream<const Config extends BaseEndpointOptions>(endpoint: StreamHandler<Config, false>): (target: any, propertyKey: string | symbol, descriptor: StreamMethodDescriptor<Config>) => PropertyDescriptor | void;
|
|
213
|
-
//#endregion
|
|
214
|
-
//#region src/legacy-compat/attribute.factory.d.mts
|
|
215
|
-
/**
|
|
216
|
-
* Type for a legacy class/method attribute decorator without a value.
|
|
217
|
-
*
|
|
218
|
-
* Attributes are custom metadata decorators that can be applied to modules,
|
|
219
|
-
* controllers, and endpoints.
|
|
220
|
-
*/
|
|
221
|
-
type LegacyClassAttribute = {
|
|
222
|
-
(): ClassDecorator & MethodDecorator;
|
|
223
|
-
token: symbol;
|
|
224
|
-
};
|
|
26
|
+
type LegacyAttributeApplication = LegacyAnyDecorator & Pick<AttributeApplication, 'token' | 'value'>;
|
|
27
|
+
interface LegacyClassAttribute {
|
|
28
|
+
(): LegacyAttributeApplication;
|
|
29
|
+
readonly token: symbol;
|
|
30
|
+
}
|
|
31
|
+
interface LegacyClassSchemaAttribute<Schema extends StandardSchemaV1> {
|
|
32
|
+
(value: InferInput<Schema>): LegacyAttributeApplication;
|
|
33
|
+
readonly token: symbol;
|
|
34
|
+
readonly schema: Schema;
|
|
35
|
+
}
|
|
36
|
+
declare function createAttribute(token: symbol): LegacyClassAttribute;
|
|
37
|
+
declare function createAttribute<Schema extends StandardSchemaV1>(token: symbol, schema: Schema): LegacyClassSchemaAttribute<Schema>;
|
|
225
38
|
/**
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
* @typeParam S - The Zod schema type for validation
|
|
39
|
+
* `AttributeFactory` whose attributes are legacy decorators. Reading
|
|
40
|
+
* (`get`, `getAll`, `has`) is the same as the standard one.
|
|
229
41
|
*/
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
42
|
+
export declare const AttributeFactory: {
|
|
43
|
+
createAttribute: typeof createAttribute;
|
|
44
|
+
get: typeof AttributeFactory$1.get;
|
|
45
|
+
getAll: typeof AttributeFactory$1.getAll;
|
|
46
|
+
has: typeof AttributeFactory$1.has;
|
|
234
47
|
};
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
*
|
|
240
|
-
* Attributes allow you to add custom metadata to modules, controllers, and endpoints.
|
|
241
|
-
* This is useful for cross-cutting concerns like rate limiting, caching, API versioning, etc.
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* ```typescript
|
|
245
|
-
* // Create a simple boolean attribute
|
|
246
|
-
* const Public = LegacyAttributeFactory.createAttribute(Symbol.for('Public'))
|
|
247
|
-
*
|
|
248
|
-
* // Use it as a decorator
|
|
249
|
-
* @Controller()
|
|
250
|
-
* @Public()
|
|
251
|
-
* export class PublicController { }
|
|
252
|
-
*
|
|
253
|
-
* // Check if attribute exists
|
|
254
|
-
* if (LegacyAttributeFactory.has(Public, controllerMetadata)) {
|
|
255
|
-
* // Skip authentication
|
|
256
|
-
* }
|
|
257
|
-
* ```
|
|
258
|
-
*
|
|
259
|
-
* @example
|
|
260
|
-
* ```typescript
|
|
261
|
-
* // Create an attribute with a validated value
|
|
262
|
-
* const RateLimit = LegacyAttributeFactory.createAttribute(
|
|
263
|
-
* Symbol.for('RateLimit'),
|
|
264
|
-
* z.object({ requests: z.number(), window: z.number() })
|
|
265
|
-
* )
|
|
266
|
-
*
|
|
267
|
-
* // Use it with a value
|
|
268
|
-
* @Endpoint(apiEndpoint)
|
|
269
|
-
* @RateLimit({ requests: 100, window: 60000 })
|
|
270
|
-
* async handler() { }
|
|
271
|
-
*
|
|
272
|
-
* // Get the value
|
|
273
|
-
* const limit = LegacyAttributeFactory.get(RateLimit, endpointMetadata)
|
|
274
|
-
* // limit is typed as { requests: number, window: number } | null
|
|
275
|
-
* ```
|
|
276
|
-
*/
|
|
277
|
-
declare class LegacyAttributeFactory {
|
|
278
|
-
/**
|
|
279
|
-
* Creates a simple attribute decorator without a value.
|
|
280
|
-
*
|
|
281
|
-
* @param token - A unique symbol to identify this attribute
|
|
282
|
-
* @returns A decorator function that can be applied to classes or methods
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* ```typescript
|
|
286
|
-
* const Public = LegacyAttributeFactory.createAttribute(Symbol.for('Public'))
|
|
287
|
-
*
|
|
288
|
-
* @Public()
|
|
289
|
-
* @Controller()
|
|
290
|
-
* export class PublicController { }
|
|
291
|
-
* ```
|
|
292
|
-
*/
|
|
293
|
-
static createAttribute(token: symbol): LegacyClassAttribute;
|
|
294
|
-
/**
|
|
295
|
-
* Creates an attribute decorator with a validated value.
|
|
296
|
-
*
|
|
297
|
-
* @param token - A unique symbol to identify this attribute
|
|
298
|
-
* @param schema - A Zod schema to validate the attribute value
|
|
299
|
-
* @returns A decorator function that accepts a value and can be applied to classes or methods
|
|
300
|
-
*
|
|
301
|
-
* @example
|
|
302
|
-
* ```typescript
|
|
303
|
-
* const RateLimit = LegacyAttributeFactory.createAttribute(
|
|
304
|
-
* Symbol.for('RateLimit'),
|
|
305
|
-
* z.object({ requests: z.number(), window: z.number() })
|
|
306
|
-
* )
|
|
307
|
-
*
|
|
308
|
-
* @RateLimit({ requests: 100, window: 60000 })
|
|
309
|
-
* @Endpoint(apiEndpoint)
|
|
310
|
-
* async handler() { }
|
|
311
|
-
* ```
|
|
312
|
-
*/
|
|
313
|
-
static createAttribute<T extends ZodType>(token: symbol, schema: T): LegacyClassSchemaAttribute<T>;
|
|
314
|
-
/**
|
|
315
|
-
* Gets the value of an attribute from metadata.
|
|
316
|
-
*
|
|
317
|
-
* Returns `null` if the attribute is not present.
|
|
318
|
-
* For simple attributes (without values), returns `true` if present.
|
|
319
|
-
*
|
|
320
|
-
* @param attribute - The attribute decorator
|
|
321
|
-
* @param target - The metadata object (module, controller, or handler)
|
|
322
|
-
* @returns The attribute value, `true` for simple attributes, or `null` if not found
|
|
323
|
-
*
|
|
324
|
-
* @example
|
|
325
|
-
* ```typescript
|
|
326
|
-
* const isPublic = LegacyAttributeFactory.get(Public, controllerMetadata)
|
|
327
|
-
* // isPublic is true | null
|
|
328
|
-
*
|
|
329
|
-
* const rateLimit = LegacyAttributeFactory.get(RateLimit, endpointMetadata)
|
|
330
|
-
* // rateLimit is { requests: number, window: number } | null
|
|
331
|
-
* ```
|
|
332
|
-
*/
|
|
333
|
-
static get(attribute: LegacyClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): true | null;
|
|
334
|
-
static get<T extends ZodType>(attribute: LegacyClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): z$1.output<T> | null;
|
|
335
|
-
/**
|
|
336
|
-
* Gets all values of an attribute from metadata (useful when an attribute can appear multiple times).
|
|
337
|
-
*
|
|
338
|
-
* Returns `null` if the attribute is not present.
|
|
339
|
-
*
|
|
340
|
-
* @param attribute - The attribute decorator
|
|
341
|
-
* @param target - The metadata object (module, controller, or handler)
|
|
342
|
-
* @returns An array of attribute values, or `null` if not found
|
|
343
|
-
*
|
|
344
|
-
* @example
|
|
345
|
-
* ```typescript
|
|
346
|
-
* const tags = LegacyAttributeFactory.getAll(Tag, endpointMetadata)
|
|
347
|
-
* // tags is string[] | null
|
|
348
|
-
* ```
|
|
349
|
-
*/
|
|
350
|
-
static getAll(attribute: LegacyClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<true> | null;
|
|
351
|
-
static getAll<T extends ZodType>(attribute: LegacyClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<z$1.output<T>> | null;
|
|
352
|
-
/**
|
|
353
|
-
* Gets the last value of an attribute from an array of metadata objects.
|
|
354
|
-
*
|
|
355
|
-
* Searches from the end of the array backwards, useful for finding the most
|
|
356
|
-
* specific attribute value (e.g., endpoint-level overrides module-level).
|
|
357
|
-
*
|
|
358
|
-
* @param attribute - The attribute decorator
|
|
359
|
-
* @param target - An array of metadata objects (typically [module, controller, handler])
|
|
360
|
-
* @returns The last attribute value found, or `null` if not found
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* ```typescript
|
|
364
|
-
* // Check attribute hierarchy: endpoint -> controller -> module
|
|
365
|
-
* const rateLimit = LegacyAttributeFactory.getLast(RateLimit, [
|
|
366
|
-
* moduleMetadata,
|
|
367
|
-
* controllerMetadata,
|
|
368
|
-
* endpointMetadata
|
|
369
|
-
* ])
|
|
370
|
-
* ```
|
|
371
|
-
*/
|
|
372
|
-
static getLast(attribute: LegacyClassAttribute, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): true | null;
|
|
373
|
-
static getLast<T extends ZodType>(attribute: LegacyClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): z$1.output<T> | null;
|
|
374
|
-
/**
|
|
375
|
-
* Checks if an attribute is present on the metadata object.
|
|
376
|
-
*
|
|
377
|
-
* @param attribute - The attribute decorator
|
|
378
|
-
* @param target - The metadata object (module, controller, or handler)
|
|
379
|
-
* @returns `true` if the attribute is present, `false` otherwise
|
|
380
|
-
*
|
|
381
|
-
* @example
|
|
382
|
-
* ```typescript
|
|
383
|
-
* if (LegacyAttributeFactory.has(Public, controllerMetadata)) {
|
|
384
|
-
* // Skip authentication
|
|
385
|
-
* }
|
|
386
|
-
* ```
|
|
387
|
-
*/
|
|
388
|
-
static has(attribute: LegacyClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
|
|
389
|
-
static has<T extends ZodType>(attribute: LegacyClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
|
|
390
|
-
}
|
|
391
|
-
//#endregion
|
|
392
|
-
export { LegacyAttributeFactory as AttributeFactory, LegacyAttributeFactory, Controller, type ControllerOptions, Endpoint, type EndpointParams, type EndpointResult, Factory, type FactoryOptions, Header, HttpCode, Injectable, type InjectableOptions, type LegacyClassAttribute, type LegacyClassSchemaAttribute, Module, type ModuleOptions, Multipart, type MultipartParams, type MultipartResult, Stream, type StreamParams, UseGuards, createClassContext, createMethodContext };
|
|
48
|
+
export declare function Module(options?: ModuleOptions): <T extends ClassType>(target: T) => T;
|
|
49
|
+
export declare function UseGuards(...guards: GuardClass[]): LegacyAnyDecorator;
|
|
50
|
+
export declare function UseInterceptors(...interceptors: InterceptorClass[]): LegacyAnyDecorator;
|
|
51
|
+
export { Factory, Injectable, type LegacyAnyDecorator, type LegacyAttributeApplication, type LegacyClassAttribute, type LegacyClassSchemaAttribute, type ModuleOptions, type StandardDecorator, createClassContext, createMethodContext };
|
|
393
52
|
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/legacy-compat/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../src/legacy-compat/legacy-decorator.mts","../../src/legacy-compat/attribute-factory.mts","../../src/legacy-compat/module.mts","../../src/legacy-compat/use-guards.mts","../../src/legacy-compat/use-interceptors.mts"],"mappings":";;;;;;;;;;;;;KAIY,qBAAqB,aAAa;;KAGlC,sBACV,aACA,+BACA,aAAa;;;;;wBAOC,OAAO,WAAW,qBAAiB,aAC9B,+BAA+B,aAAe;;;;;KCFvD,6BAA6B,qBACvC,KAAK;UAEU;MACX;WACK;;UAGM,2BAA2B,eAAe;GACxD,OAAO,WAAW,UAAU;WACpB;WACA,QAAQ;;iBAGV,gBAAgB,gBAAgB;iBAChC,gBAAgB,eAAe,kBACtC,eACA,QAAQ,SACP,2BAA2B;;;;;qBAmBjB;;;;;;wBC7CG,OAAO,UAAS,iBACa,UAAU,WAAW,QAAQ,MAAM;wBCDhE,aAAa,QAAQ,eAAe;wBCApC,mBAAmB,cAAc,qBAAqB"}
|