@midwayjs/core 3.9.0 → 3.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/baseFramework.d.ts +3 -0
  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/webGenerator.js +2 -1
  6. package/dist/config/config.default.js +2 -1
  7. package/dist/context/container.d.ts +1 -2
  8. package/dist/context/container.js +3 -3
  9. package/dist/context/definitionRegistry.d.ts +1 -5
  10. package/dist/context/managedResolverFactory.d.ts +1 -2
  11. package/dist/context/managedResolverFactory.js +2 -3
  12. package/dist/context/providerWrapper.d.ts +1 -2
  13. package/dist/decorator/common/aspect.d.ts +0 -18
  14. package/dist/decorator/common/aspect.js +2 -1
  15. package/dist/decorator/common/filter.d.ts +1 -1
  16. package/dist/decorator/common/filter.js +1 -1
  17. package/dist/decorator/common/framework.d.ts +1 -1
  18. package/dist/decorator/common/framework.js +2 -1
  19. package/dist/decorator/common/guard.js +1 -1
  20. package/dist/decorator/common/inject.d.ts +1 -2
  21. package/dist/decorator/common/middleware.js +2 -1
  22. package/dist/decorator/common/mock.d.ts +2 -0
  23. package/dist/decorator/common/mock.js +14 -0
  24. package/dist/decorator/common/objectDef.d.ts +2 -1
  25. package/dist/decorator/common/objectDef.js +10 -1
  26. package/dist/decorator/common/pipe.d.ts +2 -0
  27. package/dist/decorator/common/pipe.js +13 -0
  28. package/dist/decorator/common/pipeline.d.ts +1 -1
  29. package/dist/decorator/common/provide.d.ts +1 -1
  30. package/dist/decorator/constant.d.ts +1 -0
  31. package/dist/decorator/constant.js +3 -2
  32. package/dist/decorator/decoratorManager.d.ts +6 -10
  33. package/dist/decorator/decoratorManager.js +20 -8
  34. package/dist/decorator/faas/serverlessTrigger.d.ts +3 -1
  35. package/dist/decorator/faas/serverlessTrigger.js +3 -2
  36. package/dist/decorator/index.d.ts +2 -1
  37. package/dist/decorator/index.js +2 -1
  38. package/dist/decorator/microservice/consumer.d.ts +1 -1
  39. package/dist/decorator/microservice/consumer.js +2 -1
  40. package/dist/decorator/microservice/kafkaListener.d.ts +3 -3
  41. package/dist/decorator/microservice/provider.d.ts +1 -1
  42. package/dist/decorator/microservice/provider.js +2 -1
  43. package/dist/decorator/rpc/hsf.d.ts +1 -0
  44. package/dist/decorator/rpc/hsf.js +3 -1
  45. package/dist/decorator/task/schedule.js +2 -1
  46. package/dist/decorator/web/controller.d.ts +1 -1
  47. package/dist/decorator/web/controller.js +2 -1
  48. package/dist/decorator/web/requestMapping.d.ts +1 -4
  49. package/dist/decorator/ws/webSocketController.d.ts +1 -1
  50. package/dist/decorator/ws/webSocketController.js +2 -1
  51. package/dist/decorator/ws/webSocketEvent.d.ts +1 -1
  52. package/dist/definitions/functionDefinition.d.ts +1 -2
  53. package/dist/definitions/functionDefinition.js +4 -4
  54. package/dist/definitions/objectDefinition.d.ts +1 -2
  55. package/dist/definitions/objectDefinition.js +4 -4
  56. package/dist/definitions/properties.d.ts +1 -2
  57. package/dist/error/base.d.ts +2 -2
  58. package/dist/error/framework.d.ts +1 -1
  59. package/dist/error/framework.js +5 -5
  60. package/dist/interface.d.ts +327 -24
  61. package/dist/interface.js +64 -1
  62. package/dist/service/aspectService.d.ts +1 -2
  63. package/dist/service/aspectService.js +2 -1
  64. package/dist/service/configService.js +2 -1
  65. package/dist/service/decoratorService.d.ts +3 -1
  66. package/dist/service/decoratorService.js +63 -11
  67. package/dist/service/environmentService.js +2 -1
  68. package/dist/service/frameworkService.d.ts +1 -2
  69. package/dist/service/frameworkService.js +6 -1
  70. package/dist/service/informationService.js +2 -1
  71. package/dist/service/lifeCycleService.d.ts +2 -0
  72. package/dist/service/lifeCycleService.js +14 -4
  73. package/dist/service/loggerService.d.ts +1 -0
  74. package/dist/service/loggerService.js +19 -2
  75. package/dist/service/middlewareService.js +2 -1
  76. package/dist/service/mockService.d.ts +9 -1
  77. package/dist/service/mockService.js +43 -1
  78. package/dist/service/pipelineService.d.ts +2 -3
  79. package/dist/service/slsFunctionService.d.ts +1 -1
  80. package/dist/service/slsFunctionService.js +3 -2
  81. package/dist/service/webRouterService.d.ts +1 -1
  82. package/dist/service/webRouterService.js +3 -2
  83. package/dist/setup.js +2 -0
  84. package/dist/util/httpclient.d.ts +2 -2
  85. package/dist/util/pathToRegexp.d.ts +5 -5
  86. package/dist/util/webRouterParam.d.ts +2 -4
  87. package/dist/util/webRouterParam.js +5 -27
  88. package/package.json +4 -5
  89. package/dist/decorator/interface.d.ts +0 -242
  90. 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;
