@navios/core 0.7.0 → 0.8.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 +53 -0
- package/lib/{index-BFwNx9WQ.d.cts → index-BDNl7j1G.d.cts} +666 -292
- package/lib/index-BDNl7j1G.d.cts.map +1 -0
- package/lib/{index-D657ijFO.d.mts → index-BoP0cWT6.d.mts} +666 -292
- package/lib/index-BoP0cWT6.d.mts.map +1 -0
- package/lib/index.cjs +15 -6
- package/lib/index.d.cts +2 -2
- package/lib/index.d.mts +2 -2
- package/lib/index.mjs +3 -3
- package/lib/legacy-compat/index.cjs +1 -1
- package/lib/legacy-compat/index.cjs.map +1 -1
- package/lib/legacy-compat/index.d.cts +1 -1
- package/lib/legacy-compat/index.d.cts.map +1 -1
- package/lib/legacy-compat/index.d.mts +1 -1
- package/lib/legacy-compat/index.d.mts.map +1 -1
- package/lib/legacy-compat/index.mjs +1 -1
- package/lib/legacy-compat/index.mjs.map +1 -1
- package/lib/{src-Cb1aTjl0.cjs → src-B6eISODM.cjs} +622 -114
- package/lib/src-B6eISODM.cjs.map +1 -0
- package/lib/{src-DzPY5s6d.mjs → src-gBAChVRL.mjs} +563 -73
- package/lib/src-gBAChVRL.mjs.map +1 -0
- package/lib/testing/index.cjs +6 -6
- package/lib/testing/index.cjs.map +1 -1
- package/lib/testing/index.d.cts +1 -1
- package/lib/testing/index.d.mts +1 -1
- package/lib/testing/index.mjs +2 -2
- package/lib/{use-guards.decorator-DdvUhB03.cjs → use-guards.decorator-COR-9mZY.cjs} +34 -108
- package/lib/use-guards.decorator-COR-9mZY.cjs.map +1 -0
- package/lib/{use-guards.decorator-kZ3lNK8v.mjs → use-guards.decorator-CUww54Nt.mjs} +14 -94
- package/lib/use-guards.decorator-CUww54Nt.mjs.map +1 -0
- package/package.json +12 -12
- package/src/__tests__/controller-resolver.spec.mts +223 -0
- package/src/__tests__/controller.spec.mts +1 -1
- package/src/decorators/controller.decorator.mts +11 -6
- package/src/decorators/endpoint.decorator.mts +60 -12
- package/src/decorators/multipart.decorator.mts +67 -24
- package/src/decorators/stream.decorator.mts +65 -24
- package/src/interfaces/abstract-http-adapter.interface.mts +52 -0
- package/src/interfaces/abstract-http-handler-adapter.interface.mts +31 -1
- package/src/interfaces/index.mts +1 -0
- package/src/interfaces/plugin.interface.mts +105 -0
- package/src/legacy-compat/decorators/endpoint.decorator.mts +1 -1
- package/src/legacy-compat/decorators/multipart.decorator.mts +1 -1
- package/src/legacy-compat/decorators/stream.decorator.mts +1 -1
- package/src/logger/logger.service.mts +3 -3
- package/src/navios.application.mts +91 -27
- package/src/navios.factory.mts +29 -9
- package/src/services/guard-runner.service.mts +46 -9
- package/src/services/index.mts +1 -0
- package/src/services/instance-resolver.service.mts +186 -0
- package/src/services/module-loader.service.mts +102 -1
- package/src/stores/request-id.store.mts +45 -3
- package/src/tokens/index.mts +1 -0
- package/src/tokens/navios-options.token.mts +6 -0
- package/lib/index-BFwNx9WQ.d.cts.map +0 -1
- package/lib/index-D657ijFO.d.mts.map +0 -1
- package/lib/src-Cb1aTjl0.cjs.map +0 -1
- package/lib/src-DzPY5s6d.mjs.map +0 -1
- package/lib/use-guards.decorator-DdvUhB03.cjs.map +0 -1
- package/lib/use-guards.decorator-kZ3lNK8v.mjs.map +0 -1
- package/src/attribute.factory.d.mts +0 -175
- package/src/attribute.factory.d.mts.map +0 -1
- package/src/config/config-service.interface.d.mts +0 -39
- package/src/config/config-service.interface.d.mts.map +0 -1
- package/src/config/config.provider.d.mts +0 -46
- package/src/config/config.provider.d.mts.map +0 -1
- package/src/config/config.service.d.mts +0 -108
- package/src/config/config.service.d.mts.map +0 -1
- package/src/config/index.d.mts +0 -6
- package/src/config/index.d.mts.map +0 -1
- package/src/config/types.d.mts +0 -13
- package/src/config/types.d.mts.map +0 -1
- package/src/config/utils/helpers.d.mts +0 -3
- package/src/config/utils/helpers.d.mts.map +0 -1
- package/src/config/utils/index.d.mts +0 -2
- package/src/config/utils/index.d.mts.map +0 -1
- package/src/decorators/controller.decorator.d.mts +0 -33
- package/src/decorators/controller.decorator.d.mts.map +0 -1
- package/src/decorators/endpoint.decorator.d.mts +0 -89
- package/src/decorators/endpoint.decorator.d.mts.map +0 -1
- package/src/decorators/header.decorator.d.mts +0 -22
- package/src/decorators/header.decorator.d.mts.map +0 -1
- package/src/decorators/http-code.decorator.d.mts +0 -22
- package/src/decorators/http-code.decorator.d.mts.map +0 -1
- package/src/decorators/index.d.mts +0 -9
- package/src/decorators/index.d.mts.map +0 -1
- package/src/decorators/module.decorator.d.mts +0 -42
- package/src/decorators/module.decorator.d.mts.map +0 -1
- package/src/decorators/multipart.decorator.d.mts +0 -54
- package/src/decorators/multipart.decorator.d.mts.map +0 -1
- package/src/decorators/stream.decorator.d.mts +0 -42
- package/src/decorators/stream.decorator.d.mts.map +0 -1
- package/src/decorators/use-guards.decorator.d.mts +0 -33
- package/src/decorators/use-guards.decorator.d.mts.map +0 -1
- package/src/exceptions/bad-request.exception.d.mts +0 -26
- package/src/exceptions/bad-request.exception.d.mts.map +0 -1
- package/src/exceptions/conflict.exception.d.mts +0 -29
- package/src/exceptions/conflict.exception.d.mts.map +0 -1
- package/src/exceptions/forbidden.exception.d.mts +0 -28
- package/src/exceptions/forbidden.exception.d.mts.map +0 -1
- package/src/exceptions/http.exception.d.mts +0 -33
- package/src/exceptions/http.exception.d.mts.map +0 -1
- package/src/exceptions/index.d.mts +0 -8
- package/src/exceptions/index.d.mts.map +0 -1
- package/src/exceptions/internal-server-error.exception.d.mts +0 -31
- package/src/exceptions/internal-server-error.exception.d.mts.map +0 -1
- package/src/exceptions/not-found.exception.d.mts +0 -30
- package/src/exceptions/not-found.exception.d.mts.map +0 -1
- package/src/exceptions/unauthorized.exception.d.mts +0 -28
- package/src/exceptions/unauthorized.exception.d.mts.map +0 -1
- package/src/factories/endpoint-adapter.factory.d.mts +0 -6
- package/src/factories/endpoint-adapter.factory.d.mts.map +0 -1
- package/src/factories/http-adapter.factory.d.mts +0 -6
- package/src/factories/http-adapter.factory.d.mts.map +0 -1
- package/src/factories/index.d.mts +0 -8
- package/src/factories/index.d.mts.map +0 -1
- package/src/factories/multipart-adapter.factory.d.mts +0 -6
- package/src/factories/multipart-adapter.factory.d.mts.map +0 -1
- package/src/factories/reply.factory.d.mts +0 -6
- package/src/factories/reply.factory.d.mts.map +0 -1
- package/src/factories/request.factory.d.mts +0 -6
- package/src/factories/request.factory.d.mts.map +0 -1
- package/src/factories/stream-adapter.factory.d.mts +0 -6
- package/src/factories/stream-adapter.factory.d.mts.map +0 -1
- package/src/factories/xml-stream-adapter.factory.d.mts +0 -6
- package/src/factories/xml-stream-adapter.factory.d.mts.map +0 -1
- package/src/index.d.mts +0 -15
- package/src/index.d.mts.map +0 -1
- package/src/interfaces/abstract-execution-context.inteface.d.mts +0 -44
- package/src/interfaces/abstract-execution-context.inteface.d.mts.map +0 -1
- package/src/interfaces/abstract-http-adapter.interface.d.mts +0 -15
- package/src/interfaces/abstract-http-adapter.interface.d.mts.map +0 -1
- package/src/interfaces/abstract-http-cors-options.interface.d.mts +0 -58
- package/src/interfaces/abstract-http-cors-options.interface.d.mts.map +0 -1
- package/src/interfaces/abstract-http-handler-adapter.interface.d.mts +0 -7
- package/src/interfaces/abstract-http-handler-adapter.interface.d.mts.map +0 -1
- package/src/interfaces/abstract-http-listen-options.interface.d.mts +0 -5
- package/src/interfaces/abstract-http-listen-options.interface.d.mts.map +0 -1
- package/src/interfaces/can-activate.d.mts +0 -36
- package/src/interfaces/can-activate.d.mts.map +0 -1
- package/src/interfaces/http-header.d.mts +0 -10
- package/src/interfaces/http-header.d.mts.map +0 -1
- package/src/interfaces/index.d.mts +0 -9
- package/src/interfaces/index.d.mts.map +0 -1
- package/src/interfaces/navios-module.d.mts +0 -29
- package/src/interfaces/navios-module.d.mts.map +0 -1
- package/src/legacy-compat/context-compat.d.mts +0 -19
- package/src/legacy-compat/context-compat.d.mts.map +0 -1
- package/src/legacy-compat/decorators/controller.decorator.d.mts +0 -21
- package/src/legacy-compat/decorators/controller.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/endpoint.decorator.d.mts +0 -33
- package/src/legacy-compat/decorators/endpoint.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/header.decorator.d.mts +0 -24
- package/src/legacy-compat/decorators/header.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/http-code.decorator.d.mts +0 -22
- package/src/legacy-compat/decorators/http-code.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/index.d.mts +0 -9
- package/src/legacy-compat/decorators/index.d.mts.map +0 -1
- package/src/legacy-compat/decorators/module.decorator.d.mts +0 -22
- package/src/legacy-compat/decorators/module.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/multipart.decorator.d.mts +0 -34
- package/src/legacy-compat/decorators/multipart.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/stream.decorator.d.mts +0 -34
- package/src/legacy-compat/decorators/stream.decorator.d.mts.map +0 -1
- package/src/legacy-compat/decorators/use-guards.decorator.d.mts +0 -29
- package/src/legacy-compat/decorators/use-guards.decorator.d.mts.map +0 -1
- package/src/legacy-compat/index.d.mts +0 -19
- package/src/legacy-compat/index.d.mts.map +0 -1
- package/src/logger/console-logger.service.d.mts +0 -196
- package/src/logger/console-logger.service.d.mts.map +0 -1
- package/src/logger/index.d.mts +0 -7
- package/src/logger/index.d.mts.map +0 -1
- package/src/logger/log-levels.d.mts +0 -14
- package/src/logger/log-levels.d.mts.map +0 -1
- package/src/logger/logger-service.interface.d.mts +0 -36
- package/src/logger/logger-service.interface.d.mts.map +0 -1
- package/src/logger/logger.service.d.mts +0 -57
- package/src/logger/logger.service.d.mts.map +0 -1
- package/src/logger/logger.tokens.d.mts +0 -36
- package/src/logger/logger.tokens.d.mts.map +0 -1
- package/src/logger/utils/cli-colors.util.d.mts +0 -10
- package/src/logger/utils/cli-colors.util.d.mts.map +0 -1
- package/src/logger/utils/filter-log-levelts.util.d.mts +0 -6
- package/src/logger/utils/filter-log-levelts.util.d.mts.map +0 -1
- package/src/logger/utils/index.d.mts +0 -6
- package/src/logger/utils/index.d.mts.map +0 -1
- package/src/logger/utils/is-log-level-enabled.d.mts +0 -8
- package/src/logger/utils/is-log-level-enabled.d.mts.map +0 -1
- package/src/logger/utils/is-log-level.util.d.mts +0 -6
- package/src/logger/utils/is-log-level.util.d.mts.map +0 -1
- package/src/logger/utils/shared.utils.d.mts +0 -14
- package/src/logger/utils/shared.utils.d.mts.map +0 -1
- package/src/metadata/controller.metadata.d.mts +0 -13
- package/src/metadata/controller.metadata.d.mts.map +0 -1
- package/src/metadata/handler.metadata.d.mts +0 -18
- package/src/metadata/handler.metadata.d.mts.map +0 -1
- package/src/metadata/index.d.mts +0 -4
- package/src/metadata/index.d.mts.map +0 -1
- package/src/metadata/module.metadata.d.mts +0 -13
- package/src/metadata/module.metadata.d.mts.map +0 -1
- package/src/navios.application.d.mts +0 -210
- package/src/navios.application.d.mts.map +0 -1
- package/src/navios.environment.d.mts +0 -11
- package/src/navios.environment.d.mts.map +0 -1
- package/src/navios.factory.d.mts +0 -68
- package/src/navios.factory.d.mts.map +0 -1
- package/src/services/guard-runner.service.d.mts +0 -10
- package/src/services/guard-runner.service.d.mts.map +0 -1
- package/src/services/index.d.mts +0 -3
- package/src/services/index.d.mts.map +0 -1
- package/src/services/module-loader.service.d.mts +0 -17
- package/src/services/module-loader.service.d.mts.map +0 -1
- package/src/stores/index.d.mts +0 -2
- package/src/stores/index.d.mts.map +0 -1
- package/src/stores/request-id.store.d.mts +0 -37
- package/src/stores/request-id.store.d.mts.map +0 -1
- package/src/tokens/endpoint-adapter.token.d.mts +0 -4
- package/src/tokens/endpoint-adapter.token.d.mts.map +0 -1
- package/src/tokens/execution-context.token.d.mts +0 -5
- package/src/tokens/execution-context.token.d.mts.map +0 -1
- package/src/tokens/http-adapter.token.d.mts +0 -4
- package/src/tokens/http-adapter.token.d.mts.map +0 -1
- package/src/tokens/index.d.mts +0 -9
- package/src/tokens/index.d.mts.map +0 -1
- package/src/tokens/multipart-adapter.token.d.mts +0 -4
- package/src/tokens/multipart-adapter.token.d.mts.map +0 -1
- package/src/tokens/reply.token.d.mts +0 -3
- package/src/tokens/reply.token.d.mts.map +0 -1
- package/src/tokens/request.token.d.mts +0 -3
- package/src/tokens/request.token.d.mts.map +0 -1
- package/src/tokens/stream-adapter.token.d.mts +0 -4
- package/src/tokens/stream-adapter.token.d.mts.map +0 -1
- package/src/tokens/xml-stream-adapter.token.d.mts +0 -4
- package/src/tokens/xml-stream-adapter.token.d.mts.map +0 -1
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as _navios_di0 from "@navios/di";
|
|
2
|
-
import { AnyInjectableType, ClassType, ClassTypeWithInstance, Container, FactoryContext, FactoryInjectionToken, InjectionToken, ScopedContainer } from "@navios/di";
|
|
2
|
+
import { AnyInjectableType, ClassType, ClassTypeWithInstance, Container, FactoryContext, FactoryInjectionToken, InjectionToken, Registry, ScopedContainer } from "@navios/di";
|
|
3
3
|
import z, { ZodDiscriminatedUnion, ZodObject, ZodType, z as z$1 } from "zod/v4";
|
|
4
4
|
import { BaseEndpointConfig, BaseStreamConfig, EndpointFunctionArgs, HttpMethod, Util_FlatObject } from "@navios/builder";
|
|
5
5
|
import { InspectOptions } from "util";
|
|
6
|
-
import { AsyncLocalStorage } from "node:async_hooks";
|
|
7
6
|
import { OutgoingHttpHeaders } from "http";
|
|
8
7
|
|
|
9
8
|
//#region src/config/utils/helpers.d.mts
|
|
@@ -220,6 +219,11 @@ interface ControllerOptions {
|
|
|
220
219
|
* Guards are executed in reverse order (last guard first).
|
|
221
220
|
*/
|
|
222
221
|
guards?: ClassType[] | Set<ClassType>;
|
|
222
|
+
/**
|
|
223
|
+
* Registry to use for the controller.
|
|
224
|
+
* Registry is used to store the controller and its endpoints.
|
|
225
|
+
*/
|
|
226
|
+
registry?: Registry;
|
|
223
227
|
}
|
|
224
228
|
/**
|
|
225
229
|
* Decorator that marks a class as a Navios controller.
|
|
@@ -242,7 +246,8 @@ interface ControllerOptions {
|
|
|
242
246
|
* ```
|
|
243
247
|
*/
|
|
244
248
|
declare function Controller({
|
|
245
|
-
guards
|
|
249
|
+
guards,
|
|
250
|
+
registry
|
|
246
251
|
}?: ControllerOptions): (target: ClassType, context: ClassDecoratorContext) => ClassType;
|
|
247
252
|
//#endregion
|
|
248
253
|
//#region src/decorators/endpoint.decorator.d.mts
|
|
@@ -328,9 +333,12 @@ type EndpointResult<EndpointDeclaration extends {
|
|
|
328
333
|
* }
|
|
329
334
|
* ```
|
|
330
335
|
*/
|
|
336
|
+
declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType, 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>)>(endpoint: {
|
|
337
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
|
|
338
|
+
}): (target: (params: Params) => Promise<z$1.input<ResponseSchema>> | z$1.input<ResponseSchema>, context: ClassMethodDecoratorContext) => void;
|
|
331
339
|
declare function Endpoint<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
|
|
332
340
|
config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
|
|
333
|
-
}): (target: (
|
|
341
|
+
}): (target: () => Promise<z$1.input<ResponseSchema>> | z$1.input<ResponseSchema>, context: ClassMethodDecoratorContext) => void;
|
|
334
342
|
//#endregion
|
|
335
343
|
//#region src/metadata/handler.metadata.d.mts
|
|
336
344
|
declare const EndpointMetadataKey: unique symbol;
|
|
@@ -858,22 +866,86 @@ interface AbstractHttpListenOptions {
|
|
|
858
866
|
}
|
|
859
867
|
//#endregion
|
|
860
868
|
//#region src/interfaces/abstract-http-adapter.interface.d.mts
|
|
869
|
+
/**
|
|
870
|
+
* Abstract interface for HTTP adapters.
|
|
871
|
+
*
|
|
872
|
+
* Adapters implement this interface to provide runtime-specific HTTP server
|
|
873
|
+
* functionality (Fastify, Bun, etc.).
|
|
874
|
+
*
|
|
875
|
+
* @typeParam ServerInstance - The underlying server type (e.g., FastifyInstance)
|
|
876
|
+
* @typeParam CorsOptions - CORS configuration options type
|
|
877
|
+
* @typeParam Options - Server setup options type
|
|
878
|
+
* @typeParam MultipartOptions - Multipart form handling options type
|
|
879
|
+
*/
|
|
861
880
|
interface AbstractHttpAdapterInterface<ServerInstance, CorsOptions = AbstractHttpCorsOptions, Options$1 = {}, MultipartOptions = {}> {
|
|
881
|
+
/**
|
|
882
|
+
* Sets up the HTTP server with the provided options.
|
|
883
|
+
*/
|
|
862
884
|
setupHttpServer(options: Options$1): Promise<void>;
|
|
885
|
+
/**
|
|
886
|
+
* Called after all modules are loaded to register routes.
|
|
887
|
+
*/
|
|
863
888
|
onModulesInit(modules: Map<string, ModuleMetadata>): Promise<void>;
|
|
889
|
+
/**
|
|
890
|
+
* Signals that the server is ready to accept requests.
|
|
891
|
+
*/
|
|
864
892
|
ready(): Promise<void>;
|
|
893
|
+
/**
|
|
894
|
+
* Returns the underlying HTTP server instance.
|
|
895
|
+
*/
|
|
865
896
|
getServer(): ServerInstance;
|
|
897
|
+
/**
|
|
898
|
+
* Sets a global prefix for all routes.
|
|
899
|
+
*/
|
|
866
900
|
setGlobalPrefix(prefix: string): void;
|
|
901
|
+
/**
|
|
902
|
+
* Gets the current global prefix.
|
|
903
|
+
* Returns empty string if no prefix is set.
|
|
904
|
+
*/
|
|
905
|
+
getGlobalPrefix(): string;
|
|
906
|
+
/**
|
|
907
|
+
* Enables CORS with the specified options.
|
|
908
|
+
*/
|
|
867
909
|
enableCors(options: CorsOptions): void;
|
|
910
|
+
/**
|
|
911
|
+
* Enables multipart form data handling.
|
|
912
|
+
*/
|
|
868
913
|
enableMultipart(options: MultipartOptions): void;
|
|
914
|
+
/**
|
|
915
|
+
* Starts the server and listens for incoming requests.
|
|
916
|
+
*/
|
|
869
917
|
listen(options: AbstractHttpListenOptions): Promise<string>;
|
|
918
|
+
/**
|
|
919
|
+
* Disposes of the server and cleans up resources.
|
|
920
|
+
*/
|
|
870
921
|
dispose(): Promise<void>;
|
|
871
922
|
}
|
|
872
923
|
//#endregion
|
|
873
924
|
//#region src/interfaces/abstract-http-handler-adapter.interface.d.mts
|
|
925
|
+
/**
|
|
926
|
+
* Static handler result - handler can be called without a scoped container.
|
|
927
|
+
* Used when the controller and all its dependencies are singletons.
|
|
928
|
+
*/
|
|
929
|
+
type StaticHandler<TRequest = any, TReply = any> = {
|
|
930
|
+
isStatic: true;
|
|
931
|
+
handler: (request: TRequest, reply: TReply) => Promise<any>;
|
|
932
|
+
};
|
|
933
|
+
/**
|
|
934
|
+
* Dynamic handler result - handler requires a scoped container for resolution.
|
|
935
|
+
* Used when the controller or its dependencies need per-request resolution.
|
|
936
|
+
*/
|
|
937
|
+
type DynamicHandler<TRequest = any, TReply = any> = {
|
|
938
|
+
isStatic: false;
|
|
939
|
+
handler: (scoped: ScopedContainer, request: TRequest, reply: TReply) => Promise<any>;
|
|
940
|
+
};
|
|
941
|
+
/**
|
|
942
|
+
* Handler result returned by provideHandler.
|
|
943
|
+
* Can be either static (pre-resolved) or dynamic (needs scoped container).
|
|
944
|
+
*/
|
|
945
|
+
type HandlerResult<TRequest = any, TReply = any> = StaticHandler<TRequest, TReply> | DynamicHandler<TRequest, TReply>;
|
|
874
946
|
interface AbstractHttpHandlerAdapterInterface {
|
|
875
947
|
prepareArguments?: (handlerMetadata: HandlerMetadata<any>) => ((target: Record<string, any>, request: any) => Promise<void> | void)[];
|
|
876
|
-
provideHandler: (controller: ClassType, handlerMetadata: HandlerMetadata<any>) =>
|
|
948
|
+
provideHandler: (controller: ClassType, handlerMetadata: HandlerMetadata<any>) => Promise<HandlerResult>;
|
|
877
949
|
}
|
|
878
950
|
//#endregion
|
|
879
951
|
//#region src/interfaces/can-activate.d.mts
|
|
@@ -950,6 +1022,160 @@ interface NaviosModule {
|
|
|
950
1022
|
onModuleInit?: () => Promise<void> | void;
|
|
951
1023
|
}
|
|
952
1024
|
//#endregion
|
|
1025
|
+
//#region src/services/module-loader.service.d.mts
|
|
1026
|
+
/**
|
|
1027
|
+
* Extension definition for dynamically adding to the module tree.
|
|
1028
|
+
* Used by plugins to inject controllers or entire modules.
|
|
1029
|
+
*/
|
|
1030
|
+
interface ModuleExtension {
|
|
1031
|
+
/**
|
|
1032
|
+
* Module class to add. If provided, the module and all its
|
|
1033
|
+
* controllers/imports will be processed.
|
|
1034
|
+
*/
|
|
1035
|
+
module?: ClassTypeWithInstance<NaviosModule>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Controllers to add directly without a wrapper module.
|
|
1038
|
+
* Will be registered under a synthetic module named after the plugin.
|
|
1039
|
+
*/
|
|
1040
|
+
controllers?: ClassType[];
|
|
1041
|
+
/**
|
|
1042
|
+
* Name for the synthetic module when using controllers directly.
|
|
1043
|
+
* Required if `controllers` is provided without `module`.
|
|
1044
|
+
*/
|
|
1045
|
+
moduleName?: string;
|
|
1046
|
+
}
|
|
1047
|
+
declare class ModuleLoaderService {
|
|
1048
|
+
private logger;
|
|
1049
|
+
protected container: Container;
|
|
1050
|
+
private modulesMetadata;
|
|
1051
|
+
private loadedModules;
|
|
1052
|
+
private initialized;
|
|
1053
|
+
loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;
|
|
1054
|
+
/**
|
|
1055
|
+
* Extends the module tree with additional modules or controllers.
|
|
1056
|
+
*
|
|
1057
|
+
* This method is designed to be called by plugins during registration,
|
|
1058
|
+
* which happens after initial module loading but before route registration.
|
|
1059
|
+
*
|
|
1060
|
+
* @param extensions - Array of module extensions to add
|
|
1061
|
+
* @throws Error if not initialized (loadModules must be called first)
|
|
1062
|
+
*
|
|
1063
|
+
* @example
|
|
1064
|
+
* ```typescript
|
|
1065
|
+
* // In plugin registration
|
|
1066
|
+
* const moduleLoader = await context.container.get(ModuleLoaderService)
|
|
1067
|
+
* await moduleLoader.extendModules([{
|
|
1068
|
+
* controllers: [OpenApiJsonController, OpenApiYamlController],
|
|
1069
|
+
* moduleName: 'OpenApiBunModule',
|
|
1070
|
+
* }])
|
|
1071
|
+
* ```
|
|
1072
|
+
*/
|
|
1073
|
+
extendModules(extensions: ModuleExtension[]): Promise<void>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Registers controllers under a synthetic module.
|
|
1076
|
+
* Used when plugins want to add controllers without a full module class.
|
|
1077
|
+
*/
|
|
1078
|
+
private registerControllers;
|
|
1079
|
+
private traverseModules;
|
|
1080
|
+
private mergeMetadata;
|
|
1081
|
+
getAllModules(): Map<string, ModuleMetadata>;
|
|
1082
|
+
dispose(): void;
|
|
1083
|
+
}
|
|
1084
|
+
//#endregion
|
|
1085
|
+
//#region src/interfaces/plugin.interface.d.mts
|
|
1086
|
+
/**
|
|
1087
|
+
* Context provided to plugins during registration.
|
|
1088
|
+
*
|
|
1089
|
+
* This context gives plugins access to the application's modules,
|
|
1090
|
+
* server instance, DI container, and configuration.
|
|
1091
|
+
*/
|
|
1092
|
+
interface PluginContext {
|
|
1093
|
+
/**
|
|
1094
|
+
* All loaded modules with their metadata.
|
|
1095
|
+
* Keys are module class names, values are their metadata.
|
|
1096
|
+
*/
|
|
1097
|
+
modules: Map<string, ModuleMetadata>;
|
|
1098
|
+
/**
|
|
1099
|
+
* The underlying HTTP server instance.
|
|
1100
|
+
* Type depends on the adapter used (Fastify, Bun, etc.)
|
|
1101
|
+
*/
|
|
1102
|
+
server: any;
|
|
1103
|
+
/**
|
|
1104
|
+
* The dependency injection container.
|
|
1105
|
+
*/
|
|
1106
|
+
container: Container;
|
|
1107
|
+
/**
|
|
1108
|
+
* Global route prefix (e.g., '/api/v1').
|
|
1109
|
+
* Empty string if no prefix is set.
|
|
1110
|
+
*/
|
|
1111
|
+
globalPrefix: string;
|
|
1112
|
+
/**
|
|
1113
|
+
* Module loader service for extending the module tree.
|
|
1114
|
+
* Use `moduleLoader.extendModules()` to add controllers dynamically.
|
|
1115
|
+
*/
|
|
1116
|
+
moduleLoader: ModuleLoaderService;
|
|
1117
|
+
}
|
|
1118
|
+
/**
|
|
1119
|
+
* Base interface for Navios plugins.
|
|
1120
|
+
*
|
|
1121
|
+
* Plugins are registered using `app.usePlugin()` and are initialized
|
|
1122
|
+
* after all modules are loaded but before the server starts listening.
|
|
1123
|
+
*
|
|
1124
|
+
* @typeParam TOptions - The type of options the plugin accepts
|
|
1125
|
+
*
|
|
1126
|
+
* @example
|
|
1127
|
+
* ```typescript
|
|
1128
|
+
* const myPlugin: NaviosPlugin<{ enabled: boolean }> = {
|
|
1129
|
+
* name: 'my-plugin',
|
|
1130
|
+
* register: async (context, options) => {
|
|
1131
|
+
* if (options.enabled) {
|
|
1132
|
+
* // Register routes, services, etc.
|
|
1133
|
+
* }
|
|
1134
|
+
* },
|
|
1135
|
+
* }
|
|
1136
|
+
* ```
|
|
1137
|
+
*/
|
|
1138
|
+
interface NaviosPlugin<TOptions = unknown> {
|
|
1139
|
+
/**
|
|
1140
|
+
* Plugin name for identification and logging.
|
|
1141
|
+
*/
|
|
1142
|
+
name: string;
|
|
1143
|
+
/**
|
|
1144
|
+
* Called after modules are loaded but before the server starts listening.
|
|
1145
|
+
*
|
|
1146
|
+
* @param context - The plugin context with access to modules and server
|
|
1147
|
+
* @param options - Plugin-specific configuration options
|
|
1148
|
+
*/
|
|
1149
|
+
register(context: PluginContext, options: TOptions): Promise<void> | void;
|
|
1150
|
+
}
|
|
1151
|
+
/**
|
|
1152
|
+
* Plugin definition combining a plugin with its options.
|
|
1153
|
+
*
|
|
1154
|
+
* This is the type returned by plugin factory functions like `defineOpenApiPlugin()`.
|
|
1155
|
+
*
|
|
1156
|
+
* @typeParam TOptions - The type of options the plugin accepts
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
* ```typescript
|
|
1160
|
+
* function defineMyPlugin(options: MyPluginOptions): PluginDefinition<MyPluginOptions> {
|
|
1161
|
+
* return {
|
|
1162
|
+
* plugin: myPlugin,
|
|
1163
|
+
* options,
|
|
1164
|
+
* }
|
|
1165
|
+
* }
|
|
1166
|
+
* ```
|
|
1167
|
+
*/
|
|
1168
|
+
interface PluginDefinition<TOptions = unknown> {
|
|
1169
|
+
/**
|
|
1170
|
+
* The plugin instance.
|
|
1171
|
+
*/
|
|
1172
|
+
plugin: NaviosPlugin<TOptions>;
|
|
1173
|
+
/**
|
|
1174
|
+
* Options to pass to the plugin's register function.
|
|
1175
|
+
*/
|
|
1176
|
+
options: TOptions;
|
|
1177
|
+
}
|
|
1178
|
+
//#endregion
|
|
953
1179
|
//#region src/decorators/header.decorator.d.mts
|
|
954
1180
|
/**
|
|
955
1181
|
* Decorator that sets a custom HTTP response header for an endpoint.
|
|
@@ -1089,9 +1315,12 @@ type MultipartResult<EndpointDeclaration extends {
|
|
|
1089
1315
|
* }
|
|
1090
1316
|
* ```
|
|
1091
1317
|
*/
|
|
1318
|
+
declare function Multipart<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType, Params = (QuerySchema extends ZodObject ? 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>)>(endpoint: {
|
|
1319
|
+
config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
|
|
1320
|
+
}): (target: (params: Params) => Promise<z$1.input<ResponseSchema>> | z$1.input<ResponseSchema>, context: ClassMethodDecoratorContext) => void;
|
|
1092
1321
|
declare function Multipart<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, ResponseSchema extends ZodType = ZodType, RequestSchema = ZodType>(endpoint: {
|
|
1093
1322
|
config: BaseEndpointConfig<Method, Url, QuerySchema, ResponseSchema, RequestSchema>;
|
|
1094
|
-
}): (target: (
|
|
1323
|
+
}): (target: () => Promise<z$1.input<ResponseSchema>> | z$1.input<ResponseSchema>, context: ClassMethodDecoratorContext) => void;
|
|
1095
1324
|
//#endregion
|
|
1096
1325
|
//#region src/decorators/stream.decorator.d.mts
|
|
1097
1326
|
/**
|
|
@@ -1130,9 +1359,15 @@ type StreamParams<EndpointDeclaration extends {
|
|
|
1130
1359
|
* }
|
|
1131
1360
|
* ```
|
|
1132
1361
|
*/
|
|
1362
|
+
declare function Stream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType, Params = (QuerySchema extends ZodObject ? 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>)>(endpoint: {
|
|
1363
|
+
config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>;
|
|
1364
|
+
}): (target: (params: Params, reply: any) => any, context: ClassMethodDecoratorContext) => void;
|
|
1365
|
+
declare function Stream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType, Params = (QuerySchema extends ZodObject ? 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>)>(endpoint: {
|
|
1366
|
+
config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>;
|
|
1367
|
+
}): (target: (params: Params) => any, context: ClassMethodDecoratorContext) => void;
|
|
1133
1368
|
declare function Stream<Method extends HttpMethod = HttpMethod, Url extends string = string, QuerySchema = undefined, RequestSchema = ZodType>(endpoint: {
|
|
1134
1369
|
config: BaseStreamConfig<Method, Url, QuerySchema, RequestSchema>;
|
|
1135
|
-
}): (target: (
|
|
1370
|
+
}): (target: () => any, context: ClassMethodDecoratorContext) => void;
|
|
1136
1371
|
//#endregion
|
|
1137
1372
|
//#region src/decorators/use-guards.decorator.d.mts
|
|
1138
1373
|
/**
|
|
@@ -1372,51 +1607,153 @@ declare class ConflictException extends HttpException {
|
|
|
1372
1607
|
constructor(message: string | object, error?: Error);
|
|
1373
1608
|
}
|
|
1374
1609
|
//#endregion
|
|
1610
|
+
//#region src/services/instance-resolver.service.d.mts
|
|
1611
|
+
/**
|
|
1612
|
+
* Result of instance resolution attempt.
|
|
1613
|
+
* Contains either a cached singleton instance or a resolver function
|
|
1614
|
+
* that can be used to get a fresh instance per request.
|
|
1615
|
+
*/
|
|
1616
|
+
interface InstanceResolution<T = any> {
|
|
1617
|
+
/**
|
|
1618
|
+
* Whether the instance was successfully cached as a singleton.
|
|
1619
|
+
* If true, `instance` contains the cached instance.
|
|
1620
|
+
* If false, the class has request-scoped dependencies and
|
|
1621
|
+
* must be resolved per-request using `resolve()`.
|
|
1622
|
+
*/
|
|
1623
|
+
cached: boolean;
|
|
1624
|
+
/**
|
|
1625
|
+
* The cached instance (only available if `cached` is true).
|
|
1626
|
+
*/
|
|
1627
|
+
instance: T | null;
|
|
1628
|
+
/**
|
|
1629
|
+
* Resolves the instance from a scoped container.
|
|
1630
|
+
* Use this when `cached` is false to get a fresh instance per request.
|
|
1631
|
+
*/
|
|
1632
|
+
resolve: (scoped: ScopedContainer) => Promise<T>;
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Result of resolving multiple instances.
|
|
1636
|
+
* Contains either all cached singleton instances or a resolver function.
|
|
1637
|
+
*/
|
|
1638
|
+
interface MultiInstanceResolution<T = any> {
|
|
1639
|
+
/**
|
|
1640
|
+
* Whether ALL instances were successfully cached as singletons.
|
|
1641
|
+
* If true, `instances` contains all cached instances.
|
|
1642
|
+
* If false, at least one class has request-scoped dependencies.
|
|
1643
|
+
*/
|
|
1644
|
+
cached: boolean;
|
|
1645
|
+
/**
|
|
1646
|
+
* The cached instances (only available if `cached` is true).
|
|
1647
|
+
* Order matches the input array order.
|
|
1648
|
+
*/
|
|
1649
|
+
instances: T[] | null;
|
|
1650
|
+
/**
|
|
1651
|
+
* The original class types for dynamic resolution.
|
|
1652
|
+
*/
|
|
1653
|
+
classTypes: ClassType[];
|
|
1654
|
+
/**
|
|
1655
|
+
* Resolves all instances from a scoped container.
|
|
1656
|
+
* Use this when `cached` is false to get fresh instances per request.
|
|
1657
|
+
*/
|
|
1658
|
+
resolve: (scoped: ScopedContainer) => Promise<T[]>;
|
|
1659
|
+
}
|
|
1660
|
+
/**
|
|
1661
|
+
* Service responsible for resolving class instances with automatic scope detection.
|
|
1662
|
+
*
|
|
1663
|
+
* This service attempts to resolve classes as singletons from the root container.
|
|
1664
|
+
* If resolution fails (because the class has request-scoped dependencies),
|
|
1665
|
+
* it automatically updates the class's scope to Request and provides a
|
|
1666
|
+
* resolver function for per-request instantiation.
|
|
1667
|
+
*
|
|
1668
|
+
* This enables optimal performance:
|
|
1669
|
+
* - Classes without request-scoped deps stay as singletons (faster)
|
|
1670
|
+
* - Classes with request-scoped deps are automatically promoted to request scope
|
|
1671
|
+
*
|
|
1672
|
+
* @example
|
|
1673
|
+
* ```ts
|
|
1674
|
+
* const resolution = await instanceResolver.resolve(UserController)
|
|
1675
|
+
*
|
|
1676
|
+
* if (resolution.cached) {
|
|
1677
|
+
* // Use cached singleton
|
|
1678
|
+
* return resolution.instance.handleRequest(req)
|
|
1679
|
+
* } else {
|
|
1680
|
+
* // Resolve per request
|
|
1681
|
+
* const controller = await resolution.resolve(scopedContainer)
|
|
1682
|
+
* return controller.handleRequest(req)
|
|
1683
|
+
* }
|
|
1684
|
+
* ```
|
|
1685
|
+
*/
|
|
1686
|
+
declare class InstanceResolverService {
|
|
1687
|
+
private container;
|
|
1688
|
+
/**
|
|
1689
|
+
* Attempts to resolve a class instance, automatically detecting if it needs
|
|
1690
|
+
* request scope based on its dependencies.
|
|
1691
|
+
*
|
|
1692
|
+
* @param classType - The class to resolve
|
|
1693
|
+
* @returns A resolution result containing either a cached instance or resolver function
|
|
1694
|
+
*/
|
|
1695
|
+
resolve<T>(classType: ClassType): Promise<InstanceResolution<T>>;
|
|
1696
|
+
/**
|
|
1697
|
+
* Attempts to resolve multiple class instances, automatically detecting if any need
|
|
1698
|
+
* request scope based on their dependencies.
|
|
1699
|
+
*
|
|
1700
|
+
* Returns `cached: true` only if ALL classes can be resolved as singletons.
|
|
1701
|
+
* If any class has request-scoped dependencies, returns `cached: false`.
|
|
1702
|
+
*
|
|
1703
|
+
* @param classTypes - The classes to resolve
|
|
1704
|
+
* @returns A resolution result containing either all cached instances or resolver function
|
|
1705
|
+
*/
|
|
1706
|
+
resolveMany<T>(classTypes: ClassType[]): Promise<MultiInstanceResolution<T>>;
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* @deprecated Use InstanceResolverService instead
|
|
1710
|
+
*/
|
|
1711
|
+
declare const ControllerResolverService: typeof InstanceResolverService;
|
|
1712
|
+
/**
|
|
1713
|
+
* @deprecated Use InstanceResolution instead
|
|
1714
|
+
*/
|
|
1715
|
+
type ControllerResolution<T = any> = InstanceResolution<T>;
|
|
1716
|
+
//#endregion
|
|
1375
1717
|
//#region src/services/guard-runner.service.d.mts
|
|
1376
1718
|
declare class GuardRunnerService {
|
|
1377
1719
|
private readonly logger;
|
|
1720
|
+
/**
|
|
1721
|
+
* Runs guards that need to be resolved from a scoped container.
|
|
1722
|
+
* Use this when guards have request-scoped dependencies.
|
|
1723
|
+
*/
|
|
1378
1724
|
runGuards(allGuards: Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>, executionContext: AbstractExecutionContext, context: ScopedContainer): Promise<boolean>;
|
|
1725
|
+
/**
|
|
1726
|
+
* Runs pre-resolved guard instances.
|
|
1727
|
+
* Use this when all guards are singletons and have been pre-resolved at startup.
|
|
1728
|
+
*/
|
|
1729
|
+
runGuardsStatic(guardInstances: CanActivate[], executionContext: AbstractExecutionContext): Promise<boolean>;
|
|
1730
|
+
/**
|
|
1731
|
+
* Shared guard execution logic.
|
|
1732
|
+
* Iterates through guard instances and calls canActivate on each.
|
|
1733
|
+
*/
|
|
1734
|
+
private executeGuards;
|
|
1379
1735
|
makeContext(moduleMetadata: ModuleMetadata, controllerMetadata: ControllerMetadata, endpoint: HandlerMetadata): Set<ClassTypeWithInstance<CanActivate> | InjectionToken<CanActivate, undefined>>;
|
|
1380
1736
|
}
|
|
1381
1737
|
//#endregion
|
|
1382
|
-
//#region src/services/module-loader.service.d.mts
|
|
1383
|
-
declare class ModuleLoaderService {
|
|
1384
|
-
private logger;
|
|
1385
|
-
protected container: Container;
|
|
1386
|
-
private modulesMetadata;
|
|
1387
|
-
private loadedModules;
|
|
1388
|
-
private initialized;
|
|
1389
|
-
loadModules(appModule: ClassTypeWithInstance<NaviosModule>): Promise<void>;
|
|
1390
|
-
private traverseModules;
|
|
1391
|
-
private mergeMetadata;
|
|
1392
|
-
getAllModules(): Map<string, ModuleMetadata>;
|
|
1393
|
-
dispose(): void;
|
|
1394
|
-
}
|
|
1395
|
-
//#endregion
|
|
1396
1738
|
//#region src/stores/request-id.store.d.mts
|
|
1397
1739
|
/**
|
|
1398
|
-
*
|
|
1399
|
-
*
|
|
1400
|
-
* This allows logging and other services to access the current request ID
|
|
1401
|
-
* without explicitly passing it through the call stack.
|
|
1402
|
-
*
|
|
1403
|
-
* @example
|
|
1404
|
-
* ```typescript
|
|
1405
|
-
* import { requestIdStore, runWithRequestId, getRequestId } from '@navios/core'
|
|
1740
|
+
* Generates a simple incremental request ID.
|
|
1741
|
+
* Much faster than crypto.randomUUID() and sufficient for request tracking.
|
|
1406
1742
|
*
|
|
1407
|
-
*
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
*
|
|
1743
|
+
* @returns A unique request ID string (e.g., "req-1", "req-2", ...)
|
|
1744
|
+
*/
|
|
1745
|
+
declare function generateRequestId(): string;
|
|
1746
|
+
/**
|
|
1747
|
+
* Enables or disables request ID propagation.
|
|
1748
|
+
* Called by NaviosFactory based on the enableRequestId option.
|
|
1412
1749
|
*
|
|
1413
|
-
*
|
|
1414
|
-
* const currentId = getRequestId()
|
|
1415
|
-
* ```
|
|
1750
|
+
* @param enabled - Whether to enable request ID propagation
|
|
1416
1751
|
*/
|
|
1417
|
-
declare
|
|
1752
|
+
declare function setRequestIdEnabled(enabled: boolean): void;
|
|
1418
1753
|
/**
|
|
1419
1754
|
* Runs a function with a request ID in the async local storage context.
|
|
1755
|
+
* If request ID propagation is disabled, the function is called directly
|
|
1756
|
+
* without AsyncLocalStorage overhead.
|
|
1420
1757
|
*
|
|
1421
1758
|
* @param requestId - The request ID to set for this context
|
|
1422
1759
|
* @param fn - The function to run within this context
|
|
@@ -1443,262 +1780,34 @@ declare const HttpAdapterToken: InjectionToken<AbstractHttpAdapterInterface<any,
|
|
|
1443
1780
|
//#region src/tokens/multipart-adapter.token.d.mts
|
|
1444
1781
|
declare const MultipartAdapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface, undefined, false>;
|
|
1445
1782
|
//#endregion
|
|
1446
|
-
//#region src/
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
declare const Request: InjectionToken<any, undefined, false>;
|
|
1451
|
-
//#endregion
|
|
1452
|
-
//#region src/tokens/stream-adapter.token.d.mts
|
|
1453
|
-
declare const StreamAdapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface, undefined, false>;
|
|
1454
|
-
//#endregion
|
|
1455
|
-
//#region src/tokens/xml-stream-adapter.token.d.mts
|
|
1456
|
-
declare const XmlStreamAdapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface, undefined, false>;
|
|
1783
|
+
//#region src/navios.environment.d.mts
|
|
1784
|
+
interface NaviosEnvironmentOptions {
|
|
1785
|
+
httpTokens?: Map<InjectionToken<any, undefined>, AnyInjectableType>;
|
|
1786
|
+
}
|
|
1457
1787
|
//#endregion
|
|
1458
|
-
//#region src/
|
|
1788
|
+
//#region src/navios.application.d.mts
|
|
1459
1789
|
/**
|
|
1460
|
-
*
|
|
1461
|
-
*
|
|
1462
|
-
* Attributes are custom metadata decorators that can be applied to modules,
|
|
1463
|
-
* controllers, and endpoints.
|
|
1790
|
+
* Options for configuring the Navios application context.
|
|
1791
|
+
* These options control dependency injection and logging behavior.
|
|
1464
1792
|
*/
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1793
|
+
interface NaviosApplicationContextOptions {
|
|
1794
|
+
/**
|
|
1795
|
+
* Specifies the logger to use. Pass `false` to turn off logging.
|
|
1796
|
+
*
|
|
1797
|
+
* - `LoggerService` instance: Use a custom logger implementation
|
|
1798
|
+
* - `LogLevel[]`: Enable specific log levels (e.g., ['error', 'warn', 'log'])
|
|
1799
|
+
* - `false`: Disable logging completely
|
|
1800
|
+
*/
|
|
1801
|
+
logger?: LoggerService | LogLevel[] | false;
|
|
1802
|
+
/**
|
|
1803
|
+
* Specifies a custom container to use. Useful for testing.
|
|
1804
|
+
* If not provided, a new Container will be created.
|
|
1805
|
+
*/
|
|
1806
|
+
container?: Container;
|
|
1807
|
+
}
|
|
1468
1808
|
/**
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1471
|
-
* @typeParam T - The Zod schema type for validation
|
|
1472
|
-
*/
|
|
1473
|
-
type ClassSchemaAttribute<T extends ZodType> = ((value: z$1.input<T>) => <T>(target: T, context: ClassDecoratorContext | ClassMethodDecoratorContext) => T) & {
|
|
1474
|
-
token: symbol;
|
|
1475
|
-
schema: ZodType;
|
|
1476
|
-
};
|
|
1477
|
-
/**
|
|
1478
|
-
* Factory for creating custom attribute decorators.
|
|
1479
|
-
*
|
|
1480
|
-
* Attributes allow you to add custom metadata to modules, controllers, and endpoints.
|
|
1481
|
-
* This is useful for cross-cutting concerns like rate limiting, caching, API versioning, etc.
|
|
1482
|
-
*
|
|
1483
|
-
* @example
|
|
1484
|
-
* ```typescript
|
|
1485
|
-
* // Create a simple boolean attribute
|
|
1486
|
-
* const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
|
|
1487
|
-
*
|
|
1488
|
-
* // Use it as a decorator
|
|
1489
|
-
* @Controller()
|
|
1490
|
-
* @Public()
|
|
1491
|
-
* export class PublicController { }
|
|
1492
|
-
*
|
|
1493
|
-
* // Check if attribute exists
|
|
1494
|
-
* if (AttributeFactory.has(Public, controllerMetadata)) {
|
|
1495
|
-
* // Skip authentication
|
|
1496
|
-
* }
|
|
1497
|
-
* ```
|
|
1498
|
-
*
|
|
1499
|
-
* @example
|
|
1500
|
-
* ```typescript
|
|
1501
|
-
* // Create an attribute with a validated value
|
|
1502
|
-
* const RateLimit = AttributeFactory.createAttribute(
|
|
1503
|
-
* Symbol.for('RateLimit'),
|
|
1504
|
-
* z.object({ requests: z.number(), window: z.number() })
|
|
1505
|
-
* )
|
|
1506
|
-
*
|
|
1507
|
-
* // Use it with a value
|
|
1508
|
-
* @Endpoint(apiEndpoint)
|
|
1509
|
-
* @RateLimit({ requests: 100, window: 60000 })
|
|
1510
|
-
* async handler() { }
|
|
1511
|
-
*
|
|
1512
|
-
* // Get the value
|
|
1513
|
-
* const limit = AttributeFactory.get(RateLimit, endpointMetadata)
|
|
1514
|
-
* // limit is typed as { requests: number, window: number } | null
|
|
1515
|
-
* ```
|
|
1516
|
-
*/
|
|
1517
|
-
declare class AttributeFactory {
|
|
1518
|
-
/**
|
|
1519
|
-
* Creates a simple attribute decorator without a value.
|
|
1520
|
-
*
|
|
1521
|
-
* @param token - A unique symbol to identify this attribute
|
|
1522
|
-
* @returns A decorator function that can be applied to classes or methods
|
|
1523
|
-
*
|
|
1524
|
-
* @example
|
|
1525
|
-
* ```typescript
|
|
1526
|
-
* const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
|
|
1527
|
-
*
|
|
1528
|
-
* @Public()
|
|
1529
|
-
* @Controller()
|
|
1530
|
-
* export class PublicController { }
|
|
1531
|
-
* ```
|
|
1532
|
-
*/
|
|
1533
|
-
static createAttribute(token: symbol): ClassAttribute;
|
|
1534
|
-
/**
|
|
1535
|
-
* Creates an attribute decorator with a validated value.
|
|
1536
|
-
*
|
|
1537
|
-
* @param token - A unique symbol to identify this attribute
|
|
1538
|
-
* @param schema - A Zod schema to validate the attribute value
|
|
1539
|
-
* @returns A decorator function that accepts a value and can be applied to classes or methods
|
|
1540
|
-
*
|
|
1541
|
-
* @example
|
|
1542
|
-
* ```typescript
|
|
1543
|
-
* const RateLimit = AttributeFactory.createAttribute(
|
|
1544
|
-
* Symbol.for('RateLimit'),
|
|
1545
|
-
* z.object({ requests: z.number(), window: z.number() })
|
|
1546
|
-
* )
|
|
1547
|
-
*
|
|
1548
|
-
* @RateLimit({ requests: 100, window: 60000 })
|
|
1549
|
-
* @Endpoint(apiEndpoint)
|
|
1550
|
-
* async handler() { }
|
|
1551
|
-
* ```
|
|
1552
|
-
*/
|
|
1553
|
-
static createAttribute<T extends ZodType>(token: symbol, schema: T): ClassSchemaAttribute<T>;
|
|
1554
|
-
/**
|
|
1555
|
-
* Gets the value of an attribute from metadata.
|
|
1556
|
-
*
|
|
1557
|
-
* Returns `null` if the attribute is not present.
|
|
1558
|
-
* For simple attributes (without values), returns `true` if present.
|
|
1559
|
-
*
|
|
1560
|
-
* @param attribute - The attribute decorator
|
|
1561
|
-
* @param target - The metadata object (module, controller, or handler)
|
|
1562
|
-
* @returns The attribute value, `true` for simple attributes, or `null` if not found
|
|
1563
|
-
*
|
|
1564
|
-
* @example
|
|
1565
|
-
* ```typescript
|
|
1566
|
-
* const isPublic = AttributeFactory.get(Public, controllerMetadata)
|
|
1567
|
-
* // isPublic is true | null
|
|
1568
|
-
*
|
|
1569
|
-
* const rateLimit = AttributeFactory.get(RateLimit, endpointMetadata)
|
|
1570
|
-
* // rateLimit is { requests: number, window: number } | null
|
|
1571
|
-
* ```
|
|
1572
|
-
*/
|
|
1573
|
-
static get(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): true | null;
|
|
1574
|
-
static get<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): z$1.output<T> | null;
|
|
1575
|
-
/**
|
|
1576
|
-
* Gets all values of an attribute from metadata (useful when an attribute can appear multiple times).
|
|
1577
|
-
*
|
|
1578
|
-
* Returns `null` if the attribute is not present.
|
|
1579
|
-
*
|
|
1580
|
-
* @param attribute - The attribute decorator
|
|
1581
|
-
* @param target - The metadata object (module, controller, or handler)
|
|
1582
|
-
* @returns An array of attribute values, or `null` if not found
|
|
1583
|
-
*
|
|
1584
|
-
* @example
|
|
1585
|
-
* ```typescript
|
|
1586
|
-
* const tags = AttributeFactory.getAll(Tag, endpointMetadata)
|
|
1587
|
-
* // tags is string[] | null
|
|
1588
|
-
* ```
|
|
1589
|
-
*/
|
|
1590
|
-
static getAll(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<true> | null;
|
|
1591
|
-
static getAll<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<z$1.output<T>> | null;
|
|
1592
|
-
/**
|
|
1593
|
-
* Gets the last value of an attribute from an array of metadata objects.
|
|
1594
|
-
*
|
|
1595
|
-
* Searches from the end of the array backwards, useful for finding the most
|
|
1596
|
-
* specific attribute value (e.g., endpoint-level overrides module-level).
|
|
1597
|
-
*
|
|
1598
|
-
* @param attribute - The attribute decorator
|
|
1599
|
-
* @param target - An array of metadata objects (typically [module, controller, handler])
|
|
1600
|
-
* @returns The last attribute value found, or `null` if not found
|
|
1601
|
-
*
|
|
1602
|
-
* @example
|
|
1603
|
-
* ```typescript
|
|
1604
|
-
* // Check attribute hierarchy: endpoint -> controller -> module
|
|
1605
|
-
* const rateLimit = AttributeFactory.getLast(RateLimit, [
|
|
1606
|
-
* moduleMetadata,
|
|
1607
|
-
* controllerMetadata,
|
|
1608
|
-
* endpointMetadata
|
|
1609
|
-
* ])
|
|
1610
|
-
* ```
|
|
1611
|
-
*/
|
|
1612
|
-
static getLast(attribute: ClassAttribute, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): true | null;
|
|
1613
|
-
static getLast<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): z$1.output<T> | null;
|
|
1614
|
-
/**
|
|
1615
|
-
* Checks if an attribute is present on the metadata object.
|
|
1616
|
-
*
|
|
1617
|
-
* @param attribute - The attribute decorator
|
|
1618
|
-
* @param target - The metadata object (module, controller, or handler)
|
|
1619
|
-
* @returns `true` if the attribute is present, `false` otherwise
|
|
1620
|
-
*
|
|
1621
|
-
* @example
|
|
1622
|
-
* ```typescript
|
|
1623
|
-
* if (AttributeFactory.has(Public, controllerMetadata)) {
|
|
1624
|
-
* // Skip authentication
|
|
1625
|
-
* }
|
|
1626
|
-
* ```
|
|
1627
|
-
*/
|
|
1628
|
-
static has(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
|
|
1629
|
-
static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
|
|
1630
|
-
}
|
|
1631
|
-
//#endregion
|
|
1632
|
-
//#region src/factories/endpoint-adapter.factory.d.mts
|
|
1633
|
-
declare class EndpointAdapterFactory {
|
|
1634
|
-
private readonly environment;
|
|
1635
|
-
create(ctx: FactoryContext): Promise<any>;
|
|
1636
|
-
}
|
|
1637
|
-
//#endregion
|
|
1638
|
-
//#region src/factories/http-adapter.factory.d.mts
|
|
1639
|
-
declare class HttpAdapterFactory {
|
|
1640
|
-
private readonly environment;
|
|
1641
|
-
create(ctx: FactoryContext): Promise<any>;
|
|
1642
|
-
}
|
|
1643
|
-
//#endregion
|
|
1644
|
-
//#region src/factories/multipart-adapter.factory.d.mts
|
|
1645
|
-
declare class MultipartAdapterFactory {
|
|
1646
|
-
private readonly environment;
|
|
1647
|
-
create(ctx: FactoryContext): Promise<any>;
|
|
1648
|
-
}
|
|
1649
|
-
//#endregion
|
|
1650
|
-
//#region src/factories/request.factory.d.mts
|
|
1651
|
-
declare class RequestFactory {
|
|
1652
|
-
private readonly environment;
|
|
1653
|
-
create(ctx: FactoryContext): Promise<any>;
|
|
1654
|
-
}
|
|
1655
|
-
//#endregion
|
|
1656
|
-
//#region src/factories/reply.factory.d.mts
|
|
1657
|
-
declare class ReplyFactory {
|
|
1658
|
-
private readonly environment;
|
|
1659
|
-
create(ctx: FactoryContext): Promise<any>;
|
|
1660
|
-
}
|
|
1661
|
-
//#endregion
|
|
1662
|
-
//#region src/factories/stream-adapter.factory.d.mts
|
|
1663
|
-
declare class StreamAdapterFactory {
|
|
1664
|
-
private readonly environment;
|
|
1665
|
-
create(ctx: FactoryContext): Promise<any>;
|
|
1666
|
-
}
|
|
1667
|
-
//#endregion
|
|
1668
|
-
//#region src/factories/xml-stream-adapter.factory.d.mts
|
|
1669
|
-
declare class XmlStreamAdapterFactory {
|
|
1670
|
-
private readonly environment;
|
|
1671
|
-
create(ctx: FactoryContext): Promise<any>;
|
|
1672
|
-
}
|
|
1673
|
-
//#endregion
|
|
1674
|
-
//#region src/navios.environment.d.mts
|
|
1675
|
-
interface NaviosEnvironmentOptions {
|
|
1676
|
-
httpTokens?: Map<InjectionToken<any, undefined>, AnyInjectableType>;
|
|
1677
|
-
}
|
|
1678
|
-
//#endregion
|
|
1679
|
-
//#region src/navios.application.d.mts
|
|
1680
|
-
/**
|
|
1681
|
-
* Options for configuring the Navios application context.
|
|
1682
|
-
* These options control dependency injection and logging behavior.
|
|
1683
|
-
*/
|
|
1684
|
-
interface NaviosApplicationContextOptions {
|
|
1685
|
-
/**
|
|
1686
|
-
* Specifies the logger to use. Pass `false` to turn off logging.
|
|
1687
|
-
*
|
|
1688
|
-
* - `LoggerService` instance: Use a custom logger implementation
|
|
1689
|
-
* - `LogLevel[]`: Enable specific log levels (e.g., ['error', 'warn', 'log'])
|
|
1690
|
-
* - `false`: Disable logging completely
|
|
1691
|
-
*/
|
|
1692
|
-
logger?: LoggerService | LogLevel[] | false;
|
|
1693
|
-
/**
|
|
1694
|
-
* Specifies a custom container to use. Useful for testing.
|
|
1695
|
-
* If not provided, a new Container will be created.
|
|
1696
|
-
*/
|
|
1697
|
-
container?: Container;
|
|
1698
|
-
}
|
|
1699
|
-
/**
|
|
1700
|
-
* Complete options for creating a Navios application.
|
|
1701
|
-
* Extends NaviosApplicationContextOptions with adapter configuration.
|
|
1809
|
+
* Complete options for creating a Navios application.
|
|
1810
|
+
* Extends NaviosApplicationContextOptions with adapter configuration.
|
|
1702
1811
|
*/
|
|
1703
1812
|
interface NaviosApplicationOptions extends NaviosApplicationContextOptions {
|
|
1704
1813
|
/**
|
|
@@ -1713,6 +1822,18 @@ interface NaviosApplicationOptions extends NaviosApplicationContextOptions {
|
|
|
1713
1822
|
* ```
|
|
1714
1823
|
*/
|
|
1715
1824
|
adapter: NaviosEnvironmentOptions | NaviosEnvironmentOptions[];
|
|
1825
|
+
/**
|
|
1826
|
+
* Whether to validate response schemas.
|
|
1827
|
+
* When `false`, response schema validation is skipped for better performance.
|
|
1828
|
+
* @default true
|
|
1829
|
+
*/
|
|
1830
|
+
validateResponses?: boolean;
|
|
1831
|
+
/**
|
|
1832
|
+
* Whether to enable request ID propagation via AsyncLocalStorage.
|
|
1833
|
+
* When `true`, request IDs are available via `getRequestId()` throughout the request.
|
|
1834
|
+
* @default false
|
|
1835
|
+
*/
|
|
1836
|
+
enableRequestId?: boolean;
|
|
1716
1837
|
}
|
|
1717
1838
|
/**
|
|
1718
1839
|
* Main application class for Navios.
|
|
@@ -1740,6 +1861,7 @@ declare class NaviosApplication {
|
|
|
1740
1861
|
protected container: Container;
|
|
1741
1862
|
private appModule;
|
|
1742
1863
|
private options;
|
|
1864
|
+
private plugins;
|
|
1743
1865
|
/**
|
|
1744
1866
|
* Indicates whether the application has been initialized.
|
|
1745
1867
|
* Set to `true` after `init()` completes successfully.
|
|
@@ -1760,6 +1882,25 @@ declare class NaviosApplication {
|
|
|
1760
1882
|
* @returns The Container instance
|
|
1761
1883
|
*/
|
|
1762
1884
|
getContainer(): Container;
|
|
1885
|
+
/**
|
|
1886
|
+
* Registers a plugin to be initialized after modules are loaded.
|
|
1887
|
+
*
|
|
1888
|
+
* Plugins are initialized in the order they are registered,
|
|
1889
|
+
* after all modules are loaded but before the server starts listening.
|
|
1890
|
+
*
|
|
1891
|
+
* @param definition - Plugin definition with options
|
|
1892
|
+
* @returns this for method chaining
|
|
1893
|
+
*
|
|
1894
|
+
* @example
|
|
1895
|
+
* ```typescript
|
|
1896
|
+
* import { defineOpenApiPlugin } from '@navios/openapi-fastify'
|
|
1897
|
+
*
|
|
1898
|
+
* app.usePlugin(defineOpenApiPlugin({
|
|
1899
|
+
* info: { title: 'My API', version: '1.0.0' },
|
|
1900
|
+
* }))
|
|
1901
|
+
* ```
|
|
1902
|
+
*/
|
|
1903
|
+
usePlugin<TOptions>(definition: PluginDefinition<TOptions>): this;
|
|
1763
1904
|
/**
|
|
1764
1905
|
* Initializes the application.
|
|
1765
1906
|
*
|
|
@@ -1767,6 +1908,7 @@ declare class NaviosApplication {
|
|
|
1767
1908
|
* - Loads all modules and their dependencies
|
|
1768
1909
|
* - Sets up the HTTP server if an adapter is configured
|
|
1769
1910
|
* - Calls onModuleInit hooks on all modules
|
|
1911
|
+
* - Initializes registered plugins
|
|
1770
1912
|
* - Marks the application as initialized
|
|
1771
1913
|
*
|
|
1772
1914
|
* Must be called before `listen()`.
|
|
@@ -1784,6 +1926,7 @@ declare class NaviosApplication {
|
|
|
1784
1926
|
*/
|
|
1785
1927
|
init(): Promise<void>;
|
|
1786
1928
|
private initModules;
|
|
1929
|
+
private initPlugins;
|
|
1787
1930
|
/**
|
|
1788
1931
|
* Enables CORS (Cross-Origin Resource Sharing) for the application.
|
|
1789
1932
|
*
|
|
@@ -1882,6 +2025,237 @@ declare class NaviosApplication {
|
|
|
1882
2025
|
close(): Promise<void>;
|
|
1883
2026
|
}
|
|
1884
2027
|
//#endregion
|
|
2028
|
+
//#region src/tokens/navios-options.token.d.mts
|
|
2029
|
+
declare const NaviosOptionsToken: InjectionToken<NaviosApplicationOptions, undefined, false>;
|
|
2030
|
+
//#endregion
|
|
2031
|
+
//#region src/tokens/reply.token.d.mts
|
|
2032
|
+
declare const Reply: InjectionToken<any, undefined, false>;
|
|
2033
|
+
//#endregion
|
|
2034
|
+
//#region src/tokens/request.token.d.mts
|
|
2035
|
+
declare const Request: InjectionToken<any, undefined, false>;
|
|
2036
|
+
//#endregion
|
|
2037
|
+
//#region src/tokens/stream-adapter.token.d.mts
|
|
2038
|
+
declare const StreamAdapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface, undefined, false>;
|
|
2039
|
+
//#endregion
|
|
2040
|
+
//#region src/tokens/xml-stream-adapter.token.d.mts
|
|
2041
|
+
declare const XmlStreamAdapterToken: InjectionToken<AbstractHttpHandlerAdapterInterface, undefined, false>;
|
|
2042
|
+
//#endregion
|
|
2043
|
+
//#region src/attribute.factory.d.mts
|
|
2044
|
+
/**
|
|
2045
|
+
* Type for a class attribute decorator without a value.
|
|
2046
|
+
*
|
|
2047
|
+
* Attributes are custom metadata decorators that can be applied to modules,
|
|
2048
|
+
* controllers, and endpoints.
|
|
2049
|
+
*/
|
|
2050
|
+
type ClassAttribute = (() => <T>(target: T, context: ClassDecoratorContext | ClassMethodDecoratorContext) => T) & {
|
|
2051
|
+
token: symbol;
|
|
2052
|
+
};
|
|
2053
|
+
/**
|
|
2054
|
+
* Type for a class attribute decorator with a validated value.
|
|
2055
|
+
*
|
|
2056
|
+
* @typeParam T - The Zod schema type for validation
|
|
2057
|
+
*/
|
|
2058
|
+
type ClassSchemaAttribute<T extends ZodType> = ((value: z$1.input<T>) => <T>(target: T, context: ClassDecoratorContext | ClassMethodDecoratorContext) => T) & {
|
|
2059
|
+
token: symbol;
|
|
2060
|
+
schema: ZodType;
|
|
2061
|
+
};
|
|
2062
|
+
/**
|
|
2063
|
+
* Factory for creating custom attribute decorators.
|
|
2064
|
+
*
|
|
2065
|
+
* Attributes allow you to add custom metadata to modules, controllers, and endpoints.
|
|
2066
|
+
* This is useful for cross-cutting concerns like rate limiting, caching, API versioning, etc.
|
|
2067
|
+
*
|
|
2068
|
+
* @example
|
|
2069
|
+
* ```typescript
|
|
2070
|
+
* // Create a simple boolean attribute
|
|
2071
|
+
* const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
|
|
2072
|
+
*
|
|
2073
|
+
* // Use it as a decorator
|
|
2074
|
+
* @Controller()
|
|
2075
|
+
* @Public()
|
|
2076
|
+
* export class PublicController { }
|
|
2077
|
+
*
|
|
2078
|
+
* // Check if attribute exists
|
|
2079
|
+
* if (AttributeFactory.has(Public, controllerMetadata)) {
|
|
2080
|
+
* // Skip authentication
|
|
2081
|
+
* }
|
|
2082
|
+
* ```
|
|
2083
|
+
*
|
|
2084
|
+
* @example
|
|
2085
|
+
* ```typescript
|
|
2086
|
+
* // Create an attribute with a validated value
|
|
2087
|
+
* const RateLimit = AttributeFactory.createAttribute(
|
|
2088
|
+
* Symbol.for('RateLimit'),
|
|
2089
|
+
* z.object({ requests: z.number(), window: z.number() })
|
|
2090
|
+
* )
|
|
2091
|
+
*
|
|
2092
|
+
* // Use it with a value
|
|
2093
|
+
* @Endpoint(apiEndpoint)
|
|
2094
|
+
* @RateLimit({ requests: 100, window: 60000 })
|
|
2095
|
+
* async handler() { }
|
|
2096
|
+
*
|
|
2097
|
+
* // Get the value
|
|
2098
|
+
* const limit = AttributeFactory.get(RateLimit, endpointMetadata)
|
|
2099
|
+
* // limit is typed as { requests: number, window: number } | null
|
|
2100
|
+
* ```
|
|
2101
|
+
*/
|
|
2102
|
+
declare class AttributeFactory {
|
|
2103
|
+
/**
|
|
2104
|
+
* Creates a simple attribute decorator without a value.
|
|
2105
|
+
*
|
|
2106
|
+
* @param token - A unique symbol to identify this attribute
|
|
2107
|
+
* @returns A decorator function that can be applied to classes or methods
|
|
2108
|
+
*
|
|
2109
|
+
* @example
|
|
2110
|
+
* ```typescript
|
|
2111
|
+
* const Public = AttributeFactory.createAttribute(Symbol.for('Public'))
|
|
2112
|
+
*
|
|
2113
|
+
* @Public()
|
|
2114
|
+
* @Controller()
|
|
2115
|
+
* export class PublicController { }
|
|
2116
|
+
* ```
|
|
2117
|
+
*/
|
|
2118
|
+
static createAttribute(token: symbol): ClassAttribute;
|
|
2119
|
+
/**
|
|
2120
|
+
* Creates an attribute decorator with a validated value.
|
|
2121
|
+
*
|
|
2122
|
+
* @param token - A unique symbol to identify this attribute
|
|
2123
|
+
* @param schema - A Zod schema to validate the attribute value
|
|
2124
|
+
* @returns A decorator function that accepts a value and can be applied to classes or methods
|
|
2125
|
+
*
|
|
2126
|
+
* @example
|
|
2127
|
+
* ```typescript
|
|
2128
|
+
* const RateLimit = AttributeFactory.createAttribute(
|
|
2129
|
+
* Symbol.for('RateLimit'),
|
|
2130
|
+
* z.object({ requests: z.number(), window: z.number() })
|
|
2131
|
+
* )
|
|
2132
|
+
*
|
|
2133
|
+
* @RateLimit({ requests: 100, window: 60000 })
|
|
2134
|
+
* @Endpoint(apiEndpoint)
|
|
2135
|
+
* async handler() { }
|
|
2136
|
+
* ```
|
|
2137
|
+
*/
|
|
2138
|
+
static createAttribute<T extends ZodType>(token: symbol, schema: T): ClassSchemaAttribute<T>;
|
|
2139
|
+
/**
|
|
2140
|
+
* Gets the value of an attribute from metadata.
|
|
2141
|
+
*
|
|
2142
|
+
* Returns `null` if the attribute is not present.
|
|
2143
|
+
* For simple attributes (without values), returns `true` if present.
|
|
2144
|
+
*
|
|
2145
|
+
* @param attribute - The attribute decorator
|
|
2146
|
+
* @param target - The metadata object (module, controller, or handler)
|
|
2147
|
+
* @returns The attribute value, `true` for simple attributes, or `null` if not found
|
|
2148
|
+
*
|
|
2149
|
+
* @example
|
|
2150
|
+
* ```typescript
|
|
2151
|
+
* const isPublic = AttributeFactory.get(Public, controllerMetadata)
|
|
2152
|
+
* // isPublic is true | null
|
|
2153
|
+
*
|
|
2154
|
+
* const rateLimit = AttributeFactory.get(RateLimit, endpointMetadata)
|
|
2155
|
+
* // rateLimit is { requests: number, window: number } | null
|
|
2156
|
+
* ```
|
|
2157
|
+
*/
|
|
2158
|
+
static get(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): true | null;
|
|
2159
|
+
static get<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): z$1.output<T> | null;
|
|
2160
|
+
/**
|
|
2161
|
+
* Gets all values of an attribute from metadata (useful when an attribute can appear multiple times).
|
|
2162
|
+
*
|
|
2163
|
+
* Returns `null` if the attribute is not present.
|
|
2164
|
+
*
|
|
2165
|
+
* @param attribute - The attribute decorator
|
|
2166
|
+
* @param target - The metadata object (module, controller, or handler)
|
|
2167
|
+
* @returns An array of attribute values, or `null` if not found
|
|
2168
|
+
*
|
|
2169
|
+
* @example
|
|
2170
|
+
* ```typescript
|
|
2171
|
+
* const tags = AttributeFactory.getAll(Tag, endpointMetadata)
|
|
2172
|
+
* // tags is string[] | null
|
|
2173
|
+
* ```
|
|
2174
|
+
*/
|
|
2175
|
+
static getAll(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<true> | null;
|
|
2176
|
+
static getAll<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): Array<z$1.output<T>> | null;
|
|
2177
|
+
/**
|
|
2178
|
+
* Gets the last value of an attribute from an array of metadata objects.
|
|
2179
|
+
*
|
|
2180
|
+
* Searches from the end of the array backwards, useful for finding the most
|
|
2181
|
+
* specific attribute value (e.g., endpoint-level overrides module-level).
|
|
2182
|
+
*
|
|
2183
|
+
* @param attribute - The attribute decorator
|
|
2184
|
+
* @param target - An array of metadata objects (typically [module, controller, handler])
|
|
2185
|
+
* @returns The last attribute value found, or `null` if not found
|
|
2186
|
+
*
|
|
2187
|
+
* @example
|
|
2188
|
+
* ```typescript
|
|
2189
|
+
* // Check attribute hierarchy: endpoint -> controller -> module
|
|
2190
|
+
* const rateLimit = AttributeFactory.getLast(RateLimit, [
|
|
2191
|
+
* moduleMetadata,
|
|
2192
|
+
* controllerMetadata,
|
|
2193
|
+
* endpointMetadata
|
|
2194
|
+
* ])
|
|
2195
|
+
* ```
|
|
2196
|
+
*/
|
|
2197
|
+
static getLast(attribute: ClassAttribute, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): true | null;
|
|
2198
|
+
static getLast<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: (ModuleMetadata | ControllerMetadata | HandlerMetadata<any>)[]): z$1.output<T> | null;
|
|
2199
|
+
/**
|
|
2200
|
+
* Checks if an attribute is present on the metadata object.
|
|
2201
|
+
*
|
|
2202
|
+
* @param attribute - The attribute decorator
|
|
2203
|
+
* @param target - The metadata object (module, controller, or handler)
|
|
2204
|
+
* @returns `true` if the attribute is present, `false` otherwise
|
|
2205
|
+
*
|
|
2206
|
+
* @example
|
|
2207
|
+
* ```typescript
|
|
2208
|
+
* if (AttributeFactory.has(Public, controllerMetadata)) {
|
|
2209
|
+
* // Skip authentication
|
|
2210
|
+
* }
|
|
2211
|
+
* ```
|
|
2212
|
+
*/
|
|
2213
|
+
static has(attribute: ClassAttribute, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
|
|
2214
|
+
static has<T extends ZodType>(attribute: ClassSchemaAttribute<T>, target: ModuleMetadata | ControllerMetadata | HandlerMetadata<any>): boolean;
|
|
2215
|
+
}
|
|
2216
|
+
//#endregion
|
|
2217
|
+
//#region src/factories/endpoint-adapter.factory.d.mts
|
|
2218
|
+
declare class EndpointAdapterFactory {
|
|
2219
|
+
private readonly environment;
|
|
2220
|
+
create(ctx: FactoryContext): Promise<any>;
|
|
2221
|
+
}
|
|
2222
|
+
//#endregion
|
|
2223
|
+
//#region src/factories/http-adapter.factory.d.mts
|
|
2224
|
+
declare class HttpAdapterFactory {
|
|
2225
|
+
private readonly environment;
|
|
2226
|
+
create(ctx: FactoryContext): Promise<any>;
|
|
2227
|
+
}
|
|
2228
|
+
//#endregion
|
|
2229
|
+
//#region src/factories/multipart-adapter.factory.d.mts
|
|
2230
|
+
declare class MultipartAdapterFactory {
|
|
2231
|
+
private readonly environment;
|
|
2232
|
+
create(ctx: FactoryContext): Promise<any>;
|
|
2233
|
+
}
|
|
2234
|
+
//#endregion
|
|
2235
|
+
//#region src/factories/request.factory.d.mts
|
|
2236
|
+
declare class RequestFactory {
|
|
2237
|
+
private readonly environment;
|
|
2238
|
+
create(ctx: FactoryContext): Promise<any>;
|
|
2239
|
+
}
|
|
2240
|
+
//#endregion
|
|
2241
|
+
//#region src/factories/reply.factory.d.mts
|
|
2242
|
+
declare class ReplyFactory {
|
|
2243
|
+
private readonly environment;
|
|
2244
|
+
create(ctx: FactoryContext): Promise<any>;
|
|
2245
|
+
}
|
|
2246
|
+
//#endregion
|
|
2247
|
+
//#region src/factories/stream-adapter.factory.d.mts
|
|
2248
|
+
declare class StreamAdapterFactory {
|
|
2249
|
+
private readonly environment;
|
|
2250
|
+
create(ctx: FactoryContext): Promise<any>;
|
|
2251
|
+
}
|
|
2252
|
+
//#endregion
|
|
2253
|
+
//#region src/factories/xml-stream-adapter.factory.d.mts
|
|
2254
|
+
declare class XmlStreamAdapterFactory {
|
|
2255
|
+
private readonly environment;
|
|
2256
|
+
create(ctx: FactoryContext): Promise<any>;
|
|
2257
|
+
}
|
|
2258
|
+
//#endregion
|
|
1885
2259
|
//#region src/navios.factory.d.mts
|
|
1886
2260
|
/**
|
|
1887
2261
|
* Factory class for creating and configuring Navios applications.
|
|
@@ -1947,5 +2321,5 @@ declare class NaviosFactory {
|
|
|
1947
2321
|
private static registerLoggerConfiguration;
|
|
1948
2322
|
}
|
|
1949
2323
|
//#endregion
|
|
1950
|
-
export {
|
|
1951
|
-
//# sourceMappingURL=index-
|
|
2324
|
+
export { PluginContext as $, EndpointMetadataKey as $t, ControllerResolution as A, isString as At, BadRequestException as B, clc as Bt, ExecutionContextInjectionToken as C, isConstructor as Ct, runWithRequestId as D, isNumber as Dt, getRequestId as E, isNil as Et, ConflictException as F, isLogLevelEnabled as Ft, Multipart as G, extractModuleMetadata as Gt, UseGuards as H, AbstractExecutionContext as Ht, UnauthorizedException as I, isLogLevel as It, Module as J, ControllerMetadata as Jt, MultipartParams as K, getModuleMetadata as Kt, NotFoundException as L, filterLogLevels as Lt, InstanceResolution as M, isUndefined as Mt, InstanceResolverService as N, normalizePath as Nt, setRequestIdEnabled as O, isObject as Ot, MultiInstanceResolution as P, stripEndSlash as Pt, NaviosPlugin as Q, hasControllerMetadata as Qt, InternalServerErrorException as R, LOG_LEVELS as Rt, ExecutionContext as S, addLeadingSlash as St, generateRequestId as T, isFunction as Tt, Stream as U, ModuleMetadata as Ut, HttpException as V, yellow as Vt, StreamParams as W, ModuleMetadataKey as Wt, HttpCode as X, extractControllerMetadata as Xt, ModuleOptions as Y, ControllerMetadataKey as Yt, Header as Z, getControllerMetadata as Zt, NaviosApplication as _, PathImpl as _n, loggerOptionsSchema as _t, RequestFactory as a, EndpointResult as an, OmitIndexSignature as at, MultipartAdapterToken as b, envInt as bn, ConsoleLoggerOptions as bt, EndpointAdapterFactory as c, ConfigProviderOptions as cn, DynamicHandler as ct, ClassSchemaAttribute as d, ConfigService as dn, AbstractHttpAdapterInterface as dt, HandlerMetadata as en, PluginDefinition as et, XmlStreamAdapterToken as f, ConfigServiceOptions as fn, AbstractHttpListenOptions as ft, NaviosOptionsToken as g, Path as gn, LoggerOutput as gt, Reply as h, ConfigServiceInterface as hn, LoggerOptions as ht, ReplyFactory as i, EndpointParams as in, HttpHeader as it, ControllerResolverService as j, isSymbol as jt, GuardRunnerService as k, isPlainObject as kt, AttributeFactory as l, EnvConfigProvider as ln, HandlerResult as lt, Request as m, ConfigServiceToken as mn, Logger as mt, XmlStreamAdapterFactory as n, getEndpointMetadata as nn, ModuleLoaderService as nt, MultipartAdapterFactory as o, Controller as on, CanActivate as ot, StreamAdapterToken as p, ConfigServiceOptionsSchema as pn, AbstractHttpCorsOptions as pt, MultipartResult as q, hasModuleMetadata as qt, StreamAdapterFactory as r, Endpoint as rn, NaviosModule as rt, HttpAdapterFactory as s, ControllerOptions as sn, AbstractHttpHandlerAdapterInterface as st, NaviosFactory as t, getAllEndpointMetadata as tn, ModuleExtension as tt, ClassAttribute as u, provideConfig as un, StaticHandler as ut, NaviosApplicationContextOptions as v, PathImpl2 as vn, LoggerInstance as vt, EndpointAdapterToken as w, isEmpty as wt, HttpAdapterToken as x, envString as xn, LoggerService as xt, NaviosApplicationOptions as y, PathValue as yn, ConsoleLogger as yt, ForbiddenException as z, LogLevel as zt };
|
|
2325
|
+
//# sourceMappingURL=index-BoP0cWT6.d.mts.map
|