@navios/core 1.1.0 → 2.0.0-alpha.1
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 +85 -13
- package/README.md +69 -220
- package/lib/async-context-BAdt7bno.d.mts +239 -0
- package/lib/async-context-BAdt7bno.d.mts.map +1 -0
- package/lib/async-context-RsWmy2Hi.d.cts +239 -0
- package/lib/async-context-RsWmy2Hi.d.cts.map +1 -0
- package/lib/attribute-factory-BW1kgBqf.d.mts +70 -0
- package/lib/attribute-factory-BW1kgBqf.d.mts.map +1 -0
- package/lib/attribute-factory-DqN4x5XM.d.cts +70 -0
- package/lib/attribute-factory-DqN4x5XM.d.cts.map +1 -0
- package/lib/attribute-value-BNiJjxl1.mjs +225 -0
- package/lib/attribute-value-BNiJjxl1.mjs.map +1 -0
- package/lib/attribute-value-Cux5HhOL.cjs +314 -0
- package/lib/attribute-value-Cux5HhOL.cjs.map +1 -0
- package/lib/basic-execution-context-5uq2DvEA.cjs +318 -0
- package/lib/basic-execution-context-5uq2DvEA.cjs.map +1 -0
- package/lib/basic-execution-context-u1VktGoM.mjs +277 -0
- package/lib/basic-execution-context-u1VktGoM.mjs.map +1 -0
- package/lib/execution-context-BVSmLkYp.d.cts +71 -0
- package/lib/execution-context-BVSmLkYp.d.cts.map +1 -0
- package/lib/execution-context-C5F9rojO.d.mts +71 -0
- package/lib/execution-context-C5F9rojO.d.mts.map +1 -0
- package/lib/execution-context-token--cKS4cJv.cjs +270 -0
- package/lib/execution-context-token--cKS4cJv.cjs.map +1 -0
- package/lib/execution-context-token-Cb3M3Ao0.mjs +223 -0
- package/lib/execution-context-token-Cb3M3Ao0.mjs.map +1 -0
- package/lib/index.cjs +1672 -4426
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +842 -3
- package/lib/index.d.cts.map +1 -0
- package/lib/index.d.mts +842 -3
- package/lib/index.d.mts.map +1 -0
- package/lib/index.mjs +1559 -4221
- 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-Bz83ZnJ5.cjs +173 -0
- package/lib/module-Bz83ZnJ5.cjs.map +1 -0
- package/lib/module-options-CSqQUSTm.d.mts +51 -0
- package/lib/module-options-CSqQUSTm.d.mts.map +1 -0
- package/lib/module-options-DSRBri4J.d.cts +51 -0
- package/lib/module-options-DSRBri4J.d.cts.map +1 -0
- package/lib/module-zPXwR2qp.mjs +138 -0
- package/lib/module-zPXwR2qp.mjs.map +1 -0
- package/lib/settled-within-B6gpu2XW.cjs +32 -0
- package/lib/settled-within-B6gpu2XW.cjs.map +1 -0
- package/lib/settled-within-Bc2pj8WB.mjs +21 -0
- package/lib/settled-within-Bc2pj8WB.mjs.map +1 -0
- package/lib/testing/index.cjs +74 -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 +72 -408
- package/lib/testing/index.mjs.map +1 -1
- package/lib/transport.cjs +36 -0
- package/lib/transport.d.cts +254 -0
- package/lib/transport.d.cts.map +1 -0
- package/lib/transport.d.mts +254 -0
- package/lib/transport.d.mts.map +1 -0
- package/lib/transport.mjs +6 -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-3LcTrbxz.d.mts +0 -3804
- package/lib/index-3LcTrbxz.d.mts.map +0 -1
- package/lib/index-B14SekVb.d.cts +0 -3804
- package/lib/index-B14SekVb.d.cts.map +0 -1
- package/lib/navios.factory-CUrO_p6K.cjs +0 -4538
- package/lib/navios.factory-CUrO_p6K.cjs.map +0 -1
- package/lib/navios.factory-DjUOOVVL.mjs +0 -4151
- package/lib/navios.factory-DjUOOVVL.mjs.map +0 -1
- package/lib/tokens-BEuBMGGX.cjs +0 -193
- package/lib/tokens-BEuBMGGX.cjs.map +0 -1
- package/lib/tokens-COyNGV1I.mjs +0 -97
- package/lib/tokens-COyNGV1I.mjs.map +0 -1
- package/lib/use-guards.decorator-DLmRl2CV.mjs +0 -336
- package/lib/use-guards.decorator-DLmRl2CV.mjs.map +0 -1
- package/lib/use-guards.decorator-DhumFTk3.cjs +0 -444
- package/lib/use-guards.decorator-DhumFTk3.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 -14
- package/src/interfaces/navios-module.mts +0 -28
- package/src/interfaces/plugin-context.mts +0 -104
- package/src/interfaces/plugin-stage.mts +0 -62
- package/src/interfaces/plugin.interface.mts +0 -119
- package/src/interfaces/staged-plugin.interface.mts +0 -209
- 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 -79
- package/src/metadata/handler.metadata.mts +0 -80
- package/src/metadata/index.mts +0 -4
- package/src/metadata/module.metadata.mts +0 -116
- package/src/metadata/navios-managed.metadata.mts +0 -42
- package/src/navios.application.mts +0 -678
- 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 -255
- 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/define-plugin.mts +0 -251
- package/src/utils/index.mts +0 -2
- 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
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the author of a transport needs and application code does not: the
|
|
3
|
+
* transport contract, the module graph, handler metadata, and the pieces of
|
|
4
|
+
* an execution context.
|
|
5
|
+
*
|
|
6
|
+
* Application code imports from `@navios/core`.
|
|
7
|
+
*/
|
|
8
|
+
import { a as ContextValue, i as ContextKey, n as ExecutionContext, r as HandlerInfo } from "./execution-context-BVSmLkYp.cjs";
|
|
9
|
+
import { a as TransportDefinition, d as buildModuleGraph, f as moduleClasses, h as needsScope, l as defineTransport, p as ContextHost, r as runInContext, s as TransportHost, u as ModuleNode } from "./async-context-RsWmy2Hi.cjs";
|
|
10
|
+
import { ClassType, Container, Provider, ScopedContainer } from "@navios/di";
|
|
11
|
+
import { constructedInstances, disposeScope } from "@navios/di/internal";
|
|
12
|
+
import { a as Interceptor, i as AttributeValue, n as Guard } from "./module-options-DSRBri4J.cjs";
|
|
13
|
+
/** The longest delay a timer takes; a longer one fires at once. */
|
|
14
|
+
export declare const MAX_DELAY_MS: number;
|
|
15
|
+
/**
|
|
16
|
+
* Whether `work` settles within `ms`, or within `MAX_DELAY_MS` when `ms` is
|
|
17
|
+
* longer. Rejects when it rejects in time; a later rejection is dropped.
|
|
18
|
+
*/
|
|
19
|
+
export declare function settledWithin(work: PromiseLike<unknown>, ms: number): Promise<boolean>;
|
|
20
|
+
/** The `metadata` of a decorator context. */
|
|
21
|
+
type DecoratorMetadata = Record<PropertyKey, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* The value stored in decorator metadata under `key`, created for this class
|
|
24
|
+
* from what a parent class has, if anything. The metadata object of a class
|
|
25
|
+
* inherits from that of its parent, so writing to an inherited value would
|
|
26
|
+
* change the parent.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ownMetadata<T>(metadata: DecoratorMetadata, key: symbol, create: (inherited?: T) => T): T;
|
|
29
|
+
/** The metadata of a decorator context, which has to have one. */
|
|
30
|
+
export declare function requireMetadata(context: {
|
|
31
|
+
metadata?: DecoratorMetadata;
|
|
32
|
+
}): DecoratorMetadata;
|
|
33
|
+
interface ModuleMetadata {
|
|
34
|
+
imports: ClassType[];
|
|
35
|
+
guards: ClassType[];
|
|
36
|
+
interceptors: ClassType[];
|
|
37
|
+
providers: Provider[];
|
|
38
|
+
attributes: Map<symbol, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Every option the module system itself does not use, by option name, as
|
|
41
|
+
* written. A transport reads its own from here.
|
|
42
|
+
*/
|
|
43
|
+
entries: Map<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
export declare function getModuleMetadata(target: ClassType): ModuleMetadata;
|
|
46
|
+
/**
|
|
47
|
+
* What decorators and `handler()` options can attach to a handler.
|
|
48
|
+
*/
|
|
49
|
+
interface HandlerExtras {
|
|
50
|
+
guards: ClassType[];
|
|
51
|
+
interceptors: ClassType[];
|
|
52
|
+
attributes: Map<symbol, unknown>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A class member that is, or may become, a handler: what decorators attached
|
|
56
|
+
* to it.
|
|
57
|
+
*/
|
|
58
|
+
interface MethodHandlerMetadata extends HandlerExtras {
|
|
59
|
+
name: string;
|
|
60
|
+
/**
|
|
61
|
+
* What makes the member a handler of a transport, under that transport's
|
|
62
|
+
* own symbol.
|
|
63
|
+
*/
|
|
64
|
+
entries: Map<symbol, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* What decorators attached to a member, inherited ones included, to read and to
|
|
68
|
+
* add to.
|
|
69
|
+
*/
|
|
70
|
+
export declare function memberMetadata(context: {
|
|
71
|
+
metadata?: DecoratorMetadata;
|
|
72
|
+
}, name: string): MethodHandlerMetadata;
|
|
73
|
+
/** What a transport's decorator for handler classes may take. */
|
|
74
|
+
interface HandlerClassOptions {
|
|
75
|
+
guards?: Iterable<ClassType>;
|
|
76
|
+
interceptors?: Iterable<ClassType>;
|
|
77
|
+
attributes?: AttributeValue[];
|
|
78
|
+
}
|
|
79
|
+
/** A class that owns handlers: what applies to all of them, and its members. */
|
|
80
|
+
interface HandlerClassMetadata extends HandlerExtras {
|
|
81
|
+
/** The members decorators were applied to, by name. */
|
|
82
|
+
members: Map<string, MethodHandlerMetadata>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* What decorators attached to a class of handlers and to its members, together
|
|
86
|
+
* with the options of the class decorator that asks. The lists are live:
|
|
87
|
+
* `@UseGuards` and the like placed above that decorator run after it and are
|
|
88
|
+
* still seen.
|
|
89
|
+
*/
|
|
90
|
+
export declare function describeHandlerClass(context: {
|
|
91
|
+
metadata?: DecoratorMetadata;
|
|
92
|
+
}, options?: HandlerClassOptions): HandlerClassMetadata;
|
|
93
|
+
/** What a class decorator stores on the class it decorates. */
|
|
94
|
+
interface ClassMetadata<T> {
|
|
95
|
+
/** Stores `value` on `target`, where it is not enumerable and can be replaced. */
|
|
96
|
+
define(target: ClassType, value: T): void;
|
|
97
|
+
/**
|
|
98
|
+
* What is stored on `target` itself. A subclass does not inherit it: it is
|
|
99
|
+
* not what the decorator makes of a class unless it is decorated itself.
|
|
100
|
+
* Throws when there is none.
|
|
101
|
+
*/
|
|
102
|
+
get(target: ClassType): T;
|
|
103
|
+
/** Whether `get` would find something. */
|
|
104
|
+
has(target: ClassType): boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Metadata that a class decorator stores on classes under `key`. `what` and
|
|
108
|
+
* `decorator` name it when a class has none: `Users is not a controller. Make
|
|
109
|
+
* sure it is decorated with @Controller.`
|
|
110
|
+
*
|
|
111
|
+
* ```ts
|
|
112
|
+
* const queueHandlers = classMetadata<HandlerClassMetadata>(
|
|
113
|
+
* Symbol.for('my-transport.handlers'),
|
|
114
|
+
* 'a queue handler',
|
|
115
|
+
* 'QueueHandler',
|
|
116
|
+
* )
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function classMetadata<T>(key: symbol, what: string, decorator: string): ClassMetadata<T>;
|
|
120
|
+
interface Extras {
|
|
121
|
+
readonly guards: readonly ClassType[];
|
|
122
|
+
readonly interceptors: readonly ClassType[];
|
|
123
|
+
}
|
|
124
|
+
interface OwnExtras extends Extras {
|
|
125
|
+
readonly attributes: ReadonlyMap<symbol, unknown>;
|
|
126
|
+
}
|
|
127
|
+
interface HandlerChainInput {
|
|
128
|
+
/**
|
|
129
|
+
* Interceptors around every handler of the application or of the transport,
|
|
130
|
+
* outermost first.
|
|
131
|
+
*/
|
|
132
|
+
application: readonly ClassType[];
|
|
133
|
+
/** The module the handler belongs to, with what it inherits. */
|
|
134
|
+
node: Extras & Pick<ModuleNode, 'module' | 'attributes' | 'disputed'>;
|
|
135
|
+
/** The class that owns the handler. */
|
|
136
|
+
controller: ClassType;
|
|
137
|
+
/** What applies to every handler of `controller`. */
|
|
138
|
+
owner: OwnExtras;
|
|
139
|
+
/** The name of the handler in its class. */
|
|
140
|
+
handlerName: string;
|
|
141
|
+
/** The handler itself. */
|
|
142
|
+
member: OwnExtras;
|
|
143
|
+
}
|
|
144
|
+
interface HandlerChain {
|
|
145
|
+
/** What the contexts of the handler tell about it. */
|
|
146
|
+
info: HandlerInfo;
|
|
147
|
+
/** Interceptors around the guards: those of the application. */
|
|
148
|
+
outer: ClassType[];
|
|
149
|
+
/** Interceptors inside the guards: those of the module, the class and the handler. */
|
|
150
|
+
inner: ClassType[];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The guards and interceptors that apply to one handler, in the order they
|
|
154
|
+
* run, and what its contexts tell about it: the interceptors of the
|
|
155
|
+
* application, then the guards from the module chain, the owning class and
|
|
156
|
+
* the handler, then the interceptors of the same three. A class that appears
|
|
157
|
+
* twice is kept where it first appears. `info.guards` are the guards and
|
|
158
|
+
* `info.interceptors` the interceptors, `outer` and then `inner`.
|
|
159
|
+
*
|
|
160
|
+
* An interceptor of the application sees every execution, denied ones
|
|
161
|
+
* included, as tracing and logging need. One that is attached to handlers runs
|
|
162
|
+
* only for what their guards let through.
|
|
163
|
+
*
|
|
164
|
+
* Throws when the handler would inherit an attribute that the importers of its
|
|
165
|
+
* module do not agree about.
|
|
166
|
+
*
|
|
167
|
+
* Every transport uses this, so the rule is the same everywhere.
|
|
168
|
+
* `resolveChain` resolves the chain and `runChain` runs it.
|
|
169
|
+
*/
|
|
170
|
+
export declare function handlerChain(input: HandlerChainInput): HandlerChain;
|
|
171
|
+
/** A handler's chain with its instances, ready to run. */
|
|
172
|
+
interface ResolvedChain<Ctx extends ExecutionContext = ExecutionContext, Result = unknown> {
|
|
173
|
+
readonly outer: ReadonlyArray<Interceptor<Ctx, Result>>;
|
|
174
|
+
readonly guards: ReadonlyArray<{
|
|
175
|
+
readonly type: ClassType;
|
|
176
|
+
readonly guard: Guard<Ctx>;
|
|
177
|
+
}>;
|
|
178
|
+
readonly inner: ReadonlyArray<Interceptor<Ctx, Result>>;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Resolves the classes of a chain that `handlerChain` returned. A transport
|
|
182
|
+
* does this once per handler, while it is set up.
|
|
183
|
+
*/
|
|
184
|
+
export declare function resolveChain<Ctx extends ExecutionContext = ExecutionContext, Result = unknown>(container: Pick<Container, 'get'>, chain: {
|
|
185
|
+
readonly info: Pick<HandlerInfo, 'guards'>;
|
|
186
|
+
readonly outer: readonly ClassType[];
|
|
187
|
+
readonly inner: readonly ClassType[];
|
|
188
|
+
}): Promise<ResolvedChain<Ctx, Result>>;
|
|
189
|
+
/**
|
|
190
|
+
* Runs a handler with what applies to it: the outer interceptors, the guards
|
|
191
|
+
* one after another, the inner interceptors, the handler. When a guard refuses,
|
|
192
|
+
* nothing further runs and `onDenied` says what becomes of the execution: what
|
|
193
|
+
* it returns is the result, and what it throws is the failure.
|
|
194
|
+
*/
|
|
195
|
+
export declare function runChain<Ctx extends ExecutionContext, Result>(ctx: Ctx, chain: ResolvedChain<Ctx, Result>, handler: () => Result | Promise<Result>, onDenied: (guard: ClassType) => Result | Promise<Result>): Promise<Result>;
|
|
196
|
+
/**
|
|
197
|
+
* Runs a handler with what applies to it, as `runChain`, in the async context
|
|
198
|
+
* when the application keeps one, and then finishes its context, whatever the
|
|
199
|
+
* outcome. The context is finished inside the async context, so that
|
|
200
|
+
* `currentContext()` still answers in `onFinish` callbacks.
|
|
201
|
+
*/
|
|
202
|
+
export declare function executeChain<Ctx extends ExecutionContext & {
|
|
203
|
+
finish(): Promise<void>;
|
|
204
|
+
}, Result>(host: {
|
|
205
|
+
readonly asyncContext: boolean;
|
|
206
|
+
}, ctx: Ctx, chain: ResolvedChain<Ctx, Result>, handler: () => Result | Promise<Result>, onDenied: (guard: ClassType) => Result | Promise<Result>): Promise<Result>;
|
|
207
|
+
interface BasicExecutionContextInit {
|
|
208
|
+
/** The transport kind, for example `'cli'`. */
|
|
209
|
+
kind: string;
|
|
210
|
+
id: string;
|
|
211
|
+
handler: HandlerInfo;
|
|
212
|
+
host: ContextHost;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* An `ExecutionContext` for transports that need nothing beyond the neutral
|
|
216
|
+
* contract. The transport creates one per execution and calls `finish()` when
|
|
217
|
+
* the handler is done.
|
|
218
|
+
*/
|
|
219
|
+
export declare class BasicExecutionContext implements ExecutionContext {
|
|
220
|
+
readonly kind: string;
|
|
221
|
+
readonly id: string;
|
|
222
|
+
readonly handler: HandlerInfo;
|
|
223
|
+
private readonly host;
|
|
224
|
+
private ownSignal;
|
|
225
|
+
private slots;
|
|
226
|
+
private scope;
|
|
227
|
+
private finishers;
|
|
228
|
+
private finished;
|
|
229
|
+
private finishing;
|
|
230
|
+
constructor(init: BasicExecutionContextInit);
|
|
231
|
+
/**
|
|
232
|
+
* A signal that never aborts. Not shared between contexts: listeners would
|
|
233
|
+
* outlive their execution.
|
|
234
|
+
*/
|
|
235
|
+
get signal(): AbortSignal;
|
|
236
|
+
get<K extends ContextKey>(key: K): ContextValue<K>;
|
|
237
|
+
find<K extends ContextKey>(key: K): ContextValue<K> | undefined;
|
|
238
|
+
set<K extends ContextKey>(key: K, value: ContextValue<K>): void;
|
|
239
|
+
has(key: ContextKey): boolean;
|
|
240
|
+
use: ScopedContainer['getSync'];
|
|
241
|
+
resolve: ScopedContainer['get'];
|
|
242
|
+
onFinish(callback: () => void | Promise<void>): void;
|
|
243
|
+
/**
|
|
244
|
+
* Runs the `onFinish` callbacks in reverse order, those they register
|
|
245
|
+
* included, then disposes the DI scope. Runs once, however often it is
|
|
246
|
+
* called; every caller waits for that run.
|
|
247
|
+
*/
|
|
248
|
+
finish(): Promise<void>;
|
|
249
|
+
private runFinishers;
|
|
250
|
+
/** Runs a callback whose failure must not stop what follows. */
|
|
251
|
+
private runFinisher;
|
|
252
|
+
}
|
|
253
|
+
export { type BasicExecutionContextInit, type ClassMetadata, type ContextHost, type DecoratorMetadata, type HandlerChain, type HandlerChainInput, type HandlerClassMetadata, type HandlerClassOptions, type HandlerExtras, type MethodHandlerMetadata, type ModuleMetadata, type ModuleNode, type ResolvedChain, type TransportDefinition, type TransportHost, buildModuleGraph, constructedInstances, defineTransport, disposeScope, moduleClasses, needsScope, runInContext };
|
|
254
|
+
//# sourceMappingURL=transport.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.cts","names":[],"sources":["../src/transports/settled-within.mts","../src/metadata/decorator-metadata.mts","../src/modules/module-metadata.mts","../src/metadata/member-metadata.mts","../src/metadata/handler-class.mts","../src/metadata/class-store.mts","../src/metadata/handler-chain.mts","../src/metadata/run-chain.mts","../src/execution/basic-execution-context.mts"],"mappings":";;;;;;;;;;;;;qBACa;;;;;wBAMS,cAAc,MAAM,sBAAsB,aAAa;;KCNjE,oBAAoB,OAAO;;;;;;;wBAQvB,YAAY,GAC1B,UAAU,mBACV,aACA,SAAS,YAAY,MAAM,IAC1B;;wBAQa,gBAAgB;EAAW,WAAW;IAAsB;UCN3D;EACf,SAAS;EACT,QAAQ;EACR,cAAc;EACd,WAAW;EACX,YAAY;;;;;EAKZ,SAAS;;wBAyFK,kBAAkB,QAAQ,YAAY;;;;UCzGrC;EACf,QAAQ;EACR,cAAc;EACd,YAAY;;;;;;UAOG,8BAA8B;EAC7C;;;;;EAKA,SAAS;;;;;;wBAUK,eACd;EAAW,WAAW;GACtB,eACC;;UCxBc;EACf,SAAS,SAAS;EAClB,eAAe,SAAS;EACxB,aAAa;;;UAIE,6BAA6B;;EAE5C,SAAS,YAAY;;;;;;;;wBASP,qBACd;EAAW,WAAW;GACtB,UAAS,sBACR;;UChCc,cAAc;;EAE7B,OAAO,QAAQ,WAAW,OAAO;;;;;;EAMjC,IAAI,QAAQ,YAAY;;EAExB,IAAI,QAAQ;;;;;;;;;;;;;;;wBAgBE,cAAc,GAAG,aAAa,cAAc,oBAAoB,cAAc;UCxBpF;WACC,iBAAiB;WACjB,uBAAuB;;UAGxB,kBAAkB;WACjB,YAAY;;UAGN;;;;;EAKf,sBAAsB;;EAEtB,MAAM,SAAS,KAAK;;EAEpB,YAAY;;EAEZ,OAAO;;EAEP;;EAEA,QAAQ;;UAGO;;EAEf,MAAM;;EAEN,OAAO;;EAEP,OAAO;;;;;;;;;;;;;;;;;;;;wBAqCO,aAAa,OAAO,oBAAoB;;UChEvC,cAAc,YAAY,mBAAmB,kBAAkB;WACrE,OAAO,cAAc,YAAY,KAAK;WACtC,QAAQ;aAAyB,MAAM;aAAoB,OAAO,MAAM;;WACxE,OAAO,cAAc,YAAY,KAAK;;;;;;wBAoB3B,aACpB,YAAY,mBAAmB,kBAC/B,kBAEA,WAAW,KAAK,mBAChB;WACW,MAAM,KAAK;WACX,gBAAgB;WAChB,gBAAgB;IAE1B,QAAQ,cAAc,KAAK;;;;;;;wBAoCd,SAAS,YAAY,kBAAkB,QACrD,KAAK,KACL,OAAO,cAAc,KAAK,SAC1B,eAAe,SAAS,QAAQ,SAChC,WAAW,OAAO,cAAc,SAAS,QAAQ,UAChD,QAAQ;;;;;;;wBAkBK,aAAa,YAAY;EAAqB,UAAU;GAAiB,QACvF;WAAiB;GACjB,KAAK,KACL,OAAO,cAAc,KAAK,SAC1B,eAAe,SAAS,QAAQ,SAChC,WAAW,OAAO,cAAc,SAAS,QAAQ,UAChD,QAAQ;UClGM;;EAEf;EACA;EACA,SAAS;EACT,MAAM;;;;;;;qBAQK,iCAAiC;WACnC;WACA;WACA,SAAS;mBACD;UACT;UACA;UACA;UACA;UACA;UACA;EAER,YAAY,MAAM;;;;;MAWd,UAAU;EAId,IAAI,UAAU,YAAY,KAAK,IAAI,aAAa;EAWhD,KAAK,UAAU,YAAY,KAAK,IAAI,aAAa;EAIjD,IAAI,UAAU,YAAY,KAAK,GAAG,OAAO,aAAa;EAItD,IAAI,KAAK;EA+BD,KAAK;EAEL,SAAS;EAEjB,SAAS,uBAAuB;;;;;;EAahC,UAAU;UAII;;UAeA"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the author of a transport needs and application code does not: the
|
|
3
|
+
* transport contract, the module graph, handler metadata, and the pieces of
|
|
4
|
+
* an execution context.
|
|
5
|
+
*
|
|
6
|
+
* Application code imports from `@navios/core`.
|
|
7
|
+
*/
|
|
8
|
+
import { a as TransportDefinition, d as buildModuleGraph, f as moduleClasses, h as needsScope, l as defineTransport, p as ContextHost, r as runInContext, s as TransportHost, u as ModuleNode } from "./async-context-BAdt7bno.mjs";
|
|
9
|
+
import { constructedInstances, disposeScope } from "@navios/di/internal";
|
|
10
|
+
import { ClassType, Container, Provider, ScopedContainer } from "@navios/di";
|
|
11
|
+
import { a as Interceptor, i as AttributeValue, n as Guard } from "./module-options-CSqQUSTm.mjs";
|
|
12
|
+
import { a as ContextValue, i as ContextKey, n as ExecutionContext, r as HandlerInfo } from "./execution-context-C5F9rojO.mjs";
|
|
13
|
+
/** The longest delay a timer takes; a longer one fires at once. */
|
|
14
|
+
export declare const MAX_DELAY_MS: number;
|
|
15
|
+
/**
|
|
16
|
+
* Whether `work` settles within `ms`, or within `MAX_DELAY_MS` when `ms` is
|
|
17
|
+
* longer. Rejects when it rejects in time; a later rejection is dropped.
|
|
18
|
+
*/
|
|
19
|
+
export declare function settledWithin(work: PromiseLike<unknown>, ms: number): Promise<boolean>;
|
|
20
|
+
/** The `metadata` of a decorator context. */
|
|
21
|
+
type DecoratorMetadata = Record<PropertyKey, unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* The value stored in decorator metadata under `key`, created for this class
|
|
24
|
+
* from what a parent class has, if anything. The metadata object of a class
|
|
25
|
+
* inherits from that of its parent, so writing to an inherited value would
|
|
26
|
+
* change the parent.
|
|
27
|
+
*/
|
|
28
|
+
export declare function ownMetadata<T>(metadata: DecoratorMetadata, key: symbol, create: (inherited?: T) => T): T;
|
|
29
|
+
/** The metadata of a decorator context, which has to have one. */
|
|
30
|
+
export declare function requireMetadata(context: {
|
|
31
|
+
metadata?: DecoratorMetadata;
|
|
32
|
+
}): DecoratorMetadata;
|
|
33
|
+
interface ModuleMetadata {
|
|
34
|
+
imports: ClassType[];
|
|
35
|
+
guards: ClassType[];
|
|
36
|
+
interceptors: ClassType[];
|
|
37
|
+
providers: Provider[];
|
|
38
|
+
attributes: Map<symbol, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Every option the module system itself does not use, by option name, as
|
|
41
|
+
* written. A transport reads its own from here.
|
|
42
|
+
*/
|
|
43
|
+
entries: Map<string, unknown>;
|
|
44
|
+
}
|
|
45
|
+
export declare function getModuleMetadata(target: ClassType): ModuleMetadata;
|
|
46
|
+
/**
|
|
47
|
+
* What decorators and `handler()` options can attach to a handler.
|
|
48
|
+
*/
|
|
49
|
+
interface HandlerExtras {
|
|
50
|
+
guards: ClassType[];
|
|
51
|
+
interceptors: ClassType[];
|
|
52
|
+
attributes: Map<symbol, unknown>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A class member that is, or may become, a handler: what decorators attached
|
|
56
|
+
* to it.
|
|
57
|
+
*/
|
|
58
|
+
interface MethodHandlerMetadata extends HandlerExtras {
|
|
59
|
+
name: string;
|
|
60
|
+
/**
|
|
61
|
+
* What makes the member a handler of a transport, under that transport's
|
|
62
|
+
* own symbol.
|
|
63
|
+
*/
|
|
64
|
+
entries: Map<symbol, unknown>;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* What decorators attached to a member, inherited ones included, to read and to
|
|
68
|
+
* add to.
|
|
69
|
+
*/
|
|
70
|
+
export declare function memberMetadata(context: {
|
|
71
|
+
metadata?: DecoratorMetadata;
|
|
72
|
+
}, name: string): MethodHandlerMetadata;
|
|
73
|
+
/** What a transport's decorator for handler classes may take. */
|
|
74
|
+
interface HandlerClassOptions {
|
|
75
|
+
guards?: Iterable<ClassType>;
|
|
76
|
+
interceptors?: Iterable<ClassType>;
|
|
77
|
+
attributes?: AttributeValue[];
|
|
78
|
+
}
|
|
79
|
+
/** A class that owns handlers: what applies to all of them, and its members. */
|
|
80
|
+
interface HandlerClassMetadata extends HandlerExtras {
|
|
81
|
+
/** The members decorators were applied to, by name. */
|
|
82
|
+
members: Map<string, MethodHandlerMetadata>;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* What decorators attached to a class of handlers and to its members, together
|
|
86
|
+
* with the options of the class decorator that asks. The lists are live:
|
|
87
|
+
* `@UseGuards` and the like placed above that decorator run after it and are
|
|
88
|
+
* still seen.
|
|
89
|
+
*/
|
|
90
|
+
export declare function describeHandlerClass(context: {
|
|
91
|
+
metadata?: DecoratorMetadata;
|
|
92
|
+
}, options?: HandlerClassOptions): HandlerClassMetadata;
|
|
93
|
+
/** What a class decorator stores on the class it decorates. */
|
|
94
|
+
interface ClassMetadata<T> {
|
|
95
|
+
/** Stores `value` on `target`, where it is not enumerable and can be replaced. */
|
|
96
|
+
define(target: ClassType, value: T): void;
|
|
97
|
+
/**
|
|
98
|
+
* What is stored on `target` itself. A subclass does not inherit it: it is
|
|
99
|
+
* not what the decorator makes of a class unless it is decorated itself.
|
|
100
|
+
* Throws when there is none.
|
|
101
|
+
*/
|
|
102
|
+
get(target: ClassType): T;
|
|
103
|
+
/** Whether `get` would find something. */
|
|
104
|
+
has(target: ClassType): boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Metadata that a class decorator stores on classes under `key`. `what` and
|
|
108
|
+
* `decorator` name it when a class has none: `Users is not a controller. Make
|
|
109
|
+
* sure it is decorated with @Controller.`
|
|
110
|
+
*
|
|
111
|
+
* ```ts
|
|
112
|
+
* const queueHandlers = classMetadata<HandlerClassMetadata>(
|
|
113
|
+
* Symbol.for('my-transport.handlers'),
|
|
114
|
+
* 'a queue handler',
|
|
115
|
+
* 'QueueHandler',
|
|
116
|
+
* )
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function classMetadata<T>(key: symbol, what: string, decorator: string): ClassMetadata<T>;
|
|
120
|
+
interface Extras {
|
|
121
|
+
readonly guards: readonly ClassType[];
|
|
122
|
+
readonly interceptors: readonly ClassType[];
|
|
123
|
+
}
|
|
124
|
+
interface OwnExtras extends Extras {
|
|
125
|
+
readonly attributes: ReadonlyMap<symbol, unknown>;
|
|
126
|
+
}
|
|
127
|
+
interface HandlerChainInput {
|
|
128
|
+
/**
|
|
129
|
+
* Interceptors around every handler of the application or of the transport,
|
|
130
|
+
* outermost first.
|
|
131
|
+
*/
|
|
132
|
+
application: readonly ClassType[];
|
|
133
|
+
/** The module the handler belongs to, with what it inherits. */
|
|
134
|
+
node: Extras & Pick<ModuleNode, 'module' | 'attributes' | 'disputed'>;
|
|
135
|
+
/** The class that owns the handler. */
|
|
136
|
+
controller: ClassType;
|
|
137
|
+
/** What applies to every handler of `controller`. */
|
|
138
|
+
owner: OwnExtras;
|
|
139
|
+
/** The name of the handler in its class. */
|
|
140
|
+
handlerName: string;
|
|
141
|
+
/** The handler itself. */
|
|
142
|
+
member: OwnExtras;
|
|
143
|
+
}
|
|
144
|
+
interface HandlerChain {
|
|
145
|
+
/** What the contexts of the handler tell about it. */
|
|
146
|
+
info: HandlerInfo;
|
|
147
|
+
/** Interceptors around the guards: those of the application. */
|
|
148
|
+
outer: ClassType[];
|
|
149
|
+
/** Interceptors inside the guards: those of the module, the class and the handler. */
|
|
150
|
+
inner: ClassType[];
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* The guards and interceptors that apply to one handler, in the order they
|
|
154
|
+
* run, and what its contexts tell about it: the interceptors of the
|
|
155
|
+
* application, then the guards from the module chain, the owning class and
|
|
156
|
+
* the handler, then the interceptors of the same three. A class that appears
|
|
157
|
+
* twice is kept where it first appears. `info.guards` are the guards and
|
|
158
|
+
* `info.interceptors` the interceptors, `outer` and then `inner`.
|
|
159
|
+
*
|
|
160
|
+
* An interceptor of the application sees every execution, denied ones
|
|
161
|
+
* included, as tracing and logging need. One that is attached to handlers runs
|
|
162
|
+
* only for what their guards let through.
|
|
163
|
+
*
|
|
164
|
+
* Throws when the handler would inherit an attribute that the importers of its
|
|
165
|
+
* module do not agree about.
|
|
166
|
+
*
|
|
167
|
+
* Every transport uses this, so the rule is the same everywhere.
|
|
168
|
+
* `resolveChain` resolves the chain and `runChain` runs it.
|
|
169
|
+
*/
|
|
170
|
+
export declare function handlerChain(input: HandlerChainInput): HandlerChain;
|
|
171
|
+
/** A handler's chain with its instances, ready to run. */
|
|
172
|
+
interface ResolvedChain<Ctx extends ExecutionContext = ExecutionContext, Result = unknown> {
|
|
173
|
+
readonly outer: ReadonlyArray<Interceptor<Ctx, Result>>;
|
|
174
|
+
readonly guards: ReadonlyArray<{
|
|
175
|
+
readonly type: ClassType;
|
|
176
|
+
readonly guard: Guard<Ctx>;
|
|
177
|
+
}>;
|
|
178
|
+
readonly inner: ReadonlyArray<Interceptor<Ctx, Result>>;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Resolves the classes of a chain that `handlerChain` returned. A transport
|
|
182
|
+
* does this once per handler, while it is set up.
|
|
183
|
+
*/
|
|
184
|
+
export declare function resolveChain<Ctx extends ExecutionContext = ExecutionContext, Result = unknown>(container: Pick<Container, 'get'>, chain: {
|
|
185
|
+
readonly info: Pick<HandlerInfo, 'guards'>;
|
|
186
|
+
readonly outer: readonly ClassType[];
|
|
187
|
+
readonly inner: readonly ClassType[];
|
|
188
|
+
}): Promise<ResolvedChain<Ctx, Result>>;
|
|
189
|
+
/**
|
|
190
|
+
* Runs a handler with what applies to it: the outer interceptors, the guards
|
|
191
|
+
* one after another, the inner interceptors, the handler. When a guard refuses,
|
|
192
|
+
* nothing further runs and `onDenied` says what becomes of the execution: what
|
|
193
|
+
* it returns is the result, and what it throws is the failure.
|
|
194
|
+
*/
|
|
195
|
+
export declare function runChain<Ctx extends ExecutionContext, Result>(ctx: Ctx, chain: ResolvedChain<Ctx, Result>, handler: () => Result | Promise<Result>, onDenied: (guard: ClassType) => Result | Promise<Result>): Promise<Result>;
|
|
196
|
+
/**
|
|
197
|
+
* Runs a handler with what applies to it, as `runChain`, in the async context
|
|
198
|
+
* when the application keeps one, and then finishes its context, whatever the
|
|
199
|
+
* outcome. The context is finished inside the async context, so that
|
|
200
|
+
* `currentContext()` still answers in `onFinish` callbacks.
|
|
201
|
+
*/
|
|
202
|
+
export declare function executeChain<Ctx extends ExecutionContext & {
|
|
203
|
+
finish(): Promise<void>;
|
|
204
|
+
}, Result>(host: {
|
|
205
|
+
readonly asyncContext: boolean;
|
|
206
|
+
}, ctx: Ctx, chain: ResolvedChain<Ctx, Result>, handler: () => Result | Promise<Result>, onDenied: (guard: ClassType) => Result | Promise<Result>): Promise<Result>;
|
|
207
|
+
interface BasicExecutionContextInit {
|
|
208
|
+
/** The transport kind, for example `'cli'`. */
|
|
209
|
+
kind: string;
|
|
210
|
+
id: string;
|
|
211
|
+
handler: HandlerInfo;
|
|
212
|
+
host: ContextHost;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* An `ExecutionContext` for transports that need nothing beyond the neutral
|
|
216
|
+
* contract. The transport creates one per execution and calls `finish()` when
|
|
217
|
+
* the handler is done.
|
|
218
|
+
*/
|
|
219
|
+
export declare class BasicExecutionContext implements ExecutionContext {
|
|
220
|
+
readonly kind: string;
|
|
221
|
+
readonly id: string;
|
|
222
|
+
readonly handler: HandlerInfo;
|
|
223
|
+
private readonly host;
|
|
224
|
+
private ownSignal;
|
|
225
|
+
private slots;
|
|
226
|
+
private scope;
|
|
227
|
+
private finishers;
|
|
228
|
+
private finished;
|
|
229
|
+
private finishing;
|
|
230
|
+
constructor(init: BasicExecutionContextInit);
|
|
231
|
+
/**
|
|
232
|
+
* A signal that never aborts. Not shared between contexts: listeners would
|
|
233
|
+
* outlive their execution.
|
|
234
|
+
*/
|
|
235
|
+
get signal(): AbortSignal;
|
|
236
|
+
get<K extends ContextKey>(key: K): ContextValue<K>;
|
|
237
|
+
find<K extends ContextKey>(key: K): ContextValue<K> | undefined;
|
|
238
|
+
set<K extends ContextKey>(key: K, value: ContextValue<K>): void;
|
|
239
|
+
has(key: ContextKey): boolean;
|
|
240
|
+
use: ScopedContainer['getSync'];
|
|
241
|
+
resolve: ScopedContainer['get'];
|
|
242
|
+
onFinish(callback: () => void | Promise<void>): void;
|
|
243
|
+
/**
|
|
244
|
+
* Runs the `onFinish` callbacks in reverse order, those they register
|
|
245
|
+
* included, then disposes the DI scope. Runs once, however often it is
|
|
246
|
+
* called; every caller waits for that run.
|
|
247
|
+
*/
|
|
248
|
+
finish(): Promise<void>;
|
|
249
|
+
private runFinishers;
|
|
250
|
+
/** Runs a callback whose failure must not stop what follows. */
|
|
251
|
+
private runFinisher;
|
|
252
|
+
}
|
|
253
|
+
export { type BasicExecutionContextInit, type ClassMetadata, type ContextHost, type DecoratorMetadata, type HandlerChain, type HandlerChainInput, type HandlerClassMetadata, type HandlerClassOptions, type HandlerExtras, type MethodHandlerMetadata, type ModuleMetadata, type ModuleNode, type ResolvedChain, type TransportDefinition, type TransportHost, buildModuleGraph, constructedInstances, defineTransport, disposeScope, moduleClasses, needsScope, runInContext };
|
|
254
|
+
//# sourceMappingURL=transport.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.mts","names":[],"sources":["../src/transports/settled-within.mts","../src/metadata/decorator-metadata.mts","../src/modules/module-metadata.mts","../src/metadata/member-metadata.mts","../src/metadata/handler-class.mts","../src/metadata/class-store.mts","../src/metadata/handler-chain.mts","../src/metadata/run-chain.mts","../src/execution/basic-execution-context.mts"],"mappings":";;;;;;;;;;;;;qBACa;;;;;wBAMS,cAAc,MAAM,sBAAsB,aAAa;;KCNjE,oBAAoB,OAAO;;;;;;;wBAQvB,YAAY,GAC1B,UAAU,mBACV,aACA,SAAS,YAAY,MAAM,IAC1B;;wBAQa,gBAAgB;EAAW,WAAW;IAAsB;UCN3D;EACf,SAAS;EACT,QAAQ;EACR,cAAc;EACd,WAAW;EACX,YAAY;;;;;EAKZ,SAAS;;wBAyFK,kBAAkB,QAAQ,YAAY;;;;UCzGrC;EACf,QAAQ;EACR,cAAc;EACd,YAAY;;;;;;UAOG,8BAA8B;EAC7C;;;;;EAKA,SAAS;;;;;;wBAUK,eACd;EAAW,WAAW;GACtB,eACC;;UCxBc;EACf,SAAS,SAAS;EAClB,eAAe,SAAS;EACxB,aAAa;;;UAIE,6BAA6B;;EAE5C,SAAS,YAAY;;;;;;;;wBASP,qBACd;EAAW,WAAW;GACtB,UAAS,sBACR;;UChCc,cAAc;;EAE7B,OAAO,QAAQ,WAAW,OAAO;;;;;;EAMjC,IAAI,QAAQ,YAAY;;EAExB,IAAI,QAAQ;;;;;;;;;;;;;;;wBAgBE,cAAc,GAAG,aAAa,cAAc,oBAAoB,cAAc;UCxBpF;WACC,iBAAiB;WACjB,uBAAuB;;UAGxB,kBAAkB;WACjB,YAAY;;UAGN;;;;;EAKf,sBAAsB;;EAEtB,MAAM,SAAS,KAAK;;EAEpB,YAAY;;EAEZ,OAAO;;EAEP;;EAEA,QAAQ;;UAGO;;EAEf,MAAM;;EAEN,OAAO;;EAEP,OAAO;;;;;;;;;;;;;;;;;;;;wBAqCO,aAAa,OAAO,oBAAoB;;UChEvC,cAAc,YAAY,mBAAmB,kBAAkB;WACrE,OAAO,cAAc,YAAY,KAAK;WACtC,QAAQ;aAAyB,MAAM;aAAoB,OAAO,MAAM;;WACxE,OAAO,cAAc,YAAY,KAAK;;;;;;wBAoB3B,aACpB,YAAY,mBAAmB,kBAC/B,kBAEA,WAAW,KAAK,mBAChB;WACW,MAAM,KAAK;WACX,gBAAgB;WAChB,gBAAgB;IAE1B,QAAQ,cAAc,KAAK;;;;;;;wBAoCd,SAAS,YAAY,kBAAkB,QACrD,KAAK,KACL,OAAO,cAAc,KAAK,SAC1B,eAAe,SAAS,QAAQ,SAChC,WAAW,OAAO,cAAc,SAAS,QAAQ,UAChD,QAAQ;;;;;;;wBAkBK,aAAa,YAAY;EAAqB,UAAU;GAAiB,QACvF;WAAiB;GACjB,KAAK,KACL,OAAO,cAAc,KAAK,SAC1B,eAAe,SAAS,QAAQ,SAChC,WAAW,OAAO,cAAc,SAAS,QAAQ,UAChD,QAAQ;UClGM;;EAEf;EACA;EACA,SAAS;EACT,MAAM;;;;;;;qBAQK,iCAAiC;WACnC;WACA;WACA,SAAS;mBACD;UACT;UACA;UACA;UACA;UACA;UACA;EAER,YAAY,MAAM;;;;;MAWd,UAAU;EAId,IAAI,UAAU,YAAY,KAAK,IAAI,aAAa;EAWhD,KAAK,UAAU,YAAY,KAAK,IAAI,aAAa;EAIjD,IAAI,UAAU,YAAY,KAAK,GAAG,OAAO,aAAa;EAItD,IAAI,KAAK;EA+BD,KAAK;EAEL,SAAS;EAEjB,SAAS,uBAAuB;;;;;;EAahC,UAAU;UAII;;UAeA"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { c as classMetadata, h as requireMetadata, i as memberMetadata, m as ownMetadata, s as getModuleMetadata } from "./attribute-value-BNiJjxl1.mjs";
|
|
2
|
+
import { a as handlerChain, i as runChain, n as executeChain, o as describeHandlerClass, r as resolveChain, s as defineTransport, t as BasicExecutionContext } from "./basic-execution-context-u1VktGoM.mjs";
|
|
3
|
+
import { constructedInstances, disposeScope } from "@navios/di/internal";
|
|
4
|
+
import { n as settledWithin, t as MAX_DELAY_MS } from "./settled-within-Bc2pj8WB.mjs";
|
|
5
|
+
import { a as needsScope, c as runInContext, n as buildModuleGraph, r as moduleClasses } from "./execution-context-token-Cb3M3Ao0.mjs";
|
|
6
|
+
export { BasicExecutionContext, MAX_DELAY_MS, buildModuleGraph, classMetadata, constructedInstances, defineTransport, describeHandlerClass, disposeScope, executeChain, getModuleMetadata, handlerChain, memberMetadata, moduleClasses, needsScope, ownMetadata, requireMetadata, resolveChain, runChain, runInContext, settledWithin };
|
package/package.json
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@navios/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.1",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"author": {
|
|
5
6
|
"name": "Oleksandr Hanzha",
|
|
6
7
|
"email": "alex@granted.name"
|
|
7
8
|
},
|
|
8
9
|
"repository": {
|
|
9
|
-
"directory": "packages/core",
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/
|
|
12
|
-
|
|
13
|
-
"license": "MIT",
|
|
14
|
-
"peerDependencies": {
|
|
15
|
-
"@navios/builder": "^1.0.0",
|
|
16
|
-
"zod": "^3.25.0 || ^4.0.0"
|
|
11
|
+
"url": "https://github.com/navios-org/navios.git",
|
|
12
|
+
"directory": "packages/core"
|
|
17
13
|
},
|
|
18
|
-
"
|
|
14
|
+
"files": [
|
|
15
|
+
"lib",
|
|
16
|
+
"README.md",
|
|
17
|
+
"CHANGELOG.md",
|
|
18
|
+
"LICENSE"
|
|
19
|
+
],
|
|
19
20
|
"main": "./lib/index.cjs",
|
|
20
21
|
"module": "./lib/index.mjs",
|
|
22
|
+
"typings": "./lib/index.d.mts",
|
|
21
23
|
"exports": {
|
|
22
24
|
".": {
|
|
23
25
|
"import": {
|
|
@@ -29,6 +31,16 @@
|
|
|
29
31
|
"default": "./lib/index.cjs"
|
|
30
32
|
}
|
|
31
33
|
},
|
|
34
|
+
"./transport": {
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./lib/transport.d.mts",
|
|
37
|
+
"default": "./lib/transport.mjs"
|
|
38
|
+
},
|
|
39
|
+
"require": {
|
|
40
|
+
"types": "./lib/transport.d.cts",
|
|
41
|
+
"default": "./lib/transport.cjs"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
32
44
|
"./testing": {
|
|
33
45
|
"import": {
|
|
34
46
|
"types": "./lib/testing/index.d.mts",
|
|
@@ -50,15 +62,23 @@
|
|
|
50
62
|
}
|
|
51
63
|
}
|
|
52
64
|
},
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
65
|
+
"scripts": {
|
|
66
|
+
"check": "tsc -b",
|
|
67
|
+
"lint": "yarn run -T oxlint --fix && yarn run -T oxfmt",
|
|
68
|
+
"test:ci": "vitest run",
|
|
69
|
+
"build": "tsdown",
|
|
70
|
+
"publish": "node ../../scripts/assert-stable-version.mjs && yarn npm publish --access public",
|
|
71
|
+
"publish:next": "yarn npm publish --access public --tag next"
|
|
60
72
|
},
|
|
61
73
|
"dependencies": {
|
|
62
|
-
"@navios/di": "
|
|
74
|
+
"@navios/di": "2.0.0-alpha.1"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"tsx": "^4.23.15",
|
|
78
|
+
"typescript": "^7.0.2",
|
|
79
|
+
"zod": "^4.6.7"
|
|
80
|
+
},
|
|
81
|
+
"engines": {
|
|
82
|
+
"node": ">=24"
|
|
63
83
|
}
|
|
64
84
|
}
|