@midwayjs/core 3.8.0 → 3.10.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.
Files changed (101) hide show
  1. package/dist/baseFramework.d.ts +5 -2
  2. package/dist/baseFramework.js +17 -0
  3. package/dist/common/applicationManager.d.ts +1 -2
  4. package/dist/common/applicationManager.js +2 -1
  5. package/dist/common/dataSourceManager.d.ts +1 -0
  6. package/dist/common/dataSourceManager.js +14 -12
  7. package/dist/common/loggerFactory.d.ts +8 -0
  8. package/dist/common/loggerFactory.js +7 -0
  9. package/dist/common/serviceFactory.d.ts +3 -2
  10. package/dist/common/webGenerator.js +2 -1
  11. package/dist/config/config.default.js +2 -1
  12. package/dist/constants.d.ts +1 -11
  13. package/dist/constants.js +2 -12
  14. package/dist/context/container.d.ts +1 -2
  15. package/dist/context/container.js +3 -3
  16. package/dist/context/definitionRegistry.d.ts +1 -5
  17. package/dist/context/managedResolverFactory.d.ts +1 -2
  18. package/dist/context/managedResolverFactory.js +2 -3
  19. package/dist/context/providerWrapper.d.ts +1 -2
  20. package/dist/decorator/common/aspect.d.ts +0 -18
  21. package/dist/decorator/common/aspect.js +2 -1
  22. package/dist/decorator/common/filter.d.ts +1 -1
  23. package/dist/decorator/common/filter.js +1 -1
  24. package/dist/decorator/common/framework.d.ts +1 -1
  25. package/dist/decorator/common/framework.js +2 -1
  26. package/dist/decorator/common/guard.js +1 -1
  27. package/dist/decorator/common/inject.d.ts +2 -1
  28. package/dist/decorator/common/inject.js +9 -1
  29. package/dist/decorator/common/middleware.js +2 -1
  30. package/dist/decorator/common/mock.d.ts +2 -0
  31. package/dist/decorator/common/mock.js +14 -0
  32. package/dist/decorator/common/objectDef.d.ts +2 -1
  33. package/dist/decorator/common/objectDef.js +10 -1
  34. package/dist/decorator/common/pipe.d.ts +2 -0
  35. package/dist/decorator/common/pipe.js +13 -0
  36. package/dist/decorator/common/pipeline.d.ts +1 -1
  37. package/dist/decorator/common/provide.d.ts +1 -1
  38. package/dist/decorator/constant.d.ts +2 -0
  39. package/dist/decorator/constant.js +4 -2
  40. package/dist/decorator/decoratorManager.d.ts +6 -10
  41. package/dist/decorator/decoratorManager.js +20 -8
  42. package/dist/decorator/faas/serverlessTrigger.d.ts +3 -1
  43. package/dist/decorator/faas/serverlessTrigger.js +3 -2
  44. package/dist/decorator/index.d.ts +2 -1
  45. package/dist/decorator/index.js +2 -1
  46. package/dist/decorator/microservice/consumer.d.ts +1 -1
  47. package/dist/decorator/microservice/consumer.js +2 -1
  48. package/dist/decorator/microservice/kafkaListener.d.ts +3 -3
  49. package/dist/decorator/microservice/provider.d.ts +1 -1
  50. package/dist/decorator/microservice/provider.js +2 -1
  51. package/dist/decorator/rpc/hsf.d.ts +1 -0
  52. package/dist/decorator/rpc/hsf.js +3 -1
  53. package/dist/decorator/task/schedule.js +2 -1
  54. package/dist/decorator/web/controller.d.ts +1 -1
  55. package/dist/decorator/web/controller.js +2 -1
  56. package/dist/decorator/web/requestMapping.d.ts +1 -4
  57. package/dist/decorator/ws/webSocketController.d.ts +1 -1
  58. package/dist/decorator/ws/webSocketController.js +2 -1
  59. package/dist/decorator/ws/webSocketEvent.d.ts +1 -1
  60. package/dist/definitions/functionDefinition.d.ts +1 -2
  61. package/dist/definitions/functionDefinition.js +4 -4
  62. package/dist/definitions/objectDefinition.d.ts +1 -2
  63. package/dist/definitions/objectDefinition.js +4 -4
  64. package/dist/definitions/properties.d.ts +1 -2
  65. package/dist/error/base.d.ts +2 -2
  66. package/dist/error/framework.d.ts +1 -1
  67. package/dist/error/framework.js +5 -5
  68. package/dist/index.d.ts +1 -0
  69. package/dist/index.js +1 -0
  70. package/dist/interface.d.ts +344 -25
  71. package/dist/interface.js +64 -1
  72. package/dist/service/aspectService.d.ts +1 -2
  73. package/dist/service/aspectService.js +2 -1
  74. package/dist/service/configService.js +2 -1
  75. package/dist/service/decoratorService.d.ts +3 -1
  76. package/dist/service/decoratorService.js +64 -12
  77. package/dist/service/environmentService.js +2 -1
  78. package/dist/service/frameworkService.d.ts +1 -2
  79. package/dist/service/frameworkService.js +21 -1
  80. package/dist/service/informationService.js +2 -1
  81. package/dist/service/lifeCycleService.d.ts +2 -0
  82. package/dist/service/lifeCycleService.js +14 -4
  83. package/dist/service/loggerService.d.ts +11 -7
  84. package/dist/service/loggerService.js +31 -9
  85. package/dist/service/middlewareService.js +2 -1
  86. package/dist/service/mockService.d.ts +9 -1
  87. package/dist/service/mockService.js +43 -1
  88. package/dist/service/pipelineService.d.ts +2 -3
  89. package/dist/service/slsFunctionService.d.ts +1 -1
  90. package/dist/service/slsFunctionService.js +3 -2
  91. package/dist/service/webRouterService.d.ts +1 -1
  92. package/dist/service/webRouterService.js +3 -2
  93. package/dist/setup.js +6 -2
  94. package/dist/util/camelCase.js +8 -5
  95. package/dist/util/httpclient.d.ts +2 -2
  96. package/dist/util/pathToRegexp.d.ts +5 -5
  97. package/dist/util/webRouterParam.d.ts +2 -4
  98. package/dist/util/webRouterParam.js +5 -27
  99. package/package.json +5 -6
  100. package/dist/decorator/interface.d.ts +0 -242
  101. package/dist/decorator/interface.js +0 -66
