assemblerjs 1.0.0 → 1.1.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/README.md +29 -53
- package/dist/index.d.ts +430 -9
- package/dist/index.js +24 -12
- package/dist/index.mjs +16 -12
- package/dist/index11.js +82 -20
- package/dist/index11.mjs +78 -20
- package/dist/index12.js +17 -8
- package/dist/index12.mjs +16 -8
- package/dist/index13.js +148 -73
- package/dist/index13.mjs +148 -73
- package/dist/index14.js +4 -17
- package/dist/index14.mjs +4 -17
- package/dist/index15.js +21 -16
- package/dist/index15.mjs +21 -16
- package/dist/index16.js +10 -16
- package/dist/index16.mjs +10 -16
- package/dist/index17.js +88 -16
- package/dist/index17.mjs +88 -16
- package/dist/index18.js +11 -20
- package/dist/index18.mjs +11 -19
- package/dist/index19.js +11 -20
- package/dist/index19.mjs +11 -19
- package/dist/index2.js +3 -3
- package/dist/index2.mjs +3 -3
- package/dist/index20.js +11 -20
- package/dist/index20.mjs +11 -20
- package/dist/index21.js +14 -25
- package/dist/index21.mjs +14 -21
- package/dist/index22.js +24 -46
- package/dist/index22.mjs +23 -45
- package/dist/index23.js +25 -63
- package/dist/index23.mjs +24 -63
- package/dist/index24.js +24 -30
- package/dist/index24.mjs +24 -30
- package/dist/index25.js +24 -62
- package/dist/index25.mjs +20 -62
- package/dist/index26.js +46 -30
- package/dist/index26.mjs +45 -30
- package/dist/index27.js +2 -34
- package/dist/index27.mjs +2 -32
- package/dist/index28.js +17 -41
- package/dist/index28.mjs +15 -40
- package/dist/index29.js +64 -15
- package/dist/index29.mjs +64 -13
- package/dist/index3.js +2 -2
- package/dist/index3.mjs +2 -2
- package/dist/index30.js +32 -14
- package/dist/index30.mjs +32 -12
- package/dist/index31.js +57 -86
- package/dist/index31.mjs +57 -84
- package/dist/index32.js +28 -19
- package/dist/index32.mjs +28 -19
- package/dist/index33.js +28 -25
- package/dist/index33.mjs +28 -24
- package/dist/index34.js +17 -8
- package/dist/index34.mjs +14 -8
- package/dist/index35.js +23 -49
- package/dist/index35.mjs +23 -49
- package/dist/index36.js +37 -108
- package/dist/index36.mjs +36 -108
- package/dist/index37.js +98 -10
- package/dist/index37.mjs +96 -10
- package/dist/index38.js +95 -20
- package/dist/index38.mjs +95 -20
- package/dist/index39.js +23 -44
- package/dist/index39.mjs +23 -43
- package/dist/index4.js +5 -5
- package/dist/index4.mjs +5 -5
- package/dist/index40.js +34 -0
- package/dist/index40.mjs +29 -0
- package/dist/index41.js +14 -0
- package/dist/index41.mjs +10 -0
- package/dist/index42.js +54 -0
- package/dist/index42.mjs +50 -0
- package/dist/index43.js +177 -0
- package/dist/index43.mjs +173 -0
- package/dist/index44.js +947 -0
- package/dist/index44.mjs +943 -0
- package/dist/index45.js +7 -0
- package/dist/index45.mjs +3 -0
- package/dist/index46.js +7 -0
- package/dist/index46.mjs +3 -0
- package/dist/index47.js +19 -0
- package/dist/index47.mjs +15 -0
- package/dist/index48.js +33 -0
- package/dist/index48.mjs +29 -0
- package/dist/index49.js +67 -0
- package/dist/index49.mjs +62 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -11,18 +11,22 @@ const abstract = require('./index7.js');
|
|
|
11
11
|
const types = require('./index8.js');
|
|
12
12
|
const listenerCollection_abstract = require('./index9.js');
|
|
13
13
|
const eventManager_abstract = require('./index10.js');
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
14
|
+
const decorators = require('./index11.js');
|
|
15
|
+
const affect = require('./index12.js');
|
|
16
|
+
const transversalManager = require('./index13.js');
|
|
17
|
+
const abstract$1 = require('./index14.js');
|
|
18
|
+
const _await = require('./index15.js');
|
|
19
|
+
const indexFactory = require('./index16.js');
|
|
20
|
+
const parameterDecoratorFactory = require('./index17.js');
|
|
21
|
+
const context = require('./index18.js');
|
|
22
|
+
const configuration = require('./index19.js');
|
|
23
|
+
const definition = require('./index20.js');
|
|
24
|
+
const dispose = require('./index21.js');
|
|
25
|
+
const use = require('./index22.js');
|
|
26
|
+
const global = require('./index23.js');
|
|
27
|
+
const optional = require('./index24.js');
|
|
28
|
+
const helpers$1 = require('./index25.js');
|
|
29
|
+
const constructorDecorator = require('./index26.js');
|
|
26
30
|
|
|
27
31
|
|
|
28
32
|
|
|
@@ -38,6 +42,14 @@ exports.AbstractAssemblage = abstract.AbstractAssemblage;
|
|
|
38
42
|
exports.AbstractAssembler = types.AbstractAssembler;
|
|
39
43
|
exports.AbstractListenerCollection = listenerCollection_abstract.AbstractListenerCollection;
|
|
40
44
|
exports.AbstractEventManager = eventManager_abstract.AbstractEventManager;
|
|
45
|
+
exports.After = decorators.After;
|
|
46
|
+
exports.Around = decorators.Around;
|
|
47
|
+
exports.Before = decorators.Before;
|
|
48
|
+
exports.Transversal = decorators.Transversal;
|
|
49
|
+
exports.isTransversal = decorators.isTransversal;
|
|
50
|
+
exports.Affect = affect.Affect;
|
|
51
|
+
exports.TransversalManager = transversalManager.TransversalManager;
|
|
52
|
+
exports.AbstractTransversal = abstract$1.AbstractTransversal;
|
|
41
53
|
exports.Await = _await.Await;
|
|
42
54
|
exports.createParamIndexDecorator = indexFactory.createParamIndexDecorator;
|
|
43
55
|
exports.ParameterDecoratorFactory = parameterDecoratorFactory.ParameterDecoratorFactory;
|
package/dist/index.mjs
CHANGED
|
@@ -7,15 +7,19 @@ export { AbstractAssemblage } from './index7.mjs';
|
|
|
7
7
|
export { AbstractAssembler } from './index8.mjs';
|
|
8
8
|
export { AbstractListenerCollection } from './index9.mjs';
|
|
9
9
|
export { AbstractEventManager } from './index10.mjs';
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
14
|
-
export {
|
|
15
|
-
export {
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
18
|
-
export {
|
|
19
|
-
export {
|
|
20
|
-
export {
|
|
21
|
-
export {
|
|
10
|
+
export { After, Around, Before, Transversal, isTransversal } from './index11.mjs';
|
|
11
|
+
export { Affect } from './index12.mjs';
|
|
12
|
+
export { TransversalManager } from './index13.mjs';
|
|
13
|
+
export { AbstractTransversal } from './index14.mjs';
|
|
14
|
+
export { Await } from './index15.mjs';
|
|
15
|
+
export { createParamIndexDecorator } from './index16.mjs';
|
|
16
|
+
export { ParameterDecoratorFactory } from './index17.mjs';
|
|
17
|
+
export { Context } from './index18.mjs';
|
|
18
|
+
export { Configuration } from './index19.mjs';
|
|
19
|
+
export { Definition } from './index20.mjs';
|
|
20
|
+
export { Dispose } from './index21.mjs';
|
|
21
|
+
export { Use, decorateUse } from './index22.mjs';
|
|
22
|
+
export { Global, decorateGlobal } from './index23.mjs';
|
|
23
|
+
export { Optional } from './index24.mjs';
|
|
24
|
+
export { getDecoratedParametersIndexes, getParamIndexKey, getParamValueKey, getParameterIndexes, getParameterValues } from './index25.mjs';
|
|
25
|
+
export { ConstructorDecorator, createConstructorDecorator } from './index26.mjs';
|
package/dist/index11.js
CHANGED
|
@@ -2,26 +2,88 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
const constants = require('./index28.js');
|
|
6
|
+
const reflection = require('./index34.js');
|
|
7
|
+
const decorator = require('./index2.js');
|
|
8
|
+
const schema = require('./index37.js');
|
|
9
|
+
|
|
10
|
+
function isTransversal(e) {
|
|
11
|
+
try {
|
|
12
|
+
const t = schema.getDefinition(e);
|
|
13
|
+
return t?.metadata?.isTransversal === true;
|
|
14
|
+
} catch {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function Transversal(t) {
|
|
19
|
+
return function(a) {
|
|
20
|
+
if (t) {
|
|
21
|
+
if ('inject' in t || 'use' in t) {
|
|
22
|
+
throw new Error(`@Transversal on class ${a.name} cannot have inject or use properties. ` + `Aspects receive dependencies through constructor parameters resolved from parent context.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const s = reflection.getCustomMetadata(constants.ReflectValue.TransversalAdvices, a) || [];
|
|
26
|
+
const o = {
|
|
27
|
+
singleton: true,
|
|
28
|
+
...t,
|
|
29
|
+
inject: [],
|
|
30
|
+
use: [],
|
|
31
|
+
metadata: {
|
|
32
|
+
...t?.metadata,
|
|
33
|
+
isTransversal: true,
|
|
34
|
+
advices: s
|
|
35
|
+
}
|
|
23
36
|
};
|
|
37
|
+
return decorator.Assemblage(o)(a);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function Before(e, t = 0) {
|
|
41
|
+
return function(r, n, a) {
|
|
42
|
+
s(r.constructor, {
|
|
43
|
+
type: 'before',
|
|
44
|
+
pointcut: e,
|
|
45
|
+
methodName: n,
|
|
46
|
+
priority: t,
|
|
47
|
+
enabled: true
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function After(e, t = 0) {
|
|
52
|
+
return function(r, n, a) {
|
|
53
|
+
s(r.constructor, {
|
|
54
|
+
type: 'after',
|
|
55
|
+
pointcut: e,
|
|
56
|
+
methodName: n,
|
|
57
|
+
priority: t,
|
|
58
|
+
enabled: true
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function Around(e, t = 0) {
|
|
63
|
+
return function(r, n, a) {
|
|
64
|
+
s(r.constructor, {
|
|
65
|
+
type: 'around',
|
|
66
|
+
pointcut: e,
|
|
67
|
+
methodName: n,
|
|
68
|
+
priority: t,
|
|
69
|
+
enabled: true
|
|
70
|
+
});
|
|
24
71
|
};
|
|
25
|
-
}
|
|
72
|
+
}
|
|
73
|
+
function s(e, a) {
|
|
74
|
+
const s = reflection.getCustomMetadata(constants.ReflectValue.TransversalAdvices, e) || [];
|
|
75
|
+
s.push(a);
|
|
76
|
+
reflection.defineCustomMetadata(constants.ReflectValue.TransversalAdvices, s, e);
|
|
77
|
+
const o = reflection.getCustomMetadata('assemblage:definition.value', e) || {};
|
|
78
|
+
if (!o.metadata) {
|
|
79
|
+
o.metadata = {};
|
|
80
|
+
}
|
|
81
|
+
o.metadata.advices = s;
|
|
82
|
+
reflection.defineCustomMetadata('assemblage:definition.value', o, e);
|
|
83
|
+
}
|
|
26
84
|
|
|
27
|
-
exports.
|
|
85
|
+
exports.After = After;
|
|
86
|
+
exports.Around = Around;
|
|
87
|
+
exports.Before = Before;
|
|
88
|
+
exports.Transversal = Transversal;
|
|
89
|
+
exports.isTransversal = isTransversal;
|
package/dist/index11.mjs
CHANGED
|
@@ -1,23 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import { ReflectValue } from './index28.mjs';
|
|
2
|
+
import { getCustomMetadata, defineCustomMetadata } from './index34.mjs';
|
|
3
|
+
import { Assemblage } from './index2.mjs';
|
|
4
|
+
import { getDefinition } from './index37.mjs';
|
|
5
|
+
|
|
6
|
+
function isTransversal(e) {
|
|
7
|
+
try {
|
|
8
|
+
const t = getDefinition(e);
|
|
9
|
+
return t?.metadata?.isTransversal === true;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function Transversal(t) {
|
|
15
|
+
return function(a) {
|
|
16
|
+
if (t) {
|
|
17
|
+
if ('inject' in t || 'use' in t) {
|
|
18
|
+
throw new Error(`@Transversal on class ${a.name} cannot have inject or use properties. ` + `Aspects receive dependencies through constructor parameters resolved from parent context.`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const s = getCustomMetadata(ReflectValue.TransversalAdvices, a) || [];
|
|
22
|
+
const o = {
|
|
23
|
+
singleton: true,
|
|
24
|
+
...t,
|
|
25
|
+
inject: [],
|
|
26
|
+
use: [],
|
|
27
|
+
metadata: {
|
|
28
|
+
...t?.metadata,
|
|
29
|
+
isTransversal: true,
|
|
30
|
+
advices: s
|
|
31
|
+
}
|
|
19
32
|
};
|
|
33
|
+
return Assemblage(o)(a);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function Before(e, t = 0) {
|
|
37
|
+
return function(r, n, a) {
|
|
38
|
+
s(r.constructor, {
|
|
39
|
+
type: 'before',
|
|
40
|
+
pointcut: e,
|
|
41
|
+
methodName: n,
|
|
42
|
+
priority: t,
|
|
43
|
+
enabled: true
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function After(e, t = 0) {
|
|
48
|
+
return function(r, n, a) {
|
|
49
|
+
s(r.constructor, {
|
|
50
|
+
type: 'after',
|
|
51
|
+
pointcut: e,
|
|
52
|
+
methodName: n,
|
|
53
|
+
priority: t,
|
|
54
|
+
enabled: true
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function Around(e, t = 0) {
|
|
59
|
+
return function(r, n, a) {
|
|
60
|
+
s(r.constructor, {
|
|
61
|
+
type: 'around',
|
|
62
|
+
pointcut: e,
|
|
63
|
+
methodName: n,
|
|
64
|
+
priority: t,
|
|
65
|
+
enabled: true
|
|
66
|
+
});
|
|
20
67
|
};
|
|
21
|
-
}
|
|
68
|
+
}
|
|
69
|
+
function s(e, a) {
|
|
70
|
+
const s = getCustomMetadata(ReflectValue.TransversalAdvices, e) || [];
|
|
71
|
+
s.push(a);
|
|
72
|
+
defineCustomMetadata(ReflectValue.TransversalAdvices, s, e);
|
|
73
|
+
const o = getCustomMetadata('assemblage:definition.value', e) || {};
|
|
74
|
+
if (!o.metadata) {
|
|
75
|
+
o.metadata = {};
|
|
76
|
+
}
|
|
77
|
+
o.metadata.advices = s;
|
|
78
|
+
defineCustomMetadata('assemblage:definition.value', o, e);
|
|
79
|
+
}
|
|
22
80
|
|
|
23
|
-
export {
|
|
81
|
+
export { After, Around, Before, Transversal, isTransversal };
|
package/dist/index12.js
CHANGED
|
@@ -2,15 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
require('./index27.js');
|
|
6
|
+
const constants = require('./index28.js');
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
function Affect(t, f) {
|
|
9
|
+
return function(o, c, n) {
|
|
10
|
+
const d = {
|
|
11
|
+
transversal: t,
|
|
12
|
+
config: f
|
|
12
13
|
};
|
|
14
|
+
const a = Reflect.getOwnMetadata(constants.ReflectValue.AffectedMethods, o, c) || [];
|
|
15
|
+
a.push(d);
|
|
16
|
+
Reflect.defineMetadata(constants.ReflectValue.AffectedMethods, a, o, c);
|
|
17
|
+
return n;
|
|
13
18
|
};
|
|
14
|
-
|
|
19
|
+
}
|
|
20
|
+
function getAffectedMethods(t, f) {
|
|
21
|
+
return Reflect.getOwnMetadata(constants.ReflectValue.AffectedMethods, t, f) || [];
|
|
22
|
+
}
|
|
15
23
|
|
|
16
|
-
exports.
|
|
24
|
+
exports.Affect = Affect;
|
|
25
|
+
exports.getAffectedMethods = getAffectedMethods;
|
package/dist/index12.mjs
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './index27.mjs';
|
|
2
|
+
import { ReflectValue } from './index28.mjs';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
function Affect(t, f) {
|
|
5
|
+
return function(o, c, n) {
|
|
6
|
+
const d = {
|
|
7
|
+
transversal: t,
|
|
8
|
+
config: f
|
|
8
9
|
};
|
|
10
|
+
const a = Reflect.getOwnMetadata(ReflectValue.AffectedMethods, o, c) || [];
|
|
11
|
+
a.push(d);
|
|
12
|
+
Reflect.defineMetadata(ReflectValue.AffectedMethods, a, o, c);
|
|
13
|
+
return n;
|
|
9
14
|
};
|
|
10
|
-
|
|
15
|
+
}
|
|
16
|
+
function getAffectedMethods(t, f) {
|
|
17
|
+
return Reflect.getOwnMetadata(ReflectValue.AffectedMethods, t, f) || [];
|
|
18
|
+
}
|
|
11
19
|
|
|
12
|
-
export {
|
|
20
|
+
export { Affect, getAffectedMethods };
|
package/dist/index13.js
CHANGED
|
@@ -2,93 +2,168 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
4
4
|
|
|
5
|
-
const
|
|
5
|
+
const core = require('@assemblerjs/core');
|
|
6
|
+
const pointcutMatcher = require('./index39.js');
|
|
7
|
+
const affect = require('./index12.js');
|
|
8
|
+
const schema = require('./index37.js');
|
|
6
9
|
|
|
7
|
-
class
|
|
8
|
-
static
|
|
9
|
-
|
|
10
|
-
if (
|
|
11
|
-
|
|
10
|
+
class TransversalManager {
|
|
11
|
+
static getInstance(e) {
|
|
12
|
+
let t = this.instances.get(e);
|
|
13
|
+
if (!t) {
|
|
14
|
+
t = new TransversalManager(e);
|
|
15
|
+
this.instances.set(e, t);
|
|
12
16
|
}
|
|
13
|
-
|
|
14
|
-
const o = `assemblage:${r.toLowerCase()}.param.value`;
|
|
15
|
-
const c = this.createDecoratorFunction(s, o, t);
|
|
16
|
-
this.registeredDecorators.set(r, {
|
|
17
|
-
name: r,
|
|
18
|
-
valueType: t,
|
|
19
|
-
handler: a
|
|
20
|
-
});
|
|
21
|
-
return c;
|
|
17
|
+
return t;
|
|
22
18
|
}
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
getTransversalInstance(e) {
|
|
20
|
+
return TransversalManager.transversalInstances.get(e);
|
|
21
|
+
}
|
|
22
|
+
static resetGlobalState() {
|
|
23
|
+
TransversalManager.transversalInstances.clear();
|
|
24
|
+
TransversalManager.transversalMetadata.clear();
|
|
25
|
+
TransversalManager.instances = new WeakMap();
|
|
29
26
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
registerTransversal(t, n) {
|
|
28
|
+
let s;
|
|
29
|
+
let r;
|
|
30
|
+
let o;
|
|
31
|
+
if (t.length === 1) {
|
|
32
|
+
s = t[0];
|
|
33
|
+
r = t[0];
|
|
34
|
+
o = undefined;
|
|
35
|
+
} else if (t.length === 2) {
|
|
36
|
+
const a = t[1];
|
|
37
|
+
if (core.isClass(a)) {
|
|
38
|
+
s = t[0];
|
|
39
|
+
r = a;
|
|
40
|
+
o = undefined;
|
|
41
|
+
} else {
|
|
42
|
+
s = t[0];
|
|
43
|
+
r = t[0];
|
|
44
|
+
o = a;
|
|
35
45
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
} else {
|
|
47
|
+
s = t[0];
|
|
48
|
+
r = t[1];
|
|
49
|
+
o = t[2];
|
|
50
|
+
}
|
|
51
|
+
const c = r.name;
|
|
52
|
+
if (!TransversalManager.transversalInstances.has(c)) {
|
|
53
|
+
const e = n || this.context;
|
|
54
|
+
const t = e.require(s, o);
|
|
55
|
+
const i = schema.getDefinition(r);
|
|
56
|
+
if (!i) {
|
|
57
|
+
throw new Error(`Transversal ${c} must be decorated with @Transversal`);
|
|
39
58
|
}
|
|
59
|
+
TransversalManager.transversalInstances.set(c, t);
|
|
60
|
+
const l = {
|
|
61
|
+
definition: i,
|
|
62
|
+
advices: this.extractAdvices(r, t),
|
|
63
|
+
instance: t
|
|
64
|
+
};
|
|
65
|
+
TransversalManager.transversalMetadata.set(c, l);
|
|
40
66
|
}
|
|
41
67
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
n
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
const o = reflection.getOwnCustomMetadata(c, a) || {};
|
|
63
|
-
o[s] = t;
|
|
64
|
-
reflection.defineCustomMetadata(c, o, a);
|
|
65
|
-
break;
|
|
66
|
-
}
|
|
68
|
+
extractAdvices(e, t) {
|
|
69
|
+
const n = schema.getDefinition(e);
|
|
70
|
+
const s = [];
|
|
71
|
+
const r = n?.metadata?.advices || [];
|
|
72
|
+
for (const a of r){
|
|
73
|
+
const n = t[a.methodName];
|
|
74
|
+
if (typeof n !== 'function') {
|
|
75
|
+
throw new Error(`Advice method ${a.methodName} not found in ${e.name}`);
|
|
76
|
+
}
|
|
77
|
+
const r = a.pointcut.startsWith('execution(') ? undefined : a.pointcut;
|
|
78
|
+
s.push({
|
|
79
|
+
type: a.type,
|
|
80
|
+
pointcut: a.pointcut,
|
|
81
|
+
method: n,
|
|
82
|
+
transversalInstance: t,
|
|
83
|
+
priority: a.priority || 0,
|
|
84
|
+
enabled: a.enabled ?? true,
|
|
85
|
+
role: r
|
|
86
|
+
});
|
|
67
87
|
}
|
|
88
|
+
return s;
|
|
68
89
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
};
|
|
90
|
+
getAspectsForTarget(e) {
|
|
91
|
+
const t = [];
|
|
92
|
+
for (const a of TransversalManager.transversalMetadata.values()){
|
|
93
|
+
if (this.hasMatchingAdviceForClass(a, e)) {
|
|
94
|
+
t.push(a);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return t;
|
|
78
98
|
}
|
|
79
|
-
|
|
80
|
-
return
|
|
99
|
+
hasMatchingAdviceForClass(e, t) {
|
|
100
|
+
return e.advices.some((e)=>{
|
|
101
|
+
if (!e.enabled) return false;
|
|
102
|
+
const a = e.pointcut.match(/execution\(([^.]+)\.[^)]+\)/);
|
|
103
|
+
if (a) {
|
|
104
|
+
const e = a[1];
|
|
105
|
+
const n = this.patternToRegex(e);
|
|
106
|
+
return n.test(t.name);
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
});
|
|
81
110
|
}
|
|
82
|
-
|
|
83
|
-
|
|
111
|
+
patternToRegex(e) {
|
|
112
|
+
if (e === '*') {
|
|
113
|
+
return /.*/;
|
|
114
|
+
}
|
|
115
|
+
const t = e.replace(/[.+?^${}()|[\]\\]/g, '\\$&');
|
|
116
|
+
const a = t.replace(/\*/g, '.*');
|
|
117
|
+
return new RegExp(`^${a}$`);
|
|
84
118
|
}
|
|
85
|
-
|
|
86
|
-
|
|
119
|
+
getAdvicesForJoinPoint(e, a, s, r) {
|
|
120
|
+
const o = [];
|
|
121
|
+
for (const n of a){
|
|
122
|
+
for (const a of n.advices){
|
|
123
|
+
if (!a.enabled) continue;
|
|
124
|
+
const n = pointcutMatcher.PointcutMatcher.parse(a.pointcut);
|
|
125
|
+
if (n.matches(e)) {
|
|
126
|
+
o.push(a);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (s && r) {
|
|
131
|
+
const e = s.constructor.prototype;
|
|
132
|
+
const t = affect.getAffectedMethods(e, r);
|
|
133
|
+
for (const e of t){
|
|
134
|
+
const t = e.transversal;
|
|
135
|
+
const a = typeof t === 'function' ? t.name : String(t);
|
|
136
|
+
let n = TransversalManager.transversalMetadata.get(a);
|
|
137
|
+
if (!n && typeof t === 'function') {
|
|
138
|
+
const e = Object.getPrototypeOf(t);
|
|
139
|
+
if (e && e.name) {
|
|
140
|
+
n = TransversalManager.transversalMetadata.get(e.name);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (!n) {
|
|
144
|
+
console.warn(`@Affect: Transversal ${a} not found. Make sure it's registered in transversals[].`);
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
for (const t of n.advices){
|
|
148
|
+
if (!t.enabled) continue;
|
|
149
|
+
if (e.role && t.role !== e.role) {
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
o.push({
|
|
153
|
+
...t,
|
|
154
|
+
config: e.config
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return o.sort((e, t)=>t.priority - e.priority);
|
|
87
160
|
}
|
|
88
|
-
|
|
89
|
-
|
|
161
|
+
constructor(e){
|
|
162
|
+
this.context = e;
|
|
90
163
|
}
|
|
91
164
|
}
|
|
92
|
-
|
|
165
|
+
TransversalManager.instances = new WeakMap();
|
|
166
|
+
TransversalManager.transversalInstances = new Map();
|
|
167
|
+
TransversalManager.transversalMetadata = new Map();
|
|
93
168
|
|
|
94
|
-
exports.
|
|
169
|
+
exports.TransversalManager = TransversalManager;
|