@@ -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
@@ -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: {
@@ -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,5 +1,4 @@
1
- import { ObjectIdentifier } from '../interface';
2
- import { IServiceFactory } from '../../interface';
1
+ import { IServiceFactory, ObjectIdentifier } from '../../interface';
3
2
  export declare function Inject(identifier?: ObjectIdentifier): (target: any, targetKey: string) => void;
4
3
  export declare function InjectClient(serviceFactoryClz: new (...args: any[]) => IServiceFactory<unknown>, clientName?: string): PropertyDecorator;
5
4
  //# sourceMappingURL=inject.d.ts.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,7 @@ 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";
9
10
  export declare const FACTORY_SERVICE_CLIENT_KEY = "common:service_factory:client";
10
11
  export declare const FUNC_KEY = "faas:func";
11
12
  export declare const SERVERLESS_FUNC_KEY = "faas:serverless:function";
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TAGGED_FUN = exports.TAGGED_CLS = exports.INJECT_CUSTOM_PARAM = exports.INJECT_CUSTOM_METHOD = exports.INJECT_CUSTOM_PROPERTY = exports.INJECT_TAG = exports.NAMED_TAG = exports.CLASS_KEY_CONSTRUCTOR = exports.APPLICATION_CONTEXT_KEY = exports.APPLICATION_KEY = exports.LOGGER_KEY = exports.PLUGIN_KEY = exports.CONFIG_KEY = exports.MS_HSF_METHOD_KEY = exports.MS_DUBBO_METHOD_KEY = exports.MS_GRPC_METHOD_KEY = exports.MS_PROVIDER_KEY = exports.MS_PRODUCER_KEY = exports.MS_CONSUMER_KEY = exports.RPC_DUBBO_KEY = exports.RPC_GRPC_KEY = exports.HSF_KEY = exports.WS_EVENT_KEY = exports.WS_CONTROLLER_KEY = exports.MODULE_TASK_QUEUE_OPTIONS = exports.MODULE_TASK_QUEUE_KEY = exports.MODULE_TASK_TASK_LOCAL_OPTIONS = exports.MODULE_TASK_TASK_LOCAL_KEY = exports.MODULE_TASK_METADATA = exports.MODULE_TASK_KEY = exports.WEB_RESPONSE_RENDER = exports.WEB_RESPONSE_CONTENT_TYPE = exports.WEB_RESPONSE_HEADER = exports.WEB_RESPONSE_REDIRECT = exports.WEB_RESPONSE_HTTP_CODE = exports.WEB_RESPONSE_KEY = exports.WEB_ROUTER_PARAM_KEY = exports.WEB_ROUTER_KEY = exports.CONTROLLER_KEY = exports.SERVERLESS_FUNC_KEY = exports.FUNC_KEY = exports.FACTORY_SERVICE_CLIENT_KEY = exports.GUARD_KEY = exports.MATCH_KEY = exports.CATCH_KEY = exports.ASPECT_KEY = exports.FRAMEWORK_KEY = exports.CONFIGURATION_KEY = exports.SCHEDULE_KEY = exports.ALL = void 0;
4
- exports.PRIVATE_META_DATA_KEY = exports.MAIN_MODULE_KEY = exports.LIFECYCLE_IDENTIFIER_PREFIX = exports.PIPELINE_IDENTIFIER = exports.OBJ_DEF_CLS = void 0;
3
+ exports.TAGGED_CLS = exports.INJECT_CUSTOM_PARAM = exports.INJECT_CUSTOM_METHOD = exports.INJECT_CUSTOM_PROPERTY = exports.INJECT_TAG = exports.NAMED_TAG = exports.CLASS_KEY_CONSTRUCTOR = exports.APPLICATION_CONTEXT_KEY = exports.APPLICATION_KEY = exports.LOGGER_KEY = exports.PLUGIN_KEY = exports.CONFIG_KEY = exports.MS_HSF_METHOD_KEY = exports.MS_DUBBO_METHOD_KEY = exports.MS_GRPC_METHOD_KEY = exports.MS_PROVIDER_KEY = exports.MS_PRODUCER_KEY = exports.MS_CONSUMER_KEY = exports.RPC_DUBBO_KEY = exports.RPC_GRPC_KEY = exports.HSF_KEY = exports.WS_EVENT_KEY = exports.WS_CONTROLLER_KEY = exports.MODULE_TASK_QUEUE_OPTIONS = exports.MODULE_TASK_QUEUE_KEY = exports.MODULE_TASK_TASK_LOCAL_OPTIONS = exports.MODULE_TASK_TASK_LOCAL_KEY = exports.MODULE_TASK_METADATA = exports.MODULE_TASK_KEY = exports.WEB_RESPONSE_RENDER = exports.WEB_RESPONSE_CONTENT_TYPE = exports.WEB_RESPONSE_HEADER = exports.WEB_RESPONSE_REDIRECT = exports.WEB_RESPONSE_HTTP_CODE = exports.WEB_RESPONSE_KEY = exports.WEB_ROUTER_PARAM_KEY = exports.WEB_ROUTER_KEY = exports.CONTROLLER_KEY = exports.SERVERLESS_FUNC_KEY = exports.FUNC_KEY = exports.FACTORY_SERVICE_CLIENT_KEY = exports.MOCK_KEY = exports.GUARD_KEY = exports.MATCH_KEY = exports.CATCH_KEY = exports.ASPECT_KEY = exports.FRAMEWORK_KEY = exports.CONFIGURATION_KEY = exports.SCHEDULE_KEY = exports.ALL = void 0;
4
+ exports.PRIVATE_META_DATA_KEY = exports.MAIN_MODULE_KEY = exports.LIFECYCLE_IDENTIFIER_PREFIX = exports.PIPELINE_IDENTIFIER = exports.OBJ_DEF_CLS = exports.TAGGED_FUN = void 0;
5
5
  // got all value with no property name
6
6
  exports.ALL = 'common:all_value_key';
7
7
  // common
@@ -12,6 +12,7 @@ exports.ASPECT_KEY = 'common:aspect';
12
12
  exports.CATCH_KEY = 'common:catch';
13
13
  exports.MATCH_KEY = 'common:match';
14
14
  exports.GUARD_KEY = 'common:guard';
15
+ exports.MOCK_KEY = 'common:mock';
15
16
  exports.FACTORY_SERVICE_CLIENT_KEY = 'common:service_factory:client';
16
17
  // faas
17
18
  exports.FUNC_KEY = 'faas:func';
@@ -1,5 +1,5 @@
1
1
  import 'reflect-metadata';
2
- import { GroupModeType, IModuleStore, ObjectDefinitionOptions, ObjectIdentifier, TagPropsMetadata } from './interface';
2
+ import { GroupModeType, IModuleStore, MethodDecoratorOptions, ObjectDefinitionOptions, ObjectIdentifier, ParamDecoratorOptions, TagPropsMetadata, TSDesignType } from '../interface';
3
3
  export declare const PRELOAD_MODULE_KEY = "INJECTION_PRELOAD_MODULE_KEY";
4
4
  export declare const INJECT_CLASS_KEY_PREFIX = "INJECTION_CLASS_META_DATA";
5
5
  export declare class DecoratorManager extends Map implements IModuleStore {
@@ -200,11 +200,7 @@ export declare function resetModule(decoratorNameKey: ObjectIdentifier): void;
200
200
  * clear all module
201
201
  */
202
202
  export declare function clearAllModule(): void;
203
- export interface TSDesignType {
204
- name: string;
205
- originDesign: any;
206
- isBaseType: boolean;
207
- }
203
+ export declare function transformTypeFromTSDesign(designFn: any): TSDesignType;
208
204
  /**
209
205
  * save property inject args
210
206
  * @param opts 参数
@@ -270,7 +266,7 @@ export declare function getMethodParamTypes(target: any, methodName: string | sy
270
266
  * @param target
271
267
  * @param methodName
272
268
  */
273
- export declare function getPropertyType(target: any, methodName: string | symbol): TSDesignType;
269
+ export declare function getPropertyType(target: any, methodName: string | symbol): TSDesignType<unknown>;
274
270
  /**
275
271
  * get method return type from metadata
276
272
  * @param target
@@ -290,12 +286,12 @@ export declare function createCustomPropertyDecorator(decoratorKey: string, meta
290
286
  * @param metadata
291
287
  * @param impl default true, configuration need decoratorService.registerMethodHandler
292
288
  */
293
- export declare function createCustomMethodDecorator(decoratorKey: string, metadata: any, impl?: boolean): MethodDecorator;
289
+ export declare function createCustomMethodDecorator(decoratorKey: string, metadata: any, implOrOptions?: boolean | MethodDecoratorOptions): MethodDecorator;
294
290
  /**
295
291
  *
296
292
  * @param decoratorKey
297
293
  * @param metadata
298
- * @param impl default true, configuration need decoratorService.registerMethodHandler
294
+ * @param options
299
295
  */
300
- export declare function createCustomParamDecorator(decoratorKey: string, metadata: any, impl?: boolean): ParameterDecorator;
296
+ export declare function createCustomParamDecorator(decoratorKey: string, metadata: any, implOrOptions?: boolean | ParamDecoratorOptions): ParameterDecorator;
301
297
  //# sourceMappingURL=decoratorManager.d.ts.map
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createCustomParamDecorator = exports.createCustomMethodDecorator = exports.createCustomPropertyDecorator = exports.getMethodReturnTypes = exports.getPropertyType = exports.getMethodParamTypes = exports.BaseType = exports.isProvide = exports.getProviderUUId = exports.getProviderName = exports.getProviderId = exports.saveProviderId = exports.getObjectDefinition = exports.saveObjectDefinition = exports.getPropertyInject = exports.savePropertyInject = exports.clearAllModule = exports.resetModule = exports.listModule = exports.clearBindContainer = exports.bindContainer = exports.saveModule = exports.listPreloadModule = exports.savePreloadModule = exports.getPropertyMetadata = exports.attachPropertyMetadata = exports.savePropertyMetadata = exports.listPropertyDataFromClass = exports.getPropertyDataFromClass = exports.attachPropertyDataToClass = exports.savePropertyDataToClass = exports.getClassMetadata = exports.getClassExtendedMetadata = exports.attachClassMetadata = exports.saveClassMetadata = exports.DecoratorManager = exports.INJECT_CLASS_KEY_PREFIX = exports.PRELOAD_MODULE_KEY = void 0;
3
+ exports.createCustomParamDecorator = exports.createCustomMethodDecorator = exports.createCustomPropertyDecorator = exports.getMethodReturnTypes = exports.getPropertyType = exports.getMethodParamTypes = exports.BaseType = exports.isProvide = exports.getProviderUUId = exports.getProviderName = exports.getProviderId = exports.saveProviderId = exports.getObjectDefinition = exports.saveObjectDefinition = exports.getPropertyInject = exports.savePropertyInject = exports.transformTypeFromTSDesign = exports.clearAllModule = exports.resetModule = exports.listModule = exports.clearBindContainer = exports.bindContainer = exports.saveModule = exports.listPreloadModule = exports.savePreloadModule = exports.getPropertyMetadata = exports.attachPropertyMetadata = exports.savePropertyMetadata = exports.listPropertyDataFromClass = exports.getPropertyDataFromClass = exports.attachPropertyDataToClass = exports.savePropertyDataToClass = exports.getClassMetadata = exports.getClassExtendedMetadata = exports.attachClassMetadata = exports.saveClassMetadata = exports.DecoratorManager = exports.INJECT_CLASS_KEY_PREFIX = exports.PRELOAD_MODULE_KEY = void 0;
4
4
  require("reflect-metadata");
5
- const interface_1 = require("./interface");
5
+ const interface_1 = require("../interface");
6
6
  const constant_1 = require("./constant");
7
7
  const types_1 = require("../util/types");
8
8
  const camelCase_1 = require("../util/camelCase");
@@ -489,6 +489,7 @@ function transformTypeFromTSDesign(designFn) {
489
489
  };
490
490
  }
491
491
  }
