@eggjs/core-decorator 4.0.0-beta.34 → 4.0.0-beta.36
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/decorator/ConfigSource.d.ts +4 -1
- package/dist/decorator/ConfigSource.js +12 -7
- package/dist/decorator/ContextProto.d.ts +7 -3
- package/dist/decorator/ContextProto.js +12 -8
- package/dist/decorator/EggQualifier.d.ts +6 -2
- package/dist/decorator/EggQualifier.js +12 -7
- package/dist/decorator/InitTypeQualifier.d.ts +6 -2
- package/dist/decorator/InitTypeQualifier.js +12 -7
- package/dist/decorator/Inject.d.ts +16 -12
- package/dist/decorator/Inject.js +81 -106
- package/dist/decorator/ModuleQualifier.d.ts +4 -1
- package/dist/decorator/ModuleQualifier.js +12 -7
- package/dist/decorator/MultiInstanceInfo.d.ts +6 -2
- package/dist/decorator/MultiInstanceInfo.js +12 -7
- package/dist/decorator/MultiInstanceProto.d.ts +6 -2
- package/dist/decorator/MultiInstanceProto.js +32 -33
- package/dist/decorator/Prototype.d.ts +11 -7
- package/dist/decorator/Prototype.js +28 -30
- package/dist/decorator/SingletonProto.d.ts +7 -3
- package/dist/decorator/SingletonProto.js +12 -8
- package/dist/decorator/index.d.ts +10 -10
- package/dist/decorator/index.js +12 -11
- package/dist/index.d.ts +17 -3
- package/dist/index.js +19 -4
- package/dist/util/MetadataUtil.d.ts +38 -34
- package/dist/util/MetadataUtil.js +75 -83
- package/dist/util/PrototypeUtil.d.ts +111 -107
- package/dist/util/PrototypeUtil.js +215 -250
- package/dist/util/QualifierUtil.d.ts +16 -12
- package/dist/util/QualifierUtil.js +66 -91
- package/dist/util/index.d.ts +3 -3
- package/dist/util/index.js +5 -4
- package/package.json +25 -29
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/decorator/ConfigSource.d.ts
|
|
2
|
+
declare function ConfigSourceQualifier(moduleName: string): (target: any, propertyKey?: PropertyKey, parameterIndex?: number) => void;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { ConfigSourceQualifier };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { QualifierUtil } from "../util/QualifierUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import { ConfigSourceQualifierAttribute } from "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/decorator/ConfigSource.ts
|
|
6
|
+
function ConfigSourceQualifier(moduleName) {
|
|
7
|
+
return function(target, propertyKey, parameterIndex) {
|
|
8
|
+
QualifierUtil.addInjectQualifier(target, propertyKey, parameterIndex, ConfigSourceQualifierAttribute, moduleName);
|
|
9
|
+
};
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ConfigSourceQualifier };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { PrototypeDecorator } from "./Prototype.js";
|
|
2
|
+
import { ContextProtoParams } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/decorator/ContextProto.d.ts
|
|
5
|
+
declare function ContextProto(params?: ContextProtoParams): PrototypeDecorator;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { ContextProto };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import { AccessLevel, ObjectInitType } from '@eggjs/tegg-types';
|
|
2
1
|
import { Prototype } from "./Prototype.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
import { AccessLevel, ObjectInitType } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/decorator/ContextProto.ts
|
|
5
|
+
function ContextProto(params) {
|
|
6
|
+
return Prototype({
|
|
7
|
+
initType: ObjectInitType.CONTEXT,
|
|
8
|
+
accessLevel: params?.accessLevel || AccessLevel.PRIVATE,
|
|
9
|
+
...params
|
|
10
|
+
});
|
|
9
11
|
}
|
|
10
|
-
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { ContextProto };
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { EggType } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/decorator/EggQualifier.d.ts
|
|
4
|
+
declare function EggQualifier(eggType: EggType): (target: any, propertyKey?: PropertyKey, parameterIndex?: number) => void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { EggQualifier };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { QualifierUtil } from "../util/QualifierUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import { EggQualifierAttribute } from "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/decorator/EggQualifier.ts
|
|
6
|
+
function EggQualifier(eggType) {
|
|
7
|
+
return function(target, propertyKey, parameterIndex) {
|
|
8
|
+
QualifierUtil.addInjectQualifier(target, propertyKey, parameterIndex, EggQualifierAttribute, eggType);
|
|
9
|
+
};
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { EggQualifier };
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { ObjectInitTypeLike } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/decorator/InitTypeQualifier.d.ts
|
|
4
|
+
declare function InitTypeQualifier(initType: ObjectInitTypeLike): (target: any, propertyKey?: PropertyKey, parameterIndex?: number) => void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { InitTypeQualifier };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { QualifierUtil } from "../util/QualifierUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import { InitTypeQualifierAttribute } from "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/decorator/InitTypeQualifier.ts
|
|
6
|
+
function InitTypeQualifier(initType) {
|
|
7
|
+
return function(target, propertyKey, parameterIndex) {
|
|
8
|
+
QualifierUtil.addInjectQualifier(target, propertyKey, parameterIndex, InitTypeQualifierAttribute, initType);
|
|
9
|
+
};
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { InitTypeQualifier };
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { InjectParams } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/decorator/Inject.d.ts
|
|
4
|
+
type InjectDecorator = (target: any, propertyKey?: PropertyKey, parameterIndex?: number) => void;
|
|
3
5
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
* Inject decorator Factory
|
|
7
|
+
* @param param - Inject parameters
|
|
8
|
+
* @returns Inject decorator
|
|
9
|
+
*/
|
|
10
|
+
declare function Inject(param?: InjectParams | string): InjectDecorator;
|
|
9
11
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
* InjectOptional decorator Factory
|
|
13
|
+
* @param param - InjectOptional parameters
|
|
14
|
+
* @returns InjectOptional decorator
|
|
15
|
+
*/
|
|
16
|
+
declare function InjectOptional(param?: Omit<InjectParams, "optional"> | string): InjectDecorator;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { Inject, InjectDecorator, InjectOptional };
|
package/dist/decorator/Inject.js
CHANGED
|
@@ -1,112 +1,87 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
1
|
+
import { PrototypeUtil } from "../util/PrototypeUtil.js";
|
|
2
|
+
import { QualifierUtil } from "../util/QualifierUtil.js";
|
|
3
|
+
import "../util/index.js";
|
|
4
|
+
import { InitTypeQualifierAttribute, InjectType } from "@eggjs/tegg-types";
|
|
5
|
+
import { ObjectUtils } from "@eggjs/tegg-common-util";
|
|
6
|
+
import { debuglog } from "node:util";
|
|
7
|
+
|
|
8
|
+
//#region src/decorator/Inject.ts
|
|
9
|
+
const debug = debuglog("tegg/core/core-decorator/decorator/Inject");
|
|
6
10
|
function guessInjectInfo(clazz, name, proto) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
return {
|
|
22
|
-
objName,
|
|
23
|
-
initType,
|
|
24
|
-
};
|
|
11
|
+
let objName;
|
|
12
|
+
let initType;
|
|
13
|
+
if (typeof proto === "function" && proto !== Object) {
|
|
14
|
+
const info = PrototypeUtil.getProperty(proto);
|
|
15
|
+
objName = info?.name;
|
|
16
|
+
if (info?.initType) {
|
|
17
|
+
if (!QualifierUtil.getProperQualifier(clazz, name, InitTypeQualifierAttribute)) initType = info.initType;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
objName,
|
|
22
|
+
initType
|
|
23
|
+
};
|
|
25
24
|
}
|
|
26
25
|
/**
|
|
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
|
-
// params allow string or object
|
|
75
|
-
objName = injectParam?.name;
|
|
76
|
-
}
|
|
77
|
-
const injectObject = {
|
|
78
|
-
refIndex: parameterIndex,
|
|
79
|
-
refName: argName,
|
|
80
|
-
objName: objName || argName,
|
|
81
|
-
};
|
|
82
|
-
if (injectParam?.optional) {
|
|
83
|
-
injectObject.optional = true;
|
|
84
|
-
}
|
|
85
|
-
PrototypeUtil.setInjectType(target, InjectType.CONSTRUCTOR);
|
|
86
|
-
PrototypeUtil.addInjectConstructor(target, injectObject);
|
|
87
|
-
if (initType) {
|
|
88
|
-
QualifierUtil.addProperQualifier(target, argName, InitTypeQualifierAttribute, initType);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return function (target, propertyKey, parameterIndex) {
|
|
92
|
-
if (typeof parameterIndex === 'undefined') {
|
|
93
|
-
propertyInject(target, propertyKey);
|
|
94
|
-
}
|
|
95
|
-
else {
|
|
96
|
-
constructorInject(target, parameterIndex);
|
|
97
|
-
}
|
|
98
|
-
};
|
|
26
|
+
* Inject decorator Factory
|
|
27
|
+
* @param param - Inject parameters
|
|
28
|
+
* @returns Inject decorator
|
|
29
|
+
*/
|
|
30
|
+
function Inject(param) {
|
|
31
|
+
const injectParam = typeof param === "string" ? { name: param } : param;
|
|
32
|
+
function propertyInject(target, propertyKey) {
|
|
33
|
+
let objName;
|
|
34
|
+
let initType;
|
|
35
|
+
if (!injectParam) {
|
|
36
|
+
const proto = PrototypeUtil.getDesignType(target, propertyKey);
|
|
37
|
+
const result = guessInjectInfo(target.constructor, propertyKey, proto);
|
|
38
|
+
objName = result.objName;
|
|
39
|
+
initType = result.initType;
|
|
40
|
+
} else objName = injectParam?.name;
|
|
41
|
+
const injectObject = {
|
|
42
|
+
refName: propertyKey,
|
|
43
|
+
objName: objName || propertyKey
|
|
44
|
+
};
|
|
45
|
+
if (injectParam?.optional) injectObject.optional = true;
|
|
46
|
+
PrototypeUtil.setInjectType(target.constructor, InjectType.PROPERTY);
|
|
47
|
+
PrototypeUtil.addInjectObject(target.constructor, injectObject);
|
|
48
|
+
debug("propertyInject, clazz: %s, propertyKey: %s, injectObject: %o", target.constructor.name, propertyKey, injectObject);
|
|
49
|
+
if (initType) QualifierUtil.addProperQualifier(target.constructor, propertyKey, InitTypeQualifierAttribute, initType);
|
|
50
|
+
}
|
|
51
|
+
function constructorInject(target, parameterIndex) {
|
|
52
|
+
const argName = ObjectUtils.getConstructorArgNameList(target)[parameterIndex];
|
|
53
|
+
let objName;
|
|
54
|
+
let initType;
|
|
55
|
+
if (!injectParam) {
|
|
56
|
+
const protos = PrototypeUtil.getDesignParamtypes(target);
|
|
57
|
+
({objName, initType} = guessInjectInfo(target, argName, protos?.[parameterIndex]));
|
|
58
|
+
} else objName = injectParam?.name;
|
|
59
|
+
const injectObject = {
|
|
60
|
+
refIndex: parameterIndex,
|
|
61
|
+
refName: argName,
|
|
62
|
+
objName: objName || argName
|
|
63
|
+
};
|
|
64
|
+
if (injectParam?.optional) injectObject.optional = true;
|
|
65
|
+
PrototypeUtil.setInjectType(target, InjectType.CONSTRUCTOR);
|
|
66
|
+
PrototypeUtil.addInjectConstructor(target, injectObject);
|
|
67
|
+
if (initType) QualifierUtil.addProperQualifier(target, argName, InitTypeQualifierAttribute, initType);
|
|
68
|
+
}
|
|
69
|
+
return function(target, propertyKey, parameterIndex) {
|
|
70
|
+
if (typeof parameterIndex === "undefined") propertyInject(target, propertyKey);
|
|
71
|
+
else constructorInject(target, parameterIndex);
|
|
72
|
+
};
|
|
99
73
|
}
|
|
100
74
|
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
});
|
|
75
|
+
* InjectOptional decorator Factory
|
|
76
|
+
* @param param - InjectOptional parameters
|
|
77
|
+
* @returns InjectOptional decorator
|
|
78
|
+
*/
|
|
79
|
+
function InjectOptional(param) {
|
|
80
|
+
return Inject({
|
|
81
|
+
...typeof param === "string" ? { name: param } : param,
|
|
82
|
+
optional: true
|
|
83
|
+
});
|
|
111
84
|
}
|
|
112
|
-
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { Inject, InjectOptional };
|
|
@@ -1 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/decorator/ModuleQualifier.d.ts
|
|
2
|
+
declare function ModuleQualifier(moduleName: string): (target: any, propertyKey?: PropertyKey, parameterIndex?: number) => void;
|
|
3
|
+
//#endregion
|
|
4
|
+
export { ModuleQualifier };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { QualifierUtil } from "../util/QualifierUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import { LoadUnitNameQualifierAttribute } from "@eggjs/tegg-types";
|
|
4
|
+
|
|
5
|
+
//#region src/decorator/ModuleQualifier.ts
|
|
6
|
+
function ModuleQualifier(moduleName) {
|
|
7
|
+
return function(target, propertyKey, parameterIndex) {
|
|
8
|
+
QualifierUtil.addInjectQualifier(target, propertyKey, parameterIndex, LoadUnitNameQualifierAttribute, moduleName);
|
|
9
|
+
};
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { ModuleQualifier };
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { QualifierAttribute } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/decorator/MultiInstanceInfo.d.ts
|
|
4
|
+
declare function MultiInstanceInfo(attributes: QualifierAttribute[]): (target: any, _propertyKey: PropertyKey | undefined, parameterIndex: number) => void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { MultiInstanceInfo };
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { PrototypeUtil } from "../util/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { PrototypeUtil } from "../util/PrototypeUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
|
|
4
|
+
//#region src/decorator/MultiInstanceInfo.ts
|
|
5
|
+
function MultiInstanceInfo(attributes) {
|
|
6
|
+
return function(target, _propertyKey, parameterIndex) {
|
|
7
|
+
PrototypeUtil.setMultiInstanceConstructorIndex(target, parameterIndex);
|
|
8
|
+
PrototypeUtil.setMultiInstanceConstructorAttributes(target, attributes);
|
|
9
|
+
};
|
|
7
10
|
}
|
|
8
|
-
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { MultiInstanceInfo };
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { EggProtoImplClass, MultiInstancePrototypeParams } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/decorator/MultiInstanceProto.d.ts
|
|
4
|
+
declare function MultiInstanceProto(param: MultiInstancePrototypeParams): (clazz: EggProtoImplClass) => void;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { MultiInstanceProto };
|
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { PrototypeUtil } from "../util/PrototypeUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import { AccessLevel, DEFAULT_PROTO_IMPL_TYPE, ObjectInitType } from "@eggjs/tegg-types";
|
|
4
|
+
import { StackUtil } from "@eggjs/tegg-common-util";
|
|
5
|
+
|
|
6
|
+
//#region src/decorator/MultiInstanceProto.ts
|
|
4
7
|
const DEFAULT_PARAMS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
initType: ObjectInitType.SINGLETON,
|
|
9
|
+
accessLevel: AccessLevel.PRIVATE,
|
|
10
|
+
protoImplType: DEFAULT_PROTO_IMPL_TYPE
|
|
8
11
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// './tegg/core/core-decorator/src/decorator/Prototype.ts',
|
|
30
|
-
// './tegg/core/core-decorator/node_modules/_reflect-metadata@0.1.13@reflect-metadata/Reflect.js',
|
|
31
|
-
// './tegg/core/core-decorator/node_modules/_reflect-metadata@0.1.13@reflect-metadata/Reflect.js',
|
|
32
|
-
// './tegg/core/core-decorator/test/fixtures/decators/CacheService.ts',
|
|
33
|
-
PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 4));
|
|
34
|
-
};
|
|
12
|
+
function MultiInstanceProto(param) {
|
|
13
|
+
return function(clazz) {
|
|
14
|
+
PrototypeUtil.setIsEggMultiInstancePrototype(clazz);
|
|
15
|
+
if (param.objects) {
|
|
16
|
+
const property = {
|
|
17
|
+
...DEFAULT_PARAMS,
|
|
18
|
+
...param,
|
|
19
|
+
className: clazz.name
|
|
20
|
+
};
|
|
21
|
+
PrototypeUtil.setMultiInstanceStaticProperty(clazz, property);
|
|
22
|
+
} else if (param.getObjects) {
|
|
23
|
+
const property = {
|
|
24
|
+
...DEFAULT_PARAMS,
|
|
25
|
+
...param,
|
|
26
|
+
className: clazz.name
|
|
27
|
+
};
|
|
28
|
+
PrototypeUtil.setMultiInstanceCallbackProperty(clazz, property);
|
|
29
|
+
}
|
|
30
|
+
PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 4));
|
|
31
|
+
};
|
|
35
32
|
}
|
|
36
|
-
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
export { MultiInstanceProto };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { EggProtoImplClass, PrototypeParams } from "@eggjs/tegg-types";
|
|
2
|
+
|
|
3
|
+
//#region src/decorator/Prototype.d.ts
|
|
4
|
+
type PrototypeDecorator = (clazz: EggProtoImplClass) => void;
|
|
3
5
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
* Prototype decorator Factory
|
|
7
|
+
* @param param - Prototype parameters
|
|
8
|
+
* @returns Prototype decorator
|
|
9
|
+
*/
|
|
10
|
+
declare function Prototype(param?: PrototypeParams): PrototypeDecorator;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { Prototype, PrototypeDecorator };
|
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { PrototypeUtil } from "../util/PrototypeUtil.js";
|
|
2
|
+
import "../util/index.js";
|
|
3
|
+
import { AccessLevel, DEFAULT_PROTO_IMPL_TYPE, ObjectInitType } from "@eggjs/tegg-types";
|
|
4
|
+
import { NameUtil, StackUtil } from "@eggjs/tegg-common-util";
|
|
5
|
+
|
|
6
|
+
//#region src/decorator/Prototype.ts
|
|
4
7
|
const DEFAULT_PARAMS = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
initType: ObjectInitType.SINGLETON,
|
|
9
|
+
accessLevel: AccessLevel.PRIVATE,
|
|
10
|
+
protoImplType: DEFAULT_PROTO_IMPL_TYPE
|
|
8
11
|
};
|
|
9
12
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
// './tegg/core/common-util/src/StackUtil.ts',
|
|
27
|
-
// './tegg/core/core-decorator/src/decorator/Prototype.ts',
|
|
28
|
-
// './tegg/core/core-decorator/node_modules/_reflect-metadata@0.1.13@reflect-metadata/Reflect.js',
|
|
29
|
-
// './tegg/core/core-decorator/node_modules/_reflect-metadata@0.1.13@reflect-metadata/Reflect.js',
|
|
30
|
-
// './tegg/core/core-decorator/test/fixtures/decators/CacheService.ts',
|
|
31
|
-
PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 4));
|
|
32
|
-
};
|
|
13
|
+
* Prototype decorator Factory
|
|
14
|
+
* @param param - Prototype parameters
|
|
15
|
+
* @returns Prototype decorator
|
|
16
|
+
*/
|
|
17
|
+
function Prototype(param) {
|
|
18
|
+
return function(clazz) {
|
|
19
|
+
PrototypeUtil.setIsEggPrototype(clazz);
|
|
20
|
+
const property = {
|
|
21
|
+
...DEFAULT_PARAMS,
|
|
22
|
+
...param,
|
|
23
|
+
className: clazz.name
|
|
24
|
+
};
|
|
25
|
+
if (!property.name) property.name = NameUtil.getClassName(clazz);
|
|
26
|
+
PrototypeUtil.setProperty(clazz, property);
|
|
27
|
+
PrototypeUtil.setFilePath(clazz, StackUtil.getCalleeFromStack(false, 4));
|
|
28
|
+
};
|
|
33
29
|
}
|
|
34
|
-
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { Prototype };
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { PrototypeDecorator } from "./Prototype.js";
|
|
2
|
+
import { SingletonProtoParams } from "@eggjs/tegg-types";
|
|
3
|
+
|
|
4
|
+
//#region src/decorator/SingletonProto.d.ts
|
|
5
|
+
declare function SingletonProto(params?: SingletonProtoParams): PrototypeDecorator;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { SingletonProto };
|