-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
77 lines (65 loc) · 2.39 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
export type AfterAdviceType = (joinPoint: JoinPoint, result: any, error: Error | null) => void
export type AfterReturningAdviceType = (joinPoint: JoinPoint, result: any) => any
export type AfterThrowAdviceType = (joinPoint: JoinPoint, error: Error | null) => void
export type BeforeAdviceType = (joinPoint: JoinPoint) => void
export type AroundAdviceType = (joinPoint: ProceedJoinPoint) => any
export type AdviceKeys = keyof Advices
export type AdviceTypes = Advices[AdviceKeys]
export type PointcutOpts = { value: string }
export type AdviceDecorator = (options: PointcutOpts) => MethodDecorator
export interface Advices {
after?: AfterAdviceType;
afterReturning?: AfterReturningAdviceType;
afterThrowing?: AfterThrowAdviceType;
before?: BeforeAdviceType;
around?: AroundAdviceType;
}
export interface JoinPointType {
target: any;
args: any[];
thisArg: any;
value: any
}
export interface ProceedJoinPointType extends JoinPointType {
proceed: () => any
}
export interface WeavingOpts {
blackList?: Array<string>;
namespace?: string;
}
export type PointcutType = 'proto' | 'static'
export type PointcutRuleType = {
namespace?: RegExp | string;
className: RegExp | string;
methodName: RegExp | string
}
export type PointcutRules = string | RegExp | PointcutRuleType | Array<PointcutRuleType | RegExp | string>
export interface JoinPoint {
target: any;
args: any[];
thisArg: any;
value: any
new(jp: JoinPointType)
}
export interface ProceedJoinPoint extends JoinPoint {
new(jp: ProceedJoinPointType)
procced(): any
}
export type PointcutMatches = { namespace?: string, className?: string; methodName?: string }
export interface PointcutClass {
rules: PointcutRules;
advices: Advices;
matches: (ctx: PointcutMatches) => boolean;
registAdvice<T extends AdviceKeys>(type: T, advice: Advices[T]): void;
findAdvice(type: AdviceKeys): AdviceTypes;
normalizedRules(rules: PointcutRules): Array<PointcutRuleType | RegExp | string>;
toRegRule(rule: string): void;
}
declare let Pointcut: (type?: PointcutType) => MethodDecorator
declare let Before: AdviceDecorator
declare let After: AdviceDecorator
declare let AfterReturning: AdviceDecorator
declare let AfterThrowing: AdviceDecorator
declare let Around: AdviceDecorator
declare let Aspect: () => ClassDecorator
declare let Weaving: (opts?: WeavingOpts | undefined) => ClassDecorator