@@ -25,6 +25,7 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
25
25
  protected composeMiddleware: any;
26
26
  protected bootstrapOptions: IMidwayBootstrapOptions;
27
27
  protected asyncContextManager: AsyncContextManager;
28
+ private namespace;
28
29
  loggerService: MidwayLoggerService;
29
30
  environmentService: MidwayEnvironmentService;
30
31
  configService: MidwayConfigService;
@@ -77,9 +78,9 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
77
78
  */
78
79
  protected afterContainerReady(options: Partial<IMidwayBootstrapOptions>): Promise<void>;
79
80
  applyMiddleware<R, N>(lastMiddleware?: CommonMiddlewareUnion<CTX, R, N>): Promise<MiddlewareRespond<CTX, R, N>>;
80
- getLogger(name?: string): ILogger;
81
+ getLogger(name?: string): any;
81
82
  getCoreLogger(): ILogger;
82
- createLogger(name: string, option?: LoggerOptions): ILogger;
83
+ createLogger(name: string, option?: LoggerOptions): any;
83
84
  getProjectName(): string;
84
85
  getFrameworkName(): string;
85
86
  useMiddleware(middleware: CommonMiddlewareUnion<CTX, ResOrNext, Next>): void;
@@ -90,5 +91,7 @@ export declare abstract class BaseFramework<APP extends IMidwayApplication<CTX>,
90
91
  protected createMiddlewareManager(): ContextMiddlewareManager<CTX, ResOrNext, Next>;
91
92
  protected createFilterManager(): FilterManager<CTX, ResOrNext, Next>;
92
93
  protected createGuardManager(): GuardManager<CTX>;
94
+ setNamespace(namespace: string): void;
95
+ getNamespace(): string;
93
96
  }
94
97
  //# sourceMappingURL=baseFramework.d.ts.map
@@ -61,6 +61,7 @@ class BaseFramework {
61
61
  await this.applicationInitialize(options);
62
62
  await this.containerReady(options);
63
63
  await this.afterContainerReady(options);
64
+ await this.mockService.runSimulatorAppSetup(this.app);
64
65
  }
