@navios/core 2.0.0-alpha.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 +33 -3
- package/README.md +8 -6
- package/lib/{async-context-6pdlnNLA.d.mts → async-context-BAdt7bno.d.mts} +11 -9
- package/lib/async-context-BAdt7bno.d.mts.map +1 -0
- package/lib/{async-context-Dqk7pE-D.d.cts → async-context-RsWmy2Hi.d.cts} +11 -9
- package/lib/async-context-RsWmy2Hi.d.cts.map +1 -0
- package/lib/{attribute-factory-B3VuYnp7.d.cts → attribute-factory-BW1kgBqf.d.mts} +2 -2
- package/lib/{attribute-factory-B3VuYnp7.d.cts.map → attribute-factory-BW1kgBqf.d.mts.map} +1 -1
- package/lib/{attribute-factory-mKOXoVnV.d.mts → attribute-factory-DqN4x5XM.d.cts} +2 -2
- package/lib/{attribute-factory-mKOXoVnV.d.mts.map → attribute-factory-DqN4x5XM.d.cts.map} +1 -1
- 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-DSk5MNtc.cjs → basic-execution-context-5uq2DvEA.cjs} +66 -29
- package/lib/basic-execution-context-5uq2DvEA.cjs.map +1 -0
- package/lib/{basic-execution-context-CeGuhMOz.mjs → basic-execution-context-u1VktGoM.mjs} +61 -30
- package/lib/basic-execution-context-u1VktGoM.mjs.map +1 -0
- package/lib/{execution-context-BPD3FeFb.d.mts → execution-context-BVSmLkYp.d.cts} +2 -2
- package/lib/{execution-context-BPD3FeFb.d.mts.map → execution-context-BVSmLkYp.d.cts.map} +1 -1
- package/lib/{execution-context-BTJdHhbf.d.cts → execution-context-C5F9rojO.d.mts} +2 -2
- package/lib/{execution-context-BTJdHhbf.d.cts.map → execution-context-C5F9rojO.d.mts.map} +1 -1
- package/lib/{module-graph-DCP9MHG0.cjs → execution-context-token--cKS4cJv.cjs} +135 -12
- package/lib/execution-context-token--cKS4cJv.cjs.map +1 -0
- package/lib/{module-graph-xvVEykFM.mjs → execution-context-token-Cb3M3Ao0.mjs} +93 -12
- package/lib/execution-context-token-Cb3M3Ao0.mjs.map +1 -0
- package/lib/index.cjs +84 -101
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +14 -10
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +14 -10
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +76 -92
- package/lib/index.mjs.map +1 -1
- package/lib/legacy-compat/index.cjs +2 -2
- package/lib/legacy-compat/index.d.cts +3 -3
- package/lib/legacy-compat/index.d.mts +2 -2
- package/lib/legacy-compat/index.mjs +2 -2
- package/lib/{module-DZewk_2r.cjs → module-Bz83ZnJ5.cjs} +43 -34
- package/lib/module-Bz83ZnJ5.cjs.map +1 -0
- package/lib/{module-options-Dmse0gii.d.mts → module-options-CSqQUSTm.d.mts} +2 -2
- package/lib/{module-options-Dmse0gii.d.mts.map → module-options-CSqQUSTm.d.mts.map} +1 -1
- package/lib/{module-options-IuDO-p8u.d.cts → module-options-DSRBri4J.d.cts} +2 -2
- package/lib/{module-options-IuDO-p8u.d.cts.map → module-options-DSRBri4J.d.cts.map} +1 -1
- package/lib/{module-Bha7GER_.mjs → module-zPXwR2qp.mjs} +38 -35
- 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 +12 -34
- package/lib/testing/index.cjs.map +1 -1
- package/lib/testing/index.d.cts +2 -2
- package/lib/testing/index.d.cts.map +1 -1
- package/lib/testing/index.d.mts +1 -1
- package/lib/testing/index.d.mts.map +1 -1
- package/lib/testing/index.mjs +12 -34
- package/lib/testing/index.mjs.map +1 -1
- package/lib/transport.cjs +19 -8
- package/lib/transport.d.cts +102 -38
- package/lib/transport.d.cts.map +1 -1
- package/lib/transport.d.mts +102 -38
- package/lib/transport.d.mts.map +1 -1
- package/lib/transport.mjs +6 -7
- package/package.json +2 -2
- package/lib/async-context-6pdlnNLA.d.mts.map +0 -1
- package/lib/async-context-Dqk7pE-D.d.cts.map +0 -1
- package/lib/attribute-value-CjX9ZkLq.cjs +0 -172
- package/lib/attribute-value-CjX9ZkLq.cjs.map +0 -1
- package/lib/attribute-value-DMEA255r.mjs +0 -119
- package/lib/attribute-value-DMEA255r.mjs.map +0 -1
- package/lib/basic-execution-context-CeGuhMOz.mjs.map +0 -1
- package/lib/basic-execution-context-DSk5MNtc.cjs.map +0 -1
- package/lib/execution-context-token-BXUKB2hf.cjs +0 -112
- package/lib/execution-context-token-BXUKB2hf.cjs.map +0 -1
- package/lib/execution-context-token-CrXmTvk2.mjs +0 -77
- package/lib/execution-context-token-CrXmTvk2.mjs.map +0 -1
- package/lib/module-Bha7GER_.mjs.map +0 -1
- package/lib/module-DZewk_2r.cjs.map +0 -1
- package/lib/module-graph-DCP9MHG0.cjs.map +0 -1
- package/lib/module-graph-xvVEykFM.mjs.map +0 -1
- package/lib/module-metadata-C8S92seK.cjs +0 -95
- package/lib/module-metadata-C8S92seK.cjs.map +0 -1
- package/lib/module-metadata-k3RTt20x.mjs +0 -66
- package/lib/module-metadata-k3RTt20x.mjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,37 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [2.0.0-alpha.
|
|
8
|
+
## [2.0.0-alpha.1] - Unreleased
|
|
9
|
+
|
|
10
|
+
### Breaking
|
|
11
|
+
|
|
12
|
+
- **`@navios/core/transport` exports less.** A transport that imports these from it changes the import:
|
|
13
|
+
- `hasModuleMetadata` is removed; `getModuleMetadata` throws for a class that is not a module.
|
|
14
|
+
- The types that `@navios/core` exports are no longer exported a second time: `Transport`, `TransportFactory`, `TransportInstance`, `Guard`, `GuardClass`, `Interceptor`, `InterceptorClass`, `ExecutionContext`, `HandlerInfo`, `AttributeMap`, `ClassType` and `LoggerService`. Import them from `@navios/core`. `TransportDefinition` and `TransportHost` stay.
|
|
15
|
+
- **`RegisterProviderOptions` is no longer exported**, as `@navios/di` no longer has the type.
|
|
16
|
+
- **`isLogLevel` is removed** from `@navios/core`. `filterLogLevels` reads levels from a setting, and throws for one that does not exist.
|
|
17
|
+
- **`BasicExecutionContextInit` has no `signal`**, which no transport passed: the signal of a `BasicExecutionContext` is its own and never aborts.
|
|
18
|
+
- **`HandlerInfo.module` is a `ClassType`**, no longer `| null`: every transport sets it.
|
|
19
|
+
- **`ConsoleLogger`'s protected `printMessages()` takes no `requestId`**, which nothing passed: the id is that of `currentContext()` when the `requestId` option is on. `getRequestId()` and `printAsJson()`, protected as well, print the id they are given without checking the option again.
|
|
20
|
+
- **`handlerChain` builds the `HandlerInfo`.** It takes the `controller` and the `handlerName` of the handler besides `node`, `owner` and `member`, and returns `{ info, outer, inner }`: `info` is what the handler's contexts carry as `ctx.handler`, its guards in `info.guards`. `HandlerChain.guards` and `HandlerChain.interceptors` are removed. `resolveChain` takes what `handlerChain` returns, the guards in `info.guards`.
|
|
21
|
+
- **`ContextHost.onScopedUse` is called only for a token that `needsScope` is true for**, and no longer checks that itself. A context of a transport's own calls `needsScope` first, as `BasicExecutionContext` does; with the `'warn'` and `'forbid'` policies a context looks up the provider of a token once per resolution instead of twice.
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
|
|
25
|
+
- **`executeChain(host, ctx, chain, handler, onDenied)`** in `@navios/core/transport`: `runChain` with a context of the transport's own, in the async context when `host.asyncContext` is set, and `ctx.finish()` afterwards, whatever the outcome.
|
|
26
|
+
- **`moduleClasses(node, entry)`** in `@navios/core/transport`: the classes a module lists under an option of a transport, once each. Something that is not a class fails with the module and the option, as an import cycle between files leaves `undefined` behind.
|
|
27
|
+
- **`classMetadata(key, what, decorator)`** in `@navios/core/transport`: `define`, `get` and `has` for what a class decorator stores on a class. Only the class itself carries it, not a subclass, and `get` throws `Users is not a controller. Make sure it is decorated with @Controller.` for a class without it.
|
|
28
|
+
- **`ownMetadata(metadata, key, create)` and `requireMetadata(context)`** in `@navios/core/transport`, for decorators that keep their own entries in decorator metadata: the entry of this class, created from what its parent has, and the metadata of a context that has to have one.
|
|
29
|
+
- **`disposeScope(scope)`** in `@navios/core/transport`, re-exported from `@navios/di/internal` as `constructedInstances` is: a transport ends the scope of a context of its own without depending on `@navios/di`.
|
|
30
|
+
- **`settledWithin(work, ms)` and `MAX_DELAY_MS`** in `@navios/core/transport`: whether a promise settles within `ms`, for a transport's `stop(timeoutMs)`. A longer time than a timer takes is cut to `MAX_DELAY_MS`.
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- **An application starts in `workerd`**, the runtime of Cloudflare Workers. `AsyncLocalStorage.disable()` throws there, which failed every lifecycle step, and the logger imported `util` without the `node:` prefix, which a Worker's bundle does not resolve.
|
|
35
|
+
- **A Worker with a compatibility date before 2025-09-15 starts.** Importing `@navios/core` needed `node:os`, which `workerd` has from that date only, so the Worker failed at start-up with `No such module "node:os"`; the module is now asked for when a signal ends process 1, and the exit code is the same. The logger called `process.on()`, which the `process` of an earlier date does not have, so every request was a 500; it waits for the exit of the process only where there is one.
|
|
36
|
+
- **A schema that answers with a thenable that is not a native promise**, such as a promise of another realm, is refused by `AttributeFactory.createAttribute` and `provideConfig` as one that answers with a promise is. It was taken for a result without issues, so the value was `undefined`.
|
|
37
|
+
|
|
38
|
+
## [2.0.0-alpha.0] - 2026-11-26
|
|
9
39
|
|
|
10
40
|
`@navios/core` is now the part of Navios that does not depend on HTTP. The HTTP framework it was in 1.x is `@navios/server`, which is built on this package and re-exports it. The changes to the HTTP framework itself are listed in the changelog of `@navios/server`.
|
|
11
41
|
|
|
@@ -224,7 +254,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
224
254
|
|
|
225
255
|
- Updated to support `@navios/builder` ^1.0.0-alpha.2 with new `RequestArgs` type system
|
|
226
256
|
|
|
227
|
-
## [1.0.0-alpha.1] - 2026-01-
|
|
257
|
+
## [1.0.0-alpha.1] - 2026-01-07
|
|
228
258
|
|
|
229
259
|
### Added
|
|
230
260
|
|
|
@@ -362,7 +392,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
362
392
|
- Guards can be pre-resolved at startup for faster request handling
|
|
363
393
|
- Response validation can be disabled for production performance
|
|
364
394
|
|
|
365
|
-
## [0.7.1] - 2025-12-
|
|
395
|
+
## [0.7.1] - 2025-12-20
|
|
366
396
|
|
|
367
397
|
### Added
|
|
368
398
|
|
package/README.md
CHANGED
|
@@ -64,11 +64,13 @@ const app = createApplication(AppModule, {
|
|
|
64
64
|
})
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
67
|
+
`@navios/microservice` is not published yet.
|
|
68
|
+
|
|
69
|
+
| Transport | Package | `@Module` option |
|
|
70
|
+
| --------- | -------------------------------------------------------------------- | -------------------- |
|
|
71
|
+
| HTTP | [`@navios/server`](https://www.npmjs.com/package/@navios/server) | `controllers` |
|
|
72
|
+
| Messages | `@navios/microservice` (not published yet) | `messageControllers` |
|
|
73
|
+
| Cron jobs | [`@navios/schedule`](https://www.npmjs.com/package/@navios/schedule) | `jobs` |
|
|
72
74
|
|
|
73
75
|
A module lists what it has for each transport, and an application ignores the options of transports it does not have, so one module can serve several.
|
|
74
76
|
|
|
@@ -97,7 +99,7 @@ A module lists what it has for each transport, and an application ignores the op
|
|
|
97
99
|
|
|
98
100
|
## One copy
|
|
99
101
|
|
|
100
|
-
Every package of an application has to resolve the same `@navios/core`. `@navios/server
|
|
102
|
+
Every package of an application has to resolve the same `@navios/core`. `@navios/server`, the other transports and the plugins that work on any transport list it as a peer dependency, so an application installs it once, beside them. HTTP adapters peer on `@navios/server` only and reach this package through it. If two copies are loaded, a warning names both locations. Two copies that a bundler put into one file are not noticed.
|
|
101
103
|
|
|
102
104
|
## Upgrading from 1.x
|
|
103
105
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ExecutionContext } from "./execution-context-
|
|
1
|
+
import { n as ExecutionContext } from "./execution-context-C5F9rojO.mjs";
|
|
2
2
|
import { AnyInjectableType, ClassType, Container, InjectionToken, Provider } from "@navios/di";
|
|
3
3
|
/**
|
|
4
4
|
* Available log levels in order of severity (lowest to highest).
|
|
@@ -13,10 +13,6 @@ declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
|
|
|
13
13
|
* @publicApi
|
|
14
14
|
*/
|
|
15
15
|
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
16
|
-
/**
|
|
17
|
-
* @publicApi
|
|
18
|
-
*/
|
|
19
|
-
declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
|
|
20
16
|
/**
|
|
21
17
|
* Reads log levels out of a setting: `'error'`, `'warn,error'`, `'>=warn'` or
|
|
22
18
|
* `'>warn'`. An empty string stands for every level.
|
|
@@ -75,8 +71,8 @@ type OptionsArgument<Options, Rest extends unknown[] = []> = {} extends Options
|
|
|
75
71
|
interface ContextHost {
|
|
76
72
|
readonly container: Container;
|
|
77
73
|
/**
|
|
78
|
-
* Called when a
|
|
79
|
-
*
|
|
74
|
+
* Called when a context resolves a token that `needsScope` is true for; may
|
|
75
|
+
* throw.
|
|
80
76
|
*/
|
|
81
77
|
onScopedUse: ((token: AnyInjectableType) => void) | null;
|
|
82
78
|
/** Receives what an `onFinish` callback throws; without it that is dropped. */
|
|
@@ -115,6 +111,12 @@ interface ModuleNode {
|
|
|
115
111
|
/** Whether the module was given to the application directly. */
|
|
116
112
|
isRoot: boolean;
|
|
117
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* The classes a module lists under one of the options of a transport, once
|
|
116
|
+
* each. Throws for an entry that is not a class: what an import cycle between
|
|
117
|
+
* the files of two classes leaves behind.
|
|
118
|
+
*/
|
|
119
|
+
declare function moduleClasses(node: Pick<ModuleNode, 'module' | 'entries'>, entry: string): ClassType[];
|
|
118
120
|
/**
|
|
119
121
|
* Walks the import graph from the given roots and computes, for this
|
|
120
122
|
* application only, what applies to each module.
|
|
@@ -233,5 +235,5 @@ declare function runInContext<R>(ctx: ExecutionContext, fn: () => R): R;
|
|
|
233
235
|
* application was not created with `asyncContext: true`.
|
|
234
236
|
*/
|
|
235
237
|
declare function currentContext(): ExecutionContext | undefined;
|
|
236
|
-
export {
|
|
237
|
-
//# sourceMappingURL=async-context-
|
|
238
|
+
export { LoggerOutput as _, TransportDefinition as a, LogLevel as b, TransportInstance as c, buildModuleGraph as d, moduleClasses as f, OptionsArgument as g, needsScope as h, Transport as i, defineTransport as l, createContextHost as m, enableAsyncContext as n, TransportFactory as o, ContextHost as p, runInContext as r, TransportHost as s, currentContext as t, ModuleNode as u, LoggerService as v, filterLogLevels as x, LOG_LEVELS as y };
|
|
239
|
+
//# sourceMappingURL=async-context-BAdt7bno.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-context-BAdt7bno.d.mts","names":[],"sources":["../src/logger/log-levels.mts","../src/logger/logger-output.mts","../src/internal/options-argument.mts","../src/execution/context-host.mts","../src/modules/module-graph.mts","../src/transports/transport.mts","../src/execution/async-context.mts"],"mappings":";;;;;cAGa;;;;;;;;;KAiBD,mBAAmB;;;;;;iBAkDf,gBAAgB,2BAAuB;;;;UC/DtC;;;;EAIf,IAAI,iBAAiB;;;;EAKrB,MAAM,iBAAiB;;;;EAKvB,KAAK,iBAAiB;;;;EAKtB,O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
1
|
-
import { n as ExecutionContext } from "./execution-context-
|
|
1
|
+
import { n as ExecutionContext } from "./execution-context-BVSmLkYp.cjs";
|
|
2
2
|
import { AnyInjectableType, ClassType, Container, InjectionToken, Provider } from "@navios/di";
|
|
3
3
|
/**
|
|
4
4
|
* Available log levels in order of severity (lowest to highest).
|
|
@@ -13,10 +13,6 @@ declare const LOG_LEVELS: ["verbose", "debug", "log", "warn", "error", "fatal"];
|
|
|
13
13
|
* @publicApi
|
|
14
14
|
*/
|
|
15
15
|
type LogLevel = (typeof LOG_LEVELS)[number];
|
|
16
|
-
/**
|
|
17
|
-
* @publicApi
|
|
18
|
-
*/
|
|
19
|
-
declare function isLogLevel(maybeLogLevel: any): maybeLogLevel is LogLevel;
|
|
20
16
|
/**
|
|
21
17
|
* Reads log levels out of a setting: `'error'`, `'warn,error'`, `'>=warn'` or
|
|
22
18
|
* `'>warn'`. An empty string stands for every level.
|
|
@@ -75,8 +71,8 @@ type OptionsArgument<Options, Rest extends unknown[] = []> = {} extends Options
|
|
|
75
71
|
interface ContextHost {
|
|
76
72
|
readonly container: Container;
|
|
77
73
|
/**
|
|
78
|
-
* Called when a
|
|
79
|
-
*
|
|
74
|
+
* Called when a context resolves a token that `needsScope` is true for; may
|
|
75
|
+
* throw.
|
|
80
76
|
*/
|
|
81
77
|
onScopedUse: ((token: AnyInjectableType) => void) | null;
|
|
82
78
|
/** Receives what an `onFinish` callback throws; without it that is dropped. */
|
|
@@ -115,6 +111,12 @@ interface ModuleNode {
|
|
|
115
111
|
/** Whether the module was given to the application directly. */
|
|
116
112
|
isRoot: boolean;
|
|
117
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* The classes a module lists under one of the options of a transport, once
|
|
116
|
+
* each. Throws for an entry that is not a class: what an import cycle between
|
|
117
|
+
* the files of two classes leaves behind.
|
|
118
|
+
*/
|
|
119
|
+
declare function moduleClasses(node: Pick<ModuleNode, 'module' | 'entries'>, entry: string): ClassType[];
|
|
118
120
|
/**
|
|
119
121
|
* Walks the import graph from the given roots and computes, for this
|
|
120
122
|
* application only, what applies to each module.
|
|
@@ -233,5 +235,5 @@ declare function runInContext<R>(ctx: ExecutionContext, fn: () => R): R;
|
|
|
233
235
|
* application was not created with `asyncContext: true`.
|
|
234
236
|
*/
|
|
235
237
|
declare function currentContext(): ExecutionContext | undefined;
|
|
236
|
-
export {
|
|
237
|
-
//# sourceMappingURL=async-context-
|
|
238
|
+
export { LoggerOutput as _, TransportDefinition as a, LogLevel as b, TransportInstance as c, buildModuleGraph as d, moduleClasses as f, OptionsArgument as g, needsScope as h, Transport as i, defineTransport as l, createContextHost as m, enableAsyncContext as n, TransportFactory as o, ContextHost as p, runInContext as r, TransportHost as s, currentContext as t, ModuleNode as u, LoggerService as v, filterLogLevels as x, LOG_LEVELS as y };
|
|
239
|
+
//# sourceMappingURL=async-context-RsWmy2Hi.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-context-RsWmy2Hi.d.cts","names":[],"sources":["../src/logger/log-levels.mts","../src/logger/logger-output.mts","../src/internal/options-argument.mts","../src/execution/context-host.mts","../src/modules/module-graph.mts","../src/transports/transport.mts","../src/execution/async-context.mts"],"mappings":";;;;;cAGa;;;;;;;;;KAiBD,mBAAmB;;;;;;iBAkDf,gBAAgB,2BAAuB;;;;UC/DtC;;;;EAIf,IAAI,iBAAiB;;;;EAKrB,MAAM,iBAAiB;;;;EAKvB,KAAK,iBAAiB;;;;EAKtB,OAAO,iBAAiB;;;;EAKxB,SAAS,iBAAiB;;;;EAK1B,OAAO,iBAAiB;;;;;EAMxB,cAAc,QAAQ;;;;;;;;cASX,cAAY,eAAA;;;;;KC/Cb,gBAAgB,SAAS,0CAA0C,WAC1E,UAAU,YAAY,MAAM,SAC5B,SAAS,YAAY,MAAM;;;;UCGf;WACN,WAAW;;;;;EAKpB,eAAe,OAAO;;WAEb,SAAS,KAAK;;;;;;iBAsBT,WAAW,WAAW,WAAW,OAAO;;;;;iBAQxC,kBACd,WAAW,WACX,mCACA,QAAQ,gBACP;;;;;UCrCc;EACf,QAAQ;EACR,WAAW;;EAEX,SAAS;EACT,QAAQ;EACR,cAAc;EACd,YAAY;;;;;;EAMZ,UAAU;;EAEV,WAAW;;EAEX;;;;;;;iBAQc,cACd,MAAM,KAAK,mCACX,gBACC;;;;;;;;;;;;;;;;;;iBAqHa,iBAAiB,OAAO,cAAc;;;;UCnJrC;WACN,WAAW;WACX,QAAQ;;WAER,aAAa;;WAEb;;;;;WAKA,uBAAuB;;;;;;;UAQjB;;;;;EAKf,MAAM,gBAAgB,sBAAsB;;EAE5C,iBAAiB;;;;;;;;;EASjB,KAAK,2BAA2B;;UAGjB,oBAAoB,SAAS,UAAU;;EAEtD;EACA,OAAO,MAAM,eAAe,SAAS,UAAU,IAAI,QAAQ;;;;;UAM5C,kBAAkB,UAAU,YAAY;WAC9C,YAAY,yBAAyB;;WAErC;;WAEA;;;;;;UAOM,iBAAiB,SAAS,UAAU;MAC/C,MAAM,gBAAgB,UAAU,0BAA0B,kBAAkB;WACvE,YAAY,oBAAoB,SAAS;;;;;;;;;;;;;;;;;;;;;;;iBAwBpC,gBAAgB,gBAAgB,UAAU,YAAY,WACpE,YAAY,oBAAoB,SAAS,KACxC,iBAAiB,SAAS;;;;;iBCtFP,sBAAsB;;;;;iBAW5B,aAAa,GAAG,KAAK,kBAAkB,UAAU,IAAI;;;;;;iBASrD,kBAAkB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InferInput, InferOutput, StandardSchemaV1 } from "@navios/di";
|
|
2
|
-
import { r as HandlerInfo } from "./execution-context-
|
|
2
|
+
import { r as HandlerInfo } from "./execution-context-C5F9rojO.mjs";
|
|
3
3
|
type AttributeContext = ClassDecoratorContext | ClassMethodDecoratorContext | ClassFieldDecoratorContext;
|
|
4
4
|
/**
|
|
5
5
|
* The result of calling an attribute. It is a decorator for a module, a
|
|
@@ -67,4 +67,4 @@ declare class AttributeFactory {
|
|
|
67
67
|
}, source: AttributeSource): boolean;
|
|
68
68
|
}
|
|
69
69
|
export { ClassSchemaAttribute as i, AttributeFactory as n, ClassAttribute as r, AttributeApplication as t };
|
|
70
|
-
//# sourceMappingURL=attribute-factory-
|
|
70
|
+
//# sourceMappingURL=attribute-factory-BW1kgBqf.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribute-factory-
|
|
1
|
+
{"version":3,"file":"attribute-factory-BW1kgBqf.d.mts","names":[],"sources":["../src/attributes/attribute-factory.mts"],"mappings":";;KAUK,mBACD,wBACA,8BACA;;;;;;UAOa;GACd,aAAa,SAAS;WACd;WACA;;UAGM;MACX;WACK;;UAGM,qBAAqB,eAAe;GAClD,OAAO,WAAW,UAAU;WACpB;WACA,QAAQ;;;;;;;UAqBT;WACC;WACA;;UAGD,wBAAwB,eAAe;WACtC;WACA,QAAQ;;KAGd,kBAAkB;EAAgB,YAAY;;;;;;;;;;;;;;cAwBtC;SACJ,gBAAgB,gBAAgB;SAChC,gBAAgB,eAAe,kBACpC,eACA,QAAQ,SACP,qBAAqB;;;;;SA2BjB,IAAI,WAAW,mBAAmB,QAAQ;SAC1C,IAAI,eAAe,kBACxB,WAAW,wBAAwB,SACnC,QAAQ,kBACP,YAAY;;;;SAaR,OAAO,WAAW,mBAAmB,QAAQ;SAC7C,OAAO,eAAe,kBAC3B,WAAW,wBAAwB,SACnC,QAAQ,kBACP,YAAY;SAWR,IAAI;IAAa;KAAiB,QAAQ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InferInput, InferOutput, StandardSchemaV1 } from "@navios/di";
|
|
2
|
-
import { r as HandlerInfo } from "./execution-context-
|
|
2
|
+
import { r as HandlerInfo } from "./execution-context-BVSmLkYp.cjs";
|
|
3
3
|
type AttributeContext = ClassDecoratorContext | ClassMethodDecoratorContext | ClassFieldDecoratorContext;
|
|
4
4
|
/**
|
|
5
5
|
* The result of calling an attribute. It is a decorator for a module, a
|
|
@@ -67,4 +67,4 @@ declare class AttributeFactory {
|
|
|
67
67
|
}, source: AttributeSource): boolean;
|
|
68
68
|
}
|
|
69
69
|
export { ClassSchemaAttribute as i, AttributeFactory as n, ClassAttribute as r, AttributeApplication as t };
|
|
70
|
-
//# sourceMappingURL=attribute-factory-
|
|
70
|
+
//# sourceMappingURL=attribute-factory-DqN4x5XM.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"attribute-factory-
|
|
1
|
+
{"version":3,"file":"attribute-factory-DqN4x5XM.d.cts","names":[],"sources":["../src/attributes/attribute-factory.mts"],"mappings":";;KAUK,mBACD,wBACA,8BACA;;;;;;UAOa;GACd,aAAa,SAAS;WACd;WACA;;UAGM;MACX;WACK;;UAGM,qBAAqB,eAAe;GAClD,OAAO,WAAW,UAAU;WACpB;WACA,QAAQ;;;;;;;UAqBT;WACC;WACA;;UAGD,wBAAwB,eAAe;WACtC;WACA,QAAQ;;KAGd,kBAAkB;EAAgB,YAAY;;;;;;;;;;;;;;cAwBtC;SACJ,gBAAgB,gBAAgB;SAChC,gBAAgB,eAAe,kBACpC,eACA,QAAQ,SACP,qBAAqB;;;;;SA2BjB,IAAI,WAAW,mBAAmB,QAAQ;SAC1C,IAAI,eAAe,kBACxB,WAAW,wBAAwB,SACnC,QAAQ,kBACP,YAAY;;;;SAaR,OAAO,WAAW,mBAAmB,QAAQ;SAC7C,OAAO,eAAe,kBAC3B,WAAW,wBAAwB,SACnC,QAAQ,kBACP,YAAY;SAWR,IAAI;IAAa;KAAiB,QAAQ"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
// src/internal/single-copy.mts
|
|
2
|
+
/**
|
|
3
|
+
* Warns when a second copy of this package is loaded into the process.
|
|
4
|
+
*
|
|
5
|
+
* Several things only work with one copy: `@Module` options that other
|
|
6
|
+
* packages add by declaration merging, the async store behind
|
|
7
|
+
* `currentContext()`, and `instanceof` checks on context keys. Two copies
|
|
8
|
+
* usually mean two versions were installed, or one package bundled its own.
|
|
9
|
+
*/
|
|
10
|
+
const registryKey = Symbol.for("navios.core.copies");
|
|
11
|
+
function registerCopy(url, warn) {
|
|
12
|
+
if (typeof url !== "string") return;
|
|
13
|
+
const location = url.replace(/[?#].*$/, "");
|
|
14
|
+
const holder = globalThis;
|
|
15
|
+
const registry = holder[registryKey] ??= {
|
|
16
|
+
locations: /* @__PURE__ */ new Set(),
|
|
17
|
+
warned: false
|
|
18
|
+
};
|
|
19
|
+
if (registry.locations.has(location)) return;
|
|
20
|
+
registry.locations.add(location);
|
|
21
|
+
if (registry.locations.size > 1 && !registry.warned) {
|
|
22
|
+
registry.warned = true;
|
|
23
|
+
warn(`[Navios] @navios/core is loaded more than once:\n` + [...registry.locations].map((entry) => ` - ${entry}`).join("\n") + "\nModule options, currentContext() and context keys are not shared between copies. Make sure every package resolves the same @navios/core: one version, not bundled into another package, and not loaded with both import and require.");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
// src/internal/this-copy.mts
|
|
27
|
+
/**
|
|
28
|
+
* Registers this copy of the package. Every entry point imports this module,
|
|
29
|
+
* so a copy is noticed whichever entry is loaded, and counted once: the
|
|
30
|
+
* entries of one build share this module.
|
|
31
|
+
*/
|
|
32
|
+
registerCopy(import.meta.url, (message) => console.warn(message));
|
|
33
|
+
// src/metadata/decorator-metadata.mts
|
|
34
|
+
/**
|
|
35
|
+
* The value stored in decorator metadata under `key`, created for this class
|
|
36
|
+
* from what a parent class has, if anything. The metadata object of a class
|
|
37
|
+
* inherits from that of its parent, so writing to an inherited value would
|
|
38
|
+
* change the parent.
|
|
39
|
+
*/
|
|
40
|
+
function ownMetadata(metadata, key, create) {
|
|
41
|
+
if (!Object.hasOwn(metadata, key)) metadata[key] = create(metadata[key]);
|
|
42
|
+
return metadata[key];
|
|
43
|
+
}
|
|
44
|
+
/** The metadata of a decorator context, which has to have one. */
|
|
45
|
+
function requireMetadata(context) {
|
|
46
|
+
if (!context.metadata) throw new Error("[Navios] Decorator metadata is not available. Use standard decorators, or the @navios/core/legacy-compat entry point with experimentalDecorators.");
|
|
47
|
+
return context.metadata;
|
|
48
|
+
}
|
|
49
|
+
// src/metadata/class-metadata.mts
|
|
50
|
+
const ClassAttributesKey = Symbol.for("navios.core.classAttributes");
|
|
51
|
+
const ClassGuardsKey = Symbol.for("navios.core.classGuards");
|
|
52
|
+
const ClassInterceptorsKey = Symbol.for("navios.core.classInterceptors");
|
|
53
|
+
/** The attributes of a class, inherited ones included, to read and to add to. */
|
|
54
|
+
function classAttributes(context) {
|
|
55
|
+
return ownMetadata(requireMetadata(context), ClassAttributesKey, (inherited) => new Map(inherited));
|
|
56
|
+
}
|
|
57
|
+
/** The guards of a class, as `classAttributes`. */
|
|
58
|
+
function classGuards(context) {
|
|
59
|
+
return ownMetadata(requireMetadata(context), ClassGuardsKey, (inherited) => [...inherited ?? []]);
|
|
60
|
+
}
|
|
61
|
+
/** The interceptors of a class, as `classAttributes`. */
|
|
62
|
+
function classInterceptors(context) {
|
|
63
|
+
return ownMetadata(requireMetadata(context), ClassInterceptorsKey, (inherited) => [...inherited ?? []]);
|
|
64
|
+
}
|
|
65
|
+
/** @internal */
|
|
66
|
+
function unique(list) {
|
|
67
|
+
return Array.from(new Set(list));
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Adds to `list`, in place, what it does not include yet, in order.
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
73
|
+
function addMissing(list, items) {
|
|
74
|
+
for (const item of items) if (!list.includes(item)) list.push(item);
|
|
75
|
+
return list;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Puts `first` in front of `list`, in place, skipping duplicates.
|
|
79
|
+
*/
|
|
80
|
+
function prepend(list, first) {
|
|
81
|
+
if (first) list.unshift(...addMissing([], first).filter((item) => !list.includes(item)));
|
|
82
|
+
return list;
|
|
83
|
+
}
|
|
84
|
+
// src/metadata/class-store.mts
|
|
85
|
+
/**
|
|
86
|
+
* Metadata that a class decorator stores on classes under `key`. `what` and
|
|
87
|
+
* `decorator` name it when a class has none: `Users is not a controller. Make
|
|
88
|
+
* sure it is decorated with @Controller.`
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* const queueHandlers = classMetadata<HandlerClassMetadata>(
|
|
92
|
+
* Symbol.for('my-transport.handlers'),
|
|
93
|
+
* 'a queue handler',
|
|
94
|
+
* 'QueueHandler',
|
|
95
|
+
* )
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
function classMetadata(key, what, decorator) {
|
|
99
|
+
const has = (target) => Object.hasOwn(target, key);
|
|
100
|
+
return {
|
|
101
|
+
define(target, value) {
|
|
102
|
+
Object.defineProperty(target, key, {
|
|
103
|
+
value,
|
|
104
|
+
configurable: true,
|
|
105
|
+
enumerable: false
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
get(target) {
|
|
109
|
+
if (!has(target)) throw new Error(`[Navios] ${target.name} is not ${what}. Make sure it is decorated with @${decorator}.`);
|
|
110
|
+
return target[key];
|
|
111
|
+
},
|
|
112
|
+
has
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
// src/modules/module-metadata.mts
|
|
116
|
+
const ModuleMetadataKey = Symbol.for("navios.core.module");
|
|
117
|
+
const moduleMetadata = classMetadata(ModuleMetadataKey, "a module", "Module");
|
|
118
|
+
const ownOptions = /* @__PURE__ */ new Set([
|
|
119
|
+
"imports",
|
|
120
|
+
"guards",
|
|
121
|
+
"interceptors",
|
|
122
|
+
"providers",
|
|
123
|
+
"attributes"
|
|
124
|
+
]);
|
|
125
|
+
function defineModuleMetadata(target, context, options) {
|
|
126
|
+
if (moduleMetadata.has(target)) throw new Error(`[Navios] ${target.name} is already a module. One @Module takes all of its options.`);
|
|
127
|
+
const entries = /* @__PURE__ */ new Map();
|
|
128
|
+
for (const [name, value] of Object.entries(options)) if (!ownOptions.has(name) && value !== void 0) entries.set(name, value);
|
|
129
|
+
const imports = unique([...options.imports ?? []]);
|
|
130
|
+
assertImportsDefined(target, imports);
|
|
131
|
+
const providers = [...options.providers ?? []];
|
|
132
|
+
assertProviders(target.name, providers);
|
|
133
|
+
const base = Object.getPrototypeOf(target)[ModuleMetadataKey];
|
|
134
|
+
const module = {
|
|
135
|
+
imports,
|
|
136
|
+
guards: prepend(prepend(classGuards(context), base?.guards), options.guards),
|
|
137
|
+
interceptors: prepend(prepend(classInterceptors(context), base?.interceptors), options.interceptors),
|
|
138
|
+
providers,
|
|
139
|
+
attributes: classAttributes(context),
|
|
140
|
+
entries
|
|
141
|
+
};
|
|
142
|
+
for (const [key, value] of base?.attributes ?? []) if (!module.attributes.has(key)) module.attributes.set(key, value);
|
|
143
|
+
moduleMetadata.define(target, module);
|
|
144
|
+
return module;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* An import that is `undefined` is what an import cycle between files leaves
|
|
148
|
+
* behind: the importing file ran before the imported one defined its class.
|
|
149
|
+
*/
|
|
150
|
+
function assertImportsDefined(target, imports) {
|
|
151
|
+
const index = imports.findIndex((imported) => imported === void 0 || imported === null);
|
|
152
|
+
if (index !== -1) throw new Error(`[Navios] Module ${target.name} imports ${String(imports[index])} at index ${index} of its imports. This usually means the files of the two modules import each other, so the imported module was not defined yet when ${target.name} was. Break the import cycle.`);
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Where there are no types, a class is easily listed for itself.
|
|
156
|
+
* @internal
|
|
157
|
+
*/
|
|
158
|
+
function assertProviders(owner, providers) {
|
|
159
|
+
for (const provider of providers) {
|
|
160
|
+
if (typeof provider === "object" && provider !== null && "token" in provider) continue;
|
|
161
|
+
const listed = typeof provider === "function" ? provider.name : typeof provider === "object" && provider !== null ? "an object" : String(provider);
|
|
162
|
+
throw new Error(`[Navios] ${owner} lists ${listed} in providers, which is not a provider. Use provide(token, ...); an @Injectable class needs no entry.`);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
function getModuleMetadata(target) {
|
|
166
|
+
return moduleMetadata.get(target);
|
|
167
|
+
}
|
|
168
|
+
// src/metadata/member-metadata.mts
|
|
169
|
+
/** Where the members of a class are kept in its metadata. */
|
|
170
|
+
const MembersKey = Symbol.for("navios.core.members");
|
|
171
|
+
/**
|
|
172
|
+
* What decorators attached to a member, inherited ones included, to read and to
|
|
173
|
+
* add to.
|
|
174
|
+
*/
|
|
175
|
+
function memberMetadata(context, name) {
|
|
176
|
+
const members = ownMetadata(requireMetadata(context), MembersKey, (inherited) => {
|
|
177
|
+
const copy = /* @__PURE__ */ new Map();
|
|
178
|
+
if (inherited) for (const [key, value] of inherited) copy.set(key, {
|
|
179
|
+
...value,
|
|
180
|
+
guards: [...value.guards],
|
|
181
|
+
interceptors: [...value.interceptors],
|
|
182
|
+
attributes: new Map(value.attributes),
|
|
183
|
+
entries: new Map(value.entries)
|
|
184
|
+
});
|
|
185
|
+
return copy;
|
|
186
|
+
});
|
|
187
|
+
let member = members.get(name);
|
|
188
|
+
if (!member) {
|
|
189
|
+
member = {
|
|
190
|
+
name,
|
|
191
|
+
guards: [],
|
|
192
|
+
interceptors: [],
|
|
193
|
+
attributes: /* @__PURE__ */ new Map(),
|
|
194
|
+
entries: /* @__PURE__ */ new Map()
|
|
195
|
+
};
|
|
196
|
+
members.set(name, member);
|
|
197
|
+
}
|
|
198
|
+
return member;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A decorator for classes, methods and fields that adds to what decorators
|
|
202
|
+
* attached to them: `toClass` is given the context of a class, `toMember` the
|
|
203
|
+
* metadata of a member. `name` names the decorator in its errors.
|
|
204
|
+
* @internal
|
|
205
|
+
*/
|
|
206
|
+
function classOrMemberDecorator(name, toClass, toMember) {
|
|
207
|
+
return (target, context) => {
|
|
208
|
+
if (context.kind === "class") {
|
|
209
|
+
toClass(context);
|
|
210
|
+
return target;
|
|
211
|
+
}
|
|
212
|
+
if (context.kind !== "method" && context.kind !== "field") throw new Error(`[Navios] ${name} can only be used on classes, methods and fields.`);
|
|
213
|
+
if (typeof context.name !== "string") throw new Error(`[Navios] ${name} cannot be used on symbol-named members.`);
|
|
214
|
+
toMember(memberMetadata(context, context.name));
|
|
215
|
+
return context.kind === "field" ? void 0 : target;
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
// src/attributes/attribute-value.mts
|
|
219
|
+
/** Sets the values of attributes on a map of them. */
|
|
220
|
+
function applyAttributes(target, attributes) {
|
|
221
|
+
for (const attribute of attributes ?? []) target.set(attribute.token, attribute.value);
|
|
222
|
+
}
|
|
223
|
+
export { assertProviders as a, classMetadata as c, classGuards as d, classInterceptors as f, requireMetadata as h, memberMetadata as i, addMissing as l, ownMetadata as m, MembersKey as n, defineModuleMetadata as o, prepend as p, classOrMemberDecorator as r, getModuleMetadata as s, applyAttributes as t, classAttributes as u };
|
|
224
|
+
|
|
225
|
+
//# sourceMappingURL=attribute-value-BNiJjxl1.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute-value-BNiJjxl1.mjs","names":[],"sources":["../src/internal/single-copy.mts","../src/internal/this-copy.mts","../src/metadata/decorator-metadata.mts","../src/metadata/class-metadata.mts","../src/metadata/class-store.mts","../src/modules/module-metadata.mts","../src/metadata/member-metadata.mts","../src/attributes/attribute-value.mts"],"sourcesContent":["/**\n * Warns when a second copy of this package is loaded into the process.\n *\n * Several things only work with one copy: `@Module` options that other\n * packages add by declaration merging, the async store behind\n * `currentContext()`, and `instanceof` checks on context keys. Two copies\n * usually mean two versions were installed, or one package bundled its own.\n */\nconst registryKey = Symbol.for('navios.core.copies')\n\ninterface Registry {\n locations: Set<string>\n warned: boolean\n}\n\nexport function registerCopy(url: string | undefined, warn: (message: string) => void): void {\n if (typeof url !== 'string') {\n // `import.meta` is empty in a bundle that is not a module.\n return\n }\n // A development server adds a query when it loads a file again.\n const location = url.replace(/[?#].*$/, '')\n const holder = globalThis as { [registryKey]?: Registry }\n const registry = (holder[registryKey] ??= { locations: new Set(), warned: false })\n if (registry.locations.has(location)) {\n // The same file evaluated again: a module reload, not a second copy.\n return\n }\n registry.locations.add(location)\n if (registry.locations.size > 1 && !registry.warned) {\n registry.warned = true\n warn(\n `[Navios] @navios/core is loaded more than once:\\n` +\n [...registry.locations].map((entry) => ` - ${entry}`).join('\\n') +\n `\\nModule options, currentContext() and context keys are not shared between copies. ` +\n `Make sure every package resolves the same @navios/core: one version, not bundled into ` +\n `another package, and not loaded with both import and require.`,\n )\n }\n}\n","/**\n * Registers this copy of the package. Every entry point imports this module,\n * so a copy is noticed whichever entry is loaded, and counted once: the\n * entries of one build share this module.\n */\nimport { registerCopy } from './single-copy.mjs'\n\nregisterCopy(import.meta.url, (message) => console.warn(message))\n","/** The `metadata` of a decorator context. */\nexport type DecoratorMetadata = Record<PropertyKey, unknown>\n\n/**\n * The value stored in decorator metadata under `key`, created for this class\n * from what a parent class has, if anything. The metadata object of a class\n * inherits from that of its parent, so writing to an inherited value would\n * change the parent.\n */\nexport function ownMetadata<T>(\n metadata: DecoratorMetadata,\n key: symbol,\n create: (inherited?: T) => T,\n): T {\n if (!Object.hasOwn(metadata, key)) {\n metadata[key] = create(metadata[key] as T | undefined)\n }\n return metadata[key] as T\n}\n\n/** The metadata of a decorator context, which has to have one. */\nexport function requireMetadata(context: { metadata?: DecoratorMetadata }): DecoratorMetadata {\n if (!context.metadata) {\n throw new Error(\n '[Navios] Decorator metadata is not available. Use standard decorators, or the ' +\n '@navios/core/legacy-compat entry point with experimentalDecorators.',\n )\n }\n return context.metadata\n}\n","import type { ClassType } from '@navios/di'\n\nimport { ownMetadata, requireMetadata } from './decorator-metadata.mjs'\n\nimport type { DecoratorMetadata } from './decorator-metadata.mjs'\n\nconst ClassAttributesKey = Symbol.for('navios.core.classAttributes')\nconst ClassGuardsKey = Symbol.for('navios.core.classGuards')\nconst ClassInterceptorsKey = Symbol.for('navios.core.classInterceptors')\n\n/** The attributes of a class, inherited ones included, to read and to add to. */\nexport function classAttributes(context: { metadata?: DecoratorMetadata }): Map<symbol, unknown> {\n return ownMetadata(\n requireMetadata(context),\n ClassAttributesKey,\n (inherited) => new Map(inherited),\n )\n}\n\n/** The guards of a class, as `classAttributes`. */\nexport function classGuards(context: { metadata?: DecoratorMetadata }): ClassType[] {\n return ownMetadata<ClassType[]>(requireMetadata(context), ClassGuardsKey, (inherited) => [\n ...(inherited ?? []),\n ])\n}\n\n/** The interceptors of a class, as `classAttributes`. */\nexport function classInterceptors(context: { metadata?: DecoratorMetadata }): ClassType[] {\n return ownMetadata<ClassType[]>(requireMetadata(context), ClassInterceptorsKey, (inherited) => [\n ...(inherited ?? []),\n ])\n}\n\n/** @internal */\nexport function unique(list: ClassType[]): ClassType[] {\n return Array.from(new Set(list))\n}\n\n/**\n * Adds to `list`, in place, what it does not include yet, in order.\n * @internal\n */\nexport function addMissing<T>(list: T[], items: Iterable<T>): T[] {\n for (const item of items) {\n if (!list.includes(item)) {\n list.push(item)\n }\n }\n return list\n}\n\n/**\n * Puts `first` in front of `list`, in place, skipping duplicates.\n */\nexport function prepend(list: ClassType[], first: Iterable<ClassType> | undefined): ClassType[] {\n if (first) {\n list.unshift(...addMissing([], first).filter((item) => !list.includes(item)))\n }\n return list\n}\n","import type { ClassType } from '@navios/di'\n\n/** What a class decorator stores on the class it decorates. */\nexport interface ClassMetadata<T> {\n /** Stores `value` on `target`, where it is not enumerable and can be replaced. */\n define(target: ClassType, value: T): void\n /**\n * What is stored on `target` itself. A subclass does not inherit it: it is\n * not what the decorator makes of a class unless it is decorated itself.\n * Throws when there is none.\n */\n get(target: ClassType): T\n /** Whether `get` would find something. */\n has(target: ClassType): boolean\n}\n\n/**\n * Metadata that a class decorator stores on classes under `key`. `what` and\n * `decorator` name it when a class has none: `Users is not a controller. Make\n * sure it is decorated with @Controller.`\n *\n * ```ts\n * const queueHandlers = classMetadata<HandlerClassMetadata>(\n * Symbol.for('my-transport.handlers'),\n * 'a queue handler',\n * 'QueueHandler',\n * )\n * ```\n */\nexport function classMetadata<T>(key: symbol, what: string, decorator: string): ClassMetadata<T> {\n const has = (target: ClassType): boolean => Object.hasOwn(target, key)\n return {\n define(target, value) {\n Object.defineProperty(target, key, { value, configurable: true, enumerable: false })\n },\n get(target) {\n if (!has(target)) {\n throw new Error(\n `[Navios] ${target.name} is not ${what}. Make sure it is decorated with @${decorator}.`,\n )\n }\n return (target as unknown as Record<symbol, T>)[key]\n },\n has,\n }\n}\n","import type { ClassType, Provider } from '@navios/di'\n\nimport {\n classAttributes,\n classGuards,\n classInterceptors,\n prepend,\n unique,\n} from '../metadata/class-metadata.mjs'\nimport { classMetadata } from '../metadata/class-store.mjs'\n\nimport type { DecoratorMetadata } from '../metadata/decorator-metadata.mjs'\n\nimport type { ModuleOptions } from './module-options.mjs'\n\nexport interface ModuleMetadata {\n imports: ClassType[]\n guards: ClassType[]\n interceptors: ClassType[]\n providers: Provider[]\n attributes: Map<symbol, unknown>\n /**\n * Every option the module system itself does not use, by option name, as\n * written. A transport reads its own from here.\n */\n entries: Map<string, unknown>\n}\n\nconst ModuleMetadataKey = Symbol.for('navios.core.module')\n\nconst moduleMetadata = classMetadata<ModuleMetadata>(ModuleMetadataKey, 'a module', 'Module')\n\nconst ownOptions = new Set(['imports', 'guards', 'interceptors', 'providers', 'attributes'])\n\nexport function defineModuleMetadata(\n target: ClassType,\n context: { metadata?: DecoratorMetadata },\n options: ModuleOptions,\n): ModuleMetadata {\n if (moduleMetadata.has(target)) {\n throw new Error(\n `[Navios] ${target.name} is already a module. One @Module takes all of its options.`,\n )\n }\n const entries = new Map<string, unknown>()\n for (const [name, value] of Object.entries(options)) {\n if (!ownOptions.has(name) && value !== undefined) {\n entries.set(name, value)\n }\n }\n const imports = unique([...(options.imports ?? [])])\n assertImportsDefined(target, imports)\n const providers = [...(options.providers ?? [])]\n assertProviders(target.name, providers)\n // Decorator metadata inherits by itself between two decorated classes. This\n // covers a class or a base class that was registered without decorators.\n const base = Object.getPrototypeOf(target)[ModuleMetadataKey] as ModuleMetadata | undefined\n const module: ModuleMetadata = {\n imports,\n guards: prepend(prepend(classGuards(context), base?.guards), options.guards),\n interceptors: prepend(\n prepend(classInterceptors(context), base?.interceptors),\n options.interceptors,\n ),\n providers,\n attributes: classAttributes(context),\n entries,\n }\n for (const [key, value] of base?.attributes ?? []) {\n if (!module.attributes.has(key)) {\n module.attributes.set(key, value)\n }\n }\n moduleMetadata.define(target, module)\n return module\n}\n\n/**\n * An import that is `undefined` is what an import cycle between files leaves\n * behind: the importing file ran before the imported one defined its class.\n */\nfunction assertImportsDefined(target: ClassType, imports: readonly unknown[]): void {\n const index = imports.findIndex((imported) => imported === undefined || imported === null)\n if (index !== -1) {\n throw new Error(\n `[Navios] Module ${target.name} imports ${String(imports[index])} at index ${index} of ` +\n `its imports. This usually means the files of the two modules import each other, so the ` +\n `imported module was not defined yet when ${target.name} was. Break the import cycle.`,\n )\n }\n}\n\n/**\n * Where there are no types, a class is easily listed for itself.\n * @internal\n */\nexport function assertProviders(owner: string, providers: readonly unknown[]): void {\n for (const provider of providers) {\n if (typeof provider === 'object' && provider !== null && 'token' in provider) {\n continue\n }\n const listed =\n typeof provider === 'function'\n ? provider.name\n : typeof provider === 'object' && provider !== null\n ? 'an object'\n : String(provider)\n throw new Error(\n `[Navios] ${owner} lists ${listed} in providers, which is not a provider. Use ` +\n `provide(token, ...); an @Injectable class needs no entry.`,\n )\n }\n}\n\nexport function getModuleMetadata(target: ClassType): ModuleMetadata {\n return moduleMetadata.get(target)\n}\n","import type { ClassType } from '@navios/di'\n\nimport { ownMetadata, requireMetadata } from './decorator-metadata.mjs'\n\nimport type { DecoratorMetadata } from './decorator-metadata.mjs'\n\n/**\n * What decorators and `handler()` options can attach to a handler.\n */\nexport interface HandlerExtras {\n guards: ClassType[]\n interceptors: ClassType[]\n attributes: Map<symbol, unknown>\n}\n\n/**\n * A class member that is, or may become, a handler: what decorators attached\n * to it.\n */\nexport interface MethodHandlerMetadata extends HandlerExtras {\n name: string\n /**\n * What makes the member a handler of a transport, under that transport's\n * own symbol.\n */\n entries: Map<symbol, unknown>\n}\n\n/** Where the members of a class are kept in its metadata. */\nexport const MembersKey = Symbol.for('navios.core.members')\n\n/**\n * What decorators attached to a member, inherited ones included, to read and to\n * add to.\n */\nexport function memberMetadata(\n context: { metadata?: DecoratorMetadata },\n name: string,\n): MethodHandlerMetadata {\n const members = ownMetadata<Map<string, MethodHandlerMetadata>>(\n requireMetadata(context),\n MembersKey,\n (inherited) => {\n const copy = new Map<string, MethodHandlerMetadata>()\n if (inherited) {\n for (const [key, value] of inherited) {\n copy.set(key, {\n ...value,\n guards: [...value.guards],\n interceptors: [...value.interceptors],\n attributes: new Map(value.attributes),\n entries: new Map(value.entries),\n })\n }\n }\n return copy\n },\n )\n let member = members.get(name)\n if (!member) {\n member = { name, guards: [], interceptors: [], attributes: new Map(), entries: new Map() }\n members.set(name, member)\n }\n return member\n}\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype ClassOrMemberContext =\n | ClassDecoratorContext\n | ClassMethodDecoratorContext\n | ClassFieldDecoratorContext\n\n/**\n * A decorator for classes, methods and fields that adds to what decorators\n * attached to them: `toClass` is given the context of a class, `toMember` the\n * metadata of a member. `name` names the decorator in its errors.\n * @internal\n */\nexport function classOrMemberDecorator(\n name: string,\n toClass: (context: ClassDecoratorContext) => void,\n toMember: (member: MethodHandlerMetadata) => void,\n): (target: any, context: ClassOrMemberContext) => any {\n return (target, context) => {\n if (context.kind === 'class') {\n toClass(context)\n return target\n }\n if (context.kind !== 'method' && context.kind !== 'field') {\n throw new Error(`[Navios] ${name} can only be used on classes, methods and fields.`)\n }\n if (typeof context.name !== 'string') {\n throw new Error(`[Navios] ${name} cannot be used on symbol-named members.`)\n }\n toMember(memberMetadata(context, context.name))\n return context.kind === 'field' ? undefined : target\n }\n}\n","/** An attribute value as returned by calling an attribute. */\nexport type AttributeValue = { readonly token: symbol; readonly value: unknown }\n\n/** Sets the values of attributes on a map of them. */\nexport function applyAttributes(\n target: Map<symbol, unknown>,\n attributes: AttributeValue[] | undefined,\n): void {\n for (const attribute of attributes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