@midwayjs/core 3.0.0-alpha.10 → 3.0.0-alpha.37

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 (51) hide show
  1. package/CHANGELOG.md +3 -17
  2. package/dist/baseFramework.js +30 -44
  3. package/dist/common/reflectTool.d.ts +3 -1
  4. package/dist/context/container.d.ts +48 -24
  5. package/dist/context/container.js +212 -215
  6. package/dist/context/definitionRegistry.d.ts +26 -0
  7. package/dist/context/definitionRegistry.js +124 -0
  8. package/dist/context/managedResolverFactory.d.ts +15 -19
  9. package/dist/context/managedResolverFactory.js +27 -256
  10. package/dist/context/providerWrapper.d.ts +2 -3
  11. package/dist/context/requestContainer.js +7 -10
  12. package/dist/context/resolverHandler.d.ts +2 -2
  13. package/dist/context/resolverHandler.js +2 -2
  14. package/dist/definitions/functionDefinition.d.ts +0 -2
  15. package/dist/definitions/functionDefinition.js +0 -6
  16. package/dist/definitions/objectCreator.js +6 -6
  17. package/dist/definitions/objectDefinition.d.ts +1 -4
  18. package/dist/definitions/objectDefinition.js +0 -8
  19. package/dist/definitions/properties.d.ts +0 -2
  20. package/dist/definitions/properties.js +5 -21
  21. package/dist/definitions/resource.js +13 -13
  22. package/dist/features/pipeline.d.ts +3 -3
  23. package/dist/features/pipeline.js +1 -1
  24. package/dist/functional/configuration.d.ts +2 -0
  25. package/dist/functional/configuration.js +10 -0
  26. package/dist/index.d.ts +1 -1
  27. package/dist/index.js +1 -23
  28. package/dist/interface.d.ts +21 -32
  29. package/dist/logger.js +4 -4
  30. package/dist/service/aspectService.js +9 -4
  31. package/dist/service/configService.d.ts +4 -4
  32. package/dist/service/configService.js +32 -20
  33. package/dist/service/environmentService.js +2 -2
  34. package/dist/service/informationService.js +4 -4
  35. package/dist/util/containerUtil.d.ts +3 -1
  36. package/dist/util/containerUtil.js +3 -3
  37. package/dist/util/contextUtil.js +2 -2
  38. package/dist/util/fileDetector.js +2 -2
  39. package/dist/util/index.js +3 -3
  40. package/dist/util/pathFileUtil.js +2 -2
  41. package/dist/util/serviceFactory.d.ts +4 -2
  42. package/dist/util/serviceFactory.js +11 -3
  43. package/dist/util/webRouterCollector.d.ts +8 -0
  44. package/dist/util/webRouterCollector.js +72 -128
  45. package/package.json +6 -5
  46. package/dist/context/applicationContext.d.ts +0 -81
  47. package/dist/context/applicationContext.js +0 -263
  48. package/dist/context/managed.d.ts +0 -45
  49. package/dist/context/managed.js +0 -69
  50. package/dist/util/staticConfig.d.ts +0 -10
  51. package/dist/util/staticConfig.js +0 -67
