@midwayjs/core 3.5.4-beta.3 → 3.7.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/LICENSE +21 -0
- package/dist/baseFramework.d.ts +7 -2
- package/dist/baseFramework.js +27 -9
- package/dist/common/applicationManager.d.ts +1 -1
- package/dist/common/applicationManager.js +1 -1
- package/dist/common/dataListener.js +1 -1
- package/dist/common/dataSourceManager.d.ts +1 -0
- package/dist/common/dataSourceManager.js +10 -7
- package/dist/common/fileDetector.js +6 -5
- package/dist/common/filterManager.js +1 -1
- package/dist/common/guardManager.d.ts +6 -0
- package/dist/common/guardManager.js +49 -0
- package/dist/common/middlewareManager.d.ts +2 -2
- package/dist/common/webGenerator.d.ts +2 -1
- package/dist/common/webGenerator.js +12 -3
- package/dist/config/config.default.d.ts +2 -11
- package/dist/config/config.default.js +2 -2
- package/dist/{common/constants.d.ts → constants.d.ts} +10 -1
- package/dist/{common/constants.js → constants.js} +18 -2
- package/dist/context/container.d.ts +2 -1
- package/dist/context/container.js +19 -14
- package/dist/context/definitionRegistry.d.ts +1 -1
- package/dist/context/definitionRegistry.js +1 -1
- package/dist/context/managedResolverFactory.d.ts +1 -4
- package/dist/context/managedResolverFactory.js +6 -6
- package/dist/context/providerWrapper.d.ts +1 -1
- package/dist/context/providerWrapper.js +1 -1
- package/dist/context/requestContainer.js +3 -3
- package/dist/decorator/common/aspect.d.ts +20 -0
- package/dist/decorator/common/aspect.js +22 -0
- package/dist/decorator/common/autoload.d.ts +2 -0
- package/dist/decorator/common/autoload.js +13 -0
- package/dist/decorator/common/configuration.d.ts +24 -0
- package/dist/decorator/common/configuration.js +11 -0
- package/dist/decorator/common/filter.d.ts +6 -0
- package/dist/decorator/common/filter.js +31 -0
- package/dist/decorator/common/framework.d.ts +8 -0
- package/dist/decorator/common/framework.js +41 -0
- package/dist/decorator/common/guard.d.ts +4 -0
- package/dist/decorator/common/guard.js +30 -0
- package/dist/decorator/common/inject.d.ts +3 -0
- package/dist/decorator/common/inject.js +11 -0
- package/dist/decorator/common/middleware.d.ts +2 -0
- package/dist/decorator/common/middleware.js +12 -0
- package/dist/decorator/common/objectDef.d.ts +7 -0
- package/dist/decorator/common/objectDef.js +25 -0
- package/dist/decorator/common/pipeline.d.ts +3 -0
- package/dist/decorator/common/pipeline.js +12 -0
- package/dist/decorator/common/provide.d.ts +3 -0
- package/dist/decorator/common/provide.js +11 -0
- package/dist/decorator/constant.d.ts +55 -0
- package/dist/decorator/constant.js +86 -0
- package/dist/decorator/decoratorManager.d.ts +301 -0
- package/dist/decorator/decoratorManager.js +709 -0
- package/dist/decorator/faas/serverlessTrigger.d.ts +13 -0
- package/dist/decorator/faas/serverlessTrigger.js +29 -0
- package/dist/decorator/index.d.ts +31 -0
- package/dist/decorator/index.js +55 -0
- package/dist/decorator/interface.d.ts +242 -0
- package/dist/decorator/interface.js +66 -0
- package/dist/decorator/microservice/consumer.d.ts +5 -0
- package/dist/decorator/microservice/consumer.js +17 -0
- package/dist/decorator/microservice/kafkaListener.d.ts +24 -0
- package/dist/decorator/microservice/kafkaListener.js +13 -0
- package/dist/decorator/microservice/provider.d.ts +16 -0
- package/dist/decorator/microservice/provider.js +47 -0
- package/dist/decorator/microservice/rabbitmqListener.d.ts +50 -0
- package/dist/decorator/microservice/rabbitmqListener.js +13 -0
- package/dist/decorator/rpc/hsf.d.ts +12 -0
- package/dist/decorator/rpc/hsf.js +18 -0
- package/dist/decorator/task/queue.d.ts +2 -0
- package/dist/decorator/task/queue.js +17 -0
- package/dist/decorator/task/schedule.d.ts +21 -0
- package/dist/decorator/task/schedule.js +14 -0
- package/dist/decorator/task/task.d.ts +2 -0
- package/dist/decorator/task/task.js +18 -0
- package/dist/decorator/task/taskLocal.d.ts +2 -0
- package/dist/decorator/task/taskLocal.js +17 -0
- package/dist/decorator/web/controller.d.ts +20 -0
- package/dist/decorator/web/controller.js +18 -0
- package/dist/decorator/web/paramMapping.d.ts +37 -0
- package/dist/decorator/web/paramMapping.js +56 -0
- package/dist/decorator/web/requestMapping.d.ts +132 -0
- package/dist/decorator/web/requestMapping.js +83 -0
- package/dist/decorator/web/response.d.ts +9 -0
- package/dist/decorator/web/response.js +65 -0
- package/dist/decorator/ws/webSocketController.d.ts +10 -0
- package/dist/decorator/ws/webSocketController.js +20 -0
- package/dist/decorator/ws/webSocketEvent.d.ts +60 -0
- package/dist/decorator/ws/webSocketEvent.js +87 -0
- package/dist/definitions/functionDefinition.d.ts +1 -1
- package/dist/definitions/functionDefinition.js +1 -1
- package/dist/definitions/objectCreator.d.ts +1 -1
- package/dist/definitions/objectCreator.js +7 -7
- package/dist/definitions/objectDefinition.d.ts +1 -1
- package/dist/definitions/objectDefinition.js +1 -1
- package/dist/definitions/properties.d.ts +1 -1
- package/dist/error/framework.d.ts +5 -1
- package/dist/error/framework.js +9 -2
- package/dist/functional/configuration.d.ts +1 -1
- package/dist/index.d.ts +18 -15
- package/dist/index.js +40 -27
- package/dist/interface.d.ts +54 -18
- package/dist/interface.js +1 -17
- package/dist/service/aspectService.d.ts +1 -1
- package/dist/service/aspectService.js +3 -2
- package/dist/service/configService.js +3 -2
- package/dist/service/decoratorService.js +1 -1
- package/dist/service/environmentService.js +1 -1
- package/dist/service/frameworkService.d.ts +1 -1
- package/dist/service/frameworkService.js +16 -6
- package/dist/service/informationService.js +1 -1
- package/dist/service/lifeCycleService.js +1 -1
- package/dist/service/loggerService.js +1 -1
- package/dist/service/middlewareService.js +3 -2
- package/dist/service/mockService.js +1 -1
- package/dist/service/pipelineService.d.ts +1 -1
- package/dist/service/pipelineService.js +1 -1
- package/dist/service/slsFunctionService.d.ts +1 -1
- package/dist/service/slsFunctionService.js +1 -1
- package/dist/service/webRouterService.d.ts +9 -1
- package/dist/service/webRouterService.js +5 -2
- package/dist/setup.d.ts +2 -2
- package/dist/setup.js +1 -1
- package/dist/util/camelCase.d.ts +3 -0
- package/dist/util/camelCase.js +88 -0
- package/dist/util/contextUtil.js +2 -2
- package/dist/util/extend.js +3 -3
- package/dist/util/flatted.d.ts +7 -0
- package/dist/util/flatted.js +91 -0
- package/dist/util/format.d.ts +25 -0
- package/dist/util/format.js +38 -0
- package/dist/util/fs.d.ts +5 -0
- package/dist/util/fs.js +15 -0
- package/dist/util/httpclient.d.ts +1 -0
- package/dist/util/httpclient.js +1 -1
- package/dist/util/index.d.ts +26 -0
- package/dist/util/index.js +80 -1
- package/dist/util/pathFileUtil.d.ts +6 -3
- package/dist/util/pathFileUtil.js +28 -22
- package/dist/util/retry.js +2 -2
- package/dist/util/types.d.ts +35 -0
- package/dist/util/types.js +121 -0
- package/dist/util/uuid.d.ts +5 -0
- package/dist/util/uuid.js +64 -0
- package/dist/util/webRouterParam.d.ts +4 -2
- package/dist/util/webRouterParam.js +32 -6
- package/package.json +8 -11
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 - Now midwayjs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/baseFramework.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommonMiddlewareUnion, IConfigurationOptions, IMidwayApplication, IMidwayBootstrapOptions, IMidwayContainer, IMidwayContext, IMidwayFramework, CommonFilterUnion, MiddlewareRespond } from './interface';
|
|
1
|
+
import { CommonMiddlewareUnion, IConfigurationOptions, IMidwayApplication, IMidwayBootstrapOptions, IMidwayContainer, IMidwayContext, IMidwayFramework, CommonFilterUnion, MiddlewareRespond, CommonGuardUnion } from './interface';
|
|
2
2
|
import { ILogger, LoggerOptions, LoggerContextFormat } from '@midwayjs/logger';
|
|
3
3
|
import { MidwayEnvironmentService } from './service/environmentService';
|
|
4
4
|
import { MidwayConfigService } from './service/configService';
|
|
@@ -9,6 +9,7 @@ import { MidwayMiddlewareService } from './service/middlewareService';
|
|
|
9
9
|
import { FilterManager } from './common/filterManager';
|
|
10
10
|
import { MidwayMockService } from './service/mockService';
|
|
11
11
|
import { AsyncContextManager } from './common/asyncContextManager';
|
|
12
|
+
import { GuardManager } from './common/guardManager';
|
|
12
13
|
export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>, CTX extends IMidwayContext, OPT extends IConfigurationOptions, ResOrNext = unknown, Next = unknown> implements IMidwayFramework<APP, CTX, OPT, ResOrNext, Next> {
|
|
13
14
|
readonly applicationContext: IMidwayContainer;
|
|
14
15
|
app: APP;
|
|
@@ -20,6 +21,7 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
|
|
|
20
21
|
protected contextLoggerFormat: LoggerContextFormat;
|
|
21
22
|
protected middlewareManager: ContextMiddlewareManager<CTX, ResOrNext, Next>;
|
|
22
23
|
protected filterManager: FilterManager<CTX, ResOrNext, Next>;
|
|
24
|
+
protected guardManager: GuardManager<CTX>;
|
|
23
25
|
protected composeMiddleware: any;
|
|
24
26
|
protected bootstrapOptions: IMidwayBootstrapOptions;
|
|
25
27
|
protected asyncContextManager: AsyncContextManager;
|
|
@@ -82,8 +84,11 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
|
|
|
82
84
|
getFrameworkName(): string;
|
|
83
85
|
useMiddleware(middleware: CommonMiddlewareUnion<CTX, ResOrNext, Next>): void;
|
|
84
86
|
getMiddleware(): ContextMiddlewareManager<CTX, ResOrNext, Next>;
|
|
85
|
-
useFilter(
|
|
87
|
+
useFilter(filter: CommonFilterUnion<CTX, ResOrNext, Next>): void;
|
|
88
|
+
useGuard(guards: CommonGuardUnion<CTX>): void;
|
|
89
|
+
runGuard(ctx: CTX, supplierClz: new (...args: any[]) => any, methodName: string): Promise<boolean>;
|
|
86
90
|
protected createMiddlewareManager(): ContextMiddlewareManager<CTX, ResOrNext, Next>;
|
|
87
91
|
protected createFilterManager(): FilterManager<CTX, ResOrNext, Next>;
|
|
92
|
+
protected createGuardManager(): GuardManager<CTX>;
|
|
88
93
|
}
|
|
89
94
|
//# sourceMappingURL=baseFramework.d.ts.map
|
package/dist/baseFramework.js
CHANGED
|
@@ -11,7 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BaseFramework = void 0;
|
|
13
13
|
const interface_1 = require("./interface");
|
|
14
|
-
const
|
|
14
|
+
const constants_1 = require("./constants");
|
|
15
|
+
const decorator_1 = require("./decorator");
|
|
15
16
|
const requestContainer_1 = require("./context/requestContainer");
|
|
16
17
|
const environmentService_1 = require("./service/environmentService");
|
|
17
18
|
const configService_1 = require("./service/configService");
|
|
@@ -23,6 +24,7 @@ const filterManager_1 = require("./common/filterManager");
|
|
|
23
24
|
const mockService_1 = require("./service/mockService");
|
|
24
25
|
const util = require("util");
|
|
25
26
|
const asyncContextManager_1 = require("./common/asyncContextManager");
|
|
27
|
+
const guardManager_1 = require("./common/guardManager");
|
|
26
28
|
const debug = util.debuglog('midway:debug');
|
|
27
29
|
class BaseFramework {
|
|
28
30
|
constructor(applicationContext) {
|
|
@@ -30,6 +32,7 @@ class BaseFramework {
|
|
|
30
32
|
this.defaultContext = {};
|
|
31
33
|
this.middlewareManager = this.createMiddlewareManager();
|
|
32
34
|
this.filterManager = this.createFilterManager();
|
|
35
|
+
this.guardManager = this.createGuardManager();
|
|
33
36
|
this.composeMiddleware = null;
|
|
34
37
|
}
|
|
35
38
|
async init() {
|
|
@@ -90,10 +93,10 @@ class BaseFramework {
|
|
|
90
93
|
createContextLogger(ctx, name) {
|
|
91
94
|
const appLogger = this.getLogger(name !== null && name !== void 0 ? name : this.contextLoggerApplyLogger);
|
|
92
95
|
if (name) {
|
|
93
|
-
let ctxLoggerCache = ctx.getAttr(
|
|
96
|
+
let ctxLoggerCache = ctx.getAttr(constants_1.REQUEST_CTX_LOGGER_CACHE_KEY);
|
|
94
97
|
if (!ctxLoggerCache) {
|
|
95
98
|
ctxLoggerCache = new Map();
|
|
96
|
-
ctx.setAttr(
|
|
99
|
+
ctx.setAttr(constants_1.REQUEST_CTX_LOGGER_CACHE_KEY, ctxLoggerCache);
|
|
97
100
|
}
|
|
98
101
|
if (!name) {
|
|
99
102
|
name = 'appLogger';
|
|
@@ -163,6 +166,9 @@ class BaseFramework {
|
|
|
163
166
|
createLogger: (name, options = {}) => {
|
|
164
167
|
return this.createLogger(name, options);
|
|
165
168
|
},
|
|
169
|
+
getFramework: () => {
|
|
170
|
+
return this;
|
|
171
|
+
},
|
|
166
172
|
getProjectName: () => {
|
|
167
173
|
return this.getProjectName();
|
|
168
174
|
},
|
|
@@ -209,6 +215,9 @@ class BaseFramework {
|
|
|
209
215
|
useFilter: (Filter) => {
|
|
210
216
|
return this.useFilter(Filter);
|
|
211
217
|
},
|
|
218
|
+
useGuard: (guard) => {
|
|
219
|
+
return this.useGuard(guard);
|
|
220
|
+
},
|
|
212
221
|
};
|
|
213
222
|
for (const method of whiteList) {
|
|
214
223
|
delete defaultApplicationProperties[method];
|
|
@@ -235,7 +244,7 @@ class BaseFramework {
|
|
|
235
244
|
async applyMiddleware(lastMiddleware) {
|
|
236
245
|
var _a;
|
|
237
246
|
if (!this.composeMiddleware) {
|
|
238
|
-
if (!this.applicationContext.hasObject(
|
|
247
|
+
if (!this.applicationContext.hasObject(constants_1.ASYNC_CONTEXT_MANAGER_KEY)) {
|
|
239
248
|
const asyncContextManagerEnabled = this.configService.getConfiguration('asyncContextManager.enable') ||
|
|
240
249
|
false;
|
|
241
250
|
const contextManager = asyncContextManagerEnabled
|
|
@@ -245,12 +254,12 @@ class BaseFramework {
|
|
|
245
254
|
if (asyncContextManagerEnabled) {
|
|
246
255
|
contextManager.enable();
|
|
247
256
|
}
|
|
248
|
-
this.applicationContext.registerObject(
|
|
257
|
+
this.applicationContext.registerObject(constants_1.ASYNC_CONTEXT_MANAGER_KEY, contextManager);
|
|
249
258
|
}
|
|
250
259
|
this.middlewareManager.insertFirst((async (ctx, next) => {
|
|
251
260
|
// warp with context manager
|
|
252
|
-
const rootContext = asyncContextManager_1.ASYNC_ROOT_CONTEXT.setValue(
|
|
253
|
-
const contextManager = this.applicationContext.get(
|
|
261
|
+
const rootContext = asyncContextManager_1.ASYNC_ROOT_CONTEXT.setValue(constants_1.ASYNC_CONTEXT_KEY, ctx);
|
|
262
|
+
const contextManager = this.applicationContext.get(constants_1.ASYNC_CONTEXT_MANAGER_KEY);
|
|
254
263
|
return await contextManager.with(rootContext, async () => {
|
|
255
264
|
this.mockService.applyContextMocks(this.app, ctx);
|
|
256
265
|
let returnResult = undefined;
|
|
@@ -301,8 +310,14 @@ class BaseFramework {
|
|
|
301
310
|
getMiddleware() {
|
|
302
311
|
return this.middlewareManager;
|
|
303
312
|
}
|
|
304
|
-
useFilter(
|
|
305
|
-
return this.filterManager.useFilter(
|
|
313
|
+
useFilter(filter) {
|
|
314
|
+
return this.filterManager.useFilter(filter);
|
|
315
|
+
}
|
|
316
|
+
useGuard(guards) {
|
|
317
|
+
return this.guardManager.addGlobalGuard(guards);
|
|
318
|
+
}
|
|
319
|
+
async runGuard(ctx, supplierClz, methodName) {
|
|
320
|
+
return this.guardManager.runGuard(ctx, supplierClz, methodName);
|
|
306
321
|
}
|
|
307
322
|
createMiddlewareManager() {
|
|
308
323
|
return new middlewareManager_1.ContextMiddlewareManager();
|
|
@@ -310,6 +325,9 @@ class BaseFramework {
|
|
|
310
325
|
createFilterManager() {
|
|
311
326
|
return new filterManager_1.FilterManager();
|
|
312
327
|
}
|
|
328
|
+
createGuardManager() {
|
|
329
|
+
return new guardManager_1.GuardManager();
|
|
330
|
+
}
|
|
313
331
|
}
|
|
314
332
|
__decorate([
|
|
315
333
|
(0, decorator_1.Inject)(),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IMidwayApplication, IMidwayFramework } from '../interface';
|
|
2
|
-
import { FrameworkType } from '
|
|
2
|
+
import { FrameworkType } from '../decorator';
|
|
3
3
|
export declare class MidwayApplicationManager {
|
|
4
4
|
private globalFrameworkMap;
|
|
5
5
|
private globalFrameworkTypeMap;
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
};
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.MidwayApplicationManager = void 0;
|
|
10
|
-
const decorator_1 = require("
|
|
10
|
+
const decorator_1 = require("../decorator");
|
|
11
11
|
let MidwayApplicationManager = class MidwayApplicationManager {
|
|
12
12
|
constructor() {
|
|
13
13
|
this.globalFrameworkMap = new Map();
|
|
@@ -10,7 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.DataListener = void 0;
|
|
13
|
-
const decorator_1 = require("
|
|
13
|
+
const decorator_1 = require("../decorator");
|
|
14
14
|
class DataListener {
|
|
15
15
|
async init() {
|
|
16
16
|
this.innerData = await this.initData();
|
|
@@ -30,6 +30,7 @@ export declare abstract class DataSourceManager<T> {
|
|
|
30
30
|
protected abstract checkConnected(dataSource: T): Promise<boolean>;
|
|
31
31
|
protected abstract destroyDataSource(dataSource: T): Promise<void>;
|
|
32
32
|
stop(): Promise<void>;
|
|
33
|
+
getDefaultDataSourceName(): string;
|
|
33
34
|
}
|
|
34
35
|
export declare function globModels(globString: string, appDir: string): any[];
|
|
35
36
|
export interface CreateDataSourceInstanceOptions {
|
|
@@ -8,8 +8,8 @@ const extend_1 = require("../util/extend");
|
|
|
8
8
|
const error_1 = require("../error");
|
|
9
9
|
const glob_1 = require("@midwayjs/glob");
|
|
10
10
|
const path_1 = require("path");
|
|
11
|
-
const
|
|
12
|
-
const
|
|
11
|
+
const types_1 = require("../util/types");
|
|
12
|
+
const constants_1 = require("../constants");
|
|
13
13
|
class DataSourceManager {
|
|
14
14
|
constructor() {
|
|
15
15
|
this.dataSource = new Map();
|
|
@@ -112,6 +112,9 @@ class DataSourceManager {
|
|
|
112
112
|
}));
|
|
113
113
|
this.dataSource.clear();
|
|
114
114
|
}
|
|
115
|
+
getDefaultDataSourceName() {
|
|
116
|
+
return this.options['defaultDataSourceName'];
|
|
117
|
+
}
|
|
115
118
|
}
|
|
116
119
|
exports.DataSourceManager = DataSourceManager;
|
|
117
120
|
function globModels(globString, appDir) {
|
|
@@ -123,28 +126,28 @@ function globModels(globString, appDir) {
|
|
|
123
126
|
}
|
|
124
127
|
if (/\*/.test(globString)) {
|
|
125
128
|
cwd = appDir;
|
|
126
|
-
pattern = [...
|
|
129
|
+
pattern = [...constants_1.DEFAULT_PATTERN.map(p => (0, path_1.join)(globString, p))];
|
|
127
130
|
pattern.push(globString);
|
|
128
131
|
}
|
|
129
132
|
else {
|
|
130
|
-
pattern = [...
|
|
133
|
+
pattern = [...constants_1.DEFAULT_PATTERN];
|
|
131
134
|
cwd = (0, path_1.join)(appDir, globString);
|
|
132
135
|
}
|
|
133
136
|
const models = [];
|
|
134
137
|
// string will be glob file
|
|
135
138
|
const files = (0, glob_1.run)(pattern, {
|
|
136
139
|
cwd,
|
|
137
|
-
ignore:
|
|
140
|
+
ignore: constants_1.IGNORE_PATTERN,
|
|
138
141
|
});
|
|
139
142
|
for (const file of files) {
|
|
140
143
|
const exports = require(file);
|
|
141
|
-
if (
|
|
144
|
+
if (types_1.Types.isClass(exports)) {
|
|
142
145
|
models.push(exports);
|
|
143
146
|
}
|
|
144
147
|
else {
|
|
145
148
|
for (const m in exports) {
|
|
146
149
|
const module = exports[m];
|
|
147
|
-
if (
|
|
150
|
+
if (types_1.Types.isClass(module)) {
|
|
148
151
|
models.push(module);
|
|
149
152
|
}
|
|
150
153
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CustomModuleDetector = exports.DirectoryFileDetector = exports.AbstractFileDetector = void 0;
|
|
4
|
-
const
|
|
4
|
+
const types_1 = require("../util/types");
|
|
5
5
|
const glob_1 = require("@midwayjs/glob");
|
|
6
6
|
const error_1 = require("../error");
|
|
7
|
-
const
|
|
7
|
+
const constants_1 = require("../constants");
|
|
8
|
+
const decorator_1 = require("../decorator");
|
|
8
9
|
class AbstractFileDetector {
|
|
9
10
|
constructor(options) {
|
|
10
11
|
this.options = options;
|
|
@@ -15,7 +16,7 @@ class AbstractFileDetector {
|
|
|
15
16
|
}
|
|
16
17
|
}
|
|
17
18
|
exports.AbstractFileDetector = AbstractFileDetector;
|
|
18
|
-
const DEFAULT_GLOB_PATTERN = ['**/**.tsx'].concat(
|
|
19
|
+
const DEFAULT_GLOB_PATTERN = ['**/**.tsx'].concat(constants_1.DEFAULT_PATTERN);
|
|
19
20
|
const DEFAULT_IGNORE_PATTERN = [
|
|
20
21
|
'**/logs/**',
|
|
21
22
|
'**/run/**',
|
|
@@ -27,7 +28,7 @@ const DEFAULT_IGNORE_PATTERN = [
|
|
|
27
28
|
'**/**.test.ts',
|
|
28
29
|
'**/**.test.js',
|
|
29
30
|
'**/__test__/**',
|
|
30
|
-
].concat(
|
|
31
|
+
].concat(constants_1.IGNORE_PATTERN);
|
|
31
32
|
class DirectoryFileDetector extends AbstractFileDetector {
|
|
32
33
|
constructor() {
|
|
33
34
|
super(...arguments);
|
|
@@ -46,7 +47,7 @@ class DirectoryFileDetector extends AbstractFileDetector {
|
|
|
46
47
|
const checkDuplicatedHandler = (module, options) => {
|
|
47
48
|
if ((this.options.conflictCheck ||
|
|
48
49
|
this.extraDetectorOptions.conflictCheck) &&
|
|
49
|
-
|
|
50
|
+
types_1.Types.isClass(module)) {
|
|
50
51
|
const name = (0, decorator_1.getProviderName)(module);
|
|
51
52
|
if (name) {
|
|
52
53
|
if (this.duplicateModuleCheckSet.has(name)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FilterManager = void 0;
|
|
4
|
-
const decorator_1 = require("
|
|
4
|
+
const decorator_1 = require("../decorator");
|
|
5
5
|
const util_1 = require("../util");
|
|
6
6
|
class FilterManager {
|
|
7
7
|
constructor() {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommonGuardUnion, IGuard, IMidwayContext } from '../interface';
|
|
2
|
+
export declare class GuardManager<CTX extends IMidwayContext = IMidwayContext> extends Array<new (...args: any[]) => IGuard<any>> {
|
|
3
|
+
addGlobalGuard(guards: CommonGuardUnion<CTX>): void;
|
|
4
|
+
runGuard(ctx: CTX, supplierClz: new (...args: any[]) => any, methodName: string): Promise<boolean>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=guardManager.d.ts.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GuardManager = void 0;
|
|
4
|
+
const decorator_1 = require("../decorator");
|
|
5
|
+
class GuardManager extends Array {
|
|
6
|
+
addGlobalGuard(guards) {
|
|
7
|
+
if (!Array.isArray(guards)) {
|
|
8
|
+
this.push(guards);
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
this.push(...guards);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
async runGuard(ctx, supplierClz, methodName) {
|
|
15
|
+
// check global guard
|
|
16
|
+
for (const Guard of this) {
|
|
17
|
+
const guard = await ctx.requestContext.getAsync(Guard);
|
|
18
|
+
const isPassed = await guard.canActivate(ctx, supplierClz, methodName);
|
|
19
|
+
if (!isPassed) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// check class Guard
|
|
24
|
+
const classGuardList = (0, decorator_1.getClassMetadata)(decorator_1.GUARD_KEY, supplierClz);
|
|
25
|
+
if (classGuardList) {
|
|
26
|
+
for (const Guard of classGuardList) {
|
|
27
|
+
const guard = await ctx.requestContext.getAsync(Guard);
|
|
28
|
+
const isPassed = await guard.canActivate(ctx, supplierClz, methodName);
|
|
29
|
+
if (!isPassed) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// check method Guard
|
|
35
|
+
const methodGuardList = (0, decorator_1.getPropertyMetadata)(decorator_1.GUARD_KEY, supplierClz, methodName);
|
|
36
|
+
if (methodGuardList) {
|
|
37
|
+
for (const Guard of methodGuardList) {
|
|
38
|
+
const guard = await ctx.requestContext.getAsync(Guard);
|
|
39
|
+
const isPassed = await guard.canActivate(ctx, supplierClz, methodName);
|
|
40
|
+
if (!isPassed) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.GuardManager = GuardManager;
|
|
49
|
+
//# sourceMappingURL=guardManager.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommonMiddleware, CommonMiddlewareUnion, IMidwayContext } from '../interface';
|
|
2
|
-
export declare class ContextMiddlewareManager<CTX extends IMidwayContext, R, N> extends Array<CommonMiddleware<CTX, R, N>> {
|
|
1
|
+
import { CommonMiddleware, CommonMiddlewareUnion, IMiddlewareManager, IMidwayContext } from '../interface';
|
|
2
|
+
export declare class ContextMiddlewareManager<CTX extends IMidwayContext, R, N> extends Array<CommonMiddleware<CTX, R, N>> implements IMiddlewareManager<CTX, R, N> {
|
|
3
3
|
/**
|
|
4
4
|
* insert a middleware or middleware array to first
|
|
5
5
|
* @param middleware
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IMidwayApplication } from '../interface';
|
|
2
|
+
import { MidwayWebRouterService, RouterInfo } from '../service/webRouterService';
|
|
2
3
|
export declare abstract class WebControllerGenerator<Router extends {
|
|
3
4
|
use: (...args: any[]) => void;
|
|
4
5
|
}> {
|
|
@@ -7,9 +7,10 @@ exports.WebControllerGenerator = void 0;
|
|
|
7
7
|
* @param routeArgsInfo
|
|
8
8
|
* @param routerResponseData
|
|
9
9
|
*/
|
|
10
|
-
const decorator_1 = require("
|
|
11
|
-
const index_1 = require("../index");
|
|
10
|
+
const decorator_1 = require("../decorator");
|
|
12
11
|
const util = require("util");
|
|
12
|
+
const error_1 = require("../error");
|
|
13
|
+
const middlewareService_1 = require("../service/middlewareService");
|
|
13
14
|
const debug = util.debuglog('midway:debug');
|
|
14
15
|
class WebControllerGenerator {
|
|
15
16
|
constructor(app, midwayWebRouterService) {
|
|
@@ -22,6 +23,14 @@ class WebControllerGenerator {
|
|
|
22
23
|
*/
|
|
23
24
|
generateKoaController(routeInfo) {
|
|
24
25
|
return async (ctx, next) => {
|
|
26
|
+
if (routeInfo.controllerClz && typeof routeInfo.method === 'string') {
|
|
27
|
+
const isPassed = await this.app
|
|
28
|
+
.getFramework()
|
|
29
|
+
.runGuard(ctx, routeInfo.controllerClz, routeInfo.method);
|
|
30
|
+
if (!isPassed) {
|
|
31
|
+
throw new error_1.httpError.ForbiddenError();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
25
34
|
const args = [ctx, next];
|
|
26
35
|
let result;
|
|
27
36
|
if (typeof routeInfo.method !== 'string') {
|
|
@@ -73,7 +82,7 @@ class WebControllerGenerator {
|
|
|
73
82
|
const routerList = await this.midwayWebRouterService.getRoutePriorityList();
|
|
74
83
|
const applicationContext = this.app.getApplicationContext();
|
|
75
84
|
const logger = this.app.getCoreLogger();
|
|
76
|
-
const middlewareService = applicationContext.get(
|
|
85
|
+
const middlewareService = applicationContext.get(middlewareService_1.MidwayMiddlewareService);
|
|
77
86
|
for (const routerInfo of routerList) {
|
|
78
87
|
// bind controller first
|
|
79
88
|
applicationContext.bindClass(routerInfo.routerModule);
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { MidwayAppInfo,
|
|
2
|
-
|
|
3
|
-
declare const _default: (appInfo: MidwayAppInfo) => {
|
|
4
|
-
midwayLogger?: ServiceFactoryConfigOption<LoggerOptions>;
|
|
5
|
-
debug?: {
|
|
6
|
-
recordConfigMergeOrder?: boolean;
|
|
7
|
-
};
|
|
8
|
-
asyncContextManager: {
|
|
9
|
-
enable: boolean;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
1
|
+
import type { MidwayAppInfo, MidwayCoreDefaultConfig } from '../interface';
|
|
2
|
+
declare const _default: (appInfo: MidwayAppInfo) => MidwayCoreDefaultConfig;
|
|
12
3
|
export default _default;
|
|
13
4
|
//# sourceMappingURL=config.default.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const interface_1 = require("../interface");
|
|
4
3
|
const util_1 = require("../util/");
|
|
5
4
|
const path_1 = require("path");
|
|
5
|
+
const constants_1 = require("../constants");
|
|
6
6
|
exports.default = (appInfo) => {
|
|
7
7
|
var _a;
|
|
8
8
|
const isDevelopment = (0, util_1.isDevelopmentEnvironment)((0, util_1.getCurrentEnvironment)());
|
|
9
|
-
const logRoot = (_a = process.env[
|
|
9
|
+
const logRoot = (_a = process.env[constants_1.MIDWAY_LOGGER_WRITEABLE_DIR]) !== null && _a !== void 0 ? _a : appInfo.root;
|
|
10
10
|
return {
|
|
11
11
|
asyncContextManager: {
|
|
12
12
|
enable: false,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export declare const FUNCTION_INJECT_KEY = "midway:function_inject_key";
|
|
2
1
|
/**
|
|
3
2
|
* 静态参数
|
|
4
3
|
*
|
|
@@ -48,4 +47,14 @@ export declare const VALUE_TYPE: {
|
|
|
48
47
|
OBJECT: string;
|
|
49
48
|
BOOLEAN: string;
|
|
50
49
|
};
|
|
50
|
+
export declare const FUNCTION_INJECT_KEY = "midway:function_inject_key";
|
|
51
|
+
export declare const MIDWAY_LOGGER_WRITEABLE_DIR = "MIDWAY_LOGGER_WRITEABLE_DIR";
|
|
52
|
+
export declare const REQUEST_CTX_KEY = "ctx";
|
|
53
|
+
export declare const REQUEST_OBJ_CTX_KEY = "_req_ctx";
|
|
54
|
+
export declare const HTTP_SERVER_KEY = "_midway_http_server";
|
|
55
|
+
export declare const REQUEST_CTX_LOGGER_CACHE_KEY = "_midway_ctx_logger_cache";
|
|
56
|
+
export declare const ASYNC_CONTEXT_KEY: unique symbol;
|
|
57
|
+
export declare const ASYNC_CONTEXT_MANAGER_KEY = "MIDWAY_ASYNC_CONTEXT_MANAGER_KEY";
|
|
58
|
+
export declare const DEFAULT_PATTERN: string[];
|
|
59
|
+
export declare const IGNORE_PATTERN: string[];
|
|
51
60
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.FUNCTION_INJECT_KEY = 'midway:function_inject_key';
|
|
3
|
+
exports.IGNORE_PATTERN = exports.DEFAULT_PATTERN = exports.ASYNC_CONTEXT_MANAGER_KEY = exports.ASYNC_CONTEXT_KEY = exports.REQUEST_CTX_LOGGER_CACHE_KEY = exports.HTTP_SERVER_KEY = exports.REQUEST_OBJ_CTX_KEY = exports.REQUEST_CTX_KEY = exports.MIDWAY_LOGGER_WRITEABLE_DIR = exports.FUNCTION_INJECT_KEY = exports.VALUE_TYPE = exports.KEYS = void 0;
|
|
5
4
|
/**
|
|
6
5
|
* 静态参数
|
|
7
6
|
*
|
|
@@ -51,4 +50,21 @@ exports.VALUE_TYPE = {
|
|
|
51
50
|
OBJECT: 'object',
|
|
52
51
|
BOOLEAN: 'boolean',
|
|
53
52
|
};
|
|
53
|
+
exports.FUNCTION_INJECT_KEY = 'midway:function_inject_key';
|
|
54
|
+
exports.MIDWAY_LOGGER_WRITEABLE_DIR = 'MIDWAY_LOGGER_WRITEABLE_DIR';
|
|
55
|
+
exports.REQUEST_CTX_KEY = 'ctx';
|
|
56
|
+
exports.REQUEST_OBJ_CTX_KEY = '_req_ctx';
|
|
57
|
+
exports.HTTP_SERVER_KEY = '_midway_http_server';
|
|
58
|
+
exports.REQUEST_CTX_LOGGER_CACHE_KEY = '_midway_ctx_logger_cache';
|
|
59
|
+
exports.ASYNC_CONTEXT_KEY = Symbol('ASYNC_CONTEXT_KEY');
|
|
60
|
+
exports.ASYNC_CONTEXT_MANAGER_KEY = 'MIDWAY_ASYNC_CONTEXT_MANAGER_KEY';
|
|
61
|
+
exports.DEFAULT_PATTERN = [
|
|
62
|
+
'**/**.ts',
|
|
63
|
+
'**/**.js',
|
|
64
|
+
'**/**.mts',
|
|
65
|
+
'**/**.mjs',
|
|
66
|
+
'**/**.cts',
|
|
67
|
+
'**/**.cjs',
|
|
68
|
+
];
|
|
69
|
+
exports.IGNORE_PATTERN = ['**/**.d.ts', '**/**.d.mts', '**/**.d.cts'];
|
|
54
70
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import {
|
|
2
|
+
import { IModuleStore, ObjectIdentifier } from '../decorator';
|
|
3
3
|
import { IFileDetector, IIdentifierRelationShip, IMidwayContainer, IObjectDefinition, IObjectDefinitionRegistry, ObjectContext } from '../interface';
|
|
4
4
|
import { ManagedResolverFactory } from './managedResolverFactory';
|
|
5
5
|
import * as EventEmitter from 'events';
|
|
@@ -78,6 +78,7 @@ export declare class MidwayContainer implements IMidwayContainer, IModuleStore {
|
|
|
78
78
|
listModule(key: string): unknown[];
|
|
79
79
|
transformModule(moduleMap: Map<string, Set<any>>): void;
|
|
80
80
|
hasNamespace(ns: string): boolean;
|
|
81
|
+
getNamespaceList(): string[];
|
|
81
82
|
hasDefinition(identifier: ObjectIdentifier): boolean;
|
|
82
83
|
hasObject(identifier: ObjectIdentifier): boolean;
|
|
83
84
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MidwayContainer = void 0;
|
|
4
|
-
const decorator_1 = require("
|
|
4
|
+
const decorator_1 = require("../decorator");
|
|
5
5
|
const configuration_1 = require("../functional/configuration");
|
|
6
6
|
const util = require("util");
|
|
7
7
|
const definitionRegistry_1 = require("./definitionRegistry");
|
|
8
8
|
const interface_1 = require("../interface");
|
|
9
|
-
const constants_1 = require("../
|
|
9
|
+
const constants_1 = require("../constants");
|
|
10
10
|
const objectDefinition_1 = require("../definitions/objectDefinition");
|
|
11
11
|
const functionDefinition_1 = require("../definitions/functionDefinition");
|
|
12
12
|
const managedResolverFactory_1 = require("./managedResolverFactory");
|
|
@@ -15,6 +15,8 @@ const configService_1 = require("../service/configService");
|
|
|
15
15
|
const EventEmitter = require("events");
|
|
16
16
|
const error_1 = require("../error");
|
|
17
17
|
const extend_1 = require("../util/extend");
|
|
18
|
+
const types_1 = require("../util/types");
|
|
19
|
+
const util_1 = require("../util");
|
|
18
20
|
const debug = util.debuglog('midway:debug');
|
|
19
21
|
const debugBind = util.debuglog('midway:bind');
|
|
20
22
|
class ContainerConfiguration {
|
|
@@ -156,16 +158,16 @@ class ContainerConfiguration {
|
|
|
156
158
|
}
|
|
157
159
|
getConfigurationExport(exports) {
|
|
158
160
|
const mods = [];
|
|
159
|
-
if (
|
|
160
|
-
|
|
161
|
+
if (types_1.Types.isClass(exports) ||
|
|
162
|
+
types_1.Types.isFunction(exports) ||
|
|
161
163
|
exports instanceof configuration_1.FunctionalConfiguration) {
|
|
162
164
|
mods.push(exports);
|
|
163
165
|
}
|
|
164
166
|
else {
|
|
165
167
|
for (const m in exports) {
|
|
166
168
|
const module = exports[m];
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
+
if (types_1.Types.isClass(module) ||
|
|
170
|
+
types_1.Types.isFunction(module) ||
|
|
169
171
|
module instanceof configuration_1.FunctionalConfiguration) {
|
|
170
172
|
mods.push(module);
|
|
171
173
|
}
|
|
@@ -198,7 +200,7 @@ class MidwayContainer {
|
|
|
198
200
|
init() {
|
|
199
201
|
// 防止直接从applicationContext.getAsync or get对象实例时依赖当前上下文信息出错
|
|
200
202
|
// ctx is in requestContainer
|
|
201
|
-
this.registerObject(
|
|
203
|
+
this.registerObject(constants_1.REQUEST_CTX_KEY, this.ctx);
|
|
202
204
|
}
|
|
203
205
|
get objectCreateEventTarget() {
|
|
204
206
|
if (!this._objectCreateEventTarget) {
|
|
@@ -260,13 +262,13 @@ class MidwayContainer {
|
|
|
260
262
|
(_a = this.fileDetector) === null || _a === void 0 ? void 0 : _a.run(this);
|
|
261
263
|
}
|
|
262
264
|
bindClass(exports, options) {
|
|
263
|
-
if (
|
|
265
|
+
if (types_1.Types.isClass(exports) || types_1.Types.isFunction(exports)) {
|
|
264
266
|
this.bindModule(exports, options);
|
|
265
267
|
}
|
|
266
268
|
else {
|
|
267
269
|
for (const m in exports) {
|
|
268
270
|
const module = exports[m];
|
|
269
|
-
if (
|
|
271
|
+
if (types_1.Types.isClass(module) || types_1.Types.isFunction(module)) {
|
|
270
272
|
this.bindModule(module, options);
|
|
271
273
|
}
|
|
272
274
|
}
|
|
@@ -274,7 +276,7 @@ class MidwayContainer {
|
|
|
274
276
|
}
|
|
275
277
|
bind(identifier, target, options) {
|
|
276
278
|
var _a;
|
|
277
|
-
if (
|
|
279
|
+
if (types_1.Types.isClass(identifier) || types_1.Types.isFunction(identifier)) {
|
|
278
280
|
return this.bindModule(identifier, target);
|
|
279
281
|
}
|
|
280
282
|
if (this.registry.hasDefinition(identifier)) {
|
|
@@ -285,13 +287,13 @@ class MidwayContainer {
|
|
|
285
287
|
options.bindHook(target, options);
|
|
286
288
|
}
|
|
287
289
|
let definition;
|
|
288
|
-
if (
|
|
290
|
+
if (types_1.Types.isClass(target)) {
|
|
289
291
|
definition = new objectDefinition_1.ObjectDefinition();
|
|
290
292
|
definition.name = (0, decorator_1.getProviderName)(target);
|
|
291
293
|
}
|
|
292
294
|
else {
|
|
293
295
|
definition = new functionDefinition_1.FunctionDefinition();
|
|
294
|
-
if (!
|
|
296
|
+
if (!types_1.Types.isAsyncFunction(target)) {
|
|
295
297
|
definition.asynchronous = false;
|
|
296
298
|
}
|
|
297
299
|
definition.name = definition.id;
|
|
@@ -355,7 +357,7 @@ class MidwayContainer {
|
|
|
355
357
|
}
|
|
356
358
|
}
|
|
357
359
|
bindModule(module, options) {
|
|
358
|
-
if (
|
|
360
|
+
if (types_1.Types.isClass(module)) {
|
|
359
361
|
const providerId = (0, decorator_1.getProviderUUId)(module);
|
|
360
362
|
if (providerId) {
|
|
361
363
|
this.identifierMapping.saveClassRelation(module, options === null || options === void 0 ? void 0 : options.namespace);
|
|
@@ -371,7 +373,7 @@ class MidwayContainer {
|
|
|
371
373
|
if (!info.scope) {
|
|
372
374
|
info.scope = decorator_1.ScopeEnum.Request;
|
|
373
375
|
}
|
|
374
|
-
const uuid =
|
|
376
|
+
const uuid = util_1.Utils.generateRandomId();
|
|
375
377
|
this.identifierMapping.saveFunctionRelation(info.id, uuid);
|
|
376
378
|
this.bind(uuid, module, {
|
|
377
379
|
scope: info.scope,
|
|
@@ -488,6 +490,9 @@ class MidwayContainer {
|
|
|
488
490
|
hasNamespace(ns) {
|
|
489
491
|
return this.namespaceSet.has(ns);
|
|
490
492
|
}
|
|
493
|
+
getNamespaceList() {
|
|
494
|
+
return Array.from(this.namespaceSet);
|
|
495
|
+
}
|
|
491
496
|
hasDefinition(identifier) {
|
|
492
497
|
return this.registry.hasDefinition(identifier);
|
|
493
498
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Object Definition Registry 实现
|
|
3
3
|
*/
|
|
4
|
-
import { ObjectIdentifier } from '
|
|
4
|
+
import { ObjectIdentifier } from '../decorator';
|
|
5
5
|
import { IIdentifierRelationShip, IObjectDefinition, IObjectDefinitionRegistry } from '../interface';
|
|
6
6
|
export declare class ObjectDefinitionRegistry extends Map implements IObjectDefinitionRegistry {
|
|
7
7
|
private singletonIds;
|