@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.
- package/dist/baseFramework.d.ts +3 -0
- package/dist/baseFramework.js +17 -0
- package/dist/common/applicationManager.d.ts +1 -2
- package/dist/common/applicationManager.js +2 -1
- package/dist/common/webGenerator.js +2 -1
- package/dist/config/config.default.js +2 -1
- 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 +1 -2
- 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 +1 -0
- package/dist/decorator/constant.js +3 -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/interface.d.ts +327 -24
- 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 +63 -11
- package/dist/service/environmentService.js +2 -1
- package/dist/service/frameworkService.d.ts +1 -2
- package/dist/service/frameworkService.js +6 -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 +1 -0
- package/dist/service/loggerService.js +19 -2
- 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 +2 -0
- 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 +4 -5
- package/dist/decorator/interface.d.ts +0 -242
- package/dist/decorator/interface.js +0 -66
package/dist/interface.d.ts
CHANGED
|
@@ -3,8 +3,294 @@ import type { LoggerOptions, LoggerContextFormat } from '@midwayjs/logger';
|
|
|
3
3
|
import * as EventEmitter from 'events';
|
|
4
4
|
import type { AsyncContextManager } from './common/asyncContextManager';
|
|
5
5
|
import type { LoggerFactory } from './common/loggerFactory';
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
}
|
|
8
294
|
export interface ILogger {
|
|
9
295
|
info(msg: any, ...args: any[]): void;
|
|
10
296
|
debug(msg: any, ...args: any[]): void;
|
|
@@ -12,7 +298,9 @@ export interface ILogger {
|
|
|
12
298
|
warn(msg: any, ...args: any[]): void;
|
|
13
299
|
}
|
|
14
300
|
export interface MidwayCoreDefaultConfig {
|
|
15
|
-
midwayLogger?: ServiceFactoryConfigOption<LoggerOptions
|
|
301
|
+
midwayLogger?: ServiceFactoryConfigOption<LoggerOptions & {
|
|
302
|
+
lazyLoad?: boolean;
|
|
303
|
+
}>;
|
|
16
304
|
debug?: {
|
|
17
305
|
recordConfigMergeOrder?: boolean;
|
|
18
306
|
};
|
|
@@ -20,10 +308,10 @@ export interface MidwayCoreDefaultConfig {
|
|
|
20
308
|
enable: boolean;
|
|
21
309
|
};
|
|
22
310
|
}
|
|
23
|
-
export
|
|
311
|
+
export type PowerPartial<T> = {
|
|
24
312
|
[U in keyof T]?: T[U] extends {} ? PowerPartial<T[U]> : T[U];
|
|
25
313
|
};
|
|
26
|
-
export
|
|
314
|
+
export type ServiceFactoryConfigOption<OPTIONS> = {
|
|
27
315
|
default?: PowerPartial<OPTIONS>;
|
|
28
316
|
client?: PowerPartial<OPTIONS>;
|
|
29
317
|
clients?: {
|
|
@@ -31,7 +319,7 @@ export declare type ServiceFactoryConfigOption<OPTIONS> = {
|
|
|
31
319
|
};
|
|
32
320
|
defaultClientName?: string;
|
|
33
321
|
};
|
|
34
|
-
export
|
|
322
|
+
export type DataSourceManagerConfigOption<OPTIONS> = {
|
|
35
323
|
default?: PowerPartial<OPTIONS>;
|
|
36
324
|
defaultDataSourceName?: string;
|
|
37
325
|
dataSource?: {
|
|
@@ -40,15 +328,15 @@ export declare type DataSourceManagerConfigOption<OPTIONS> = {
|
|
|
40
328
|
} & OPTIONS>;
|
|
41
329
|
};
|
|
42
330
|
};
|
|
43
|
-
|
|
331
|
+
type ConfigType<T> = T extends (...args: any[]) => any ? Writable<PowerPartial<ReturnType<T>>> : Writable<PowerPartial<T>>;
|
|
44
332
|
/**
|
|
45
333
|
* Get definition from config
|
|
46
334
|
*/
|
|
47
|
-
export
|
|
335
|
+
export type FileConfigOption<T, K = unknown> = K extends keyof ConfigType<T> ? Pick<ConfigType<T>, K> : ConfigType<T>;
|
|
48
336
|
/**
|
|
49
337
|
* Make object property writeable
|
|
50
338
|
*/
|
|
51
|
-
export
|
|
339
|
+
export type Writable<T> = {
|
|
52
340
|
-readonly [P in keyof T]: T[P];
|
|
53
341
|
};
|
|
54
342
|
/**
|
|
@@ -61,7 +349,7 @@ export interface ILifeCycle extends Partial<IObjectLifeCycle> {
|
|
|
61
349
|
onServerReady?(container: IMidwayContainer, mainApp?: IMidwayApplication): Promise<void>;
|
|
62
350
|
onStop?(container: IMidwayContainer, mainApp?: IMidwayApplication): Promise<void>;
|
|
63
351
|
}
|
|
64
|
-
export
|
|
352
|
+
export type ObjectContext = {
|
|
65
353
|
originName?: string;
|
|
66
354
|
};
|
|
67
355
|
/**
|
|
@@ -206,7 +494,7 @@ export interface IManagedResolverFactoryCreateOptions {
|
|
|
206
494
|
args?: any;
|
|
207
495
|
namespace?: string;
|
|
208
496
|
}
|
|
209
|
-
export
|
|
497
|
+
export type HandlerFunction = (
|
|
210
498
|
/**
|
|
211
499
|
* decorator uuid key
|
|
212
500
|
*/
|
|
@@ -215,12 +503,12 @@ key: string,
|
|
|
215
503
|
* decorator set metadata
|
|
216
504
|
*/
|
|
217
505
|
meta: any, instance: any) => any;
|
|
218
|
-
export
|
|
506
|
+
export type MethodHandlerFunction = (options: {
|
|
219
507
|
target: new (...args: any[]) => any;
|
|
220
508
|
propertyName: string;
|
|
221
509
|
metadata: any;
|
|
222
510
|
}) => IMethodAspect;
|
|
223
|
-
export
|
|
511
|
+
export type ParameterHandlerFunction = (options: {
|
|
224
512
|
target: new (...args: any[]) => any;
|
|
225
513
|
propertyName: string;
|
|
226
514
|
metadata: any;
|
|
@@ -266,7 +554,7 @@ export interface IMidwayContainer extends IObjectFactory, IObjectLifeCycle {
|
|
|
266
554
|
/**
|
|
267
555
|
* @deprecated
|
|
268
556
|
*/
|
|
269
|
-
export
|
|
557
|
+
export type IApplicationContext = IMidwayContainer;
|
|
270
558
|
export interface IFileDetector {
|
|
271
559
|
run(container: IMidwayContainer, fileDetectorOptions?: Record<string, any>): any;
|
|
272
560
|
setExtraDetectorOptions(detectorOptions: Record<string, any>): any;
|
|
@@ -315,8 +603,8 @@ export interface Context {
|
|
|
315
603
|
*/
|
|
316
604
|
getAttr<T>(key: string): T;
|
|
317
605
|
}
|
|
318
|
-
export
|
|
319
|
-
export
|
|
606
|
+
export type IMidwayContext<FrameworkContext = unknown> = Context & FrameworkContext;
|
|
607
|
+
export type NextFunction = () => Promise<any>;
|
|
320
608
|
/**
|
|
321
609
|
* Common middleware definition
|
|
322
610
|
*/
|
|
@@ -325,11 +613,11 @@ export interface IMiddleware<CTX, R, N = unknown> {
|
|
|
325
613
|
match?: (ctx: CTX) => boolean;
|
|
326
614
|
ignore?: (ctx: CTX) => boolean;
|
|
327
615
|
}
|
|
328
|
-
export
|
|
329
|
-
export
|
|
330
|
-
export
|
|
331
|
-
export
|
|
332
|
-
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>;
|
|
333
621
|
/**
|
|
334
622
|
* Common Exception Filter definition
|
|
335
623
|
*/
|
|
@@ -337,14 +625,14 @@ export interface IFilter<CTX, R, N> {
|
|
|
337
625
|
catch?(err: Error, ctx: CTX, res?: R, next?: N): any;
|
|
338
626
|
match?(result: any, ctx: CTX, res?: R, next?: N): any;
|
|
339
627
|
}
|
|
340
|
-
export
|
|
628
|
+
export type CommonFilterUnion<CTX, R, N> = (new (...args: any[]) => IFilter<CTX, R, N>) | Array<new (...args: any[]) => IFilter<CTX, R, N>>;
|
|
341
629
|
/**
|
|
342
630
|
* Guard definition
|
|
343
631
|
*/
|
|
344
632
|
export interface IGuard<CTX = unknown> {
|
|
345
633
|
canActivate(ctx: CTX, supplierClz: new (...args: any[]) => any, methodName: string): boolean | Promise<boolean>;
|
|
346
634
|
}
|
|
347
|
-
export
|
|
635
|
+
export type CommonGuardUnion<CTX = unknown> = (new (...args: any[]) => IGuard<CTX>) | Array<new (...args: any[]) => IGuard<CTX>>;
|
|
348
636
|
export interface IMiddlewareManager<CTX, R, N> {
|
|
349
637
|
insertFirst(middleware: CommonMiddlewareUnion<CTX, R, N>): void;
|
|
350
638
|
insertLast(middleware: CommonMiddlewareUnion<CTX, R, N>): void;
|
|
@@ -461,8 +749,12 @@ export interface IMidwayBaseApplication<CTX extends IMidwayContext> {
|
|
|
461
749
|
* @param guard
|
|
462
750
|
*/
|
|
463
751
|
useGuard(guard: CommonGuardUnion<CTX>): void;
|
|
752
|
+
/**
|
|
753
|
+
* get current namespace
|
|
754
|
+
*/
|
|
755
|
+
getNamespace(): string;
|
|
464
756
|
}
|
|
465
|
-
export
|
|
757
|
+
export type IMidwayApplication<T extends IMidwayContext = IMidwayContext, FrameworkApplication = unknown> = IMidwayBaseApplication<T> & FrameworkApplication;
|
|
466
758
|
export interface IMidwayBootstrapOptions {
|
|
467
759
|
[customPropertyKey: string]: any;
|
|
468
760
|
baseDir?: string;
|
|
@@ -514,6 +806,8 @@ export interface IMidwayFramework<APP extends IMidwayApplication<CTX>, CTX exten
|
|
|
514
806
|
useFilter(Filter: CommonFilterUnion<CTX, ResOrNext, Next>): void;
|
|
515
807
|
useGuard(guard: CommonGuardUnion<CTX>): void;
|
|
516
808
|
runGuard(ctx: CTX, supplierClz: new (...args: any[]) => any, methodName: string): Promise<boolean>;
|
|
809
|
+
getNamespace(): string;
|
|
810
|
+
setNamespace(namespace: string): void;
|
|
517
811
|
}
|
|
518
812
|
export interface MidwayAppInfo {
|
|
519
813
|
pkg: Record<string, any>;
|
|
@@ -538,5 +832,14 @@ export interface IServiceFactory<Client> {
|
|
|
538
832
|
stop(): Promise<void>;
|
|
539
833
|
getDefaultClientName(): string;
|
|
540
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
|
+
}
|
|
541
844
|
export {};
|
|
542
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
|
*
|