@@ -19,13 +19,11 @@ export declare class FunctionDefinition implements IObjectDefinition {
19
19
  handlerProps: HandlerProp[];
20
20
  protected innerAutowire: boolean;
21
21
  protected innerScope: ScopeEnum;
22
- set autowire(autowire: boolean);
23
22
  getAttr(key: ObjectIdentifier): any;
24
23
  hasAttr(key: ObjectIdentifier): boolean;
25
24
  hasConstructorArgs(): boolean;
26
25
  hasDependsOn(): boolean;
27
26
  isAsync(): boolean;
28
- isAutowire(): boolean;
29
27
  isDirect(): boolean;
30
28
  isExternal(): boolean;
31
29
  set scope(scope: ScopeEnum);
@@ -28,9 +28,6 @@ class FunctionDefinition {
28
28
  this.innerScope = decorator_1.ScopeEnum.Singleton;
29
29
  this.creator = new FunctionWrapperCreator(this);
30
30
  }
31
- set autowire(autowire) {
32
- this.innerAutowire = autowire;
33
- }
34
31
  getAttr(key) { }
35
32
  hasAttr(key) {
36
33
  return false;
@@ -44,9 +41,6 @@ class FunctionDefinition {
44
41
  isAsync() {
45
42
  return this.asynchronous;
46
43
  }
47
- isAutowire() {
48
- return this.innerAutowire;
49
- }
50
44
  isDirect() {
51
45
  return false;
52
46
  }
@@ -64,7 +64,7 @@ class ObjectCreator {
64
64
  let inst;
65
65
  if (this.definition.constructMethod) {
66
66
  const fn = Clzz[this.definition.constructMethod];
67
- if (decorator_1.isAsyncFunction(fn)) {
67
+ if ((0, decorator_1.isAsyncFunction)(fn)) {
68
68
  inst = await fn.apply(Clzz, args);
69
69
  }
70
70
  else {
@@ -85,13 +85,13 @@ class ObjectCreator {
85
85
  const inst = obj;
86
86
  // after properties set then do init
87
87
  if (this.definition.initMethod && inst[this.definition.initMethod]) {
88
- if (decorator_1.isGeneratorFunction(inst[this.definition.initMethod]) ||
89
- decorator_1.isAsyncFunction(inst[this.definition.initMethod])) {
88
+ if ((0, decorator_1.isGeneratorFunction)(inst[this.definition.initMethod]) ||
89
+ (0, decorator_1.isAsyncFunction)(inst[this.definition.initMethod])) {
90
90
  throw new Error(`${this.definition.id} not valid by context.get, Use context.getAsync instead!`);
91
91
  }
92
92
  else {
93
93
  const rt = inst[this.definition.initMethod].call(inst);
94
- if (decorator_1.isPromise(rt)) {
94
+ if ((0, decorator_1.isPromise)(rt)) {
95
95
  throw new Error(`${this.definition.id} not valid by context.get, Use context.getAsync instead!`);
96
96
  }
97
97
  }
@@ -106,7 +106,7 @@ class ObjectCreator {
106
106
  const inst = obj;
107
107
  if (this.definition.initMethod && inst[this.definition.initMethod]) {
108
108
  const initFn = inst[this.definition.initMethod];
109
- if (decorator_1.isAsyncFunction(initFn)) {
109
+ if ((0, decorator_1.isAsyncFunction)(initFn)) {
110
110
  await initFn.call(inst);
111
111
  }
112
112
  else {
@@ -139,7 +139,7 @@ class ObjectCreator {
139
139
  async doDestroyAsync(obj) {
140
140
  if (this.definition.destroyMethod && obj[this.definition.destroyMethod]) {
141
141
  const fn = obj[this.definition.destroyMethod];
142
- if (decorator_1.isAsyncFunction(fn)) {
142
+ if ((0, decorator_1.isAsyncFunction)(fn)) {
143
143
  await fn.call(obj);
144
144
  }
145
145
  else {
@@ -2,9 +2,8 @@ import { IObjectCreator, IObjectDefinition, HandlerProp } from '../interface';
2
2
  import { ScopeEnum, ObjectIdentifier } from '@midwayjs/decorator';
3
3
  import { ObjectProperties } from './properties';
4
4
  export declare class ObjectDefinition implements IObjectDefinition {
5
- protected _attrs: Map<string, any>;
5
+ protected _attrs: Map<ObjectIdentifier, any>;
6
6
  protected _asynchronous: boolean;
7
- protected _autowire: boolean;
8
7
  scope: ScopeEnum;
9
8
  creator: IObjectCreator;
10
9
  id: string;
@@ -21,8 +20,6 @@ export declare class ObjectDefinition implements IObjectDefinition {
21
20
  namespace: string;
22
21
  handlerProps: HandlerProp[];
23
22
  constructor();
24
- set autowire(autowire: boolean);
25
- isAutowire(): boolean;
26
23
  set asynchronous(asynchronous: boolean);
27
24
  isAsync(): boolean;
28
25
  isSingletonScope(): boolean;
@@ -9,8 +9,6 @@ class ObjectDefinition {
9
9
  constructor() {
10
10
  this._attrs = new Map();
11
11
  this._asynchronous = false;
12
- // 对象定义默认需要自动装配
13
- this._autowire = true;
14
12
  this.scope = decorator_1.ScopeEnum.Singleton;
15
13
  this.creator = null;
16
14
  this.id = null;
@@ -27,12 +25,6 @@ class ObjectDefinition {
27
25
  this.handlerProps = [];
28
26
  this.creator = new objectCreator_1.ObjectCreator(this);
29
27
  }
30
- set autowire(autowire) {
31
- this._autowire = autowire;
32
- }
33
- isAutowire() {
34
- return this._autowire;
35
- }
36
28
  set asynchronous(asynchronous) {
37
29
  this._asynchronous = asynchronous;
38
30
  }
@@ -9,13 +9,11 @@ export declare class ObjectProperties implements IProperties {
9
9
  has(key: ObjectIdentifier): boolean;
10
10
  set(key: ObjectIdentifier, value: any): any;
11
11
  putAll(props: IProperties): void;
12
- putObject(props: Record<string, unknown>, needClone?: boolean): void;
13
12
  stringPropertyNames(): ObjectIdentifier[];
14
13
  getProperty(key: ObjectIdentifier, defaultValue?: any): any;
15
14
  addProperty(key: ObjectIdentifier, value: any): void;
16
15
  setProperty(key: ObjectIdentifier, value: any): any;
17
16
  clear(): void;
18
17
  toJSON(): Record<string, unknown>;
19
- clone(): IProperties;
20
18
  }
21
19
  //# sourceMappingURL=properties.d.ts.map
@@ -5,7 +5,7 @@ const _ = require("../common/lodashWrap");
5
5
  const util_1 = require("util");
6
6
  class ObjectProperties {
7
7
  constructor() {
8
- this.innerConfig = {};
8
+ this.innerConfig = new Map();
9
9
  }
10
10
  get size() {
11
11
  return this.keys().length;
@@ -28,7 +28,7 @@ class ObjectProperties {
28
28
  return JSON.parse(JSON.stringify(_.get(this.innerConfig, key)));
29
29
  }
30
30
  has(key) {
31
- return this.innerConfig[key] !== undefined;
31
+ return this.innerConfig.get(key) !== undefined;
32
32
  }
33
33
  set(key, value) {
34
34
  const origin = this.get(key);
@@ -38,25 +38,14 @@ class ObjectProperties {
38
38
  putAll(props) {
39
39
  const keys = props.keys();
40
40
  for (const key of keys) {
41
- if (typeof this.innerConfig[key] === 'object') {
42
- this.set(key, _.defaultsDeep(props.get(key), this.innerConfig[key]));
41
+ if (typeof this.innerConfig.get(key) === 'object') {
42
+ this.set(key, _.defaultsDeep(props.get(key), this.innerConfig.get(key)));
43
43
  }
44
44
  else {
45
45
  this.set(key, props.get(key));
46
46
  }
47
47
  }
48
48
  }
49
- putObject(props, needClone = false) {
50
- if (needClone) {
51
- const tmp = _.cloneDeep(props);
52
- _.defaultsDeep(tmp, this.innerConfig);
53
- this.innerConfig = tmp;
54
- }
55
- else {
56
- _.defaultsDeep(props, this.innerConfig);
57
- this.innerConfig = props;
58
- }
59
- }
60
49
  stringPropertyNames() {
61
50
  return this.keys();
62
51
  }
@@ -73,16 +62,11 @@ class ObjectProperties {
73
62
  return this.set(key, value);
74
63
  }
75
64
  clear() {
76
- this.innerConfig = {};
65
+ this.innerConfig.clear();
77
66
  }
78
67
  toJSON() {
79
68
  return JSON.parse(JSON.stringify(this.innerConfig));
80
69
  }
81
- clone() {
82
- const cfg = new ObjectProperties();
83
- cfg.putObject(this.toJSON());
84
- return cfg;
85
- }
86
70
  }
87
71
  exports.ObjectProperties = ObjectProperties;
88
72
  //# sourceMappingURL=properties.js.map
@@ -15,19 +15,19 @@ class Resource {
15
15
  }
16
16
  getPath() {
17
17
  if (this._baseDir) {
18
- return path_1.resolve(this._baseDir, this._path);
18
+ return (0, path_1.resolve)(this._baseDir, this._path);
19
19
  }
20
20
  return this._path;
21
21
  }
22
22
  exists() {
23
- return fs_1.existsSync(this.getPath());
23
+ return (0, fs_1.existsSync)(this.getPath());
24
24
  }
25
25
  isFile() {
26
- const stats = fs_1.lstatSync(this.getPath());
26
+ const stats = (0, fs_1.lstatSync)(this.getPath());
27
27
  return stats.isFile();
28
28
  }
29
29
  isDir() {
30
- const stats = fs_1.lstatSync(this.getPath());
30
+ const stats = (0, fs_1.lstatSync)(this.getPath());
31
31
  return stats.isDirectory();
32
32
  }
33
33
  isURL() {
@@ -46,16 +46,16 @@ class Resource {
46
46
  */
47
47
  createRelative(path) {
48
48
  if (this.isFile()) {
49
- path = path_1.join(path_1.dirname(this.getPath()), path);
49
+ path = (0, path_1.join)((0, path_1.dirname)(this.getPath()), path);
50
50
  }
51
51
  else {
52
- path = path_1.join(this.getPath(), path);
52
+ path = (0, path_1.join)(this.getPath(), path);
53
53
  }
54
54
  return new Resource(this._baseDir, path);
55
55
  }
56
56
  getSubResources() {
57
57
  if (this.isDir()) {
58
- const files = fs_1.readdirSync(this.getPath());
58
+ const files = (0, fs_1.readdirSync)(this.getPath());
59
59
  const arr = files.map(file => {
60
60
  return new Resource(this.getPath(), file);
61
61
  });
@@ -70,7 +70,7 @@ class Resource {
70
70
  if (!this.isFile()) {
71
71
  throw new Error(`${this.getPath()} is not a file!`);
72
72
  }
73
- return fs_1.readFileSync(this.getPath());
73
+ return (0, fs_1.readFileSync)(this.getPath());
74
74
  }
75
75
  getContentAsJSON() {
76
76
  if (!this.exists()) {
@@ -79,8 +79,8 @@ class Resource {
79
79
  if (!this.isFile()) {
80
80
  throw new Error(`${this.getPath()} is not a file!`);
81
81
  }
82
- if (path_1.parse(this.getPath()).ext === '.json') {
83
- const buf = fs_1.readFileSync(this.getPath());
82
+ if ((0, path_1.parse)(this.getPath()).ext === '.json') {
83
+ const buf = (0, fs_1.readFileSync)(this.getPath());
84
84
  try {
85
85
  return JSON.parse(buf.toString());
86
86
  // eslint-disable-next-line no-empty
@@ -92,20 +92,20 @@ class Resource {
92
92
  }
93
93
  get name() {
94
94
  if (this.exists()) {
95
- return path_1.parse(this.getPath()).name;
95
+ return (0, path_1.parse)(this.getPath()).name;
96
96
  }
97
97
  return null;
98
98
  }
99
99
  get contentLength() {
100
100
  if (this.exists()) {
101
- const buf = fs_1.readFileSync(this.getPath());
101
+ const buf = (0, fs_1.readFileSync)(this.getPath());
102
102
  return buf.length;
103
103
  }
104
104
  return 0;
105
105
  }
106
106
  get lastModified() {
107
107
  if (this.exists()) {
108
- const stats = fs_1.lstatSync(this.getPath());
108
+ const stats = (0, fs_1.lstatSync)(this.getPath());
109
109
  return stats.mtime.getTime();
110
110
  }
111
111
  return 0;
@@ -127,7 +127,7 @@ export interface IPipelineHandler {
127
127
  */
128
128
  waterfall<T>(opts: IPipelineOptions): Promise<IPipelineResult<T>>;
129
129
  }
130
- import { IApplicationContext } from '../interface';
130
+ import { IMidwayContainer } from '../interface';
131
131
  export declare class PipelineContext implements IPipelineContext {
132
132
  args: any;
133
133
  info: {
@@ -145,7 +145,7 @@ export declare class PipelineContext implements IPipelineContext {
145
145
  export declare class PipelineHandler implements IPipelineHandler {
146
146
  private applicationContext;
147
147
  private valves;
148
- constructor(applicationContext: IApplicationContext, valves?: string[]);
148
+ constructor(applicationContext: IMidwayContainer, valves?: string[]);
149
149
  parallel<T>(opts: IPipelineOptions): Promise<IPipelineResult<T>>;
150
150
  concat<T>(opts: IPipelineOptions): Promise<IPipelineResult<T>>;
151
151
  series<T>(opts: IPipelineOptions): Promise<IPipelineResult<T>>;
@@ -155,5 +155,5 @@ export declare class PipelineHandler implements IPipelineHandler {
155
155
  private prepareParallelValves;
156
156
  private packResult;
157
157
  }
158
- export declare function pipelineFactory(applicationContext: IApplicationContext, valves?: string[]): PipelineHandler;
158
+ export declare function pipelineFactory(applicationContext: IMidwayContainer, valves?: string[]): PipelineHandler;
159
159
  //# sourceMappingURL=pipeline.d.ts.map
@@ -209,7 +209,7 @@ function pipelineFactory(applicationContext, valves) {
209
209
  return new PipelineHandler(applicationContext, valves);
210
210
  }
211
211
  exports.pipelineFactory = pipelineFactory;
212
- providerWrapper_1.providerWrapper([
212
+ (0, providerWrapper_1.providerWrapper)([
213
213
  {
214
214
  id: decorator_1.PIPELINE_IDENTIFIER,
215
215
  provider: pipelineFactory,
@@ -3,8 +3,10 @@ import { InjectionConfigurationOptions } from '@midwayjs/decorator';
3
3
  export declare class FunctionalConfiguration {
4
4
  private readyHandler;
5
5
  private stopHandler;
6
+ private configLoadHandler;
6
7
  private options;
7
8
  constructor(options: InjectionConfigurationOptions);
9
+ onConfigLoad(configLoadHandler: ((container: IMidwayContainer, app: IMidwayApplication) => any) | IMidwayContainer, app?: IMidwayApplication): this;
8
10
  onReady(readyHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): this;
9
11
  onStop(stopHandler: ((container: IMidwayContainer, app: IMidwayApplication) => void) | IMidwayContainer, app?: IMidwayApplication): this;
10
12
  getConfigurationOptions(): InjectionConfigurationOptions;
@@ -6,6 +6,16 @@ class FunctionalConfiguration {
6
6
  this.options = options;
7
7
  this.readyHandler = () => { };
8
8
  this.stopHandler = () => { };
9
+ this.configLoadHandler = () => { };
10
+ }
11
+ onConfigLoad(configLoadHandler, app) {
12
+ if (typeof configLoadHandler === 'function') {
13
+ this.configLoadHandler = configLoadHandler;
14
+ }
15
+ else {
16
+ this.configLoadHandler(configLoadHandler, app);
17
+ }
18
+ return this;
9
19
  }
10
20
  onReady(readyHandler, app) {
11
21
  if (typeof readyHandler === 'function') {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { ObjectIdentifier, ObjectDefinitionOptions, IManagedInstance, ScopeEnum, MidwayFrameworkType, saveClassMetadata, attachClassMetadata, getClassMetadata, savePropertyDataToClass, attachPropertyDataToClass, getPropertyDataFromClass, listPropertyDataFromClass, savePropertyMetadata, attachPropertyMetadata, getPropertyMetadata, savePreloadModule, listPreloadModule, saveModule, listModule, resetModule, clearAllModule, getParamNames, getProviderId, getObjectDefinition, classNamed, generateProvideId, } from '@midwayjs/decorator';
1
+ export { MidwayFrameworkType } from '@midwayjs/decorator';
2
2
  export * from './interface';
3
3
  export * from './context/container';
4
4
  export { MidwayRequestContainer } from './context/requestContainer';
package/dist/index.js CHANGED
@@ -10,31 +10,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.createConfiguration = exports.classToPlain = exports.plainToClass = exports.delegateTargetPrototypeMethod = exports.safeRequire = exports.safelyGet = exports.BaseFramework = exports.MidwayRequestContainer = exports.generateProvideId = exports.classNamed = exports.getObjectDefinition = exports.getProviderId = exports.getParamNames = exports.clearAllModule = exports.resetModule = exports.listModule = exports.saveModule = exports.listPreloadModule = exports.savePreloadModule = exports.getPropertyMetadata = exports.attachPropertyMetadata = exports.savePropertyMetadata = exports.listPropertyDataFromClass = exports.getPropertyDataFromClass = exports.attachPropertyDataToClass = exports.savePropertyDataToClass = exports.getClassMetadata = exports.attachClassMetadata = exports.saveClassMetadata = exports.MidwayFrameworkType = exports.ScopeEnum = void 0;
13
+ exports.MidwayInformationService = exports.MidwayEnvironmentService = exports.MidwayConfigService = exports.createConfiguration = exports.classToPlain = exports.plainToClass = exports.delegateTargetPrototypeMethod = exports.safeRequire = exports.safelyGet = exports.BaseFramework = exports.MidwayRequestContainer = exports.MidwayFrameworkType = void 0;
14
14
  var decorator_1 = require("@midwayjs/decorator");
15
- Object.defineProperty(exports, "ScopeEnum", { enumerable: true, get: function () { return decorator_1.ScopeEnum; } });
16
15
  Object.defineProperty(exports, "MidwayFrameworkType", { enumerable: true, get: function () { return decorator_1.MidwayFrameworkType; } });
17
- Object.defineProperty(exports, "saveClassMetadata", { enumerable: true, get: function () { return decorator_1.saveClassMetadata; } });
18
- Object.defineProperty(exports, "attachClassMetadata", { enumerable: true, get: function () { return decorator_1.attachClassMetadata; } });
19
- Object.defineProperty(exports, "getClassMetadata", { enumerable: true, get: function () { return decorator_1.getClassMetadata; } });
20
- Object.defineProperty(exports, "savePropertyDataToClass", { enumerable: true, get: function () { return decorator_1.savePropertyDataToClass; } });
21
- Object.defineProperty(exports, "attachPropertyDataToClass", { enumerable: true, get: function () { return decorator_1.attachPropertyDataToClass; } });
22
- Object.defineProperty(exports, "getPropertyDataFromClass", { enumerable: true, get: function () { return decorator_1.getPropertyDataFromClass; } });
23
- Object.defineProperty(exports, "listPropertyDataFromClass", { enumerable: true, get: function () { return decorator_1.listPropertyDataFromClass; } });
24
- Object.defineProperty(exports, "savePropertyMetadata", { enumerable: true, get: function () { return decorator_1.savePropertyMetadata; } });
25
- Object.defineProperty(exports, "attachPropertyMetadata", { enumerable: true, get: function () { return decorator_1.attachPropertyMetadata; } });
26
- Object.defineProperty(exports, "getPropertyMetadata", { enumerable: true, get: function () { return decorator_1.getPropertyMetadata; } });
27
- Object.defineProperty(exports, "savePreloadModule", { enumerable: true, get: function () { return decorator_1.savePreloadModule; } });
28
- Object.defineProperty(exports, "listPreloadModule", { enumerable: true, get: function () { return decorator_1.listPreloadModule; } });
29
- Object.defineProperty(exports, "saveModule", { enumerable: true, get: function () { return decorator_1.saveModule; } });
30
- Object.defineProperty(exports, "listModule", { enumerable: true, get: function () { return decorator_1.listModule; } });
31
- Object.defineProperty(exports, "resetModule", { enumerable: true, get: function () { return decorator_1.resetModule; } });
32
- Object.defineProperty(exports, "clearAllModule", { enumerable: true, get: function () { return decorator_1.clearAllModule; } });
33
- Object.defineProperty(exports, "getParamNames", { enumerable: true, get: function () { return decorator_1.getParamNames; } });
34
- Object.defineProperty(exports, "getProviderId", { enumerable: true, get: function () { return decorator_1.getProviderId; } });
35
- Object.defineProperty(exports, "getObjectDefinition", { enumerable: true, get: function () { return decorator_1.getObjectDefinition; } });
36
- Object.defineProperty(exports, "classNamed", { enumerable: true, get: function () { return decorator_1.classNamed; } });
37
- Object.defineProperty(exports, "generateProvideId", { enumerable: true, get: function () { return decorator_1.generateProvideId; } });
38
16
  __exportStar(require("./interface"), exports);
39
17
  __exportStar(require("./context/container"), exports);
40
18
  var requestContainer_1 = require("./context/requestContainer");
@@ -5,6 +5,7 @@ import { ILogger, LoggerOptions } from '@midwayjs/logger';
5
5
  * 生命周期定义
6
6
  */
7
7
  export interface ILifeCycle {
8
+ onConfigLoad?(container: IMidwayContainer, app?: IMidwayApplication): Promise<any>;
8
9
  onReady(container: IMidwayContainer, app?: IMidwayApplication): Promise<void>;
9
10
  onStop?(container: IMidwayContainer, app?: IMidwayApplication): Promise<void>;
10
11
  }
@@ -21,7 +22,6 @@ export interface IMessageSource {
21
22
  */
22
23
  export interface IObjectFactory {
23
24
  registry: IObjectDefinitionRegistry;
24
- isAsync(identifier: ObjectIdentifier): boolean;
25
25
  get<T>(identifier: new () => T, args?: any): T;
26
26
  get<T>(identifier: ObjectIdentifier, args?: any): T;
27
27
  getAsync<T>(identifier: new () => T, args?: any): Promise<T>;
@@ -44,7 +44,6 @@ export interface IObjectDefinition {
44
44
  dependsOn: ObjectIdentifier[];
45
45
  constructorArgs: IManagedInstance[];
46
46
  properties: IProperties;
47
- isAutowire(): boolean;
48
47
  isAsync(): boolean;
49
48
  isSingletonScope(): boolean;
50
49
  isRequestScope(): boolean;
@@ -64,13 +63,12 @@ export interface HandlerProp {
64
63
  */
65
64
  export interface IObjectDefinitionMetadata {
66
65
  namespace?: string;
67
- id: string;
66
+ id: ObjectIdentifier;
68
67
  name: string;
69
68
  initMethod: string;
70
69
  destroyMethod: string;
71
70
  constructMethod: string;
72
71
  scope: ScopeEnum;
73
- autowire: boolean;
74
72
  srcPath: string;
75
73
  path: any;
76
74
  export: string;
@@ -87,13 +85,14 @@ export interface IObjectDefinitionMetadata {
87
85
  }
88
86
  export interface FrameworkDecoratorMetadata {
89
87
  key: string;
88
+ targetKey: string;
90
89
  propertyName: string;
91
90
  meta: any;
92
91
  }
93
92
  export interface IObjectCreator {
94
93
  load(): any;
95
- doConstruct(Clzz: any, args?: any, context?: IApplicationContext): any;
96
- doConstructAsync(Clzz: any, args?: any, context?: IApplicationContext): Promise<any>;
94
+ doConstruct(Clzz: any, args?: any, context?: IMidwayContainer): any;
95
+ doConstructAsync(Clzz: any, args?: any, context?: IMidwayContainer): Promise<any>;
97
96
  doInit(obj: any): void;
98
97
  doInitAsync(obj: any): Promise<void>;
99
98
  doDestroy(obj: any): void;
@@ -108,7 +107,6 @@ export interface IObjectDefinitionRegistry {
108
107
  registerDefinition(identifier: ObjectIdentifier, definition: IObjectDefinition): any;
109
108
  getSingletonDefinitionIds(): ObjectIdentifier[];
110
109
  getDefinition(identifier: ObjectIdentifier): IObjectDefinition;
111
- getDefinitionByPath(path: string): IObjectDefinition;
112
110
  getDefinitionByName(name: string): IObjectDefinition[];
113
111
  removeDefinition(identifier: ObjectIdentifier): void;
114
112
  hasDefinition(identifier: ObjectIdentifier): boolean;
@@ -116,6 +114,8 @@ export interface IObjectDefinitionRegistry {
116
114
  hasObject(identifier: ObjectIdentifier): boolean;
117
115
  registerObject(identifier: ObjectIdentifier, target: any): any;
118
116
  getObject(identifier: ObjectIdentifier): any;
117
+ getIdentifierRelation(): IIdentifierRelationShip;
118
+ setIdentifierRelation(identifierRelation: IIdentifierRelationShip): any;
119
119
  }
120
120
  /**
121
121
  * 属性配置抽象
@@ -134,7 +134,6 @@ export interface IProperties {
134
134
  addProperty(key: ObjectIdentifier, value: any): void;
135
135
  setProperty(key: ObjectIdentifier, value: any): any;
136
136
  clear(): void;
137
- clone(): IProperties;
138
137
  }
139
138
  /**
140
139
  * 资源配置抽象
@@ -155,19 +154,6 @@ export interface IResource {
155
154
  getSubResources(): IResource[];
156
155
  createRelative(path: string): IResource;
157
156
  }
158
- /**
159
- * IoC上下文抽象
160
- */
161
- export interface IApplicationContext extends IObjectFactory {
162
- disableConflictCheck: boolean;
163
- baseDir: string;
164
- parent: IApplicationContext;
165
- props: IProperties;
166
- dependencyMap: Map<string, ObjectDependencyTree>;
167
- ready(): any;
168
- stop(): Promise<void>;
169
- registerObject(identifier: ObjectIdentifier, target: any): any;
170
- }
171
157
  /**
172
158
  * 解析内部管理的属性、json、ref等实例的解析器
173
159
  * 同时创建这些对象的实际使用的对象
@@ -213,7 +199,18 @@ export interface IResolverHandler {
213
199
  hasHandler(key: string): boolean;
214
200
  getHandler(key: string): any;
215
201
  }
216
- export interface IMidwayContainer extends IApplicationContext {
202
+ export interface IIdentifierRelationShip {
203
+ saveClassRelation(module: any, namespace?: string): any;
204
+ saveFunctionRelation(ObjectIdentifier: any, uuid: any): any;
205
+ hasRelation(id: ObjectIdentifier): boolean;
206
+ getRelation(id: ObjectIdentifier): string;
207
+ }
208
+ export interface IMidwayContainer extends IObjectFactory {
209
+ parent: IMidwayContainer;
210
+ identifierMapping: IIdentifierRelationShip;
211
+ ready(): any;
212
+ stop(): Promise<void>;
213
+ registerObject(identifier: ObjectIdentifier, target: any): any;
217
214
  load(module?: any): any;
218
215
  bind<T>(target: T, options?: ObjectDefinitionOptions): void;
219
216
  bind<T>(identifier: ObjectIdentifier, target: T, options?: ObjectDefinitionOptions): void;
@@ -222,9 +219,6 @@ export interface IMidwayContainer extends IApplicationContext {
222
219
  setFileDetector(fileDetector: IFileDetector): any;
223
220
  registerDataHandler(handlerType: string, handler: (...args: any[]) => any): any;
224
221
  createChild(): IMidwayContainer;
225
- /**
226
- * 默认不添加创建的 configuration 到 configurations 数组中
227
- */
228
222
  getConfigService(): IConfigService;
229
223
  getEnvironmentService(): IEnvironmentService;
230
224
  getInformationService(): IInformationService;
@@ -245,10 +239,10 @@ export interface IMidwayContainer extends IApplicationContext {
245
239
  getAttr<T>(key: string): T;
246
240
  }
247
241
  export interface IFileDetector {
248
- run(container: IApplicationContext): any;
242
+ run(container: IMidwayContainer): any;
249
243
  }
250
244
  export interface IConfigService {
251
- add(configFilePaths: string[]): any;
245
+ add(configFilePaths: any[]): any;
252
246
  addObject(obj: object): any;
253
247
  load(): any;
254
248
  getConfiguration(configKey?: string): any;
@@ -323,11 +317,6 @@ export interface IMidwayBaseApplication<T extends IMidwayContext = IMidwayContex
323
317
  getAttr<T>(key: string): T;
324
318
  }
325
319
  export declare type IMidwayApplication<T extends IMidwayContext = IMidwayContext, FrameworkApplication = unknown> = IMidwayBaseApplication<T> & FrameworkApplication;
326
- /**
327
- * @deprecated
328
- */
329
- export interface IMidwayCoreApplication extends IMidwayApplication {
330
- }
331
320
  export interface IMidwayBootstrapOptions {
332
321
  logger?: ILogger | boolean;
333
322
  baseDir?: string;
package/dist/logger.js CHANGED
@@ -6,15 +6,15 @@ const interface_1 = require("./interface");
6
6
  const util_1 = require("./util");
7
7
  const path_1 = require("path");
8
8
  const createMidwayLogger = (framework, name, options = {}) => {
9
- const isDevelopmentEnv = util_1.isDevelopmentEnvironment(framework.getCurrentEnvironment());
9
+ const isDevelopmentEnv = (0, util_1.isDevelopmentEnvironment)(framework.getCurrentEnvironment());
10
10
  const loggerOptions = {
11
- dir: path_1.join(framework.getApplicationContext().getInformationService().getRoot(), 'logs', framework.getProjectName()),
11
+ dir: (0, path_1.join)(framework.getApplicationContext().getInformationService().getRoot(), 'logs', framework.getProjectName()),
12
12
  level: isDevelopmentEnv ? 'info' : 'warn',
13
13
  };
14
14
  if (process.env[interface_1.MIDWAY_LOGGER_WRITEABLE_DIR]) {
15
- loggerOptions.dir = path_1.join(process.env[interface_1.MIDWAY_LOGGER_WRITEABLE_DIR], 'logs', framework.getProjectName());
15
+ loggerOptions.dir = (0, path_1.join)(process.env[interface_1.MIDWAY_LOGGER_WRITEABLE_DIR], 'logs', framework.getProjectName());
16
16
  }
17
- return logger_1.createLogger(name, Object.assign({}, loggerOptions, options));
17
+ return (0, logger_1.createLogger)(name, Object.assign({}, loggerOptions, options));
18
18
  };
19
19
  exports.createMidwayLogger = createMidwayLogger;
20
20
  //# sourceMappingURL=logger.js.map
@@ -17,11 +17,11 @@ class MidwayAspectService {
17
17
  */
18
18
  async loadAspect() {
19
19
  // for aop implementation
20
- const aspectModules = decorator_1.listModule(decorator_1.ASPECT_KEY);
20
+ const aspectModules = (0, decorator_1.listModule)(decorator_1.ASPECT_KEY);
21
21
  // sort for aspect target
22
22
  let aspectDataList = [];
23
23
  for (const module of aspectModules) {
24
- const data = decorator_1.getClassMetadata(decorator_1.ASPECT_KEY, module);
24
+ const data = (0, decorator_1.getClassMetadata)(decorator_1.ASPECT_KEY, module);
25
25
  aspectDataList = aspectDataList.concat(data.map(el => {
26
26
  el.aspectModule = module;
27
27
  return el;
@@ -81,7 +81,7 @@ class MidwayAspectService {
81
81
  }
82
82
  // 把拦截器本身加到数组中
83
83
  const methodAspectCollection = mappingMap.get(name);
84
- if (decorator_1.isAsyncFunction(descriptor.value)) {
84
+ if ((0, decorator_1.isAsyncFunction)(descriptor.value)) {
85
85
  debugLogger(`aspect [#${module.name}:${name}], isAsync=true, aspect class=[${aspectIns.constructor.name}]`);
86
86
  const fn = (ins, originMethod) => {
87
87
  return async (...args) => {
@@ -151,7 +151,12 @@ class MidwayAspectService {
151
151
  }
152
152
  const resultTemp = (_b = aspectIns.afterReturn) === null || _b === void 0 ? void 0 : _b.call(aspectIns, joinPoint, result);
153
153
  result = typeof resultTemp === 'undefined' ? result : resultTemp;
154
- return result;
154
+ if (result && (0, decorator_1.isClass)(result.constructor)) {
155
+ return this.wrapperAspectToInstance(ins);
156
+ }
157
+ else {
158
+ return result;
159
+ }
155
160
  }
156
161
  catch (err) {
157
162
  error = err;
@@ -7,13 +7,13 @@ export declare class MidwayConfigService implements IConfigService {
7
7
  isReady: boolean;
8
8
  externalObject: Record<string, unknown>[];
9
9
  constructor(container: any);
10
- add(configFilePaths: string[]): void;
10
+ add(configFilePaths: any[]): void;
11
11
  addObject(obj: Record<string, unknown>): void;
12
- getEnvSet(env: any): Set<string>;
12
+ getEnvSet(env: any): Set<any>;
13
13
  getConfigEnv(configFilePath: any): string;
14
- load(): void;
14
+ load(): Promise<void>;
15
15
  getConfiguration(configKey?: string): any;
16
- loadConfig(configFilename: any, target?: any): Record<string, unknown>;
16
+ loadConfig(configFilename: any, target?: any): Promise<Record<string, unknown>>;
17
17
  clearAllConfig(): void;
18
18
  }
19
19
  //# sourceMappingURL=configService.d.ts.map