@tstdl/base 0.86.0-beta8 → 0.86.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/injector/injector.js +2 -2
- package/module/modules/web-server.module.js +0 -2
- package/object-storage/object-storage-provider.d.ts +1 -1
- package/object-storage/s3/s3.object-storage-provider.d.ts +1 -6
- package/object-storage/s3/s3.object-storage-provider.js +2 -12
- package/object-storage/s3/s3.object-storage.js +4 -1
- package/package.json +2 -2
- package/_container/container.d.ts +0 -99
- package/_container/container.js +0 -443
- package/_container/decorators.d.ts +0 -76
- package/_container/decorators.js +0 -110
- package/_container/index.d.ts +0 -10
- package/_container/index.js +0 -27
- package/_container/interfaces.d.ts +0 -16
- package/_container/interfaces.js +0 -26
- package/_container/provider.d.ts +0 -35
- package/_container/provider.js +0 -60
- package/_container/resolve-chain.d.ts +0 -27
- package/_container/resolve-chain.js +0 -105
- package/_container/resolve.error.d.ts +0 -5
- package/_container/resolve.error.js +0 -36
- package/_container/token.d.ts +0 -18
- package/_container/token.js +0 -41
- package/_container/type-info.d.ts +0 -18
- package/_container/type-info.js +0 -16
- package/_container/types.d.ts +0 -9
- package/_container/types.js +0 -16
- package/_container/utils.d.ts +0 -3
- package/_container/utils.js +0 -44
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export declare const resolveArgumentType: unique symbol;
|
|
2
|
-
export declare const afterResolve: unique symbol;
|
|
3
|
-
export type InjectableArgument<T, Fallback> = T extends Injectable<infer A> ? A : Fallback;
|
|
4
|
-
export interface Injectable<T = unknown> {
|
|
5
|
-
/**
|
|
6
|
-
* type of resolve argument
|
|
7
|
-
* @deprecated only used for type inference
|
|
8
|
-
*/
|
|
9
|
-
readonly [resolveArgumentType]: T;
|
|
10
|
-
}
|
|
11
|
-
export interface AfterResolve {
|
|
12
|
-
/**
|
|
13
|
-
* called after resolve through container
|
|
14
|
-
*/
|
|
15
|
-
[afterResolve](): void | Promise<void>;
|
|
16
|
-
}
|
package/_container/interfaces.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var interfaces_exports = {};
|
|
20
|
-
__export(interfaces_exports, {
|
|
21
|
-
afterResolve: () => afterResolve,
|
|
22
|
-
resolveArgumentType: () => resolveArgumentType
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(interfaces_exports);
|
|
25
|
-
const resolveArgumentType = Symbol("resolveArgumentType");
|
|
26
|
-
const afterResolve = Symbol("after resolve");
|
package/_container/provider.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { Constructor } from '../types.js';
|
|
2
|
-
import type { InjectableArgument } from './interfaces.js';
|
|
3
|
-
import type { InjectionToken } from './token.js';
|
|
4
|
-
import type { ResolveContext } from './types.js';
|
|
5
|
-
export type Factory<T, A = any> = (argument: InjectableArgument<T, A> | undefined, context: ResolveContext) => T | Promise<T>;
|
|
6
|
-
export type Provider<T = any, A = any> = ClassProvider<T> | ValueProvider<T> | TokenProvider<T, A> | FactoryProvider<T, A>;
|
|
7
|
-
export type ClassProvider<T = any> = {
|
|
8
|
-
useClass: Constructor<T>;
|
|
9
|
-
};
|
|
10
|
-
export type ValueProvider<T = any> = {
|
|
11
|
-
useValue: T;
|
|
12
|
-
};
|
|
13
|
-
export type TokenProvider<T = any, A = any> = {
|
|
14
|
-
useToken: InjectionToken<T, A>;
|
|
15
|
-
useTokenProvider?: undefined;
|
|
16
|
-
argument?: InjectableArgument<T, A>;
|
|
17
|
-
argumentProvider?: () => InjectableArgument<T, A> | Promise<InjectableArgument<T, A>>;
|
|
18
|
-
} | {
|
|
19
|
-
useToken?: undefined;
|
|
20
|
-
useTokenProvider: () => InjectionToken<T, A> | Promise<InjectionToken<T, A>>;
|
|
21
|
-
argument?: InjectableArgument<T, A>;
|
|
22
|
-
argumentProvider?: () => InjectableArgument<T, A> | Promise<InjectableArgument<T, A>>;
|
|
23
|
-
};
|
|
24
|
-
export type FactoryProvider<T = any, A = unknown> = {
|
|
25
|
-
useFactory: Factory<T, A>;
|
|
26
|
-
};
|
|
27
|
-
export declare function classProvider<T>(constructor: Constructor<T>): ClassProvider<T>;
|
|
28
|
-
export declare function valueProvider<T>(value: T): ValueProvider<T>;
|
|
29
|
-
export declare function tokenProvider<T, A>(token: InjectionToken<T, A>, argument?: InjectableArgument<T, A>): TokenProvider<T>;
|
|
30
|
-
export declare function factoryProvider<T, A>(factory: Factory<T, A>): FactoryProvider<T, A>;
|
|
31
|
-
export declare function isClassProvider<T>(value: unknown): value is ClassProvider<T>;
|
|
32
|
-
export declare function isValueProvider<T>(value: unknown): value is ValueProvider<T>;
|
|
33
|
-
export declare function isTokenProvider<T>(value: unknown): value is TokenProvider<T>;
|
|
34
|
-
export declare function isFactoryProvider<T, A>(value: unknown): value is FactoryProvider<T, A>;
|
|
35
|
-
export declare function isProvider<T, A>(value: unknown): value is Provider<T, A>;
|
package/_container/provider.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var provider_exports = {};
|
|
20
|
-
__export(provider_exports, {
|
|
21
|
-
classProvider: () => classProvider,
|
|
22
|
-
factoryProvider: () => factoryProvider,
|
|
23
|
-
isClassProvider: () => isClassProvider,
|
|
24
|
-
isFactoryProvider: () => isFactoryProvider,
|
|
25
|
-
isProvider: () => isProvider,
|
|
26
|
-
isTokenProvider: () => isTokenProvider,
|
|
27
|
-
isValueProvider: () => isValueProvider,
|
|
28
|
-
tokenProvider: () => tokenProvider,
|
|
29
|
-
valueProvider: () => valueProvider
|
|
30
|
-
});
|
|
31
|
-
module.exports = __toCommonJS(provider_exports);
|
|
32
|
-
var import_object = require("../utils/object/object.js");
|
|
33
|
-
var import_type_guards = require("../utils/type-guards.js");
|
|
34
|
-
function classProvider(constructor) {
|
|
35
|
-
return { useClass: constructor };
|
|
36
|
-
}
|
|
37
|
-
function valueProvider(value) {
|
|
38
|
-
return { useValue: value };
|
|
39
|
-
}
|
|
40
|
-
function tokenProvider(token, argument) {
|
|
41
|
-
return { useToken: token, argument };
|
|
42
|
-
}
|
|
43
|
-
function factoryProvider(factory) {
|
|
44
|
-
return { useFactory: factory };
|
|
45
|
-
}
|
|
46
|
-
function isClassProvider(value) {
|
|
47
|
-
return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useClass");
|
|
48
|
-
}
|
|
49
|
-
function isValueProvider(value) {
|
|
50
|
-
return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useValue");
|
|
51
|
-
}
|
|
52
|
-
function isTokenProvider(value) {
|
|
53
|
-
return (0, import_type_guards.isObject)(value) && ((0, import_object.hasOwnProperty)(value, "useToken") || (0, import_object.hasOwnProperty)(value, "useTokenProvider"));
|
|
54
|
-
}
|
|
55
|
-
function isFactoryProvider(value) {
|
|
56
|
-
return (0, import_type_guards.isObject)(value) && (0, import_object.hasOwnProperty)(value, "useFactory");
|
|
57
|
-
}
|
|
58
|
-
function isProvider(value) {
|
|
59
|
-
return (0, import_type_guards.isObject)(value) && (isClassProvider(value) || isValueProvider(value) || isTokenProvider(value) || isFactoryProvider(value));
|
|
60
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { AbstractConstructor } from '../types.js';
|
|
2
|
-
import type { InjectionToken } from './token.js';
|
|
3
|
-
export type ResolveChainNodeBase<Type extends string> = {
|
|
4
|
-
type: Type;
|
|
5
|
-
};
|
|
6
|
-
export type ResolveChainNode = ResolveChainNodeBase<'token'> & {
|
|
7
|
-
token: InjectionToken;
|
|
8
|
-
} | ResolveChainNodeBase<'parameter'> & {
|
|
9
|
-
constructor: AbstractConstructor;
|
|
10
|
-
index: number;
|
|
11
|
-
token: InjectionToken;
|
|
12
|
-
} | ResolveChainNodeBase<'property'> & {
|
|
13
|
-
constructor: AbstractConstructor;
|
|
14
|
-
property: PropertyKey;
|
|
15
|
-
token: InjectionToken;
|
|
16
|
-
};
|
|
17
|
-
export declare class ResolveChain {
|
|
18
|
-
readonly nodes: readonly ResolveChainNode[];
|
|
19
|
-
get length(): number;
|
|
20
|
-
constructor(nodes?: ResolveChainNode[]);
|
|
21
|
-
static startWith(token: InjectionToken): ResolveChain;
|
|
22
|
-
addToken(token: InjectionToken): ResolveChain;
|
|
23
|
-
addParameter(constructor: AbstractConstructor, index: number, token: InjectionToken): ResolveChain;
|
|
24
|
-
addProperty(constructor: AbstractConstructor, property: PropertyKey, token: InjectionToken): ResolveChain;
|
|
25
|
-
format(truncate?: number): string;
|
|
26
|
-
truncate(tokenCount: number): ResolveChain;
|
|
27
|
-
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var resolve_chain_exports = {};
|
|
20
|
-
__export(resolve_chain_exports, {
|
|
21
|
-
ResolveChain: () => ResolveChain
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(resolve_chain_exports);
|
|
24
|
-
var import_reflection = require("../reflection/index.js");
|
|
25
|
-
var import_type_guards = require("../utils/type-guards.js");
|
|
26
|
-
var import_token = require("./token.js");
|
|
27
|
-
class ResolveChain {
|
|
28
|
-
nodes;
|
|
29
|
-
get length() {
|
|
30
|
-
return this.nodes.length;
|
|
31
|
-
}
|
|
32
|
-
constructor(nodes) {
|
|
33
|
-
this.nodes = nodes ?? [];
|
|
34
|
-
}
|
|
35
|
-
static startWith(token) {
|
|
36
|
-
const chain = new ResolveChain();
|
|
37
|
-
return chain.addToken(token);
|
|
38
|
-
}
|
|
39
|
-
addToken(token) {
|
|
40
|
-
const node = { type: "token", token };
|
|
41
|
-
return new ResolveChain([...this.nodes, node]);
|
|
42
|
-
}
|
|
43
|
-
addParameter(constructor, index, token) {
|
|
44
|
-
const node = { type: "parameter", constructor, index, token };
|
|
45
|
-
return new ResolveChain([...this.nodes, node]);
|
|
46
|
-
}
|
|
47
|
-
addProperty(constructor, property, token) {
|
|
48
|
-
const node = { type: "property", constructor, property, token };
|
|
49
|
-
return new ResolveChain([...this.nodes, node]);
|
|
50
|
-
}
|
|
51
|
-
format(truncate) {
|
|
52
|
-
let chainString = "";
|
|
53
|
-
const chain = (0, import_type_guards.isDefined)(truncate) ? this.truncate(truncate) : this;
|
|
54
|
-
if (chain.length < this.length) {
|
|
55
|
-
chainString += "\n [...]";
|
|
56
|
-
}
|
|
57
|
-
for (const node of chain.nodes) {
|
|
58
|
-
const tokenName = (0, import_token.getTokenName)(node.token);
|
|
59
|
-
switch (node.type) {
|
|
60
|
-
case "token":
|
|
61
|
-
chainString += `
|
|
62
|
-
-> ${tokenName}`;
|
|
63
|
-
break;
|
|
64
|
-
case "parameter":
|
|
65
|
-
const metadata = import_reflection.reflectionRegistry.getMetadata(node.constructor);
|
|
66
|
-
const prefix = "_, ".repeat(node.index);
|
|
67
|
-
const suffix = ", _".repeat((0, import_type_guards.assertDefinedPass)(metadata?.parameters, "missing parameters metadata").length - node.index - 1);
|
|
68
|
-
chainString += `(${prefix}${tokenName}${suffix})`;
|
|
69
|
-
break;
|
|
70
|
-
case "property":
|
|
71
|
-
const constructorName = (0, import_token.getTokenName)(node.constructor);
|
|
72
|
-
const key = getPropertyKeyString(node.property);
|
|
73
|
-
chainString += `
|
|
74
|
-
-> ${constructorName}[${key}]: ${tokenName}`;
|
|
75
|
-
break;
|
|
76
|
-
default:
|
|
77
|
-
throw new Error(`unknown chain node type ${node.type}`);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return chainString;
|
|
81
|
-
}
|
|
82
|
-
truncate(tokenCount) {
|
|
83
|
-
const truncatedChain = [];
|
|
84
|
-
let counter = 0;
|
|
85
|
-
for (let i = this.nodes.length - 1; i >= 0 && counter < tokenCount; i--) {
|
|
86
|
-
const node = this.nodes[i];
|
|
87
|
-
truncatedChain.unshift(node);
|
|
88
|
-
if (node.type == "token") {
|
|
89
|
-
counter++;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return new ResolveChain(truncatedChain);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
function getPropertyKeyString(key) {
|
|
96
|
-
switch (typeof key) {
|
|
97
|
-
case "number":
|
|
98
|
-
case "symbol":
|
|
99
|
-
return key.toString();
|
|
100
|
-
case "string":
|
|
101
|
-
return `'${key}'`;
|
|
102
|
-
default:
|
|
103
|
-
throw new Error(`unsupported key type ${typeof key}`);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var resolve_error_exports = {};
|
|
20
|
-
__export(resolve_error_exports, {
|
|
21
|
-
ResolveError: () => ResolveError
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(resolve_error_exports);
|
|
24
|
-
var import_custom_error = require("../error/custom.error.js");
|
|
25
|
-
var import_type_guards = require("../utils/type-guards.js");
|
|
26
|
-
class ResolveError extends import_custom_error.CustomError {
|
|
27
|
-
constructor(message, chain, cause) {
|
|
28
|
-
const causeMessage = (0, import_type_guards.isDefined)(cause) ? `
|
|
29
|
-
cause: ${cause.message}` : "";
|
|
30
|
-
super({
|
|
31
|
-
message: `${message}${causeMessage}
|
|
32
|
-
chain: ${chain.format(15)}`,
|
|
33
|
-
cause
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
package/_container/token.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { AbstractConstructor, EnumerationObject } from '../types.js';
|
|
2
|
-
declare const type: unique symbol;
|
|
3
|
-
declare const argument: unique symbol;
|
|
4
|
-
export type ArgumentedInjectionToken<T, A> = SimpleInjectionToken<T> & {
|
|
5
|
-
[argument]?: A;
|
|
6
|
-
};
|
|
7
|
-
export type SimpleInjectionToken<T> = AbstractConstructor<T> | EnumerationObject;
|
|
8
|
-
export type InjectionToken<T = any, A = any> = SimpleInjectionToken<T> | ArgumentedInjectionToken<T, A> | ReifyingInjectionToken<T, A>;
|
|
9
|
-
export declare class ReifyingInjectionToken<T = any, A = any> {
|
|
10
|
-
private readonly [type];
|
|
11
|
-
private readonly [argument];
|
|
12
|
-
readonly description: string;
|
|
13
|
-
constructor(description: string);
|
|
14
|
-
toString(): string;
|
|
15
|
-
}
|
|
16
|
-
export declare function injectionToken<T, A = any>(description: string): InjectionToken<T, A>;
|
|
17
|
-
export declare function getTokenName(token: InjectionToken | undefined): string;
|
|
18
|
-
export {};
|
package/_container/token.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var token_exports = {};
|
|
20
|
-
__export(token_exports, {
|
|
21
|
-
ReifyingInjectionToken: () => ReifyingInjectionToken,
|
|
22
|
-
getTokenName: () => getTokenName,
|
|
23
|
-
injectionToken: () => injectionToken
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(token_exports);
|
|
26
|
-
var import_type_guards = require("../utils/type-guards.js");
|
|
27
|
-
class ReifyingInjectionToken {
|
|
28
|
-
description;
|
|
29
|
-
constructor(description) {
|
|
30
|
-
this.description = description;
|
|
31
|
-
}
|
|
32
|
-
toString() {
|
|
33
|
-
return `InjectionToken["${this.description}"]`;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
function injectionToken(description) {
|
|
37
|
-
return new ReifyingInjectionToken(description);
|
|
38
|
-
}
|
|
39
|
-
function getTokenName(token) {
|
|
40
|
-
return (0, import_type_guards.isFunction)(token) ? token.name : (0, import_type_guards.isString)(token) ? `"${token}"` : String(token);
|
|
41
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { InjectionToken } from './token.js';
|
|
2
|
-
import type { ArgumentProvider, ForwardRefInjectionToken, Mapper } from './types.js';
|
|
3
|
-
export type InjectMetadata = {
|
|
4
|
-
/** token overwrite by inject decorator */
|
|
5
|
-
injectToken?: InjectionToken;
|
|
6
|
-
/** if defined, resolve the ForwardRefToken using ForwardRef strategy instead resolving the token */
|
|
7
|
-
forwardRefToken?: ForwardRefInjectionToken;
|
|
8
|
-
/** whether injection is optional if token is not registered. Set by optional decorator */
|
|
9
|
-
optional?: boolean;
|
|
10
|
-
/** mapper to map resolved value */
|
|
11
|
-
mapper?: Mapper;
|
|
12
|
-
/** provider to get resolve argument */
|
|
13
|
-
resolveArgumentProvider?: ArgumentProvider;
|
|
14
|
-
/** if defined, map the resolve argument and use the returned value as the value to inject */
|
|
15
|
-
injectArgumentMapper?: Mapper;
|
|
16
|
-
/** if defined, use the provided argument, map it and pass it to the resolution of the token */
|
|
17
|
-
forwardArgumentMapper?: Mapper;
|
|
18
|
-
};
|
package/_container/type-info.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var type_info_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(type_info_exports);
|
package/_container/types.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { AbstractConstructor } from '../types.js';
|
|
2
|
-
import type { Container } from './container.js';
|
|
3
|
-
import type { InjectionToken } from './token.js';
|
|
4
|
-
export type ResolveContext = Pick<Container, 'resolve' | 'resolveAsync'> & {
|
|
5
|
-
isAsync: boolean;
|
|
6
|
-
};
|
|
7
|
-
export type Mapper<T = any, U = unknown> = (value: T) => U | Promise<U>;
|
|
8
|
-
export type ArgumentProvider<T = unknown> = (context: ResolveContext) => T | Promise<T>;
|
|
9
|
-
export type ForwardRefInjectionToken<T = any, A = any> = Exclude<InjectionToken<T, A>, AbstractConstructor> | (() => InjectionToken<T, A>);
|
package/_container/types.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var types_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(types_exports);
|
package/_container/utils.d.ts
DELETED
package/_container/utils.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var utils_exports = {};
|
|
20
|
-
__export(utils_exports, {
|
|
21
|
-
isStubClass: () => isStubClass,
|
|
22
|
-
stubClass: () => stubClass
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(utils_exports);
|
|
25
|
-
var import_type_guards = require("../utils/type-guards.js");
|
|
26
|
-
var import_container = require("./container.js");
|
|
27
|
-
const isStubClassSymbol = Symbol("Stub class");
|
|
28
|
-
function stubClass(forClass) {
|
|
29
|
-
const forClassName = (0, import_type_guards.isString)(forClass) ? forClass : forClass.name;
|
|
30
|
-
const stubName = `${forClassName}Stub`;
|
|
31
|
-
const stub = {
|
|
32
|
-
[stubName]: class {
|
|
33
|
-
constructor() {
|
|
34
|
-
throw new Error(`Stub class for ${forClassName} not instantiable.`);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}[stubName];
|
|
38
|
-
stub[isStubClassSymbol] = true;
|
|
39
|
-
import_container.container.register(stub, { useClass: stub });
|
|
40
|
-
return stub;
|
|
41
|
-
}
|
|
42
|
-
function isStubClass(target) {
|
|
43
|
-
return target[isStubClassSymbol] === true;
|
|
44
|
-
}
|