65
66
  /**
66
67
  * @deprecated
@@ -124,6 +125,7 @@ class BaseFramework {
124
125
  }
125
126
  }
126
127
  async stop() {
128
+ await this.mockService.runSimulatorAppTearDown(this.app);
127
129
  await this.beforeStop();
128
130
  }
129
131
  getAppDir() {
@@ -218,6 +220,9 @@ class BaseFramework {
218
220
  useGuard: (guard) => {
219
221
  return this.useGuard(guard);
220
222
  },
223
+ getNamespace: () => {
224
+ return this.getNamespace();
225
+ },
221
226
  };
222
227
  for (const method of whiteList) {
223
228
  delete defaultApplicationProperties[method];
@@ -261,6 +266,8 @@ class BaseFramework {
261
266
  const rootContext = asyncContextManager_1.ASYNC_ROOT_CONTEXT.setValue(constants_1.ASYNC_CONTEXT_KEY, ctx);
262
267
  const contextManager = this.applicationContext.get(constants_1.ASYNC_CONTEXT_MANAGER_KEY);
263
268
  return await contextManager.with(rootContext, async () => {
269
+ // run simulator context setup
270
+ await this.mockService.runSimulatorContextSetup(ctx, this.app);
264
271
  this.mockService.applyContextMocks(this.app, ctx);
265
272
  let returnResult = undefined;
266
273
  try {
@@ -270,6 +277,10 @@ class BaseFramework {
270
277
  catch (err) {
271
278
  returnResult = await this.filterManager.runErrorFilter(err, ctx);
272
279
  }
280
+ finally {
281
+ // run simulator context teardown
282
+ await this.mockService.runSimulatorContextTearDown(ctx, this.app);
283
+ }
273
284
  if (returnResult.error) {
274
285
  throw returnResult.error;
275
286
  }
@@ -328,6 +339,12 @@ class BaseFramework {
328
339
  createGuardManager() {
329
340
  return new guardManager_1.GuardManager();
330
341
  }
342
+ setNamespace(namespace) {
343
+ this.namespace = namespace;
344
+ }
345
+ getNamespace() {
346
+ return this.namespace;
347
+ }
331
348
  }
332
349
  __decorate([
333
350
  (0, decorator_1.Inject)(),
@@ -1,5 +1,4 @@
1
- import { IMidwayApplication, IMidwayFramework } from '../interface';
2
- import { FrameworkType } from '../decorator';
1
+ import { IMidwayApplication, IMidwayFramework, FrameworkType } from '../interface';
3
2
  export declare class MidwayApplicationManager {
4
3
  private globalFrameworkMap;
5
4
  private globalFrameworkTypeMap;
@@ -7,6 +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 interface_1 = require("../interface");
10
11
  const decorator_1 = require("../decorator");
11
12
  let MidwayApplicationManager = class MidwayApplicationManager {
12
13
  constructor() {
@@ -66,7 +67,7 @@ let MidwayApplicationManager = class MidwayApplicationManager {
66
67
  };
67
68
  MidwayApplicationManager = __decorate([
68
69
  (0, decorator_1.Provide)(),
69
- (0, decorator_1.Scope)(decorator_1.ScopeEnum.Singleton)
70
+ (0, decorator_1.Scope)(interface_1.ScopeEnum.Singleton)
70
71
  ], MidwayApplicationManager);
71
72
  exports.MidwayApplicationManager = MidwayApplicationManager;
72
73
  //# sourceMappingURL=applicationManager.js.map
@@ -33,6 +33,7 @@ export declare abstract class DataSourceManager<T> {
33
33
  stop(): Promise<void>;
34
34
  getDefaultDataSourceName(): string;
35
35
  }
36
+ export declare function formatGlobString(globString: string): string[];
36
37
  export declare function globModels(globString: string, appDir: string): any[];
37
38
  export interface CreateDataSourceInstanceOptions {
38
39
  /**
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.globModels = exports.DataSourceManager = void 0;
3
+ exports.globModels = exports.formatGlobString = exports.DataSourceManager = void 0;
4
4
  /**
5
5
  * 数据源管理器实现
6
6
  */
@@ -130,25 +130,27 @@ class DataSourceManager {
130
130
  }
131
131
  }
132
132
  exports.DataSourceManager = DataSourceManager;
