@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,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../attribute-value-
|
|
2
|
+
require("../attribute-value-Cux5HhOL.cjs");
|
|
3
3
|
let _navios_di_legacy_compat = require("@navios/di/legacy-compat");
|
|
4
|
-
const require_module = require("../module-
|
|
4
|
+
const require_module = require("../module-Bz83ZnJ5.cjs");
|
|
5
5
|
// src/legacy-compat/legacy-decorator.mts
|
|
6
6
|
/**
|
|
7
7
|
* Turns a standard decorator into one that accepts the legacy call shapes:
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
* implementation as the standard decorator of the same name, so behaviour is
|
|
8
8
|
* identical.
|
|
9
9
|
*/
|
|
10
|
-
import "../execution-context-
|
|
11
|
-
import { o as InterceptorClass, r as GuardClass, t as ModuleOptions } from "../module-options-
|
|
10
|
+
import "../execution-context-BVSmLkYp.cjs";
|
|
11
|
+
import { o as InterceptorClass, r as GuardClass, t as ModuleOptions } from "../module-options-DSRBri4J.cjs";
|
|
12
12
|
import { ClassType, InferInput, StandardSchemaV1 } from "@navios/di";
|
|
13
13
|
import { Factory, Injectable, createClassContext, createMethodContext } from "@navios/di/legacy-compat";
|
|
14
|
-
import { n as AttributeFactory$1, t as AttributeApplication } from "../attribute-factory-
|
|
14
|
+
import { n as AttributeFactory$1, t as AttributeApplication } from "../attribute-factory-DqN4x5XM.cjs";
|
|
15
15
|
type StandardDecorator = (target: any, context: any) => any;
|
|
16
16
|
/** A decorator that accepts every legacy call shape. */
|
|
17
17
|
type LegacyAnyDecorator = (target: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => any;
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* identical.
|
|
9
9
|
*/
|
|
10
10
|
import { Factory, Injectable, createClassContext, createMethodContext } from "@navios/di/legacy-compat";
|
|
11
|
-
import { o as InterceptorClass, r as GuardClass, t as ModuleOptions } from "../module-options-
|
|
11
|
+
import { o as InterceptorClass, r as GuardClass, t as ModuleOptions } from "../module-options-CSqQUSTm.mjs";
|
|
12
12
|
import { ClassType, InferInput, StandardSchemaV1 } from "@navios/di";
|
|
13
|
-
import { n as AttributeFactory$1, t as AttributeApplication } from "../attribute-factory-
|
|
13
|
+
import { n as AttributeFactory$1, t as AttributeApplication } from "../attribute-factory-BW1kgBqf.mjs";
|
|
14
14
|
type StandardDecorator = (target: any, context: any) => any;
|
|
15
15
|
/** A decorator that accepts every legacy call shape. */
|
|
16
16
|
type LegacyAnyDecorator = (target: any, propertyKey?: string | symbol, descriptor?: PropertyDescriptor) => any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../attribute-value-
|
|
1
|
+
import "../attribute-value-BNiJjxl1.mjs";
|
|
2
2
|
import { Factory, Injectable, createClassContext, createClassContext as createClassContext$1, createMethodContext, createMethodContext as createMethodContext$1 } from "@navios/di/legacy-compat";
|
|
3
|
-
import { a as AttributeFactory$1, i as UseGuards$1, r as UseInterceptors$1, t as Module$1 } from "../module-
|
|
3
|
+
import { a as AttributeFactory$1, i as UseGuards$1, r as UseInterceptors$1, t as Module$1 } from "../module-zPXwR2qp.mjs";
|
|
4
4
|
// src/legacy-compat/legacy-decorator.mts
|
|
5
5
|
/**
|
|
6
6
|
* Turns a standard decorator into one that accepts the legacy call shapes:
|
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
const require_attribute_value = require("./attribute-value-
|
|
2
|
-
const require_module_metadata = require("./module-metadata-C8S92seK.cjs");
|
|
1
|
+
const require_attribute_value = require("./attribute-value-Cux5HhOL.cjs");
|
|
3
2
|
let _navios_di = require("@navios/di");
|
|
3
|
+
// src/internal/validate-now.mts
|
|
4
|
+
function ignore() {}
|
|
5
|
+
/**
|
|
6
|
+
* Validates `value` with a schema that has to answer at once. A schema that
|
|
7
|
+
* answers with a promise, or with a thenable of another kind, is an error
|
|
8
|
+
* with `notSynchronous` as its message, and what it rejects with later is
|
|
9
|
+
* handled.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function validateNow(schema, value, notSynchronous) {
|
|
13
|
+
const result = schema["~standard"].validate(value);
|
|
14
|
+
if (typeof result.then === "function") {
|
|
15
|
+
result.then(void 0, ignore);
|
|
16
|
+
throw new Error(notSynchronous);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
4
20
|
// src/attributes/attribute-factory.mts
|
|
5
21
|
function apply(token, value) {
|
|
6
|
-
const decorator = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} else throw new Error("[Navios] Attributes can only be applied to classes, methods and fields");
|
|
12
|
-
return context.kind === "field" ? void 0 : target;
|
|
13
|
-
};
|
|
22
|
+
const decorator = require_attribute_value.classOrMemberDecorator(`Attribute ${String(token)}`, (context) => {
|
|
23
|
+
require_attribute_value.classAttributes(context).set(token, value);
|
|
24
|
+
}, (member) => {
|
|
25
|
+
member.attributes.set(token, value);
|
|
26
|
+
});
|
|
14
27
|
return Object.assign(decorator, {
|
|
15
28
|
token,
|
|
16
29
|
value
|
|
@@ -42,11 +55,7 @@ var AttributeFactory = class {
|
|
|
42
55
|
static createAttribute(token, schema) {
|
|
43
56
|
const attribute = (value) => {
|
|
44
57
|
if (!schema) return apply(token, true);
|
|
45
|
-
const result = schema[
|
|
46
|
-
if (result instanceof Promise) {
|
|
47
|
-
result.catch(() => {});
|
|
48
|
-
throw new Error(`[Navios] Attribute ${token.toString()} must use a schema that validates synchronously`);
|
|
49
|
-
}
|
|
58
|
+
const result = validateNow(schema, value, `[Navios] Attribute ${token.toString()} must use a schema that validates synchronously`);
|
|
50
59
|
if (result.issues) throw new Error(`[Navios] Invalid value for attribute ${token.toString()}: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
51
60
|
return apply(token, result.value);
|
|
52
61
|
};
|
|
@@ -75,18 +84,11 @@ var AttributeFactory = class {
|
|
|
75
84
|
* @internal
|
|
76
85
|
*/
|
|
77
86
|
function attachClasses(kind, classes, name) {
|
|
78
|
-
return (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
if (context.kind !== "method" && context.kind !== "field") throw new Error(`[Navios] @${name} can only be used on classes, methods and fields.`);
|
|
85
|
-
if (typeof context.name !== "string") throw new Error(`[Navios] @${name} cannot be used on symbol-named members.`);
|
|
86
|
-
const list = require_attribute_value.memberMetadata(context, context.name)[kind];
|
|
87
|
-
for (const cls of classes) if (!list.includes(cls)) list.push(cls);
|
|
88
|
-
return context.kind === "field" ? void 0 : target;
|
|
89
|
-
};
|
|
87
|
+
return require_attribute_value.classOrMemberDecorator(`@${name}`, (context) => {
|
|
88
|
+
require_attribute_value.addMissing(kind === "guards" ? require_attribute_value.classGuards(context) : require_attribute_value.classInterceptors(context), classes);
|
|
89
|
+
}, (member) => {
|
|
90
|
+
require_attribute_value.addMissing(member[kind], classes);
|
|
91
|
+
});
|
|
90
92
|
}
|
|
91
93
|
// src/guards/use-guards.mts
|
|
92
94
|
/**
|
|
@@ -110,6 +112,11 @@ function UseInterceptors(...interceptors) {
|
|
|
110
112
|
return attachClasses("interceptors", interceptors, "UseInterceptors");
|
|
111
113
|
}
|
|
112
114
|
// src/modules/module.mts
|
|
115
|
+
function defineModule(target, context, options) {
|
|
116
|
+
require_attribute_value.applyAttributes(require_attribute_value.defineModuleMetadata(target, context, options).attributes, options.attributes);
|
|
117
|
+
(0, _navios_di.registerInjectable)(target, { scope: _navios_di.InjectableScope.Singleton });
|
|
118
|
+
return target;
|
|
119
|
+
}
|
|
113
120
|
/**
|
|
114
121
|
* Marks a class as a module: a group of handlers with shared guards,
|
|
115
122
|
* interceptors and attributes.
|
|
@@ -117,18 +124,14 @@ function UseInterceptors(...interceptors) {
|
|
|
117
124
|
function Module(options = {}) {
|
|
118
125
|
return (target, context) => {
|
|
119
126
|
if (context.kind !== "class") throw new Error("[Navios] @Module can only be used on classes.");
|
|
120
|
-
|
|
121
|
-
(0, _navios_di.registerInjectable)(target, { scope: _navios_di.InjectableScope.Singleton });
|
|
122
|
-
return target;
|
|
127
|
+
return defineModule(target, context, options);
|
|
123
128
|
};
|
|
124
129
|
}
|
|
125
130
|
/**
|
|
126
131
|
* Registers a class as a module without decorator syntax.
|
|
127
132
|
*/
|
|
128
133
|
function registerModule(target, options = {}) {
|
|
129
|
-
|
|
130
|
-
(0, _navios_di.registerInjectable)(target, { scope: _navios_di.InjectableScope.Singleton });
|
|
131
|
-
return target;
|
|
134
|
+
return defineModule(target, { metadata: {} }, options);
|
|
132
135
|
}
|
|
133
136
|
Object.defineProperty(exports, "AttributeFactory", {
|
|
134
137
|
enumerable: true,
|
|
@@ -160,5 +163,11 @@ Object.defineProperty(exports, "registerModule", {
|
|
|
160
163
|
return registerModule;
|
|
161
164
|
}
|
|
162
165
|
});
|
|
166
|
+
Object.defineProperty(exports, "validateNow", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
get: function() {
|
|
169
|
+
return validateNow;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
163
172
|
|
|
164
|
-
//# sourceMappingURL=module-
|
|
173
|
+
//# sourceMappingURL=module-Bz83ZnJ5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-Bz83ZnJ5.cjs","names":["classOrMemberDecorator","classAttributes","classOrMemberDecorator","addMissing","classGuards","classInterceptors","applyAttributes","defineModuleMetadata","registerInjectable","InjectableScope"],"sources":["../src/internal/validate-now.mts","../src/attributes/attribute-factory.mts","../src/metadata/attach-classes.mts","../src/guards/use-guards.mts","../src/interceptors/use-interceptors.mts","../src/modules/module.mts"],"sourcesContent":["import type { StandardSchemaIssue, StandardSchemaV1 } from '@navios/di'\n\ntype ValidationResult<Output> =\n | { readonly value: Output; readonly issues?: undefined }\n | { readonly issues: ReadonlyArray<StandardSchemaIssue> }\n\nfunction ignore(): void {}\n\n/**\n * Validates `value` with a schema that has to answer at once. A schema that\n * answers with a promise, or with a thenable of another kind, is an error\n * with `notSynchronous` as its message, and what it rejects with later is\n * handled.\n * @internal\n */\nexport function validateNow<Output>(\n schema: StandardSchemaV1<unknown, Output>,\n value: unknown,\n notSynchronous: string,\n): ValidationResult<Output> {\n const result = schema['~standard'].validate(value) as\n | ValidationResult<Output>\n | PromiseLike<unknown>\n if (typeof (result as Partial<PromiseLike<unknown>>).then === 'function') {\n ;(result as PromiseLike<unknown>).then(undefined, ignore)\n throw new Error(notSynchronous)\n }\n return result as ValidationResult<Output>\n}\n","import type { InferInput, InferOutput, StandardSchemaV1 } from '@navios/di'\n\nimport { validateNow } from '../internal/validate-now.mjs'\nimport { classAttributes } from '../metadata/class-metadata.mjs'\nimport { classOrMemberDecorator } from '../metadata/member-metadata.mjs'\n\nimport type { HandlerInfo } from '../execution/execution-context.mjs'\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype AttributeContext =\n | ClassDecoratorContext\n | ClassMethodDecoratorContext\n | ClassFieldDecoratorContext\n\n/**\n * The result of calling an attribute. It is a decorator for a module, a\n * controller, a handler method or a handler field, and it can also be passed\n * in `handler(endpoint, { attributes: [...] }, fn)`.\n */\nexport interface AttributeApplication {\n (target: any, context: AttributeContext): any\n readonly token: symbol\n readonly value: unknown\n}\n\nexport interface ClassAttribute {\n (): AttributeApplication\n readonly token: symbol\n}\n\nexport interface ClassSchemaAttribute<Schema extends StandardSchemaV1> {\n (value: InferInput<Schema>): AttributeApplication\n readonly token: symbol\n readonly schema: Schema\n}\n\nfunction apply(token: symbol, value: unknown): AttributeApplication {\n const decorator = classOrMemberDecorator(\n `Attribute ${String(token)}`,\n (context) => {\n classAttributes(context).set(token, value)\n },\n (member) => {\n member.attributes.set(token, value)\n },\n )\n return Object.assign(decorator, { token, value })\n}\n\n/**\n * What reading an attribute needs of it. An attribute of either factory, the\n * standard one or the one from `@navios/core/legacy-compat`, has this shape;\n * what calling it returns differs between the two and does not matter here.\n */\ninterface ReadableAttribute {\n readonly token: symbol\n readonly schema?: undefined\n}\n\ninterface ReadableSchemaAttribute<Schema extends StandardSchemaV1> {\n readonly token: symbol\n readonly schema: Schema\n}\n\ntype AttributeSource = HandlerInfo | { attributes: ReadonlyMap<symbol, unknown> }\n\nfunction layers(source: AttributeSource): ReadonlyMap<symbol, unknown>[] {\n const attributes = source.attributes\n if (attributes instanceof Map) {\n return [attributes]\n }\n const route = attributes as HandlerInfo['attributes']\n // Most specific first.\n return [route.handler, route.controller, route.module]\n}\n\n/**\n * Creates and reads attributes: typed metadata attached to modules,\n * controllers and handlers.\n *\n * ```ts\n * export const Public = AttributeFactory.createAttribute(Symbol.for('Public'))\n * export const Roles = AttributeFactory.createAttribute(Symbol.for('Roles'), z.array(z.string()))\n *\n * if (AttributeFactory.has(Public, ctx.handler)) return true\n * const roles = AttributeFactory.get(Roles, ctx.handler) // string[] | null\n * ```\n */\nexport class AttributeFactory {\n static createAttribute(token: symbol): ClassAttribute\n static createAttribute<Schema extends StandardSchemaV1>(\n token: symbol,\n schema: Schema,\n ): ClassSchemaAttribute<Schema>\n static createAttribute(token: symbol, schema?: StandardSchemaV1): any {\n const attribute = (value?: unknown) => {\n if (!schema) {\n return apply(token, true)\n }\n const result = validateNow(\n schema,\n value,\n `[Navios] Attribute ${token.toString()} must use a schema that validates synchronously`,\n )\n if (result.issues) {\n throw new Error(\n `[Navios] Invalid value for attribute ${token.toString()}: ${result.issues\n .map((issue) => issue.message)\n .join('; ')}`,\n )\n }\n return apply(token, result.value)\n }\n return Object.assign(attribute, schema ? { token, schema } : { token })\n }\n\n /**\n * The attribute's value for a handler: the handler's own, else the controller's,\n * else the module's. `null` when none has it.\n */\n static get(attribute: ReadableAttribute, source: AttributeSource): true | null\n static get<Schema extends StandardSchemaV1>(\n attribute: ReadableSchemaAttribute<Schema>,\n source: AttributeSource,\n ): InferOutput<Schema> | null\n static get(attribute: { token: symbol }, source: AttributeSource): unknown {\n for (const layer of layers(source)) {\n if (layer.has(attribute.token)) {\n return layer.get(attribute.token)\n }\n }\n return null\n }\n\n /**\n * Every value of the attribute for a handler, most specific first.\n */\n static getAll(attribute: ReadableAttribute, source: AttributeSource): true[]\n static getAll<Schema extends StandardSchemaV1>(\n attribute: ReadableSchemaAttribute<Schema>,\n source: AttributeSource,\n ): InferOutput<Schema>[]\n static getAll(attribute: { token: symbol }, source: AttributeSource): unknown[] {\n const values: unknown[] = []\n for (const layer of layers(source)) {\n if (layer.has(attribute.token)) {\n values.push(layer.get(attribute.token))\n }\n }\n return values\n }\n\n static has(attribute: { token: symbol }, source: AttributeSource): boolean {\n return layers(source).some((layer) => layer.has(attribute.token))\n }\n}\n","import type { ClassType } from '@navios/di'\n\nimport { addMissing, classGuards, classInterceptors } from './class-metadata.mjs'\nimport { classOrMemberDecorator } from './member-metadata.mjs'\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype AnyMemberContext =\n | ClassDecoratorContext\n | ClassMethodDecoratorContext\n | ClassFieldDecoratorContext\n\n/**\n * The decorator behind `@UseGuards` and `@UseInterceptors`: adds classes to\n * the list of a class or of one of its members.\n * @internal\n */\nexport function attachClasses(\n kind: 'guards' | 'interceptors',\n classes: ClassType[],\n name: string,\n): (target: any, context: AnyMemberContext) => any {\n return classOrMemberDecorator(\n `@${name}`,\n (context) => {\n addMissing(kind === 'guards' ? classGuards(context) : classInterceptors(context), classes)\n },\n (member) => {\n addMissing(member[kind], classes)\n },\n )\n}\n","import { attachClasses } from '../metadata/attach-classes.mjs'\n\nimport type { GuardClass } from './guard.mjs'\n\n/**\n * Adds guards to a module, a controller or a handler. Guards run in the\n * order module, controller, handler, and within one level in the order given.\n *\n * On a class, place it above `@Controller` / `@Module`.\n */\nexport function UseGuards(...guards: GuardClass[]) {\n return attachClasses('guards', guards, 'UseGuards')\n}\n","import { attachClasses } from '../metadata/attach-classes.mjs'\n\nimport type { InterceptorClass } from './interceptor.mjs'\n\n/**\n * Adds interceptors to a module, a controller or a handler. The first one\n * given is the outermost. They run for what the guards let through, unlike the\n * interceptors of the application.\n *\n * On a class, place it above `@Controller` / `@Module`.\n */\nexport function UseInterceptors(...interceptors: InterceptorClass[]) {\n return attachClasses('interceptors', interceptors, 'UseInterceptors')\n}\n","import { InjectableScope, registerInjectable } from '@navios/di'\n\nimport type { ClassType } from '@navios/di'\n\nimport { applyAttributes } from '../attributes/attribute-value.mjs'\n\nimport type { DecoratorMetadata } from '../metadata/decorator-metadata.mjs'\n\nimport { defineModuleMetadata } from './module-metadata.mjs'\n\nimport type { ModuleOptions } from './module-options.mjs'\n\nfunction defineModule<T extends ClassType>(\n target: T,\n context: { metadata?: DecoratorMetadata },\n options: ModuleOptions,\n): T {\n applyAttributes(defineModuleMetadata(target, context, options).attributes, options.attributes)\n registerInjectable(target, { scope: InjectableScope.Singleton })\n return target\n}\n\n/**\n * Marks a class as a module: a group of handlers with shared guards,\n * interceptors and attributes.\n */\nexport function Module(options: ModuleOptions = {}) {\n return <T extends ClassType>(target: T, context: ClassDecoratorContext): T => {\n if (context.kind !== 'class') {\n throw new Error('[Navios] @Module can only be used on classes.')\n }\n return defineModule(target, context, options)\n }\n}\n\n/**\n * Registers a class as a module without decorator syntax.\n */\nexport function registerModule<T extends ClassType>(target: T, options: ModuleOptions = {}): T {\n return defineModule(target, { metadata: {} }, options)\n}\n"],"mappings":";;;AAMA,SAAS,SAAe,CAAC;;;;;;;;AASzB,SAAgB,YACd,QACA,OACA,gBAC0B;CAC1B,MAAM,SAAS,OAAO,YAAY,CAAC,SAAS,KAAK;CAGjD,IAAI,OAAQ,OAAyC,SAAS,YAAY;EACtE,OAAgC,KAAK,KAAA,GAAW,MAAM;EACxD,MAAM,IAAI,MAAM,cAAc;CAChC;CACA,OAAO;AACT;;ACSA,SAAS,MAAM,OAAe,OAAsC;CAClE,MAAM,YAAYA,wBAAAA,uBAChB,aAAa,OAAO,KAAK,MACxB,YAAY;EACXC,wBAAAA,gBAAgB,OAAO,CAAC,CAAC,IAAI,OAAO,KAAK;CAC3C,IACC,WAAW;EACV,OAAO,WAAW,IAAI,OAAO,KAAK;CACpC,CACF;CACA,OAAO,OAAO,OAAO,WAAW;EAAE;EAAO;CAAM,CAAC;AAClD;AAmBA,SAAS,OAAO,QAAyD;CACvE,MAAM,aAAa,OAAO;CAC1B,IAAI,sBAAsB,KACxB,OAAO,CAAC,UAAU;CAEpB,MAAM,QAAQ;CAEd,OAAO;EAAC,MAAM;EAAS,MAAM;EAAY,MAAM;CAAM;AACvD;;;;;;;;;;;;;AAcA,IAAa,mBAAb,MAA8B;CAM5B,OAAO,gBAAgB,OAAe,QAAgC;EACpE,MAAM,aAAa,UAAoB;GACrC,IAAI,CAAC,QACH,OAAO,MAAM,OAAO,IAAI;GAE1B,MAAM,SAAS,YACb,QACA,OACA,sBAAsB,MAAM,SAAS,EAAE,gDACzC;GACA,IAAI,OAAO,QACT,MAAM,IAAI,MACR,wCAAwC,MAAM,SAAS,EAAE,IAAI,OAAO,OACjE,KAAK,UAAU,MAAM,OAAO,CAAC,CAC7B,KAAK,IAAI,GACd;GAEF,OAAO,MAAM,OAAO,OAAO,KAAK;EAClC;EACA,OAAO,OAAO,OAAO,WAAW,SAAS;GAAE;GAAO;EAAO,IAAI,EAAE,MAAM,CAAC;CACxE;CAWA,OAAO,IAAI,WAA8B,QAAkC;EACzE,KAAK,MAAM,SAAS,OAAO,MAAM,GAC/B,IAAI,MAAM,IAAI,UAAU,KAAK,GAC3B,OAAO,MAAM,IAAI,UAAU,KAAK;EAGpC,OAAO;CACT;CAUA,OAAO,OAAO,WAA8B,QAAoC;EAC9E,MAAM,SAAoB,CAAC;EAC3B,KAAK,MAAM,SAAS,OAAO,MAAM,GAC/B,IAAI,MAAM,IAAI,UAAU,KAAK,GAC3B,OAAO,KAAK,MAAM,IAAI,UAAU,KAAK,CAAC;EAG1C,OAAO;CACT;CAEA,OAAO,IAAI,WAA8B,QAAkC;EACzE,OAAO,OAAO,MAAM,CAAC,CAAC,MAAM,UAAU,MAAM,IAAI,UAAU,KAAK,CAAC;CAClE;AACF;;;;;;;AC3IA,SAAgB,cACd,MACA,SACA,MACiD;CACjD,OAAOC,wBAAAA,uBACL,IAAI,SACH,YAAY;EACXC,wBAAAA,WAAW,SAAS,WAAWC,wBAAAA,YAAY,OAAO,IAAIC,wBAAAA,kBAAkB,OAAO,GAAG,OAAO;CAC3F,IACC,WAAW;EACVF,wBAAAA,WAAW,OAAO,OAAO,OAAO;CAClC,CACF;AACF;;;;;;;;ACrBA,SAAgB,UAAU,GAAG,QAAsB;CACjD,OAAO,cAAc,UAAU,QAAQ,WAAW;AACpD;;;;;;;;;ACDA,SAAgB,gBAAgB,GAAG,cAAkC;CACnE,OAAO,cAAc,gBAAgB,cAAc,iBAAiB;AACtE;;ACDA,SAAS,aACP,QACA,SACA,SACG;CACHG,wBAAAA,gBAAgBC,wBAAAA,qBAAqB,QAAQ,SAAS,OAAO,CAAC,CAAC,YAAY,QAAQ,UAAU;CAC7FC,CAAAA,GAAAA,WAAAA,mBAAAA,CAAmB,QAAQ,EAAE,OAAOC,WAAAA,gBAAgB,UAAU,CAAC;CAC/D,OAAO;AACT;;;;;AAMA,SAAgB,OAAO,UAAyB,CAAC,GAAG;CAClD,QAA6B,QAAW,YAAsC;EAC5E,IAAI,QAAQ,SAAS,SACnB,MAAM,IAAI,MAAM,+CAA+C;EAEjE,OAAO,aAAa,QAAQ,SAAS,OAAO;CAC9C;AACF;;;;AAKA,SAAgB,eAAoC,QAAW,UAAyB,CAAC,GAAM;CAC7F,OAAO,aAAa,QAAQ,EAAE,UAAU,CAAC,EAAE,GAAG,OAAO;AACvD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClassType, Provider } from "@navios/di";
|
|
2
|
-
import { n as ExecutionContext } from "./execution-context-
|
|
2
|
+
import { n as ExecutionContext } from "./execution-context-C5F9rojO.mjs";
|
|
3
3
|
/**
|
|
4
4
|
* Wraps a handler. `Ctx` is the context of the transport the interceptor is
|
|
5
5
|
* written for and `Result` what that transport's handlers produce; the
|
|
@@ -48,4 +48,4 @@ interface ModuleOptions {
|
|
|
48
48
|
attributes?: AttributeValue[];
|
|
49
49
|
}
|
|
50
50
|
export { Interceptor as a, AttributeValue as i, Guard as n, InterceptorClass as o, GuardClass as r, ModuleOptions as t };
|
|
51
|
-
//# sourceMappingURL=module-options-
|
|
51
|
+
//# sourceMappingURL=module-options-CSqQUSTm.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-options-
|
|
1
|
+
{"version":3,"file":"module-options-CSqQUSTm.d.mts","names":[],"sources":["../src/interceptors/interceptor.mts","../src/attributes/attribute-value.mts","../src/guards/guard.mts","../src/modules/module-options.mts"],"mappings":";;;;;;;UAOiB,YAAY,YAAY,mBAAmB,kBAAkB;EAC5E,UAAU,KAAK,KAAK,YAAY,QAAQ,UAAU,SAAS,QAAQ;;;KAMzD,2BAA2B,gBAAgB;;KCb3C;WAA4B;WAAwB;;;;;;UCK/C,MAAM,YAAY,mBAAmB;EACpD,YAAY,KAAK,gBAAgB;;;KAMvB,qBAAqB,gBAAgB;;;;;;;;UCAhC;EACf,UAAU;;EAEV,YAAY;;EAEZ,SAAS;;EAET,eAAe;;;;;;;EAOf,aAAa"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ClassType, Provider } from "@navios/di";
|
|
2
|
-
import { n as ExecutionContext } from "./execution-context-
|
|
2
|
+
import { n as ExecutionContext } from "./execution-context-BVSmLkYp.cjs";
|
|
3
3
|
/**
|
|
4
4
|
* Wraps a handler. `Ctx` is the context of the transport the interceptor is
|
|
5
5
|
* written for and `Result` what that transport's handlers produce; the
|
|
@@ -48,4 +48,4 @@ interface ModuleOptions {
|
|
|
48
48
|
attributes?: AttributeValue[];
|
|
49
49
|
}
|
|
50
50
|
export { Interceptor as a, AttributeValue as i, Guard as n, InterceptorClass as o, GuardClass as r, ModuleOptions as t };
|
|
51
|
-
//# sourceMappingURL=module-options-
|
|
51
|
+
//# sourceMappingURL=module-options-DSRBri4J.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"module-options-
|
|
1
|
+
{"version":3,"file":"module-options-DSRBri4J.d.cts","names":[],"sources":["../src/interceptors/interceptor.mts","../src/attributes/attribute-value.mts","../src/guards/guard.mts","../src/modules/module-options.mts"],"mappings":";;;;;;;UAOiB,YAAY,YAAY,mBAAmB,kBAAkB;EAC5E,UAAU,KAAK,KAAK,YAAY,QAAQ,UAAU,SAAS,QAAQ;;;KAMzD,2BAA2B,gBAAgB;;KCb3C;WAA4B;WAAwB;;;;;;UCK/C,MAAM,YAAY,mBAAmB;EACpD,YAAY,KAAK,gBAAgB;;;KAMvB,qBAAqB,gBAAgB;;;;;;;;UCAhC;EACf,UAAU;;EAEV,YAAY;;EAEZ,SAAS;;EAET,eAAe;;;;;;;EAOf,aAAa"}
|
|
@@ -1,16 +1,29 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as defineModuleMetadata } from "./module-metadata-k3RTt20x.mjs";
|
|
1
|
+
import { d as classGuards, f as classInterceptors, l as addMissing, o as defineModuleMetadata, r as classOrMemberDecorator, t as applyAttributes, u as classAttributes } from "./attribute-value-BNiJjxl1.mjs";
|
|
3
2
|
import { InjectableScope, registerInjectable } from "@navios/di";
|
|
3
|
+
// src/internal/validate-now.mts
|
|
4
|
+
function ignore() {}
|
|
5
|
+
/**
|
|
6
|
+
* Validates `value` with a schema that has to answer at once. A schema that
|
|
7
|
+
* answers with a promise, or with a thenable of another kind, is an error
|
|
8
|
+
* with `notSynchronous` as its message, and what it rejects with later is
|
|
9
|
+
* handled.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
function validateNow(schema, value, notSynchronous) {
|
|
13
|
+
const result = schema["~standard"].validate(value);
|
|
14
|
+
if (typeof result.then === "function") {
|
|
15
|
+
result.then(void 0, ignore);
|
|
16
|
+
throw new Error(notSynchronous);
|
|
17
|
+
}
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
4
20
|
// src/attributes/attribute-factory.mts
|
|
5
21
|
function apply(token, value) {
|
|
6
|
-
const decorator = (
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
} else throw new Error("[Navios] Attributes can only be applied to classes, methods and fields");
|
|
12
|
-
return context.kind === "field" ? void 0 : target;
|
|
13
|
-
};
|
|
22
|
+
const decorator = classOrMemberDecorator(`Attribute ${String(token)}`, (context) => {
|
|
23
|
+
classAttributes(context).set(token, value);
|
|
24
|
+
}, (member) => {
|
|
25
|
+
member.attributes.set(token, value);
|
|
26
|
+
});
|
|
14
27
|
return Object.assign(decorator, {
|
|
15
28
|
token,
|
|
16
29
|
value
|
|
@@ -42,11 +55,7 @@ var AttributeFactory = class {
|
|
|
42
55
|
static createAttribute(token, schema) {
|
|
43
56
|
const attribute = (value) => {
|
|
44
57
|
if (!schema) return apply(token, true);
|
|
45
|
-
const result = schema[
|
|
46
|
-
if (result instanceof Promise) {
|
|
47
|
-
result.catch(() => {});
|
|
48
|
-
throw new Error(`[Navios] Attribute ${token.toString()} must use a schema that validates synchronously`);
|
|
49
|
-
}
|
|
58
|
+
const result = validateNow(schema, value, `[Navios] Attribute ${token.toString()} must use a schema that validates synchronously`);
|
|
50
59
|
if (result.issues) throw new Error(`[Navios] Invalid value for attribute ${token.toString()}: ${result.issues.map((issue) => issue.message).join("; ")}`);
|
|
51
60
|
return apply(token, result.value);
|
|
52
61
|
};
|
|
@@ -75,18 +84,11 @@ var AttributeFactory = class {
|
|
|
75
84
|
* @internal
|
|
76
85
|
*/
|
|
77
86
|
function attachClasses(kind, classes, name) {
|
|
78
|
-
return (
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
}
|
|
84
|
-
if (context.kind !== "method" && context.kind !== "field") throw new Error(`[Navios] @${name} can only be used on classes, methods and fields.`);
|
|
85
|
-
if (typeof context.name !== "string") throw new Error(`[Navios] @${name} cannot be used on symbol-named members.`);
|
|
86
|
-
const list = memberMetadata(context, context.name)[kind];
|
|
87
|
-
for (const cls of classes) if (!list.includes(cls)) list.push(cls);
|
|
88
|
-
return context.kind === "field" ? void 0 : target;
|
|
89
|
-
};
|
|
87
|
+
return classOrMemberDecorator(`@${name}`, (context) => {
|
|
88
|
+
addMissing(kind === "guards" ? classGuards(context) : classInterceptors(context), classes);
|
|
89
|
+
}, (member) => {
|
|
90
|
+
addMissing(member[kind], classes);
|
|
91
|
+
});
|
|
90
92
|
}
|
|
91
93
|
// src/guards/use-guards.mts
|
|
92
94
|
/**
|
|
@@ -110,6 +112,11 @@ function UseInterceptors(...interceptors) {
|
|
|
110
112
|
return attachClasses("interceptors", interceptors, "UseInterceptors");
|
|
111
113
|
}
|
|
112
114
|
// src/modules/module.mts
|
|
115
|
+
function defineModule(target, context, options) {
|
|
116
|
+
applyAttributes(defineModuleMetadata(target, context, options).attributes, options.attributes);
|
|
117
|
+
registerInjectable(target, { scope: InjectableScope.Singleton });
|
|
118
|
+
return target;
|
|
119
|
+
}
|
|
113
120
|
/**
|
|
114
121
|
* Marks a class as a module: a group of handlers with shared guards,
|
|
115
122
|
* interceptors and attributes.
|
|
@@ -117,19 +124,15 @@ function UseInterceptors(...interceptors) {
|
|
|
117
124
|
function Module(options = {}) {
|
|
118
125
|
return (target, context) => {
|
|
119
126
|
if (context.kind !== "class") throw new Error("[Navios] @Module can only be used on classes.");
|
|
120
|
-
|
|
121
|
-
registerInjectable(target, { scope: InjectableScope.Singleton });
|
|
122
|
-
return target;
|
|
127
|
+
return defineModule(target, context, options);
|
|
123
128
|
};
|
|
124
129
|
}
|
|
125
130
|
/**
|
|
126
131
|
* Registers a class as a module without decorator syntax.
|
|
127
132
|
*/
|
|
128
133
|
function registerModule(target, options = {}) {
|
|
129
|
-
|
|
130
|
-
registerInjectable(target, { scope: InjectableScope.Singleton });
|
|
131
|
-
return target;
|
|
134
|
+
return defineModule(target, { metadata: {} }, options);
|
|
132
135
|
}
|
|
133
|
-
export { AttributeFactory as a, UseGuards as i, registerModule as n, UseInterceptors as r, Module as t };
|
|
136
|
+
export { AttributeFactory as a, UseGuards as i, registerModule as n, validateNow as o, UseInterceptors as r, Module as t };
|
|
134
137
|
|
|
135
|
-
//# sourceMappingURL=module-
|
|
138
|
+
//# sourceMappingURL=module-zPXwR2qp.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-zPXwR2qp.mjs","names":[],"sources":["../src/internal/validate-now.mts","../src/attributes/attribute-factory.mts","../src/metadata/attach-classes.mts","../src/guards/use-guards.mts","../src/interceptors/use-interceptors.mts","../src/modules/module.mts"],"sourcesContent":["import type { StandardSchemaIssue, StandardSchemaV1 } from '@navios/di'\n\ntype ValidationResult<Output> =\n | { readonly value: Output; readonly issues?: undefined }\n | { readonly issues: ReadonlyArray<StandardSchemaIssue> }\n\nfunction ignore(): void {}\n\n/**\n * Validates `value` with a schema that has to answer at once. A schema that\n * answers with a promise, or with a thenable of another kind, is an error\n * with `notSynchronous` as its message, and what it rejects with later is\n * handled.\n * @internal\n */\nexport function validateNow<Output>(\n schema: StandardSchemaV1<unknown, Output>,\n value: unknown,\n notSynchronous: string,\n): ValidationResult<Output> {\n const result = schema['~standard'].validate(value) as\n | ValidationResult<Output>\n | PromiseLike<unknown>\n if (typeof (result as Partial<PromiseLike<unknown>>).then === 'function') {\n ;(result as PromiseLike<unknown>).then(undefined, ignore)\n throw new Error(notSynchronous)\n }\n return result as ValidationResult<Output>\n}\n","import type { InferInput, InferOutput, StandardSchemaV1 } from '@navios/di'\n\nimport { validateNow } from '../internal/validate-now.mjs'\nimport { classAttributes } from '../metadata/class-metadata.mjs'\nimport { classOrMemberDecorator } from '../metadata/member-metadata.mjs'\n\nimport type { HandlerInfo } from '../execution/execution-context.mjs'\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype AttributeContext =\n | ClassDecoratorContext\n | ClassMethodDecoratorContext\n | ClassFieldDecoratorContext\n\n/**\n * The result of calling an attribute. It is a decorator for a module, a\n * controller, a handler method or a handler field, and it can also be passed\n * in `handler(endpoint, { attributes: [...] }, fn)`.\n */\nexport interface AttributeApplication {\n (target: any, context: AttributeContext): any\n readonly token: symbol\n readonly value: unknown\n}\n\nexport interface ClassAttribute {\n (): AttributeApplication\n readonly token: symbol\n}\n\nexport interface ClassSchemaAttribute<Schema extends StandardSchemaV1> {\n (value: InferInput<Schema>): AttributeApplication\n readonly token: symbol\n readonly schema: Schema\n}\n\nfunction apply(token: symbol, value: unknown): AttributeApplication {\n const decorator = classOrMemberDecorator(\n `Attribute ${String(token)}`,\n (context) => {\n classAttributes(context).set(token, value)\n },\n (member) => {\n member.attributes.set(token, value)\n },\n )\n return Object.assign(decorator, { token, value })\n}\n\n/**\n * What reading an attribute needs of it. An attribute of either factory, the\n * standard one or the one from `@navios/core/legacy-compat`, has this shape;\n * what calling it returns differs between the two and does not matter here.\n */\ninterface ReadableAttribute {\n readonly token: symbol\n readonly schema?: undefined\n}\n\ninterface ReadableSchemaAttribute<Schema extends StandardSchemaV1> {\n readonly token: symbol\n readonly schema: Schema\n}\n\ntype AttributeSource = HandlerInfo | { attributes: ReadonlyMap<symbol, unknown> }\n\nfunction layers(source: AttributeSource): ReadonlyMap<symbol, unknown>[] {\n const attributes = source.attributes\n if (attributes instanceof Map) {\n return [attributes]\n }\n const route = attributes as HandlerInfo['attributes']\n // Most specific first.\n return [route.handler, route.controller, route.module]\n}\n\n/**\n * Creates and reads attributes: typed metadata attached to modules,\n * controllers and handlers.\n *\n * ```ts\n * export const Public = AttributeFactory.createAttribute(Symbol.for('Public'))\n * export const Roles = AttributeFactory.createAttribute(Symbol.for('Roles'), z.array(z.string()))\n *\n * if (AttributeFactory.has(Public, ctx.handler)) return true\n * const roles = AttributeFactory.get(Roles, ctx.handler) // string[] | null\n * ```\n */\nexport class AttributeFactory {\n static createAttribute(token: symbol): ClassAttribute\n static createAttribute<Schema extends StandardSchemaV1>(\n token: symbol,\n schema: Schema,\n ): ClassSchemaAttribute<Schema>\n static createAttribute(token: symbol, schema?: StandardSchemaV1): any {\n const attribute = (value?: unknown) => {\n if (!schema) {\n return apply(token, true)\n }\n const result = validateNow(\n schema,\n value,\n `[Navios] Attribute ${token.toString()} must use a schema that validates synchronously`,\n )\n if (result.issues) {\n throw new Error(\n `[Navios] Invalid value for attribute ${token.toString()}: ${result.issues\n .map((issue) => issue.message)\n .join('; ')}`,\n )\n }\n return apply(token, result.value)\n }\n return Object.assign(attribute, schema ? { token, schema } : { token })\n }\n\n /**\n * The attribute's value for a handler: the handler's own, else the controller's,\n * else the module's. `null` when none has it.\n */\n static get(attribute: ReadableAttribute, source: AttributeSource): true | null\n static get<Schema extends StandardSchemaV1>(\n attribute: ReadableSchemaAttribute<Schema>,\n source: AttributeSource,\n ): InferOutput<Schema> | null\n static get(attribute: { token: symbol }, source: AttributeSource): unknown {\n for (const layer of layers(source)) {\n if (layer.has(attribute.token)) {\n return layer.get(attribute.token)\n }\n }\n return null\n }\n\n /**\n * Every value of the attribute for a handler, most specific first.\n */\n static getAll(attribute: ReadableAttribute, source: AttributeSource): true[]\n static getAll<Schema extends StandardSchemaV1>(\n attribute: ReadableSchemaAttribute<Schema>,\n source: AttributeSource,\n ): InferOutput<Schema>[]\n static getAll(attribute: { token: symbol }, source: AttributeSource): unknown[] {\n const values: unknown[] = []\n for (const layer of layers(source)) {\n if (layer.has(attribute.token)) {\n values.push(layer.get(attribute.token))\n }\n }\n return values\n }\n\n static has(attribute: { token: symbol }, source: AttributeSource): boolean {\n return layers(source).some((layer) => layer.has(attribute.token))\n }\n}\n","import type { ClassType } from '@navios/di'\n\nimport { addMissing, classGuards, classInterceptors } from './class-metadata.mjs'\nimport { classOrMemberDecorator } from './member-metadata.mjs'\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\n\ntype AnyMemberContext =\n | ClassDecoratorContext\n | ClassMethodDecoratorContext\n | ClassFieldDecoratorContext\n\n/**\n * The decorator behind `@UseGuards` and `@UseInterceptors`: adds classes to\n * the list of a class or of one of its members.\n * @internal\n */\nexport function attachClasses(\n kind: 'guards' | 'interceptors',\n classes: ClassType[],\n name: string,\n): (target: any, context: AnyMemberContext) => any {\n return classOrMemberDecorator(\n `@${name}`,\n (context) => {\n addMissing(kind === 'guards' ? classGuards(context) : classInterceptors(context), classes)\n },\n (member) => {\n addMissing(member[kind], classes)\n },\n )\n}\n","import { attachClasses } from '../metadata/attach-classes.mjs'\n\nimport type { GuardClass } from './guard.mjs'\n\n/**\n * Adds guards to a module, a controller or a handler. Guards run in the\n * order module, controller, handler, and within one level in the order given.\n *\n * On a class, place it above `@Controller` / `@Module`.\n */\nexport function UseGuards(...guards: GuardClass[]) {\n return attachClasses('guards', guards, 'UseGuards')\n}\n","import { attachClasses } from '../metadata/attach-classes.mjs'\n\nimport type { InterceptorClass } from './interceptor.mjs'\n\n/**\n * Adds interceptors to a module, a controller or a handler. The first one\n * given is the outermost. They run for what the guards let through, unlike the\n * interceptors of the application.\n *\n * On a class, place it above `@Controller` / `@Module`.\n */\nexport function UseInterceptors(...interceptors: InterceptorClass[]) {\n return attachClasses('interceptors', interceptors, 'UseInterceptors')\n}\n","import { InjectableScope, registerInjectable } from '@navios/di'\n\nimport type { ClassType } from '@navios/di'\n\nimport { applyAttributes } from '../attributes/attribute-value.mjs'\n\nimport type { DecoratorMetadata } from '../metadata/decorator-metadata.mjs'\n\nimport { defineModuleMetadata } from './module-metadata.mjs'\n\nimport type { ModuleOptions } from './module-options.mjs'\n\nfunction defineModule<T extends ClassType>(\n target: T,\n context: { metadata?: DecoratorMetadata },\n options: ModuleOptions,\n): T {\n applyAttributes(defineModuleMetadata(target, context, options).attributes, options.attributes)\n registerInjectable(target, { scope: InjectableScope.Singleton })\n return target\n}\n\n/**\n * Marks a class as a module: a group of handlers with shared guards,\n * interceptors and attributes.\n */\nexport function Module(options: ModuleOptions = {}) {\n return <T extends ClassType>(target: T, context: ClassDecoratorContext): T => {\n if (context.kind !== 'class') {\n throw new Error('[Navios] @Module can only be used on classes.')\n }\n return defineModule(target, context, options)\n }\n}\n\n/**\n * Registers a class as a module without decorator syntax.\n */\nexport function registerModule<T extends ClassType>(target: T, options: ModuleOptions = {}): T {\n return defineModule(target, { metadata: {} }, options)\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// src/transports/settled-within.mts
|
|
2
|
+
/** The longest delay a timer takes; a longer one fires at once. */
|
|
3
|
+
const MAX_DELAY_MS = 2 ** 31 - 1;
|
|
4
|
+
/**
|
|
5
|
+
* Whether `work` settles within `ms`, or within `MAX_DELAY_MS` when `ms` is
|
|
6
|
+
* longer. Rejects when it rejects in time; a later rejection is dropped.
|
|
7
|
+
*/
|
|
8
|
+
async function settledWithin(work, ms) {
|
|
9
|
+
let timer;
|
|
10
|
+
const timeout = new Promise((resolve) => {
|
|
11
|
+
timer = setTimeout(resolve, Math.min(ms, MAX_DELAY_MS), false);
|
|
12
|
+
});
|
|
13
|
+
try {
|
|
14
|
+
return await Promise.race([Promise.resolve(work).then(() => true), timeout]);
|
|
15
|
+
} finally {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(exports, "MAX_DELAY_MS", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function() {
|
|
22
|
+
return MAX_DELAY_MS;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "settledWithin", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function() {
|
|
28
|
+
return settledWithin;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=settled-within-B6gpu2XW.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settled-within-B6gpu2XW.cjs","names":[],"sources":["../src/transports/settled-within.mts"],"sourcesContent":["/** The longest delay a timer takes; a longer one fires at once. */\nexport const MAX_DELAY_MS = 2 ** 31 - 1\n\n/**\n * Whether `work` settles within `ms`, or within `MAX_DELAY_MS` when `ms` is\n * longer. Rejects when it rejects in time; a later rejection is dropped.\n */\nexport async function settledWithin(work: PromiseLike<unknown>, ms: number): Promise<boolean> {\n let timer: ReturnType<typeof setTimeout> | undefined\n const timeout = new Promise<false>((resolve) => {\n timer = setTimeout(resolve, Math.min(ms, MAX_DELAY_MS), false)\n })\n try {\n return await Promise.race([Promise.resolve(work).then(() => true), timeout])\n } finally {\n clearTimeout(timer)\n }\n}\n"],"mappings":";;AACA,MAAa,eAAe,KAAK,KAAK;;;;;AAMtC,eAAsB,cAAc,MAA4B,IAA8B;CAC5F,IAAI;CACJ,MAAM,UAAU,IAAI,SAAgB,YAAY;EAC9C,QAAQ,WAAW,SAAS,KAAK,IAAI,IAAI,YAAY,GAAG,KAAK;CAC/D,CAAC;CACD,IAAI;EACF,OAAO,MAAM,QAAQ,KAAK,CAAC,QAAQ,QAAQ,IAAI,CAAC,CAAC,WAAW,IAAI,GAAG,OAAO,CAAC;CAC7E,UAAU;EACR,aAAa,KAAK;CACpB;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/transports/settled-within.mts
|
|
2
|
+
/** The longest delay a timer takes; a longer one fires at once. */
|
|
3
|
+
const MAX_DELAY_MS = 2 ** 31 - 1;
|
|
4
|
+
/**
|
|
5
|
+
* Whether `work` settles within `ms`, or within `MAX_DELAY_MS` when `ms` is
|
|
6
|
+
* longer. Rejects when it rejects in time; a later rejection is dropped.
|
|
7
|
+
*/
|
|
8
|
+
async function settledWithin(work, ms) {
|
|
9
|
+
let timer;
|
|
10
|
+
const timeout = new Promise((resolve) => {
|
|
11
|
+
timer = setTimeout(resolve, Math.min(ms, MAX_DELAY_MS), false);
|
|
12
|
+
});
|
|
13
|
+
try {
|
|
14
|
+
return await Promise.race([Promise.resolve(work).then(() => true), timeout]);
|
|
15
|
+
} finally {
|
|
16
|
+
clearTimeout(timer);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export { settledWithin as n, MAX_DELAY_MS as t };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=settled-within-Bc2pj8WB.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settled-within-Bc2pj8WB.mjs","names":[],"sources":["../src/transports/settled-within.mts"],"sourcesContent":["/** The longest delay a timer takes; a longer one fires at once. */\nexport const MAX_DELAY_MS = 2 ** 31 - 1\n\n/**\n * Whether `work` settles within `ms`, or within `MAX_DELAY_MS` when `ms` is\n * longer. Rejects when it rejects in time; a later rejection is dropped.\n */\nexport async function settledWithin(work: PromiseLike<unknown>, ms: number): Promise<boolean> {\n let timer: ReturnType<typeof setTimeout> | undefined\n const timeout = new Promise<false>((resolve) => {\n timer = setTimeout(resolve, Math.min(ms, MAX_DELAY_MS), false)\n })\n try {\n return await Promise.race([Promise.resolve(work).then(() => true), timeout])\n } finally {\n clearTimeout(timer)\n }\n}\n"],"mappings":";;AACA,MAAa,eAAe,KAAK,KAAK;;;;;AAMtC,eAAsB,cAAc,MAA4B,IAA8B;CAC5F,IAAI;CACJ,MAAM,UAAU,IAAI,SAAgB,YAAY;EAC9C,QAAQ,WAAW,SAAS,KAAK,IAAI,IAAI,YAAY,GAAG,KAAK;CAC/D,CAAC;CACD,IAAI;EACF,OAAO,MAAM,QAAQ,KAAK,CAAC,QAAQ,QAAQ,IAAI,CAAC,CAAC,WAAW,IAAI,GAAG,OAAO,CAAC;CAC7E,UAAU;EACR,aAAa,KAAK;CACpB;AACF"}
|
package/lib/testing/index.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
require("../attribute-value-
|
|
3
|
-
const require_execution_context_token = require("../execution-context-token
|
|
2
|
+
require("../attribute-value-Cux5HhOL.cjs");
|
|
3
|
+
const require_execution_context_token = require("../execution-context-token--cKS4cJv.cjs");
|
|
4
4
|
let _navios_di_legacy_compat = require("@navios/di/legacy-compat");
|
|
5
|
-
const require_basic_execution_context = require("../basic-execution-context-
|
|
5
|
+
const require_basic_execution_context = require("../basic-execution-context-5uq2DvEA.cjs");
|
|
6
6
|
// src/testing/fake-transport.mts
|
|
7
7
|
let runs = 0;
|
|
8
8
|
/**
|
|
@@ -37,23 +37,20 @@ const fakeTransport = require_basic_execution_context.defineTransport({
|
|
|
37
37
|
setup(graph) {
|
|
38
38
|
log.push(`${kind}:setup`);
|
|
39
39
|
if (options.failSetup) throw new Error(`${kind} setup failed`);
|
|
40
|
-
for (const node of graph) for (const handler of
|
|
41
|
-
const owner = attachedTo(handler);
|
|
40
|
+
for (const node of graph) for (const handler of require_execution_context_token.moduleClasses(node, entry)) {
|
|
42
41
|
const chain = require_basic_execution_context.handlerChain({
|
|
43
42
|
application: host.interceptors,
|
|
44
43
|
node,
|
|
45
|
-
|
|
44
|
+
controller: handler,
|
|
45
|
+
owner: attachedTo(handler),
|
|
46
|
+
handlerName: "run",
|
|
46
47
|
member: {
|
|
47
48
|
guards: [],
|
|
48
49
|
interceptors: [],
|
|
49
50
|
attributes: /* @__PURE__ */ new Map()
|
|
50
51
|
}
|
|
51
52
|
});
|
|
52
|
-
found.set(handler,
|
|
53
|
-
node,
|
|
54
|
-
owner,
|
|
55
|
-
chain
|
|
56
|
-
});
|
|
53
|
+
found.set(handler, chain);
|
|
57
54
|
}
|
|
58
55
|
},
|
|
59
56
|
start() {
|
|
@@ -65,35 +62,16 @@ const fakeTransport = require_basic_execution_context.defineTransport({
|
|
|
65
62
|
if (options.failStop) throw new Error(`${kind} stop failed`);
|
|
66
63
|
},
|
|
67
64
|
async run(handler) {
|
|
68
|
-
const
|
|
69
|
-
if (!
|
|
70
|
-
const { node, owner, chain } = known;
|
|
65
|
+
const chain = found.get(handler);
|
|
66
|
+
if (!chain) throw new Error(`${handler.name} is not a handler of the ${kind} transport`);
|
|
71
67
|
const resolved = await require_basic_execution_context.resolveChain(host.container, chain);
|
|
72
68
|
const ctx = new require_basic_execution_context.BasicExecutionContext({
|
|
73
69
|
kind,
|
|
74
70
|
id: `${kind}-${++runs}`,
|
|
75
71
|
host: host.contextHost,
|
|
76
|
-
handler:
|
|
77
|
-
module: node.module,
|
|
78
|
-
controller: handler,
|
|
79
|
-
handlerName: "run",
|
|
80
|
-
guards: chain.guards,
|
|
81
|
-
interceptors: chain.interceptors,
|
|
82
|
-
attributes: {
|
|
83
|
-
handler: /* @__PURE__ */ new Map(),
|
|
84
|
-
controller: owner.attributes,
|
|
85
|
-
module: node.attributes
|
|
86
|
-
}
|
|
87
|
-
}
|
|
72
|
+
handler: chain.info
|
|
88
73
|
});
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
return await require_basic_execution_context.runChain(ctx, resolved, () => true, () => false);
|
|
92
|
-
} finally {
|
|
93
|
-
await ctx.finish();
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
return host.asyncContext ? require_execution_context_token.runInContext(ctx, execute) : execute();
|
|
74
|
+
return require_basic_execution_context.executeChain(host, ctx, resolved, () => true, () => false);
|
|
97
75
|
}
|
|
98
76
|
};
|
|
99
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["createClassContext","describeHandlerClass","defineTransport","handlerChain","resolveChain","BasicExecutionContext","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["createClassContext","describeHandlerClass","defineTransport","moduleClasses","handlerChain","resolveChain","BasicExecutionContext","executeChain"],"sources":["../../src/testing/fake-transport.mts"],"sourcesContent":["import { createClassContext } from '@navios/di/legacy-compat'\n\nimport type { ClassType } from '@navios/di'\n\nimport { BasicExecutionContext } from '../execution/basic-execution-context.mjs'\nimport { handlerChain } from '../metadata/handler-chain.mjs'\nimport { describeHandlerClass } from '../metadata/handler-class.mjs'\nimport { executeChain, resolveChain } from '../metadata/run-chain.mjs'\nimport { moduleClasses } from '../modules/module-graph.mjs'\nimport { defineTransport } from '../transports/transport.mjs'\n\nimport type { HandlerChain } from '../metadata/handler-chain.mjs'\nimport type { HandlerExtras } from '../metadata/member-metadata.mjs'\nimport type { Transport, TransportHost } from '../transports/transport.mjs'\n\nexport interface FakeTransportOptions {\n /** The `kind` of the contexts this transport creates. */\n kind: string\n /** The `@Module` option this transport reads its handler classes from. */\n entry: string\n /** Receives `<kind>:create`, `:setup`, `:start` and `:stop`. */\n log: string[]\n failSetup?: boolean\n failStart?: boolean\n failStop?: boolean\n}\n\nexport interface FakeTransport extends Transport {\n /** The handler classes found in the graph, in graph order. */\n readonly handlers: ClassType[]\n /**\n * Runs what applies to a handler class, as a transport runs it for a handler\n * that does nothing: the application's interceptors, the guards, the\n * interceptors of the module and the class. Resolves to whether every guard\n * allowed it.\n */\n run(handler: ClassType): Promise<boolean>\n}\n\nlet runs = 0\n\n/**\n * What decorators attached to a class, of either kind, without a decorator of\n * the transport's own having asked for it.\n */\nfunction attachedTo(target: ClassType): HandlerExtras {\n const symbol = (Symbol as { metadata?: symbol }).metadata\n const standard = symbol && (target as unknown as Record<symbol, object | undefined>)[symbol]\n const { metadata } = createClassContext(target)\n const [first, second] = [standard, metadata].map((from) =>\n // Read through an object of its own: reading adds what is missing.\n describeHandlerClass({ metadata: Object.create(from ?? null) }),\n )\n return {\n guards: [...first.guards, ...second.guards],\n interceptors: [...first.interceptors, ...second.interceptors],\n attributes: new Map([...first.attributes, ...second.attributes]),\n }\n}\n\n/**\n * A transport for tests: it records its lifecycle and can run the guards and\n * interceptors of a handler class with a context of its own kind.\n */\nexport const fakeTransport = defineTransport<FakeTransportOptions, FakeTransport>({\n name: 'fake',\n create(host: TransportHost, options) {\n const { kind, entry, log } = options\n const found = new Map<ClassType, HandlerChain>()\n log.push(`${kind}:create`)\n return {\n get handlers() {\n return [...found.keys()]\n },\n setup(graph) {\n log.push(`${kind}:setup`)\n if (options.failSetup) {\n throw new Error(`${kind} setup failed`)\n }\n for (const node of graph) {\n for (const handler of moduleClasses(node, entry)) {\n const chain = handlerChain({\n application: host.interceptors,\n node,\n controller: handler,\n owner: attachedTo(handler),\n handlerName: 'run',\n member: { guards: [], interceptors: [], attributes: new Map() },\n })\n found.set(handler, chain)\n }\n }\n },\n start() {\n log.push(`${kind}:start`)\n if (options.failStart) {\n throw new Error(`${kind} start failed`)\n }\n },\n async stop() {\n log.push(`${kind}:stop`)\n if (options.failStop) {\n throw new Error(`${kind} stop failed`)\n }\n },\n async run(handler) {\n const chain = found.get(handler)\n if (!chain) {\n throw new Error(`${handler.name} is not a handler of the ${kind} transport`)\n }\n const resolved = await resolveChain<BasicExecutionContext, boolean>(host.container, chain)\n const ctx = new BasicExecutionContext({\n kind,\n id: `${kind}-${++runs}`,\n host: host.contextHost,\n handler: chain.info,\n })\n return executeChain(\n host,\n ctx,\n resolved,\n () => true,\n () => false,\n )\n },\n }\n },\n})\n"],"mappings":";;;;;;AAuCA,IAAI,OAAO;;;;;AAMX,SAAS,WAAW,QAAkC;CACpD,MAAM,SAAU,OAAiC;CACjD,MAAM,WAAW,UAAW,OAAyD;CACrF,MAAM,EAAE,cAAA,GAAaA,yBAAAA,mBAAAA,CAAmB,MAAM;CAC9C,MAAM,CAAC,OAAO,UAAU,CAAC,UAAU,QAAQ,CAAC,CAAC,KAAK,SAEhDC,gCAAAA,qBAAqB,EAAE,UAAU,OAAO,OAAO,QAAQ,IAAI,EAAE,CAAC,CAChE;CACA,OAAO;EACL,QAAQ,CAAC,GAAG,MAAM,QAAQ,GAAG,OAAO,MAAM;EAC1C,cAAc,CAAC,GAAG,MAAM,cAAc,GAAG,OAAO,YAAY;EAC5D,YAAY,IAAI,IAAI,CAAC,GAAG,MAAM,YAAY,GAAG,OAAO,UAAU,CAAC;CACjE;AACF;;;;;AAMA,MAAa,gBAAgBC,gCAAAA,gBAAqD;CAChF,MAAM;CACN,OAAO,MAAqB,SAAS;EACnC,MAAM,EAAE,MAAM,OAAO,QAAQ;EAC7B,MAAM,wBAAQ,IAAI,IAA6B;EAC/C,IAAI,KAAK,GAAG,KAAK,QAAQ;EACzB,OAAO;GACL,IAAI,WAAW;IACb,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC;GACzB;GACA,MAAM,OAAO;IACX,IAAI,KAAK,GAAG,KAAK,OAAO;IACxB,IAAI,QAAQ,WACV,MAAM,IAAI,MAAM,GAAG,KAAK,cAAc;IAExC,KAAK,MAAM,QAAQ,OACjB,KAAK,MAAM,WAAWC,gCAAAA,cAAc,MAAM,KAAK,GAAG;KAChD,MAAM,QAAQC,gCAAAA,aAAa;MACzB,aAAa,KAAK;MAClB;MACA,YAAY;MACZ,OAAO,WAAW,OAAO;MACzB,aAAa;MACb,QAAQ;OAAE,QAAQ,CAAC;OAAG,cAAc,CAAC;OAAG,4BAAY,IAAI,IAAI;MAAE;KAChE,CAAC;KACD,MAAM,IAAI,SAAS,KAAK;IAC1B;GAEJ;GACA,QAAQ;IACN,IAAI,KAAK,GAAG,KAAK,OAAO;IACxB,IAAI,QAAQ,WACV,MAAM,IAAI,MAAM,GAAG,KAAK,cAAc;GAE1C;GACA,MAAM,OAAO;IACX,IAAI,KAAK,GAAG,KAAK,MAAM;IACvB,IAAI,QAAQ,UACV,MAAM,IAAI,MAAM,GAAG,KAAK,aAAa;GAEzC;GACA,MAAM,IAAI,SAAS;IACjB,MAAM,QAAQ,MAAM,IAAI,OAAO;IAC/B,IAAI,CAAC,OACH,MAAM,IAAI,MAAM,GAAG,QAAQ,KAAK,2BAA2B,KAAK,WAAW;IAE7E,MAAM,WAAW,MAAMC,gCAAAA,aAA6C,KAAK,WAAW,KAAK;IACzF,MAAM,MAAM,IAAIC,gCAAAA,sBAAsB;KACpC;KACA,IAAI,GAAG,KAAK,GAAG,EAAE;KACjB,MAAM,KAAK;KACX,SAAS,MAAM;IACjB,CAAC;IACD,OAAOC,gCAAAA,aACL,MACA,KACA,gBACM,YACA,KACR;GACF;EACF;CACF;AACF,CAAC"}
|
package/lib/testing/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import "../execution-context-
|
|
2
|
-
import {
|
|
1
|
+
import "../execution-context-BVSmLkYp.cjs";
|
|
2
|
+
import { i as Transport, m as createContextHost, n as enableAsyncContext, o as TransportFactory, p as ContextHost } from "../async-context-RsWmy2Hi.cjs";
|
|
3
3
|
import { ClassType } from "@navios/di";
|
|
4
4
|
interface FakeTransportOptions {
|
|
5
5
|
/** The `kind` of the contexts this transport creates. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":["_$___transports_transport_mjs0.TransportFactory"],"sources":["../../src/testing/fake-transport.mts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":["_$___transports_transport_mjs0.TransportFactory"],"sources":["../../src/testing/fake-transport.mts"],"mappings":";;;UAeiB;;EAEf;;EAEA;;EAEA;EACA;EACA;EACA;;UAGe,sBAAsB;;WAE5B,UAAU;;;;;;;EAOnB,IAAI,SAAS,YAAY;;;;;;qBA4Bd,eAAaA,iBAAA,sBAAA"}
|
package/lib/testing/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Transport, m as createContextHost, n as enableAsyncContext, o as TransportFactory, p as ContextHost } from "../async-context-BAdt7bno.mjs";
|
|
2
2
|
import { ClassType } from "@navios/di";
|
|
3
3
|
interface FakeTransportOptions {
|
|
4
4
|
/** The `kind` of the contexts this transport creates. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":["_$___transports_transport_mjs0.TransportFactory"],"sources":["../../src/testing/fake-transport.mts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["_$___transports_transport_mjs0.TransportFactory"],"sources":["../../src/testing/fake-transport.mts"],"mappings":";;UAeiB;;EAEf;;EAEA;;EAEA;EACA;EACA;EACA;;UAGe,sBAAsB;;WAE5B,UAAU;;;;;;;EAOnB,IAAI,SAAS,YAAY;;;;;;qBA4Bd,eAAaA,iBAAA,sBAAA"}
|