Package not found. Please check the package name and try again.
@midwayjs/core 3.19.0-beta.2 → 4.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/LICENSE +21 -0
- package/dist/baseFramework.d.ts +7 -35
- package/dist/baseFramework.js +10 -52
- package/dist/common/applicationManager.d.ts +6 -6
- package/dist/common/applicationManager.js +18 -35
- package/dist/common/asyncContextManager.d.ts +15 -0
- package/dist/common/asyncContextManager.js +51 -2
- package/dist/common/dataListener.js +1 -1
- package/dist/common/dataSourceManager.d.ts +3 -0
- package/dist/common/dataSourceManager.js +6 -4
- package/dist/common/fileDetector.d.ts +9 -9
- package/dist/common/fileDetector.js +30 -28
- package/dist/common/filterManager.js +5 -4
- package/dist/common/guardManager.js +3 -2
- package/dist/common/middlewareManager.js +4 -3
- package/dist/common/performanceManager.d.ts +3 -3
- package/dist/common/performanceManager.js +17 -9
- package/dist/common/priorityManager.js +2 -2
- package/dist/common/serviceFactory.js +1 -1
- package/dist/common/typedResourceManager.js +2 -0
- package/dist/common/webGenerator.js +4 -6
- package/dist/config/config.default.js +1 -1
- package/dist/constants.d.ts +2 -32
- package/dist/constants.js +3 -33
- package/dist/context/componentLoader.d.ts +20 -0
- package/dist/context/componentLoader.js +193 -0
- package/dist/context/container.d.ts +14 -29
- package/dist/context/container.js +68 -306
- package/dist/context/definitionRegistry.d.ts +3 -0
- package/dist/context/definitionRegistry.js +8 -15
- package/dist/context/managedResolverFactory.d.ts +15 -40
- package/dist/context/managedResolverFactory.js +263 -348
- package/dist/context/requestContainer.d.ts +22 -12
- package/dist/context/requestContainer.js +43 -51
- package/dist/decorator/common/aspect.js +4 -4
- package/dist/decorator/common/autoload.js +1 -1
- package/dist/decorator/common/configuration.d.ts +1 -24
- package/dist/decorator/common/configuration.js +6 -1
- package/dist/decorator/common/filter.js +6 -6
- package/dist/decorator/common/framework.d.ts +46 -3
- package/dist/decorator/common/framework.js +43 -9
- package/dist/decorator/common/guard.js +4 -9
- package/dist/decorator/common/inject.d.ts +4 -2
- package/dist/decorator/common/inject.js +87 -4
- package/dist/decorator/common/mock.js +1 -1
- package/dist/decorator/common/objectDef.d.ts +0 -5
- package/dist/decorator/common/objectDef.js +8 -20
- package/dist/decorator/common/provide.d.ts +1 -1
- package/dist/decorator/common/provide.js +1 -1
- package/dist/decorator/common/scope.d.ts +6 -0
- package/dist/decorator/common/scope.js +21 -0
- package/dist/decorator/constant.d.ts +14 -17
- package/dist/decorator/constant.js +23 -35
- package/dist/decorator/decoratorManager.d.ts +21 -294
- package/dist/decorator/decoratorManager.js +127 -694
- package/dist/decorator/faas/serverlessTrigger.js +5 -5
- package/dist/decorator/index.d.ts +2 -3
- package/dist/decorator/index.js +6 -4
- package/dist/decorator/metadataManager.d.ts +127 -0
- package/dist/decorator/metadataManager.js +465 -0
- package/dist/decorator/microservice/consumer.js +3 -2
- package/dist/decorator/microservice/kafkaListener.js +2 -1
- package/dist/decorator/microservice/provider.js +6 -5
- package/dist/decorator/microservice/rabbitmqListener.js +2 -1
- package/dist/decorator/task/queue.js +3 -2
- package/dist/decorator/task/schedule.js +3 -2
- package/dist/decorator/task/task.js +4 -3
- package/dist/decorator/task/taskLocal.js +4 -3
- package/dist/decorator/web/controller.js +3 -2
- package/dist/decorator/web/paramMapping.js +2 -2
- package/dist/decorator/web/requestMapping.js +5 -5
- package/dist/decorator/web/response.js +6 -5
- package/dist/decorator/ws/webSocketController.js +3 -2
- package/dist/decorator/ws/webSocketEvent.js +7 -6
- package/dist/definitions/functionDefinition.d.ts +3 -3
- package/dist/definitions/functionDefinition.js +12 -11
- package/dist/definitions/objectCreator.d.ts +5 -11
- package/dist/definitions/objectCreator.js +3 -27
- package/dist/definitions/objectDefinition.d.ts +2 -3
- package/dist/definitions/objectDefinition.js +1 -3
- package/dist/error/base.js +2 -2
- package/dist/error/framework.d.ts +1 -8
- package/dist/error/framework.js +9 -25
- package/dist/error/http.js +1 -1
- package/dist/functional/configuration.d.ts +14 -15
- package/dist/functional/configuration.js +37 -47
- package/dist/functional/hooks.d.ts +10 -0
- package/dist/functional/hooks.js +68 -0
- package/dist/functional/index.d.ts +3 -0
- package/dist/functional/index.js +22 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +5 -6
- package/dist/interface.d.ts +80 -113
- package/dist/interface.js +9 -33
- package/dist/legacy/constants.d.ts +29 -0
- package/dist/legacy/constants.js +33 -0
- package/dist/legacy/decorator.d.ts +255 -0
- package/dist/legacy/decorator.js +468 -0
- package/dist/legacy/index.d.ts +3 -0
- package/dist/legacy/index.js +19 -0
- package/dist/legacy/types.d.ts +2 -0
- package/dist/legacy/types.js +3 -0
- package/dist/response/base.d.ts +1 -0
- package/dist/response/http.d.ts +1 -0
- package/dist/response/sse.js +1 -3
- package/dist/service/aspectService.js +11 -12
- package/dist/service/configService.js +2 -2
- package/dist/service/decoratorService.d.ts +3 -3
- package/dist/service/decoratorService.js +14 -10
- package/dist/service/environmentService.d.ts +1 -0
- package/dist/service/environmentService.js +5 -2
- package/dist/service/frameworkService.d.ts +5 -4
- package/dist/service/frameworkService.js +30 -28
- package/dist/service/healthService.js +4 -4
- package/dist/service/informationService.js +3 -4
- package/dist/service/lifeCycleService.js +6 -17
- package/dist/service/loggerService.js +3 -4
- package/dist/service/middlewareService.js +7 -8
- package/dist/service/mockService.d.ts +28 -12
- package/dist/service/mockService.js +82 -49
- package/dist/service/slsFunctionService.d.ts +1 -14
- package/dist/service/slsFunctionService.js +33 -81
- package/dist/service/webRouterService.js +11 -11
- package/dist/setup.d.ts +5 -5
- package/dist/setup.js +75 -93
- package/dist/util/contextUtil.d.ts +2 -2
- package/dist/util/httpclient.d.ts +3 -2
- package/dist/util/index.d.ts +14 -0
- package/dist/util/index.js +159 -25
- package/dist/util/pathFileUtil.d.ts +14 -1
- package/dist/util/pathFileUtil.js +27 -6
- package/dist/util/webRouterParam.js +2 -2
- package/package.json +24 -6
- package/dist/decorator/common/pipeline.d.ts +0 -3
- package/dist/decorator/common/pipeline.js +0 -12
- package/dist/decorator/rpc/hsf.d.ts +0 -13
- package/dist/decorator/rpc/hsf.js +0 -20
- package/dist/definitions/properties.d.ts +0 -7
- package/dist/definitions/properties.js +0 -19
- package/dist/service/pipelineService.d.ts +0 -168
- package/dist/service/pipelineService.js +0 -254
|
@@ -1,729 +1,162 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
require("reflect-metadata");
|
|
5
|
-
const interface_1 = require("../interface");
|
|
3
|
+
exports.DecoratorManager = void 0;
|
|
6
4
|
const constant_1 = require("./constant");
|
|
7
|
-
const types_1 = require("../util/types");
|
|
8
5
|
const camelCase_1 = require("../util/camelCase");
|
|
9
6
|
const util_1 = require("../util");
|
|
10
7
|
const pathFileUtil_1 = require("../util/pathFileUtil");
|
|
8
|
+
const metadataManager_1 = require("./metadataManager");
|
|
9
|
+
const types_1 = require("../util/types");
|
|
10
|
+
const error_1 = require("../error");
|
|
11
11
|
const debug = require('util').debuglog('midway:core');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* the key for method meta data store in class
|
|
23
|
-
*/
|
|
24
|
-
this.injectClassMethodKeyPrefix = 'INJECTION_CLASS_METHOD_META_DATA';
|
|
25
|
-
/**
|
|
26
|
-
* the key for method meta data store in method
|
|
27
|
-
*/
|
|
28
|
-
this.injectMethodKeyPrefix = 'INJECTION_METHOD_META_DATA';
|
|
29
|
-
}
|
|
30
|
-
saveModule(key, module) {
|
|
31
|
-
if (this.container) {
|
|
32
|
-
return this.container.saveModule(key, module);
|
|
12
|
+
/**
|
|
13
|
+
* This class is used to manage the decorator data of the class
|
|
14
|
+
*
|
|
15
|
+
* @since 3.0.0
|
|
16
|
+
*/
|
|
17
|
+
class DecoratorManager {
|
|
18
|
+
static saveModule(key, module) {
|
|
19
|
+
if ((0, types_1.isClass)(module)) {
|
|
20
|
+
this.saveProviderId(undefined, module);
|
|
33
21
|
}
|
|
34
|
-
if (!this.has(key)) {
|
|
35
|
-
this.set(key, new Set());
|
|
22
|
+
if (!this.moduleStore.has(key)) {
|
|
23
|
+
this.moduleStore.set(key, new Set());
|
|
36
24
|
}
|
|
37
|
-
this.get(key).add(module);
|
|
25
|
+
this.moduleStore.get(key).add(module);
|
|
38
26
|
}
|
|
39
|
-
listModule(key) {
|
|
40
|
-
|
|
41
|
-
|
|
27
|
+
static listModule(key, filter) {
|
|
28
|
+
const modules = [...(this.moduleStore.get(key) || [])];
|
|
29
|
+
if (filter) {
|
|
30
|
+
return modules.filter(filter);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return modules;
|
|
42
34
|
}
|
|
43
|
-
return Array.from(this.get(key) || {});
|
|
44
|
-
}
|
|
45
|
-
resetModule(key) {
|
|
46
|
-
this.set(key, new Set());
|
|
47
|
-
}
|
|
48
|
-
bindContainer(container) {
|
|
49
|
-
this.container = container;
|
|
50
|
-
this.container.transformModule(this);
|
|
51
|
-
}
|
|
52
|
-
static getDecoratorClassKey(decoratorNameKey) {
|
|
53
|
-
return decoratorNameKey.toString() + '_CLS';
|
|
54
|
-
}
|
|
55
|
-
static removeDecoratorClassKeySuffix(decoratorNameKey) {
|
|
56
|
-
return decoratorNameKey.toString().replace('_CLS', '');
|
|
57
|
-
}
|
|
58
|
-
static getDecoratorMethodKey(decoratorNameKey) {
|
|
59
|
-
return decoratorNameKey.toString() + '_METHOD';
|
|
60
35
|
}
|
|
61
|
-
static
|
|
62
|
-
|
|
36
|
+
static savePreStartModule(module) {
|
|
37
|
+
this.saveModule(constant_1.PRE_START_MODULE_KEY, module);
|
|
63
38
|
}
|
|
64
|
-
static
|
|
65
|
-
return
|
|
39
|
+
static listPreStartModule() {
|
|
40
|
+
return this.listModule(constant_1.PRE_START_MODULE_KEY);
|
|
66
41
|
}
|
|
67
|
-
static
|
|
68
|
-
|
|
69
|
-
':' +
|
|
70
|
-
methodKey.toString());
|
|
42
|
+
static resetModule(key) {
|
|
43
|
+
this.moduleStore.set(key, new Set());
|
|
71
44
|
}
|
|
72
|
-
static
|
|
73
|
-
|
|
74
|
-
'_' +
|
|
75
|
-
methodKey.toString());
|
|
45
|
+
static clearAllModule() {
|
|
46
|
+
this.moduleStore.clear();
|
|
76
47
|
}
|
|
77
|
-
static
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
else {
|
|
87
|
-
m = new Map();
|
|
88
|
-
}
|
|
89
|
-
m.set(dataKey, data);
|
|
90
|
-
Reflect.defineMetadata(metaKey, m, target);
|
|
91
|
-
}
|
|
92
|
-
static attachMetadata(metaKey, target, dataKey, data, groupBy, groupMode = 'one') {
|
|
93
|
-
// filter Object.create(null)
|
|
94
|
-
if (typeof target === 'object' && target.constructor) {
|
|
95
|
-
target = target.constructor;
|
|
96
|
-
}
|
|
97
|
-
let m;
|
|
98
|
-
if (Reflect.hasOwnMetadata(metaKey, target)) {
|
|
99
|
-
m = Reflect.getMetadata(metaKey, target);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
m = new Map();
|
|
103
|
-
}
|
|
104
|
-
if (!m.has(dataKey)) {
|
|
105
|
-
if (groupBy) {
|
|
106
|
-
m.set(dataKey, {});
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
m.set(dataKey, []);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
if (groupBy) {
|
|
113
|
-
if (groupMode === 'one') {
|
|
114
|
-
m.get(dataKey)[groupBy] = data;
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
if (m.get(dataKey)[groupBy]) {
|
|
118
|
-
m.get(dataKey)[groupBy].push(data);
|
|
119
|
-
}
|
|
120
|
-
else {
|
|
121
|
-
m.get(dataKey)[groupBy] = [data];
|
|
48
|
+
static saveProviderId(identifier, target) {
|
|
49
|
+
if (this.isProvide(target)) {
|
|
50
|
+
if (identifier) {
|
|
51
|
+
const meta = metadataManager_1.MetadataManager.getOwnMetadata(constant_1.PROVIDE_KEY, target);
|
|
52
|
+
if (meta.id !== identifier) {
|
|
53
|
+
meta.id = identifier;
|
|
54
|
+
// save class id and uuid
|
|
55
|
+
metadataManager_1.MetadataManager.defineMetadata(constant_1.PROVIDE_KEY, meta, target);
|
|
56
|
+
debug(`update provide: ${target.name} -> ${meta.uuid}`);
|
|
122
57
|
}
|
|
123
58
|
}
|
|
124
59
|
}
|
|
125
60
|
else {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (!Reflect.hasOwnMetadata(metaKey, target)) {
|
|
137
|
-
m = new Map();
|
|
138
|
-
Reflect.defineMetadata(metaKey, m, target);
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
m = Reflect.getMetadata(metaKey, target);
|
|
142
|
-
}
|
|
143
|
-
if (!dataKey) {
|
|
144
|
-
return m;
|
|
61
|
+
// save
|
|
62
|
+
const uuid = (0, util_1.generateRandomId)();
|
|
63
|
+
// save class id and uuid
|
|
64
|
+
metadataManager_1.MetadataManager.defineMetadata(constant_1.PROVIDE_KEY, {
|
|
65
|
+
id: identifier,
|
|
66
|
+
originName: target.name,
|
|
67
|
+
uuid,
|
|
68
|
+
name: (0, camelCase_1.camelCase)(target.name),
|
|
69
|
+
}, target);
|
|
70
|
+
debug(`save provide: ${target.name} -> ${uuid}`);
|
|
145
71
|
}
|
|
146
|
-
return
|
|
72
|
+
return target;
|
|
147
73
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
* @param target target class
|
|
153
|
-
* @param propertyName
|
|
154
|
-
*/
|
|
155
|
-
saveMetadata(decoratorNameKey, data, target, propertyName) {
|
|
156
|
-
if (propertyName) {
|
|
157
|
-
const dataKey = DecoratorManager.getDecoratorMethod(decoratorNameKey, propertyName);
|
|
158
|
-
DecoratorManager.saveMetadata(this.injectMethodKeyPrefix, target, dataKey, data);
|
|
159
|
-
}
|
|
160
|
-
else {
|
|
161
|
-
const dataKey = DecoratorManager.getDecoratorClassKey(decoratorNameKey);
|
|
162
|
-
DecoratorManager.saveMetadata(this.injectClassKeyPrefix, target, dataKey, data);
|
|
74
|
+
static getProviderId(module) {
|
|
75
|
+
const metaData = metadataManager_1.MetadataManager.getOwnMetadata(constant_1.PROVIDE_KEY, module);
|
|
76
|
+
if (metaData && metaData.id) {
|
|
77
|
+
return metaData.id;
|
|
163
78
|
}
|
|
164
79
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
* @param target
|
|
170
|
-
* @param propertyName
|
|
171
|
-
* @param groupBy
|
|
172
|
-
*/
|
|
173
|
-
attachMetadata(decoratorNameKey, data, target, propertyName, groupBy, groupMode) {
|
|
174
|
-
if (propertyName) {
|
|
175
|
-
const dataKey = DecoratorManager.getDecoratorMethod(decoratorNameKey, propertyName);
|
|
176
|
-
DecoratorManager.attachMetadata(this.injectMethodKeyPrefix, target, dataKey, data, groupBy, groupMode);
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
const dataKey = DecoratorManager.getDecoratorClassKey(decoratorNameKey);
|
|
180
|
-
DecoratorManager.attachMetadata(this.injectClassKeyPrefix, target, dataKey, data, groupBy, groupMode);
|
|
80
|
+
static getProviderName(module) {
|
|
81
|
+
const metaData = metadataManager_1.MetadataManager.getOwnMetadata(constant_1.PROVIDE_KEY, module);
|
|
82
|
+
if (metaData && metaData.name) {
|
|
83
|
+
return metaData.name;
|
|
181
84
|
}
|
|
182
85
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
* @param propertyName
|
|
188
|
-
*/
|
|
189
|
-
getMetadata(decoratorNameKey, target, propertyName) {
|
|
190
|
-
if (propertyName) {
|
|
191
|
-
const dataKey = DecoratorManager.getDecoratorMethod(decoratorNameKey, propertyName);
|
|
192
|
-
return DecoratorManager.getMetadata(this.injectMethodKeyPrefix, target, dataKey);
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
const dataKey = `${DecoratorManager.getDecoratorClassKey(decoratorNameKey)}`;
|
|
196
|
-
return DecoratorManager.getMetadata(this.injectClassKeyPrefix, target, dataKey);
|
|
86
|
+
static getProviderUUId(module) {
|
|
87
|
+
const metaData = metadataManager_1.MetadataManager.getOwnMetadata(constant_1.PROVIDE_KEY, module);
|
|
88
|
+
if (metaData && metaData.uuid) {
|
|
89
|
+
return metaData.uuid;
|
|
197
90
|
}
|
|
198
91
|
}
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
* @param decoratorNameKey
|
|
202
|
-
* @param data
|
|
203
|
-
* @param target
|
|
204
|
-
* @param propertyName
|
|
205
|
-
*/
|
|
206
|
-
savePropertyDataToClass(decoratorNameKey, data, target, propertyName) {
|
|
207
|
-
const dataKey = DecoratorManager.getDecoratorClsMethodKey(decoratorNameKey, propertyName);
|
|
208
|
-
DecoratorManager.saveMetadata(this.injectClassMethodKeyPrefix, target, dataKey, data);
|
|
92
|
+
static isProvide(target) {
|
|
93
|
+
return !!metadataManager_1.MetadataManager.getOwnMetadata(constant_1.PROVIDE_KEY, target);
|
|
209
94
|
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
* @param target
|
|
215
|
-
* @param propertyName
|
|
216
|
-
* @param groupBy
|
|
217
|
-
*/
|
|
218
|
-
attachPropertyDataToClass(decoratorNameKey, data, target, propertyName, groupBy) {
|
|
219
|
-
const dataKey = DecoratorManager.getDecoratorClsMethodKey(decoratorNameKey, propertyName);
|
|
220
|
-
DecoratorManager.attachMetadata(this.injectClassMethodKeyPrefix, target, dataKey, data, groupBy);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* get property data from class
|
|
224
|
-
* @param decoratorNameKey
|
|
225
|
-
* @param target
|
|
226
|
-
* @param propertyName
|
|
227
|
-
*/
|
|
228
|
-
getPropertyDataFromClass(decoratorNameKey, target, propertyName) {
|
|
229
|
-
const dataKey = DecoratorManager.getDecoratorClsMethodKey(decoratorNameKey, propertyName);
|
|
230
|
-
return DecoratorManager.getMetadata(this.injectClassMethodKeyPrefix, target, dataKey);
|
|
231
|
-
}
|
|
232
|
-
/**
|
|
233
|
-
* list property data from class
|
|
234
|
-
* @param decoratorNameKey
|
|
235
|
-
* @param target
|
|
236
|
-
*/
|
|
237
|
-
listPropertyDataFromClass(decoratorNameKey, target) {
|
|
238
|
-
const originMap = DecoratorManager.getMetadata(this.injectClassMethodKeyPrefix, target);
|
|
239
|
-
const res = [];
|
|
240
|
-
for (const [key, value] of originMap) {
|
|
241
|
-
if (key.indexOf(DecoratorManager.getDecoratorClsMethodPrefix(decoratorNameKey)) !== -1) {
|
|
242
|
-
res.push(value);
|
|
95
|
+
static createCustomPropertyDecorator(decoratorKey, metadata, implOrOptions = { impl: true }) {
|
|
96
|
+
const implOrOpt = typeof implOrOptions === 'boolean'
|
|
97
|
+
? {
|
|
98
|
+
impl: implOrOptions,
|
|
243
99
|
}
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
manager = global['MIDWAY_GLOBAL_DECORATOR_MANAGER'];
|
|
261
|
-
}
|
|
262
|
-
else {
|
|
263
|
-
global['MIDWAY_GLOBAL_DECORATOR_MANAGER'] = manager;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* save data to class
|
|
268
|
-
* @param decoratorNameKey
|
|
269
|
-
* @param data
|
|
270
|
-
* @param target
|
|
271
|
-
* @param mergeIfExist
|
|
272
|
-
*/
|
|
273
|
-
function saveClassMetadata(decoratorNameKey, data, target, mergeIfExist) {
|
|
274
|
-
if (mergeIfExist && typeof data === 'object') {
|
|
275
|
-
const originData = manager.getMetadata(decoratorNameKey, target);
|
|
276
|
-
if (!originData) {
|
|
277
|
-
return manager.saveMetadata(decoratorNameKey, data, target);
|
|
278
|
-
}
|
|
279
|
-
if (Array.isArray(originData)) {
|
|
280
|
-
return manager.saveMetadata(decoratorNameKey, originData.concat(data), target);
|
|
281
|
-
}
|
|
282
|
-
else {
|
|
283
|
-
return manager.saveMetadata(decoratorNameKey, Object.assign(originData, data), target);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
else {
|
|
287
|
-
return manager.saveMetadata(decoratorNameKey, data, target);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
exports.saveClassMetadata = saveClassMetadata;
|
|
291
|
-
/**
|
|
292
|
-
* attach data to class
|
|
293
|
-
* @param decoratorNameKey
|
|
294
|
-
* @param data
|
|
295
|
-
* @param target
|
|
296
|
-
* @param groupBy
|
|
297
|
-
*/
|
|
298
|
-
function attachClassMetadata(decoratorNameKey, data, target, groupBy, groupMode) {
|
|
299
|
-
return manager.attachMetadata(decoratorNameKey, data, target, undefined, groupBy, groupMode);
|
|
300
|
-
}
|
|
301
|
-
exports.attachClassMetadata = attachClassMetadata;
|
|
302
|
-
/**
|
|
303
|
-
* get data from class and proto
|
|
304
|
-
* @param decoratorNameKey
|
|
305
|
-
* @param target
|
|
306
|
-
* @param propertyName
|
|
307
|
-
* @param useCache
|
|
308
|
-
*/
|
|
309
|
-
function getClassExtendedMetadata(decoratorNameKey, target, propertyName, useCache) {
|
|
310
|
-
if (useCache === undefined) {
|
|
311
|
-
useCache = true;
|
|
312
|
-
}
|
|
313
|
-
const extKey = DecoratorManager.getDecoratorClsExtendedKey(decoratorNameKey);
|
|
314
|
-
let metadata = manager.getMetadata(extKey, target, propertyName);
|
|
315
|
-
if (useCache && metadata !== undefined) {
|
|
316
|
-
return metadata;
|
|
317
|
-
}
|
|
318
|
-
const father = Reflect.getPrototypeOf(target);
|
|
319
|
-
if (father && father.constructor !== Object) {
|
|
320
|
-
metadata = (0, util_1.merge)(getClassExtendedMetadata(decoratorNameKey, father, propertyName, useCache), manager.getMetadata(decoratorNameKey, target, propertyName));
|
|
321
|
-
}
|
|
322
|
-
manager.saveMetadata(extKey, metadata || null, target, propertyName);
|
|
323
|
-
return metadata;
|
|
324
|
-
}
|
|
325
|
-
exports.getClassExtendedMetadata = getClassExtendedMetadata;
|
|
326
|
-
/**
|
|
327
|
-
* get data from class
|
|
328
|
-
* @param decoratorNameKey
|
|
329
|
-
* @param target
|
|
330
|
-
*/
|
|
331
|
-
function getClassMetadata(decoratorNameKey, target) {
|
|
332
|
-
return manager.getMetadata(decoratorNameKey, target);
|
|
333
|
-
}
|
|
334
|
-
exports.getClassMetadata = getClassMetadata;
|
|
335
|
-
/**
|
|
336
|
-
* save property data to class
|
|
337
|
-
* @param decoratorNameKey
|
|
338
|
-
* @param data
|
|
339
|
-
* @param target
|
|
340
|
-
* @param propertyName
|
|
341
|
-
*/
|
|
342
|
-
function savePropertyDataToClass(decoratorNameKey, data, target, propertyName) {
|
|
343
|
-
return manager.savePropertyDataToClass(decoratorNameKey, data, target, propertyName);
|
|
344
|
-
}
|
|
345
|
-
exports.savePropertyDataToClass = savePropertyDataToClass;
|
|
346
|
-
/**
|
|
347
|
-
* attach property data to class
|
|
348
|
-
* @param decoratorNameKey
|
|
349
|
-
* @param data
|
|
350
|
-
* @param target
|
|
351
|
-
* @param propertyName
|
|
352
|
-
* @param groupBy
|
|
353
|
-
*/
|
|
354
|
-
function attachPropertyDataToClass(decoratorNameKey, data, target, propertyName, groupBy) {
|
|
355
|
-
return manager.attachPropertyDataToClass(decoratorNameKey, data, target, propertyName, groupBy);
|
|
356
|
-
}
|
|
357
|
-
exports.attachPropertyDataToClass = attachPropertyDataToClass;
|
|
358
|
-
/**
|
|
359
|
-
* get property data from class
|
|
360
|
-
* @param decoratorNameKey
|
|
361
|
-
* @param target
|
|
362
|
-
* @param propertyName
|
|
363
|
-
*/
|
|
364
|
-
function getPropertyDataFromClass(decoratorNameKey, target, propertyName) {
|
|
365
|
-
return manager.getPropertyDataFromClass(decoratorNameKey, target, propertyName);
|
|
366
|
-
}
|
|
367
|
-
exports.getPropertyDataFromClass = getPropertyDataFromClass;
|
|
368
|
-
/**
|
|
369
|
-
* list property data from class
|
|
370
|
-
* @param decoratorNameKey
|
|
371
|
-
* @param target
|
|
372
|
-
*/
|
|
373
|
-
function listPropertyDataFromClass(decoratorNameKey, target) {
|
|
374
|
-
return manager.listPropertyDataFromClass(decoratorNameKey, target);
|
|
375
|
-
}
|
|
376
|
-
exports.listPropertyDataFromClass = listPropertyDataFromClass;
|
|
377
|
-
/**
|
|
378
|
-
* save property data
|
|
379
|
-
* @param decoratorNameKey
|
|
380
|
-
* @param data
|
|
381
|
-
* @param target
|
|
382
|
-
* @param propertyName
|
|
383
|
-
*/
|
|
384
|
-
function savePropertyMetadata(decoratorNameKey, data, target, propertyName) {
|
|
385
|
-
return manager.saveMetadata(decoratorNameKey, data, target, propertyName);
|
|
386
|
-
}
|
|
387
|
-
exports.savePropertyMetadata = savePropertyMetadata;
|
|
388
|
-
/**
|
|
389
|
-
* attach property data
|
|
390
|
-
* @param decoratorNameKey
|
|
391
|
-
* @param data
|
|
392
|
-
* @param target
|
|
393
|
-
* @param propertyName
|
|
394
|
-
*/
|
|
395
|
-
function attachPropertyMetadata(decoratorNameKey, data, target, propertyName) {
|
|
396
|
-
return manager.attachMetadata(decoratorNameKey, data, target, propertyName);
|
|
397
|
-
}
|
|
398
|
-
exports.attachPropertyMetadata = attachPropertyMetadata;
|
|
399
|
-
/**
|
|
400
|
-
* get property data
|
|
401
|
-
* @param decoratorNameKey
|
|
402
|
-
* @param target
|
|
403
|
-
* @param propertyName
|
|
404
|
-
*/
|
|
405
|
-
function getPropertyMetadata(decoratorNameKey, target, propertyName) {
|
|
406
|
-
return manager.getMetadata(decoratorNameKey, target, propertyName);
|
|
407
|
-
}
|
|
408
|
-
exports.getPropertyMetadata = getPropertyMetadata;
|
|
409
|
-
/**
|
|
410
|
-
* save preload module by target
|
|
411
|
-
* @param target
|
|
412
|
-
*/
|
|
413
|
-
function savePreloadModule(target) {
|
|
414
|
-
return saveModule(exports.PRELOAD_MODULE_KEY, target);
|
|
415
|
-
}
|
|
416
|
-
exports.savePreloadModule = savePreloadModule;
|
|
417
|
-
/**
|
|
418
|
-
* list preload module
|
|
419
|
-
*/
|
|
420
|
-
function listPreloadModule() {
|
|
421
|
-
return listModule(exports.PRELOAD_MODULE_KEY);
|
|
422
|
-
}
|
|
423
|
-
exports.listPreloadModule = listPreloadModule;
|
|
424
|
-
/**
|
|
425
|
-
* save module to inner map
|
|
426
|
-
* @param decoratorNameKey
|
|
427
|
-
* @param target
|
|
428
|
-
*/
|
|
429
|
-
function saveModule(decoratorNameKey, target) {
|
|
430
|
-
if ((0, types_1.isClass)(target)) {
|
|
431
|
-
saveProviderId(undefined, target);
|
|
432
|
-
}
|
|
433
|
-
return manager.saveModule(decoratorNameKey, target);
|
|
434
|
-
}
|
|
435
|
-
exports.saveModule = saveModule;
|
|
436
|
-
function bindContainer(container) {
|
|
437
|
-
return manager.bindContainer(container);
|
|
438
|
-
}
|
|
439
|
-
exports.bindContainer = bindContainer;
|
|
440
|
-
function clearBindContainer() {
|
|
441
|
-
return (manager.container = null);
|
|
442
|
-
}
|
|
443
|
-
exports.clearBindContainer = clearBindContainer;
|
|
444
|
-
/**
|
|
445
|
-
* list module from decorator key
|
|
446
|
-
* @param decoratorNameKey
|
|
447
|
-
* @param filter
|
|
448
|
-
*/
|
|
449
|
-
function listModule(decoratorNameKey, filter) {
|
|
450
|
-
const modules = manager.listModule(decoratorNameKey);
|
|
451
|
-
if (filter) {
|
|
452
|
-
return modules.filter(filter);
|
|
453
|
-
}
|
|
454
|
-
else {
|
|
455
|
-
return modules;
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
exports.listModule = listModule;
|
|
459
|
-
/**
|
|
460
|
-
* reset module
|
|
461
|
-
* @param decoratorNameKey
|
|
462
|
-
*/
|
|
463
|
-
function resetModule(decoratorNameKey) {
|
|
464
|
-
return manager.resetModule(decoratorNameKey);
|
|
465
|
-
}
|
|
466
|
-
exports.resetModule = resetModule;
|
|
467
|
-
/**
|
|
468
|
-
* clear all module
|
|
469
|
-
*/
|
|
470
|
-
function clearAllModule() {
|
|
471
|
-
debug('--- clear all module here ---');
|
|
472
|
-
return manager.clear();
|
|
473
|
-
}
|
|
474
|
-
exports.clearAllModule = clearAllModule;
|
|
475
|
-
function transformTypeFromTSDesign(designFn) {
|
|
476
|
-
if ((0, types_1.isNullOrUndefined)(designFn)) {
|
|
477
|
-
return { name: 'undefined', isBaseType: true, originDesign: designFn };
|
|
478
|
-
}
|
|
479
|
-
switch (designFn.name) {
|
|
480
|
-
case 'String':
|
|
481
|
-
return { name: 'string', isBaseType: true, originDesign: designFn };
|
|
482
|
-
case 'Number':
|
|
483
|
-
return { name: 'number', isBaseType: true, originDesign: designFn };
|
|
484
|
-
case 'Boolean':
|
|
485
|
-
return { name: 'boolean', isBaseType: true, originDesign: designFn };
|
|
486
|
-
case 'Symbol':
|
|
487
|
-
return { name: 'symbol', isBaseType: true, originDesign: designFn };
|
|
488
|
-
case 'Object':
|
|
489
|
-
return { name: 'object', isBaseType: true, originDesign: designFn };
|
|
490
|
-
case 'Function':
|
|
491
|
-
return { name: 'function', isBaseType: true, originDesign: designFn };
|
|
492
|
-
default:
|
|
493
|
-
return {
|
|
494
|
-
name: designFn.name,
|
|
495
|
-
isBaseType: false,
|
|
496
|
-
originDesign: designFn,
|
|
497
|
-
};
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
exports.transformTypeFromTSDesign = transformTypeFromTSDesign;
|
|
501
|
-
/**
|
|
502
|
-
* save property inject args
|
|
503
|
-
* @param opts 参数
|
|
504
|
-
*/
|
|
505
|
-
function savePropertyInject(opts) {
|
|
506
|
-
// 1、use identifier by user
|
|
507
|
-
let identifier = opts.identifier;
|
|
508
|
-
let injectMode = interface_1.InjectModeEnum.Identifier;
|
|
509
|
-
// 2、use identifier by class uuid
|
|
510
|
-
if (!identifier) {
|
|
511
|
-
const type = getPropertyType(opts.target, opts.targetKey);
|
|
512
|
-
if (!type.isBaseType &&
|
|
513
|
-
(0, types_1.isClass)(type.originDesign) &&
|
|
514
|
-
isProvide(type.originDesign)) {
|
|
515
|
-
identifier = getProviderUUId(type.originDesign);
|
|
516
|
-
injectMode = interface_1.InjectModeEnum.Class;
|
|
517
|
-
}
|
|
518
|
-
if (!identifier) {
|
|
519
|
-
// 3、use identifier by property name
|
|
520
|
-
identifier = opts.targetKey;
|
|
521
|
-
injectMode = interface_1.InjectModeEnum.PropertyName;
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
attachClassMetadata(constant_1.INJECT_TAG, {
|
|
525
|
-
targetKey: opts.targetKey,
|
|
526
|
-
value: identifier,
|
|
527
|
-
args: opts.args,
|
|
528
|
-
injectMode,
|
|
529
|
-
}, opts.target, opts.targetKey);
|
|
530
|
-
}
|
|
531
|
-
exports.savePropertyInject = savePropertyInject;
|
|
532
|
-
/**
|
|
533
|
-
* get property inject args
|
|
534
|
-
* @param target
|
|
535
|
-
* @param useCache
|
|
536
|
-
*/
|
|
537
|
-
function getPropertyInject(target, useCache) {
|
|
538
|
-
return getClassExtendedMetadata(constant_1.INJECT_TAG, target, undefined, useCache);
|
|
539
|
-
}
|
|
540
|
-
exports.getPropertyInject = getPropertyInject;
|
|
541
|
-
/**
|
|
542
|
-
* save class object definition
|
|
543
|
-
* @param target class
|
|
544
|
-
* @param props property data
|
|
545
|
-
*/
|
|
546
|
-
function saveObjectDefinition(target, props = {}) {
|
|
547
|
-
saveClassMetadata(constant_1.OBJ_DEF_CLS, props, target, true);
|
|
548
|
-
return target;
|
|
549
|
-
}
|
|
550
|
-
exports.saveObjectDefinition = saveObjectDefinition;
|
|
551
|
-
/**
|
|
552
|
-
* get class object definition from metadata
|
|
553
|
-
* @param target
|
|
554
|
-
*/
|
|
555
|
-
function getObjectDefinition(target) {
|
|
556
|
-
return getClassExtendedMetadata(constant_1.OBJ_DEF_CLS, target);
|
|
557
|
-
}
|
|
558
|
-
exports.getObjectDefinition = getObjectDefinition;
|
|
559
|
-
/**
|
|
560
|
-
* class provider id
|
|
561
|
-
* @param identifier id
|
|
562
|
-
* @param target class
|
|
563
|
-
*/
|
|
564
|
-
function saveProviderId(identifier, target) {
|
|
565
|
-
if (isProvide(target)) {
|
|
566
|
-
if (identifier) {
|
|
567
|
-
const meta = getClassMetadata(constant_1.TAGGED_CLS, target);
|
|
568
|
-
if (meta.id !== identifier) {
|
|
569
|
-
meta.id = identifier;
|
|
570
|
-
// save class id and uuid
|
|
571
|
-
saveClassMetadata(constant_1.TAGGED_CLS, meta, target);
|
|
572
|
-
debug(`update provide: ${target.name} -> ${meta.uuid}`);
|
|
100
|
+
: implOrOptions;
|
|
101
|
+
implOrOpt.impl = implOrOpt.impl ?? true;
|
|
102
|
+
return function (target, propertyName) {
|
|
103
|
+
metadataManager_1.MetadataManager.attachMetadata(constant_1.CUSTOM_PROPERTY_INJECT_KEY, {
|
|
104
|
+
propertyName,
|
|
105
|
+
key: decoratorKey,
|
|
106
|
+
metadata,
|
|
107
|
+
options: implOrOptions,
|
|
108
|
+
}, target, propertyName);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
static createCustomMethodDecorator(decoratorKey, metadata, implOrOptions = { impl: true }) {
|
|
112
|
+
const implOrOpt = typeof implOrOptions === 'boolean'
|
|
113
|
+
? {
|
|
114
|
+
impl: implOrOptions,
|
|
573
115
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
}
|
|
601
|
-
exports.getProviderId = getProviderId;
|
|
602
|
-
function getProviderName(module) {
|
|
603
|
-
const metaData = getClassMetadata(constant_1.TAGGED_CLS, module);
|
|
604
|
-
if (metaData && metaData.name) {
|
|
605
|
-
return metaData.name;
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
exports.getProviderName = getProviderName;
|
|
609
|
-
/**
|
|
610
|
-
* get provider uuid from module
|
|
611
|
-
* @param module
|
|
612
|
-
*/
|
|
613
|
-
function getProviderUUId(module) {
|
|
614
|
-
const metaData = getClassMetadata(constant_1.TAGGED_CLS, module);
|
|
615
|
-
if (metaData && metaData.uuid) {
|
|
616
|
-
return metaData.uuid;
|
|
116
|
+
: implOrOptions;
|
|
117
|
+
implOrOpt.impl = implOrOpt.impl ?? true;
|
|
118
|
+
return function (target, propertyName) {
|
|
119
|
+
metadataManager_1.MetadataManager.attachMetadata(constant_1.CUSTOM_METHOD_INJECT_KEY, {
|
|
120
|
+
propertyName,
|
|
121
|
+
key: decoratorKey,
|
|
122
|
+
metadata,
|
|
123
|
+
options: implOrOpt,
|
|
124
|
+
}, target);
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
static createCustomParamDecorator(decoratorKey, metadata, implOrOptions = { impl: true }) {
|
|
128
|
+
if (typeof implOrOptions === 'boolean') {
|
|
129
|
+
implOrOptions = { impl: implOrOptions };
|
|
130
|
+
}
|
|
131
|
+
if (implOrOptions.impl === undefined) {
|
|
132
|
+
implOrOptions.impl = true;
|
|
133
|
+
}
|
|
134
|
+
return function (target, propertyName, parameterIndex) {
|
|
135
|
+
metadataManager_1.MetadataManager.attachMetadata(constant_1.CUSTOM_PARAM_INJECT_KEY, {
|
|
136
|
+
key: decoratorKey,
|
|
137
|
+
parameterIndex,
|
|
138
|
+
propertyName,
|
|
139
|
+
metadata,
|
|
140
|
+
options: implOrOptions,
|
|
141
|
+
}, target, propertyName);
|
|
142
|
+
};
|
|
617
143
|
}
|
|
618
144
|
}
|
|
619
|
-
exports.
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
* get parameters type by reflect-metadata
|
|
636
|
-
*/
|
|
637
|
-
function getMethodParamTypes(target, methodName) {
|
|
638
|
-
if ((0, types_1.isClass)(target)) {
|
|
639
|
-
target = target.prototype;
|
|
640
|
-
}
|
|
641
|
-
return Reflect.getMetadata('design:paramtypes', target, methodName);
|
|
642
|
-
}
|
|
643
|
-
exports.getMethodParamTypes = getMethodParamTypes;
|
|
644
|
-
/**
|
|
645
|
-
* get property(method) type from metadata
|
|
646
|
-
* @param target
|
|
647
|
-
* @param methodName
|
|
648
|
-
*/
|
|
649
|
-
function getPropertyType(target, methodName) {
|
|
650
|
-
return transformTypeFromTSDesign(Reflect.getMetadata('design:type', target, methodName));
|
|
651
|
-
}
|
|
652
|
-
exports.getPropertyType = getPropertyType;
|
|
653
|
-
/**
|
|
654
|
-
* get method return type from metadata
|
|
655
|
-
* @param target
|
|
656
|
-
* @param methodName
|
|
657
|
-
*/
|
|
658
|
-
function getMethodReturnTypes(target, methodName) {
|
|
659
|
-
if ((0, types_1.isClass)(target)) {
|
|
660
|
-
target = target.prototype;
|
|
661
|
-
}
|
|
662
|
-
return Reflect.getMetadata('design:returntype', target, methodName);
|
|
663
|
-
}
|
|
664
|
-
exports.getMethodReturnTypes = getMethodReturnTypes;
|
|
665
|
-
/**
|
|
666
|
-
* create a custom property inject
|
|
667
|
-
* @param decoratorKey
|
|
668
|
-
* @param metadata
|
|
669
|
-
* @param impl default true, configuration need decoratorService.registerMethodHandler
|
|
670
|
-
*/
|
|
671
|
-
function createCustomPropertyDecorator(decoratorKey, metadata, impl = true) {
|
|
672
|
-
return function (target, propertyName) {
|
|
673
|
-
attachClassMetadata(constant_1.INJECT_CUSTOM_PROPERTY, {
|
|
674
|
-
propertyName,
|
|
675
|
-
key: decoratorKey,
|
|
676
|
-
metadata,
|
|
677
|
-
impl,
|
|
678
|
-
}, target, propertyName);
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
exports.createCustomPropertyDecorator = createCustomPropertyDecorator;
|
|
682
|
-
/**
|
|
683
|
-
*
|
|
684
|
-
* @param decoratorKey
|
|
685
|
-
* @param metadata
|
|
686
|
-
* @param impl default true, configuration need decoratorService.registerMethodHandler
|
|
687
|
-
*/
|
|
688
|
-
function createCustomMethodDecorator(decoratorKey, metadata, implOrOptions = { impl: true }) {
|
|
689
|
-
if (typeof implOrOptions === 'boolean') {
|
|
690
|
-
implOrOptions = { impl: implOrOptions };
|
|
691
|
-
}
|
|
692
|
-
if (implOrOptions.impl === undefined) {
|
|
693
|
-
implOrOptions.impl = true;
|
|
694
|
-
}
|
|
695
|
-
return function (target, propertyName, descriptor) {
|
|
696
|
-
attachClassMetadata(constant_1.INJECT_CUSTOM_METHOD, {
|
|
697
|
-
propertyName,
|
|
698
|
-
key: decoratorKey,
|
|
699
|
-
metadata,
|
|
700
|
-
options: implOrOptions,
|
|
701
|
-
}, target);
|
|
702
|
-
};
|
|
703
|
-
}
|
|
704
|
-
exports.createCustomMethodDecorator = createCustomMethodDecorator;
|
|
705
|
-
/**
|
|
706
|
-
*
|
|
707
|
-
* @param decoratorKey
|
|
708
|
-
* @param metadata
|
|
709
|
-
* @param options
|
|
710
|
-
*/
|
|
711
|
-
function createCustomParamDecorator(decoratorKey, metadata, implOrOptions = { impl: true }) {
|
|
712
|
-
if (typeof implOrOptions === 'boolean') {
|
|
713
|
-
implOrOptions = { impl: implOrOptions };
|
|
714
|
-
}
|
|
715
|
-
if (implOrOptions.impl === undefined) {
|
|
716
|
-
implOrOptions.impl = true;
|
|
717
|
-
}
|
|
718
|
-
return function (target, propertyName, parameterIndex) {
|
|
719
|
-
attachClassMetadata(constant_1.INJECT_CUSTOM_PARAM, {
|
|
720
|
-
key: decoratorKey,
|
|
721
|
-
parameterIndex,
|
|
722
|
-
propertyName,
|
|
723
|
-
metadata,
|
|
724
|
-
options: implOrOptions,
|
|
725
|
-
}, target, propertyName, 'multi');
|
|
726
|
-
};
|
|
145
|
+
exports.DecoratorManager = DecoratorManager;
|
|
146
|
+
DecoratorManager.moduleStore = new Map();
|
|
147
|
+
if (typeof globalThis === 'object' &&
|
|
148
|
+
globalThis['MIDWAY_GLOBAL_DECORATOR_MANAGER']) {
|
|
149
|
+
console.warn('DecoratorManager not singleton and please check @midwayjs/core version by "npm ls @midwayjs/core"');
|
|
150
|
+
const coreModulePathList = (0, pathFileUtil_1.getModuleRequirePathList)('@midwayjs/core');
|
|
151
|
+
if (coreModulePathList.length) {
|
|
152
|
+
console.info('The module may be located in:');
|
|
153
|
+
coreModulePathList.forEach((path, index) => {
|
|
154
|
+
console.info(`${index + 1}. ${path}`);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
throw new error_1.MidwayInconsistentVersionError();
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
globalThis['MIDWAY_GLOBAL_DECORATOR_MANAGER'] = DecoratorManager;
|
|
727
161
|
}
|
|
728
|
-
exports.createCustomParamDecorator = createCustomParamDecorator;
|
|
729
162
|
//# sourceMappingURL=decoratorManager.js.map
|