@adaas/a-concept 0.1.23 → 0.1.25
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/index.cjs +3 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +3952 -0
- package/dist/index.d.ts +3952 -50
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -6
- package/src/global/A-Abstraction/A-Abstraction-Extend.decorator.ts +18 -13
- package/src/global/A-Component/A-Component.meta.ts +3 -2
- package/src/global/A-Container/A-Container.meta.ts +5 -8
- package/src/global/A-Context/A-Context.class.ts +81 -7
- package/src/global/A-Context/A-Context.error.ts +4 -0
- package/src/global/A-Dependency/A-Dependency-Default.decorator.ts +75 -0
- package/src/global/A-Dependency/A-Dependency-Load.decorator.ts +80 -0
- package/src/global/A-Dependency/A-Dependency-Require.decorator.ts +68 -0
- package/src/global/A-Dependency/A-Dependency.class.ts +33 -0
- package/src/global/A-Dependency/A-Dependency.error.ts +13 -0
- package/src/global/A-Dependency/A-Dependency.types.ts +28 -0
- package/src/global/A-Entity/A-Entity.class.ts +2 -1
- package/src/global/A-Feature/A-Feature-Define.decorator.ts +7 -4
- package/src/global/A-Feature/A-Feature-Extend.decorator.ts +23 -17
- package/src/global/A-Feature/A-Feature.class.ts +12 -1
- package/src/global/A-Feature/A-Feature.types.ts +33 -8
- package/src/global/A-Inject/A-Inject.decorator.ts +4 -2
- package/src/global/A-Inject/A-Inject.types.ts +5 -3
- package/src/global/A-Scope/A-Scope.class.ts +85 -57
- package/src/global/A-Stage/A-Stage.class.ts +22 -2
- package/src/global/A-Stage/A-Stage.error.ts +2 -0
- package/src/global/A-Stage/A-Stage.types.ts +7 -2
- package/src/global/A-StepManager/A-StepManager.class.ts +19 -13
- package/src/helpers/A_Common.helper.ts +101 -0
- package/src/helpers/A_TypeGuards.helper.ts +8 -0
- package/src/index.ts +88 -0
- package/tests/A-Component.test.ts +1 -1
- package/tests/A-Concept.test.ts +58 -10
- package/tests/A-Dependency.test.ts +93 -0
- package/tests/A-Feature.test.ts +11 -11
- package/tests/A-Scope.test.ts +10 -10
- package/tests/A-StepManager.test.ts +60 -11
- package/tsconfig.json +2 -2
- package/tsup.config.ts +32 -0
- package/dist/index.js +0 -112
- package/dist/index.js.map +0 -1
- package/dist/src/constants/env.constants.d.ts +0 -33
- package/dist/src/constants/env.constants.js +0 -47
- package/dist/src/constants/env.constants.js.map +0 -1
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.d.ts +0 -23
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js +0 -89
- package/dist/src/global/A-Abstraction/A-Abstraction-Extend.decorator.js.map +0 -1
- package/dist/src/global/A-Abstraction/A-Abstraction.class.d.ts +0 -74
- package/dist/src/global/A-Abstraction/A-Abstraction.class.js +0 -130
- package/dist/src/global/A-Abstraction/A-Abstraction.class.js.map +0 -1
- package/dist/src/global/A-Abstraction/A-Abstraction.error.d.ts +0 -7
- package/dist/src/global/A-Abstraction/A-Abstraction.error.js +0 -12
- package/dist/src/global/A-Abstraction/A-Abstraction.error.js.map +0 -1
- package/dist/src/global/A-Abstraction/A-Abstraction.types.d.ts +0 -38
- package/dist/src/global/A-Abstraction/A-Abstraction.types.js +0 -3
- package/dist/src/global/A-Abstraction/A-Abstraction.types.js.map +0 -1
- package/dist/src/global/A-Caller/A_Caller.class.d.ts +0 -33
- package/dist/src/global/A-Caller/A_Caller.class.js +0 -44
- package/dist/src/global/A-Caller/A_Caller.class.js.map +0 -1
- package/dist/src/global/A-Caller/A_Caller.error.d.ts +0 -7
- package/dist/src/global/A-Caller/A_Caller.error.js +0 -12
- package/dist/src/global/A-Caller/A_Caller.error.js.map +0 -1
- package/dist/src/global/A-Caller/A_Caller.types.d.ts +0 -18
- package/dist/src/global/A-Caller/A_Caller.types.js +0 -3
- package/dist/src/global/A-Caller/A_Caller.types.js.map +0 -1
- package/dist/src/global/A-Component/A-Component.class.d.ts +0 -34
- package/dist/src/global/A-Component/A-Component.class.js +0 -56
- package/dist/src/global/A-Component/A-Component.class.js.map +0 -1
- package/dist/src/global/A-Component/A-Component.constants.d.ts +0 -6
- package/dist/src/global/A-Component/A-Component.constants.js +0 -11
- package/dist/src/global/A-Component/A-Component.constants.js.map +0 -1
- package/dist/src/global/A-Component/A-Component.meta.d.ts +0 -34
- package/dist/src/global/A-Component/A-Component.meta.js +0 -77
- package/dist/src/global/A-Component/A-Component.meta.js.map +0 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +0 -76
- package/dist/src/global/A-Component/A-Component.types.js +0 -4
- package/dist/src/global/A-Component/A-Component.types.js.map +0 -1
- package/dist/src/global/A-Concept/A-Concept.class.d.ts +0 -153
- package/dist/src/global/A-Concept/A-Concept.class.js +0 -260
- package/dist/src/global/A-Concept/A-Concept.class.js.map +0 -1
- package/dist/src/global/A-Concept/A-Concept.constants.d.ts +0 -33
- package/dist/src/global/A-Concept/A-Concept.constants.js +0 -39
- package/dist/src/global/A-Concept/A-Concept.constants.js.map +0 -1
- package/dist/src/global/A-Concept/A-Concept.meta.d.ts +0 -6
- package/dist/src/global/A-Concept/A-Concept.meta.js +0 -12
- package/dist/src/global/A-Concept/A-Concept.meta.js.map +0 -1
- package/dist/src/global/A-Concept/A-Concept.types.d.ts +0 -66
- package/dist/src/global/A-Concept/A-Concept.types.js +0 -3
- package/dist/src/global/A-Concept/A-Concept.types.js.map +0 -1
- package/dist/src/global/A-Container/A-Container.class.d.ts +0 -52
- package/dist/src/global/A-Container/A-Container.class.js +0 -78
- package/dist/src/global/A-Container/A-Container.class.js.map +0 -1
- package/dist/src/global/A-Container/A-Container.constants.d.ts +0 -6
- package/dist/src/global/A-Container/A-Container.constants.js +0 -11
- package/dist/src/global/A-Container/A-Container.constants.js.map +0 -1
- package/dist/src/global/A-Container/A-Container.meta.d.ts +0 -35
- package/dist/src/global/A-Container/A-Container.meta.js +0 -83
- package/dist/src/global/A-Container/A-Container.meta.js.map +0 -1
- package/dist/src/global/A-Container/A-Container.types.d.ts +0 -75
- package/dist/src/global/A-Container/A-Container.types.js +0 -4
- package/dist/src/global/A-Container/A-Container.types.js.map +0 -1
- package/dist/src/global/A-Context/A-Context.class.d.ts +0 -361
- package/dist/src/global/A-Context/A-Context.class.js +0 -603
- package/dist/src/global/A-Context/A-Context.class.js.map +0 -1
- package/dist/src/global/A-Context/A-Context.error.d.ts +0 -20
- package/dist/src/global/A-Context/A-Context.error.js +0 -25
- package/dist/src/global/A-Context/A-Context.error.js.map +0 -1
- package/dist/src/global/A-Context/A-Context.types.d.ts +0 -5
- package/dist/src/global/A-Context/A-Context.types.js +0 -3
- package/dist/src/global/A-Context/A-Context.types.js.map +0 -1
- package/dist/src/global/A-Dependency/A-DependencyReference.class.d.ts +0 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js +0 -49
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +0 -1
- package/dist/src/global/A-Dependency/A-DependencyReference.types.d.ts +0 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.types.js +0 -58
- package/dist/src/global/A-Dependency/A-DependencyReference.types.js.map +0 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +0 -214
- package/dist/src/global/A-Entity/A-Entity.class.js +0 -281
- package/dist/src/global/A-Entity/A-Entity.class.js.map +0 -1
- package/dist/src/global/A-Entity/A-Entity.constants.d.ts +0 -11
- package/dist/src/global/A-Entity/A-Entity.constants.js +0 -17
- package/dist/src/global/A-Entity/A-Entity.constants.js.map +0 -1
- package/dist/src/global/A-Entity/A-Entity.error.d.ts +0 -7
- package/dist/src/global/A-Entity/A-Entity.error.js +0 -12
- package/dist/src/global/A-Entity/A-Entity.error.js.map +0 -1
- package/dist/src/global/A-Entity/A-Entity.meta.d.ts +0 -11
- package/dist/src/global/A-Entity/A-Entity.meta.js +0 -18
- package/dist/src/global/A-Entity/A-Entity.meta.js.map +0 -1
- package/dist/src/global/A-Entity/A-Entity.types.d.ts +0 -56
- package/dist/src/global/A-Entity/A-Entity.types.js +0 -5
- package/dist/src/global/A-Entity/A-Entity.types.js.map +0 -1
- package/dist/src/global/A-Error/A_Error.class.d.ts +0 -229
- package/dist/src/global/A-Error/A_Error.class.js +0 -296
- package/dist/src/global/A-Error/A_Error.class.js.map +0 -1
- package/dist/src/global/A-Error/A_Error.constants.d.ts +0 -5
- package/dist/src/global/A-Error/A_Error.constants.js +0 -9
- package/dist/src/global/A-Error/A_Error.constants.js.map +0 -1
- package/dist/src/global/A-Error/A_Error.types.d.ts +0 -93
- package/dist/src/global/A-Error/A_Error.types.js +0 -3
- package/dist/src/global/A-Error/A_Error.types.js.map +0 -1
- package/dist/src/global/A-Feature/A-Feature-Define.decorator.d.ts +0 -15
- package/dist/src/global/A-Feature/A-Feature-Define.decorator.js +0 -76
- package/dist/src/global/A-Feature/A-Feature-Define.decorator.js.map +0 -1
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.d.ts +0 -56
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js +0 -119
- package/dist/src/global/A-Feature/A-Feature-Extend.decorator.js.map +0 -1
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +0 -175
- package/dist/src/global/A-Feature/A-Feature.class.js +0 -318
- package/dist/src/global/A-Feature/A-Feature.class.js.map +0 -1
- package/dist/src/global/A-Feature/A-Feature.error.d.ts +0 -25
- package/dist/src/global/A-Feature/A-Feature.error.js +0 -33
- package/dist/src/global/A-Feature/A-Feature.error.js.map +0 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +0 -310
- package/dist/src/global/A-Feature/A-Feature.types.js +0 -26
- package/dist/src/global/A-Feature/A-Feature.types.js.map +0 -1
- package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +0 -36
- package/dist/src/global/A-Fragment/A-Fragment.class.js +0 -46
- package/dist/src/global/A-Fragment/A-Fragment.class.js.map +0 -1
- package/dist/src/global/A-Fragment/A-Fragment.types.d.ts +0 -21
- package/dist/src/global/A-Fragment/A-Fragment.types.js +0 -6
- package/dist/src/global/A-Fragment/A-Fragment.types.js.map +0 -1
- package/dist/src/global/A-Inject/A-Inject.decorator.d.ts +0 -80
- package/dist/src/global/A-Inject/A-Inject.decorator.js +0 -49
- package/dist/src/global/A-Inject/A-Inject.decorator.js.map +0 -1
- package/dist/src/global/A-Inject/A-Inject.error.d.ts +0 -5
- package/dist/src/global/A-Inject/A-Inject.error.js +0 -10
- package/dist/src/global/A-Inject/A-Inject.error.js.map +0 -1
- package/dist/src/global/A-Inject/A-Inject.types.d.ts +0 -42
- package/dist/src/global/A-Inject/A-Inject.types.js +0 -3
- package/dist/src/global/A-Inject/A-Inject.types.js.map +0 -1
- package/dist/src/global/A-Meta/A-Meta.class.d.ts +0 -97
- package/dist/src/global/A-Meta/A-Meta.class.js +0 -164
- package/dist/src/global/A-Meta/A-Meta.class.js.map +0 -1
- package/dist/src/global/A-Meta/A-Meta.types.d.ts +0 -14
- package/dist/src/global/A-Meta/A-Meta.types.js +0 -3
- package/dist/src/global/A-Meta/A-Meta.types.js.map +0 -1
- package/dist/src/global/A-Scope/A-Scope.class.d.ts +0 -466
- package/dist/src/global/A-Scope/A-Scope.class.js +0 -791
- package/dist/src/global/A-Scope/A-Scope.class.js.map +0 -1
- package/dist/src/global/A-Scope/A-Scope.error.d.ts +0 -8
- package/dist/src/global/A-Scope/A-Scope.error.js +0 -13
- package/dist/src/global/A-Scope/A-Scope.error.js.map +0 -1
- package/dist/src/global/A-Scope/A-Scope.types.d.ts +0 -81
- package/dist/src/global/A-Scope/A-Scope.types.js +0 -3
- package/dist/src/global/A-Scope/A-Scope.types.js.map +0 -1
- package/dist/src/global/A-Stage/A-Stage.class.d.ts +0 -112
- package/dist/src/global/A-Stage/A-Stage.class.js +0 -240
- package/dist/src/global/A-Stage/A-Stage.class.js.map +0 -1
- package/dist/src/global/A-Stage/A-Stage.error.d.ts +0 -4
- package/dist/src/global/A-Stage/A-Stage.error.js +0 -11
- package/dist/src/global/A-Stage/A-Stage.error.js.map +0 -1
- package/dist/src/global/A-Stage/A-Stage.types.d.ts +0 -97
- package/dist/src/global/A-Stage/A-Stage.types.js +0 -43
- package/dist/src/global/A-Stage/A-Stage.types.js.map +0 -1
- package/dist/src/global/A-StepManager/A-StepManager.class.d.ts +0 -20
- package/dist/src/global/A-StepManager/A-StepManager.class.js +0 -111
- package/dist/src/global/A-StepManager/A-StepManager.class.js.map +0 -1
- package/dist/src/global/A-StepManager/A-StepManager.error.d.ts +0 -4
- package/dist/src/global/A-StepManager/A-StepManager.error.js +0 -9
- package/dist/src/global/A-StepManager/A-StepManager.error.js.map +0 -1
- package/dist/src/global/ASEID/ASEID.class.d.ts +0 -130
- package/dist/src/global/ASEID/ASEID.class.js +0 -167
- package/dist/src/global/ASEID/ASEID.class.js.map +0 -1
- package/dist/src/global/ASEID/ASEID.constants.d.ts +0 -0
- package/dist/src/global/ASEID/ASEID.constants.js +0 -2
- package/dist/src/global/ASEID/ASEID.constants.js.map +0 -1
- package/dist/src/global/ASEID/ASEID.error.d.ts +0 -5
- package/dist/src/global/ASEID/ASEID.error.js +0 -10
- package/dist/src/global/ASEID/ASEID.error.js.map +0 -1
- package/dist/src/global/ASEID/ASEID.types.d.ts +0 -65
- package/dist/src/global/ASEID/ASEID.types.js +0 -5
- package/dist/src/global/ASEID/ASEID.types.js.map +0 -1
- package/dist/src/helpers/A_Common.helper.d.ts +0 -28
- package/dist/src/helpers/A_Common.helper.js +0 -170
- package/dist/src/helpers/A_Common.helper.js.map +0 -1
- package/dist/src/helpers/A_Formatter.helper.d.ts +0 -35
- package/dist/src/helpers/A_Formatter.helper.js +0 -62
- package/dist/src/helpers/A_Formatter.helper.js.map +0 -1
- package/dist/src/helpers/A_Identity.helper.d.ts +0 -29
- package/dist/src/helpers/A_Identity.helper.js +0 -43
- package/dist/src/helpers/A_Identity.helper.js.map +0 -1
- package/dist/src/helpers/A_TypeGuards.helper.d.ts +0 -207
- package/dist/src/helpers/A_TypeGuards.helper.js +0 -296
- package/dist/src/helpers/A_TypeGuards.helper.js.map +0 -1
- package/dist/src/types/A_Common.types.d.ts +0 -36
- package/dist/src/types/A_Common.types.js +0 -3
- package/dist/src/types/A_Common.types.js.map +0 -1
- package/index.ts +0 -81
- package/src/global/A-Dependency/A-DependencyReference.class.ts +0 -61
- package/src/global/A-Dependency/A-DependencyReference.types.ts +0 -61
- package/trace-require.js +0 -46
- package/tsconfig.build.json +0 -58
|
@@ -1,296 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_Error = void 0;
|
|
4
|
-
const A_Error_constants_1 = require("./A_Error.constants");
|
|
5
|
-
const A_Formatter_helper_1 = require("../../helpers/A_Formatter.helper");
|
|
6
|
-
const A_Context_class_1 = require("../A-Context/A-Context.class");
|
|
7
|
-
const A_TypeGuards_helper_1 = require("../../helpers/A_TypeGuards.helper");
|
|
8
|
-
const ASEID_class_1 = require("../ASEID/ASEID.class");
|
|
9
|
-
const env_constants_1 = require("../../constants/env.constants");
|
|
10
|
-
class A_Error extends Error {
|
|
11
|
-
// ====================================================================
|
|
12
|
-
// ================== Static A-Error Information ======================
|
|
13
|
-
// ====================================================================
|
|
14
|
-
/**
|
|
15
|
-
* Error Identifier that corresponds to the class name
|
|
16
|
-
*/
|
|
17
|
-
static get entity() {
|
|
18
|
-
return A_Formatter_helper_1.A_FormatterHelper.toKebabCase(this.name);
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* DEFAULT Namespace of the error from environment variable A_CONCEPT_NAMESPACE
|
|
22
|
-
*
|
|
23
|
-
* [!] If environment variable is not set, it will default to 'a-concept'
|
|
24
|
-
*/
|
|
25
|
-
static get concept() {
|
|
26
|
-
return A_Context_class_1.A_Context.concept;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* DEFAULT Scope of the entity from environment variable A_CONCEPT_DEFAULT_SCOPE
|
|
30
|
-
*
|
|
31
|
-
* [!] If environment variable is not set, it will default to 'core'
|
|
32
|
-
* [!] Scope is an application specific identifier that can be used to group entities together
|
|
33
|
-
* [!] e.g. 'default', 'core', 'public', 'internal', etc
|
|
34
|
-
*/
|
|
35
|
-
static get scope() {
|
|
36
|
-
return A_Context_class_1.A_Context.root.name;
|
|
37
|
-
}
|
|
38
|
-
constructor(param1, param2) {
|
|
39
|
-
// to prevent errors accumulation in the stack trace it returns the original error if provided param1 is A_Error
|
|
40
|
-
switch (true) {
|
|
41
|
-
case param1 instanceof A_Error:
|
|
42
|
-
return param1;
|
|
43
|
-
case param1 instanceof Error:
|
|
44
|
-
super(param1.message);
|
|
45
|
-
break;
|
|
46
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isConstructorType(param1) && 'description' in param1:
|
|
47
|
-
super(`[${param1.title}]: ${param1.description}`);
|
|
48
|
-
break;
|
|
49
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isConstructorType(param1) && !('description' in param1):
|
|
50
|
-
super(param1.title);
|
|
51
|
-
break;
|
|
52
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isString(param1) && !param2:
|
|
53
|
-
super(param1);
|
|
54
|
-
break;
|
|
55
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isString(param1) && !!param2:
|
|
56
|
-
super(`[${param1}]: ${param2}`);
|
|
57
|
-
break;
|
|
58
|
-
default:
|
|
59
|
-
throw new A_Error(A_Error_constants_1.A_CONSTANTS__ERROR_CODES.VALIDATION_ERROR, 'Invalid parameters provided to A_Error constructor');
|
|
60
|
-
}
|
|
61
|
-
const initializer = this.getInitializer(param1, param2);
|
|
62
|
-
// the returned initializer is already bound to `this` (we used .bind(this)),
|
|
63
|
-
// so calling it will run the appropriate logic on this instance:
|
|
64
|
-
initializer.call(this, param1, param2);
|
|
65
|
-
}
|
|
66
|
-
// ====================================================================
|
|
67
|
-
// ================== Public A-Error Information ======================
|
|
68
|
-
// ====================================================================
|
|
69
|
-
/**
|
|
70
|
-
* Returns the ASEID of the error instance
|
|
71
|
-
*/
|
|
72
|
-
get aseid() {
|
|
73
|
-
return this._aseid;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Returns the title of the error
|
|
77
|
-
*
|
|
78
|
-
* Example: 'User not found', 'Validation error', 'Unauthorized access', etc.
|
|
79
|
-
*
|
|
80
|
-
* [!] Note: This title should be short and concise, less than 60 characters
|
|
81
|
-
* [!] Note: If title exceeds 60 characters, there would be an error thrown
|
|
82
|
-
* [!] Note: This title is intended to be human-readable and can be displayed in UI or logs
|
|
83
|
-
*/
|
|
84
|
-
get title() {
|
|
85
|
-
return this._title;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Returns an Error message what is a brief title of the error
|
|
89
|
-
*
|
|
90
|
-
*/
|
|
91
|
-
get message() {
|
|
92
|
-
return super.message;
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Returns a unique code representing the type of error
|
|
96
|
-
*
|
|
97
|
-
* If code is not provided, it will generate a kebab-case of the message
|
|
98
|
-
*
|
|
99
|
-
* Example: 'validation-error', 'not-found', 'user-not-found', 'unauthorized' etc.
|
|
100
|
-
*
|
|
101
|
-
* [!] Note: It is recommended to use kebab-case for error codes
|
|
102
|
-
* [!] Note: If not provided would be used a kebab-case message of the error
|
|
103
|
-
*/
|
|
104
|
-
get code() {
|
|
105
|
-
return this._code || A_Formatter_helper_1.A_FormatterHelper.toKebabCase(this.title);
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Returns the type of the error which corresponds to the static entity of the class
|
|
109
|
-
*
|
|
110
|
-
* Example: 'a-error', 'validation-error', 'not-found-error', 'user-error', etc.
|
|
111
|
-
*
|
|
112
|
-
* Defaults to the kebab-case of the class name
|
|
113
|
-
*
|
|
114
|
-
* [!] Note: naming ad separation are fully dependent on the architecture of the application
|
|
115
|
-
* [!] Note: It is recommended to use kebab-case for error types
|
|
116
|
-
* [!] Note: This type is intended to group similar errors together
|
|
117
|
-
*/
|
|
118
|
-
get type() {
|
|
119
|
-
return this.constructor.entity;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Returns a link with possible documentation or support page for the error
|
|
123
|
-
* If link is not provided, it will generate a link based on the ASEID of the error that points to the A-Concept support page
|
|
124
|
-
*
|
|
125
|
-
* Example: https://adaas.support/a-concept/errors/{ASEID}
|
|
126
|
-
*
|
|
127
|
-
* [!] Note: ASEID is generated based on the static properties of the class (concept, scope, entity) and the code of the error
|
|
128
|
-
*/
|
|
129
|
-
get link() {
|
|
130
|
-
if (this._link)
|
|
131
|
-
return this._link;
|
|
132
|
-
const url = new URL(`https://adaas.support/a-concept/errors/${this.aseid.toString()}`);
|
|
133
|
-
return url.toString();
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* The scope name of the error instance
|
|
137
|
-
*
|
|
138
|
-
* If scope is not provided, it will use the static scope of the class
|
|
139
|
-
*
|
|
140
|
-
* [!] Note: Scope is an application specific identifier that can be used to group entities together
|
|
141
|
-
* [!] e.g. 'default', 'core', 'public', 'internal', etc
|
|
142
|
-
*/
|
|
143
|
-
get scope() {
|
|
144
|
-
return this._aseid.scope;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* A detailed description of the error
|
|
148
|
-
* If description is not provided, it will use the environment variable A_ERROR_DEFAULT_DESCRIPTION or a generic message
|
|
149
|
-
*
|
|
150
|
-
* Example: 'The user with the given ID was not found.', 'The provided data is invalid.', 'You do not have permission to access this resource.', etc.
|
|
151
|
-
*
|
|
152
|
-
* [!] Note: This description is intended to provide more context about the error and can be used for debugging or logging purposes
|
|
153
|
-
*/
|
|
154
|
-
get description() {
|
|
155
|
-
return this._description || process.env[env_constants_1.A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_ERROR_DEFAULT_DESCRIPTION] || A_Error_constants_1.A_CONSTANTS__ERROR_DESCRIPTION;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Returns the original error if any
|
|
159
|
-
*
|
|
160
|
-
* This can be useful for debugging purposes to see the original stack trace or error message
|
|
161
|
-
*
|
|
162
|
-
* [!] Note: Original error is optional and may not be present in all cases
|
|
163
|
-
*/
|
|
164
|
-
get originalError() {
|
|
165
|
-
return this._originalError;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Determines which initializer method to use based on the type of the first parameter.
|
|
169
|
-
*
|
|
170
|
-
* @param param1
|
|
171
|
-
* @returns
|
|
172
|
-
*/
|
|
173
|
-
getInitializer(param1, param2) {
|
|
174
|
-
switch (true) {
|
|
175
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isString(param1) && !param2:
|
|
176
|
-
return this.fromMessage;
|
|
177
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isString(param1) && !!param2:
|
|
178
|
-
return this.fromTitle;
|
|
179
|
-
case param1 instanceof Error:
|
|
180
|
-
return this.fromError;
|
|
181
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isConstructorType(param1):
|
|
182
|
-
return this.fromConstructor;
|
|
183
|
-
default: {
|
|
184
|
-
console.log('INVALID PARAMS PROVIDED TO A_ERROR CONSTRUCTOR: ', param1);
|
|
185
|
-
throw new A_Error(A_Error_constants_1.A_CONSTANTS__ERROR_CODES.VALIDATION_ERROR, 'Invalid parameters provided to A_Error constructor');
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Initializes the A_Error instance from a standard Error object.
|
|
191
|
-
*
|
|
192
|
-
* @param error
|
|
193
|
-
*/
|
|
194
|
-
fromError(error) {
|
|
195
|
-
this._title = A_Error_constants_1.A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR;
|
|
196
|
-
this._aseid = new ASEID_class_1.ASEID({
|
|
197
|
-
concept: this.constructor.concept,
|
|
198
|
-
scope: this.constructor.scope,
|
|
199
|
-
entity: this.constructor.entity,
|
|
200
|
-
id: this.code
|
|
201
|
-
});
|
|
202
|
-
this._originalError = error;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Initializes the A_Error instance from a message.
|
|
206
|
-
*
|
|
207
|
-
* @param title
|
|
208
|
-
* @param description
|
|
209
|
-
*/
|
|
210
|
-
fromMessage(message) {
|
|
211
|
-
this._title = A_Error_constants_1.A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR;
|
|
212
|
-
this._aseid = new ASEID_class_1.ASEID({
|
|
213
|
-
concept: this.constructor.concept,
|
|
214
|
-
scope: this._scope || this.constructor.scope,
|
|
215
|
-
entity: this.constructor.entity,
|
|
216
|
-
id: this.code
|
|
217
|
-
});
|
|
218
|
-
this._link = undefined;
|
|
219
|
-
this._originalError = undefined;
|
|
220
|
-
}
|
|
221
|
-
fromTitle(title, description) {
|
|
222
|
-
this.validateTitle(title);
|
|
223
|
-
this._title = title;
|
|
224
|
-
this._description = description;
|
|
225
|
-
this._aseid = new ASEID_class_1.ASEID({
|
|
226
|
-
concept: this.constructor.concept,
|
|
227
|
-
scope: this._scope || this.constructor.scope,
|
|
228
|
-
entity: this.constructor.entity,
|
|
229
|
-
id: this.code
|
|
230
|
-
});
|
|
231
|
-
this._link = undefined;
|
|
232
|
-
this._originalError = undefined;
|
|
233
|
-
}
|
|
234
|
-
/**
|
|
235
|
-
* Initializes the A_Error instance from a constructor parameters object.
|
|
236
|
-
*
|
|
237
|
-
* @param params
|
|
238
|
-
*/
|
|
239
|
-
fromConstructor(params) {
|
|
240
|
-
this.validateTitle(params.title);
|
|
241
|
-
this._title = params.title;
|
|
242
|
-
this._code = params.code;
|
|
243
|
-
this._scope = params.scope ? (A_TypeGuards_helper_1.A_TypeGuards.isScopeInstance(params.scope) ? params.scope.name : params.scope) : undefined;
|
|
244
|
-
this._aseid = new ASEID_class_1.ASEID({
|
|
245
|
-
concept: this.constructor.concept,
|
|
246
|
-
scope: this._scope || this.constructor.scope,
|
|
247
|
-
entity: this.constructor.entity,
|
|
248
|
-
id: this.code
|
|
249
|
-
});
|
|
250
|
-
this._description = params.description;
|
|
251
|
-
this._link = params.link;
|
|
252
|
-
this._originalError = params.originalError;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Serializes the A_Error instance to a plain object.
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
* @returns
|
|
259
|
-
*/
|
|
260
|
-
toJSON() {
|
|
261
|
-
var _a;
|
|
262
|
-
return {
|
|
263
|
-
aseid: this.aseid.toString(),
|
|
264
|
-
title: this.title,
|
|
265
|
-
code: this.code,
|
|
266
|
-
type: this.type,
|
|
267
|
-
message: this.message,
|
|
268
|
-
link: this.link,
|
|
269
|
-
scope: this.scope,
|
|
270
|
-
description: this.description,
|
|
271
|
-
originalError: (_a = this.originalError) === null || _a === void 0 ? void 0 : _a.message
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
// --------------------------------------------------------------------------
|
|
275
|
-
// ----------------------- PROTECTED HELPERS --------------------------------
|
|
276
|
-
// --------------------------------------------------------------------------
|
|
277
|
-
/**
|
|
278
|
-
* Checks if the provided title exceeds 60 characters.
|
|
279
|
-
* If it does, throws a validation A_Error.
|
|
280
|
-
*
|
|
281
|
-
* @param title
|
|
282
|
-
*/
|
|
283
|
-
validateTitle(title) {
|
|
284
|
-
if (title.length > 60) {
|
|
285
|
-
throw new A_Error(A_Error_constants_1.A_CONSTANTS__ERROR_CODES.VALIDATION_ERROR, 'A-Error title exceeds 60 characters limit.');
|
|
286
|
-
}
|
|
287
|
-
if (title.length === 0) {
|
|
288
|
-
throw new A_Error(A_Error_constants_1.A_CONSTANTS__ERROR_CODES.VALIDATION_ERROR, 'A-Error title cannot be empty.');
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
exports.A_Error = A_Error;
|
|
293
|
-
// message = title + description for better printing in the console
|
|
294
|
-
// description = detailed information about the error
|
|
295
|
-
// code = kebabcase (title)
|
|
296
|
-
//# sourceMappingURL=A_Error.class.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A_Error.class.js","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,CAAC;IACzB,CAAC;IAID,6EAA6E;IAC7E,6EAA6E;IAC7E,6EAA6E;IAC7E;;;;;OAKG;IACO,aAAa,CAAC,KAAa;QACjC,IAAI,KAAK,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACpB,MAAM,IAAI,OAAO,CACb,4CAAwB,CAAC,gBAAgB,EACzC,4CAA4C,CAC/C,CAAC;QACN,CAAC;QACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,OAAO,CACb,4CAAwB,CAAC,gBAAgB,EACzC,gCAAgC,CACnC,CAAC;QACN,CAAC;IACL,CAAC;CACJ;AAvbD,0BAubC;AAMD,mEAAmE;AACnE,qDAAqD;AACrD,2BAA2B"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_CONSTANTS__ERROR_DESCRIPTION = exports.A_CONSTANTS__ERROR_CODES = void 0;
|
|
4
|
-
exports.A_CONSTANTS__ERROR_CODES = {
|
|
5
|
-
UNEXPECTED_ERROR: 'A-Error Unexpected Error',
|
|
6
|
-
VALIDATION_ERROR: 'A-Error Validation Error',
|
|
7
|
-
};
|
|
8
|
-
exports.A_CONSTANTS__ERROR_DESCRIPTION = 'If you see this error please let us know.';
|
|
9
|
-
//# sourceMappingURL=A_Error.constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A_Error.constants.js","sourceRoot":"","sources":["../../../../src/global/A-Error/A_Error.constants.ts"],"names":[],"mappings":";;;AAGa,QAAA,wBAAwB,GAAG;IACpC,gBAAgB,EAAE,0BAA0B;IAC5C,gBAAgB,EAAE,0BAA0B;CACtC,CAAC;AAIE,QAAA,8BAA8B,GAAG,2CAA2C,CAAA"}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
2
|
-
import { A_Error } from "./A_Error.class";
|
|
3
|
-
/**
|
|
4
|
-
* Entity constructor type
|
|
5
|
-
* Uses the generic type T to specify the type of the entity
|
|
6
|
-
*/
|
|
7
|
-
export type A_TYPES__Error_Constructor<T = A_Error> = new (...args: any[]) => T;
|
|
8
|
-
/**
|
|
9
|
-
* Error initialization type
|
|
10
|
-
*/
|
|
11
|
-
export type A_TYPES__Error_Init = {
|
|
12
|
-
/**
|
|
13
|
-
* Error title
|
|
14
|
-
*
|
|
15
|
-
* A short description of the error
|
|
16
|
-
*/
|
|
17
|
-
title: string;
|
|
18
|
-
/**
|
|
19
|
-
* Error code representing the type of error
|
|
20
|
-
*
|
|
21
|
-
* Should be unique within the application or service
|
|
22
|
-
*
|
|
23
|
-
* Example: 'validation-error', 'not-found', 'user-not-found', 'unauthorized' etc.
|
|
24
|
-
*
|
|
25
|
-
* [!] Note: It is recommended to use kebab-case for error codes
|
|
26
|
-
* [!] Note: If not provided would be used a kebab-case message of the error
|
|
27
|
-
*/
|
|
28
|
-
code?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Possible Scope if needed to identify the error by it's execution environment
|
|
31
|
-
*
|
|
32
|
-
* For example, error of type 'validation' could happen in different scopes
|
|
33
|
-
* like 'user', 'admin', 'system' etc. This will help to identify the error context better
|
|
34
|
-
*
|
|
35
|
-
* Could be string or A_Scope instance
|
|
36
|
-
*
|
|
37
|
-
* [!] Note: If not provided, the default scope of the A_Error will be used (A_Context.root.name)
|
|
38
|
-
*/
|
|
39
|
-
scope?: string | A_Scope;
|
|
40
|
-
/**
|
|
41
|
-
* Detailed description of the error
|
|
42
|
-
*/
|
|
43
|
-
description?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Link to the documentation or support page for the error
|
|
46
|
-
*/
|
|
47
|
-
link?: string;
|
|
48
|
-
/**
|
|
49
|
-
* Original Error if any
|
|
50
|
-
*/
|
|
51
|
-
originalError?: Error | unknown;
|
|
52
|
-
};
|
|
53
|
-
/**
|
|
54
|
-
* Error serialized type
|
|
55
|
-
*/
|
|
56
|
-
export type A_TYPES__Error_Serialized = {
|
|
57
|
-
/**
|
|
58
|
-
* ASEID of the error
|
|
59
|
-
*/
|
|
60
|
-
aseid: string;
|
|
61
|
-
/**
|
|
62
|
-
* A brief title of the error
|
|
63
|
-
*/
|
|
64
|
-
title: string;
|
|
65
|
-
/**
|
|
66
|
-
* Error message
|
|
67
|
-
*/
|
|
68
|
-
message: string;
|
|
69
|
-
/**
|
|
70
|
-
* Type of the error
|
|
71
|
-
*/
|
|
72
|
-
type: string;
|
|
73
|
-
/**
|
|
74
|
-
* Error code
|
|
75
|
-
*/
|
|
76
|
-
code: string;
|
|
77
|
-
/**
|
|
78
|
-
* Error description
|
|
79
|
-
*/
|
|
80
|
-
description: string;
|
|
81
|
-
/**
|
|
82
|
-
* Link to documentation or support page
|
|
83
|
-
*/
|
|
84
|
-
link?: string;
|
|
85
|
-
/**
|
|
86
|
-
* Scope of the error
|
|
87
|
-
*/
|
|
88
|
-
scope: string;
|
|
89
|
-
/**
|
|
90
|
-
* Original error message if any
|
|
91
|
-
*/
|
|
92
|
-
originalError?: string;
|
|
93
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A_Error.types.js","sourceRoot":"","sources":["../../../../src/global/A-Error/A_Error.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { A_TYPES__FeatureDefineDecoratorConfig, A_TYPES__FeatureDefineDecoratorDescriptor, A_TYPES__FeatureDefineDecoratorTarget } from "./A-Feature.types";
|
|
2
|
-
/**
|
|
3
|
-
* A-Feature decorator
|
|
4
|
-
*
|
|
5
|
-
* This decorator allows to define a custom lifecycle stage for the Container.
|
|
6
|
-
* These stages are executed in a container-specific order and can be extended by components that are injected into the container.
|
|
7
|
-
* This approach allows to create a flexible and extendable architecture for the application.
|
|
8
|
-
*
|
|
9
|
-
* The main difference between the A-Feature and A-Feature decorators is that A-Feature methods can be inherited and overridden by child classes.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param params
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
export declare function A_Feature_Define(config?: Partial<A_TYPES__FeatureDefineDecoratorConfig>): (target: A_TYPES__FeatureDefineDecoratorTarget, propertyKey: string, descriptor: A_TYPES__FeatureDefineDecoratorDescriptor) => A_TYPES__FeatureDefineDecoratorDescriptor;
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.A_Feature_Define = A_Feature_Define;
|
|
4
|
-
const A_Context_class_1 = require("../A-Context/A-Context.class");
|
|
5
|
-
const A_Meta_class_1 = require("../A-Meta/A-Meta.class");
|
|
6
|
-
const A_Entity_constants_1 = require("../A-Entity/A-Entity.constants");
|
|
7
|
-
const A_Container_constants_1 = require("../A-Container/A-Container.constants");
|
|
8
|
-
const A_Component_constants_1 = require("../A-Component/A-Component.constants");
|
|
9
|
-
const A_TypeGuards_helper_1 = require("../../helpers/A_TypeGuards.helper");
|
|
10
|
-
const A_Feature_error_1 = require("./A-Feature.error");
|
|
11
|
-
/**
|
|
12
|
-
* A-Feature decorator
|
|
13
|
-
*
|
|
14
|
-
* This decorator allows to define a custom lifecycle stage for the Container.
|
|
15
|
-
* These stages are executed in a container-specific order and can be extended by components that are injected into the container.
|
|
16
|
-
* This approach allows to create a flexible and extendable architecture for the application.
|
|
17
|
-
*
|
|
18
|
-
* The main difference between the A-Feature and A-Feature decorators is that A-Feature methods can be inherited and overridden by child classes.
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* @param params
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
function A_Feature_Define(config = {}) {
|
|
25
|
-
return function (target, propertyKey, descriptor) {
|
|
26
|
-
var _a;
|
|
27
|
-
// for error messages
|
|
28
|
-
const componentName = ((_a = target === null || target === void 0 ? void 0 : target.constructor) === null || _a === void 0 ? void 0 : _a.name) || String(target) || 'Unknown';
|
|
29
|
-
if (!A_TypeGuards_helper_1.A_TypeGuards.isAllowedForFeatureDefinition(target))
|
|
30
|
-
throw new A_Feature_error_1.A_FeatureError(A_Feature_error_1.A_FeatureError.FeatureDefinitionError, `A-Feature cannot be defined on the ${componentName} level`);
|
|
31
|
-
const meta = A_Context_class_1.A_Context.meta(target.constructor);
|
|
32
|
-
let metaKey;
|
|
33
|
-
switch (true) {
|
|
34
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isEntityInstance(target):
|
|
35
|
-
metaKey = A_Entity_constants_1.A_TYPES__EntityMetaKey.FEATURES;
|
|
36
|
-
break;
|
|
37
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isContainerInstance(target):
|
|
38
|
-
metaKey = A_Container_constants_1.A_TYPES__ContainerMetaKey.FEATURES;
|
|
39
|
-
break;
|
|
40
|
-
case A_TypeGuards_helper_1.A_TypeGuards.isComponentInstance(target):
|
|
41
|
-
metaKey = A_Component_constants_1.A_TYPES__ComponentMetaKey.FEATURES;
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
// Get the existed metadata or create a new one
|
|
45
|
-
const existedMeta = meta.get(metaKey) || new A_Meta_class_1.A_Meta();
|
|
46
|
-
const name = config.name || propertyKey;
|
|
47
|
-
// default to false
|
|
48
|
-
const invoke = config.invoke || false;
|
|
49
|
-
// Set the metadata of the method to define a custom Feature with name
|
|
50
|
-
existedMeta.set(propertyKey, {
|
|
51
|
-
name: `${target.constructor.name}.${name}`,
|
|
52
|
-
handler: propertyKey,
|
|
53
|
-
invoke: invoke,
|
|
54
|
-
template: config.template && config.template.length ? config.template.map(item => (Object.assign(Object.assign({}, item), { before: item.before || [], after: item.after || [], behavior: item.behavior || 'sync', throwOnError: true }))) : [],
|
|
55
|
-
});
|
|
56
|
-
// Update the metadata of the container with the new Feature definition
|
|
57
|
-
A_Context_class_1.A_Context
|
|
58
|
-
.meta(target.constructor)
|
|
59
|
-
.set(metaKey, existedMeta);
|
|
60
|
-
const originalMethod = descriptor.value;
|
|
61
|
-
// Wrap the original method to add the call to `call`
|
|
62
|
-
// this helps to automatically call the container/entity/component method when it's called
|
|
63
|
-
descriptor.value = function (...args) {
|
|
64
|
-
// Call the original method
|
|
65
|
-
if (!invoke)
|
|
66
|
-
return originalMethod.apply(this, args);
|
|
67
|
-
else
|
|
68
|
-
originalMethod.apply(this, args);
|
|
69
|
-
// Call your `call` with the function name
|
|
70
|
-
if (typeof this.call === "function" && invoke)
|
|
71
|
-
return this.call(name);
|
|
72
|
-
};
|
|
73
|
-
return descriptor;
|
|
74
|
-
};
|
|
75
|
-
}
|
|
76
|
-
//# sourceMappingURL=A-Feature-Define.decorator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"A-Feature-Define.decorator.js","sourceRoot":"","sources":["../../../../src/global/A-Feature/A-Feature-Define.decorator.ts"],"names":[],"mappings":";;AA8BA,4CA+FC;AAvHD,uFAA8E;AAI9E,8EAAqE;AACrE,4FAA6F;AAC7F,qGAAsG;AACtG,qGAAsG;AACtG,sFAA4E;AAC5E,uDAAmD;AAEnD;;;;;;;;;;;;GAYG;AACH,SAAgB,gBAAgB,CAC5B,SAAyD,EAAE;IAE3D,OAAO,UACH,MAA6C,EAC7C,WAAmB,EACnB,UAAqD;;QAErD,qBAAqB;QACrB,MAAM,aAAa,GAAG,CAAA,MAAC,MAAc,aAAd,MAAM,uBAAN,MAAM,CAAU,WAAW,0CAAE,IAAI,KAAI,MAAM,CAAC,MAAM,CAAC,IAAI,SAAS,CAAC;QAGxF,IAAI,CAAC,kCAAY,CAAC,6BAA6B,CAAC,MAAM,CAAC;YACnD,MAAM,IAAI,gCAAc,CACpB,gCAAc,CAAC,sBAAsB,EACrC,sCAAsC,aAAa,QAAQ,CAC9D,CAAC;QAEN,MAAM,IAAI,GAAqD,2BAAS,CAAC,IAAI,CAAC,MAAM,CAAC,WAAkB,CAAC,CAAC;QAEzG,IAAI,OAAO,CAAC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AAC,MAAM,CAAC,WAAkB,CAAC;aAC/B,GAAG,CACA,OAAO,EACP,WAAW,CACd,CAAC;QAEN,MAAM,cAAc,GAAG,UAAU,CAAC,KAAM,CAAC;QAEzC,qDAAqD;QACrD,0FAA0F;QAC1F,UAAU,CAAC,KAAK,GAAG,UAAU,GAAG,IAAW;YAEvC,2BAA2B;YAC3B,IAAI,CAAC,MAAM;gBACP,OAAO,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;;gBAExC,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;YAErC,0CAA0C;YAC1C,IAAI,OAAQ,IAA8C,CAAC,IAAI,KAAK,UAAU,IAAI,MAAM;gBACpF,OAAQ,IAA8C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE1E,CAAC,CAAC;QAEF,OAAO,UAAU,CAAC;IACtB,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { A_TYPES__FeatureExtendDecoratorConfig } from "./A-Feature.types";
|
|
2
|
-
/**
|
|
3
|
-
* A-Extend decorator
|
|
4
|
-
*
|
|
5
|
-
* This decorator allows to define a custom Extend stage for the Container.
|
|
6
|
-
* These stages are executed in a container-specific order and can be extended by components that are injected into the container.
|
|
7
|
-
* This approach allows to create a flexible and extendable architecture for the application.
|
|
8
|
-
*
|
|
9
|
-
* The main difference between the A-Extend and A-Extend decorators is that A-Extend methods can be inherited and overridden by child classes.
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @param params
|
|
13
|
-
* @returns
|
|
14
|
-
*/
|
|
15
|
-
/**
|
|
16
|
-
* Use regexp in case if you need more flexibility and control over the name of the method
|
|
17
|
-
*
|
|
18
|
-
* @param regexp
|
|
19
|
-
*/
|
|
20
|
-
export declare function A_Feature_Extend(
|
|
21
|
-
/**
|
|
22
|
-
* The regular expression to match the name of the Feature method to be extended
|
|
23
|
-
*
|
|
24
|
-
* Example:
|
|
25
|
-
*
|
|
26
|
-
* ```ts
|
|
27
|
-
* @A_Feature.Extend(/.*\.load/)
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
30
|
-
regexp: RegExp): any;
|
|
31
|
-
/**
|
|
32
|
-
* In this case the name configurations will be used as an input to get scope and name of target function
|
|
33
|
-
* [!] Not that for all SCOPE will be used OR operator
|
|
34
|
-
*
|
|
35
|
-
* @param config
|
|
36
|
-
*/
|
|
37
|
-
export declare function A_Feature_Extend(
|
|
38
|
-
/**
|
|
39
|
-
* Configuration for the A-Feature-Extend decorator
|
|
40
|
-
*/
|
|
41
|
-
config: Partial<A_TYPES__FeatureExtendDecoratorConfig>): any;
|
|
42
|
-
/**
|
|
43
|
-
* In this case the name of function will be used as a name of the Feature.
|
|
44
|
-
* [!] AND it will be applicable for ANY element where the name is the same as the name of the function
|
|
45
|
-
*/
|
|
46
|
-
export declare function A_Feature_Extend(): any;
|
|
47
|
-
/**
|
|
48
|
-
* Builds a target regular expression based on the provided parameters.
|
|
49
|
-
*
|
|
50
|
-
* @param param1 - The first parameter, which can be a string or an object.
|
|
51
|
-
* @param include - An array of items to include in the regular expression.
|
|
52
|
-
* @param exclude - An array of items to exclude from the regular expression.
|
|
53
|
-
* @param propertyKey - The property key to use in the regular expression.
|
|
54
|
-
* @returns A regular expression object.
|
|
55
|
-
*/
|
|
56
|
-
export declare function buildTargetRegexp(param1: any, include: any[], exclude: any[], propertyKey: string): RegExp;
|