@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.
- package/dist/baseFramework.d.ts +5 -2
- package/dist/baseFramework.js +17 -0
- package/dist/common/applicationManager.d.ts +1 -2
- package/dist/common/applicationManager.js +2 -1
- package/dist/common/dataSourceManager.d.ts +1 -0
- package/dist/common/dataSourceManager.js +14 -12
- package/dist/common/loggerFactory.d.ts +8 -0
- package/dist/common/loggerFactory.js +7 -0
- package/dist/common/serviceFactory.d.ts +3 -2
- package/dist/common/webGenerator.js +2 -1
- package/dist/config/config.default.js +2 -1
- package/dist/constants.d.ts +1 -11
- package/dist/constants.js +2 -12
- package/dist/context/container.d.ts +1 -2
- package/dist/context/container.js +3 -3
- package/dist/context/definitionRegistry.d.ts +1 -5
- package/dist/context/managedResolverFactory.d.ts +1 -2
- package/dist/context/managedResolverFactory.js +2 -3
- package/dist/context/providerWrapper.d.ts +1 -2
- package/dist/decorator/common/aspect.d.ts +0 -18
- package/dist/decorator/common/aspect.js +2 -1
- package/dist/decorator/common/filter.d.ts +1 -1
- package/dist/decorator/common/filter.js +1 -1
- package/dist/decorator/common/framework.d.ts +1 -1
- package/dist/decorator/common/framework.js +2 -1
- package/dist/decorator/common/guard.js +1 -1
- package/dist/decorator/common/inject.d.ts +2 -1
- package/dist/decorator/common/inject.js +9 -1
- package/dist/decorator/common/middleware.js +2 -1
- package/dist/decorator/common/mock.d.ts +2 -0
- package/dist/decorator/common/mock.js +14 -0
- package/dist/decorator/common/objectDef.d.ts +2 -1
- package/dist/decorator/common/objectDef.js +10 -1
- package/dist/decorator/common/pipe.d.ts +2 -0
- package/dist/decorator/common/pipe.js +13 -0
- package/dist/decorator/common/pipeline.d.ts +1 -1
- package/dist/decorator/common/provide.d.ts +1 -1
- package/dist/decorator/constant.d.ts +2 -0
- package/dist/decorator/constant.js +4 -2
- package/dist/decorator/decoratorManager.d.ts +6 -10
- package/dist/decorator/decoratorManager.js +20 -8
- package/dist/decorator/faas/serverlessTrigger.d.ts +3 -1
- package/dist/decorator/faas/serverlessTrigger.js +3 -2
- package/dist/decorator/index.d.ts +2 -1
- package/dist/decorator/index.js +2 -1
- package/dist/decorator/microservice/consumer.d.ts +1 -1
- package/dist/decorator/microservice/consumer.js +2 -1
- package/dist/decorator/microservice/kafkaListener.d.ts +3 -3
- package/dist/decorator/microservice/provider.d.ts +1 -1
- package/dist/decorator/microservice/provider.js +2 -1
- package/dist/decorator/rpc/hsf.d.ts +1 -0
- package/dist/decorator/rpc/hsf.js +3 -1
- package/dist/decorator/task/schedule.js +2 -1
- package/dist/decorator/web/controller.d.ts +1 -1
- package/dist/decorator/web/controller.js +2 -1
- package/dist/decorator/web/requestMapping.d.ts +1 -4
- package/dist/decorator/ws/webSocketController.d.ts +1 -1
- package/dist/decorator/ws/webSocketController.js +2 -1
- package/dist/decorator/ws/webSocketEvent.d.ts +1 -1
- package/dist/definitions/functionDefinition.d.ts +1 -2
- package/dist/definitions/functionDefinition.js +4 -4
- package/dist/definitions/objectDefinition.d.ts +1 -2
- package/dist/definitions/objectDefinition.js +4 -4
- package/dist/definitions/properties.d.ts +1 -2
- package/dist/error/base.d.ts +2 -2
- package/dist/error/framework.d.ts +1 -1
- package/dist/error/framework.js +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/interface.d.ts +344 -25
- package/dist/interface.js +64 -1
- package/dist/service/aspectService.d.ts +1 -2
- package/dist/service/aspectService.js +2 -1
- package/dist/service/configService.js +2 -1
- package/dist/service/decoratorService.d.ts +3 -1
- package/dist/service/decoratorService.js +64 -12
- package/dist/service/environmentService.js +2 -1
- package/dist/service/frameworkService.d.ts +1 -2
- package/dist/service/frameworkService.js +21 -1
- package/dist/service/informationService.js +2 -1
- package/dist/service/lifeCycleService.d.ts +2 -0
- package/dist/service/lifeCycleService.js +14 -4
- package/dist/service/loggerService.d.ts +11 -7
- package/dist/service/loggerService.js +31 -9
- package/dist/service/middlewareService.js +2 -1
- package/dist/service/mockService.d.ts +9 -1
- package/dist/service/mockService.js +43 -1
- package/dist/service/pipelineService.d.ts +2 -3
- package/dist/service/slsFunctionService.d.ts +1 -1
- package/dist/service/slsFunctionService.js +3 -2
- package/dist/service/webRouterService.d.ts +1 -1
- package/dist/service/webRouterService.js +3 -2
- package/dist/setup.js +6 -2
- package/dist/util/camelCase.js +8 -5
- package/dist/util/httpclient.d.ts +2 -2
- package/dist/util/pathToRegexp.d.ts +5 -5
- package/dist/util/webRouterParam.d.ts +2 -4
- package/dist/util/webRouterParam.js +5 -27
- package/package.json +5 -6
- package/dist/decorator/interface.d.ts +0 -242
- package/dist/decorator/interface.js +0 -66
package/dist/interface.d.ts
CHANGED
|
@@ -1,11 +1,306 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { LoggerOptions, LoggerContextFormat } from '@midwayjs/logger';
|
|
3
3
|
import * as EventEmitter from 'events';
|
|
4
4
|
import type { AsyncContextManager } from './common/asyncContextManager';
|
|
5
|
-
import type {
|
|
6
|
-
|
|
5
|
+
import type { LoggerFactory } from './common/loggerFactory';
|
|
6
|
+
export type MiddlewareParamArray = Array<string | any>;
|
|
7
|
+
export type ObjectIdentifier = string | Symbol;
|
|
8
|
+
export type GroupModeType = 'one' | 'multi';
|
|
9
|
+
export declare enum ScopeEnum {
|
|
10
|
+
Singleton = "Singleton",
|
|
11
|
+
Request = "Request",
|
|
12
|
+
Prototype = "Prototype"
|
|
13
|
+
}
|
|
14
|
+
export declare enum InjectModeEnum {
|
|
15
|
+
Identifier = "Identifier",
|
|
16
|
+
Class = "Class",
|
|
17
|
+
PropertyName = "PropertyName"
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 内部管理的属性、json、ref等解析实例存储
|
|
21
|
+
*/
|
|
22
|
+
export interface IManagedInstance {
|
|
23
|
+
type: string;
|
|
24
|
+
value?: any;
|
|
25
|
+
args?: any;
|
|
26
|
+
}
|
|
27
|
+
export interface ObjectDefinitionOptions {
|
|
28
|
+
isAsync?: boolean;
|
|
29
|
+
initMethod?: string;
|
|
30
|
+
destroyMethod?: string;
|
|
31
|
+
scope?: ScopeEnum;
|
|
32
|
+
constructorArgs?: any[];
|
|
33
|
+
namespace?: string;
|
|
34
|
+
srcPath?: string;
|
|
35
|
+
allowDowngrade?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface TagPropsMetadata {
|
|
38
|
+
key: string | number | symbol;
|
|
39
|
+
value: any;
|
|
40
|
+
args?: any;
|
|
41
|
+
}
|
|
42
|
+
export interface TagClsMetadata {
|
|
43
|
+
id: string;
|
|
44
|
+
originName: string;
|
|
45
|
+
uuid: string;
|
|
46
|
+
name: string;
|
|
47
|
+
}
|
|
48
|
+
export interface ReflectResult {
|
|
49
|
+
[key: string]: any[];
|
|
50
|
+
}
|
|
51
|
+
export declare enum MSProviderType {
|
|
52
|
+
DUBBO = "dubbo",
|
|
53
|
+
GRPC = "gRPC"
|
|
54
|
+
}
|
|
55
|
+
export declare enum MSListenerType {
|
|
56
|
+
RABBITMQ = "rabbitmq",
|
|
57
|
+
MQTT = "mqtt",
|
|
58
|
+
KAFKA = "kafka",
|
|
59
|
+
REDIS = "redis"
|
|
60
|
+
}
|
|
61
|
+
export declare namespace ConsumerMetadata {
|
|
62
|
+
interface ConsumerMetadata {
|
|
63
|
+
type: MSListenerType;
|
|
64
|
+
metadata: any;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* grpc decorator metadata format
|
|
69
|
+
*/
|
|
70
|
+
export declare namespace GRPCMetadata {
|
|
71
|
+
interface ProviderOptions {
|
|
72
|
+
serviceName?: string;
|
|
73
|
+
package?: string;
|
|
74
|
+
}
|
|
75
|
+
interface ProviderMetadata {
|
|
76
|
+
type: MSProviderType;
|
|
77
|
+
metadata: ProviderOptions;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export declare namespace FaaSMetadata {
|
|
81
|
+
export interface ServerlessFunctionOptions {
|
|
82
|
+
/**
|
|
83
|
+
* function name
|
|
84
|
+
*/
|
|
85
|
+
functionName?: string;
|
|
86
|
+
/**
|
|
87
|
+
* function description
|
|
88
|
+
*/
|
|
89
|
+
description?: string;
|
|
90
|
+
/**
|
|
91
|
+
* function memory size, unit: M
|
|
92
|
+
*/
|
|
93
|
+
memorySize?: number;
|
|
94
|
+
/**
|
|
95
|
+
* function timeout value, unit: seconds
|
|
96
|
+
*/
|
|
97
|
+
timeout?: number;
|
|
98
|
+
/**
|
|
99
|
+
* function init timeout, just for aliyun
|
|
100
|
+
*/
|
|
101
|
+
initTimeout?: number;
|
|
102
|
+
/**
|
|
103
|
+
* function runtime, nodejs10, nodejs12, nodejs14
|
|
104
|
+
*/
|
|
105
|
+
runtime?: string;
|
|
106
|
+
/**
|
|
107
|
+
* invoke concurrency, just for aliyun
|
|
108
|
+
*/
|
|
109
|
+
concurrency?: number;
|
|
110
|
+
/**
|
|
111
|
+
* function invoke stage, like env, just for tencent
|
|
112
|
+
*/
|
|
113
|
+
stage?: string;
|
|
114
|
+
/**
|
|
115
|
+
* environment variable, key-value
|
|
116
|
+
*/
|
|
117
|
+
environment?: any;
|
|
118
|
+
/**
|
|
119
|
+
* deploy or not
|
|
120
|
+
*/
|
|
121
|
+
isDeploy?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* function handler name, like 'index.handler'
|
|
124
|
+
*/
|
|
125
|
+
handlerName?: string;
|
|
126
|
+
}
|
|
127
|
+
interface TriggerCommonOptions {
|
|
128
|
+
/**
|
|
129
|
+
* function name
|
|
130
|
+
*/
|
|
131
|
+
functionName?: string;
|
|
132
|
+
/**
|
|
133
|
+
* serverless event name
|
|
134
|
+
*/
|
|
135
|
+
name?: string;
|
|
136
|
+
/**
|
|
137
|
+
* function invoke role, just for aliyun
|
|
138
|
+
*/
|
|
139
|
+
role?: string;
|
|
140
|
+
/**
|
|
141
|
+
* function publish version, just for aliyun
|
|
142
|
+
*/
|
|
143
|
+
version?: string;
|
|
144
|
+
/**
|
|
145
|
+
* deploy or not
|
|
146
|
+
*/
|
|
147
|
+
isDeploy?: boolean;
|
|
148
|
+
/**
|
|
149
|
+
* function middleware
|
|
150
|
+
*/
|
|
151
|
+
middleware?: any[];
|
|
152
|
+
}
|
|
153
|
+
export interface EventTriggerOptions extends TriggerCommonOptions {
|
|
154
|
+
}
|
|
155
|
+
export interface HTTPTriggerOptions extends TriggerCommonOptions {
|
|
156
|
+
path: string;
|
|
157
|
+
method?: 'get' | 'post' | 'delete' | 'put' | 'head' | 'patch' | 'all';
|
|
158
|
+
}
|
|
159
|
+
export interface APIGatewayTriggerOptions extends HTTPTriggerOptions {
|
|
160
|
+
}
|
|
161
|
+
export interface OSTriggerOptions extends TriggerCommonOptions {
|
|
162
|
+
bucket: string;
|
|
163
|
+
events: string | string[];
|
|
164
|
+
filter?: {
|
|
165
|
+
prefix: string;
|
|
166
|
+
suffix: string;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export interface LogTriggerOptions extends TriggerCommonOptions {
|
|
170
|
+
source: string;
|
|
171
|
+
project: string;
|
|
172
|
+
log: string;
|
|
173
|
+
retryTime?: number;
|
|
174
|
+
interval?: number;
|
|
175
|
+
}
|
|
176
|
+
export interface TimerTriggerOptions extends TriggerCommonOptions {
|
|
177
|
+
type: 'cron' | 'every' | 'interval';
|
|
178
|
+
value: string;
|
|
179
|
+
payload?: string;
|
|
180
|
+
enable?: boolean;
|
|
181
|
+
}
|
|
182
|
+
export interface MQTriggerOptions extends TriggerCommonOptions {
|
|
183
|
+
topic: string;
|
|
184
|
+
tags?: string;
|
|
185
|
+
region?: string;
|
|
186
|
+
strategy?: 'BACKOFF_RETRY' | 'EXPONENTIAL_DECAY_RETRY';
|
|
187
|
+
}
|
|
188
|
+
export interface HSFTriggerOptions extends TriggerCommonOptions {
|
|
189
|
+
}
|
|
190
|
+
export interface MTopTriggerOptions extends TriggerCommonOptions {
|
|
191
|
+
}
|
|
192
|
+
export interface SSRTriggerOptions extends HTTPTriggerOptions {
|
|
193
|
+
}
|
|
194
|
+
export interface CDNTriggerOptions extends TriggerCommonOptions {
|
|
195
|
+
}
|
|
196
|
+
export type EventTriggerUnionOptions = EventTriggerOptions | HTTPTriggerOptions | APIGatewayTriggerOptions | OSTriggerOptions | CDNTriggerOptions | LogTriggerOptions | TimerTriggerOptions | MQTriggerOptions | HSFTriggerOptions | MTopTriggerOptions | SSRTriggerOptions;
|
|
197
|
+
export interface TriggerMetadata {
|
|
198
|
+
type: ServerlessTriggerType | string;
|
|
199
|
+
functionName?: string;
|
|
200
|
+
handlerName?: string;
|
|
201
|
+
methodName?: string;
|
|
202
|
+
metadata: EventTriggerUnionOptions;
|
|
203
|
+
}
|
|
204
|
+
export {};
|
|
205
|
+
}
|
|
206
|
+
export declare abstract class FrameworkType {
|
|
207
|
+
abstract name: string;
|
|
208
|
+
}
|
|
209
|
+
export declare class MidwayFrameworkType extends FrameworkType {
|
|
210
|
+
name: string;
|
|
211
|
+
static WEB: MidwayFrameworkType;
|
|
212
|
+
static WEB_KOA: MidwayFrameworkType;
|
|
213
|
+
static WEB_EXPRESS: MidwayFrameworkType;
|
|
214
|
+
static FAAS: MidwayFrameworkType;
|
|
215
|
+
static MS_GRPC: MidwayFrameworkType;
|
|
216
|
+
static MS_RABBITMQ: MidwayFrameworkType;
|
|
217
|
+
static MS_KAFKA: MidwayFrameworkType;
|
|
218
|
+
static WS_IO: MidwayFrameworkType;
|
|
219
|
+
static WS: MidwayFrameworkType;
|
|
220
|
+
static SERVERLESS_APP: MidwayFrameworkType;
|
|
221
|
+
static CUSTOM: MidwayFrameworkType;
|
|
222
|
+
static EMPTY: MidwayFrameworkType;
|
|
223
|
+
static LIGHT: MidwayFrameworkType;
|
|
224
|
+
static TASK: MidwayFrameworkType;
|
|
225
|
+
constructor(name: string);
|
|
226
|
+
}
|
|
227
|
+
export declare enum ServerlessTriggerType {
|
|
228
|
+
EVENT = "event",
|
|
229
|
+
HTTP = "http",
|
|
230
|
+
API_GATEWAY = "apigw",
|
|
231
|
+
OS = "os",
|
|
232
|
+
CDN = "cdn",
|
|
233
|
+
LOG = "log",
|
|
234
|
+
TIMER = "timer",
|
|
235
|
+
MQ = "mq",
|
|
236
|
+
KAFKA = "kafka",
|
|
237
|
+
HSF = "hsf",
|
|
238
|
+
MTOP = "mtop",
|
|
239
|
+
SSR = "ssr"
|
|
240
|
+
}
|
|
241
|
+
export interface JoinPoint {
|
|
242
|
+
methodName: string;
|
|
243
|
+
target: any;
|
|
244
|
+
args: any[];
|
|
245
|
+
proceed?(...args: any[]): any;
|
|
246
|
+
}
|
|
247
|
+
export interface AspectMetadata {
|
|
248
|
+
aspectTarget: any;
|
|
249
|
+
match?: string | (() => boolean);
|
|
250
|
+
priority?: number;
|
|
251
|
+
}
|
|
252
|
+
export interface IMethodAspect {
|
|
253
|
+
after?(joinPoint: JoinPoint, result: any, error: Error): any;
|
|
254
|
+
afterReturn?(joinPoint: JoinPoint, result: any): any;
|
|
255
|
+
afterThrow?(joinPoint: JoinPoint, error: Error): void;
|
|
256
|
+
before?(joinPoint: JoinPoint): void;
|
|
257
|
+
around?(joinPoint: JoinPoint): any;
|
|
258
|
+
}
|
|
259
|
+
export interface IModuleStore {
|
|
260
|
+
listModule(key: string): any;
|
|
261
|
+
saveModule(key: string, module: any): any;
|
|
262
|
+
transformModule?(moduleMap: Map<string, Set<any>>): any;
|
|
263
|
+
}
|
|
264
|
+
export interface TSDesignType<OriginType = unknown> {
|
|
265
|
+
name: string;
|
|
266
|
+
originDesign: OriginType;
|
|
267
|
+
isBaseType: boolean;
|
|
268
|
+
}
|
|
269
|
+
export interface TransformOptions<OriginType = unknown> {
|
|
270
|
+
metaType: TSDesignType<OriginType>;
|
|
271
|
+
metadata: any;
|
|
272
|
+
/**
|
|
273
|
+
* current instance
|
|
274
|
+
*/
|
|
275
|
+
target: any;
|
|
276
|
+
/**
|
|
277
|
+
* the name of method
|
|
278
|
+
*/
|
|
279
|
+
methodName: string;
|
|
280
|
+
}
|
|
281
|
+
export interface PipeTransform<T = unknown, R = unknown> {
|
|
282
|
+
transform(value: T, transformOptions: TransformOptions): R;
|
|
283
|
+
}
|
|
284
|
+
export type PipeTransformFunction<T = any, R = any> = (value: T) => R;
|
|
285
|
+
export type PipeUnionTransform<T = any, R = any> = PipeTransform<T, R> | (new (...args: any[]) => PipeTransform<T, R>) | PipeTransformFunction<T, R>;
|
|
286
|
+
export interface MethodDecoratorOptions {
|
|
287
|
+
impl?: boolean;
|
|
288
|
+
}
|
|
289
|
+
export interface ParamDecoratorOptions {
|
|
290
|
+
impl?: boolean;
|
|
291
|
+
throwError?: boolean;
|
|
292
|
+
pipes?: PipeUnionTransform<any, any>[];
|
|
293
|
+
}
|
|
294
|
+
export interface ILogger {
|
|
295
|
+
info(msg: any, ...args: any[]): void;
|
|
296
|
+
debug(msg: any, ...args: any[]): void;
|
|
297
|
+
error(msg: any, ...args: any[]): void;
|
|
298
|
+
warn(msg: any, ...args: any[]): void;
|
|
299
|
+
}
|
|
7
300
|
export interface MidwayCoreDefaultConfig {
|
|
8
|
-
midwayLogger?: ServiceFactoryConfigOption<LoggerOptions
|
|
301
|
+
midwayLogger?: ServiceFactoryConfigOption<LoggerOptions & {
|
|
302
|
+
lazyLoad?: boolean;
|
|
303
|
+
}>;
|
|
9
304
|
debug?: {
|
|
10
305
|
recordConfigMergeOrder?: boolean;
|
|
11
306
|
};
|
|
@@ -13,10 +308,10 @@ export interface MidwayCoreDefaultConfig {
|
|
|
13
308
|
enable: boolean;
|
|
14
309
|
};
|
|
15
310
|
}
|
|
16
|
-
export
|
|
311
|
+
export type PowerPartial<T> = {
|
|
17
312
|
[U in keyof T]?: T[U] extends {} ? PowerPartial<T[U]> : T[U];
|
|
18
313
|
};
|
|
19
|
-
export
|
|
314
|
+
export type ServiceFactoryConfigOption<OPTIONS> = {
|
|
20
315
|
default?: PowerPartial<OPTIONS>;
|
|
21
316
|
client?: PowerPartial<OPTIONS>;
|
|
22
317
|
clients?: {
|
|
@@ -24,7 +319,7 @@ export declare type ServiceFactoryConfigOption<OPTIONS> = {
|
|
|
24
319
|
};
|
|
25
320
|
defaultClientName?: string;
|
|
26
321
|
};
|
|
27
|
-
export
|
|
322
|
+
export type DataSourceManagerConfigOption<OPTIONS> = {
|
|
28
323
|
default?: PowerPartial<OPTIONS>;
|
|
29
324
|
defaultDataSourceName?: string;
|
|
30
325
|
dataSource?: {
|
|
@@ -33,15 +328,15 @@ export declare type DataSourceManagerConfigOption<OPTIONS> = {
|
|
|
33
328
|
} & OPTIONS>;
|
|
34
329
|
};
|
|
35
330
|
};
|
|
36
|
-
|
|
331
|
+
type ConfigType<T> = T extends (...args: any[]) => any ? Writable<PowerPartial<ReturnType<T>>> : Writable<PowerPartial<T>>;
|
|
37
332
|
/**
|
|
38
333
|
* Get definition from config
|
|
39
334
|
*/
|
|
40
|
-
export
|
|
335
|
+
export type FileConfigOption<T, K = unknown> = K extends keyof ConfigType<T> ? Pick<ConfigType<T>, K> : ConfigType<T>;
|
|
41
336
|
/**
|
|
42
337
|
* Make object property writeable
|
|
43
338
|
*/
|
|
44
|
-
export
|
|
339
|
+
export type Writable<T> = {
|
|
45
340
|
-readonly [P in keyof T]: T[P];
|
|
46
341
|
};
|
|
47
342
|
/**
|
|
@@ -54,7 +349,7 @@ export interface ILifeCycle extends Partial<IObjectLifeCycle> {
|
|
|
54
349
|
onServerReady?(container: IMidwayContainer, mainApp?: IMidwayApplication): Promise<void>;
|
|
55
350
|
onStop?(container: IMidwayContainer, mainApp?: IMidwayApplication): Promise<void>;
|
|
56
351
|
}
|
|
57
|
-
export
|
|
352
|
+
export type ObjectContext = {
|
|
58
353
|
originName?: string;
|
|
59
354
|
};
|
|
60
355
|
/**
|
|
@@ -199,7 +494,7 @@ export interface IManagedResolverFactoryCreateOptions {
|
|
|
199
494
|
args?: any;
|
|
200
495
|
namespace?: string;
|
|
201
496
|
}
|
|
202
|
-
export
|
|
497
|
+
export type HandlerFunction = (
|
|
203
498
|
/**
|
|
204
499
|
* decorator uuid key
|
|
205
500
|
*/
|
|
@@ -208,12 +503,12 @@ key: string,
|
|
|
208
503
|
* decorator set metadata
|
|
209
504
|
*/
|
|
210
505
|
meta: any, instance: any) => any;
|
|
211
|
-
export
|
|
506
|
+
export type MethodHandlerFunction = (options: {
|
|
212
507
|
target: new (...args: any[]) => any;
|
|
213
508
|
propertyName: string;
|
|
214
509
|
metadata: any;
|
|
215
510
|
}) => IMethodAspect;
|
|
216
|
-
export
|
|
511
|
+
export type ParameterHandlerFunction = (options: {
|
|
217
512
|
target: new (...args: any[]) => any;
|
|
218
513
|
propertyName: string;
|
|
219
514
|
metadata: any;
|
|
@@ -259,7 +554,7 @@ export interface IMidwayContainer extends IObjectFactory, IObjectLifeCycle {
|
|
|
259
554
|
/**
|
|
260
555
|
* @deprecated
|
|
261
556
|
*/
|
|
262
|
-
export
|
|
557
|
+
export type IApplicationContext = IMidwayContainer;
|
|
263
558
|
export interface IFileDetector {
|
|
264
559
|
run(container: IMidwayContainer, fileDetectorOptions?: Record<string, any>): any;
|
|
265
560
|
setExtraDetectorOptions(detectorOptions: Record<string, any>): any;
|
|
@@ -308,8 +603,8 @@ export interface Context {
|
|
|
308
603
|
*/
|
|
309
604
|
getAttr<T>(key: string): T;
|
|
310
605
|
}
|
|
311
|
-
export
|
|
312
|
-
export
|
|
606
|
+
export type IMidwayContext<FrameworkContext = unknown> = Context & FrameworkContext;
|
|
607
|
+
export type NextFunction = () => Promise<any>;
|
|
313
608
|
/**
|
|
314
609
|
* Common middleware definition
|
|
315
610
|
*/
|
|
@@ -318,11 +613,11 @@ export interface IMiddleware<CTX, R, N = unknown> {
|
|
|
318
613
|
match?: (ctx: CTX) => boolean;
|
|
319
614
|
ignore?: (ctx: CTX) => boolean;
|
|
320
615
|
}
|
|
321
|
-
export
|
|
322
|
-
export
|
|
323
|
-
export
|
|
324
|
-
export
|
|
325
|
-
export
|
|
616
|
+
export type FunctionMiddleware<CTX, R, N = unknown> = N extends true ? (req: CTX, res: R, next: N) => any : (context: CTX, next: R, options?: any) => any;
|
|
617
|
+
export type ClassMiddleware<CTX, R, N> = new (...args: any[]) => IMiddleware<CTX, R, N>;
|
|
618
|
+
export type CommonMiddleware<CTX, R, N> = ClassMiddleware<CTX, R, N> | FunctionMiddleware<CTX, R, N>;
|
|
619
|
+
export type CommonMiddlewareUnion<CTX, R, N> = CommonMiddleware<CTX, R, N> | Array<CommonMiddleware<CTX, R, N>>;
|
|
620
|
+
export type MiddlewareRespond<CTX, R, N> = (context: CTX, nextOrRes?: N extends true ? R : NextFunction, next?: N) => Promise<any>;
|
|
326
621
|
/**
|
|
327
622
|
* Common Exception Filter definition
|
|
328
623
|
*/
|
|
@@ -330,14 +625,14 @@ export interface IFilter<CTX, R, N> {
|
|
|
330
625
|
catch?(err: Error, ctx: CTX, res?: R, next?: N): any;
|
|
331
626
|
match?(result: any, ctx: CTX, res?: R, next?: N): any;
|
|
332
627
|
}
|
|
333
|
-
export
|
|
628
|
+
export type CommonFilterUnion<CTX, R, N> = (new (...args: any[]) => IFilter<CTX, R, N>) | Array<new (...args: any[]) => IFilter<CTX, R, N>>;
|
|
334
629
|
/**
|
|
335
630
|
* Guard definition
|
|
336
631
|
*/
|
|
337
632
|
export interface IGuard<CTX = unknown> {
|
|
338
633
|
canActivate(ctx: CTX, supplierClz: new (...args: any[]) => any, methodName: string): boolean | Promise<boolean>;
|
|
339
634
|
}
|
|
340
|
-
export
|
|
635
|
+
export type CommonGuardUnion<CTX = unknown> = (new (...args: any[]) => IGuard<CTX>) | Array<new (...args: any[]) => IGuard<CTX>>;
|
|
341
636
|
export interface IMiddlewareManager<CTX, R, N> {
|
|
342
637
|
insertFirst(middleware: CommonMiddlewareUnion<CTX, R, N>): void;
|
|
343
638
|
insertLast(middleware: CommonMiddlewareUnion<CTX, R, N>): void;
|
|
@@ -454,8 +749,12 @@ export interface IMidwayBaseApplication<CTX extends IMidwayContext> {
|
|
|
454
749
|
* @param guard
|
|
455
750
|
*/
|
|
456
751
|
useGuard(guard: CommonGuardUnion<CTX>): void;
|
|
752
|
+
/**
|
|
753
|
+
* get current namespace
|
|
754
|
+
*/
|
|
755
|
+
getNamespace(): string;
|
|
457
756
|
}
|
|
458
|
-
export
|
|
757
|
+
export type IMidwayApplication<T extends IMidwayContext = IMidwayContext, FrameworkApplication = unknown> = IMidwayBaseApplication<T> & FrameworkApplication;
|
|
459
758
|
export interface IMidwayBootstrapOptions {
|
|
460
759
|
[customPropertyKey: string]: any;
|
|
461
760
|
baseDir?: string;
|
|
@@ -474,6 +773,7 @@ export interface IMidwayBootstrapOptions {
|
|
|
474
773
|
[environmentName: string]: Record<string, any>;
|
|
475
774
|
}> | Record<string, any>;
|
|
476
775
|
asyncContextManager?: AsyncContextManager;
|
|
776
|
+
loggerFactory?: LoggerFactory<any, any>;
|
|
477
777
|
}
|
|
478
778
|
export interface IConfigurationOptions {
|
|
479
779
|
logger?: ILogger;
|
|
@@ -506,6 +806,8 @@ export interface IMidwayFramework<APP extends IMidwayApplication<CTX>, CTX exten
|
|
|
506
806
|
useFilter(Filter: CommonFilterUnion<CTX, ResOrNext, Next>): void;
|
|
507
807
|
useGuard(guard: CommonGuardUnion<CTX>): void;
|
|
508
808
|
runGuard(ctx: CTX, supplierClz: new (...args: any[]) => any, methodName: string): Promise<boolean>;
|
|
809
|
+
getNamespace(): string;
|
|
810
|
+
setNamespace(namespace: string): void;
|
|
509
811
|
}
|
|
510
812
|
export interface MidwayAppInfo {
|
|
511
813
|
pkg: Record<string, any>;
|
|
@@ -522,5 +824,22 @@ export interface MidwayAppInfo {
|
|
|
522
824
|
export interface MidwayConfig extends FileConfigOption<MidwayCoreDefaultConfig> {
|
|
523
825
|
[customConfigKey: string]: unknown;
|
|
524
826
|
}
|
|
827
|
+
export interface IServiceFactory<Client> {
|
|
828
|
+
get(clientId: string): Client;
|
|
829
|
+
has(clientId: string): boolean;
|
|
830
|
+
createInstance(config: any, clientId?: string): Promise<Client | undefined>;
|
|
831
|
+
getName(): string;
|
|
832
|
+
stop(): Promise<void>;
|
|
833
|
+
getDefaultClientName(): string;
|
|
834
|
+
}
|
|
835
|
+
export interface ISimulation {
|
|
836
|
+
setup?(): Promise<void>;
|
|
837
|
+
tearDown?(): Promise<void>;
|
|
838
|
+
appSetup?(app: IMidwayApplication): Promise<void>;
|
|
839
|
+
contextSetup?(ctx: IMidwayContext, app: IMidwayApplication): Promise<void>;
|
|
840
|
+
contextTearDown?(ctx: IMidwayContext, app: IMidwayApplication): Promise<void>;
|
|
841
|
+
appTearDown?(app: IMidwayApplication): Promise<void>;
|
|
842
|
+
enableCondition(): boolean | Promise<boolean>;
|
|
843
|
+
}
|
|
525
844
|
export {};
|
|
526
845
|
//# sourceMappingURL=interface.d.ts.map
|
package/dist/interface.js
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MidwayProcessTypeEnum = exports.ObjectLifeCycleEvent = void 0;
|
|
3
|
+
exports.MidwayProcessTypeEnum = exports.ObjectLifeCycleEvent = exports.ServerlessTriggerType = exports.MidwayFrameworkType = exports.FrameworkType = exports.MSListenerType = exports.MSProviderType = exports.InjectModeEnum = exports.ScopeEnum = void 0;
|
|
4
|
+
var ScopeEnum;
|
|
5
|
+
(function (ScopeEnum) {
|
|
6
|
+
ScopeEnum["Singleton"] = "Singleton";
|
|
7
|
+
ScopeEnum["Request"] = "Request";
|
|
8
|
+
ScopeEnum["Prototype"] = "Prototype";
|
|
9
|
+
})(ScopeEnum = exports.ScopeEnum || (exports.ScopeEnum = {}));
|
|
10
|
+
var InjectModeEnum;
|
|
11
|
+
(function (InjectModeEnum) {
|
|
12
|
+
InjectModeEnum["Identifier"] = "Identifier";
|
|
13
|
+
InjectModeEnum["Class"] = "Class";
|
|
14
|
+
InjectModeEnum["PropertyName"] = "PropertyName";
|
|
15
|
+
})(InjectModeEnum = exports.InjectModeEnum || (exports.InjectModeEnum = {}));
|
|
16
|
+
var MSProviderType;
|
|
17
|
+
(function (MSProviderType) {
|
|
18
|
+
MSProviderType["DUBBO"] = "dubbo";
|
|
19
|
+
MSProviderType["GRPC"] = "gRPC";
|
|
20
|
+
})(MSProviderType = exports.MSProviderType || (exports.MSProviderType = {}));
|
|
21
|
+
var MSListenerType;
|
|
22
|
+
(function (MSListenerType) {
|
|
23
|
+
MSListenerType["RABBITMQ"] = "rabbitmq";
|
|
24
|
+
MSListenerType["MQTT"] = "mqtt";
|
|
25
|
+
MSListenerType["KAFKA"] = "kafka";
|
|
26
|
+
MSListenerType["REDIS"] = "redis";
|
|
27
|
+
})(MSListenerType = exports.MSListenerType || (exports.MSListenerType = {}));
|
|
28
|
+
class FrameworkType {
|
|
29
|
+
}
|
|
30
|
+
exports.FrameworkType = FrameworkType;
|
|
31
|
+
class MidwayFrameworkType extends FrameworkType {
|
|
32
|
+
constructor(name) {
|
|
33
|
+
super();
|
|
34
|
+
this.name = name;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.MidwayFrameworkType = MidwayFrameworkType;
|
|
38
|
+
MidwayFrameworkType.WEB = new MidwayFrameworkType('@midwayjs/web');
|
|
39
|
+
MidwayFrameworkType.WEB_KOA = new MidwayFrameworkType('@midwayjs/web-koa');
|
|
40
|
+
MidwayFrameworkType.WEB_EXPRESS = new MidwayFrameworkType('@midwayjs/express');
|
|
41
|
+
MidwayFrameworkType.FAAS = new MidwayFrameworkType('@midwayjs/faas');
|
|
42
|
+
MidwayFrameworkType.MS_GRPC = new MidwayFrameworkType('@midwayjs/grpc');
|
|
43
|
+
MidwayFrameworkType.MS_RABBITMQ = new MidwayFrameworkType('@midwayjs/rabbitmq');
|
|
44
|
+
MidwayFrameworkType.MS_KAFKA = new MidwayFrameworkType('@midwayjs/kafka');
|
|
45
|
+
MidwayFrameworkType.WS_IO = new MidwayFrameworkType('@midwayjs/socketio');
|
|
46
|
+
MidwayFrameworkType.WS = new MidwayFrameworkType('@midwayjs/ws');
|
|
47
|
+
MidwayFrameworkType.SERVERLESS_APP = new MidwayFrameworkType('@midwayjs/serverless-app');
|
|
48
|
+
MidwayFrameworkType.CUSTOM = new MidwayFrameworkType('');
|
|
49
|
+
MidwayFrameworkType.EMPTY = new MidwayFrameworkType('empty');
|
|
50
|
+
MidwayFrameworkType.LIGHT = new MidwayFrameworkType('light');
|
|
51
|
+
MidwayFrameworkType.TASK = new MidwayFrameworkType('@midwayjs/task');
|
|
52
|
+
var ServerlessTriggerType;
|
|
53
|
+
(function (ServerlessTriggerType) {
|
|
54
|
+
ServerlessTriggerType["EVENT"] = "event";
|
|
55
|
+
ServerlessTriggerType["HTTP"] = "http";
|
|
56
|
+
ServerlessTriggerType["API_GATEWAY"] = "apigw";
|
|
57
|
+
ServerlessTriggerType["OS"] = "os";
|
|
58
|
+
ServerlessTriggerType["CDN"] = "cdn";
|
|
59
|
+
ServerlessTriggerType["LOG"] = "log";
|
|
60
|
+
ServerlessTriggerType["TIMER"] = "timer";
|
|
61
|
+
ServerlessTriggerType["MQ"] = "mq";
|
|
62
|
+
ServerlessTriggerType["KAFKA"] = "kafka";
|
|
63
|
+
ServerlessTriggerType["HSF"] = "hsf";
|
|
64
|
+
ServerlessTriggerType["MTOP"] = "mtop";
|
|
65
|
+
ServerlessTriggerType["SSR"] = "ssr";
|
|
66
|
+
})(ServerlessTriggerType = exports.ServerlessTriggerType || (exports.ServerlessTriggerType = {}));
|
|
4
67
|
var ObjectLifeCycleEvent;
|
|
5
68
|
(function (ObjectLifeCycleEvent) {
|
|
6
69
|
ObjectLifeCycleEvent["BEFORE_BIND"] = "beforeBind";
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { IMidwayContainer } from '../interface';
|
|
2
|
-
import { AspectMetadata, IMethodAspect } from '../decorator';
|
|
1
|
+
import { IMidwayContainer, AspectMetadata, IMethodAspect } from '../interface';
|
|
3
2
|
export declare class MidwayAspectService {
|
|
4
3
|
readonly applicationContext: IMidwayContainer;
|
|
5
4
|
constructor(applicationContext: IMidwayContainer);
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MidwayAspectService = void 0;
|
|
13
13
|
const pm = require("picomatch");
|
|
14
|
+
const interface_1 = require("../interface");
|
|
14
15
|
const decorator_1 = require("../decorator");
|
|
15
16
|
const types_1 = require("../util/types");
|
|
16
17
|
let MidwayAspectService = class MidwayAspectService {
|
|
@@ -157,7 +158,7 @@ let MidwayAspectService = class MidwayAspectService {
|
|
|
157
158
|
};
|
|
158
159
|
MidwayAspectService = __decorate([
|
|
159
160
|
(0, decorator_1.Provide)(),
|
|
160
|
-
(0, decorator_1.Scope)(
|
|
161
|
+
(0, decorator_1.Scope)(interface_1.ScopeEnum.Singleton),
|
|
161
162
|
__metadata("design:paramtypes", [Object])
|
|
162
163
|
], MidwayAspectService);
|
|
163
164
|
exports.MidwayAspectService = MidwayAspectService;
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.MidwayConfigService = void 0;
|
|
13
13
|
const path_1 = require("path");
|
|
14
|
+
const interface_1 = require("../interface");
|
|
14
15
|
const util_1 = require("../util");
|
|
15
16
|
const fs_1 = require("fs");
|
|
16
17
|
const util = require("util");
|
|
@@ -240,7 +241,7 @@ __decorate([
|
|
|
240
241
|
], MidwayConfigService.prototype, "init", null);
|
|
241
242
|
MidwayConfigService = __decorate([
|
|
242
243
|
(0, decorator_1.Provide)(),
|
|
243
|
-
(0, decorator_1.Scope)(
|
|
244
|
+
(0, decorator_1.Scope)(interface_1.ScopeEnum.Singleton)
|
|
244
245
|
], MidwayConfigService);
|
|
245
246
|
exports.MidwayConfigService = MidwayConfigService;
|
|
246
247
|
//# sourceMappingURL=configService.js.map
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import { HandlerFunction, IMidwayContainer, MethodHandlerFunction, ParameterHandlerFunction } from '../interface';
|
|
1
|
+
import { HandlerFunction, IMidwayContainer, MethodHandlerFunction, ParameterHandlerFunction, PipeUnionTransform } from '../interface';
|
|
2
2
|
export declare class MidwayDecoratorService {
|
|
3
3
|
readonly applicationContext: IMidwayContainer;
|
|
4
4
|
private propertyHandlerMap;
|
|
5
5
|
private methodDecoratorMap;
|
|
6
6
|
private parameterDecoratorMap;
|
|
7
|
+
private parameterDecoratorPipes;
|
|
7
8
|
private aspectService;
|
|
8
9
|
constructor(applicationContext: IMidwayContainer);
|
|
9
10
|
protected init(): void;
|
|
10
11
|
registerPropertyHandler(decoratorKey: string, fn: HandlerFunction): void;
|
|
11
12
|
registerMethodHandler(decoratorKey: string, fn: MethodHandlerFunction): void;
|
|
12
13
|
registerParameterHandler(decoratorKey: string, fn: ParameterHandlerFunction): void;
|
|
14
|
+
registerParameterPipes(decoratorKey: string, pipes: PipeUnionTransform[]): void;
|
|
13
15
|
/**
|
|
14
16
|
* binding getter method for decorator
|
|
15
17
|
*
|