492
+ exports.transformTypeFromTSDesign = transformTypeFromTSDesign;
492
493
  /**
493
494
  * save property inject args
494
495
  * @param opts 参数
@@ -676,13 +677,19 @@ exports.createCustomPropertyDecorator = createCustomPropertyDecorator;
676
677
  * @param metadata
677
678
  * @param impl default true, configuration need decoratorService.registerMethodHandler
678
679
  */
679
- function createCustomMethodDecorator(decoratorKey, metadata, impl = true) {
680
+ function createCustomMethodDecorator(decoratorKey, metadata, implOrOptions = { impl: true }) {
681
+ if (typeof implOrOptions === 'boolean') {
682
+ implOrOptions = { impl: implOrOptions };
683
+ }
684
+ if (implOrOptions.impl === undefined) {
685
+ implOrOptions.impl = true;
686
+ }
680
687
  return function (target, propertyName, descriptor) {
681
688
  attachClassMetadata(constant_1.INJECT_CUSTOM_METHOD, {
682
689
  propertyName,
683
690
  key: decoratorKey,
684
691
  metadata,
685
- impl,
692
+ options: implOrOptions,
686
693
  }, target);
687
694
  };
688
695
  }
@@ -691,17 +698,22 @@ exports.createCustomMethodDecorator = createCustomMethodDecorator;
691
698
  *
692
699
  * @param decoratorKey
693
700
  * @param metadata
694
- * @param impl default true, configuration need decoratorService.registerMethodHandler
701
+ * @param options
695
702
  */
696
- function createCustomParamDecorator(decoratorKey, metadata, impl = true) {
703
+ function createCustomParamDecorator(decoratorKey, metadata, implOrOptions = { impl: true }) {
704
+ if (typeof implOrOptions === 'boolean') {
705
+ implOrOptions = { impl: implOrOptions };
706
+ }
707
+ if (implOrOptions.impl === undefined) {
708
+ implOrOptions.impl = true;
709
+ }
697
710
  return function (target, propertyName, parameterIndex) {
698
- // const parameterName = getParamNames(target[methodName])[parameterIndex];
699
711
  attachClassMetadata(constant_1.INJECT_CUSTOM_PARAM, {
700
712
  key: decoratorKey,
701
713
  parameterIndex,
702
714
  propertyName,
703
715
  metadata,
704
- impl,
716
+ options: implOrOptions,
705
717
  }, target, propertyName, 'multi');
706
718
  };
707
719
  }
@@ -1,4 +1,4 @@
1
- import { FaaSMetadata, ServerlessTriggerType } from '../';
1
+ import { FaaSMetadata, ServerlessTriggerType } from '../../interface';
2
2
  export declare function ServerlessFunction(options: FaaSMetadata.ServerlessFunctionOptions): MethodDecorator;
3
3
  export declare function ServerlessTrigger(type: ServerlessTriggerType.HTTP, metadata: FaaSMetadata.HTTPTriggerOptions): MethodDecorator;
4
4
  export declare function ServerlessTrigger(type: ServerlessTriggerType.OS, metadata: FaaSMetadata.OSTriggerOptions): MethodDecorator;
@@ -9,5 +9,7 @@ export declare function ServerlessTrigger(type: ServerlessTriggerType.CDN, metad
9
9
  export declare function ServerlessTrigger(type: ServerlessTriggerType.API_GATEWAY, metadata?: FaaSMetadata.APIGatewayTriggerOptions): MethodDecorator;
10
10
  export declare function ServerlessTrigger(type: ServerlessTriggerType.HSF, metadata?: FaaSMetadata.HSFTriggerOptions): MethodDecorator;
11
11
  export declare function ServerlessTrigger(type: ServerlessTriggerType.MTOP, metadata?: FaaSMetadata.MTopTriggerOptions): MethodDecorator;
12
+ export declare function ServerlessTrigger(type: ServerlessTriggerType.SSR, metadata?: FaaSMetadata.SSRTriggerOptions): MethodDecorator;
12
13
  export declare function ServerlessTrigger(type: ServerlessTriggerType.EVENT, metadata?: FaaSMetadata.EventTriggerOptions): MethodDecorator;
14
+ export declare function ServerlessTrigger(type: string, metadata?: FaaSMetadata.EventTriggerOptions & Record<string, any>): MethodDecorator;
13
15
  //# sourceMappingURL=serverlessTrigger.d.ts.map
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ServerlessTrigger = exports.ServerlessFunction = void 0;
4
4
  const __1 = require("../");
5
+ const interface_1 = require("../../interface");
5
6
  function ServerlessFunction(options) {
6
7
  return (target, key, descriptor) => {
7
8
  (0, __1.savePropertyMetadata)(__1.SERVERLESS_FUNC_KEY, options, target, key);
@@ -11,8 +12,8 @@ exports.ServerlessFunction = ServerlessFunction;
11
12
  function ServerlessTrigger(type, metadata = {}) {
12
13
  return (target, functionName, descriptor) => {
13
14
  var _a;
14
- if (type === __1.ServerlessTriggerType.HTTP ||
15
- type === __1.ServerlessTriggerType.API_GATEWAY) {
15
+ if (type === interface_1.ServerlessTriggerType.HTTP ||
16
+ type === interface_1.ServerlessTriggerType.API_GATEWAY) {
16
17
  metadata['method'] = (_a = metadata['method']) !== null && _a !== void 0 ? _a : 'get';
17
18
  }
18
19
  (0, __1.saveModule)(__1.FUNC_KEY, target.constructor);
@@ -1,4 +1,3 @@
1
- export * from './interface';
2
1
  export * from './common/provide';
3
2
  export * from './common/inject';
4
3
  export * from './common/pipeline';
@@ -10,6 +9,8 @@ export * from './common/framework';
10
9
  export * from './common/filter';
11
10
  export * from './common/middleware';
12
11
  export * from './common/guard';
12
+ export * from './common/pipe';
13
+ export * from './common/mock';
13
14
  export * from './faas/serverlessTrigger';
14
15
  export * from './web/controller';
15
16
  export * from './web/paramMapping';