133
- function globModels(globString, appDir) {
134
- let cwd;
133
+ function formatGlobString(globString) {
135
134
  let pattern;
136
- if (globString.endsWith('**')) {
137
- // 去掉尾部的 **,因为 glob 会自动添加
138
- globString = globString.slice(0, -2);
135
+ if (!/^\*/.test(globString)) {
136
+ globString = '/' + globString;
139
137
  }
140
- if (/\*/.test(globString)) {
141
- cwd = appDir;
142
- pattern = [...constants_1.DEFAULT_PATTERN.map(p => (0, path_1.join)(globString, p))];
138
+ const parsePattern = (0, path_1.parse)(globString);
139
+ if (parsePattern.base && (/\*/.test(parsePattern.base) || parsePattern.ext)) {
140
+ pattern = [globString];
143
141
  }
144
142
  else {
145
- pattern = [...constants_1.DEFAULT_PATTERN];
146
- cwd = (0, path_1.join)(appDir, globString);
143
+ pattern = [...constants_1.DEFAULT_PATTERN.map(p => (0, path_1.join)(globString, p))];
147
144
  }
145
+ return pattern;
146
+ }
147
+ exports.formatGlobString = formatGlobString;
148
+ function globModels(globString, appDir) {
149
+ const pattern = formatGlobString(globString);
148
150
  const models = [];
149
151
  // string will be glob file
150
152
  const files = (0, glob_1.run)(pattern, {
151
- cwd,
153
+ cwd: appDir,
152
154
  ignore: constants_1.IGNORE_PATTERN,
153
155
  });
154
156
  for (const file of files) {
@@ -0,0 +1,8 @@
1
+ import { ILogger } from '../interface';
2
+ export declare abstract class LoggerFactory<Logger extends ILogger, LoggerOptions> {
3
+ abstract createLogger(name: string, options: LoggerOptions): Logger;
4
+ abstract getLogger(loggerName: string): Logger;
5
+ abstract close(loggerName?: string): any;
6
+ abstract removeLogger(loggerName: string): any;
7
+ }
8
+ //# sourceMappingURL=loggerFactory.d.ts.map
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.LoggerFactory = void 0;
4
+ class LoggerFactory {
5
+ }
6
+ exports.LoggerFactory = LoggerFactory;
7
+ //# sourceMappingURL=loggerFactory.js.map
@@ -1,13 +1,14 @@
1
+ import { IServiceFactory } from '../interface';
1
2
  /**
2
3
  * 多客户端工厂实现
3
4
  */
4
- export declare abstract class ServiceFactory<T> {
5
+ export declare abstract class ServiceFactory<T> implements IServiceFactory<T> {
5
6
  protected clients: Map<string, T>;
6
7
  protected options: {};
7
8
  protected initClients(options?: any): Promise<void>;
8
9
  get<U = T>(id?: string): U;
9
10
  has(id: string): boolean;
10
- createInstance(config: any, clientName?: any): Promise<T | void>;
11
+ createInstance(config: any, clientName?: any): Promise<T | undefined>;
11
12
  abstract getName(): string;
12
13
  protected abstract createClient(config: any, clientName: any): Promise<T | void> | (T | void);
13
14
  protected destroyClient(client: T): Promise<void>;
@@ -9,6 +9,7 @@ exports.WebControllerGenerator = void 0;
9
9
  */
10
10
  const decorator_1 = require("../decorator");
11
11
  const util = require("util");
12
+ const interface_1 = require("../interface");
12
13
  const error_1 = require("../error");
13
14
  const middlewareService_1 = require("../service/middlewareService");
14
15
  const debug = util.debuglog('midway:debug');
@@ -109,7 +110,7 @@ class WebControllerGenerator {
109
110
  const routeMiddlewareFn = await middlewareService.compose(routeInfo.middleware, this.app);
110
111
  methodMiddlewares.push(routeMiddlewareFn);
111
112
  }
112
- if (this.app.getFrameworkType() === decorator_1.MidwayFrameworkType.WEB_KOA) {
113
+ if (this.app.getFrameworkType() === interface_1.MidwayFrameworkType.WEB_KOA) {
113
114
  // egg use path-to-regexp v1 but koa use v6
114
115
  if (typeof routeInfo.url === 'string' && /\*$/.test(routeInfo.url)) {
115
116
  routeInfo.url = routeInfo.url.replace('*', '(.*)');
@@ -14,12 +14,13 @@ exports.default = (appInfo) => {
14
14
  midwayLogger: {
15
15
  default: {
16
16
  dir: (0, path_1.join)(logRoot, 'logs', appInfo.name),
17
- level: isDevelopment ? 'info' : 'warn',
17
+ level: 'info',
18
18
  consoleLevel: isDevelopment ? 'info' : 'warn',
19
19
  auditFileDir: '.audit',
20
20
  },
21
21
  clients: {
22
22
  coreLogger: {
23
+ level: isDevelopment ? 'info' : 'warn',
23
24
  fileLogName: 'midway-core.log',
24
25
  },
25
26
  appLogger: {
@@ -14,7 +14,7 @@ export declare const KEYS: {
14
14
  PROPS_ELEMENT: string;
15
15
  PROP_ELEMENT: string;
16
16
  SET_ELEMENT: string;
17
- CONSTRUCTORARG_ELEMENT: string;
17
+ CONSTRUCTOR_ARG_ELEMENT: string;
18
18
  REF_ELEMENT: string;
19
19
  JSON_ELEMENT: string;
20
20
  CONFIGURATION_ELEMENT: string;
@@ -37,16 +37,6 @@ export declare const KEYS: {
37
37
  EXPRESSION_ATTRIBUTE: string;
38
38
  EXECUTE_ATTRIBUTE: string;
39
39
  };
40
- export declare const VALUE_TYPE: {
41
- STRING: string;
42
- DATE: string;
43
- NUMBER: string;
44
- INTEGER: string;
45
- TEMPLATE: string;
46
- MANAGED: string;
47
- OBJECT: string;
48
- BOOLEAN: string;
49
- };
50
40
  export declare const FUNCTION_INJECT_KEY = "midway:function_inject_key";
51
41
  export declare const MIDWAY_LOGGER_WRITEABLE_DIR = "MIDWAY_LOGGER_WRITEABLE_DIR";
52
42
  export declare const REQUEST_CTX_KEY = "ctx";
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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;
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.KEYS = void 0;
4
4
  /**
5
5
  * 静态参数
6
6
  *
@@ -17,7 +17,7 @@ exports.KEYS = {
17
17
  PROPS_ELEMENT: 'props',
18
18
  PROP_ELEMENT: 'prop',
19
19
  SET_ELEMENT: 'set',
20
- CONSTRUCTORARG_ELEMENT: 'constructor-arg',
20
+ CONSTRUCTOR_ARG_ELEMENT: 'constructor-arg',
21
21
  REF_ELEMENT: 'ref',
22
22
  JSON_ELEMENT: 'json',
23
23
  CONFIGURATION_ELEMENT: 'configuration',
@@ -40,16 +40,6 @@ exports.KEYS = {
40
40
  EXPRESSION_ATTRIBUTE: 'expression',
41
41
  EXECUTE_ATTRIBUTE: 'execute',
42
42
  };
43
- exports.VALUE_TYPE = {
44
- STRING: 'string',
45
- DATE: 'date',
46
- NUMBER: 'number',
47
- INTEGER: 'int',
48
- TEMPLATE: 'template',
49
- MANAGED: 'managed',
50
- OBJECT: 'object',
51
- BOOLEAN: 'boolean',
52
- };
53
43
  exports.FUNCTION_INJECT_KEY = 'midway:function_inject_key';
54
44
  exports.MIDWAY_LOGGER_WRITEABLE_DIR = 'MIDWAY_LOGGER_WRITEABLE_DIR';
55
45
  exports.REQUEST_CTX_KEY = 'ctx';
@@ -1,6 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { IModuleStore, ObjectIdentifier } from '../decorator';
3
- import { IFileDetector, IIdentifierRelationShip, IMidwayContainer, IObjectDefinition, IObjectDefinitionRegistry, ObjectContext } from '../interface';
2
+ import { IFileDetector, IIdentifierRelationShip, IMidwayContainer, IModuleStore, IObjectDefinition, IObjectDefinitionRegistry, ObjectContext, ObjectIdentifier } from '../interface';
4
3
  import { ManagedResolverFactory } from './managedResolverFactory';
5
4
  import * as EventEmitter from 'events';
6
5
  export declare class MidwayContainer implements IMidwayContainer, IModuleStore {
@@ -141,7 +141,7 @@ class ContainerConfiguration {
141
141
  const id = (0, decorator_1.getProviderUUId)(clzz);
142
142
  this.container.bind(id, clzz, {
143
143
  namespace: namespace,
144
- scope: decorator_1.ScopeEnum.Singleton,
144
+ scope: interface_1.ScopeEnum.Singleton,
145
145
  });
146
146
  }
147
147
  // configuration 手动绑定去重
@@ -302,7 +302,7 @@ class MidwayContainer {
302
302
  definition.id = identifier;
303
303
  definition.srcPath = (options === null || options === void 0 ? void 0 : options.srcPath) || null;
304
304
  definition.namespace = (options === null || options === void 0 ? void 0 : options.namespace) || '';
305
- definition.scope = (options === null || options === void 0 ? void 0 : options.scope) || decorator_1.ScopeEnum.Request;
305
+ definition.scope = (options === null || options === void 0 ? void 0 : options.scope) || interface_1.ScopeEnum.Request;
306
306
  definition.createFrom = options === null || options === void 0 ? void 0 : options.createFrom;
307
307
  if (definition.srcPath) {
308
308
  debug(`[core]: bind id "${definition.name} (${definition.srcPath}) ${identifier}"`);
@@ -371,7 +371,7 @@ class MidwayContainer {
371
371
  const info = module[constants_1.FUNCTION_INJECT_KEY];
372
372
  if (info && info.id) {
373
373
  if (!info.scope) {
374
- info.scope = decorator_1.ScopeEnum.Request;
374
+ info.scope = interface_1.ScopeEnum.Request;
375
375
  }
376
376
  const uuid = util_1.Utils.generateRandomId();
377
377
  this.identifierMapping.saveFunctionRelation(info.id, uuid);
@@ -1,8 +1,4 @@
1
- /**
2
- * Object Definition Registry 实现
3
- */
4
- import { ObjectIdentifier } from '../decorator';
5
- import { IIdentifierRelationShip, IObjectDefinition, IObjectDefinitionRegistry } from '../interface';
1
+ import { IIdentifierRelationShip, IObjectDefinition, IObjectDefinitionRegistry, ObjectIdentifier } from '../interface';
6
2
  export declare class ObjectDefinitionRegistry extends Map implements IObjectDefinitionRegistry {
7
3
  private singletonIds;
8
4
  private _identifierRelation;
@@ -1,5 +1,4 @@
1
- import { IManagedResolver, IObjectDefinition, IManagedResolverFactoryCreateOptions, IMidwayContainer } from '../interface';
2
- import { IManagedInstance, InjectModeEnum, ObjectIdentifier } from '../decorator';
1
+ import { IManagedResolver, IObjectDefinition, IManagedResolverFactoryCreateOptions, IMidwayContainer, IManagedInstance, InjectModeEnum, ObjectIdentifier } from '../interface';
3
2
  export declare class ManagedReference implements IManagedInstance {
4
3
  type: string;
5
4
  name: string;
@@ -8,7 +8,6 @@ const constants_1 = require("../constants");
8
8
  const interface_1 = require("../interface");
9
9
  const util = require("util");
10
10
  const error_1 = require("../error");
11
- const decorator_1 = require("../decorator");
12
11
  const debug = util.debuglog('midway:managedresolver');
13
12
  const debugLog = util.debuglog('midway:debug');
14
13
  class ManagedReference {
@@ -30,7 +29,7 @@ class RefResolver {
30
29
  resolve(managed, originName) {
31
30
  var _a;
32
31
  const mr = managed;
33
- if (mr.injectMode === decorator_1.InjectModeEnum.Class &&
32
+ if (mr.injectMode === interface_1.InjectModeEnum.Class &&
34
33
  !((_a = this.factory.context.parent) !== null && _a !== void 0 ? _a : this.factory.context).hasDefinition(mr.name)) {
35
34
  if (originName === 'loggerService') {
36
35
  throw new error_1.MidwayInconsistentVersionError();
@@ -46,7 +45,7 @@ class RefResolver {
46
45
  async resolveAsync(managed, originName) {
47
46
  var _a;
48
47
  const mr = managed;
49
- if (mr.injectMode === decorator_1.InjectModeEnum.Class &&
48
+ if (mr.injectMode === interface_1.InjectModeEnum.Class &&
50
49
  !((_a = this.factory.context.parent) !== null && _a !== void 0 ? _a : this.factory.context).hasDefinition(mr.name)) {
51
50
  if (originName === 'loggerService') {
52
51
  throw new error_1.MidwayInconsistentVersionError();
@@ -1,5 +1,4 @@
1
- import { IMidwayContainer } from '../interface';
2
- import { ObjectIdentifier, ScopeEnum } from '../decorator';
1
+ import { IMidwayContainer, ObjectIdentifier, ScopeEnum } from '../interface';
3
2
  export declare function providerWrapper(wrapperInfo: Array<{
4
3
  id: ObjectIdentifier;
5
4
  provider: (context: IMidwayContainer, args?: any) => any;
@@ -1,20 +1,2 @@
1
- export interface JoinPoint {
2
- methodName: string;
3
- target: any;
4
- args: any[];
5
- proceed?(...args: any[]): any;
6
- }
7
- export interface AspectMetadata {
8
- aspectTarget: any;
9
- match?: string | (() => boolean);
10
- priority?: number;
11
- }
12
- export interface IMethodAspect {
13
- after?(joinPoint: JoinPoint, result: any, error: Error): any;
14
- afterReturn?(joinPoint: JoinPoint, result: any): any;
15
- afterThrow?(joinPoint: JoinPoint, error: Error): void;
16
- before?(joinPoint: JoinPoint): void;
17
- around?(joinPoint: JoinPoint): any;
18
- }
19
1
  export declare function Aspect(aspectTarget: any | any[], match?: string | (() => boolean), priority?: number): (target: any) => void;
20
2
  //# sourceMappingURL=aspect.d.ts.map
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Aspect = void 0;
4
4
  const __1 = require("../");
5
5
  const objectDef_1 = require("./objectDef");
6
+ const interface_1 = require("../../interface");
6
7
  function Aspect(aspectTarget, match, priority) {
7
8
  return function (target) {
8
9
  (0, __1.saveModule)(__1.ASPECT_KEY, target);
@@ -14,7 +15,7 @@ function Aspect(aspectTarget, match, priority) {
14
15
  priority,
15
16
  }, target);
16
17
  }
17
- (0, objectDef_1.Scope)(__1.ScopeEnum.Singleton)(target);
18
+ (0, objectDef_1.Scope)(interface_1.ScopeEnum.Singleton)(target);
18
19
  (0, __1.Provide)()(target);
19
20
  };
20
21
  }
@@ -1,6 +1,6 @@
1
1
  export declare function Catch(catchTarget?: any | any[], options?: {
2
2
  matchPrototype?: boolean;
3
3
  }): (target: any) => void;
4
- export declare type MatchPattern<CtxOrReq = any, Res = any> = ((ctxOrReq: CtxOrReq, res: Res) => boolean) | string | string[] | boolean;
4
+ export type MatchPattern<CtxOrReq = any, Res = any> = ((ctxOrReq: CtxOrReq, res: Res) => boolean) | string | string[] | boolean;
5
5
  export declare function Match(matchPattern?: MatchPattern): (target: any) => void;
6
6
  //# sourceMappingURL=filter.d.ts.map
@@ -5,7 +5,7 @@ const decoratorManager_1 = require("../decoratorManager");
5
5
  const constant_1 = require("../constant");
6
6
  const objectDef_1 = require("./objectDef");
7
7
  const provide_1 = require("./provide");
8
- const interface_1 = require("../interface");
8
+ const interface_1 = require("../../interface");
9
9
  function Catch(catchTarget, options = {}) {
10
10
  return function (target) {
11
11
  const catchTargets = catchTarget ? [].concat(catchTarget) : undefined;
@@ -1,4 +1,4 @@
1
- import { FrameworkType } from '../';
1
+ import { FrameworkType } from '../../interface';
2
2
  export declare function Framework(): ClassDecorator;
3
3
  export declare function Plugin(identifier?: string): PropertyDecorator;
4
4
  export declare function Config(identifier?: string): PropertyDecorator;
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ApplicationContext = exports.Logger = exports.App = exports.Config = exports.Plugin = exports.Framework = void 0;
4
4
  const __1 = require("../");
5
+ const interface_1 = require("../../interface");
5
6
  function Framework() {
6
7
  return (target) => {
7
8
  (0, __1.saveModule)(__1.FRAMEWORK_KEY, target);
8
- (0, __1.Scope)(__1.ScopeEnum.Singleton)(target);
9
+ (0, __1.Scope)(interface_1.ScopeEnum.Singleton)(target);
9
10
  (0, __1.Provide)()(target);
10
11
  };
11
12
  }
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Guard = exports.UseGuard = void 0;
4
4
  const decoratorManager_1 = require("../decoratorManager");
5
+ const interface_1 = require("../../interface");
5
6
  const constant_1 = require("../constant");
6
7
  const provide_1 = require("./provide");
7
8
  const objectDef_1 = require("./objectDef");
8
- const interface_1 = require("../interface");
9
9
  function UseGuard(guardOrArr) {
10
10
  return (target, propertyKey, descriptor) => {
11
11
  if (!Array.isArray(guardOrArr)) {
@@ -1,3 +1,4 @@
1
- import { ObjectIdentifier } from '../interface';
1
+ import { IServiceFactory, ObjectIdentifier } from '../../interface';
2
2
  export declare function Inject(identifier?: ObjectIdentifier): (target: any, targetKey: string) => void;
3
+ export declare function InjectClient(serviceFactoryClz: new (...args: any[]) => IServiceFactory<unknown>, clientName?: string): PropertyDecorator;
3
4
  //# sourceMappingURL=inject.d.ts.map
@@ -1,11 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Inject = void 0;
3
+ exports.InjectClient = exports.Inject = void 0;
4
4
  const decoratorManager_1 = require("../decoratorManager");
5
+ const constant_1 = require("../constant");
5
6
  function Inject(identifier) {
6
7
  return function (target, targetKey) {
7
8
  (0, decoratorManager_1.savePropertyInject)({ target, targetKey, identifier });
8
9
  };
9
10
  }
10
11
  exports.Inject = Inject;
12
+ function InjectClient(serviceFactoryClz, clientName) {
13
+ return (0, decoratorManager_1.createCustomPropertyDecorator)(constant_1.FACTORY_SERVICE_CLIENT_KEY, {
14
+ serviceFactoryClz,
15
+ clientName,
16
+ });
17
+ }
18
+ exports.InjectClient = InjectClient;
11
19
  //# sourceMappingURL=inject.js.map
@@ -2,9 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Middleware = void 0;
4
4
  const __1 = require("../");
5
+ const interface_1 = require("../../interface");
5
6
  function Middleware() {
6
7
  return (target) => {
7
- (0, __1.Scope)(__1.ScopeEnum.Singleton)(target);
8
+ (0, __1.Scope)(interface_1.ScopeEnum.Singleton)(target);
8
9
  (0, __1.Provide)()(target);
9
10
  };
10
11
  }
@@ -0,0 +1,2 @@
1
+ export declare function Mock(): ClassDecorator;
2
+ //# sourceMappingURL=mock.d.ts.map
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Mock = void 0;
4
+ const __1 = require("../");
5
+ const interface_1 = require("../../interface");
6
+ function Mock() {
7
+ return (target) => {
8
+ (0, __1.saveModule)(__1.MOCK_KEY, target);
9
+ (0, __1.Scope)(interface_1.ScopeEnum.Singleton)(target);
10
+ (0, __1.Provide)()(target);
11
+ };
12
+ }
13
+ exports.Mock = Mock;
14
+ //# sourceMappingURL=mock.js.map
@@ -1,7 +1,8 @@
1
- import { ScopeEnum } from '../interface';
1
+ import { ScopeEnum } from '../../interface';
2
2
  export declare function Init(): MethodDecorator;
3
3
  export declare function Destroy(): MethodDecorator;
4
4
  export declare function Scope(scope: ScopeEnum, scopeOptions?: {
5
5
  allowDowngrade?: boolean;
6
6
  }): ClassDecorator;
7
+ export declare function Singleton(): ClassDecorator;
7
8
  //# sourceMappingURL=objectDef.d.ts.map
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Scope = exports.Destroy = exports.Init = void 0;
3
+ exports.Singleton = exports.Scope = exports.Destroy = exports.Init = void 0;
4
4
  const decoratorManager_1 = require("../decoratorManager");
5
+ const provide_1 = require("./provide");
6
+ const interface_1 = require("../../interface");
5
7
  function Init() {
6
8
  return function (target, propertyKey) {
7
9
  (0, decoratorManager_1.saveObjectDefinition)(target, { initMethod: propertyKey });
@@ -22,4 +24,11 @@ function Scope(scope, scopeOptions) {
22
24
  };
23
25
  }
24
26
  exports.Scope = Scope;
27
+ function Singleton() {
28
+ return function (target) {
29
+ Scope(interface_1.ScopeEnum.Singleton)(target);
30
+ (0, provide_1.Provide)()(target);
31
+ };
32
+ }
33
+ exports.Singleton = Singleton;
25
34
  //# sourceMappingURL=objectDef.js.map
@@ -0,0 +1,2 @@
1
+ export declare function Pipe(): ClassDecorator;
2
+ //# sourceMappingURL=pipe.d.ts.map
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Pipe = void 0;
4
+ const __1 = require("../");
5
+ const interface_1 = require("../../interface");
6
+ function Pipe() {
7
+ return (target) => {
8
+ (0, __1.Scope)(interface_1.ScopeEnum.Singleton)(target);
9
+ (0, __1.Provide)()(target);
10
+ };
11
+ }
12
+ exports.Pipe = Pipe;
13
+ //# sourceMappingURL=pipe.js.map
@@ -1,3 +1,3 @@
1
- import { ObjectIdentifier } from '../interface';
1
+ import { ObjectIdentifier } from '../../interface';
2
2
  export declare function Pipeline(valves?: Array<ObjectIdentifier | (new (...args: any[]) => any)>): PropertyDecorator;
3
3
  //# sourceMappingURL=pipeline.d.ts.map
@@ -1,3 +1,3 @@
1
- import { ObjectIdentifier } from '../interface';
1
+ import { ObjectIdentifier } from '../../interface';
2
2
  export declare function Provide(identifier?: ObjectIdentifier): (target: any) => any;
3
3
  //# sourceMappingURL=provide.d.ts.map
@@ -6,6 +6,8 @@ export declare const ASPECT_KEY = "common:aspect";
6
6
  export declare const CATCH_KEY = "common:catch";
7
7
  export declare const MATCH_KEY = "common:match";
8
8
  export declare const GUARD_KEY = "common:guard";
9
+ export declare const MOCK_KEY = "common:mock";
10
+ export declare const FACTORY_SERVICE_CLIENT_KEY = "common:service_factory:client";
9
11
  export declare const FUNC_KEY = "faas:func";
10
12
  export declare const SERVERLESS_FUNC_KEY = "faas:serverless:function";
11
13
  export declare const CONTROLLER_KEY = "web:controller";