@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
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { a as classGuards, c as unique, i as classAttributes, o as classInterceptors, s as prepend } from "./attribute-value-DMEA255r.mjs";
|
|
2
|
-
// src/modules/module-metadata.mts
|
|
3
|
-
const ModuleMetadataKey = Symbol.for("navios.core.module");
|
|
4
|
-
const ownOptions = /* @__PURE__ */ new Set([
|
|
5
|
-
"imports",
|
|
6
|
-
"guards",
|
|
7
|
-
"interceptors",
|
|
8
|
-
"providers",
|
|
9
|
-
"attributes"
|
|
10
|
-
]);
|
|
11
|
-
function defineModuleMetadata(target, context, options) {
|
|
12
|
-
if (hasModuleMetadata(target)) throw new Error(`[Navios] ${target.name} is already a module. One @Module takes all of its options.`);
|
|
13
|
-
const entries = /* @__PURE__ */ new Map();
|
|
14
|
-
for (const [name, value] of Object.entries(options)) if (!ownOptions.has(name) && value !== void 0) entries.set(name, value);
|
|
15
|
-
const imports = unique([...options.imports ?? []]);
|
|
16
|
-
assertImportsDefined(target, imports);
|
|
17
|
-
const providers = [...options.providers ?? []];
|
|
18
|
-
assertProviders(target.name, providers);
|
|
19
|
-
const base = Object.getPrototypeOf(target)[ModuleMetadataKey];
|
|
20
|
-
const module = {
|
|
21
|
-
imports,
|
|
22
|
-
guards: prepend(prepend(classGuards(context), base?.guards), options.guards),
|
|
23
|
-
interceptors: prepend(prepend(classInterceptors(context), base?.interceptors), options.interceptors),
|
|
24
|
-
providers,
|
|
25
|
-
attributes: classAttributes(context),
|
|
26
|
-
entries
|
|
27
|
-
};
|
|
28
|
-
for (const [key, value] of base?.attributes ?? []) if (!module.attributes.has(key)) module.attributes.set(key, value);
|
|
29
|
-
Object.defineProperty(target, ModuleMetadataKey, {
|
|
30
|
-
value: module,
|
|
31
|
-
configurable: true,
|
|
32
|
-
enumerable: false
|
|
33
|
-
});
|
|
34
|
-
return module;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* An import that is `undefined` is what an import cycle between files leaves
|
|
38
|
-
* behind: the importing file ran before the imported one defined its class.
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
function assertImportsDefined(target, imports) {
|
|
42
|
-
const index = imports.findIndex((imported) => imported === void 0 || imported === null);
|
|
43
|
-
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.`);
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Where there are no types, a class is easily listed for itself.
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
49
|
-
function assertProviders(owner, providers) {
|
|
50
|
-
for (const provider of providers) {
|
|
51
|
-
if (typeof provider === "object" && provider !== null && "token" in provider) continue;
|
|
52
|
-
const listed = typeof provider === "function" ? provider.name : typeof provider === "object" && provider !== null ? "an object" : String(provider);
|
|
53
|
-
throw new Error(`[Navios] ${owner} lists ${listed} in providers, which is not a provider. Use provide(token, ...); an @Injectable class needs no entry.`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function getModuleMetadata(target) {
|
|
57
|
-
const metadata = Object.hasOwn(target, ModuleMetadataKey) ? target[ModuleMetadataKey] : void 0;
|
|
58
|
-
if (!metadata) throw new Error(`[Navios] ${target.name} is not a module. Make sure it is decorated with @Module.`);
|
|
59
|
-
return metadata;
|
|
60
|
-
}
|
|
61
|
-
function hasModuleMetadata(target) {
|
|
62
|
-
return Object.hasOwn(target, ModuleMetadataKey);
|
|
63
|
-
}
|
|
64
|
-
export { hasModuleMetadata as a, getModuleMetadata as i, assertProviders as n, defineModuleMetadata as r, assertImportsDefined as t };
|
|
65
|
-
|
|
66
|
-
//# sourceMappingURL=module-metadata-k3RTt20x.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"module-metadata-k3RTt20x.mjs","names":[],"sources":["../src/modules/module-metadata.mts"],"sourcesContent":["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'\n\nimport type { DecoratorMetadata } from '../metadata/decorator-metadata.mjs'\n\nimport type { ModuleOptions } from './module-options.mjs'\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\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 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 (hasModuleMetadata(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 Object.defineProperty(target, ModuleMetadataKey, {\n value: module,\n configurable: true,\n enumerable: false,\n })\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 * @internal\n */\nexport function 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 const metadata = Object.hasOwn(target, ModuleMetadataKey)\n ? ((target as any)[ModuleMetadataKey] as ModuleMetadata)\n : undefined\n if (!metadata) {\n throw new Error(\n `[Navios] ${target.name} is not a module. Make sure it is decorated with @Module.`,\n )\n }\n return metadata\n}\n\nexport function hasModuleMetadata(target: ClassType): boolean {\n return Object.hasOwn(target, ModuleMetadataKey)\n}\n"],"mappings":";;AA6BA,MAAM,oBAAoB,OAAO,IAAI,oBAAoB;AAEzD,MAAM,6BAAa,IAAI,IAAI;CAAC;CAAW;CAAU;CAAgB;CAAa;AAAY,CAAC;AAE3F,SAAgB,qBACd,QACA,SACA,SACgB;CAChB,IAAI,kBAAkB,MAAM,GAC1B,MAAM,IAAI,MACR,YAAY,OAAO,KAAK,4DAC1B;CAEF,MAAM,0BAAU,IAAI,IAAqB;CACzC,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,OAAO,GAChD,IAAI,CAAC,WAAW,IAAI,IAAI,KAAK,UAAU,KAAA,GACrC,QAAQ,IAAI,MAAM,KAAK;CAG3B,MAAM,UAAU,OAAO,CAAC,GAAI,QAAQ,WAAW,CAAC,CAAE,CAAC;CACnD,qBAAqB,QAAQ,OAAO;CACpC,MAAM,YAAY,CAAC,GAAI,QAAQ,aAAa,CAAC,CAAE;CAC/C,gBAAgB,OAAO,MAAM,SAAS;CAGtC,MAAM,OAAO,OAAO,eAAe,MAAM,CAAC,CAAC;CAC3C,MAAM,SAAyB;EAC7B;EACA,QAAQ,QAAQ,QAAQ,YAAY,OAAO,GAAG,MAAM,MAA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