@midwayjs/core 3.0.0-beta.1 → 3.0.0-beta.13

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +138 -0
  2. package/README.md +1 -1
  3. package/dist/baseFramework.d.ts +13 -10
  4. package/dist/baseFramework.js +32 -23
  5. package/dist/common/applicationManager.d.ts +12 -0
  6. package/dist/common/applicationManager.js +66 -0
  7. package/dist/{util → common}/fileDetector.d.ts +0 -0
  8. package/dist/{util → common}/fileDetector.js +0 -0
  9. package/dist/common/filterManager.d.ts +19 -0
  10. package/dist/common/filterManager.js +85 -0
  11. package/dist/common/middlewareManager.d.ts +68 -0
  12. package/dist/common/middlewareManager.js +183 -0
  13. package/dist/{util → common}/serviceFactory.d.ts +0 -0
  14. package/dist/{util → common}/serviceFactory.js +0 -0
  15. package/dist/{util → common}/triggerCollector.d.ts +0 -0
  16. package/dist/{util → common}/triggerCollector.js +0 -0
  17. package/dist/common/webGenerator.d.ts +16 -0
  18. package/dist/{util → common}/webGenerator.js +36 -51
  19. package/dist/{util → common}/webRouterCollector.d.ts +9 -4
  20. package/dist/{util → common}/webRouterCollector.js +53 -29
  21. package/dist/config/config.default.d.ts +3 -17
  22. package/dist/context/container.js +13 -2
  23. package/dist/context/managedResolverFactory.js +5 -5
  24. package/dist/definitions/objectCreator.js +3 -2
  25. package/dist/error/base.d.ts +24 -3
  26. package/dist/error/base.js +34 -4
  27. package/dist/error/framework.d.ts +26 -2
  28. package/dist/error/framework.js +48 -10
  29. package/dist/error/http.d.ts +145 -38
  30. package/dist/error/http.js +162 -30
  31. package/dist/error/index.d.ts +1 -0
  32. package/dist/error/index.js +1 -0
  33. package/dist/index.d.ts +9 -9
  34. package/dist/index.js +13 -11
  35. package/dist/interface.d.ts +59 -30
  36. package/dist/service/configService.js +4 -5
  37. package/dist/service/decoratorService.js +33 -25
  38. package/dist/service/frameworkService.d.ts +6 -4
  39. package/dist/service/frameworkService.js +26 -11
  40. package/dist/service/lifeCycleService.js +7 -5
  41. package/dist/service/loggerService.d.ts +1 -2
  42. package/dist/service/loggerService.js +1 -10
  43. package/dist/service/middlewareService.d.ts +3 -4
  44. package/dist/service/middlewareService.js +28 -46
  45. package/dist/setup.js +10 -2
  46. package/dist/util/contextUtil.d.ts +1 -1
  47. package/dist/util/index.d.ts +46 -0
  48. package/dist/util/index.js +150 -1
  49. package/dist/util/webRouterParam.d.ts +2 -2
  50. package/dist/util/webRouterParam.js +41 -22
  51. package/package.json +7 -7
  52. package/dist/error/code.d.ts +0 -59
  53. package/dist/error/code.js +0 -64
  54. package/dist/util/exceptionFilterManager.d.ts +0 -13
  55. package/dist/util/exceptionFilterManager.js +0 -53
  56. package/dist/util/middlewareManager.d.ts +0 -11
  57. package/dist/util/middlewareManager.js +0 -48
  58. package/dist/util/webGenerator.d.ts +0 -30
@@ -4,6 +4,7 @@ import { MidwayConfigService } from './configService';
4
4
  import { MidwayLoggerService } from './loggerService';
5
5
  import { MidwayDecoratorService } from './decoratorService';
6
6
  import { MidwayAspectService } from './aspectService';
