@tsed/di 6.68.1 → 6.69.0-rc.3
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/lib/index.js +2537 -23
- package/lib/index.js.map +1 -1
- package/lib/index.modern.js +2474 -0
- package/lib/index.modern.js.map +1 -0
- package/lib/registries/GlobalProviders.d.ts +1 -1
- package/package.json +11 -8
- package/lib/constants/index.js +0 -7
- package/lib/constants/index.js.map +0 -1
- package/lib/decorators/configuration.js +0 -24
- package/lib/decorators/configuration.js.map +0 -1
- package/lib/decorators/constant.js +0 -55
- package/lib/decorators/constant.js.map +0 -1
- package/lib/decorators/index.js +0 -17
- package/lib/decorators/index.js.map +0 -1
- package/lib/decorators/inject.js +0 -60
- package/lib/decorators/inject.js.map +0 -1
- package/lib/decorators/injectable.js +0 -33
- package/lib/decorators/injectable.js.map +0 -1
- package/lib/decorators/intercept.js +0 -28
- package/lib/decorators/intercept.js.map +0 -1
- package/lib/decorators/interceptor.js +0 -21
- package/lib/decorators/interceptor.js.map +0 -1
- package/lib/decorators/module.js +0 -31
- package/lib/decorators/module.js.map +0 -1
- package/lib/decorators/opts.js +0 -54
- package/lib/decorators/opts.js.map +0 -1
- package/lib/decorators/overrideProvider.js +0 -17
- package/lib/decorators/overrideProvider.js.map +0 -1
- package/lib/decorators/scope.js +0 -16
- package/lib/decorators/scope.js.map +0 -1
- package/lib/decorators/service.js +0 -18
- package/lib/decorators/service.js.map +0 -1
- package/lib/decorators/useOpts.js +0 -65
- package/lib/decorators/useOpts.js.map +0 -1
- package/lib/decorators/value.js +0 -55
- package/lib/decorators/value.js.map +0 -1
- package/lib/domain/Container.js +0 -69
- package/lib/domain/Container.js.map +0 -1
- package/lib/domain/ContextLogger.js +0 -92
- package/lib/domain/ContextLogger.js.map +0 -1
- package/lib/domain/DIContext.js +0 -45
- package/lib/domain/DIContext.js.map +0 -1
- package/lib/domain/InjectablePropertyType.js +0 -12
- package/lib/domain/InjectablePropertyType.js.map +0 -1
- package/lib/domain/LocalsContainer.js +0 -55
- package/lib/domain/LocalsContainer.js.map +0 -1
- package/lib/domain/Provider.js +0 -173
- package/lib/domain/Provider.js.map +0 -1
- package/lib/domain/ProviderScope.js +0 -10
- package/lib/domain/ProviderScope.js.map +0 -1
- package/lib/domain/ProviderType.js +0 -15
- package/lib/domain/ProviderType.js.map +0 -1
- package/lib/domain/index.js +0 -12
- package/lib/domain/index.js.map +0 -1
- package/lib/errors/InjectionError.js +0 -59
- package/lib/errors/InjectionError.js.map +0 -1
- package/lib/errors/UndefinedTokenError.js +0 -11
- package/lib/errors/UndefinedTokenError.js.map +0 -1
- package/lib/interfaces/DIConfigurationOptions.js +0 -3
- package/lib/interfaces/DIConfigurationOptions.js.map +0 -1
- package/lib/interfaces/DILogger.js +0 -3
- package/lib/interfaces/DILogger.js.map +0 -1
- package/lib/interfaces/DIResolver.js +0 -3
- package/lib/interfaces/DIResolver.js.map +0 -1
- package/lib/interfaces/IProvider.js +0 -3
- package/lib/interfaces/IProvider.js.map +0 -1
- package/lib/interfaces/InjectableProperties.js +0 -3
- package/lib/interfaces/InjectableProperties.js.map +0 -1
- package/lib/interfaces/InterceptorContext.js +0 -3
- package/lib/interfaces/InterceptorContext.js.map +0 -1
- package/lib/interfaces/InterceptorMethods.js +0 -3
- package/lib/interfaces/InterceptorMethods.js.map +0 -1
- package/lib/interfaces/InvokeOptions.js +0 -3
- package/lib/interfaces/InvokeOptions.js.map +0 -1
- package/lib/interfaces/OnDestroy.js +0 -3
- package/lib/interfaces/OnDestroy.js.map +0 -1
- package/lib/interfaces/OnInit.js +0 -3
- package/lib/interfaces/OnInit.js.map +0 -1
- package/lib/interfaces/RegistrySettings.js +0 -3
- package/lib/interfaces/RegistrySettings.js.map +0 -1
- package/lib/interfaces/TokenProvider.js +0 -3
- package/lib/interfaces/TokenProvider.js.map +0 -1
- package/lib/interfaces/index.js +0 -17
- package/lib/interfaces/index.js.map +0 -1
- package/lib/registries/GlobalProviders.js +0 -124
- package/lib/registries/GlobalProviders.js.map +0 -1
- package/lib/registries/ProviderRegistry.js +0 -181
- package/lib/registries/ProviderRegistry.js.map +0 -1
- package/lib/services/DIConfiguration.js +0 -129
- package/lib/services/DIConfiguration.js.map +0 -1
- package/lib/services/DILogger.js +0 -13
- package/lib/services/DILogger.js.map +0 -1
- package/lib/services/DITest.js +0 -100
- package/lib/services/DITest.js.map +0 -1
- package/lib/services/InjectorService.js +0 -543
- package/lib/services/InjectorService.js.map +0 -1
- package/lib/utils/cleanGlobPatterns.js +0 -30
- package/lib/utils/cleanGlobPatterns.js.map +0 -1
- package/lib/utils/createContainer.js +0 -14
- package/lib/utils/createContainer.js.map +0 -1
- package/lib/utils/data/Test1.d.ts +0 -3
- package/lib/utils/data/Test1.js +0 -8
- package/lib/utils/data/Test1.js.map +0 -1
- package/lib/utils/data/Test2.d.ts +0 -3
- package/lib/utils/data/Test2.js +0 -8
- package/lib/utils/data/Test2.js.map +0 -1
- package/lib/utils/getConfiguration.js +0 -20
- package/lib/utils/getConfiguration.js.map +0 -1
- package/lib/utils/importComponents.js +0 -50
- package/lib/utils/importComponents.js.map +0 -1
- package/lib/utils/importFiles.js +0 -28
- package/lib/utils/importFiles.js.map +0 -1
- package/lib/utils/importProviders.js +0 -29
- package/lib/utils/importProviders.js.map +0 -1
- package/lib/utils/setLoggerLevel.js +0 -16
- package/lib/utils/setLoggerLevel.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LocalsContainer.js","sourceRoot":"","sources":["../../src/domain/LocalsContainer.ts"],"names":[],"mappings":";;;AAEA,MAAa,eAAyB,SAAQ,GAAqB;IACjE;;;;;OAKG;IACI,KAAK,CAAC,IAAI,CAAC,SAAiB,EAAE,GAAG,IAAW;QACjD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;YAClD,MAAM,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC;SACxB;IACH,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAU,SAAiB,EAAE,KAAU,EAAE,GAAG,IAAW;QACjE,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;YAClD,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;SACjC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,UAAU,CAAU,SAAiB,EAAE,KAAU,EAAE,GAAG,IAAW;QAC5E,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE;YAClD,KAAK,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;SACjC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;IAES,YAAY,CAAC,KAAa;QAClC,OAAO,IAAI,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,QAAQ,EAAE,EAAE;YACnD,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,IAAI,QAAQ,EAAE;gBACjE,OAAO,SAAS,CAAC,MAAM,CAAE,QAAgB,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;aAClE;YAED,OAAO,SAAS,CAAC;QACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;CACF;AAzDD,0CAyDC","sourcesContent":["import {TokenProvider} from \"../interfaces/TokenProvider\";\n\nexport class LocalsContainer<V = any> extends Map<TokenProvider, V> {\n /**\n * Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).\n * @param eventName The event name to emit at all services.\n * @param args List of the parameters to give to each services.\n * @returns {Promise<any[]>} A list of promises.\n */\n public async emit(eventName: string, ...args: any[]) {\n for (const handler of this.getListeners(eventName)) {\n await handler(...args);\n }\n }\n\n /**\n * @param eventName\n * @param value\n * @param args\n */\n public alter<T = any>(eventName: string, value: any, ...args: any[]): T {\n for (const handler of this.getListeners(eventName)) {\n value = handler(value, ...args);\n }\n\n return value;\n }\n\n /**\n * @param eventName\n * @param value\n * @param args\n */\n public async alterAsync<T = any>(eventName: string, value: any, ...args: any[]): Promise<T> {\n for (const handler of this.getListeners(eventName)) {\n value = handler(value, ...args);\n }\n\n return value;\n }\n\n toArray() {\n return [...this.values()];\n }\n\n async destroy() {\n await this.emit(\"$onDestroy\");\n this.clear();\n }\n\n protected getListeners(event: string): any[] {\n return this.toArray().reduce((listeners, instance) => {\n if (typeof instance === \"object\" && instance && event in instance) {\n return listeners.concat((instance as any)[event].bind(instance));\n }\n\n return listeners;\n }, []);\n }\n}\n"]}
|
package/lib/domain/Provider.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Provider = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@tsed/core");
|
|
6
|
-
const ProviderScope_1 = require("./ProviderScope");
|
|
7
|
-
const ProviderType_1 = require("./ProviderType");
|
|
8
|
-
class Provider {
|
|
9
|
-
constructor(token) {
|
|
10
|
-
this.type = ProviderType_1.ProviderType.PROVIDER;
|
|
11
|
-
this.injectable = true;
|
|
12
|
-
this.provide = token;
|
|
13
|
-
this.useClass = token;
|
|
14
|
-
}
|
|
15
|
-
get token() {
|
|
16
|
-
return this._provide;
|
|
17
|
-
}
|
|
18
|
-
get provide() {
|
|
19
|
-
return this._provide;
|
|
20
|
-
}
|
|
21
|
-
set provide(value) {
|
|
22
|
-
if (value) {
|
|
23
|
-
this._provide = core_1.isClass(value) ? core_1.classOf(value) : value;
|
|
24
|
-
this._tokenStore = this._store = core_1.Store.from(value);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
get useClass() {
|
|
28
|
-
return this._useClass;
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Create a new store if the given value is a class. Otherwise the value is ignored.
|
|
32
|
-
* @param value
|
|
33
|
-
*/
|
|
34
|
-
set useClass(value) {
|
|
35
|
-
if (core_1.isClass(value)) {
|
|
36
|
-
this._useClass = core_1.classOf(value);
|
|
37
|
-
this._store = core_1.Store.from(value);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
get className() {
|
|
41
|
-
return this.name;
|
|
42
|
-
}
|
|
43
|
-
get name() {
|
|
44
|
-
return core_1.nameOf(this.provide);
|
|
45
|
-
}
|
|
46
|
-
get store() {
|
|
47
|
-
return this._store;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Get the scope of the provider.
|
|
51
|
-
*
|
|
52
|
-
* ::: tip Note
|
|
53
|
-
* Async provider is always a SINGLETON
|
|
54
|
-
* :::
|
|
55
|
-
*
|
|
56
|
-
* @returns {boolean}
|
|
57
|
-
*/
|
|
58
|
-
get scope() {
|
|
59
|
-
if (this.isAsync()) {
|
|
60
|
-
return ProviderScope_1.ProviderScope.SINGLETON;
|
|
61
|
-
}
|
|
62
|
-
return this.get("scope");
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Change the scope value of the provider.
|
|
66
|
-
* @param scope
|
|
67
|
-
*/
|
|
68
|
-
set scope(scope) {
|
|
69
|
-
this.store.set("scope", scope);
|
|
70
|
-
}
|
|
71
|
-
get configuration() {
|
|
72
|
-
return this.get("configuration");
|
|
73
|
-
}
|
|
74
|
-
set configuration(configuration) {
|
|
75
|
-
this.store.set("configuration", configuration);
|
|
76
|
-
}
|
|
77
|
-
get(key) {
|
|
78
|
-
return this.store.get(key) || this._tokenStore.get(key);
|
|
79
|
-
}
|
|
80
|
-
isAsync() {
|
|
81
|
-
return !!this.useAsyncFactory;
|
|
82
|
-
}
|
|
83
|
-
clone() {
|
|
84
|
-
const provider = new (core_1.classOf(this))(this.token);
|
|
85
|
-
core_1.getEnumerableKeys(this).forEach((key) => {
|
|
86
|
-
if (this[key] !== undefined) {
|
|
87
|
-
provider[key] = this[key];
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
return provider;
|
|
91
|
-
}
|
|
92
|
-
toString() {
|
|
93
|
-
return [
|
|
94
|
-
"Token",
|
|
95
|
-
this.name,
|
|
96
|
-
this.useClass && core_1.nameOf(this.useClass),
|
|
97
|
-
this.useFactory && "Factory",
|
|
98
|
-
this.useValue && "Value",
|
|
99
|
-
this.useAsyncFactory && "AsyncFactory"
|
|
100
|
-
]
|
|
101
|
-
.filter(Boolean)
|
|
102
|
-
.join(":");
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
tslib_1.__decorate([
|
|
106
|
-
core_1.Enumerable(),
|
|
107
|
-
tslib_1.__metadata("design:type", Object)
|
|
108
|
-
], Provider.prototype, "type", void 0);
|
|
109
|
-
tslib_1.__decorate([
|
|
110
|
-
core_1.Enumerable(),
|
|
111
|
-
tslib_1.__metadata("design:type", Boolean)
|
|
112
|
-
], Provider.prototype, "injectable", void 0);
|
|
113
|
-
tslib_1.__decorate([
|
|
114
|
-
core_1.Enumerable(),
|
|
115
|
-
tslib_1.__metadata("design:type", Object)
|
|
116
|
-
], Provider.prototype, "instance", void 0);
|
|
117
|
-
tslib_1.__decorate([
|
|
118
|
-
core_1.Enumerable(),
|
|
119
|
-
tslib_1.__metadata("design:type", Array)
|
|
120
|
-
], Provider.prototype, "deps", void 0);
|
|
121
|
-
tslib_1.__decorate([
|
|
122
|
-
core_1.Enumerable(),
|
|
123
|
-
tslib_1.__metadata("design:type", Array)
|
|
124
|
-
], Provider.prototype, "imports", void 0);
|
|
125
|
-
tslib_1.__decorate([
|
|
126
|
-
core_1.Enumerable(),
|
|
127
|
-
tslib_1.__metadata("design:type", Function)
|
|
128
|
-
], Provider.prototype, "useFactory", void 0);
|
|
129
|
-
tslib_1.__decorate([
|
|
130
|
-
core_1.Enumerable(),
|
|
131
|
-
tslib_1.__metadata("design:type", Function)
|
|
132
|
-
], Provider.prototype, "useAsyncFactory", void 0);
|
|
133
|
-
tslib_1.__decorate([
|
|
134
|
-
core_1.Enumerable(),
|
|
135
|
-
tslib_1.__metadata("design:type", Object)
|
|
136
|
-
], Provider.prototype, "useValue", void 0);
|
|
137
|
-
tslib_1.__decorate([
|
|
138
|
-
core_1.NotEnumerable(),
|
|
139
|
-
tslib_1.__metadata("design:type", Object)
|
|
140
|
-
], Provider.prototype, "_provide", void 0);
|
|
141
|
-
tslib_1.__decorate([
|
|
142
|
-
core_1.NotEnumerable(),
|
|
143
|
-
tslib_1.__metadata("design:type", core_1.Type)
|
|
144
|
-
], Provider.prototype, "_useClass", void 0);
|
|
145
|
-
tslib_1.__decorate([
|
|
146
|
-
core_1.NotEnumerable(),
|
|
147
|
-
tslib_1.__metadata("design:type", Object)
|
|
148
|
-
], Provider.prototype, "_instance", void 0);
|
|
149
|
-
tslib_1.__decorate([
|
|
150
|
-
core_1.NotEnumerable(),
|
|
151
|
-
tslib_1.__metadata("design:type", core_1.Store)
|
|
152
|
-
], Provider.prototype, "_store", void 0);
|
|
153
|
-
tslib_1.__decorate([
|
|
154
|
-
core_1.NotEnumerable(),
|
|
155
|
-
tslib_1.__metadata("design:type", core_1.Store)
|
|
156
|
-
], Provider.prototype, "_tokenStore", void 0);
|
|
157
|
-
tslib_1.__decorate([
|
|
158
|
-
core_1.Enumerable(),
|
|
159
|
-
tslib_1.__metadata("design:type", core_1.Type),
|
|
160
|
-
tslib_1.__metadata("design:paramtypes", [core_1.Type])
|
|
161
|
-
], Provider.prototype, "useClass", null);
|
|
162
|
-
tslib_1.__decorate([
|
|
163
|
-
core_1.Enumerable(),
|
|
164
|
-
tslib_1.__metadata("design:type", String),
|
|
165
|
-
tslib_1.__metadata("design:paramtypes", [String])
|
|
166
|
-
], Provider.prototype, "scope", null);
|
|
167
|
-
tslib_1.__decorate([
|
|
168
|
-
core_1.Enumerable(),
|
|
169
|
-
tslib_1.__metadata("design:type", Object),
|
|
170
|
-
tslib_1.__metadata("design:paramtypes", [Object])
|
|
171
|
-
], Provider.prototype, "configuration", null);
|
|
172
|
-
exports.Provider = Provider;
|
|
173
|
-
//# sourceMappingURL=Provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../src/domain/Provider.ts"],"names":[],"mappings":";;;;AAAA,qCAA+G;AAE/G,mDAA8C;AAC9C,iDAA4C;AAE5C,MAAa,QAAQ;IA0CnB,YAAY,KAAoB;QAxCzB,SAAI,GAAuB,2BAAY,CAAC,QAAQ,CAAC;QAGjD,eAAU,GAAY,IAAI,CAAC;QAsChC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;IACxB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,IAAI,OAAO,CAAC,KAAoB;QAC9B,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,QAAQ,GAAG,cAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,cAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACxD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,MAAM,GAAG,YAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;SACpD;IACH,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IAED;;;OAGG;IAEH,IAAI,QAAQ,CAAC,KAAc;QACzB,IAAI,cAAO,CAAC,KAAK,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classOf, Enumerable, getEnumerableKeys, isClass, nameOf, NotEnumerable, Store, Type} from \"@tsed/core\";\nimport {IProvider, TokenProvider} from \"../interfaces\";\nimport {ProviderScope} from \"./ProviderScope\";\nimport {ProviderType} from \"./ProviderType\";\n\nexport class Provider<T = any> implements IProvider<T> {\n @Enumerable()\n public type: ProviderType | any = ProviderType.PROVIDER;\n\n @Enumerable()\n public injectable: boolean = true;\n\n @Enumerable()\n public instance: T;\n\n @Enumerable()\n public deps: TokenProvider[];\n\n @Enumerable()\n public imports: any[];\n\n @Enumerable()\n public useFactory: Function;\n\n @Enumerable()\n public useAsyncFactory: Function;\n\n @Enumerable()\n public useValue: any;\n\n @NotEnumerable()\n protected _provide: TokenProvider;\n\n @NotEnumerable()\n protected _useClass: Type<T>;\n\n @NotEnumerable()\n protected _instance: T;\n\n @NotEnumerable()\n private _store: Store;\n\n @NotEnumerable()\n private _tokenStore: Store;\n\n [key: string]: any;\n\n constructor(token: TokenProvider) {\n this.provide = token;\n this.useClass = token;\n }\n\n get token() {\n return this._provide;\n }\n\n get provide(): TokenProvider {\n return this._provide;\n }\n\n set provide(value: TokenProvider) {\n if (value) {\n this._provide = isClass(value) ? classOf(value) : value;\n this._tokenStore = this._store = Store.from(value);\n }\n }\n\n get useClass(): Type<T> {\n return this._useClass;\n }\n\n /**\n * Create a new store if the given value is a class. Otherwise the value is ignored.\n * @param value\n */\n @Enumerable()\n set useClass(value: Type<T>) {\n if (isClass(value)) {\n this._useClass = classOf(value);\n this._store = Store.from(value);\n }\n }\n\n get className() {\n return this.name;\n }\n\n get name() {\n return nameOf(this.provide);\n }\n\n public get store(): Store {\n return this._store;\n }\n\n /**\n * Get the scope of the provider.\n *\n * ::: tip Note\n * Async provider is always a SINGLETON\n * :::\n *\n * @returns {boolean}\n */\n get scope(): ProviderScope {\n if (this.isAsync()) {\n return ProviderScope.SINGLETON;\n }\n\n return this.get(\"scope\");\n }\n\n /**\n * Change the scope value of the provider.\n * @param scope\n */\n @Enumerable()\n set scope(scope: ProviderScope) {\n this.store.set(\"scope\", scope);\n }\n\n get configuration(): Partial<TsED.Configuration> {\n return this.get(\"configuration\");\n }\n\n @Enumerable()\n set configuration(configuration: Partial<TsED.Configuration>) {\n this.store.set(\"configuration\", configuration);\n }\n\n get(key: string) {\n return this.store.get(key) || this._tokenStore.get(key);\n }\n\n isAsync(): boolean {\n return !!this.useAsyncFactory;\n }\n\n clone(): Provider<any> {\n const provider = new (classOf(this))(this.token);\n\n getEnumerableKeys(this).forEach((key) => {\n if (this[key] !== undefined) {\n provider[key] = this[key];\n }\n });\n\n return provider;\n }\n\n toString() {\n return [\n \"Token\",\n this.name,\n this.useClass && nameOf(this.useClass),\n this.useFactory && \"Factory\",\n this.useValue && \"Value\",\n this.useAsyncFactory && \"AsyncFactory\"\n ]\n .filter(Boolean)\n .join(\":\");\n }\n}\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProviderScope = void 0;
|
|
4
|
-
var ProviderScope;
|
|
5
|
-
(function (ProviderScope) {
|
|
6
|
-
ProviderScope["SINGLETON"] = "singleton";
|
|
7
|
-
ProviderScope["REQUEST"] = "request";
|
|
8
|
-
ProviderScope["INSTANCE"] = "instance";
|
|
9
|
-
})(ProviderScope = exports.ProviderScope || (exports.ProviderScope = {}));
|
|
10
|
-
//# sourceMappingURL=ProviderScope.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderScope.js","sourceRoot":"","sources":["../../src/domain/ProviderScope.ts"],"names":[],"mappings":";;;AAAA,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,wCAAuB,CAAA;IACvB,oCAAmB,CAAA;IACnB,sCAAqB,CAAA;AACvB,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB","sourcesContent":["export enum ProviderScope {\n SINGLETON = \"singleton\",\n REQUEST = \"request\",\n INSTANCE = \"instance\"\n}\n"]}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ProviderType = void 0;
|
|
4
|
-
var ProviderType;
|
|
5
|
-
(function (ProviderType) {
|
|
6
|
-
ProviderType["VALUE"] = "value";
|
|
7
|
-
ProviderType["FACTORY"] = "factory";
|
|
8
|
-
ProviderType["SERVICE"] = "service";
|
|
9
|
-
ProviderType["PROVIDER"] = "provider";
|
|
10
|
-
ProviderType["MODULE"] = "module";
|
|
11
|
-
ProviderType["CONTROLLER"] = "controller";
|
|
12
|
-
ProviderType["INTERCEPTOR"] = "interceptor";
|
|
13
|
-
ProviderType["MIDDLEWARE"] = "middleware";
|
|
14
|
-
})(ProviderType = exports.ProviderType || (exports.ProviderType = {}));
|
|
15
|
-
//# sourceMappingURL=ProviderType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderType.js","sourceRoot":"","sources":["../../src/domain/ProviderType.ts"],"names":[],"mappings":";;;AAAA,IAAY,YASX;AATD,WAAY,YAAY;IACtB,+BAAe,CAAA;IACf,mCAAmB,CAAA;IACnB,mCAAmB,CAAA;IACnB,qCAAqB,CAAA;IACrB,iCAAiB,CAAA;IACjB,yCAAyB,CAAA;IACzB,2CAA2B,CAAA;IAC3B,yCAAyB,CAAA;AAC3B,CAAC,EATW,YAAY,GAAZ,oBAAY,KAAZ,oBAAY,QASvB","sourcesContent":["export enum ProviderType {\n VALUE = \"value\",\n FACTORY = \"factory\",\n SERVICE = \"service\",\n PROVIDER = \"provider\",\n MODULE = \"module\",\n CONTROLLER = \"controller\",\n INTERCEPTOR = \"interceptor\",\n MIDDLEWARE = \"middleware\"\n}\n"]}
|
package/lib/domain/index.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./Container"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./InjectablePropertyType"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./LocalsContainer"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./Provider"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./ProviderScope"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./ProviderType"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./ContextLogger"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./DIContext"), exports);
|
|
12
|
-
//# sourceMappingURL=index.js.map
|
package/lib/domain/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/domain/index.ts"],"names":[],"mappings":";;;AAAA,sDAA4B;AAC5B,mEAAyC;AACzC,4DAAkC;AAClC,qDAA2B;AAC3B,0DAAgC;AAChC,yDAA+B;AAC/B,0DAAgC;AAChC,sDAA4B","sourcesContent":["export * from \"./Container\";\nexport * from \"./InjectablePropertyType\";\nexport * from \"./LocalsContainer\";\nexport * from \"./Provider\";\nexport * from \"./ProviderScope\";\nexport * from \"./ProviderType\";\nexport * from \"./ContextLogger\";\nexport * from \"./DIContext\";\n"]}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InjectionError = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const core_1 = require("@tsed/core");
|
|
6
|
-
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
-
class InjectionError extends Error {
|
|
8
|
-
constructor(token, origin) {
|
|
9
|
-
super(core_1.isString(origin) ? origin : "");
|
|
10
|
-
this.name = "INJECTION_ERROR";
|
|
11
|
-
this.tokens = [];
|
|
12
|
-
this.tokens = [token];
|
|
13
|
-
if (origin) {
|
|
14
|
-
if (core_1.isString(origin)) {
|
|
15
|
-
this.origin = {
|
|
16
|
-
message: origin,
|
|
17
|
-
stack: this.stack
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
if (origin.tokens) {
|
|
22
|
-
this.tokens = this.tokens.concat(origin.tokens);
|
|
23
|
-
this.origin = origin.origin;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
this.origin = origin;
|
|
27
|
-
this.stack = origin.stack;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
const originMessage = this.origin ? "\nOrigin: " + this.origin.message : "";
|
|
32
|
-
const tokensMessage = this.tokens.map((token) => core_1.nameOf(token)).join(" > ");
|
|
33
|
-
this.message = `Injection failed on ${tokensMessage}${originMessage}`;
|
|
34
|
-
}
|
|
35
|
-
static throwInjectorError(token, currentDependency, error) {
|
|
36
|
-
if (currentDependency && core_1.isClass(token)) {
|
|
37
|
-
error.message = printDependencyInjectionError(token, { ...currentDependency, message: error.message });
|
|
38
|
-
}
|
|
39
|
-
throw new InjectionError(token, error);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
exports.InjectionError = InjectionError;
|
|
43
|
-
function printDependencyInjectionError(token, options) {
|
|
44
|
-
let erroredArg = "";
|
|
45
|
-
const args = core_1.getConstructorArgNames(token)
|
|
46
|
-
.map((arg, index) => {
|
|
47
|
-
if (options.index === index) {
|
|
48
|
-
erroredArg = arg;
|
|
49
|
-
arg = chalk_1.default.red(arg);
|
|
50
|
-
}
|
|
51
|
-
return `${arg}: ${core_1.nameOf(options.deps[index])}`;
|
|
52
|
-
})
|
|
53
|
-
.join(", ");
|
|
54
|
-
const signature = core_1.nameOf(token) + "->constructor(" + args + ")";
|
|
55
|
-
const indexOf = signature.indexOf(erroredArg) - 5;
|
|
56
|
-
const drawline = (indexOf) => " ".repeat(indexOf) + chalk_1.default.red("^" + "‾".repeat(erroredArg.length - 1));
|
|
57
|
-
return "Unable to inject dependency. " + options.message + "\n\n" + signature + "\n" + (indexOf > -1 ? drawline(indexOf) : "");
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=InjectionError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InjectionError.js","sourceRoot":"","sources":["../../src/errors/InjectionError.ts"],"names":[],"mappings":";;;;AAAA,qCAA6E;AAC7E,0DAA0B;AAG1B,MAAa,cAAe,SAAQ,KAAK;IAMvC,YAAY,KAAoB,EAAE,MAAY;QAC5C,KAAK,CAAC,eAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QANxC,SAAI,GAAG,iBAAiB,CAAC;QAElB,WAAM,GAAoB,EAAE,CAAC;QAMlC,IAAI,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC;QAEtB,IAAI,MAAM,EAAE;YACV,IAAI,eAAQ,CAAC,MAAM,CAAC,EAAE;gBACpB,IAAI,CAAC,MAAM,GAAG;oBACZ,OAAO,EAAE,MAAM;oBACf,KAAK,EAAE,IAAI,CAAC,KAAK;iBAClB,CAAC;aACH;iBAAM;gBACL,IAAI,MAAM,CAAC,MAAM,EAAE;oBACjB,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;oBAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;iBAC7B;qBAAM;oBACL,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;oBACrB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;iBAC3B;aACF;SACF;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC5E,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,K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CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,eAAK,CAAC,GAAG,CAAC,GAAG,GAAG,GAAG,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;IAE/G,OAAO,+BAA+B,GAAG,OAAO,CAAC,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACjI,CAAC","sourcesContent":["import {getConstructorArgNames, isClass, isString, nameOf} from \"@tsed/core\";\nimport chalk from \"chalk\";\nimport {TokenProvider} from \"../interfaces\";\n\nexport class InjectionError extends Error {\n name = \"INJECTION_ERROR\";\n\n public tokens: TokenProvider[] = [];\n public origin: any;\n\n constructor(token: TokenProvider, origin?: any) {\n super(isString(origin) ? origin : \"\");\n\n this.tokens = [token];\n\n if (origin) {\n if (isString(origin)) {\n this.origin = {\n message: origin,\n stack: this.stack\n };\n } else {\n if (origin.tokens) {\n this.tokens = this.tokens.concat(origin.tokens);\n this.origin = origin.origin;\n } else {\n this.origin = origin;\n this.stack = origin.stack;\n }\n }\n }\n\n const originMessage = this.origin ? \"\\nOrigin: \" + this.origin.message : \"\";\n const tokensMessage = this.tokens.map((token) => nameOf(token)).join(\" > \");\n\n this.message = `Injection failed on ${tokensMessage}${originMessage}`;\n }\n\n static throwInjectorError(token: any, currentDependency: any, error: any) {\n if (currentDependency && isClass(token)) {\n error.message = printDependencyInjectionError(token, {...currentDependency, message: error.message});\n }\n\n throw new InjectionError(token, error);\n }\n}\n\nfunction printDependencyInjectionError(token: any, options: {token: any; index: number; deps: any[]; message: string}) {\n let erroredArg = \"\";\n\n const args = getConstructorArgNames(token)\n .map((arg, index) => {\n if (options.index === index) {\n erroredArg = arg;\n arg = chalk.red(arg);\n }\n\n return `${arg}: ${nameOf(options.deps[index])}`;\n })\n .join(\", \");\n\n const signature = nameOf(token) + \"->constructor(\" + args + \")\";\n const indexOf = signature.indexOf(erroredArg) - 5;\n const drawline = (indexOf: number) => \" \".repeat(indexOf) + chalk.red(\"^\" + \"‾\".repeat(erroredArg.length - 1));\n\n return \"Unable to inject dependency. \" + options.message + \"\\n\\n\" + signature + \"\\n\" + (indexOf > -1 ? drawline(indexOf) : \"\");\n}\n"]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UndefinedTokenError = void 0;
|
|
4
|
-
class UndefinedTokenError extends Error {
|
|
5
|
-
constructor() {
|
|
6
|
-
super("Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?");
|
|
7
|
-
this.name = "UNDEFINED_TOKEN_ERROR";
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.UndefinedTokenError = UndefinedTokenError;
|
|
11
|
-
//# sourceMappingURL=UndefinedTokenError.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UndefinedTokenError.js","sourceRoot":"","sources":["../../src/errors/UndefinedTokenError.ts"],"names":[],"mappings":";;;AAAA,MAAa,mBAAoB,SAAQ,KAAK;IAG5C;QACE,KAAK,CACH,4JAA4J,CAC7J,CAAC;QALJ,SAAI,GAAG,uBAAuB,CAAC;IAM/B,CAAC;CACF;AARD,kDAQC","sourcesContent":["export class UndefinedTokenError extends Error {\n name = \"UNDEFINED_TOKEN_ERROR\";\n\n constructor() {\n super(\n \"Given token is undefined. Have you enabled emitDecoratorMetadata in your tsconfig.json or decorated your class with @Injectable, @Service, ... decorator ?\"\n );\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DIConfigurationOptions.js","sourceRoot":"","sources":["../../src/interfaces/DIConfigurationOptions.ts"],"names":[],"mappings":"","sourcesContent":["import type {DIResolver} from \"./DIResolver\";\nimport type {ProviderScope} from \"../domain/ProviderScope\";\nimport type {TokenProvider} from \"./TokenProvider\";\n\ndeclare global {\n namespace TsED {\n interface Context {}\n interface Configuration {\n scopes: {[key: string]: ProviderScope};\n /**\n * Define a list of resolvers (it can be an external DI).\n */\n resolvers: DIResolver[];\n /**\n * Define dependencies to build the provider\n */\n imports: TokenProvider[];\n\n [key: string]: any;\n }\n }\n}\n\nexport interface DIConfigurationOptions extends TsED.Configuration {}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DILogger.js","sourceRoot":"","sources":["../../src/interfaces/DILogger.ts"],"names":[],"mappings":"","sourcesContent":["export interface DILogger {\n info(...args: any[]): void | any;\n\n warn(...args: any[]): void | any;\n\n debug(...args: any[]): void | any;\n\n error(...args: any[]): void | any;\n\n trace(...args: any[]): void | any;\n\n [key: string]: any;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DIResolver.js","sourceRoot":"","sources":["../../src/interfaces/DIResolver.ts"],"names":[],"mappings":"","sourcesContent":["import type {TokenProvider} from \"./TokenProvider\";\n\nexport interface DIResolver {\n deps?: TokenProvider[];\n get<T = any>(type: TokenProvider, options: any): T | undefined;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IProvider.js","sourceRoot":"","sources":["../../src/interfaces/IProvider.ts"],"names":[],"mappings":"","sourcesContent":["import type {Type} from \"@tsed/core\";\nimport type {DIResolver} from \"./DIResolver\";\nimport type {ProviderScope} from \"../domain/ProviderScope\";\nimport type {ProviderType} from \"../domain/ProviderType\";\nimport type {TokenProvider} from \"./TokenProvider\";\n/**\n *\n */\nexport interface IProvider<T = any> {\n /**\n * An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).\n */\n provide: TokenProvider;\n /**\n * Provider type\n */\n type?: ProviderType | string;\n /**\n * Instance build by the injector\n */\n instance?: T;\n /**\n * Define dependencies to build the provider\n */\n deps?: TokenProvider[];\n /**\n * Class to instantiate for the `token`.\n */\n useClass?: Type<T>;\n /**\n * Provide a function to build the provider\n */\n useFactory?: Function;\n /**\n * Provide an async function to build the provider\n */\n useAsyncFactory?: Function;\n /**\n * Provide predefined value\n */\n useValue?: any;\n /**\n * Scope used by the injector to build the provider.\n */\n scope?: ProviderScope;\n /**\n * A list of resolvers which will be used to resolve missing Symbol/Class when injector invoke a Class. This property allow external DI usage.\n */\n resolvers?: DIResolver[];\n\n /**\n *\n */\n [key: string]: any;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InjectableProperties.js","sourceRoot":"","sources":["../../src/interfaces/InjectableProperties.ts"],"names":[],"mappings":"","sourcesContent":["import type {InjectablePropertyType} from \"../domain/InjectablePropertyType\";\nimport type {TokenProvider} from \"./TokenProvider\";\n\nexport interface InjectableProperty {\n propertyKey: string;\n}\n\nexport interface InjectablePropertyService extends InjectableProperty {\n bindingType: InjectablePropertyType.METHOD | InjectablePropertyType.PROPERTY | InjectablePropertyType.INTERCEPTOR;\n propertyType: string;\n useType: TokenProvider;\n onGet?: (bean: any) => any;\n options?: any;\n}\n\nexport interface InjectablePropertyValue extends InjectableProperty {\n bindingType: InjectablePropertyType.CONSTANT | InjectablePropertyType.VALUE;\n expression: string;\n defaultValue?: any;\n}\n\nexport interface InjectableProperties {\n [key: string]: InjectablePropertyService | InjectablePropertyValue;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InterceptorContext.js","sourceRoot":"","sources":["../../src/interfaces/InterceptorContext.ts"],"names":[],"mappings":"","sourcesContent":["import type {Type} from \"@tsed/core\";\n\nexport interface InterceptorNext {\n <T>(err?: Error): T;\n}\n\nexport interface InterceptorContext<Klass = Type, Opts = any> {\n target: Klass;\n propertyKey: string;\n args: any[];\n next: InterceptorNext;\n options?: Opts;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InterceptorMethods.js","sourceRoot":"","sources":["../../src/interfaces/InterceptorMethods.ts"],"names":[],"mappings":"","sourcesContent":["import type {InterceptorContext, InterceptorNext} from \"./InterceptorContext\";\n\nexport interface InterceptorMethods {\n intercept?(context: InterceptorContext, next?: InterceptorNext): any;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InvokeOptions.js","sourceRoot":"","sources":["../../src/interfaces/InvokeOptions.ts"],"names":[],"mappings":"","sourcesContent":["import {ProviderScope} from \"../domain/ProviderScope\";\nimport {TokenProvider} from \"./TokenProvider\";\n\nexport interface InvokeOptions<T = any> {\n deps: any[];\n imports: any[];\n parent?: TokenProvider;\n scope: ProviderScope;\n useScope: boolean;\n rebuild?: boolean;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OnDestroy.js","sourceRoot":"","sources":["../../src/interfaces/OnDestroy.ts"],"names":[],"mappings":"","sourcesContent":["export interface OnDestroy {\n $onDestroy(): Promise<any> | void;\n}\n"]}
|
package/lib/interfaces/OnInit.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"OnInit.js","sourceRoot":"","sources":["../../src/interfaces/OnInit.ts"],"names":[],"mappings":"","sourcesContent":["export interface OnInit {\n $onInit(): Promise<any> | void;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RegistrySettings.js","sourceRoot":"","sources":["../../src/interfaces/RegistrySettings.ts"],"names":[],"mappings":"","sourcesContent":["import {Type} from \"@tsed/core\";\nimport type {Provider} from \"../domain\";\n\n/**\n * @ignore\n */\nexport interface RegistrySettings {\n injectable?: boolean;\n model?: Type<Provider>;\n\n /**\n *\n * @param provider\n * @param {Map<string | Function, any>} locals\n * @param deps\n */\n onInvoke?(provider: Provider, locals: Map<string | Function, any>, deps: any[]): void;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TokenProvider.js","sourceRoot":"","sources":["../../src/interfaces/TokenProvider.ts"],"names":[],"mappings":"","sourcesContent":["import type {Type} from \"@tsed/core\";\n\nexport type TokenProvider = string | symbol | Type | Function | any;\n"]}
|
package/lib/interfaces/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./DILogger"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./DIConfigurationOptions"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./DIResolver"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./InjectableProperties"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./InterceptorMethods"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./InterceptorContext"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./InvokeOptions"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./IProvider"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./OnInit"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./OnDestroy"), exports);
|
|
14
|
-
tslib_1.__exportStar(require("./OnInit"), exports);
|
|
15
|
-
tslib_1.__exportStar(require("./RegistrySettings"), exports);
|
|
16
|
-
tslib_1.__exportStar(require("./TokenProvider"), exports);
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interfaces/index.ts"],"names":[],"mappings":";;;AAAA,qDAA2B;AAC3B,mEAAyC;AACzC,uDAA6B;AAC7B,iEAAuC;AACvC,+DAAqC;AACrC,+DAAqC;AACrC,0DAAgC;AAChC,sDAA4B;AAC5B,mDAAyB;AACzB,sDAA4B;AAC5B,mDAAyB;AACzB,6DAAmC;AACnC,0DAAgC","sourcesContent":["export * from \"./DILogger\";\nexport * from \"./DIConfigurationOptions\";\nexport * from \"./DIResolver\";\nexport * from \"./InjectableProperties\";\nexport * from \"./InterceptorMethods\";\nexport * from \"./InterceptorContext\";\nexport * from \"./InvokeOptions\";\nexport * from \"./IProvider\";\nexport * from \"./OnInit\";\nexport * from \"./OnDestroy\";\nexport * from \"./OnInit\";\nexport * from \"./RegistrySettings\";\nexport * from \"./TokenProvider\";\n"]}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _settings;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.GlobalProviders = exports.GlobalProviderRegistry = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const core_1 = require("@tsed/core");
|
|
7
|
-
const domain_1 = require("../domain");
|
|
8
|
-
class GlobalProviderRegistry extends Map {
|
|
9
|
-
constructor() {
|
|
10
|
-
super(...arguments);
|
|
11
|
-
_settings.set(this, new Map());
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* The get() method returns a specified element from a Map object.
|
|
15
|
-
* @param key Required. The key of the element to return from the Map object.
|
|
16
|
-
* @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.
|
|
17
|
-
*/
|
|
18
|
-
get(key) {
|
|
19
|
-
return super.get(core_1.getClassOrSymbol(key));
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* The has() method returns a boolean indicating whether an element with the specified key exists or not.
|
|
23
|
-
* @param key
|
|
24
|
-
* @returns {boolean}
|
|
25
|
-
*/
|
|
26
|
-
has(key) {
|
|
27
|
-
return super.has(core_1.getClassOrSymbol(key));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* The set() method adds or updates an element with a specified key and value to a Map object.
|
|
31
|
-
* @param key Required. The key of the element to add to the Map object.
|
|
32
|
-
* @param metadata Required. The value of the element to add to the Map object.
|
|
33
|
-
*/
|
|
34
|
-
set(key, metadata) {
|
|
35
|
-
super.set(core_1.getClassOrSymbol(key), metadata);
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @param target
|
|
41
|
-
* @param options
|
|
42
|
-
*/
|
|
43
|
-
merge(target, options) {
|
|
44
|
-
const meta = this.createIfNotExists(target, options);
|
|
45
|
-
Object.keys(options).forEach((key) => {
|
|
46
|
-
meta[key] = options[key];
|
|
47
|
-
});
|
|
48
|
-
this.set(target, meta);
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* The delete() method removes the specified element from a Map object.
|
|
52
|
-
* @param key Required. The key of the element to remove from the Map object.
|
|
53
|
-
* @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.
|
|
54
|
-
*/
|
|
55
|
-
delete(key) {
|
|
56
|
-
return super.delete(core_1.getClassOrSymbol(key));
|
|
57
|
-
}
|
|
58
|
-
createRegistry(type, model, options = { injectable: true }) {
|
|
59
|
-
const defaultOptions = this.getRegistrySettings(type);
|
|
60
|
-
options = Object.assign(defaultOptions, {
|
|
61
|
-
...options,
|
|
62
|
-
model
|
|
63
|
-
});
|
|
64
|
-
tslib_1.__classPrivateFieldGet(this, _settings).set(type, options);
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
getRegistrySettings(target) {
|
|
68
|
-
let type = "provider";
|
|
69
|
-
if (typeof target === "string") {
|
|
70
|
-
type = target;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
const provider = this.get(target);
|
|
74
|
-
if (provider) {
|
|
75
|
-
type = provider.type;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return (tslib_1.__classPrivateFieldGet(this, _settings).get(type) || {
|
|
79
|
-
model: domain_1.Provider,
|
|
80
|
-
injectable: true
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
createRegisterFn(type) {
|
|
84
|
-
return (provider, instance) => {
|
|
85
|
-
if (!provider.provide) {
|
|
86
|
-
provider = {
|
|
87
|
-
provide: provider
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
provider = Object.assign({ instance }, provider, { type });
|
|
91
|
-
this.merge(provider.provide, provider);
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* @deprecated
|
|
96
|
-
*/
|
|
97
|
-
// istanbul ignore next
|
|
98
|
-
getRegistry(target) {
|
|
99
|
-
return this;
|
|
100
|
-
}
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
103
|
-
* @param key
|
|
104
|
-
* @param options
|
|
105
|
-
*/
|
|
106
|
-
createIfNotExists(key, options) {
|
|
107
|
-
const type = options.type || domain_1.ProviderType.PROVIDER;
|
|
108
|
-
if (!this.has(key)) {
|
|
109
|
-
const { model = domain_1.Provider } = tslib_1.__classPrivateFieldGet(this, _settings).get(type) || {};
|
|
110
|
-
const item = new model(key);
|
|
111
|
-
this.set(key, item);
|
|
112
|
-
}
|
|
113
|
-
return this.get(key);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
exports.GlobalProviderRegistry = GlobalProviderRegistry;
|
|
117
|
-
_settings = new WeakMap();
|
|
118
|
-
/**
|
|
119
|
-
*
|
|
120
|
-
* @type {GlobalProviders}
|
|
121
|
-
*/
|
|
122
|
-
// tslint:disable-next-line: variable-name
|
|
123
|
-
exports.GlobalProviders = new GlobalProviderRegistry();
|
|
124
|
-
//# sourceMappingURL=GlobalProviders.js.map
|