@midwayjs/core 3.5.4-beta.3 → 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/baseFramework.d.ts +7 -2
- package/dist/baseFramework.js +27 -9
- package/dist/common/applicationManager.d.ts +1 -1
- package/dist/common/applicationManager.js +1 -1
- package/dist/common/dataListener.js +1 -1
- package/dist/common/dataSourceManager.d.ts +1 -0
- package/dist/common/dataSourceManager.js +10 -7
- package/dist/common/fileDetector.js +6 -5
- package/dist/common/filterManager.js +1 -1
- package/dist/common/guardManager.d.ts +6 -0
- package/dist/common/guardManager.js +49 -0
- package/dist/common/middlewareManager.d.ts +2 -2
- package/dist/common/webGenerator.d.ts +2 -1
- package/dist/common/webGenerator.js +12 -3
- package/dist/config/config.default.d.ts +2 -11
- package/dist/config/config.default.js +2 -2
- package/dist/{common/constants.d.ts → constants.d.ts} +10 -1
- package/dist/{common/constants.js → constants.js} +18 -2
- package/dist/context/container.d.ts +2 -1
- package/dist/context/container.js +19 -14
- package/dist/context/definitionRegistry.d.ts +1 -1
- package/dist/context/definitionRegistry.js +1 -1
- package/dist/context/managedResolverFactory.d.ts +1 -4
- package/dist/context/managedResolverFactory.js +6 -6
- package/dist/context/providerWrapper.d.ts +1 -1
- package/dist/context/providerWrapper.js +1 -1
- package/dist/context/requestContainer.js +3 -3
- package/dist/decorator/common/aspect.d.ts +20 -0
- package/dist/decorator/common/aspect.js +22 -0
- package/dist/decorator/common/autoload.d.ts +2 -0
- package/dist/decorator/common/autoload.js +13 -0
- package/dist/decorator/common/configuration.d.ts +24 -0
- package/dist/decorator/common/configuration.js +11 -0
- package/dist/decorator/common/filter.d.ts +6 -0
- package/dist/decorator/common/filter.js +31 -0
- package/dist/decorator/common/framework.d.ts +8 -0
- package/dist/decorator/common/framework.js +41 -0
- package/dist/decorator/common/guard.d.ts +4 -0
- package/dist/decorator/common/guard.js +30 -0
- package/dist/decorator/common/inject.d.ts +3 -0
- package/dist/decorator/common/inject.js +11 -0
- package/dist/decorator/common/middleware.d.ts +2 -0
- package/dist/decorator/common/middleware.js +12 -0
- package/dist/decorator/common/objectDef.d.ts +7 -0
- package/dist/decorator/common/objectDef.js +25 -0
- package/dist/decorator/common/pipeline.d.ts +3 -0
- package/dist/decorator/common/pipeline.js +12 -0
- package/dist/decorator/common/provide.d.ts +3 -0
- package/dist/decorator/common/provide.js +11 -0
- package/dist/decorator/constant.d.ts +55 -0
- package/dist/decorator/constant.js +86 -0
- package/dist/decorator/decoratorManager.d.ts +301 -0
- package/dist/decorator/decoratorManager.js +709 -0
- package/dist/decorator/faas/serverlessTrigger.d.ts +13 -0
- package/dist/decorator/faas/serverlessTrigger.js +29 -0
- package/dist/decorator/index.d.ts +31 -0
- package/dist/decorator/index.js +55 -0
- package/dist/decorator/interface.d.ts +242 -0
- package/dist/decorator/interface.js +66 -0
- package/dist/decorator/microservice/consumer.d.ts +5 -0
- package/dist/decorator/microservice/consumer.js +17 -0
- package/dist/decorator/microservice/kafkaListener.d.ts +24 -0
- package/dist/decorator/microservice/kafkaListener.js +13 -0
- package/dist/decorator/microservice/provider.d.ts +16 -0
- package/dist/decorator/microservice/provider.js +47 -0
- package/dist/decorator/microservice/rabbitmqListener.d.ts +50 -0
- package/dist/decorator/microservice/rabbitmqListener.js +13 -0
- package/dist/decorator/rpc/hsf.d.ts +12 -0
- package/dist/decorator/rpc/hsf.js +18 -0
- package/dist/decorator/task/queue.d.ts +2 -0
- package/dist/decorator/task/queue.js +17 -0
- package/dist/decorator/task/schedule.d.ts +21 -0
- package/dist/decorator/task/schedule.js +14 -0
- package/dist/decorator/task/task.d.ts +2 -0
- package/dist/decorator/task/task.js +18 -0
- package/dist/decorator/task/taskLocal.d.ts +2 -0
- package/dist/decorator/task/taskLocal.js +17 -0
- package/dist/decorator/web/controller.d.ts +20 -0
- package/dist/decorator/web/controller.js +18 -0
- package/dist/decorator/web/paramMapping.d.ts +37 -0
- package/dist/decorator/web/paramMapping.js +56 -0
- package/dist/decorator/web/requestMapping.d.ts +132 -0
- package/dist/decorator/web/requestMapping.js +83 -0
- package/dist/decorator/web/response.d.ts +9 -0
- package/dist/decorator/web/response.js +65 -0
- package/dist/decorator/ws/webSocketController.d.ts +10 -0
- package/dist/decorator/ws/webSocketController.js +20 -0
- package/dist/decorator/ws/webSocketEvent.d.ts +60 -0
- package/dist/decorator/ws/webSocketEvent.js +87 -0
- package/dist/definitions/functionDefinition.d.ts +1 -1
- package/dist/definitions/functionDefinition.js +1 -1
- package/dist/definitions/objectCreator.d.ts +1 -1
- package/dist/definitions/objectCreator.js +7 -7
- package/dist/definitions/objectDefinition.d.ts +1 -1
- package/dist/definitions/objectDefinition.js +1 -1
- package/dist/definitions/properties.d.ts +1 -1
- package/dist/error/framework.d.ts +5 -1
- package/dist/error/framework.js +9 -2
- package/dist/functional/configuration.d.ts +1 -1
- package/dist/index.d.ts +18 -15
- package/dist/index.js +40 -27
- package/dist/interface.d.ts +54 -18
- package/dist/interface.js +1 -17
- package/dist/service/aspectService.d.ts +1 -1
- package/dist/service/aspectService.js +3 -2
- package/dist/service/configService.js +3 -2
- package/dist/service/decoratorService.js +1 -1
- package/dist/service/environmentService.js +1 -1
- package/dist/service/frameworkService.d.ts +1 -1
- package/dist/service/frameworkService.js +16 -6
- package/dist/service/informationService.js +1 -1
- package/dist/service/lifeCycleService.js +1 -1
- package/dist/service/loggerService.js +1 -1
- package/dist/service/middlewareService.js +3 -2
- package/dist/service/mockService.js +1 -1
- package/dist/service/pipelineService.d.ts +1 -1
- package/dist/service/pipelineService.js +1 -1
- package/dist/service/slsFunctionService.d.ts +1 -1
- package/dist/service/slsFunctionService.js +1 -1
- package/dist/service/webRouterService.d.ts +9 -1
- package/dist/service/webRouterService.js +5 -2
- package/dist/setup.d.ts +2 -2
- package/dist/setup.js +1 -1
- package/dist/util/camelCase.d.ts +3 -0
- package/dist/util/camelCase.js +88 -0
- package/dist/util/contextUtil.js +2 -2
- package/dist/util/extend.js +3 -3
- package/dist/util/flatted.d.ts +7 -0
- package/dist/util/flatted.js +91 -0
- package/dist/util/format.d.ts +25 -0
- package/dist/util/format.js +38 -0
- package/dist/util/fs.d.ts +5 -0
- package/dist/util/fs.js +15 -0
- package/dist/util/httpclient.d.ts +1 -0
- package/dist/util/httpclient.js +1 -1
- package/dist/util/index.d.ts +26 -0
- package/dist/util/index.js +80 -1
- package/dist/util/pathFileUtil.d.ts +6 -3
- package/dist/util/pathFileUtil.js +28 -22
- package/dist/util/retry.js +2 -2
- package/dist/util/types.d.ts +35 -0
- package/dist/util/types.js +121 -0
- package/dist/util/uuid.d.ts +5 -0
- package/dist/util/uuid.js +64 -0
- package/dist/util/webRouterParam.d.ts +4 -2
- package/dist/util/webRouterParam.js +32 -6
- package/package.json +8 -11
|
@@ -4,7 +4,7 @@ exports.ObjectDefinitionRegistry = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Object Definition Registry 实现
|
|
6
6
|
*/
|
|
7
|
-
const decorator_1 = require("
|
|
7
|
+
const decorator_1 = require("../decorator");
|
|
8
8
|
const PREFIX = '_id_default_';
|
|
9
9
|
class LegacyIdentifierRelation extends Map {
|
|
10
10
|
saveClassRelation(module, namespace) {
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 管理对象解析构建
|
|
3
|
-
*/
|
|
4
|
-
import { IManagedInstance, InjectModeEnum, ObjectIdentifier } from '@midwayjs/decorator';
|
|
5
1
|
import { IManagedResolver, IObjectDefinition, IManagedResolverFactoryCreateOptions, IMidwayContainer } from '../interface';
|
|
2
|
+
import { IManagedInstance, InjectModeEnum, ObjectIdentifier } from '../decorator';
|
|
6
3
|
export declare class ManagedReference implements IManagedInstance {
|
|
7
4
|
type: string;
|
|
8
5
|
name: string;
|
|
@@ -4,11 +4,11 @@ exports.ManagedResolverFactory = exports.ManagedReference = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* 管理对象解析构建
|
|
6
6
|
*/
|
|
7
|
-
const
|
|
8
|
-
const constants_1 = require("../common/constants");
|
|
7
|
+
const constants_1 = require("../constants");
|
|
9
8
|
const interface_1 = require("../interface");
|
|
10
9
|
const util = require("util");
|
|
11
10
|
const error_1 = require("../error");
|
|
11
|
+
const decorator_1 = require("../decorator");
|
|
12
12
|
const debug = util.debuglog('midway:managedresolver');
|
|
13
13
|
const debugLog = util.debuglog('midway:debug');
|
|
14
14
|
class ManagedReference {
|
|
@@ -128,8 +128,8 @@ class ManagedResolverFactory {
|
|
|
128
128
|
// binding ctx object
|
|
129
129
|
if (definition.isRequestScope() &&
|
|
130
130
|
definition.constructor.name === 'ObjectDefinition') {
|
|
131
|
-
Object.defineProperty(inst,
|
|
132
|
-
value: this.context.get(
|
|
131
|
+
Object.defineProperty(inst, constants_1.REQUEST_OBJ_CTX_KEY, {
|
|
132
|
+
value: this.context.get(constants_1.REQUEST_CTX_KEY),
|
|
133
133
|
writable: false,
|
|
134
134
|
enumerable: false,
|
|
135
135
|
});
|
|
@@ -218,8 +218,8 @@ class ManagedResolverFactory {
|
|
|
218
218
|
if (definition.isRequestScope() &&
|
|
219
219
|
definition.constructor.name === 'ObjectDefinition') {
|
|
220
220
|
debug('id = %s inject ctx', definition.id);
|
|
221
|
-
Object.defineProperty(inst,
|
|
222
|
-
value: this.context.get(
|
|
221
|
+
Object.defineProperty(inst, constants_1.REQUEST_OBJ_CTX_KEY, {
|
|
222
|
+
value: this.context.get(constants_1.REQUEST_CTX_KEY),
|
|
223
223
|
writable: false,
|
|
224
224
|
enumerable: false,
|
|
225
225
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ObjectIdentifier, ScopeEnum } from '@midwayjs/decorator';
|
|
2
1
|
import { IMidwayContainer } from '../interface';
|
|
2
|
+
import { ObjectIdentifier, ScopeEnum } from '../decorator';
|
|
3
3
|
export declare function providerWrapper(wrapperInfo: Array<{
|
|
4
4
|
id: ObjectIdentifier;
|
|
5
5
|
provider: (context: IMidwayContainer, args?: any) => any;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.providerWrapper = void 0;
|
|
4
|
-
const constants_1 = require("../
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
5
|
function providerWrapper(wrapperInfo) {
|
|
6
6
|
for (const info of wrapperInfo) {
|
|
7
7
|
Object.defineProperty(info.provider, constants_1.FUNCTION_INJECT_KEY, {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MidwayRequestContainer = void 0;
|
|
4
4
|
const container_1 = require("./container");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const decorator_1 = require("../decorator");
|
|
6
|
+
const constants_1 = require("../constants");
|
|
7
7
|
class MidwayRequestContainer extends container_1.MidwayContainer {
|
|
8
8
|
constructor(ctx, applicationContext) {
|
|
9
9
|
super(applicationContext);
|
|
@@ -12,7 +12,7 @@ class MidwayRequestContainer extends container_1.MidwayContainer {
|
|
|
12
12
|
this.registry.setIdentifierRelation(this.applicationContext.registry.getIdentifierRelation());
|
|
13
13
|
this.ctx = ctx;
|
|
14
14
|
// register ctx
|
|
15
|
-
this.registerObject(
|
|
15
|
+
this.registerObject(constants_1.REQUEST_CTX_KEY, ctx);
|
|
16
16
|
// register res
|
|
17
17
|
this.registerObject('res', {});
|
|
18
18
|
if (ctx.logger) {
|
|
@@ -0,0 +1,20 @@
|
|
|
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
|
+
export declare function Aspect(aspectTarget: any | any[], match?: string | (() => boolean), priority?: number): (target: any) => void;
|
|
20
|
+
//# sourceMappingURL=aspect.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Aspect = void 0;
|
|
4
|
+
const __1 = require("../");
|
|
5
|
+
const objectDef_1 = require("./objectDef");
|
|
6
|
+
function Aspect(aspectTarget, match, priority) {
|
|
7
|
+
return function (target) {
|
|
8
|
+
(0, __1.saveModule)(__1.ASPECT_KEY, target);
|
|
9
|
+
const aspectTargets = [].concat(aspectTarget);
|
|
10
|
+
for (const aspectTarget of aspectTargets) {
|
|
11
|
+
(0, __1.attachClassMetadata)(__1.ASPECT_KEY, {
|
|
12
|
+
aspectTarget,
|
|
13
|
+
match,
|
|
14
|
+
priority,
|
|
15
|
+
}, target);
|
|
16
|
+
}
|
|
17
|
+
(0, objectDef_1.Scope)(__1.ScopeEnum.Singleton)(target);
|
|
18
|
+
(0, __1.Provide)()(target);
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.Aspect = Aspect;
|
|
22
|
+
//# sourceMappingURL=aspect.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Autoload = void 0;
|
|
4
|
+
const decoratorManager_1 = require("../decoratorManager");
|
|
5
|
+
const provide_1 = require("./provide");
|
|
6
|
+
function Autoload() {
|
|
7
|
+
return function (target) {
|
|
8
|
+
(0, decoratorManager_1.savePreloadModule)(target);
|
|
9
|
+
(0, provide_1.Provide)()(target);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
exports.Autoload = Autoload;
|
|
13
|
+
//# sourceMappingURL=autoload.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface IComponentInfo {
|
|
2
|
+
component: any;
|
|
3
|
+
enabledEnvironment?: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface ResolveFilter {
|
|
6
|
+
pattern: string | RegExp;
|
|
7
|
+
filter: (module: any, filter: any, bindModule: any) => any;
|
|
8
|
+
ignoreRequire?: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface InjectionConfigurationOptions {
|
|
11
|
+
imports?: Array<string | IComponentInfo | {
|
|
12
|
+
Configuration: any;
|
|
13
|
+
}>;
|
|
14
|
+
importObjects?: Record<string, unknown>;
|
|
15
|
+
importConfigs?: Array<{
|
|
16
|
+
[environmentName: string]: Record<string, any>;
|
|
17
|
+
}> | Record<string, any>;
|
|
18
|
+
importConfigFilter?: (config: Record<string, any>) => Record<string, any>;
|
|
19
|
+
namespace?: string;
|
|
20
|
+
detectorOptions?: Record<string, any>;
|
|
21
|
+
conflictCheck?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function Configuration(options?: InjectionConfigurationOptions): ClassDecorator;
|
|
24
|
+
//# sourceMappingURL=configuration.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Configuration = void 0;
|
|
4
|
+
const __1 = require("../");
|
|
5
|
+
function Configuration(options = {}) {
|
|
6
|
+
return (target) => {
|
|
7
|
+
(0, __1.saveClassMetadata)(__1.CONFIGURATION_KEY, options, target);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.Configuration = Configuration;
|
|
11
|
+
//# sourceMappingURL=configuration.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function Catch(catchTarget?: any | any[], options?: {
|
|
2
|
+
matchPrototype?: boolean;
|
|
3
|
+
}): (target: any) => void;
|
|
4
|
+
export declare type MatchPattern<CtxOrReq = any, Res = any> = ((ctxOrReq: CtxOrReq, res: Res) => boolean) | string | string[] | boolean;
|
|
5
|
+
export declare function Match(matchPattern?: MatchPattern): (target: any) => void;
|
|
6
|
+
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Match = exports.Catch = void 0;
|
|
4
|
+
const decoratorManager_1 = require("../decoratorManager");
|
|
5
|
+
const constant_1 = require("../constant");
|
|
6
|
+
const objectDef_1 = require("./objectDef");
|
|
7
|
+
const provide_1 = require("./provide");
|
|
8
|
+
const interface_1 = require("../interface");
|
|
9
|
+
function Catch(catchTarget, options = {}) {
|
|
10
|
+
return function (target) {
|
|
11
|
+
const catchTargets = catchTarget ? [].concat(catchTarget) : undefined;
|
|
12
|
+
(0, decoratorManager_1.saveClassMetadata)(constant_1.CATCH_KEY, {
|
|
13
|
+
catchTargets,
|
|
14
|
+
catchOptions: options,
|
|
15
|
+
}, target);
|
|
16
|
+
(0, objectDef_1.Scope)(interface_1.ScopeEnum.Singleton)(target);
|
|
17
|
+
(0, provide_1.Provide)()(target);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
exports.Catch = Catch;
|
|
21
|
+
function Match(matchPattern = true) {
|
|
22
|
+
return function (target) {
|
|
23
|
+
(0, decoratorManager_1.saveClassMetadata)(constant_1.MATCH_KEY, {
|
|
24
|
+
matchPattern,
|
|
25
|
+
}, target);
|
|
26
|
+
(0, objectDef_1.Scope)(interface_1.ScopeEnum.Singleton)(target);
|
|
27
|
+
(0, provide_1.Provide)()(target);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.Match = Match;
|
|
31
|
+
//# sourceMappingURL=filter.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FrameworkType } from '../';
|
|
2
|
+
export declare function Framework(): ClassDecorator;
|
|
3
|
+
export declare function Plugin(identifier?: string): PropertyDecorator;
|
|
4
|
+
export declare function Config(identifier?: string): PropertyDecorator;
|
|
5
|
+
export declare function App(typeOrNamespace?: FrameworkType | string): PropertyDecorator;
|
|
6
|
+
export declare function Logger(identifier?: string): PropertyDecorator;
|
|
7
|
+
export declare function ApplicationContext(): PropertyDecorator;
|
|
8
|
+
//# sourceMappingURL=framework.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApplicationContext = exports.Logger = exports.App = exports.Config = exports.Plugin = exports.Framework = void 0;
|
|
4
|
+
const __1 = require("../");
|
|
5
|
+
function Framework() {
|
|
6
|
+
return (target) => {
|
|
7
|
+
(0, __1.saveModule)(__1.FRAMEWORK_KEY, target);
|
|
8
|
+
(0, __1.Scope)(__1.ScopeEnum.Singleton)(target);
|
|
9
|
+
(0, __1.Provide)()(target);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
exports.Framework = Framework;
|
|
13
|
+
function Plugin(identifier) {
|
|
14
|
+
return (0, __1.createCustomPropertyDecorator)(__1.PLUGIN_KEY, {
|
|
15
|
+
identifier,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
exports.Plugin = Plugin;
|
|
19
|
+
function Config(identifier) {
|
|
20
|
+
return (0, __1.createCustomPropertyDecorator)(__1.CONFIG_KEY, {
|
|
21
|
+
identifier,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.Config = Config;
|
|
25
|
+
function App(typeOrNamespace) {
|
|
26
|
+
return (0, __1.createCustomPropertyDecorator)(__1.APPLICATION_KEY, {
|
|
27
|
+
type: typeOrNamespace,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
exports.App = App;
|
|
31
|
+
function Logger(identifier) {
|
|
32
|
+
return (0, __1.createCustomPropertyDecorator)(__1.LOGGER_KEY, {
|
|
33
|
+
identifier,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
exports.Logger = Logger;
|
|
37
|
+
function ApplicationContext() {
|
|
38
|
+
return (0, __1.createCustomPropertyDecorator)(__1.APPLICATION_CONTEXT_KEY, {});
|
|
39
|
+
}
|
|
40
|
+
exports.ApplicationContext = ApplicationContext;
|
|
41
|
+
//# sourceMappingURL=framework.js.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Guard = exports.UseGuard = void 0;
|
|
4
|
+
const decoratorManager_1 = require("../decoratorManager");
|
|
5
|
+
const constant_1 = require("../constant");
|
|
6
|
+
const provide_1 = require("./provide");
|
|
7
|
+
const objectDef_1 = require("./objectDef");
|
|
8
|
+
const interface_1 = require("../interface");
|
|
9
|
+
function UseGuard(guardOrArr) {
|
|
10
|
+
return (target, propertyKey, descriptor) => {
|
|
11
|
+
if (!Array.isArray(guardOrArr)) {
|
|
12
|
+
guardOrArr = [guardOrArr];
|
|
13
|
+
}
|
|
14
|
+
if (propertyKey) {
|
|
15
|
+
(0, decoratorManager_1.savePropertyMetadata)(constant_1.GUARD_KEY, guardOrArr, target, propertyKey);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
(0, decoratorManager_1.saveClassMetadata)(constant_1.GUARD_KEY, guardOrArr, target);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
exports.UseGuard = UseGuard;
|
|
23
|
+
function Guard() {
|
|
24
|
+
return target => {
|
|
25
|
+
(0, provide_1.Provide)()(target);
|
|
26
|
+
(0, objectDef_1.Scope)(interface_1.ScopeEnum.Singleton)(target);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.Guard = Guard;
|
|
30
|
+
//# sourceMappingURL=guard.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Inject = void 0;
|
|
4
|
+
const decoratorManager_1 = require("../decoratorManager");
|
|
5
|
+
function Inject(identifier) {
|
|
6
|
+
return function (target, targetKey) {
|
|
7
|
+
(0, decoratorManager_1.savePropertyInject)({ target, targetKey, identifier });
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.Inject = Inject;
|
|
11
|
+
//# sourceMappingURL=inject.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Middleware = void 0;
|
|
4
|
+
const __1 = require("../");
|
|
5
|
+
function Middleware() {
|
|
6
|
+
return (target) => {
|
|
7
|
+
(0, __1.Scope)(__1.ScopeEnum.Singleton)(target);
|
|
8
|
+
(0, __1.Provide)()(target);
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
exports.Middleware = Middleware;
|
|
12
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ScopeEnum } from '../interface';
|
|
2
|
+
export declare function Init(): MethodDecorator;
|
|
3
|
+
export declare function Destroy(): MethodDecorator;
|
|
4
|
+
export declare function Scope(scope: ScopeEnum, scopeOptions?: {
|
|
5
|
+
allowDowngrade?: boolean;
|
|
6
|
+
}): ClassDecorator;
|
|
7
|
+
//# sourceMappingURL=objectDef.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Scope = exports.Destroy = exports.Init = void 0;
|
|
4
|
+
const decoratorManager_1 = require("../decoratorManager");
|
|
5
|
+
function Init() {
|
|
6
|
+
return function (target, propertyKey) {
|
|
7
|
+
(0, decoratorManager_1.saveObjectDefinition)(target, { initMethod: propertyKey });
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.Init = Init;
|
|
11
|
+
function Destroy() {
|
|
12
|
+
return function (target, propertyKey) {
|
|
13
|
+
(0, decoratorManager_1.saveObjectDefinition)(target, {
|
|
14
|
+
destroyMethod: propertyKey,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
exports.Destroy = Destroy;
|
|
19
|
+
function Scope(scope, scopeOptions) {
|
|
20
|
+
return function (target) {
|
|
21
|
+
(0, decoratorManager_1.saveObjectDefinition)(target, { scope, ...scopeOptions });
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
exports.Scope = Scope;
|
|
25
|
+
//# sourceMappingURL=objectDef.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Pipeline = void 0;
|
|
4
|
+
const decoratorManager_1 = require("../decoratorManager");
|
|
5
|
+
const constant_1 = require("../constant");
|
|
6
|
+
function Pipeline(valves) {
|
|
7
|
+
return (0, decoratorManager_1.createCustomPropertyDecorator)(constant_1.PIPELINE_IDENTIFIER, {
|
|
8
|
+
valves,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
exports.Pipeline = Pipeline;
|
|
12
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Provide = void 0;
|
|
4
|
+
const decoratorManager_1 = require("../decoratorManager");
|
|
5
|
+
function Provide(identifier) {
|
|
6
|
+
return function (target) {
|
|
7
|
+
return (0, decoratorManager_1.saveProviderId)(identifier, target);
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
exports.Provide = Provide;
|
|
11
|
+
//# sourceMappingURL=provide.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export declare const ALL = "common:all_value_key";
|
|
2
|
+
export declare const SCHEDULE_KEY = "common:schedule";
|
|
3
|
+
export declare const CONFIGURATION_KEY = "common:configuration";
|
|
4
|
+
export declare const FRAMEWORK_KEY = "common:framework";
|
|
5
|
+
export declare const ASPECT_KEY = "common:aspect";
|
|
6
|
+
export declare const CATCH_KEY = "common:catch";
|
|
7
|
+
export declare const MATCH_KEY = "common:match";
|
|
8
|
+
export declare const GUARD_KEY = "common:guard";
|
|
9
|
+
export declare const FUNC_KEY = "faas:func";
|
|
10
|
+
export declare const SERVERLESS_FUNC_KEY = "faas:serverless:function";
|
|
11
|
+
export declare const CONTROLLER_KEY = "web:controller";
|
|
12
|
+
export declare const WEB_ROUTER_KEY = "web:router";
|
|
13
|
+
export declare const WEB_ROUTER_PARAM_KEY = "web:router_param";
|
|
14
|
+
export declare const WEB_RESPONSE_KEY = "web:response";
|
|
15
|
+
export declare const WEB_RESPONSE_HTTP_CODE = "web:response_http_code";
|
|
16
|
+
export declare const WEB_RESPONSE_REDIRECT = "web:response_redirect";
|
|
17
|
+
export declare const WEB_RESPONSE_HEADER = "web:response_header";
|
|
18
|
+
export declare const WEB_RESPONSE_CONTENT_TYPE = "web:response_content_type";
|
|
19
|
+
export declare const WEB_RESPONSE_RENDER = "web:response_render";
|
|
20
|
+
export declare const MODULE_TASK_KEY = "task:task";
|
|
21
|
+
export declare const MODULE_TASK_METADATA = "task:task:options";
|
|
22
|
+
export declare const MODULE_TASK_TASK_LOCAL_KEY = "task:task:task_local";
|
|
23
|
+
export declare const MODULE_TASK_TASK_LOCAL_OPTIONS = "task:task:task_local:options";
|
|
24
|
+
export declare const MODULE_TASK_QUEUE_KEY = "task:task:queue";
|
|
25
|
+
export declare const MODULE_TASK_QUEUE_OPTIONS = "task:task:queue:options";
|
|
26
|
+
export declare const WS_CONTROLLER_KEY = "ws:controller";
|
|
27
|
+
export declare const WS_EVENT_KEY = "ws:event";
|
|
28
|
+
export declare const HSF_KEY = "rpc:hsf";
|
|
29
|
+
export declare const RPC_GRPC_KEY = "rpc:grpc";
|
|
30
|
+
export declare const RPC_DUBBO_KEY = "rpc:dubbo";
|
|
31
|
+
export declare const MS_CONSUMER_KEY = "ms:consumer";
|
|
32
|
+
export declare const MS_PRODUCER_KEY = "ms:producer";
|
|
33
|
+
export declare const MS_PROVIDER_KEY = "ms:provider";
|
|
34
|
+
export declare const MS_GRPC_METHOD_KEY = "ms:grpc:method";
|
|
35
|
+
export declare const MS_DUBBO_METHOD_KEY = "ms:dubbo:method";
|
|
36
|
+
export declare const MS_HSF_METHOD_KEY = "ms:hsf:method";
|
|
37
|
+
export declare const CONFIG_KEY = "config";
|
|
38
|
+
export declare const PLUGIN_KEY = "plugin";
|
|
39
|
+
export declare const LOGGER_KEY = "logger";
|
|
40
|
+
export declare const APPLICATION_KEY = "__midway_framework_app__";
|
|
41
|
+
export declare const APPLICATION_CONTEXT_KEY = "__midway_application_context__";
|
|
42
|
+
export declare const CLASS_KEY_CONSTRUCTOR = "midway:class_key_constructor";
|
|
43
|
+
export declare const NAMED_TAG = "named";
|
|
44
|
+
export declare const INJECT_TAG = "inject";
|
|
45
|
+
export declare const INJECT_CUSTOM_PROPERTY = "inject_custom_property";
|
|
46
|
+
export declare const INJECT_CUSTOM_METHOD = "inject_custom_method";
|
|
47
|
+
export declare const INJECT_CUSTOM_PARAM = "inject_custom_param";
|
|
48
|
+
export declare const TAGGED_CLS = "injection:tagged_class";
|
|
49
|
+
export declare const TAGGED_FUN = "injection:tagged_function";
|
|
50
|
+
export declare const OBJ_DEF_CLS = "injection:object_definition_class";
|
|
51
|
+
export declare const PIPELINE_IDENTIFIER = "__pipeline_identifier__";
|
|
52
|
+
export declare const LIFECYCLE_IDENTIFIER_PREFIX = "__lifecycle__";
|
|
53
|
+
export declare const MAIN_MODULE_KEY = "__main__";
|
|
54
|
+
export declare const PRIVATE_META_DATA_KEY = "__midway_private_meta_data__";
|
|
55
|
+
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OBJ_DEF_CLS = 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.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 = void 0;
|
|
5
|
+
// got all value with no property name
|
|
6
|
+
exports.ALL = 'common:all_value_key';
|
|
7
|
+
// common
|
|
8
|
+
exports.SCHEDULE_KEY = 'common:schedule';
|
|
9
|
+
exports.CONFIGURATION_KEY = 'common:configuration';
|
|
10
|
+
exports.FRAMEWORK_KEY = 'common:framework';
|
|
11
|
+
exports.ASPECT_KEY = 'common:aspect';
|
|
12
|
+
exports.CATCH_KEY = 'common:catch';
|
|
13
|
+
exports.MATCH_KEY = 'common:match';
|
|
14
|
+
exports.GUARD_KEY = 'common:guard';
|
|
15
|
+
// faas
|
|
16
|
+
exports.FUNC_KEY = 'faas:func';
|
|
17
|
+
exports.SERVERLESS_FUNC_KEY = 'faas:serverless:function';
|
|
18
|
+
// web
|
|
19
|
+
exports.CONTROLLER_KEY = 'web:controller';
|
|
20
|
+
exports.WEB_ROUTER_KEY = 'web:router';
|
|
21
|
+
exports.WEB_ROUTER_PARAM_KEY = 'web:router_param';
|
|
22
|
+
exports.WEB_RESPONSE_KEY = 'web:response';
|
|
23
|
+
exports.WEB_RESPONSE_HTTP_CODE = 'web:response_http_code';
|
|
24
|
+
exports.WEB_RESPONSE_REDIRECT = 'web:response_redirect';
|
|
25
|
+
exports.WEB_RESPONSE_HEADER = 'web:response_header';
|
|
26
|
+
exports.WEB_RESPONSE_CONTENT_TYPE = 'web:response_content_type';
|
|
27
|
+
exports.WEB_RESPONSE_RENDER = 'web:response_render';
|
|
28
|
+
// task
|
|
29
|
+
exports.MODULE_TASK_KEY = 'task:task';
|
|
30
|
+
exports.MODULE_TASK_METADATA = 'task:task:options';
|
|
31
|
+
exports.MODULE_TASK_TASK_LOCAL_KEY = 'task:task:task_local';
|
|
32
|
+
exports.MODULE_TASK_TASK_LOCAL_OPTIONS = 'task:task:task_local:options';
|
|
33
|
+
exports.MODULE_TASK_QUEUE_KEY = 'task:task:queue';
|
|
34
|
+
exports.MODULE_TASK_QUEUE_OPTIONS = 'task:task:queue:options';
|
|
35
|
+
// ws
|
|
36
|
+
exports.WS_CONTROLLER_KEY = 'ws:controller';
|
|
37
|
+
exports.WS_EVENT_KEY = 'ws:event';
|
|
38
|
+
// RPC
|
|
39
|
+
exports.HSF_KEY = 'rpc:hsf';
|
|
40
|
+
exports.RPC_GRPC_KEY = 'rpc:grpc';
|
|
41
|
+
exports.RPC_DUBBO_KEY = 'rpc:dubbo';
|
|
42
|
+
// microservice
|
|
43
|
+
exports.MS_CONSUMER_KEY = 'ms:consumer';
|
|
44
|
+
exports.MS_PRODUCER_KEY = 'ms:producer';
|
|
45
|
+
exports.MS_PROVIDER_KEY = 'ms:provider';
|
|
46
|
+
// rpc method
|
|
47
|
+
exports.MS_GRPC_METHOD_KEY = 'ms:grpc:method';
|
|
48
|
+
exports.MS_DUBBO_METHOD_KEY = 'ms:dubbo:method';
|
|
49
|
+
exports.MS_HSF_METHOD_KEY = 'ms:hsf:method';
|
|
50
|
+
// framework
|
|
51
|
+
exports.CONFIG_KEY = 'config';
|
|
52
|
+
exports.PLUGIN_KEY = 'plugin';
|
|
53
|
+
exports.LOGGER_KEY = 'logger';
|
|
54
|
+
exports.APPLICATION_KEY = '__midway_framework_app__';
|
|
55
|
+
exports.APPLICATION_CONTEXT_KEY = '__midway_application_context__';
|
|
56
|
+
////////////////////////////////////////// inject keys
|
|
57
|
+
// constructor key
|
|
58
|
+
exports.CLASS_KEY_CONSTRUCTOR = 'midway:class_key_constructor';
|
|
59
|
+
// Used for named bindings
|
|
60
|
+
exports.NAMED_TAG = 'named';
|
|
61
|
+
// The name of the target at design time
|
|
62
|
+
exports.INJECT_TAG = 'inject';
|
|
63
|
+
// The name inject custom property decorator with resolver
|
|
64
|
+
exports.INJECT_CUSTOM_PROPERTY = 'inject_custom_property';
|
|
65
|
+
// The name inject custom param decorator with resolver
|
|
66
|
+
exports.INJECT_CUSTOM_METHOD = 'inject_custom_method';
|
|
67
|
+
// The name inject custom param decorator with resolver
|
|
68
|
+
exports.INJECT_CUSTOM_PARAM = 'inject_custom_param';
|
|
69
|
+
//
|
|
70
|
+
// // used to store constructor arguments tags
|
|
71
|
+
// export const TAGGED = 'injection:tagged';
|
|
72
|
+
//
|
|
73
|
+
// // used to store class properties tags
|
|
74
|
+
// export const TAGGED_PROP = 'injection:tagged_props';
|
|
75
|
+
// used to store class to be injected
|
|
76
|
+
exports.TAGGED_CLS = 'injection:tagged_class';
|
|
77
|
+
// used to store function to be injected
|
|
78
|
+
exports.TAGGED_FUN = 'injection:tagged_function';
|
|
79
|
+
exports.OBJ_DEF_CLS = 'injection:object_definition_class';
|
|
80
|
+
// pipeline
|
|
81
|
+
exports.PIPELINE_IDENTIFIER = '__pipeline_identifier__';
|
|
82
|
+
// lifecycle interface
|
|
83
|
+
exports.LIFECYCLE_IDENTIFIER_PREFIX = '__lifecycle__';
|
|
84
|
+
exports.MAIN_MODULE_KEY = '__main__';
|
|
85
|
+
exports.PRIVATE_META_DATA_KEY = '__midway_private_meta_data__';
|
|
86
|
+
//# sourceMappingURL=constant.js.map
|