7
+ import { MidwayApplicationManager } from '../common/applicationManager';
7
8
  export declare class MidwayFrameworkService {
8
9
  readonly applicationContext: IMidwayContainer;
9
10
  readonly globalOptions: any;
@@ -11,14 +12,15 @@ export declare class MidwayFrameworkService {
11
12
  loggerService: MidwayLoggerService;
12
13
  aspectService: MidwayAspectService;
13
14
  decoratorService: MidwayDecoratorService;
15
+ applicationManager: MidwayApplicationManager;
14
16
  constructor(applicationContext: IMidwayContainer, globalOptions: any);
15
17
  private mainFramework;
16
- private globalFrameworkMap;
17
18
  private globalFrameworkList;
18
- init(): Promise<void>;
19
+ protected init(): Promise<void>;
19
20
  getMainApp(): any;
20
- getMainFramework(): IMidwayFramework<any, any>;
21
- getFramework(type: MidwayFrameworkType): IMidwayFramework<any, any>;
21
+ getMainFramework(): IMidwayFramework<any, any, any, unknown, unknown>;
22
+ getFramework(namespaceOrFrameworkType: string | MidwayFrameworkType): IMidwayFramework<any, any, any, unknown, unknown>;
23
+ runFramework(): Promise<void>;
22
24
  stopFramework(): Promise<void>;
23
25
  }
24
26
  //# sourceMappingURL=frameworkService.d.ts.map
@@ -18,6 +18,7 @@ const baseFramework_1 = require("../baseFramework");
18
18
  const pipelineService_1 = require("./pipelineService");
19
19
  const decoratorService_1 = require("./decoratorService");
20
20
  const aspectService_1 = require("./aspectService");
21
+ const applicationManager_1 = require("../common/applicationManager");
21
22
  const util = require("util");
22
23
  const error_1 = require("../error");
23
24
  const debug = util.debuglog('midway:debug');
@@ -25,10 +26,10 @@ let MidwayFrameworkService = class MidwayFrameworkService {
25
26
  constructor(applicationContext, globalOptions) {
26
27
  this.applicationContext = applicationContext;
27
28
  this.globalOptions = globalOptions;
28
- this.globalFrameworkMap = new WeakMap();
29
29
  this.globalFrameworkList = [];
30
30
  }
31
31
  async init() {
32
+ var _a;
32
33
  // register base config hook
33
34
  this.decoratorService.registerPropertyHandler(decorator_1.CONFIG_KEY, (propertyName, meta) => {
34
35
  var _a;
@@ -51,7 +52,7 @@ let MidwayFrameworkService = class MidwayFrameworkService {
51
52
  let frameworks = (0, decorator_1.listModule)(decorator_1.FRAMEWORK_KEY);
52
53
  // filter proto
53
54
  frameworks = filterProtoFramework(frameworks);
54
- debug(`[core:framework]: Found Framework length = ${frameworks.length}`);
55
+ debug(`[core]: Found Framework length = ${frameworks.length}`);
55
56
  if (frameworks.length) {
56
57
  for (const frameworkClz of frameworks) {
57
58
  const frameworkInstance = await this.applicationContext.getAsync(frameworkClz, [this.applicationContext]);
@@ -62,24 +63,24 @@ let MidwayFrameworkService = class MidwayFrameworkService {
62
63
  applicationContext: this.applicationContext,
63
64
  ...this.globalOptions,
64
65
  });
65
- debug(`[core:framework]: Found Framework "${frameworkInstance.getFrameworkName()}" and initialize.`);
66
+ debug(`[core]: Found Framework "${frameworkInstance.getFrameworkName()}" and initialize.`);
66
67
  }
67
68
  else {
68
- debug(`[core:framework]: Found Framework "${frameworkInstance.getFrameworkName()}" and delay initialize.`);
69
+ debug(`[core]: Found Framework "${frameworkInstance.getFrameworkName()}" and delay initialize.`);
69
70
  }
70
71
  // app init
71
- this.globalFrameworkMap.set(frameworkInstance.getFrameworkType(), frameworkInstance);
72
+ const definition = this.applicationContext.registry.getDefinition((0, decorator_1.getProviderUUId)(frameworkClz));
73
+ this.applicationManager.addFramework((_a = definition === null || definition === void 0 ? void 0 : definition.namespace) !== null && _a !== void 0 ? _a : frameworkInstance.getFrameworkName(), frameworkInstance);
72
74
  this.globalFrameworkList.push(frameworkInstance);
73
75
  }
74
76
  // register @App decorator handler
75
77
  this.decoratorService.registerPropertyHandler(decorator_1.APPLICATION_KEY, (propertyName, mete) => {
76
78
  if (mete.type) {
77
- if (this.globalFrameworkMap.has(mete.type)) {
78
- return this.globalFrameworkMap.get(mete.type).getApplication();
79
- }
80
- else {
79
+ const framework = this.applicationManager.getApplication(mete.type);
80
+ if (!framework) {
81
81
  throw new error_1.MidwayCommonError(`Framework ${mete.type} not Found`);
82
82
  }
83
+ return framework;
83
84
  }
84
85
  else {
85
86
  return this.getMainApp();
@@ -107,8 +108,18 @@ let MidwayFrameworkService = class MidwayFrameworkService {
107
108
  getMainFramework() {
108
109
  return this.mainFramework;
109
110
  }
110
- getFramework(type) {
111
- return this.globalFrameworkMap.get(type);
111
+ getFramework(namespaceOrFrameworkType) {
112
+ return this.applicationManager.getFramework(namespaceOrFrameworkType);
113
+ }
114
+ async runFramework() {
115
+ for (const frameworkInstance of this.globalFrameworkList) {
116
+ // if enable, just init framework
117
+ if (frameworkInstance.isEnable()) {
118
+ // app init
119
+ await frameworkInstance.run();
120
+ debug(`[core]: Found Framework "${frameworkInstance.getFrameworkName()}" and run.`);
121
+ }
122
+ }
112
123
  }
113
124
  async stopFramework() {
114
125
  await Promise.all(Array.from(this.globalFrameworkList).map(frameworkInstance => {
@@ -132,6 +143,10 @@ __decorate([
132
143
  (0, decorator_1.Inject)(),
133
144
  __metadata("design:type", decoratorService_1.MidwayDecoratorService)
134
145
  ], MidwayFrameworkService.prototype, "decoratorService", void 0);
146
+ __decorate([
147
+ (0, decorator_1.Inject)(),
148
+ __metadata("design:type", applicationManager_1.MidwayApplicationManager)
149
+ ], MidwayFrameworkService.prototype, "applicationManager", void 0);
135
150
  __decorate([
136
151
  (0, decorator_1.Init)(),
137
152
  __metadata("design:type", Function),
@@ -23,7 +23,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
23
23
  async init() {
24
24
  // run lifecycle
25
25
  const cycles = (0, decorator_1.listModule)(decorator_1.CONFIGURATION_KEY);
26
- debug(`[core:lifecycle]: Found Configuration length = ${cycles.length}`);
26
+ debug(`[core]: Found Configuration length = ${cycles.length}`);
27
27
  const lifecycleInstanceList = [];
28
28
  for (const cycle of cycles) {
29
29
  if (cycle.target instanceof configuration_1.FunctionalConfiguration) {
@@ -32,7 +32,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
32
32
  }
33
33
  else {
34
34
  // 普通类写法
35
- debug(`[core:lifecycle]: run ${cycle.target.name} init`);
35
+ debug(`[core]: run ${cycle.target.name} init`);
36
36
  cycle.instance = await this.applicationContext.getAsync(cycle.target);
37
37
  }
38
38
  cycle.instance && lifecycleInstanceList.push(cycle);
@@ -54,6 +54,8 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
54
54
  });
55
55
  // exec onReady()
56
56
  await this.runContainerLifeCycle(lifecycleInstanceList, 'onReady');
57
+ // exec framework.run()
58
+ await this.frameworkService.runFramework();
57
59
  // exec onServerReady()
58
60
  await this.runContainerLifeCycle(lifecycleInstanceList, 'onServerReady');
59
61
  }
@@ -78,7 +80,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
78
80
  if (Array.isArray(lifecycleInstanceOrList)) {
79
81
  for (const cycle of lifecycleInstanceOrList) {
80
82
  if (typeof cycle.instance[lifecycle] === 'function') {
81
- debug(`[core:lifecycle]: run ${cycle.instance.constructor.name} ${lifecycle}`);
83
+ debug(`[core]: run ${cycle.instance.constructor.name} ${lifecycle}`);
82
84
  const result = await cycle.instance[lifecycle](this.applicationContext, this.frameworkService.getMainApp());
83
85
  if (resultHandler) {
84
86
  resultHandler(result);
@@ -88,7 +90,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
88
90
  }
89
91
  else {
90
92
  if (typeof lifecycleInstanceOrList[lifecycle] === 'function') {
91
- debug(`[core:lifecycle]: run ${lifecycleInstanceOrList.constructor.name} ${lifecycle}`);
93
+ debug(`[core]: run ${lifecycleInstanceOrList.constructor.name} ${lifecycle}`);
92
94
  const result = await lifecycleInstanceOrList[lifecycle](this.applicationContext, this.frameworkService.getMainApp());
93
95
  if (resultHandler) {
94
96
  resultHandler(result);
@@ -99,7 +101,7 @@ let MidwayLifeCycleService = class MidwayLifeCycleService {
99
101
  async runObjectLifeCycle(lifecycleInstanceList, lifecycle) {
100
102
  for (const cycle of lifecycleInstanceList) {
101
103
  if (typeof cycle.instance[lifecycle] === 'function') {
102
- debug(`[core:lifecycle]: run ${cycle.instance.constructor.name} ${lifecycle}`);
104
+ debug(`[core]: run ${cycle.instance.constructor.name} ${lifecycle}`);
103
105
  return this.applicationContext[lifecycle](cycle.instance[lifecycle].bind(cycle.instance));
104
106
  }
105
107
  }
@@ -1,5 +1,5 @@
1
1
  import { MidwayConfigService } from './configService';
2
- import { ServiceFactory } from '../util/serviceFactory';
2
+ import { ServiceFactory } from '../common/serviceFactory';
3
3
  import { ILogger } from '@midwayjs/logger';
4
4
  import { IMidwayContainer } from '../interface';
5
5
  export declare class MidwayLoggerService extends ServiceFactory<ILogger> {
@@ -15,7 +15,6 @@ export declare class MidwayLoggerService extends ServiceFactory<ILogger> {
15
15
  };
16
16
  protected createClient(config: any, name?: string): Promise<void>;
17
17
  getName(): string;
18
- destroy(): Promise<void>;
19
18
  createLogger(name: any, config: any): ILogger;
20
19
  getLogger(name: string): ILogger;
21
20
  transformEggLogger(options: any): {
@@ -12,7 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.MidwayLoggerService = void 0;
13
13
  const decorator_1 = require("@midwayjs/decorator");
14
14
  const configService_1 = require("./configService");
15
- const serviceFactory_1 = require("../util/serviceFactory");
15
+ const serviceFactory_1 = require("../common/serviceFactory");
16
16
  const logger_1 = require("@midwayjs/logger");
17
17
  const levelTransform = level => {
18
18
  if (!level) {
@@ -73,9 +73,6 @@ let MidwayLoggerService = class MidwayLoggerService extends serviceFactory_1.Ser
73
73
  getName() {
74
74
  return 'logger';
75
75
  }
76
- async destroy() {
77
- logger_1.loggers.close();
78
- }
79
76
  createLogger(name, config) {
80
77
  return logger_1.loggers.createLogger(name, config);
81
78
  }
@@ -119,12 +116,6 @@ __decorate([
119
116
  __metadata("design:paramtypes", []),
120
117
  __metadata("design:returntype", Promise)
121
118
  ], MidwayLoggerService.prototype, "init", null);
122
- __decorate([
123
- (0, decorator_1.Destroy)(),
124
- __metadata("design:type", Function),
125
- __metadata("design:paramtypes", []),
126
- __metadata("design:returntype", Promise)
127
- ], MidwayLoggerService.prototype, "destroy", null);
128
119
  MidwayLoggerService = __decorate([
129
120
  (0, decorator_1.Provide)(),
130
121
  (0, decorator_1.Scope)(decorator_1.ScopeEnum.Singleton),
@@ -1,11 +1,10 @@
1
- import { CommonMiddleware, IMidwayContainer } from '../interface';
2
- export declare class MidwayMiddlewareService<T> {
1
+ import { CommonMiddleware, IMidwayContainer, IMidwayApplication } from '../interface';
2
+ export declare class MidwayMiddlewareService<T, R, N = unknown> {
3
3
  readonly applicationContext: IMidwayContainer;
4
4
  constructor(applicationContext: IMidwayContainer);
5
- compose(middleware: Array<CommonMiddleware<T> | string>, name?: string): Promise<{
5
+ compose(middleware: Array<CommonMiddleware<T, R, N> | string>, app: IMidwayApplication, name?: string): Promise<{
6
6
  (context: any, next?: any): Promise<any>;
7
7
  _name: string;
8
8
  }>;
9
9
  }
10
- export declare function pathMatching(options: any): (ctx?: any) => any;
11
10
  //# sourceMappingURL=middlewareService.d.ts.map
@@ -9,15 +9,15 @@ var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.pathMatching = exports.MidwayMiddlewareService = void 0;
12
+ exports.MidwayMiddlewareService = void 0;
13
13
  const decorator_1 = require("@midwayjs/decorator");
14
- const pathToRegexp_1 = require("../util/pathToRegexp");
15
14
  const error_1 = require("../error");
15
+ const util_1 = require("../util");
16
16
  let MidwayMiddlewareService = class MidwayMiddlewareService {
17
17
  constructor(applicationContext) {
18
18
  this.applicationContext = applicationContext;
19
19
  }
20
- async compose(middleware, name) {
20
+ async compose(middleware, app, name) {
21
21
  if (!Array.isArray(middleware)) {
22
22
  throw new error_1.MidwayParameterError('Middleware stack must be an array');
23
23
  }
@@ -30,16 +30,18 @@ let MidwayMiddlewareService = class MidwayMiddlewareService {
30
30
  }
31
31
  const classMiddleware = await this.applicationContext.getAsync(fn);
32
32
  if (classMiddleware) {
33
- fn = classMiddleware.resolve();
33
+ fn = classMiddleware.resolve(app);
34
34
  if (!classMiddleware.match && !classMiddleware.ignore) {
35
- fn._name = classMiddleware.constructor.name;
35
+ if (!fn.name) {
36
+ fn._name = classMiddleware.constructor.name;
37
+ }
36
38
  // just got fn
37
39
  newMiddlewareArr.push(fn);
38
40
  }
39
41
  else {
40
42
  // wrap ignore and match
41
43
  const mw = fn;
42
- const match = pathMatching({
44
+ const match = (0, util_1.pathMatching)({
43
45
  match: classMiddleware.match,
44
46
  ignore: classMiddleware.ignore,
45
47
  });
@@ -67,6 +69,7 @@ let MidwayMiddlewareService = class MidwayMiddlewareService {
67
69
  * @api public
68
70
  */
69
71
  const composeFn = (context, next) => {
72
+ const supportBody = (0, util_1.isIncludeProperty)(context, 'body');
70
73
  // last called middleware #
71
74
  let index = -1;
72
75
  return dispatch(0);
@@ -80,9 +83,25 @@ let MidwayMiddlewareService = class MidwayMiddlewareService {
80
83
  if (!fn)
81
84
  return Promise.resolve();
82
85
  try {
83
- return Promise.resolve(fn(context, dispatch.bind(null, i + 1), {
84
- index,
85
- }));
86
+ if (supportBody) {
87
+ return Promise.resolve(fn(context, dispatch.bind(null, i + 1), {
88
+ index,
89
+ })).then(result => {
90
+ // need to set body
91
+ if (context.body && !result) {
92
+ result = context.body;
93
+ }
94
+ else if (result && context.body !== result) {
95
+ context.body = result;
96
+ }
97
+ return result;
98
+ });
99
+ }
100
+ else {
101
+ return Promise.resolve(fn(context, dispatch.bind(null, i + 1), {
102
+ index,
103
+ }));
104
+ }
86
105
  }
87
106
  catch (err) {
88
107
  return Promise.reject(err);
@@ -101,41 +120,4 @@ MidwayMiddlewareService = __decorate([
101
120
  __metadata("design:paramtypes", [Object])
102
121
  ], MidwayMiddlewareService);
103
122
  exports.MidwayMiddlewareService = MidwayMiddlewareService;
104
- function pathMatching(options) {
105
- options = options || {};
106
- if (options.match && options.ignore)
107
- throw new error_1.MidwayCommonError('options.match and options.ignore can not both present');
108
- if (!options.match && !options.ignore)
109
- return () => true;
110
- const matchFn = options.match
111
- ? toPathMatch(options.match)
112
- : toPathMatch(options.ignore);
113
- return function pathMatch(ctx) {
114
- const matched = matchFn(ctx);
115
- return options.match ? matched : !matched;
116
- };
117
- }
118
- exports.pathMatching = pathMatching;
119
- function toPathMatch(pattern) {
120
- if (typeof pattern === 'string') {
121
- const reg = (0, pathToRegexp_1.pathToRegexp)(pattern, [], { end: false });
122
- if (reg.global)
123
- reg.lastIndex = 0;
124
- return ctx => reg.test(ctx.path);
125
- }
126
- if (pattern instanceof RegExp) {
127
- return ctx => {
128
- if (pattern.global)
129
- pattern.lastIndex = 0;
130
- return pattern.test(ctx.path);
131
- };
132
- }
133
- if (typeof pattern === 'function')
134
- return pattern;
135
- if (Array.isArray(pattern)) {
136
- const matchs = pattern.map(item => toPathMatch(item));
137
- return ctx => matchs.some(match => match(ctx));
138
- }
139
- throw new error_1.MidwayCommonError('match/ignore pattern must be RegExp, Array or String, but got ' + pattern);
140
- }
141
123
  //# sourceMappingURL=middlewareService.js.map
package/dist/setup.js CHANGED
@@ -6,6 +6,7 @@ const config_default_1 = require("./config/config.default");
6
6
  const decorator_1 = require("@midwayjs/decorator");
7
7
  const util = require("util");
8
8
  const path_1 = require("path");
9
+ const logger_1 = require("@midwayjs/logger");
9
10
  const debug = util.debuglog('midway:debug');
10
11
  async function initializeGlobalApplicationContext(globalOptions) {
11
12
  var _a, _b, _c, _d;
@@ -21,7 +22,7 @@ async function initializeGlobalApplicationContext(globalOptions) {
21
22
  // register baseDir and appDir
22
23
  applicationContext.registerObject('baseDir', baseDir);
23
24
  applicationContext.registerObject('appDir', appDir);
24
- if (globalOptions.moduleDirector !== false) {
25
+ if (globalOptions.moduleDetector !== false) {
25
26
  if (globalOptions.moduleDetector === undefined ||
26
27
  globalOptions.moduleDetector === 'file') {
27
28
  applicationContext.setFileDetector(new _1.DirectoryFileDetector({
@@ -43,6 +44,7 @@ async function initializeGlobalApplicationContext(globalOptions) {
43
44
  applicationContext.bindClass(_1.MidwayFrameworkService);
44
45
  applicationContext.bindClass(_1.MidwayMiddlewareService);
45
46
  applicationContext.bindClass(_1.MidwayLifeCycleService);
47
+ applicationContext.bindClass(_1.MidwayApplicationManager);
46
48
  // bind preload module
47
49
  if (globalOptions.preloadModules && globalOptions.preloadModules.length) {
48
50
  for (const preloadModule of globalOptions.preloadModules) {
@@ -74,7 +76,12 @@ async function initializeGlobalApplicationContext(globalOptions) {
74
76
  // bind user code module
75
77
  await applicationContext.ready();
76
78
  if (globalOptions.globalConfig) {
77
- configService.add([globalOptions.globalConfig]);
79
+ if (Array.isArray(globalOptions.globalConfig)) {
80
+ configService.add(globalOptions.globalConfig);
81
+ }
82
+ else {
83
+ configService.addObject(globalOptions.globalConfig);
84
+ }
78
85
  }
79
86
  // merge config
80
87
  await configService.load();
@@ -104,6 +111,7 @@ async function destroyGlobalApplicationContext(applicationContext) {
104
111
  // stop container
105
112
  await applicationContext.stop();
106
113
  (0, decorator_1.clearBindContainer)();
114
+ logger_1.loggers.close();
107
115
  global['MIDWAY_APPLICATION_CONTEXT'] = undefined;
108
116
  global['MIDWAY_MAIN_FRAMEWORK'] = undefined;
109
117
  }
@@ -1,5 +1,5 @@
1
1
  import { IConfigurationOptions, IMidwayContainer, IMidwayFramework } from '../interface';
2
2
  export declare const getCurrentApplicationContext: () => IMidwayContainer;
3
- export declare const getCurrentMainFramework: <APP extends import("../interface").IMidwayBaseApplication<import("../interface").Context>, T extends IConfigurationOptions>() => IMidwayFramework<APP, T>;
3
+ export declare const getCurrentMainFramework: <APP extends import("../interface").IMidwayBaseApplication<CTX>, CTX extends import("../interface").Context, CONFIG extends IConfigurationOptions>() => IMidwayFramework<APP, CTX, CONFIG, unknown, unknown>;
4
4
  export declare const getCurrentMainApp: <APP extends import("../interface").IMidwayBaseApplication<import("../interface").Context>>() => APP;
5
5
  //# sourceMappingURL=contextUtil.d.ts.map
@@ -1,5 +1,18 @@
1
+ import { FunctionMiddleware } from '../interface';
2
+ /**
3
+ * @since 2.0.0
4
+ * @param env
5
+ */
1
6
  export declare const isDevelopmentEnvironment: (env: any) => boolean;
7
+ /**
8
+ * @since 2.0.0
9
+ */
2
10
  export declare const getCurrentEnvironment: () => string;
11
+ /**
12
+ * @param p
13
+ * @param enabledCache
14
+ * @since 2.0.0
15
+ */
3
16
  export declare const safeRequire: (p: any, enabledCache?: boolean) => any;
4
17
  /**
5
18
  * safelyGet(['a','b'],{a: {b: 2}}) // => 2
@@ -8,11 +21,13 @@ export declare const safeRequire: (p: any, enabledCache?: boolean) => any;
8
21
  * safelyGet(['a','1'],{a: {b: 2}}) // => undefined
9
22
  * safelyGet('a.b',{a: {b: 2}}) // => 2
10
23
  * safelyGet('a.b',{c: {b: 2}}) // => undefined
24
+ * @since 2.0.0
11
25
  */
12
26
  export declare function safelyGet(list: string | string[], obj?: Record<string, unknown>): any;
13
27
  /**
14
28
  * 剔除 @ 符号
15
29
  * @param provideId provideId
30
+ * @since 2.0.0
16
31
  */
17
32
  export declare function parsePrefix(provideId: string): string;
18
33
  export declare function getUserHome(): string;
@@ -21,19 +36,50 @@ export declare function joinURLPath(...strArray: any[]): string;
21
36
  * 代理目标所有的原型方法,不包括构造器和内部隐藏方法
22
37
  * @param derivedCtor
23
38
  * @param constructors
39
+ * @since 2.0.0
24
40
  */
25
41
  export declare function delegateTargetPrototypeMethod(derivedCtor: any, constructors: any[]): void;
26
42
  /**
27
43
  * 代理目标原型上的特定方法
28
44
  * @param derivedCtor
29
45
  * @param methods
46
+ * @since 2.0.0
30
47
  */
31
48
  export declare function delegateTargetMethod(derivedCtor: any, methods: string[]): void;
32
49
  /**
33
50
  * 代理目标原型属性
34
51
  * @param derivedCtor
35
52
  * @param properties
53
+ * @since 2.0.0
36
54
  */
37
55
  export declare function delegateTargetProperties(derivedCtor: any, properties: string[]): void;
56
+ /**
57
+ * 代理目标原型属性
58
+ * @since 2.0.0
59
+ * @param timestamp
60
+ */
38
61
  export declare const getCurrentDateString: (timestamp?: number) => string;
62
+ /**
63
+ *
64
+ * @param message
65
+ * @since 3.0.0
66
+ */
67
+ export declare const deprecatedOutput: (message: string) => void;
68
+ /**
69
+ * transform request object to definition type
70
+ *
71
+ * @param originValue
72
+ * @param targetType
73
+ * @since 3.0.0
74
+ */
75
+ export declare const transformRequestObjectByType: (originValue: any, targetType?: any) => any;
76
+ export declare function toPathMatch(pattern: any): any;
77
+ export declare function pathMatching(options: any): (ctx?: any) => any;
78
+ /**
79
+ * wrap function middleware with match and ignore
80
+ * @param mw
81
+ * @param options
82
+ */
83
+ export declare function wrapMiddleware(mw: FunctionMiddleware<any, any>, options: any): (context: any, next: any, options?: any) => any;
84
+ export declare function isIncludeProperty(obj: any, prop: string): boolean;
39
85
  //# sourceMappingURL=index.d.ts.map