@adaas/a-concept 0.1.61 → 0.2.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/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +1584 -1456
- package/dist/index.d.ts +1584 -1456
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/global/A-Abstraction/A-Abstraction.types.ts +2 -3
- package/src/global/A-Caller/A_Caller.types.ts +2 -1
- package/src/global/A-Component/A-Component.types.ts +2 -1
- package/src/global/A-Concept/A-Concept.types.ts +2 -1
- package/src/global/A-Container/A-Container.types.ts +2 -1
- package/src/global/A-Context/A-Context.class.ts +56 -25
- package/src/global/A-Dependency/A-Dependency-All.decorator.ts +77 -0
- package/src/global/A-Dependency/A-Dependency-Default.decorator.ts +4 -4
- package/src/global/A-Dependency/A-Dependency-Flat.decorator.ts +3 -2
- package/src/global/A-Dependency/A-Dependency-Load.decorator.ts +9 -13
- package/src/global/A-Dependency/A-Dependency-Parent.decorator.ts +2 -3
- package/src/global/A-Dependency/A-Dependency-Require.decorator.ts +1 -2
- package/src/global/A-Dependency/A-Dependency.class.ts +144 -5
- package/src/global/A-Dependency/A-Dependency.error.ts +3 -0
- package/src/global/A-Dependency/A-Dependency.types.ts +124 -3
- package/src/global/A-Entity/A-Entity.types.ts +2 -1
- package/src/global/A-Error/A_Error.types.ts +2 -1
- package/src/global/A-Feature/A-Feature-Define.decorator.ts +0 -1
- package/src/global/A-Feature/A-Feature-Extend.decorator.ts +1 -5
- package/src/global/A-Feature/A-Feature.types.ts +3 -3
- package/src/global/A-Fragment/A-Fragment.types.ts +2 -1
- package/src/global/A-Inject/A-Inject.decorator.ts +70 -42
- package/src/global/A-Inject/A-Inject.types.ts +2 -42
- package/src/global/A-Meta/A-Meta.decorator.ts +2 -1
- package/src/global/A-Meta/A-Meta.types.ts +2 -1
- package/src/global/A-Scope/A-Scope.class.ts +409 -389
- package/src/global/A-Scope/A-Scope.error.ts +2 -0
- package/src/global/A-Scope/A-Scope.types.ts +4 -8
- package/src/global/A-Stage/A-Stage.class.ts +19 -86
- package/src/global/A-Stage/A-Stage.types.ts +3 -1
- package/src/global/A-StepManager/A-StepManager.class.ts +1 -1
- package/src/global/ASEID/ASEID.class.ts +20 -0
- package/src/helpers/A_Common.helper.ts +4 -0
- package/src/helpers/A_TypeGuards.helper.ts +28 -3
- package/src/types/A_Common.types.ts +4 -0
- package/tests/A-Abstraction.test.ts +2 -0
- package/tests/A-Dependency.test.ts +49 -5
- package/tests/A-Feature.test.ts +44 -19
- package/tests/A-Scope.test.ts +38 -9
- package/tests/A-StepManager.test.ts +40 -39
|
@@ -1,3 +1,112 @@
|
|
|
1
|
+
// ==================================== A-Dependency types ==================================== //
|
|
2
|
+
|
|
3
|
+
import { A_TYPES__Ctor } from "@adaas/a-concept/types/A_Common.types";
|
|
4
|
+
import { A_Caller } from "../A-Caller/A_Caller.class";
|
|
5
|
+
import { A_Component } from "../A-Component/A-Component.class";
|
|
6
|
+
import { A_Container } from "../A-Container/A-Container.class";
|
|
7
|
+
import { A_Entity } from "../A-Entity/A-Entity.class"
|
|
8
|
+
import { A_Error } from "../A-Error/A_Error.class";
|
|
9
|
+
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
10
|
+
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
11
|
+
import { A_Dependency } from "./A-Dependency.class";
|
|
12
|
+
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
// ===========================================================================================
|
|
16
|
+
// ============================= A-Dependency Resolution Options =============================
|
|
17
|
+
// ===========================================================================================
|
|
18
|
+
export type A_TYPES__A_DependencyConstructor<T extends A_Dependency> = A_TYPES__Ctor<T>;
|
|
19
|
+
|
|
20
|
+
export type A_TYPES__A_DependencyInjectable = A_Entity
|
|
21
|
+
| A_Container
|
|
22
|
+
| A_Component
|
|
23
|
+
| A_Fragment
|
|
24
|
+
| A_Feature
|
|
25
|
+
| A_Caller
|
|
26
|
+
| A_Error
|
|
27
|
+
| A_Scope
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
export type A_TYPES__A_DependencyResolutionType<T> =
|
|
31
|
+
T extends string
|
|
32
|
+
? string
|
|
33
|
+
: T extends A_TYPES__Ctor<infer R>
|
|
34
|
+
? R
|
|
35
|
+
: never
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
export type A_TYPES__A_DependencyResolutionStrategy<T extends A_TYPES__A_DependencyInjectable = A_TYPES__A_DependencyInjectable> = {
|
|
39
|
+
/**
|
|
40
|
+
* If tru will throw an error if the dependency is not found
|
|
41
|
+
*/
|
|
42
|
+
require: boolean
|
|
43
|
+
/**
|
|
44
|
+
* Indicates that dependency should be loaded from a specific path before resolution
|
|
45
|
+
*/
|
|
46
|
+
load: boolean
|
|
47
|
+
/**
|
|
48
|
+
* Number of levels to go up in the parent chain when resolving the dependency
|
|
49
|
+
*/
|
|
50
|
+
parent: number
|
|
51
|
+
/**
|
|
52
|
+
* If true, will only resolve the dependency in the current scope without going up to parent scopes
|
|
53
|
+
*/
|
|
54
|
+
flat: boolean
|
|
55
|
+
/**
|
|
56
|
+
* If has any value indicates that entity should be created with default parameters provided
|
|
57
|
+
*/
|
|
58
|
+
create: boolean
|
|
59
|
+
/**
|
|
60
|
+
* Default constructor arguments to use when creating the dependency
|
|
61
|
+
*/
|
|
62
|
+
args: any[]
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Allows to query by specific entity properties e.g. ASEID, name, type, custom properties, etc.
|
|
66
|
+
*/
|
|
67
|
+
query: Partial<A_TYPES__A_Dependency_EntityInjectionQuery<T extends A_Entity ? T : A_Entity>>,
|
|
68
|
+
/**
|
|
69
|
+
* Pagination settings for the entity search
|
|
70
|
+
*/
|
|
71
|
+
pagination: A_TYPES__A_Dependency_EntityInjectionPagination
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
export type A_TYPES__A_Dependency_Serialized = {
|
|
76
|
+
name: string,
|
|
77
|
+
all: boolean,
|
|
78
|
+
require: boolean,
|
|
79
|
+
load: boolean,
|
|
80
|
+
parent: number,
|
|
81
|
+
flat: boolean,
|
|
82
|
+
create: any,
|
|
83
|
+
args: any[],
|
|
84
|
+
query: Partial<A_TYPES__A_Dependency_EntityInjectionQuery>,
|
|
85
|
+
pagination: A_TYPES__A_Dependency_EntityInjectionPagination
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// =--------------------------------------------------------------------------------------------
|
|
89
|
+
// =========================== A-Dependency Possible Configurations ============================
|
|
90
|
+
// =--------------------------------------------------------------------------------------------
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
export type A_TYPES__A_Dependency_EntityResolutionConfig<T extends A_Entity = A_Entity> = {
|
|
94
|
+
query: Partial<A_TYPES__A_Dependency_EntityInjectionQuery<T>>,
|
|
95
|
+
pagination: Partial<A_TYPES__A_Dependency_EntityInjectionPagination>
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
export type A_TYPES__A_Dependency_EntityInjectionQuery<T extends A_Entity = A_Entity> = {
|
|
100
|
+
aseid: string,
|
|
101
|
+
} & {
|
|
102
|
+
[key in keyof T]?: any
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
export type A_TYPES__A_Dependency_EntityInjectionPagination = {
|
|
107
|
+
count: number,
|
|
108
|
+
from: 'start' | 'end'
|
|
109
|
+
}
|
|
1
110
|
|
|
2
111
|
|
|
3
112
|
/**
|
|
@@ -27,15 +136,27 @@ export type A_TYPES__A_Dependency_DefaultDecoratorReturn<T = any> = (
|
|
|
27
136
|
parameterIndex: number
|
|
28
137
|
) => void
|
|
29
138
|
|
|
30
|
-
|
|
139
|
+
/**
|
|
140
|
+
* A-Dependency parent decorator return type
|
|
141
|
+
*/
|
|
31
142
|
export type A_TYPES__A_Dependency_ParentDecoratorReturn<T = any> = (
|
|
32
143
|
target: T,
|
|
33
144
|
propertyKey: string | symbol | undefined,
|
|
34
145
|
parameterIndex: number
|
|
35
146
|
) => void
|
|
36
|
-
|
|
147
|
+
/**
|
|
148
|
+
* A-Dependency flat decorator return type
|
|
149
|
+
*/
|
|
37
150
|
export type A_TYPES__A_Dependency_FlatDecoratorReturn<T = any> = (
|
|
38
151
|
target: T,
|
|
39
152
|
propertyKey: string | symbol | undefined,
|
|
40
153
|
parameterIndex: number
|
|
41
|
-
) => void
|
|
154
|
+
) => void
|
|
155
|
+
/**
|
|
156
|
+
* A-Dependency All decorator return type
|
|
157
|
+
*/
|
|
158
|
+
export type A_TYPES__A_Dependency_AllDecoratorReturn<T = any> = (
|
|
159
|
+
target: T,
|
|
160
|
+
propertyKey: string | symbol | undefined,
|
|
161
|
+
parameterIndex: number
|
|
162
|
+
) => void
|
|
@@ -4,6 +4,7 @@ import { ASEID } from "../ASEID/ASEID.class";
|
|
|
4
4
|
import { A_TYPES__EntityMetaKey } from "./A-Entity.constants";
|
|
5
5
|
import { A_TYPES__FeatureDefineDecoratorMeta, A_TYPES__FeatureExtendDecoratorMeta } from "../A-Feature/A-Feature.types";
|
|
6
6
|
import { A_TYPES__A_InjectDecorator_Meta } from "../A-Inject/A-Inject.types";
|
|
7
|
+
import { A_TYPES__Ctor } from "@adaas/a-concept/types/A_Common.types";
|
|
7
8
|
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -23,7 +24,7 @@ export interface A_TYPES__IEntity {
|
|
|
23
24
|
* Entity constructor type
|
|
24
25
|
* Uses the generic type T to specify the type of the entity
|
|
25
26
|
*/
|
|
26
|
-
export type A_TYPES__Entity_Constructor<T = A_Entity> =
|
|
27
|
+
export type A_TYPES__Entity_Constructor<T = A_Entity> = A_TYPES__Ctor<T>;
|
|
27
28
|
/**
|
|
28
29
|
* Entity initialization type
|
|
29
30
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { A_TYPES__Ctor } from "@adaas/a-concept/types/A_Common.types";
|
|
1
2
|
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
2
3
|
import { A_Error } from "./A_Error.class";
|
|
3
4
|
|
|
@@ -9,7 +10,7 @@ import { A_Error } from "./A_Error.class";
|
|
|
9
10
|
* Entity constructor type
|
|
10
11
|
* Uses the generic type T to specify the type of the entity
|
|
11
12
|
*/
|
|
12
|
-
export type A_TYPES__Error_Constructor<T = A_Error> =
|
|
13
|
+
export type A_TYPES__Error_Constructor<T = A_Error> = A_TYPES__Ctor<T>;
|
|
13
14
|
/**
|
|
14
15
|
* Error initialization type
|
|
15
16
|
*/
|
|
@@ -146,16 +146,12 @@ export function A_Feature_Extend(
|
|
|
146
146
|
}
|
|
147
147
|
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
149
|
const existedDefinitions = A_Context
|
|
153
150
|
.meta(target)
|
|
154
151
|
.get(metaKey);
|
|
155
152
|
|
|
156
153
|
// Get the existed metadata or create a new one
|
|
157
|
-
const meta = A_Context
|
|
158
|
-
.meta(target)
|
|
154
|
+
const meta = A_Context.meta(target)
|
|
159
155
|
|
|
160
156
|
const existedMeta = meta.get(metaKey)
|
|
161
157
|
? new A_Meta().from(meta.get(metaKey)!)
|
|
@@ -7,7 +7,7 @@ import { A_TYPES__Component_Constructor } from "../A-Component/A-Component.types
|
|
|
7
7
|
import { A_TYPES__Container_Constructor } from "../A-Container/A-Container.types"
|
|
8
8
|
import { A_TYPES__Entity_Constructor } from "../A-Entity/A-Entity.types"
|
|
9
9
|
import { A_Feature } from "./A-Feature.class"
|
|
10
|
-
import { A_TYPES__Required } from "@adaas/a-concept/types/A_Common.types"
|
|
10
|
+
import { A_TYPES__Ctor, A_TYPES__Required } from "@adaas/a-concept/types/A_Common.types"
|
|
11
11
|
import { A_Scope } from "../A-Scope/A-Scope.class"
|
|
12
12
|
import { A_Stage } from "../A-Stage/A-Stage.class"
|
|
13
13
|
import { A_TYPES__Error_Init } from "../A-Error/A_Error.types"
|
|
@@ -20,7 +20,7 @@ import { A_TYPES__Error_Init } from "../A-Error/A_Error.types"
|
|
|
20
20
|
* Feature constructor type
|
|
21
21
|
* Uses the generic type T to specify the type of the feature
|
|
22
22
|
*/
|
|
23
|
-
export type A_TYPES__Feature_Constructor<T = A_Feature> =
|
|
23
|
+
export type A_TYPES__Feature_Constructor<T = A_Feature> = A_TYPES__Ctor<T>;
|
|
24
24
|
/**
|
|
25
25
|
* Feature initialization type
|
|
26
26
|
*/
|
|
@@ -181,7 +181,7 @@ export type A_TYPES__FeatureDefineDecoratorConfig = {
|
|
|
181
181
|
/**
|
|
182
182
|
* Describes a single template item used in Feature Define decorator
|
|
183
183
|
*/
|
|
184
|
-
export type A_TYPES__FeatureDefineDecoratorTemplateItem = A_TYPES__Required<Partial<A_TYPES__A_StageStep>, ['name', 'handler', '
|
|
184
|
+
export type A_TYPES__FeatureDefineDecoratorTemplateItem = A_TYPES__Required<Partial<A_TYPES__A_StageStep>, ['name', 'handler', 'dependency']>
|
|
185
185
|
/**
|
|
186
186
|
* Describes a target where Feature Define decorator can be applied
|
|
187
187
|
*
|
|
@@ -2,13 +2,14 @@
|
|
|
2
2
|
// --------------------------- Primary Types ----------------------------------
|
|
3
3
|
// ============================================================================
|
|
4
4
|
|
|
5
|
+
import { A_TYPES__Ctor } from "@adaas/a-concept/types/A_Common.types";
|
|
5
6
|
import { A_Fragment } from "./A-Fragment.class";
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Fragment constructor type
|
|
9
10
|
* Uses the generic type T to specify the type of the fragment
|
|
10
11
|
*/
|
|
11
|
-
export type A_TYPES__Fragment_Constructor<T = A_Fragment> =
|
|
12
|
+
export type A_TYPES__Fragment_Constructor<T = A_Fragment> = A_TYPES__Ctor<T>;
|
|
12
13
|
/**
|
|
13
14
|
* Fragment initialization type
|
|
14
15
|
*/
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
-
A_TYPES__A_InjectDecorator_EntityInjectionInstructions,
|
|
3
2
|
A_TYPES__A_InjectDecorator_Meta,
|
|
4
3
|
A_TYPES__A_InjectDecoratorReturn,
|
|
5
|
-
A_TYPES__InjectableConstructors,
|
|
6
4
|
A_TYPES__InjectableTargets
|
|
7
5
|
} from "./A-Inject.types";
|
|
8
6
|
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
@@ -26,6 +24,10 @@ import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
|
|
|
26
24
|
import { A_TYPES__Error_Constructor } from "../A-Error/A_Error.types";
|
|
27
25
|
import { A_Error } from "../A-Error/A_Error.class";
|
|
28
26
|
import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.constants";
|
|
27
|
+
import { A_Dependency } from "../A-Dependency/A-Dependency.class";
|
|
28
|
+
import { A_TYPES__Ctor } from "@adaas/a-concept/types/A_Common.types";
|
|
29
|
+
import { A_TYPES__A_DependencyInjectable, A_TYPES__A_DependencyResolutionStrategy } from "../A-Dependency/A-Dependency.types";
|
|
30
|
+
import { A_TYPES__Caller_Constructor } from "../A-Caller/A_Caller.types";
|
|
29
31
|
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -39,46 +41,19 @@ import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.constants";
|
|
|
39
41
|
* @param params - see overloads
|
|
40
42
|
* @returns - decorator function
|
|
41
43
|
*/
|
|
42
|
-
export function A_Inject<T extends A_Scope>(
|
|
43
|
-
/***
|
|
44
|
-
* Provide the Scope constructor that will be associated with the injection.
|
|
45
|
-
*
|
|
46
|
-
* [!] It returns an instance of the Scope where the Entity/Component/Container is defined.
|
|
47
|
-
*/
|
|
48
|
-
scope: A_TYPES__Scope_Constructor<T>
|
|
49
|
-
): A_TYPES__A_InjectDecoratorReturn
|
|
50
|
-
export function A_Inject<T extends A_Error>(
|
|
51
|
-
/***
|
|
52
|
-
* Provide the Error constructor that will be associated with the injection.
|
|
53
|
-
*
|
|
54
|
-
* [!] It returns an Instance of the Error what is executed.
|
|
55
|
-
*/
|
|
56
|
-
error: A_TYPES__Error_Constructor<T>
|
|
57
|
-
): A_TYPES__A_InjectDecoratorReturn
|
|
58
|
-
export function A_Inject<T extends A_Feature>(
|
|
59
|
-
/**
|
|
60
|
-
* Provide the Feature constructor that will be associated with the injection.
|
|
61
|
-
*
|
|
62
|
-
* [!] It returns an Instance of the Feature what is executed.
|
|
63
|
-
*/
|
|
64
|
-
feature: A_TYPES__Feature_Constructor<T>
|
|
65
|
-
): A_TYPES__A_InjectDecoratorReturn
|
|
66
44
|
export function A_Inject<T extends A_Component>(
|
|
67
45
|
/**
|
|
68
46
|
* Provide the Component constructor that will be associated with the injection.
|
|
69
47
|
*
|
|
70
48
|
* [!] It returns an Instance of the Component from current Scope or from Parent Scopes.
|
|
71
49
|
*/
|
|
72
|
-
component: A_TYPES__Component_Constructor<T
|
|
73
|
-
): A_TYPES__A_InjectDecoratorReturn
|
|
74
|
-
// Allows to inject just one A_FeatureCaller
|
|
75
|
-
export function A_Inject(
|
|
50
|
+
component: A_TYPES__Component_Constructor<T>,
|
|
76
51
|
/**
|
|
77
|
-
* Provide
|
|
52
|
+
* Provide additional instructions on how to perform the injection
|
|
78
53
|
*
|
|
79
|
-
* [!]
|
|
54
|
+
* [!] Default Pagination is 1 if it's necessary to get multiple Fragments please customize it in the instructions
|
|
80
55
|
*/
|
|
81
|
-
|
|
56
|
+
config?: Omit<Partial<A_TYPES__A_DependencyResolutionStrategy<T>>, 'query' | 'pagination'>
|
|
82
57
|
): A_TYPES__A_InjectDecoratorReturn
|
|
83
58
|
// Allows to inject just one Context Fragment
|
|
84
59
|
export function A_Inject<T extends A_Fragment>(
|
|
@@ -87,7 +62,13 @@ export function A_Inject<T extends A_Fragment>(
|
|
|
87
62
|
*
|
|
88
63
|
* [!] It returns the Fragment instance from current Scope or from Parent Scopes.
|
|
89
64
|
*/
|
|
90
|
-
fragment: A_TYPES__Fragment_Constructor<T
|
|
65
|
+
fragment: A_TYPES__Fragment_Constructor<T>,
|
|
66
|
+
/**
|
|
67
|
+
* Provide additional instructions on how to perform the injection
|
|
68
|
+
*
|
|
69
|
+
* [!] Default Pagination is 1 if it's necessary to get multiple Fragments please customize it in the instructions
|
|
70
|
+
*/
|
|
71
|
+
config?: Omit<Partial<A_TYPES__A_DependencyResolutionStrategy<T>>, 'query' | 'pagination'>
|
|
91
72
|
): A_TYPES__A_InjectDecoratorReturn
|
|
92
73
|
export function A_Inject<T extends A_Entity>(
|
|
93
74
|
/**
|
|
@@ -103,7 +84,7 @@ export function A_Inject<T extends A_Entity>(
|
|
|
103
84
|
*
|
|
104
85
|
* [!] Default Pagination is 1 if it's necessary to get multiple Entities please customize it in the instructions
|
|
105
86
|
*/
|
|
106
|
-
config?: Partial<
|
|
87
|
+
config?: Partial<A_TYPES__A_DependencyResolutionStrategy<T>>
|
|
107
88
|
): A_TYPES__A_InjectDecoratorReturn<T>
|
|
108
89
|
export function A_Inject<T extends A_Component>(
|
|
109
90
|
/**
|
|
@@ -113,9 +94,58 @@ export function A_Inject<T extends A_Component>(
|
|
|
113
94
|
*/
|
|
114
95
|
ctor: string
|
|
115
96
|
): A_TYPES__A_InjectDecoratorReturn
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
97
|
+
// Allows to inject just one A_FeatureCaller
|
|
98
|
+
export function A_Inject<T extends A_Caller>(
|
|
99
|
+
/**
|
|
100
|
+
* Provide the A_Caller constructor to inject the Caller instance
|
|
101
|
+
*
|
|
102
|
+
* [!] It returns initiator of the call, e.g. Container/Component/Command who called Feature
|
|
103
|
+
*/
|
|
104
|
+
caller: A_TYPES__Caller_Constructor<T>
|
|
105
|
+
): A_TYPES__A_InjectDecoratorReturn
|
|
106
|
+
// Allows to inject just one A_Error instance
|
|
107
|
+
export function A_Inject<T extends A_Error>(
|
|
108
|
+
/***
|
|
109
|
+
* Provide the Error constructor that will be associated with the injection.
|
|
110
|
+
*
|
|
111
|
+
* [!] It returns an Instance of the Error what is executed.
|
|
112
|
+
*/
|
|
113
|
+
error: A_TYPES__Error_Constructor<T>,
|
|
114
|
+
/**
|
|
115
|
+
* Provide additional instructions on how to perform the injection
|
|
116
|
+
*
|
|
117
|
+
* [!] Default Pagination is 1 if it's necessary to get multiple Fragments please customize it in the instructions
|
|
118
|
+
*/
|
|
119
|
+
config?: Omit<Partial<A_TYPES__A_DependencyResolutionStrategy<T>>, 'query' | 'pagination'>
|
|
120
|
+
): A_TYPES__A_InjectDecoratorReturn
|
|
121
|
+
export function A_Inject<T extends A_Feature>(
|
|
122
|
+
/**
|
|
123
|
+
* Provide the Feature constructor that will be associated with the injection.
|
|
124
|
+
*
|
|
125
|
+
* [!] It returns an Instance of the Feature what is executed.
|
|
126
|
+
*/
|
|
127
|
+
feature: A_TYPES__Feature_Constructor<T>
|
|
128
|
+
): A_TYPES__A_InjectDecoratorReturn
|
|
129
|
+
// Allows to inject just one Scope instance
|
|
130
|
+
export function A_Inject<T extends A_Scope>(
|
|
131
|
+
/***
|
|
132
|
+
* Provide the Scope constructor that will be associated with the injection.
|
|
133
|
+
*
|
|
134
|
+
* [!] It returns an instance of the Scope where the Entity/Component/Container is defined.
|
|
135
|
+
*/
|
|
136
|
+
scope: A_TYPES__Scope_Constructor<T>
|
|
137
|
+
): A_TYPES__A_InjectDecoratorReturn
|
|
138
|
+
export function A_Inject<T extends A_TYPES__A_DependencyInjectable>(
|
|
139
|
+
/***
|
|
140
|
+
* Provide the Scope constructor that will be associated with the injection.
|
|
141
|
+
*
|
|
142
|
+
* [!] It returns an instance of the Scope where the Entity/Component/Container is defined.
|
|
143
|
+
*/
|
|
144
|
+
dependency: A_Dependency<T>
|
|
145
|
+
): A_TYPES__A_InjectDecoratorReturn
|
|
146
|
+
export function A_Inject<T extends A_TYPES__A_DependencyInjectable>(
|
|
147
|
+
param1: string | A_TYPES__Ctor<T> | A_Dependency<T>,
|
|
148
|
+
param2?: Partial<A_TYPES__A_DependencyResolutionStrategy<T extends A_Entity ? T : A_Entity>>
|
|
119
149
|
): A_TYPES__A_InjectDecoratorReturn {
|
|
120
150
|
|
|
121
151
|
// pre call checks
|
|
@@ -166,10 +196,8 @@ export function A_Inject(
|
|
|
166
196
|
const paramsArray: A_TYPES__A_InjectDecorator_Meta = existedMeta.get(method) || [];
|
|
167
197
|
|
|
168
198
|
// set the parameter injection info
|
|
169
|
-
paramsArray[parameterIndex] =
|
|
170
|
-
|
|
171
|
-
instructions: param2
|
|
172
|
-
}
|
|
199
|
+
paramsArray[parameterIndex] = param1 instanceof A_Dependency ? param1 : new A_Dependency(param1, param2);
|
|
200
|
+
|
|
173
201
|
// save back the updated injections array
|
|
174
202
|
existedMeta.set(method, paramsArray);
|
|
175
203
|
|
|
@@ -6,6 +6,7 @@ import { A_TYPES__Feature_Constructor } from "@adaas/a-concept/global/A-Feature/
|
|
|
6
6
|
import { A_TYPES__Fragment_Constructor } from "@adaas/a-concept/global/A-Fragment/A-Fragment.types";
|
|
7
7
|
import { A_TYPES__Caller_Constructor } from "@adaas/a-concept/global/A-Caller/A_Caller.types";
|
|
8
8
|
import { A_TYPES__Error_Constructor } from "../A-Error/A_Error.types";
|
|
9
|
+
import { A_Dependency } from "../A-Dependency/A-Dependency.class";
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
// ============================================================================
|
|
@@ -30,54 +31,13 @@ export type A_TYPES__A_InjectDecoratorReturn<T = any> = (
|
|
|
30
31
|
) => void
|
|
31
32
|
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
export type A_TYPES__A_InjectDecorator_Meta = Array<{
|
|
35
|
-
target: A_TYPES__InjectableConstructors
|
|
36
|
-
require?: boolean
|
|
37
|
-
load?: string
|
|
38
|
-
defaultArgs?: any,
|
|
39
|
-
parent?: {
|
|
40
|
-
layerOffset?: number
|
|
41
|
-
},
|
|
42
|
-
flat?: boolean
|
|
43
|
-
create?: boolean
|
|
44
|
-
instructions?: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>,
|
|
45
|
-
}>;
|
|
34
|
+
export type A_TYPES__A_InjectDecorator_Meta = Array<A_Dependency>;
|
|
46
35
|
|
|
47
36
|
/**
|
|
48
37
|
* Targets that can be injected into Extended functions or constructors
|
|
49
|
-
*
|
|
50
38
|
*/
|
|
51
39
|
export type A_TYPES__InjectableTargets = A_TYPES__Component_Constructor
|
|
52
40
|
| InstanceType<A_TYPES__Component_Constructor>
|
|
53
41
|
| InstanceType<A_TYPES__Container_Constructor>;
|
|
54
42
|
|
|
55
43
|
|
|
56
|
-
export type A_TYPES__InjectableConstructors = A_TYPES__Component_Constructor
|
|
57
|
-
| A_TYPES__Container_Constructor
|
|
58
|
-
| A_TYPES__Entity_Constructor
|
|
59
|
-
| A_TYPES__Feature_Constructor
|
|
60
|
-
| A_TYPES__Caller_Constructor
|
|
61
|
-
| A_TYPES__Fragment_Constructor
|
|
62
|
-
| A_TYPES__Error_Constructor
|
|
63
|
-
| string;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
export type A_TYPES__A_InjectDecorator_EntityInjectionInstructions<T extends A_Entity = A_Entity> = {
|
|
67
|
-
query: Partial<A_TYPES__A_InjectDecorator_EntityInjectionQuery<T>>,
|
|
68
|
-
pagination: Partial<A_TYPES__A_InjectDecorator_EntityInjectionPagination>
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export type A_TYPES__A_InjectDecorator_EntityInjectionQuery<T extends A_Entity = A_Entity> = {
|
|
73
|
-
aseid: string,
|
|
74
|
-
} & {
|
|
75
|
-
[key in keyof T]?: any
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export type A_TYPES__A_InjectDecorator_EntityInjectionPagination = {
|
|
80
|
-
count: number,
|
|
81
|
-
from: 'start' | 'end'
|
|
82
|
-
}
|
|
83
|
-
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { A_TYPES__Ctor } from "@adaas/a-concept/types/A_Common.types";
|
|
1
2
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
2
3
|
import { A_Meta } from "./A-Meta.class";
|
|
3
4
|
import { A_TYPES__MetaLinkedComponentConstructors } from "./A-Meta.types";
|
|
@@ -13,7 +14,7 @@ import { A_TYPES__MetaLinkedComponentConstructors } from "./A-Meta.types";
|
|
|
13
14
|
* @returns
|
|
14
15
|
*/
|
|
15
16
|
export function A_MetaDecorator<T extends A_Meta>(
|
|
16
|
-
constructor:
|
|
17
|
+
constructor: A_TYPES__Ctor<T>
|
|
17
18
|
) {
|
|
18
19
|
return function <TTarget extends A_TYPES__MetaLinkedComponentConstructors>(
|
|
19
20
|
target: TTarget
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { A_TYPES__Ctor } from "@adaas/a-concept/types/A_Common.types";
|
|
1
2
|
import { A_Component } from "../A-Component/A-Component.class";
|
|
2
3
|
import { A_TYPES__Component_Constructor } from "../A-Component/A-Component.types";
|
|
3
4
|
import { A_Container } from "../A-Container/A-Container.class";
|
|
@@ -15,7 +16,7 @@ import { A_Meta } from "./A-Meta.class";
|
|
|
15
16
|
/**
|
|
16
17
|
* Meta constructor type
|
|
17
18
|
*/
|
|
18
|
-
export type A_TYPES__Meta_Constructor<T = A_Meta> =
|
|
19
|
+
export type A_TYPES__Meta_Constructor<T = A_Meta> = A_TYPES__Ctor<T>;
|
|
19
20
|
/**
|
|
20
21
|
* Components that can have Meta associated with them
|
|
21
22
|
*/
|