@adaas/a-concept 0.2.13 → 0.3.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/.conf/tsconfig.base.json +91 -0
- package/.conf/tsconfig.browser.json +36 -0
- package/.conf/tsconfig.node.json +40 -0
- package/dist/browser/index.d.mts +4166 -212
- package/dist/browser/index.mjs +2 -67
- package/dist/browser/index.mjs.map +1 -1
- package/dist/node/index.cjs +5761 -0
- package/dist/node/index.cjs.map +1 -0
- package/dist/node/index.d.mts +4193 -212
- package/dist/node/index.d.ts +4193 -212
- package/dist/node/index.mjs +5699 -66
- package/dist/node/index.mjs.map +1 -1
- package/jest.config.ts +30 -15
- package/package.json +19 -18
- package/src/env/env-browser.ts +38 -1
- package/src/env/env-node.ts +26 -2
- package/src/env/env.base.ts +20 -1
- package/src/env/global.browser.d.ts +1 -1
- package/src/helpers/A_BasicTypeGuards.helper.ts +81 -0
- package/src/helpers/A_Common.helper.ts +2 -2
- package/src/helpers/A_Identity.helper.ts +2 -4
- package/src/helpers/A_TypeGuards.helper.ts +45 -30
- package/src/helpers/index.ts +5 -0
- package/src/index.ts +21 -94
- package/src/{global → lib}/A-Abstraction/A-Abstraction-Extend.decorator.ts +18 -13
- package/src/{global → lib}/A-Abstraction/A-Abstraction.class.ts +5 -5
- package/src/{global → lib}/A-Abstraction/A-Abstraction.error.ts +1 -1
- package/src/{global → lib}/A-Abstraction/A-Abstraction.types.ts +5 -5
- package/src/lib/A-Abstraction/index.ts +8 -0
- package/src/{global → lib}/A-Caller/A_Caller.class.ts +3 -4
- package/src/{global → lib}/A-Caller/A_Caller.error.ts +1 -4
- package/src/{global → lib}/A-Caller/A_Caller.types.ts +4 -4
- package/src/lib/A-Caller/index.ts +3 -0
- package/src/{global → lib}/A-Component/A-Component.class.ts +2 -3
- package/src/{global → lib}/A-Component/A-Component.meta.ts +5 -5
- package/src/{global → lib}/A-Component/A-Component.types.ts +5 -5
- package/src/lib/A-Component/index.ts +5 -0
- package/src/{global → lib}/A-Concept/A-Concept.class.ts +9 -7
- package/src/{global → lib}/A-Concept/A-Concept.meta.ts +2 -2
- package/src/{global → lib}/A-Concept/A-Concept.types.ts +7 -7
- package/src/lib/A-Concept/index.ts +4 -0
- package/src/{global → lib}/A-Container/A-Container.class.ts +3 -3
- package/src/{global → lib}/A-Container/A-Container.meta.ts +11 -6
- package/src/{global → lib}/A-Container/A-Container.types.ts +9 -6
- package/src/lib/A-Container/index.ts +5 -0
- package/src/{global → lib}/A-Context/A-Context.class.ts +41 -33
- package/src/{global → lib}/A-Context/A-Context.error.ts +1 -1
- package/src/lib/A-Context/A-Context.types.ts +14 -0
- package/src/lib/A-Context/index.ts +5 -0
- package/src/{global → lib}/A-Dependency/A-Dependency-All.decorator.ts +11 -11
- package/src/{global → lib}/A-Dependency/A-Dependency-Default.decorator.ts +11 -9
- package/src/{global → lib}/A-Dependency/A-Dependency-Flat.decorator.ts +11 -8
- package/src/{global → lib}/A-Dependency/A-Dependency-Load.decorator.ts +11 -9
- package/src/{global → lib}/A-Dependency/A-Dependency-Parent.decorator.ts +11 -9
- package/src/{global → lib}/A-Dependency/A-Dependency-Require.decorator.ts +11 -9
- package/src/{global → lib}/A-Dependency/A-Dependency.class.ts +9 -3
- package/src/{global → lib}/A-Dependency/A-Dependency.error.ts +1 -1
- package/src/{global → lib}/A-Dependency/A-Dependency.types.ts +9 -9
- package/src/lib/A-Dependency/index.ts +17 -0
- package/src/{global → lib}/A-Entity/A-Entity.class.ts +11 -9
- package/src/{global → lib}/A-Entity/A-Entity.error.ts +1 -1
- package/src/{global → lib}/A-Entity/A-Entity.meta.ts +3 -3
- package/src/{global → lib}/A-Entity/A-Entity.types.ts +5 -5
- package/src/lib/A-Entity/index.ts +5 -0
- package/src/{global → lib}/A-Error/A_Error.class.ts +13 -13
- package/src/{global → lib}/A-Error/A_Error.types.ts +2 -2
- package/src/lib/A-Error/index.ts +3 -0
- package/src/{global → lib}/A-Feature/A-Feature-Define.decorator.ts +16 -10
- package/src/{global → lib}/A-Feature/A-Feature-Extend.decorator.ts +13 -9
- package/src/{global → lib}/A-Feature/A-Feature.class.ts +15 -13
- package/src/{global → lib}/A-Feature/A-Feature.error.ts +2 -2
- package/src/{global → lib}/A-Feature/A-Feature.types.ts +21 -12
- package/src/lib/A-Feature/index.ts +13 -0
- package/src/{global → lib}/A-Fragment/A-Fragment.class.ts +0 -2
- package/src/{global → lib}/A-Fragment/A-Fragment.types.ts +1 -1
- package/src/lib/A-Fragment/index.ts +5 -0
- package/src/{global → lib}/A-Inject/A-Inject.decorator.ts +42 -24
- package/src/{global → lib}/A-Inject/A-Inject.error.ts +1 -1
- package/src/{global → lib}/A-Inject/A-Inject.types.ts +3 -9
- package/src/lib/A-Inject/index.ts +3 -0
- package/src/{global → lib}/A-Meta/A-Meta.decorator.ts +2 -2
- package/src/{global → lib}/A-Meta/A-Meta.types.ts +18 -10
- package/src/lib/A-Meta/index.ts +11 -0
- package/src/{global → lib}/A-Scope/A-Scope.class.ts +34 -24
- package/src/{global → lib}/A-Scope/A-Scope.error.ts +1 -1
- package/src/{global → lib}/A-Scope/A-Scope.types.ts +22 -14
- package/src/lib/A-Scope/index.ts +5 -0
- package/src/{global → lib}/A-Stage/A-Stage.class.ts +9 -10
- package/src/{global → lib}/A-Stage/A-Stage.error.ts +1 -1
- package/src/{global → lib}/A-Stage/A-Stage.types.ts +1 -4
- package/src/lib/A-Stage/index.ts +5 -0
- package/src/{global → lib}/A-StepManager/A-StepManager.class.ts +8 -4
- package/src/{global → lib}/A-StepManager/A-StepManager.error.ts +1 -1
- package/src/lib/A-StepManager/index.ts +4 -0
- package/src/{global → lib}/ASEID/ASEID.class.ts +20 -23
- package/src/lib/ASEID/ASEID.error.ts +12 -0
- package/src/lib/ASEID/index.ts +4 -0
- package/src/types/A_identity.types.ts +4 -0
- package/src/types/index.ts +2 -0
- package/tests/A-Abstraction.test.ts +6 -6
- package/tests/A-Common.test.ts +6 -4
- package/tests/A-Component.test.ts +7 -5
- package/tests/A-Concept.test.ts +13 -11
- package/tests/A-Container.test.ts +4 -3
- package/tests/A-Dependency.test.ts +6 -1
- package/tests/A-Entity.test.ts +7 -5
- package/tests/A-Error.test.ts +7 -4
- package/tests/A-Feature.test.ts +12 -8
- package/tests/A-Fragment.test.ts +1 -2
- package/tests/A-Inject.test.ts +4 -1
- package/tests/A-Meta.test.ts +12 -10
- package/tests/A-Scope.test.ts +11 -10
- package/tests/A-StepManager.test.ts +3 -3
- package/tests/ASEID.test.ts +2 -2
- package/tests/jest.setup.ts +23 -23
- package/tsconfig.json +59 -97
- package/tsup.config.ts +25 -13
- package/dist/browser/A-Context.types-BtR_HJ0j.d.mts +0 -3828
- package/dist/browser/env.d.mts +0 -64
- package/dist/browser/env.mjs +0 -3
- package/dist/browser/env.mjs.map +0 -1
- package/dist/node/A-Context.types-BtR_HJ0j.d.mts +0 -3828
- package/dist/node/A-Context.types-BtR_HJ0j.d.ts +0 -3828
- package/dist/node/env.d.mts +0 -91
- package/dist/node/env.d.ts +0 -91
- package/dist/node/env.js +0 -12
- package/dist/node/env.js.map +0 -1
- package/dist/node/env.mjs +0 -3
- package/dist/node/env.mjs.map +0 -1
- package/dist/node/index.js +0 -387
- package/dist/node/index.js.map +0 -1
- package/src/global/A-Context/A-Context.types.ts +0 -14
- package/src/global/ASEID/ASEID.error.ts +0 -12
- /package/src/{global → lib}/A-Component/A-Component.constants.ts +0 -0
- /package/src/{global → lib}/A-Concept/A-Concept.constants.ts +0 -0
- /package/src/{global → lib}/A-Container/A-Container.constants.ts +0 -0
- /package/src/{global → lib}/A-Entity/A-Entity.constants.ts +0 -0
- /package/src/{global → lib}/A-Error/A_Error.constants.ts +0 -0
- /package/src/{global → lib}/A-Meta/A-Meta.class.ts +0 -0
- /package/src/{global → lib}/ASEID/ASEID.constants.ts +0 -0
- /package/src/{global → lib}/ASEID/ASEID.types.ts +0 -0
package/dist/node/index.d.ts
CHANGED
|
@@ -1,43 +1,4018 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type Decrement = [never, 0, 1, 2, 3, 4, 5];
|
|
2
|
+
type A_TYPES__Ctor<T> = new (...args: any[]) => T;
|
|
3
|
+
type A_TYPES__DeepPartial<T, D extends number = 5> = {
|
|
4
|
+
[P in keyof Required<T>]?: [
|
|
5
|
+
D
|
|
6
|
+
] extends [never] ? any : Required<T>[P] extends Array<infer U> ? Array<A_TYPES__DeepPartial<U, Decrement[D]>> : Required<T>[P] extends Function ? Required<T>[P] : Required<T>[P] extends object ? A_TYPES__DeepPartial<T[P], Decrement[D]> : T[P];
|
|
7
|
+
};
|
|
8
|
+
type A_TYPES__ObjectKeyEnum<T, E> = {
|
|
9
|
+
[P in keyof Required<T>]?: T[P] extends object ? A_TYPES__ObjectKeyEnum<T[P], E> : E;
|
|
10
|
+
};
|
|
11
|
+
type A_TYPES__Dictionary<T> = {
|
|
12
|
+
[Key: string]: T;
|
|
13
|
+
};
|
|
14
|
+
type A_TYPES__NonObjectPaths<T> = T extends object ? {
|
|
15
|
+
[K in keyof T]: `${Exclude<K, symbol>}${""}`;
|
|
16
|
+
}[keyof T] : never;
|
|
17
|
+
type A_TYPES__Paths<T, D extends number = 5> = [D] extends [never] ? never : (T extends object ? {
|
|
18
|
+
[K in keyof T]: `${Exclude<K, symbol>}${"" | `.${A_TYPES__Paths<T[K], Decrement[D]>}`}`;
|
|
19
|
+
}[keyof T] : never);
|
|
20
|
+
type A_TYPES__UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
21
|
+
type A_TYPES__PathsToObject<_Obj, T extends readonly string[]> = A_TYPES__UnionToIntersection<{
|
|
22
|
+
[K in keyof T]: T[K] extends `${infer Key}.${infer Rest}` ? {
|
|
23
|
+
[P in Key]: P extends keyof _Obj ? A_TYPES__PathsToObject<Required<_Obj>[P], [Rest]> : any;
|
|
24
|
+
} : {
|
|
25
|
+
[P in T[K]]: `${T[K]}` extends keyof Required<_Obj> ? Required<_Obj>[`${T[K]}`] : never;
|
|
26
|
+
};
|
|
27
|
+
}[number]>;
|
|
28
|
+
type A_TYPES__Required<T, arr extends (A_TYPES__Paths<T>)[] = (A_TYPES__Paths<T>)[]> = A_TYPES__PathsToObject<T, arr> & T;
|
|
29
|
+
type A_TYPES__ExtractNested<T, P extends string> = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? {
|
|
30
|
+
[Key in K]: A_TYPES__ExtractNested<T[K], Rest>;
|
|
31
|
+
} : never : P extends keyof T ? {
|
|
32
|
+
[Key in P]: T[P];
|
|
33
|
+
} : never;
|
|
34
|
+
type A_TYPES__ExtractProperties<T, P extends A_TYPES__Paths<T>[]> = A_TYPES__UnionToIntersection<{
|
|
35
|
+
[K in keyof P]: P[K] extends string ? A_TYPES__ExtractNested<T, P[K]> : never;
|
|
36
|
+
}[number]>;
|
|
37
|
+
|
|
38
|
+
type A_ID_TYPES__TimeId_Parts = {
|
|
39
|
+
timestamp: Date;
|
|
40
|
+
random: string;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Entity constructor type
|
|
45
|
+
* Uses the generic type T to specify the type of the entity
|
|
46
|
+
*/
|
|
47
|
+
type A_TYPES__Error_Constructor<T = A_Error> = A_TYPES__Ctor<T>;
|
|
48
|
+
/**
|
|
49
|
+
* Error initialization type
|
|
50
|
+
*/
|
|
51
|
+
type A_TYPES__Error_Init = {
|
|
52
|
+
/**
|
|
53
|
+
* Error title
|
|
54
|
+
*
|
|
55
|
+
* A short description of the error
|
|
56
|
+
*/
|
|
57
|
+
title: string;
|
|
58
|
+
/**
|
|
59
|
+
* Error code representing the type of error
|
|
60
|
+
*
|
|
61
|
+
* Should be unique within the application or service
|
|
62
|
+
*
|
|
63
|
+
* Example: 'validation-error', 'not-found', 'user-not-found', 'unauthorized' etc.
|
|
64
|
+
*
|
|
65
|
+
* [!] Note: It is recommended to use kebab-case for error codes
|
|
66
|
+
* [!] Note: If not provided would be used a kebab-case message of the error
|
|
67
|
+
*/
|
|
68
|
+
code?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Possible Scope if needed to identify the error by it's execution environment
|
|
71
|
+
*
|
|
72
|
+
* For example, error of type 'validation' could happen in different scopes
|
|
73
|
+
* like 'user', 'admin', 'system' etc. This will help to identify the error context better
|
|
74
|
+
*
|
|
75
|
+
* Could be string or A_Scope instance
|
|
76
|
+
*
|
|
77
|
+
* [!] Note: If not provided, the default scope of the A_Error will be used (A_Context.root.name)
|
|
78
|
+
*/
|
|
79
|
+
scope?: string | A_Scope;
|
|
80
|
+
/**
|
|
81
|
+
* Detailed description of the error
|
|
82
|
+
*/
|
|
83
|
+
description?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Link to the documentation or support page for the error
|
|
86
|
+
*/
|
|
87
|
+
link?: string;
|
|
88
|
+
/**
|
|
89
|
+
* Original Error if any
|
|
90
|
+
*/
|
|
91
|
+
originalError?: Error | unknown;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Error serialized type
|
|
95
|
+
*/
|
|
96
|
+
type A_TYPES__Error_Serialized = {
|
|
97
|
+
/**
|
|
98
|
+
* ASEID of the error
|
|
99
|
+
*/
|
|
100
|
+
aseid: string;
|
|
101
|
+
/**
|
|
102
|
+
* A brief title of the error
|
|
103
|
+
*/
|
|
104
|
+
title: string;
|
|
105
|
+
/**
|
|
106
|
+
* Error message
|
|
107
|
+
*/
|
|
108
|
+
message: string;
|
|
109
|
+
/**
|
|
110
|
+
* Type of the error
|
|
111
|
+
*/
|
|
112
|
+
type: string;
|
|
113
|
+
/**
|
|
114
|
+
* Error code
|
|
115
|
+
*/
|
|
116
|
+
code: string;
|
|
117
|
+
/**
|
|
118
|
+
* Error description
|
|
119
|
+
*/
|
|
120
|
+
description: string;
|
|
121
|
+
/**
|
|
122
|
+
* Link to documentation or support page
|
|
123
|
+
*/
|
|
124
|
+
link?: string;
|
|
125
|
+
/**
|
|
126
|
+
* Scope of the error
|
|
127
|
+
*/
|
|
128
|
+
scope: string;
|
|
129
|
+
/**
|
|
130
|
+
* Original error message if any
|
|
131
|
+
*/
|
|
132
|
+
originalError?: string;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
interface A_TYPES__ASEID_Constructor {
|
|
136
|
+
/**
|
|
137
|
+
* Concept for the ASEID
|
|
138
|
+
* Generally it is the application name or code, should correspond to the concept where the entity is used
|
|
139
|
+
* Could be ID or ASEID
|
|
140
|
+
*/
|
|
141
|
+
concept?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Entity Scope the primary location of the resource
|
|
144
|
+
* Organization, or organization Unit or Internal/External
|
|
145
|
+
* Could be ID or ASEID
|
|
146
|
+
*
|
|
147
|
+
*/
|
|
148
|
+
scope: number | string;
|
|
149
|
+
/**
|
|
150
|
+
* Entity Type the type of the resource
|
|
151
|
+
*/
|
|
152
|
+
entity: string;
|
|
153
|
+
/**
|
|
154
|
+
* Entity ID the unique identifier of the resource
|
|
155
|
+
*/
|
|
156
|
+
id: number | string;
|
|
157
|
+
/**
|
|
158
|
+
* Version of the entity (optional)
|
|
159
|
+
*/
|
|
160
|
+
version?: string;
|
|
161
|
+
/**
|
|
162
|
+
* Shard of the entity (optional)
|
|
163
|
+
*/
|
|
164
|
+
shard?: string;
|
|
165
|
+
}
|
|
166
|
+
interface A_TYPES__ASEID_ConstructorConfig {
|
|
167
|
+
/**
|
|
168
|
+
* If true, the entity ASEID will be distributed across multiple shards.
|
|
169
|
+
* In this case SHARD should be provided via Environment Variables (A_SHARD) or Configurations
|
|
170
|
+
*
|
|
171
|
+
*/
|
|
172
|
+
sharding?: boolean;
|
|
173
|
+
}
|
|
174
|
+
type A_TYPES__ASEID_JSON = {
|
|
175
|
+
/**
|
|
176
|
+
* Concept for the ASEID
|
|
177
|
+
*/
|
|
178
|
+
concept: string;
|
|
179
|
+
/**
|
|
180
|
+
* Entity Scope the primary location of the resource
|
|
181
|
+
*/
|
|
182
|
+
scope: string;
|
|
183
|
+
/**
|
|
184
|
+
* Entity Type the type of the resource
|
|
185
|
+
*/
|
|
186
|
+
entity: string;
|
|
187
|
+
/**
|
|
188
|
+
* Entity ID the unique identifier of the resource
|
|
189
|
+
*/
|
|
190
|
+
id: string;
|
|
191
|
+
/**
|
|
192
|
+
* Version of the entity (optional)
|
|
193
|
+
*/
|
|
194
|
+
version?: string;
|
|
195
|
+
/**
|
|
196
|
+
* Shard of the entity (optional)
|
|
197
|
+
*/
|
|
198
|
+
shard?: string;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
declare class ASEID {
|
|
202
|
+
/**
|
|
203
|
+
* ASEID Regular Expression
|
|
204
|
+
*/
|
|
205
|
+
static readonly regexp: RegExp;
|
|
206
|
+
/**
|
|
207
|
+
* Tests if the identity string is an ASEID
|
|
208
|
+
*
|
|
209
|
+
* @param identity
|
|
210
|
+
* @returns
|
|
211
|
+
*/
|
|
212
|
+
static isASEID(identity: string): boolean;
|
|
213
|
+
static compare(aseid1: ASEID | string | undefined, aseid2: ASEID | string | undefined): boolean;
|
|
214
|
+
/**
|
|
215
|
+
* Concept for the ASEID
|
|
216
|
+
* Generally it is the application name or code, should correspond to the concept where the entity is used
|
|
217
|
+
* Could be ID or ASEID
|
|
218
|
+
*/
|
|
219
|
+
private _concept;
|
|
220
|
+
/**
|
|
221
|
+
* Entity Scope the primary location of the resource
|
|
222
|
+
* Organization, or organization Unit
|
|
223
|
+
* Could be ID or ASEID
|
|
224
|
+
*
|
|
225
|
+
*/
|
|
226
|
+
private _scope;
|
|
227
|
+
/**
|
|
228
|
+
* Entity Type the type of the resource
|
|
229
|
+
*/
|
|
230
|
+
private _entity;
|
|
231
|
+
/**
|
|
232
|
+
* Entity ID the unique identifier of the resource
|
|
233
|
+
*/
|
|
234
|
+
private _id;
|
|
235
|
+
/**
|
|
236
|
+
* Version of the entity (optional)
|
|
237
|
+
*/
|
|
238
|
+
private _version?;
|
|
239
|
+
/**
|
|
240
|
+
* Shard of the entity (optional)
|
|
241
|
+
*/
|
|
242
|
+
private _shard?;
|
|
243
|
+
/**
|
|
244
|
+
* ASEID is a structured identifier for entities in the A-Concept system.
|
|
245
|
+
* using the format:
|
|
246
|
+
* A - A-Concept
|
|
247
|
+
* S - System
|
|
248
|
+
* E - Entity
|
|
249
|
+
* I - Identifier
|
|
250
|
+
* D - iDentifier
|
|
251
|
+
*
|
|
252
|
+
* Structure: CONCEPT_NAME + @ + SCOPE + : ENTITY_NAME + : + ID + @ + VERSION
|
|
253
|
+
*
|
|
254
|
+
* Example:
|
|
255
|
+
* - root@core:usr:0000000001
|
|
256
|
+
*
|
|
257
|
+
* [!] Concept is optional, if not provided will be used the current concept name
|
|
258
|
+
* [!] Scope is optional, if not provided will be used the root scope of the current concept
|
|
259
|
+
* [!] Version is optional, if not provided will be considered as latest version
|
|
260
|
+
*
|
|
261
|
+
* @param aseid - ASEID string representation or ASEID components as object
|
|
262
|
+
*/
|
|
263
|
+
constructor(
|
|
264
|
+
/**
|
|
265
|
+
* ASEID string representation
|
|
266
|
+
*/
|
|
267
|
+
aseid: string);
|
|
268
|
+
constructor(
|
|
269
|
+
/**
|
|
270
|
+
* ASEID components as object
|
|
271
|
+
*/
|
|
272
|
+
props: A_TYPES__Required<Partial<A_TYPES__ASEID_Constructor>, ['id', 'entity']>);
|
|
273
|
+
/**
|
|
274
|
+
* Getters for ASEID components
|
|
275
|
+
*/
|
|
276
|
+
get concept(): string;
|
|
277
|
+
/**
|
|
278
|
+
* Get the scope of the ASEID
|
|
279
|
+
*/
|
|
280
|
+
get scope(): string;
|
|
281
|
+
/**
|
|
282
|
+
* Get the entity of the ASEID
|
|
283
|
+
*/
|
|
284
|
+
get entity(): string;
|
|
285
|
+
/**
|
|
286
|
+
* Get the id of the ASEID
|
|
287
|
+
*/
|
|
288
|
+
get id(): string;
|
|
289
|
+
/**
|
|
290
|
+
* Get the version of the ASEID (if any)
|
|
291
|
+
*/
|
|
292
|
+
get version(): string | undefined;
|
|
293
|
+
/**
|
|
294
|
+
* Get the shard of the ASEID (if any)
|
|
295
|
+
*/
|
|
296
|
+
get shard(): string | undefined;
|
|
297
|
+
/**
|
|
298
|
+
* Get the hash of the ASEID, Unique identifier based on the ASEID string
|
|
299
|
+
* Useful when aseid details should not be exposed directly
|
|
300
|
+
*/
|
|
301
|
+
get hash(): string;
|
|
302
|
+
/**
|
|
303
|
+
* get Internal Initializer based on the type of the parameter provided
|
|
304
|
+
*
|
|
305
|
+
* @param param1
|
|
306
|
+
* @returns
|
|
307
|
+
*/
|
|
308
|
+
private getInitializer;
|
|
309
|
+
/**
|
|
310
|
+
* Initialize ASEID from string
|
|
311
|
+
*
|
|
312
|
+
* @param param1
|
|
313
|
+
*/
|
|
314
|
+
private fromString;
|
|
315
|
+
/**
|
|
316
|
+
* Initialize ASEID from object
|
|
317
|
+
*
|
|
318
|
+
* @param param1
|
|
319
|
+
*/
|
|
320
|
+
private fromObject;
|
|
321
|
+
/**
|
|
322
|
+
* String representation of the ASEID
|
|
323
|
+
*
|
|
324
|
+
* @returns
|
|
325
|
+
*/
|
|
326
|
+
toString(): string;
|
|
327
|
+
/**
|
|
328
|
+
* JSON representation of the ASEID
|
|
329
|
+
*
|
|
330
|
+
* @returns
|
|
331
|
+
*/
|
|
332
|
+
toJSON(): A_TYPES__ASEID_JSON;
|
|
333
|
+
protected verifyInput(param1: string | A_TYPES__Required<Partial<A_TYPES__ASEID_Constructor>, ['id', 'entity']>): void;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
declare class A_Error<_ConstructorType extends A_TYPES__Error_Init = A_TYPES__Error_Init, _SerializedType extends A_TYPES__Error_Serialized = A_TYPES__Error_Serialized> extends Error {
|
|
337
|
+
/**
|
|
338
|
+
* Error Identifier that corresponds to the class name
|
|
339
|
+
*/
|
|
340
|
+
static get entity(): string;
|
|
341
|
+
/**
|
|
342
|
+
* DEFAULT Namespace of the error from environment variable A_CONCEPT_NAMESPACE
|
|
343
|
+
*
|
|
344
|
+
* [!] If environment variable is not set, it will default to 'a-concept'
|
|
345
|
+
*/
|
|
346
|
+
static get concept(): string;
|
|
347
|
+
/**
|
|
348
|
+
* DEFAULT Scope of the entity from environment variable A_CONCEPT_DEFAULT_SCOPE
|
|
349
|
+
*
|
|
350
|
+
* [!] If environment variable is not set, it will default to 'core'
|
|
351
|
+
* [!] Scope is an application specific identifier that can be used to group entities together
|
|
352
|
+
* [!] e.g. 'default', 'core', 'public', 'internal', etc
|
|
353
|
+
*/
|
|
354
|
+
static get scope(): string;
|
|
355
|
+
/**
|
|
356
|
+
* ASEID of the error instance
|
|
357
|
+
*/
|
|
358
|
+
protected _aseid: ASEID;
|
|
359
|
+
/**
|
|
360
|
+
* Title of the error
|
|
361
|
+
*/
|
|
362
|
+
protected _title: string;
|
|
363
|
+
/**
|
|
364
|
+
* Possible Scope if needed to identify the error by it's execution environment
|
|
365
|
+
*/
|
|
366
|
+
protected _scope?: string;
|
|
367
|
+
/**
|
|
368
|
+
* Unique code representing the type of error
|
|
369
|
+
*/
|
|
370
|
+
protected _code?: string;
|
|
371
|
+
/**
|
|
372
|
+
* Detailed description of the error
|
|
373
|
+
*/
|
|
374
|
+
protected _description?: string;
|
|
375
|
+
/**
|
|
376
|
+
* Original Error if any
|
|
377
|
+
*/
|
|
378
|
+
protected _originalError?: Error | any;
|
|
379
|
+
/**
|
|
380
|
+
* Link to the documentation or support page for the error
|
|
381
|
+
*/
|
|
382
|
+
protected _link?: string;
|
|
383
|
+
/**
|
|
384
|
+
* A_Error is a custom error class for A_Concept framework.
|
|
385
|
+
* This error allows to have more structured error handling.
|
|
386
|
+
* Each error has a unique code, description and a link to the documentation.
|
|
387
|
+
*
|
|
388
|
+
* Example of usage:
|
|
389
|
+
* ```typescript
|
|
390
|
+
*
|
|
391
|
+
* // 1) all parameters will be used as provided
|
|
392
|
+
* throw new A_Error({
|
|
393
|
+
* message: 'User not found',
|
|
394
|
+
* code: 'USER_NOT_FOUND',
|
|
395
|
+
* description: 'The user with the given ID was not found.',
|
|
396
|
+
* link: 'https://support.adaas.org/error/USER_NOT_FOUND'
|
|
397
|
+
* });
|
|
398
|
+
*
|
|
399
|
+
* // or
|
|
400
|
+
* // 2) only message is provided, other parameters will be set to default values:
|
|
401
|
+
* // - code: 'user-not-found' (kebab-case of the message)
|
|
402
|
+
* // - description: 'User not found' (same as message)
|
|
403
|
+
* // - link: Empty
|
|
404
|
+
* throw new A_Error('User not found');
|
|
405
|
+
*
|
|
406
|
+
* // or
|
|
407
|
+
* // 3) Provided Message and Description, other parameters will be set to default values:
|
|
408
|
+
* // - code: 'user-not-found' (kebab-case of the message)
|
|
409
|
+
* // - description: 'The user with the given ID was not found.' (as provided)
|
|
410
|
+
* // - link: Empty
|
|
411
|
+
* throw new A_Error('User not found', 'The user with the given ID was not found.');
|
|
412
|
+
*
|
|
413
|
+
*
|
|
414
|
+
* ```
|
|
415
|
+
* [!] Note: The behavior of A_Error is similar to the A_Entity however it cannot have own A_Features.
|
|
416
|
+
* [!] Note: This class can be inherited to create custom error classes.
|
|
417
|
+
*
|
|
418
|
+
* @param message
|
|
419
|
+
*/
|
|
420
|
+
constructor(
|
|
421
|
+
/**
|
|
422
|
+
* A_Error Constructor params
|
|
423
|
+
*/
|
|
424
|
+
params: _ConstructorType);
|
|
425
|
+
constructor(
|
|
426
|
+
/**
|
|
427
|
+
* Error message
|
|
428
|
+
*/
|
|
429
|
+
message: string);
|
|
430
|
+
constructor(
|
|
431
|
+
/**
|
|
432
|
+
* Original JS Error
|
|
433
|
+
*/
|
|
434
|
+
error: Error);
|
|
435
|
+
constructor(
|
|
436
|
+
/**
|
|
437
|
+
* Original JS Error
|
|
438
|
+
*/
|
|
439
|
+
error: unknown);
|
|
440
|
+
constructor(
|
|
441
|
+
/**
|
|
442
|
+
* Error message
|
|
443
|
+
*/
|
|
444
|
+
title: string,
|
|
445
|
+
/**
|
|
446
|
+
* Detailed description of the error
|
|
447
|
+
*/
|
|
448
|
+
description: string);
|
|
449
|
+
/**
|
|
450
|
+
* Returns the ASEID of the error instance
|
|
451
|
+
*/
|
|
452
|
+
get aseid(): ASEID;
|
|
453
|
+
/**
|
|
454
|
+
* Returns the title of the error
|
|
455
|
+
*
|
|
456
|
+
* Example: 'User not found', 'Validation error', 'Unauthorized access', etc.
|
|
457
|
+
*
|
|
458
|
+
* [!] Note: This title should be short and concise, less than 60 characters
|
|
459
|
+
* [!] Note: If title exceeds 60 characters, there would be an error thrown
|
|
460
|
+
* [!] Note: This title is intended to be human-readable and can be displayed in UI or logs
|
|
461
|
+
*/
|
|
462
|
+
get title(): string;
|
|
463
|
+
/**
|
|
464
|
+
* Returns an Error message what is a brief title of the error
|
|
465
|
+
*
|
|
466
|
+
*/
|
|
467
|
+
get message(): string;
|
|
468
|
+
/**
|
|
469
|
+
* Returns a unique code representing the type of error
|
|
470
|
+
*
|
|
471
|
+
* If code is not provided, it will generate a kebab-case of the message
|
|
472
|
+
*
|
|
473
|
+
* Example: 'validation-error', 'not-found', 'user-not-found', 'unauthorized' etc.
|
|
474
|
+
*
|
|
475
|
+
* [!] Note: It is recommended to use kebab-case for error codes
|
|
476
|
+
* [!] Note: If not provided would be used a kebab-case message of the error
|
|
477
|
+
*/
|
|
478
|
+
get code(): string;
|
|
479
|
+
/**
|
|
480
|
+
* Returns the type of the error which corresponds to the static entity of the class
|
|
481
|
+
*
|
|
482
|
+
* Example: 'a-error', 'validation-error', 'not-found-error', 'user-error', etc.
|
|
483
|
+
*
|
|
484
|
+
* Defaults to the kebab-case of the class name
|
|
485
|
+
*
|
|
486
|
+
* [!] Note: naming ad separation are fully dependent on the architecture of the application
|
|
487
|
+
* [!] Note: It is recommended to use kebab-case for error types
|
|
488
|
+
* [!] Note: This type is intended to group similar errors together
|
|
489
|
+
*/
|
|
490
|
+
get type(): string;
|
|
491
|
+
/**
|
|
492
|
+
* Returns a link with possible documentation or support page for the error
|
|
493
|
+
* 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
|
|
494
|
+
*
|
|
495
|
+
* Example: https://adaas.support/a-concept/errors/{ASEID}
|
|
496
|
+
*
|
|
497
|
+
* [!] Note: ASEID is generated based on the static properties of the class (concept, scope, entity) and the code of the error
|
|
498
|
+
*/
|
|
499
|
+
get link(): string;
|
|
500
|
+
/**
|
|
501
|
+
* The scope name of the error instance
|
|
502
|
+
*
|
|
503
|
+
* If scope is not provided, it will use the static scope of the class
|
|
504
|
+
*
|
|
505
|
+
* [!] Note: Scope is an application specific identifier that can be used to group entities together
|
|
506
|
+
* [!] e.g. 'default', 'core', 'public', 'internal', etc
|
|
507
|
+
*/
|
|
508
|
+
get scope(): string;
|
|
509
|
+
/**
|
|
510
|
+
* A detailed description of the error
|
|
511
|
+
* If description is not provided, it will use the environment variable A_ERROR_DEFAULT_DESCRIPTION or a generic message
|
|
512
|
+
*
|
|
513
|
+
* 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.
|
|
514
|
+
*
|
|
515
|
+
* [!] Note: This description is intended to provide more context about the error and can be used for debugging or logging purposes
|
|
516
|
+
*/
|
|
517
|
+
get description(): string;
|
|
518
|
+
/**
|
|
519
|
+
* Returns the original error if any
|
|
520
|
+
*
|
|
521
|
+
* This can be useful for debugging purposes to see the original stack trace or error message
|
|
522
|
+
*
|
|
523
|
+
* [!] Note: Original error is optional and may not be present in all cases
|
|
524
|
+
*/
|
|
525
|
+
get originalError(): Error | any | undefined;
|
|
526
|
+
/**
|
|
527
|
+
* Determines which initializer method to use based on the type of the first parameter.
|
|
528
|
+
*
|
|
529
|
+
* @param param1
|
|
530
|
+
* @returns
|
|
531
|
+
*/
|
|
532
|
+
protected getInitializer(param1: _ConstructorType | Error | string | any, param2?: string): (param1: any, param2: any) => void | (() => void);
|
|
533
|
+
/**
|
|
534
|
+
* Initializes the A_Error instance from a standard Error object.
|
|
535
|
+
*
|
|
536
|
+
* @param error
|
|
537
|
+
*/
|
|
538
|
+
protected fromError(error: Error): void;
|
|
539
|
+
/**
|
|
540
|
+
* Initializes the A_Error instance from a message.
|
|
541
|
+
*
|
|
542
|
+
* @param title
|
|
543
|
+
* @param description
|
|
544
|
+
*/
|
|
545
|
+
protected fromMessage(message: string): void;
|
|
546
|
+
/**
|
|
547
|
+
* Initializes the A_Error instance from a serialized object.
|
|
548
|
+
*
|
|
549
|
+
* @param serialized
|
|
550
|
+
*/
|
|
551
|
+
protected fromJSON(serialized: _SerializedType): void;
|
|
552
|
+
fromTitle(title: string, description: string): void;
|
|
553
|
+
/**
|
|
554
|
+
* Initializes the A_Error instance from a constructor parameters object.
|
|
555
|
+
*
|
|
556
|
+
* @param params
|
|
557
|
+
*/
|
|
558
|
+
protected fromConstructor(params: _ConstructorType): void;
|
|
559
|
+
/**
|
|
560
|
+
* Serializes the A_Error instance to a plain object.
|
|
561
|
+
*
|
|
562
|
+
*
|
|
563
|
+
* @returns
|
|
564
|
+
*/
|
|
565
|
+
toJSON(): _SerializedType;
|
|
566
|
+
/**
|
|
567
|
+
* Checks if the provided title exceeds 60 characters.
|
|
568
|
+
* If it does, throws a validation A_Error.
|
|
569
|
+
*
|
|
570
|
+
* @param title
|
|
571
|
+
*/
|
|
572
|
+
protected validateTitle(title: string): void;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
declare const A_CONSTANTS__ERROR_CODES: {
|
|
576
|
+
readonly UNEXPECTED_ERROR: "A-Error Unexpected Error";
|
|
577
|
+
readonly VALIDATION_ERROR: "A-Error Validation Error";
|
|
578
|
+
};
|
|
579
|
+
declare const A_CONSTANTS__ERROR_DESCRIPTION = "If you see this error please let us know.";
|
|
580
|
+
|
|
581
|
+
/**
|
|
582
|
+
* Fragment constructor type
|
|
583
|
+
* Uses the generic type T to specify the type of the fragment
|
|
584
|
+
*/
|
|
585
|
+
type A_TYPES__Fragment_Constructor<T = A_Fragment> = A_TYPES__Ctor<T>;
|
|
586
|
+
/**
|
|
587
|
+
* Fragment initialization type
|
|
588
|
+
*/
|
|
589
|
+
type A_TYPES__Fragment_Init = {
|
|
590
|
+
name: string;
|
|
591
|
+
};
|
|
592
|
+
/**
|
|
593
|
+
* Fragment serialized type
|
|
594
|
+
*/
|
|
595
|
+
type A_TYPES__Fragment_Serialized = {
|
|
596
|
+
/**
|
|
597
|
+
* The Name of the fragment
|
|
598
|
+
*/
|
|
599
|
+
name: string;
|
|
600
|
+
};
|
|
601
|
+
|
|
602
|
+
/**
|
|
603
|
+
* A_Fragment is a core architectural component that represents a singleton execution context
|
|
604
|
+
* within the A-Concept framework. It serves as a shared memory container that can be passed
|
|
605
|
+
* between Components, Entities, and Commands throughout the application pipeline.
|
|
606
|
+
*
|
|
607
|
+
* Key Features:
|
|
608
|
+
* - Singleton pattern: Only one instance per fragment type per scope
|
|
609
|
+
* - Meta storage: Built-in key-value storage for pipeline data
|
|
610
|
+
* - Type-safe: Full TypeScript generics support for meta items and serialization
|
|
611
|
+
* - Serializable: Can be converted to JSON for persistence or transmission
|
|
612
|
+
*
|
|
613
|
+
* @template _MetaItems - Type definition for the meta storage structure
|
|
614
|
+
* @template _SerializedType - Type definition for the serialized output format
|
|
615
|
+
*
|
|
616
|
+
* @example
|
|
617
|
+
* ```typescript
|
|
618
|
+
* // Basic usage with typed meta
|
|
619
|
+
* class UserFragment extends A_Fragment<{ userId: string; role: string }> {
|
|
620
|
+
* constructor() {
|
|
621
|
+
* super({ name: 'UserFragment' });
|
|
622
|
+
* }
|
|
623
|
+
* }
|
|
624
|
+
*
|
|
625
|
+
* // Custom serialization
|
|
626
|
+
* class SessionFragment extends A_Fragment<
|
|
627
|
+
* { sessionId: string; timestamp: number },
|
|
628
|
+
* { name: string; sessionData: string }
|
|
629
|
+
* > {
|
|
630
|
+
* toJSON() {
|
|
631
|
+
* return {
|
|
632
|
+
* name: this.name,
|
|
633
|
+
* sessionData: `${this.get('sessionId')}-${this.get('timestamp')}`
|
|
634
|
+
* };
|
|
635
|
+
* }
|
|
636
|
+
* }
|
|
637
|
+
* ```
|
|
638
|
+
*/
|
|
639
|
+
declare class A_Fragment<_SerializedType extends A_TYPES__Fragment_Serialized = A_TYPES__Fragment_Serialized> {
|
|
640
|
+
/**
|
|
641
|
+
* The unique identifier/name for this fragment instance.
|
|
642
|
+
* Used for identification and debugging purposes.
|
|
643
|
+
*/
|
|
644
|
+
protected _name: string;
|
|
645
|
+
/**
|
|
646
|
+
* Creates a new A_Fragment instance.
|
|
647
|
+
*
|
|
648
|
+
* A_Fragment implements the singleton pattern for execution contexts, allowing
|
|
649
|
+
* shared state management across different parts of the application pipeline.
|
|
650
|
+
* Each fragment serves as a memory container that can store typed data and be
|
|
651
|
+
* serialized for persistence or transmission.
|
|
652
|
+
*
|
|
653
|
+
* Key Benefits:
|
|
654
|
+
* - Centralized state management for related operations
|
|
655
|
+
* - Type-safe meta operations with full IntelliSense support
|
|
656
|
+
* - Serialization support for data persistence
|
|
657
|
+
* - Singleton pattern ensures consistent state within scope
|
|
658
|
+
*
|
|
659
|
+
* @param params - Initialization parameters
|
|
660
|
+
* @param params.name - Optional custom name for the fragment (defaults to class name)
|
|
661
|
+
*
|
|
662
|
+
* @example
|
|
663
|
+
* ```typescript
|
|
664
|
+
* const fragment = new A_Fragment<{ userId: string }>({
|
|
665
|
+
* name: 'UserSessionFragment'
|
|
666
|
+
* });
|
|
667
|
+
* fragment.set('userId', '12345');
|
|
668
|
+
* ```
|
|
669
|
+
*/
|
|
670
|
+
constructor(params?: Partial<A_TYPES__Fragment_Init>);
|
|
671
|
+
/**
|
|
672
|
+
* Gets the fragment's unique name/identifier.
|
|
673
|
+
*
|
|
674
|
+
* @returns The fragment name
|
|
675
|
+
*/
|
|
676
|
+
get name(): string;
|
|
677
|
+
/**
|
|
678
|
+
* Serializes the fragment to a JSON-compatible object.
|
|
679
|
+
*
|
|
680
|
+
* This method combines the fragment's name with all meta data to create
|
|
681
|
+
* a serializable representation. The return type is determined by the
|
|
682
|
+
* _SerializedType generic parameter, allowing for custom serialization formats.
|
|
683
|
+
*
|
|
684
|
+
* @returns A serialized representation of the fragment
|
|
685
|
+
*
|
|
686
|
+
* @example
|
|
687
|
+
* ```typescript
|
|
688
|
+
* const fragment = new A_Fragment<{ userId: string, role: string }>({
|
|
689
|
+
* name: 'UserFragment'
|
|
690
|
+
* });
|
|
691
|
+
* fragment.set('userId', '12345');
|
|
692
|
+
* fragment.set('role', 'admin');
|
|
693
|
+
*
|
|
694
|
+
* const json = fragment.toJSON();
|
|
695
|
+
* // Result: { name: 'UserFragment', userId: '12345', role: 'admin' }
|
|
696
|
+
* ```
|
|
697
|
+
*/
|
|
698
|
+
toJSON(): _SerializedType;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
/**
|
|
702
|
+
* Meta constructor type
|
|
703
|
+
*/
|
|
704
|
+
type A_TYPES__Meta_Constructor<T = A_Meta> = A_TYPES__Ctor<T>;
|
|
705
|
+
/**
|
|
706
|
+
* Components that can have Meta associated with them
|
|
707
|
+
*/
|
|
708
|
+
type A_TYPES__MetaLinkedComponents = A_Container | A_Component | A_Entity | A_Fragment;
|
|
709
|
+
/**
|
|
710
|
+
* Constructors of components that can have Meta associated with them
|
|
711
|
+
*/
|
|
712
|
+
type A_TYPES__MetaLinkedComponentConstructors = A_TYPES__Ctor<any> | A_TYPES__Container_Constructor | A_TYPES__Component_Constructor | A_TYPES__Entity_Constructor | A_TYPES__Fragment_Constructor;
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* A Meta is an entity that stores all the metadata for the specific entity like container, component, feature, etc.
|
|
716
|
+
*
|
|
717
|
+
* [!] Meta can be different depending on the type of input data
|
|
718
|
+
*/
|
|
719
|
+
declare class A_Meta<_StorageItems extends Record<any, any> = any, _SerializedType extends Record<string, any> = Record<string, any>> implements Iterable<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
720
|
+
/**
|
|
721
|
+
* Allows to set a custom meta class for the Component or Container or Entity, or anything else.
|
|
722
|
+
*
|
|
723
|
+
* @param target
|
|
724
|
+
* @returns
|
|
725
|
+
*/
|
|
726
|
+
static Define<T extends A_Meta>(target: A_TYPES__Meta_Constructor<T>): <TTarget extends A_TYPES__MetaLinkedComponentConstructors>(target: TTarget) => TTarget;
|
|
727
|
+
protected meta: Map<keyof _StorageItems, _StorageItems[keyof _StorageItems]>;
|
|
728
|
+
/**
|
|
729
|
+
* Method to get the iterator for the meta object
|
|
730
|
+
*
|
|
731
|
+
* @returns
|
|
732
|
+
*/
|
|
733
|
+
[Symbol.iterator](): Iterator<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]>;
|
|
734
|
+
/**
|
|
735
|
+
* Allows to replicate received meta object by replacing internal meta to the received one
|
|
736
|
+
*
|
|
737
|
+
* @param meta
|
|
738
|
+
* @returns
|
|
739
|
+
*/
|
|
740
|
+
from(meta: A_Meta<_StorageItems>): A_Meta<_StorageItems>;
|
|
741
|
+
/**
|
|
742
|
+
* Method to set values in the map
|
|
743
|
+
*
|
|
744
|
+
* @param key
|
|
745
|
+
* @param value
|
|
746
|
+
*/
|
|
747
|
+
set<K extends keyof _StorageItems>(key: K, value: _StorageItems[K]): void;
|
|
748
|
+
/**
|
|
749
|
+
* Method to get values from the map
|
|
750
|
+
*
|
|
751
|
+
* @param key
|
|
752
|
+
* @returns
|
|
753
|
+
*/
|
|
754
|
+
get<K extends keyof _StorageItems>(key: K): _StorageItems[K] | undefined;
|
|
755
|
+
/**
|
|
756
|
+
* Method to delete values from the map
|
|
757
|
+
*
|
|
758
|
+
* @param key
|
|
759
|
+
* @returns
|
|
760
|
+
*/
|
|
761
|
+
delete(key: keyof _StorageItems): boolean;
|
|
762
|
+
/**
|
|
763
|
+
* Method to get the size of the map
|
|
764
|
+
*
|
|
765
|
+
* @returns
|
|
766
|
+
*/
|
|
767
|
+
size(): number;
|
|
768
|
+
/**
|
|
769
|
+
* This method is needed to convert the key to a regular expression and cover cases like:
|
|
770
|
+
*
|
|
771
|
+
* simple * e.g. "a*" instead of "a.*"
|
|
772
|
+
*
|
|
773
|
+
* simple ? e.g. "a?" instead of "a."
|
|
774
|
+
*
|
|
775
|
+
* etc.
|
|
776
|
+
*
|
|
777
|
+
* @param key
|
|
778
|
+
* @returns
|
|
779
|
+
*/
|
|
780
|
+
private convertToRegExp;
|
|
781
|
+
/**
|
|
782
|
+
* Method to find values in the map by name.
|
|
783
|
+
*
|
|
784
|
+
* Converts the Key in Map to a regular expression and then compares to the name
|
|
785
|
+
*
|
|
786
|
+
* @param name
|
|
787
|
+
* @returns
|
|
788
|
+
*/
|
|
789
|
+
find(name: string): [keyof _StorageItems, _StorageItems[keyof _StorageItems]][];
|
|
790
|
+
/**
|
|
791
|
+
* Method to find values in the map by regular expression
|
|
792
|
+
*
|
|
793
|
+
* Compares Map Key to the input regular expression
|
|
794
|
+
*
|
|
795
|
+
* @param regex
|
|
796
|
+
* @returns
|
|
797
|
+
*/
|
|
798
|
+
findByRegex(regex: RegExp): Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]>;
|
|
799
|
+
/**
|
|
800
|
+
* Method to check if the map has a specific key
|
|
801
|
+
*
|
|
802
|
+
* @param key
|
|
803
|
+
* @returns
|
|
804
|
+
*/
|
|
805
|
+
has(key: keyof _StorageItems): boolean;
|
|
806
|
+
/**
|
|
807
|
+
* Method to get the size of the map
|
|
808
|
+
*
|
|
809
|
+
* @returns
|
|
810
|
+
*/
|
|
811
|
+
entries(): IterableIterator<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]>;
|
|
812
|
+
/**
|
|
813
|
+
* Method to clear the map
|
|
814
|
+
*/
|
|
815
|
+
clear(): void;
|
|
816
|
+
toArray(): Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]>;
|
|
817
|
+
protected recursiveToJSON(value: any): any;
|
|
818
|
+
/**
|
|
819
|
+
* Serializes the meta to a JSON object
|
|
820
|
+
* Uses internal storage to convert to JSON
|
|
821
|
+
*
|
|
822
|
+
* @returns
|
|
823
|
+
*/
|
|
824
|
+
toJSON(): _SerializedType;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
*
|
|
829
|
+
* This decorator should allow to set a default meta type for the class, this helps to avoid
|
|
830
|
+
* the need to create custom meta classes for each class.
|
|
831
|
+
*
|
|
832
|
+
* @returns
|
|
833
|
+
*/
|
|
834
|
+
declare function A_MetaDecorator<T extends A_Meta>(constructor: A_TYPES__Ctor<T>): <TTarget extends A_TYPES__MetaLinkedComponentConstructors>(target: TTarget) => TTarget;
|
|
835
|
+
|
|
836
|
+
declare enum A_TYPES__EntityMetaKey {
|
|
837
|
+
EXTENSIONS = "a-component-extensions",
|
|
838
|
+
FEATURES = "a-component-features",
|
|
839
|
+
ABSTRACTIONS = "a-component-abstractions",
|
|
840
|
+
INJECTIONS = "a-component-injections"
|
|
841
|
+
}
|
|
842
|
+
declare enum A_TYPES__EntityFeatures {
|
|
843
|
+
SAVE = "save",
|
|
844
|
+
DESTROY = "destroy",
|
|
845
|
+
LOAD = "load"
|
|
846
|
+
}
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Entity interface
|
|
850
|
+
*/
|
|
851
|
+
interface A_TYPES__IEntity {
|
|
852
|
+
/**
|
|
853
|
+
* The ASEID of the entity
|
|
854
|
+
*/
|
|
855
|
+
aseid: ASEID;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Entity constructor type
|
|
859
|
+
* Uses the generic type T to specify the type of the entity
|
|
860
|
+
*/
|
|
861
|
+
type A_TYPES__Entity_Constructor<T = A_Entity> = A_TYPES__Ctor<T>;
|
|
862
|
+
/**
|
|
863
|
+
* Entity initialization type
|
|
864
|
+
*/
|
|
865
|
+
type A_TYPES__Entity_Init = any;
|
|
866
|
+
/**
|
|
867
|
+
* Entity serialized type
|
|
868
|
+
*/
|
|
869
|
+
type A_TYPES__Entity_Serialized = {
|
|
870
|
+
/**
|
|
871
|
+
* The ASEID of the entity
|
|
872
|
+
*/
|
|
873
|
+
aseid: string;
|
|
874
|
+
};
|
|
875
|
+
/**
|
|
876
|
+
* Entity meta type
|
|
877
|
+
*/
|
|
878
|
+
type A_TYPES__EntityMeta = {
|
|
879
|
+
[A_TYPES__EntityMetaKey.EXTENSIONS]: A_Meta<{
|
|
880
|
+
/**
|
|
881
|
+
* Where Key the regexp for what to apply the extension
|
|
882
|
+
* A set of container names or a wildcard, or a regexp
|
|
883
|
+
*
|
|
884
|
+
*
|
|
885
|
+
* Where value is the extension instructions
|
|
886
|
+
*/
|
|
887
|
+
[Key: string]: A_TYPES__FeatureExtendDecoratorMeta[];
|
|
888
|
+
}>;
|
|
889
|
+
case: any;
|
|
890
|
+
[A_TYPES__EntityMetaKey.FEATURES]: A_Meta<{
|
|
891
|
+
/**
|
|
892
|
+
* Where Key is the name of the feature
|
|
893
|
+
*
|
|
894
|
+
* Where value is the list of features
|
|
895
|
+
*/
|
|
896
|
+
[Key: string]: A_TYPES__FeatureDefineDecoratorMeta;
|
|
897
|
+
}>;
|
|
898
|
+
/**
|
|
899
|
+
* Injections defined on the component per handler
|
|
900
|
+
*/
|
|
901
|
+
[A_TYPES__EntityMetaKey.INJECTIONS]: A_Meta<{
|
|
902
|
+
/**
|
|
903
|
+
* Where Key is the name of the injection
|
|
904
|
+
*
|
|
905
|
+
* Where value is the list of injections
|
|
906
|
+
*/
|
|
907
|
+
[Key: string]: A_TYPES__A_InjectDecorator_Meta;
|
|
908
|
+
}>;
|
|
909
|
+
};
|
|
910
|
+
|
|
911
|
+
/**
|
|
912
|
+
* A_Entity is another abstraction that describes all major participants in the system business logic.
|
|
913
|
+
* Each Entity should have a clear definition and a clear set of responsibilities.
|
|
914
|
+
* However, entity may hide some of its responsibilities behind the interface to prevent overload.
|
|
915
|
+
*
|
|
916
|
+
* Each entity should be connected to the ContextFragment (Scope) and should be able to communicate with other entities.
|
|
917
|
+
*/
|
|
918
|
+
declare class A_Entity<_ConstructorType extends A_TYPES__Entity_Init = A_TYPES__Entity_Init, _SerializedType extends A_TYPES__Entity_Serialized = A_TYPES__Entity_Serialized> implements A_TYPES__IEntity {
|
|
919
|
+
/**
|
|
920
|
+
* Entity Identifier that corresponds to the class name
|
|
921
|
+
*/
|
|
922
|
+
static get entity(): string;
|
|
923
|
+
/**
|
|
924
|
+
* DEFAULT Concept Name (Application Name) of the entity from environment variable A_CONCEPT_NAME
|
|
925
|
+
* [!] If environment variable is not set, it will default to 'a-concept'
|
|
926
|
+
*/
|
|
927
|
+
static get concept(): string;
|
|
928
|
+
/**
|
|
929
|
+
* DEFAULT Scope of the entity from environment variable A_CONCEPT_DEFAULT_SCOPE
|
|
930
|
+
* [!] If environment variable is not set, it will default to 'core'
|
|
931
|
+
* [!] Scope is an application specific identifier that can be used to group entities together
|
|
932
|
+
* [!] e.g. 'default', 'core', 'public', 'internal', etc
|
|
933
|
+
*/
|
|
934
|
+
static get scope(): string;
|
|
935
|
+
/**
|
|
936
|
+
* ASEID is an entity identifier that is unique across the system
|
|
937
|
+
* A - A_Concept or Application
|
|
938
|
+
* S - System or Scope
|
|
939
|
+
* E - Entity
|
|
940
|
+
* ID - Identifier
|
|
941
|
+
*
|
|
942
|
+
* [!] ASEID is immutable and should not be changed after the entity is created
|
|
943
|
+
*
|
|
944
|
+
* [!] ASEID is composed of the following parts:
|
|
945
|
+
* - concept: an application specific identifier from where the entity is coming from
|
|
946
|
+
* - scope: the scope of the entity from concept
|
|
947
|
+
* - entity: the name of the entity from concept
|
|
948
|
+
* - id: the unique identifier of the entity
|
|
949
|
+
*
|
|
950
|
+
* [!] For more information about ASEID, please refer to the ASEID class documentation]
|
|
951
|
+
*/
|
|
952
|
+
aseid: ASEID;
|
|
953
|
+
/**
|
|
954
|
+
* Create a new A_entity instance from Aseid String
|
|
955
|
+
* e.g. project@scope:entity:0000000001
|
|
956
|
+
*
|
|
957
|
+
* @param aseid
|
|
958
|
+
*/
|
|
959
|
+
constructor(
|
|
960
|
+
/**
|
|
961
|
+
* ASEID string that represents the entity
|
|
962
|
+
*/
|
|
963
|
+
aseid?: string);
|
|
964
|
+
/**
|
|
965
|
+
* Create a new A_entity instance from Aseid instance
|
|
966
|
+
* e.g. new ASEID({concept: 'project', scope: 'default', entity: 'entity', id: '0000000001'})
|
|
967
|
+
*
|
|
968
|
+
* @param aseid
|
|
969
|
+
*/
|
|
970
|
+
constructor(
|
|
971
|
+
/**
|
|
972
|
+
* ASEID instance that represents the entity
|
|
973
|
+
*/
|
|
974
|
+
aseid: ASEID);
|
|
975
|
+
/**
|
|
976
|
+
* Create a new A_entity instance from serialized object
|
|
977
|
+
*
|
|
978
|
+
* @param serialized
|
|
979
|
+
*/
|
|
980
|
+
constructor(
|
|
981
|
+
/**
|
|
982
|
+
* Serialized object that represents the entity
|
|
983
|
+
*/
|
|
984
|
+
serialized: _SerializedType);
|
|
985
|
+
/**
|
|
986
|
+
* Create a new A_entity instance from constructor object
|
|
987
|
+
*
|
|
988
|
+
* @param newEntity
|
|
989
|
+
*/
|
|
990
|
+
constructor(
|
|
991
|
+
/**
|
|
992
|
+
* Constructor object that represents the entity
|
|
993
|
+
*/
|
|
994
|
+
newEntity?: _ConstructorType);
|
|
995
|
+
/**
|
|
996
|
+
* Extracts the ID from the ASEID
|
|
997
|
+
* ID is the unique identifier of the entity
|
|
998
|
+
*/
|
|
999
|
+
get id(): string | number;
|
|
1000
|
+
protected isStringASEID(x: unknown): x is string;
|
|
1001
|
+
protected isASEIDInstance(x: unknown): x is ASEID;
|
|
1002
|
+
/**
|
|
1003
|
+
* A "serialized" object is considered such if it is a non-null object
|
|
1004
|
+
* and contains an "aseid" property (this mirrors your original check).
|
|
1005
|
+
*
|
|
1006
|
+
* @param x
|
|
1007
|
+
* @returns
|
|
1008
|
+
*/
|
|
1009
|
+
protected isSerializedObject(x: unknown): x is _SerializedType;
|
|
1010
|
+
/**
|
|
1011
|
+
* Constructor-style props = a plain object which does NOT contain "aseid".
|
|
1012
|
+
* This is the "create from provided fields" case.
|
|
1013
|
+
*
|
|
1014
|
+
* @param x
|
|
1015
|
+
* @returns
|
|
1016
|
+
*/
|
|
1017
|
+
protected isConstructorProps(x: unknown): x is _ConstructorType;
|
|
1018
|
+
/**
|
|
1019
|
+
* Determines the appropriate initializer method based on the type of `props`.
|
|
1020
|
+
* The method checks if `props` is:
|
|
1021
|
+
* 1) a string that matches ASEID format -> fromASEID
|
|
1022
|
+
* 2) an ASEID instance -> fromASEID
|
|
1023
|
+
* 3) a serialized object (has 'aseid') -> fromJSON
|
|
1024
|
+
* 4) a plain object with no 'aseid' -> treat as constructor props -> fromNew
|
|
1025
|
+
*
|
|
1026
|
+
* [!] If `props` is undefined, it will call fromUndefined method
|
|
1027
|
+
*
|
|
1028
|
+
* If none of the above, it throws an error indicating incorrect constructor usage.
|
|
1029
|
+
*
|
|
1030
|
+
*
|
|
1031
|
+
* To get a custom initializer, override this method in the child class.
|
|
1032
|
+
* Example:
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* protected getInitializer(
|
|
1035
|
+
* props?: string | ASEID | _SerializedType | _ConstructorType
|
|
1036
|
+
* ): (props: any) => void | (() => void) {
|
|
1037
|
+
* if('customField' in props) {
|
|
1038
|
+
* return this.fromCustomField.bind(this);
|
|
1039
|
+
* }
|
|
1040
|
+
* return super.getInitializer(props);
|
|
1041
|
+
* }
|
|
1042
|
+
* ```
|
|
1043
|
+
* @param props
|
|
1044
|
+
* @returns The appropriate initializer method
|
|
1045
|
+
*/
|
|
1046
|
+
protected getInitializer(props?: string | ASEID | _SerializedType | _ConstructorType): (props: any) => void | (() => void);
|
|
1047
|
+
/**
|
|
1048
|
+
* Generates a new ASEID for the entity.
|
|
1049
|
+
* It uses class definitions for concept, scope, and entity,
|
|
1050
|
+
* and allows overriding any of these values.
|
|
1051
|
+
*
|
|
1052
|
+
* @param override
|
|
1053
|
+
* @returns
|
|
1054
|
+
*/
|
|
1055
|
+
protected generateASEID(override?: Partial<A_TYPES__ASEID_Constructor>): ASEID;
|
|
1056
|
+
/**
|
|
1057
|
+
* Call a feature of the component with the provided scope
|
|
1058
|
+
*
|
|
1059
|
+
* [!] If the provided scope is not inherited from the entity scope, it will be inherited
|
|
1060
|
+
*
|
|
1061
|
+
* @param lifecycleMethod
|
|
1062
|
+
* @param args
|
|
1063
|
+
*/
|
|
1064
|
+
call(feature: string, scope?: A_Scope): any;
|
|
1065
|
+
/**
|
|
1066
|
+
* The default method that can be called and extended to load entity data.
|
|
1067
|
+
*/
|
|
1068
|
+
load(scope?: A_Scope): Promise<any>;
|
|
1069
|
+
/**
|
|
1070
|
+
* The default method that can be called and extended to destroy entity data.
|
|
1071
|
+
*/
|
|
1072
|
+
destroy(scope?: A_Scope): Promise<any>;
|
|
1073
|
+
/**
|
|
1074
|
+
* The default method that can be called and extended to save entity data.
|
|
1075
|
+
*/
|
|
1076
|
+
save(scope?: A_Scope): Promise<any>;
|
|
1077
|
+
/**
|
|
1078
|
+
* Create a new entity from ASEID string or instance
|
|
1079
|
+
* [!] Executed when the constructor is called with a string or ASEID instance that represents the ASEID
|
|
1080
|
+
* [!] Executes By Default with new A_Entity('aseid-string') or new A_Entity(new ASEID(...)) if getInitializer has not been overridden
|
|
1081
|
+
*
|
|
1082
|
+
* @param aseid
|
|
1083
|
+
*/
|
|
1084
|
+
fromASEID(aseid: string | ASEID): void;
|
|
1085
|
+
/**
|
|
1086
|
+
* Handles the case when no props are provided to the constructor.
|
|
1087
|
+
* This method can be overridden in child classes to set default values or perform specific initialization logic.
|
|
1088
|
+
* By default, it does nothing.
|
|
1089
|
+
*
|
|
1090
|
+
*
|
|
1091
|
+
* @returns
|
|
1092
|
+
*/
|
|
1093
|
+
fromUndefined(): void;
|
|
1094
|
+
/**
|
|
1095
|
+
* Create a new entity from constructor object
|
|
1096
|
+
* [!] Executed when the constructor is called with an object that does not contain "aseid" property
|
|
1097
|
+
* [!] Executes By Default with new A_Entity({}) if getInitializer has not been overridden
|
|
1098
|
+
*
|
|
1099
|
+
* @param newEntity
|
|
1100
|
+
* @returns
|
|
1101
|
+
*/
|
|
1102
|
+
fromNew(newEntity: _ConstructorType): void;
|
|
1103
|
+
/**
|
|
1104
|
+
* Creates a new entity from serialized object
|
|
1105
|
+
*
|
|
1106
|
+
* [!] Executed when the constructor is called with an object that contains "aseid" property
|
|
1107
|
+
* [!] Executes By Default with new A_Entity({ aseid: '...' }) if getInitializer has not been overridden
|
|
1108
|
+
*
|
|
1109
|
+
*
|
|
1110
|
+
* @param serialized
|
|
1111
|
+
* @returns
|
|
1112
|
+
*/
|
|
1113
|
+
fromJSON(serialized: _SerializedType): void;
|
|
1114
|
+
/**
|
|
1115
|
+
* Converts the entity to a JSON object
|
|
1116
|
+
* [!] This method should be extended in the child classes to include all properties of the entity
|
|
1117
|
+
* [!] Includes aseid by default
|
|
1118
|
+
*
|
|
1119
|
+
*
|
|
1120
|
+
* @returns
|
|
1121
|
+
*/
|
|
1122
|
+
toJSON(): _SerializedType;
|
|
1123
|
+
/**
|
|
1124
|
+
* Returns the string representation of the entity
|
|
1125
|
+
* what is basically the ASEID string
|
|
1126
|
+
*
|
|
1127
|
+
* @returns
|
|
1128
|
+
*/
|
|
1129
|
+
toString(): string;
|
|
1130
|
+
}
|
|
1131
|
+
|
|
1132
|
+
declare class A_EntityMeta extends A_Meta<A_TYPES__EntityMeta> {
|
|
1133
|
+
/**
|
|
1134
|
+
* Returns all features defined in the Container
|
|
1135
|
+
*
|
|
1136
|
+
* @returns
|
|
1137
|
+
*/
|
|
1138
|
+
features(): Array<A_TYPES__FeatureDefineDecoratorMeta>;
|
|
1139
|
+
/**
|
|
1140
|
+
* Allows to get all the injections for a given handler
|
|
1141
|
+
*
|
|
1142
|
+
* @param handler
|
|
1143
|
+
* @returns
|
|
1144
|
+
*/
|
|
1145
|
+
injections(handler: string): A_TYPES__A_InjectDecorator_Meta;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
declare class A_EntityError extends A_Error {
|
|
1149
|
+
/**
|
|
1150
|
+
* Error code for validation errors.
|
|
1151
|
+
*/
|
|
1152
|
+
static readonly ValidationError = "A-Entity Validation Error";
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
declare enum A_TYPES__A_Stage_Status {
|
|
1156
|
+
/**
|
|
1157
|
+
* The stage is currently being processed
|
|
1158
|
+
*/
|
|
1159
|
+
PROCESSING = "PROCESSING",
|
|
1160
|
+
/**
|
|
1161
|
+
* The stage has been completed
|
|
1162
|
+
*/
|
|
1163
|
+
COMPLETED = "COMPLETED",
|
|
1164
|
+
/**
|
|
1165
|
+
* The stage has failed
|
|
1166
|
+
*/
|
|
1167
|
+
FAILED = "FAILED",
|
|
1168
|
+
/**
|
|
1169
|
+
* The stage has been skipped
|
|
1170
|
+
*/
|
|
1171
|
+
SKIPPED = "SKIPPED",
|
|
1172
|
+
/**
|
|
1173
|
+
* The stage has been paused
|
|
1174
|
+
*/
|
|
1175
|
+
/**
|
|
1176
|
+
* The stage has been stopped
|
|
1177
|
+
*/
|
|
1178
|
+
/**
|
|
1179
|
+
* The stage has been started
|
|
1180
|
+
*/
|
|
1181
|
+
/**
|
|
1182
|
+
* The stage has been initialized
|
|
1183
|
+
*/
|
|
1184
|
+
INITIALIZED = "INITIALIZED",
|
|
1185
|
+
/**
|
|
1186
|
+
* The stage has been aborted
|
|
1187
|
+
*/
|
|
1188
|
+
ABORTED = "ABORTED"
|
|
1189
|
+
}
|
|
1190
|
+
type A_TYPES_StageExecutionBehavior = 'async' | 'sync';
|
|
1191
|
+
type A_TYPES__A_StageStep = {
|
|
1192
|
+
/**
|
|
1193
|
+
* The component to be called
|
|
1194
|
+
*/
|
|
1195
|
+
dependency: A_Dependency;
|
|
1196
|
+
/**
|
|
1197
|
+
* The method to be called on the component
|
|
1198
|
+
*/
|
|
1199
|
+
handler: string;
|
|
1200
|
+
/**
|
|
1201
|
+
* Original Feature Extension name
|
|
1202
|
+
*
|
|
1203
|
+
* [!] could be string or regex
|
|
1204
|
+
*
|
|
1205
|
+
*/
|
|
1206
|
+
name: string;
|
|
1207
|
+
/**
|
|
1208
|
+
* In case its async it will be executed independently from the main thread.
|
|
1209
|
+
*
|
|
1210
|
+
* [!] However, in case of sync, it will be executed in the main thread.in the order of the declaration.
|
|
1211
|
+
*
|
|
1212
|
+
*/
|
|
1213
|
+
behavior: A_TYPES_StageExecutionBehavior;
|
|
1214
|
+
/**
|
|
1215
|
+
* Allows to define the order of the execution of the method.
|
|
1216
|
+
*
|
|
1217
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
1218
|
+
*
|
|
1219
|
+
*/
|
|
1220
|
+
before: string;
|
|
1221
|
+
/**
|
|
1222
|
+
* Allows to define the order of the execution of the method.
|
|
1223
|
+
*
|
|
1224
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
1225
|
+
*
|
|
1226
|
+
*/
|
|
1227
|
+
after: string;
|
|
1228
|
+
/**
|
|
1229
|
+
* Indicates whether to throw an error if the step fails.
|
|
1230
|
+
*
|
|
1231
|
+
* [!] By default is true
|
|
1232
|
+
*/
|
|
1233
|
+
throwOnError: boolean;
|
|
1234
|
+
/**
|
|
1235
|
+
*
|
|
1236
|
+
*/
|
|
1237
|
+
override: string;
|
|
1238
|
+
};
|
|
1239
|
+
type A_TYPES__Stage_Serialized = {
|
|
1240
|
+
/**
|
|
1241
|
+
* The name of the stage
|
|
1242
|
+
*/
|
|
1243
|
+
name: string;
|
|
1244
|
+
/**
|
|
1245
|
+
* The status of the stage
|
|
1246
|
+
*
|
|
1247
|
+
*/
|
|
1248
|
+
status: A_TYPES__A_Stage_Status;
|
|
1249
|
+
};
|
|
1250
|
+
type A_TYPES__A_StageStepProcessingExtraParams = {
|
|
1251
|
+
steps: A_TYPES__A_StageStep[];
|
|
1252
|
+
filter: (step: A_TYPES__A_StageStep) => boolean;
|
|
1253
|
+
};
|
|
1254
|
+
|
|
1255
|
+
declare class A_Stage {
|
|
1256
|
+
/**
|
|
1257
|
+
* The feature that owns this stage
|
|
1258
|
+
*/
|
|
1259
|
+
private readonly _feature;
|
|
1260
|
+
/**
|
|
1261
|
+
* Initial Instructions to process the stage
|
|
1262
|
+
*/
|
|
1263
|
+
private readonly _definition;
|
|
1264
|
+
/**
|
|
1265
|
+
* Possible errors during stage processing
|
|
1266
|
+
*/
|
|
1267
|
+
private _error?;
|
|
1268
|
+
/**
|
|
1269
|
+
* Indicates the current status of the stage
|
|
1270
|
+
*/
|
|
1271
|
+
private _status;
|
|
1272
|
+
/**
|
|
1273
|
+
* A_Stage is a callable A_Function within A_Feature that should be run with specific parameters.
|
|
1274
|
+
* [!] Depending on the Stage Definition type sync/async function can be executed correspondingly.
|
|
1275
|
+
*
|
|
1276
|
+
* A-Stage is a common object that uses to simplify logic and re-use of A-Feature internals for better composition.
|
|
1277
|
+
*/
|
|
1278
|
+
constructor(
|
|
1279
|
+
/**
|
|
1280
|
+
* The feature that owns this stage
|
|
1281
|
+
*/
|
|
1282
|
+
feature: A_Feature,
|
|
1283
|
+
/**
|
|
1284
|
+
* The step definitions of the stage
|
|
1285
|
+
*/
|
|
1286
|
+
step: A_TYPES__A_StageStep);
|
|
1287
|
+
/**
|
|
1288
|
+
* Returns the name of the stage
|
|
1289
|
+
*/
|
|
1290
|
+
get name(): string;
|
|
1291
|
+
/**
|
|
1292
|
+
* Returns the definition of the stage
|
|
1293
|
+
*/
|
|
1294
|
+
get definition(): A_TYPES__A_StageStep;
|
|
1295
|
+
/**
|
|
1296
|
+
* Returns the current status of the stage
|
|
1297
|
+
*/
|
|
1298
|
+
get status(): A_TYPES__A_Stage_Status;
|
|
1299
|
+
/**
|
|
1300
|
+
* Returns the feature that owns this stage
|
|
1301
|
+
*/
|
|
1302
|
+
get feature(): A_Feature;
|
|
1303
|
+
/**
|
|
1304
|
+
* Returns true if the stage is processed (completed, failed, or skipped)
|
|
1305
|
+
*/
|
|
1306
|
+
get isProcessed(): boolean;
|
|
1307
|
+
/**
|
|
1308
|
+
* Returns the error of the stage
|
|
1309
|
+
*/
|
|
1310
|
+
get error(): A_Error | undefined;
|
|
1311
|
+
/**
|
|
1312
|
+
* Resolves the arguments of the step
|
|
1313
|
+
*
|
|
1314
|
+
* @param step
|
|
1315
|
+
* @returns
|
|
1316
|
+
*/
|
|
1317
|
+
protected getStepArgs(scope: A_Scope, step: A_TYPES__A_StageStep): (A_Component | A_Container | A_Entity<any, A_TYPES__Entity_Serialized> | A_Fragment<A_TYPES__Fragment_Serialized> | A_Feature<A_TYPES__FeatureAvailableComponents> | A_Caller<A_TYPES__FeatureAvailableComponents> | A_Error<A_TYPES__Error_Init, A_TYPES__Error_Serialized> | A_Scope<any, A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<A_TYPES__Fragment_Serialized>[]> | A_TYPES__A_DependencyInjectable[] | undefined)[];
|
|
1318
|
+
/**
|
|
1319
|
+
* Resolves the component of the step
|
|
1320
|
+
*
|
|
1321
|
+
* @param step
|
|
1322
|
+
* @returns
|
|
1323
|
+
*/
|
|
1324
|
+
protected getStepComponent(scope: A_Scope, step: A_TYPES__A_StageStep): A_TYPES__A_DependencyInjectable;
|
|
1325
|
+
/**
|
|
1326
|
+
* Calls the handler of the step
|
|
1327
|
+
*
|
|
1328
|
+
* @param step
|
|
1329
|
+
* @returns
|
|
1330
|
+
*/
|
|
1331
|
+
protected callStepHandler(step: A_TYPES__A_StageStep, scope: A_Scope): {
|
|
1332
|
+
handler: Function;
|
|
1333
|
+
params: any[];
|
|
1334
|
+
};
|
|
1335
|
+
skip(): void;
|
|
1336
|
+
/**
|
|
1337
|
+
* This method processes the stage by executing all the steps
|
|
1338
|
+
*
|
|
1339
|
+
* @param scope - Scope to be used to resolve the steps dependencies
|
|
1340
|
+
*/
|
|
1341
|
+
process(
|
|
1342
|
+
/**
|
|
1343
|
+
* Scope to be used to resolve the steps dependencies
|
|
1344
|
+
*/
|
|
1345
|
+
scope?: A_Scope): Promise<void> | void;
|
|
1346
|
+
protected completed(): void;
|
|
1347
|
+
protected failed(error: Error | A_Error | any): void;
|
|
1348
|
+
/**
|
|
1349
|
+
* Serializes the stage to JSON
|
|
1350
|
+
*
|
|
1351
|
+
*/
|
|
1352
|
+
toJSON(): A_TYPES__Stage_Serialized;
|
|
1353
|
+
/**
|
|
1354
|
+
* Returns a string representation of the stage
|
|
1355
|
+
*
|
|
1356
|
+
* @returns
|
|
1357
|
+
*/
|
|
1358
|
+
toString(): string;
|
|
1359
|
+
}
|
|
1360
|
+
|
|
1361
|
+
declare class A_StageError extends A_Error {
|
|
1362
|
+
static readonly ArgumentsResolutionError = "A-Stage Arguments Resolution Error";
|
|
1363
|
+
static get CompileError(): string;
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
/**
|
|
1367
|
+
* Feature constructor type
|
|
1368
|
+
* Uses the generic type T to specify the type of the feature
|
|
1369
|
+
*/
|
|
1370
|
+
type A_TYPES__Feature_Constructor<T = A_Feature> = A_TYPES__Ctor<T>;
|
|
1371
|
+
/**
|
|
1372
|
+
* Feature initialization type
|
|
1373
|
+
*/
|
|
1374
|
+
type A_TYPES__Feature_Init<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__FeatureAvailableComponents> = A_TYPES__Feature_InitWithComponent<T> | A_TYPES__Feature_InitWithTemplate<T>;
|
|
1375
|
+
/**
|
|
1376
|
+
* Feature initialization type using component
|
|
1377
|
+
*/
|
|
1378
|
+
type A_TYPES__Feature_InitWithComponent<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__FeatureAvailableComponents> = {
|
|
1379
|
+
/**
|
|
1380
|
+
* Feature Name
|
|
1381
|
+
*/
|
|
1382
|
+
name: string;
|
|
1383
|
+
/**
|
|
1384
|
+
* The component from where the feature is calling. It's important for proper scoping.
|
|
1385
|
+
* Based on the component would be retrieved connected components, entities and containers.
|
|
1386
|
+
*
|
|
1387
|
+
* [!] Could be Container, Entity, Component or Command
|
|
1388
|
+
*/
|
|
1389
|
+
component: T;
|
|
1390
|
+
/**
|
|
1391
|
+
* In case when Entity is not attached to the scope can be used to transparently show dependencies
|
|
1392
|
+
*
|
|
1393
|
+
*
|
|
1394
|
+
*/
|
|
1395
|
+
scope?: A_Scope;
|
|
1396
|
+
};
|
|
1397
|
+
/**
|
|
1398
|
+
* Feature initialization type using template
|
|
1399
|
+
*/
|
|
1400
|
+
type A_TYPES__Feature_InitWithTemplate<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__FeatureAvailableComponents> = {
|
|
1401
|
+
/**
|
|
1402
|
+
* Feature Name
|
|
1403
|
+
*/
|
|
1404
|
+
name: string;
|
|
1405
|
+
/**
|
|
1406
|
+
* The scope from where to retrieve dependent components, entities and containers.
|
|
1407
|
+
*
|
|
1408
|
+
* [!] Important for proper scoping.
|
|
1409
|
+
*/
|
|
1410
|
+
scope: A_Scope;
|
|
1411
|
+
/**
|
|
1412
|
+
* The component from where the feature is calling. It's important for proper scoping.
|
|
1413
|
+
* Based on the component would be retrieved connected components, entities and containers.
|
|
1414
|
+
*
|
|
1415
|
+
* [!] Could be Container, Entity, Component or Command
|
|
1416
|
+
*/
|
|
1417
|
+
component?: T;
|
|
1418
|
+
/**
|
|
1419
|
+
* Optional Feature template to be used instead of building it from decorators
|
|
1420
|
+
*/
|
|
1421
|
+
template: Array<A_TYPES__FeatureDefineDecoratorTemplateItem>;
|
|
1422
|
+
};
|
|
1423
|
+
/**
|
|
1424
|
+
* Feature serialized type
|
|
1425
|
+
*/
|
|
1426
|
+
type A_TYPES__Feature_Serialized = {};
|
|
1427
|
+
/**
|
|
1428
|
+
* Feature lifecycle states
|
|
1429
|
+
*/
|
|
1430
|
+
declare enum A_TYPES__FeatureState {
|
|
1431
|
+
/**
|
|
1432
|
+
* The feature has been initialized
|
|
1433
|
+
*/
|
|
1434
|
+
INITIALIZED = "INITIALIZED",
|
|
1435
|
+
/**
|
|
1436
|
+
* The feature is currently being processed
|
|
1437
|
+
*/
|
|
1438
|
+
PROCESSING = "PROCESSING",
|
|
1439
|
+
/**
|
|
1440
|
+
* The feature has been completed
|
|
1441
|
+
*/
|
|
1442
|
+
COMPLETED = "COMPLETED",
|
|
1443
|
+
/**
|
|
1444
|
+
* The feature has been interrupted
|
|
1445
|
+
*/
|
|
1446
|
+
INTERRUPTED = "INTERRUPTED",
|
|
1447
|
+
/**
|
|
1448
|
+
* The feature has failed
|
|
1449
|
+
*/
|
|
1450
|
+
FAILED = "FAILED"
|
|
1451
|
+
}
|
|
1452
|
+
type A_TYPES__FeatureError_Init = {
|
|
1453
|
+
/**
|
|
1454
|
+
* Stage where the error occurred
|
|
1455
|
+
*/
|
|
1456
|
+
stage?: A_Stage;
|
|
1457
|
+
} & A_TYPES__Error_Init;
|
|
1458
|
+
/**
|
|
1459
|
+
* A list of component where features can be Defined
|
|
1460
|
+
*
|
|
1461
|
+
* [!] On this component Feature Definition is Available
|
|
1462
|
+
*/
|
|
1463
|
+
type A_TYPES__FeatureAvailableComponents = InstanceType<A_TYPES__FeatureAvailableConstructors>;
|
|
1464
|
+
/**
|
|
1465
|
+
* A list of constructors where features can be Defined
|
|
1466
|
+
*
|
|
1467
|
+
* [!] On this component Feature Definition is Available
|
|
1468
|
+
*/
|
|
1469
|
+
type A_TYPES__FeatureAvailableConstructors = A_TYPES__Component_Constructor | A_TYPES__Entity_Constructor | A_TYPES__Container_Constructor;
|
|
1470
|
+
/**
|
|
1471
|
+
* Indicates a type of Feature Define decorator
|
|
1472
|
+
*/
|
|
1473
|
+
type A_TYPES__FeatureDefineDecoratorDescriptor = TypedPropertyDescriptor<(...args: any[]) => any> | TypedPropertyDescriptor<(...args: any[]) => any> | TypedPropertyDescriptor<(...args: any[]) => Promise<any>> | TypedPropertyDescriptor<(...args: any[]) => Promise<any>>;
|
|
1474
|
+
/**
|
|
1475
|
+
* Describes additional configuration properties to be used in Feature Define decorator
|
|
1476
|
+
*/
|
|
1477
|
+
type A_TYPES__FeatureDefineDecoratorConfig = {
|
|
1478
|
+
/**
|
|
1479
|
+
* Feature name
|
|
1480
|
+
*
|
|
1481
|
+
* [!] By default uses the method name
|
|
1482
|
+
*/
|
|
1483
|
+
name: string;
|
|
1484
|
+
/**
|
|
1485
|
+
* Indicates a default behavior of the feature. If true the feature will be automatically attached to the execution.
|
|
1486
|
+
*
|
|
1487
|
+
* [!] Before feature execution the method itself will be called to prepare the feature template
|
|
1488
|
+
* [!] Default is false
|
|
1489
|
+
*/
|
|
1490
|
+
invoke: boolean;
|
|
1491
|
+
/**
|
|
1492
|
+
* Allows to add a default behavior or number of steps that will be part of the feature
|
|
1493
|
+
*/
|
|
1494
|
+
template: Array<A_TYPES__FeatureDefineDecoratorTemplateItem>;
|
|
1495
|
+
};
|
|
1496
|
+
/**
|
|
1497
|
+
* Describes a single template item used in Feature Define decorator
|
|
1498
|
+
*/
|
|
1499
|
+
type A_TYPES__FeatureDefineDecoratorTemplateItem = A_TYPES__Required<Partial<A_TYPES__A_StageStep>, ['name', 'handler', 'dependency']>;
|
|
1500
|
+
/**
|
|
1501
|
+
* Describes a target where Feature Define decorator can be applied
|
|
1502
|
+
*
|
|
1503
|
+
* [!] The feature can be defined on Container, Entity, Component or Command
|
|
1504
|
+
*/
|
|
1505
|
+
type A_TYPES__FeatureDefineDecoratorTarget = A_Container | A_Entity | A_Component;
|
|
1506
|
+
/**
|
|
1507
|
+
* A type of Meta information stored by Feature Define decorator
|
|
1508
|
+
* This information then uses by A-Context to build a proper feature template
|
|
1509
|
+
*/
|
|
1510
|
+
type A_TYPES__FeatureDefineDecoratorMeta = {
|
|
1511
|
+
/**
|
|
1512
|
+
* Feature name
|
|
1513
|
+
* mainly it's a unique combination of the class name and method name
|
|
1514
|
+
*/
|
|
1515
|
+
name: string;
|
|
1516
|
+
/**
|
|
1517
|
+
* Actual method name in the class
|
|
1518
|
+
*/
|
|
1519
|
+
handler: string;
|
|
1520
|
+
/**
|
|
1521
|
+
* Indicates a default behavior of the feature. If true the feature will be automatically attached to the execution.
|
|
1522
|
+
*
|
|
1523
|
+
* [!] Before feature execution the method itself will be called to prepare the feature template
|
|
1524
|
+
* [!] Default is false
|
|
1525
|
+
*/
|
|
1526
|
+
invoke: boolean;
|
|
1527
|
+
/**
|
|
1528
|
+
* Allows to add a default behavior or number of steps that will be part of the feature
|
|
1529
|
+
*/
|
|
1530
|
+
template: Array<A_TYPES__A_StageStep>;
|
|
1531
|
+
};
|
|
1532
|
+
/**
|
|
1533
|
+
* Descriptor type for A_Extend decorator
|
|
1534
|
+
*/
|
|
1535
|
+
type A_TYPES__FeatureExtendDecoratorDescriptor = TypedPropertyDescriptor<() => any> | TypedPropertyDescriptor<(...args: any[]) => any> | TypedPropertyDescriptor<(...args: any[]) => Promise<any>> | TypedPropertyDescriptor<() => Promise<any>>;
|
|
1536
|
+
/**
|
|
1537
|
+
* Target type for A_Extend decorator
|
|
1538
|
+
*
|
|
1539
|
+
* [!] Can be applied only on A-Components
|
|
1540
|
+
*/
|
|
1541
|
+
type A_TYPES__FeatureExtendDecoratorTarget = A_Component | A_Container | A_Entity;
|
|
1542
|
+
/**
|
|
1543
|
+
* Configuration type for A_Extend decorator
|
|
1544
|
+
*
|
|
1545
|
+
* This is an INPUT parameter provided by the user
|
|
1546
|
+
*/
|
|
1547
|
+
type A_TYPES__FeatureExtendDecoratorConfig = {
|
|
1548
|
+
/**
|
|
1549
|
+
* Name of the container Lifecycle method to be extended.
|
|
1550
|
+
*
|
|
1551
|
+
* [!] If not provided will be used the name of the method.
|
|
1552
|
+
* [!!] If name contains "." dot it will be considered as a path to the method.
|
|
1553
|
+
*/
|
|
1554
|
+
name: string;
|
|
1555
|
+
/**
|
|
1556
|
+
* Container class or container name uses to identify the proper container in case when the name is not unique.
|
|
1557
|
+
*
|
|
1558
|
+
* [!] If not provided will be applied to all containers with the same name.
|
|
1559
|
+
* [!!] By default uses OR to join all provided items. If you need more complex Logic, please use Regexp instead
|
|
1560
|
+
*
|
|
1561
|
+
* [!!!] In case if you need to exclude some containers, entities or components, please use "exclude" property
|
|
1562
|
+
*
|
|
1563
|
+
* Example:
|
|
1564
|
+
*
|
|
1565
|
+
* ```ts
|
|
1566
|
+
* @A_Feature.Extend({
|
|
1567
|
+
* name: 'load',
|
|
1568
|
+
* scope: {
|
|
1569
|
+
* include: [A_Container1, A_Entity1],
|
|
1570
|
+
* exclude: [A_Component1]
|
|
1571
|
+
* }
|
|
1572
|
+
* })
|
|
1573
|
+
* ```
|
|
1574
|
+
*/
|
|
1575
|
+
scope: Array<A_TYPES__FeatureExtendDecoratorScopeItem> | Partial<A_TYPES__FeatureExtendDecoratorScopeConfig>;
|
|
1576
|
+
/**
|
|
1577
|
+
* The behavior of the method.
|
|
1578
|
+
* In case its async it will be executed independently from the main thread.
|
|
1579
|
+
*
|
|
1580
|
+
* [!] However, in case of sync, it will be executed in the main thread.in the order of the declaration.
|
|
1581
|
+
*
|
|
1582
|
+
*/
|
|
1583
|
+
behavior: A_TYPES_StageExecutionBehavior;
|
|
1584
|
+
/**
|
|
1585
|
+
* Allows to define the order of the execution of the method.
|
|
1586
|
+
*
|
|
1587
|
+
* [!] It applies for the following structure :'Component.methodName'
|
|
1588
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
1589
|
+
*
|
|
1590
|
+
* Example:
|
|
1591
|
+
* ```ts
|
|
1592
|
+
* @A_Feature.Extend({
|
|
1593
|
+
* name: 'load',
|
|
1594
|
+
* before: ['Component1.methodName', 'Component2.methodName2']
|
|
1595
|
+
* })
|
|
1596
|
+
* // OR
|
|
1597
|
+
* @A_Feature.Extend({
|
|
1598
|
+
* name: 'load',
|
|
1599
|
+
* before: /Component2\..+/
|
|
1600
|
+
* })
|
|
1601
|
+
* ```
|
|
1602
|
+
*/
|
|
1603
|
+
before: Array<string> | RegExp;
|
|
1604
|
+
/**
|
|
1605
|
+
* Allows to define the order of the execution of the method.
|
|
1606
|
+
*
|
|
1607
|
+
* [!] It applies for the following structure :'Component.methodName'
|
|
1608
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
1609
|
+
*
|
|
1610
|
+
* Example:
|
|
1611
|
+
* ```ts
|
|
1612
|
+
* @A_Feature.Extend({
|
|
1613
|
+
* name: 'load',
|
|
1614
|
+
* after: ['Component1.methodName', 'Component2.methodName2']
|
|
1615
|
+
* })
|
|
1616
|
+
* // OR
|
|
1617
|
+
* @A_Feature.Extend({
|
|
1618
|
+
* name: 'load',
|
|
1619
|
+
* after: /Component2\..+/
|
|
1620
|
+
* })
|
|
1621
|
+
* ```
|
|
1622
|
+
*
|
|
1623
|
+
*/
|
|
1624
|
+
after: Array<string> | RegExp;
|
|
1625
|
+
/**
|
|
1626
|
+
* Indicates whether to throw an error if the step fails.
|
|
1627
|
+
*
|
|
1628
|
+
* [!] By default is true
|
|
1629
|
+
*/
|
|
1630
|
+
throwOnError: boolean;
|
|
1631
|
+
/**
|
|
1632
|
+
* Allows to override particular steps in the feature sequence by provided names [Component].[Method] or by regexp
|
|
1633
|
+
*/
|
|
1634
|
+
override: Array<string> | RegExp;
|
|
1635
|
+
};
|
|
1636
|
+
/**
|
|
1637
|
+
* Scope item that can be used in A_Extend decorator configuration
|
|
1638
|
+
*/
|
|
1639
|
+
type A_TYPES__FeatureExtendDecoratorScopeConfig = {
|
|
1640
|
+
/**
|
|
1641
|
+
* A list of components, entities or containers to include in the scope of the extension
|
|
1642
|
+
*/
|
|
1643
|
+
include?: Array<A_TYPES__FeatureExtendDecoratorScopeItem>;
|
|
1644
|
+
/**
|
|
1645
|
+
* A list of components, entities or containers to exclude from the scope of the extension
|
|
1646
|
+
*/
|
|
1647
|
+
exclude?: Array<A_TYPES__FeatureExtendDecoratorScopeItem>;
|
|
1648
|
+
};
|
|
1649
|
+
/**
|
|
1650
|
+
* A single item that can be used in scope configuration
|
|
1651
|
+
*/
|
|
1652
|
+
type A_TYPES__FeatureExtendDecoratorScopeItem = A_TYPES__Container_Constructor | A_TYPES__Entity_Constructor | A_TYPES__Component_Constructor;
|
|
1653
|
+
/**
|
|
1654
|
+
* Meta type for A_Extend decorator
|
|
1655
|
+
*/
|
|
1656
|
+
type A_TYPES__FeatureExtendDecoratorMeta = {
|
|
1657
|
+
/**
|
|
1658
|
+
* Original Feature Extension name
|
|
1659
|
+
*
|
|
1660
|
+
* [!] could be string or regex
|
|
1661
|
+
*/
|
|
1662
|
+
name: string;
|
|
1663
|
+
/**
|
|
1664
|
+
* Actual method name in the class
|
|
1665
|
+
*/
|
|
1666
|
+
handler: string;
|
|
1667
|
+
/**
|
|
1668
|
+
* The behavior of the method.
|
|
1669
|
+
* In case its async it will be executed independently from the main thread.
|
|
1670
|
+
*
|
|
1671
|
+
* [!] However, in case of sync, it will be executed in the main thread.in the order of the declaration.
|
|
1672
|
+
*
|
|
1673
|
+
*/
|
|
1674
|
+
behavior: A_TYPES_StageExecutionBehavior;
|
|
1675
|
+
/**
|
|
1676
|
+
* Allows to define the order of the execution of the method.
|
|
1677
|
+
*
|
|
1678
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
1679
|
+
*
|
|
1680
|
+
*/
|
|
1681
|
+
before: string;
|
|
1682
|
+
/**
|
|
1683
|
+
* Allows to define the order of the execution of the method.
|
|
1684
|
+
*
|
|
1685
|
+
* [!] In case the method has circular dependencies it will Throw an error.
|
|
1686
|
+
*
|
|
1687
|
+
*/
|
|
1688
|
+
after: string;
|
|
1689
|
+
/**
|
|
1690
|
+
* Indicates whether to throw an error if the step fails.
|
|
1691
|
+
*
|
|
1692
|
+
* [!] By default is true
|
|
1693
|
+
*/
|
|
1694
|
+
throwOnError: boolean;
|
|
1695
|
+
/**
|
|
1696
|
+
* Allows to override particular steps in the feature sequence by provided names [Component].[Method] or by regexp
|
|
1697
|
+
*/
|
|
1698
|
+
override: string;
|
|
1699
|
+
};
|
|
1700
|
+
|
|
1701
|
+
/**
|
|
1702
|
+
* A-Feature decorator
|
|
1703
|
+
*
|
|
1704
|
+
* This decorator allows to define a custom lifecycle stage for the Container.
|
|
1705
|
+
* These stages are executed in a container-specific order and can be extended by components that are injected into the container.
|
|
1706
|
+
* This approach allows to create a flexible and extendable architecture for the application.
|
|
1707
|
+
*
|
|
1708
|
+
* The main difference between the A-Feature and A-Feature decorators is that A-Feature methods can be inherited and overridden by child classes.
|
|
1709
|
+
*
|
|
1710
|
+
*
|
|
1711
|
+
* @param params
|
|
1712
|
+
* @returns
|
|
1713
|
+
*/
|
|
1714
|
+
declare function A_Feature_Define(config?: Partial<A_TYPES__FeatureDefineDecoratorConfig>): (target: A_TYPES__FeatureDefineDecoratorTarget, propertyKey: string, descriptor: A_TYPES__FeatureDefineDecoratorDescriptor) => A_TYPES__FeatureDefineDecoratorDescriptor;
|
|
1715
|
+
|
|
1716
|
+
/**
|
|
1717
|
+
* A-Extend decorator
|
|
1718
|
+
*
|
|
1719
|
+
* This decorator allows to define a custom Extend stage for the Container.
|
|
1720
|
+
* These stages are executed in a container-specific order and can be extended by components that are injected into the container.
|
|
1721
|
+
* This approach allows to create a flexible and extendable architecture for the application.
|
|
1722
|
+
*
|
|
1723
|
+
* The main difference between the A-Extend and A-Extend decorators is that A-Extend methods can be inherited and overridden by child classes.
|
|
1724
|
+
*
|
|
1725
|
+
*
|
|
1726
|
+
* @param params
|
|
1727
|
+
* @returns
|
|
1728
|
+
*/
|
|
1729
|
+
/**
|
|
1730
|
+
* Use regexp in case if you need more flexibility and control over the name of the method
|
|
1731
|
+
*
|
|
1732
|
+
* @param regexp
|
|
1733
|
+
*/
|
|
1734
|
+
declare function A_Feature_Extend(
|
|
1735
|
+
/**
|
|
1736
|
+
* The regular expression to match the name of the Feature method to be extended
|
|
1737
|
+
*
|
|
1738
|
+
* Example:
|
|
1739
|
+
*
|
|
1740
|
+
* ```ts
|
|
1741
|
+
* @A_Feature.Extend(/.*\.load/)
|
|
1742
|
+
* ```
|
|
1743
|
+
*/
|
|
1744
|
+
regexp: RegExp): any;
|
|
1745
|
+
/**
|
|
1746
|
+
* In this case the name configurations will be used as an input to get scope and name of target function
|
|
1747
|
+
* [!] Not that for all SCOPE will be used OR operator
|
|
1748
|
+
*
|
|
1749
|
+
* @param config
|
|
1750
|
+
*/
|
|
1751
|
+
declare function A_Feature_Extend(
|
|
1752
|
+
/**
|
|
1753
|
+
* Configuration for the A-Feature-Extend decorator
|
|
1754
|
+
*/
|
|
1755
|
+
config: Partial<A_TYPES__FeatureExtendDecoratorConfig>): any;
|
|
1756
|
+
/**
|
|
1757
|
+
* In this case the name of function will be used as a name of the Feature.
|
|
1758
|
+
* [!] AND it will be applicable for ANY element where the name is the same as the name of the function
|
|
1759
|
+
*/
|
|
1760
|
+
declare function A_Feature_Extend(): any;
|
|
1761
|
+
|
|
1762
|
+
declare class A_StepsManager {
|
|
1763
|
+
entities: A_TYPES__A_StageStep[];
|
|
1764
|
+
graph: Map<string, Set<string>>;
|
|
1765
|
+
visited: Set<string>;
|
|
1766
|
+
tempMark: Set<string>;
|
|
1767
|
+
sortedEntities: string[];
|
|
1768
|
+
private _isBuilt;
|
|
1769
|
+
constructor(entities: Array<A_TYPES__FeatureDefineDecoratorTemplateItem>);
|
|
1770
|
+
private prepareSteps;
|
|
1771
|
+
private ID;
|
|
1772
|
+
private buildGraph;
|
|
1773
|
+
private matchEntities;
|
|
1774
|
+
private visit;
|
|
1775
|
+
toSortedArray(): Array<string>;
|
|
1776
|
+
toStages(feature: A_Feature): Array<A_Stage>;
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
declare class A_StepManagerError extends A_Error {
|
|
1780
|
+
static readonly CircularDependencyError = "A-StepManager Circular Dependency Error";
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
declare class A_FeatureError extends A_Error<A_TYPES__FeatureError_Init> {
|
|
1784
|
+
/**
|
|
1785
|
+
* Indicates that the Feature has been interrupted
|
|
1786
|
+
*/
|
|
1787
|
+
static readonly Interruption = "Feature Interrupted";
|
|
1788
|
+
/**
|
|
1789
|
+
* Indicates that there was an error initializing the Feature
|
|
1790
|
+
*
|
|
1791
|
+
* Failed during the A-Feature initialization process
|
|
1792
|
+
*/
|
|
1793
|
+
static readonly FeatureInitializationError = "Unable to initialize A-Feature";
|
|
1794
|
+
/**
|
|
1795
|
+
* Indicates that there was an error processing the Feature
|
|
1796
|
+
*
|
|
1797
|
+
* Failed during the A-Feature processing
|
|
1798
|
+
*/
|
|
1799
|
+
static readonly FeatureProcessingError = "Error occurred during A-Feature processing";
|
|
1800
|
+
/**
|
|
1801
|
+
* Indicates that there was an error defining the Feature
|
|
1802
|
+
*
|
|
1803
|
+
* Failed during the @A_Feature.Define() decorator execution
|
|
1804
|
+
*/
|
|
1805
|
+
static readonly FeatureDefinitionError = "Unable to define A-Feature";
|
|
1806
|
+
/**
|
|
1807
|
+
* Indicates that there was an error extending the Feature
|
|
1808
|
+
*
|
|
1809
|
+
* Failed during the @A_Feature.Extend() decorator execution
|
|
1810
|
+
*/
|
|
1811
|
+
static readonly FeatureExtensionError = "Unable to extend A-Feature";
|
|
1812
|
+
/**
|
|
1813
|
+
* Stage where the error occurred
|
|
1814
|
+
*/
|
|
1815
|
+
stage?: A_Stage;
|
|
1816
|
+
protected fromConstructor(params: A_TYPES__FeatureError_Init): void;
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
/**
|
|
1820
|
+
* A_Feature is representing a feature that can be executed across multiple components
|
|
1821
|
+
* This class stores the steps of the feature and executes them in order of appearance
|
|
1822
|
+
*
|
|
1823
|
+
* Using A_Feature.Define and A_Feature.Extend decorators to define and extend the feature methods
|
|
1824
|
+
* across the different, distributed components
|
|
1825
|
+
*
|
|
1826
|
+
*/
|
|
1827
|
+
declare class A_Feature<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__FeatureAvailableComponents> {
|
|
1828
|
+
/**
|
|
1829
|
+
* Define a new A-Feature
|
|
1830
|
+
*/
|
|
1831
|
+
static get Define(): typeof A_Feature_Define;
|
|
1832
|
+
/**
|
|
1833
|
+
* Extend an existing A-Feature
|
|
1834
|
+
*/
|
|
1835
|
+
static get Extend(): typeof A_Feature_Extend;
|
|
1836
|
+
/**
|
|
1837
|
+
* The name of the Feature
|
|
1838
|
+
*/
|
|
1839
|
+
protected _name: string;
|
|
1840
|
+
/**
|
|
1841
|
+
* List of stages that are part of this Feature
|
|
1842
|
+
*/
|
|
1843
|
+
protected _stages: Array<A_Stage>;
|
|
1844
|
+
/**
|
|
1845
|
+
* The Stage currently being processed
|
|
1846
|
+
*/
|
|
1847
|
+
protected _current?: A_Stage;
|
|
1848
|
+
/**
|
|
1849
|
+
* Actual Index of the current Stage being processed
|
|
1850
|
+
*/
|
|
1851
|
+
protected _index: number;
|
|
1852
|
+
/**
|
|
1853
|
+
* Steps Manager to organize the steps into stages
|
|
1854
|
+
*/
|
|
1855
|
+
protected _SM: A_StepsManager;
|
|
1856
|
+
/**
|
|
1857
|
+
* The Caller that initiated the Feature call
|
|
1858
|
+
*/
|
|
1859
|
+
protected _caller: A_Caller<T>;
|
|
1860
|
+
/**
|
|
1861
|
+
* The current state of the Feature
|
|
1862
|
+
*/
|
|
1863
|
+
protected _state: A_TYPES__FeatureState;
|
|
1864
|
+
/**
|
|
1865
|
+
* The error that caused the Feature to be interrupted
|
|
1866
|
+
*/
|
|
1867
|
+
protected _error?: A_FeatureError;
|
|
1868
|
+
/**
|
|
1869
|
+
* A-Feature is a pipeline distributed by multiple components that can be easily attached or detached from the scope.
|
|
1870
|
+
* Feature itself does not have scope, but attached to the caller who dictates how feature should be processed.
|
|
1871
|
+
*
|
|
1872
|
+
* Comparing to A-Command Feature does not store any state except statuses for better analysis.
|
|
1873
|
+
*
|
|
1874
|
+
* [!] Note: If A-Feature should have result use A-Fragment
|
|
1875
|
+
*
|
|
1876
|
+
* @param params
|
|
1877
|
+
*/
|
|
1878
|
+
constructor(
|
|
1879
|
+
/**
|
|
1880
|
+
* Feature Initialization parameters
|
|
1881
|
+
*/
|
|
1882
|
+
params: A_TYPES__Feature_Init<T>);
|
|
1883
|
+
/**
|
|
1884
|
+
* The name of the Feature
|
|
1885
|
+
*/
|
|
1886
|
+
get name(): string;
|
|
1887
|
+
/**
|
|
1888
|
+
* The error that caused the Feature to be interrupted
|
|
1889
|
+
*/
|
|
1890
|
+
get error(): A_FeatureError | undefined;
|
|
1891
|
+
/**
|
|
1892
|
+
* The current state of the Feature
|
|
1893
|
+
*/
|
|
1894
|
+
get state(): A_TYPES__FeatureState;
|
|
1895
|
+
/**
|
|
1896
|
+
* Sets the current state of the Feature
|
|
1897
|
+
*/
|
|
1898
|
+
get index(): number;
|
|
1899
|
+
/**
|
|
1900
|
+
* Returns the current A-Feature Stage
|
|
1901
|
+
*/
|
|
1902
|
+
get stage(): A_Stage | undefined;
|
|
1903
|
+
/**
|
|
1904
|
+
* The Caller that initiated the Feature call
|
|
1905
|
+
*/
|
|
1906
|
+
get caller(): A_Caller<T>;
|
|
1907
|
+
/**
|
|
1908
|
+
* The Scope allocated for the Feature Execution
|
|
1909
|
+
*/
|
|
1910
|
+
get scope(): A_Scope;
|
|
1911
|
+
/**
|
|
1912
|
+
* The number of stages in the feature
|
|
1913
|
+
*/
|
|
1914
|
+
get size(): number;
|
|
1915
|
+
/**
|
|
1916
|
+
* This method checks if the A-Feature is done
|
|
1917
|
+
*
|
|
1918
|
+
* @returns
|
|
1919
|
+
*/
|
|
1920
|
+
get isDone(): boolean;
|
|
1921
|
+
/**
|
|
1922
|
+
* Indicates whether the feature has been processed (completed, failed, or interrupted)
|
|
1923
|
+
*/
|
|
1924
|
+
get isProcessed(): boolean;
|
|
1925
|
+
/**
|
|
1926
|
+
* Iterator to iterate over the steps of the feature
|
|
1927
|
+
*
|
|
1928
|
+
* @returns
|
|
1929
|
+
*/
|
|
1930
|
+
[Symbol.iterator](): Iterator<A_Stage, any>;
|
|
1931
|
+
/**
|
|
1932
|
+
* Validates the provided parameters for A-Feature initialization
|
|
1933
|
+
*
|
|
1934
|
+
* @param params
|
|
1935
|
+
*/
|
|
1936
|
+
protected validateParams(params: A_TYPES__Feature_Init<T>): void;
|
|
1937
|
+
/**
|
|
1938
|
+
* Returns the appropriate initializer method based on the provided parameters
|
|
1939
|
+
*
|
|
1940
|
+
* @param params
|
|
1941
|
+
* @returns
|
|
1942
|
+
*/
|
|
1943
|
+
protected getInitializer(params: A_TYPES__Feature_Init<T>): (param1: any) => void | (() => void);
|
|
1944
|
+
/**
|
|
1945
|
+
* Initializes the A-Feature from the provided template
|
|
1946
|
+
*
|
|
1947
|
+
* @param params
|
|
1948
|
+
*/
|
|
1949
|
+
protected fromTemplate(params: A_TYPES__Feature_InitWithTemplate<T>): void;
|
|
1950
|
+
/**
|
|
1951
|
+
* Initializes the A-Feature from the provided component
|
|
1952
|
+
*
|
|
1953
|
+
* @param params
|
|
1954
|
+
*/
|
|
1955
|
+
protected fromComponent(params: A_TYPES__Feature_InitWithComponent<T>): void;
|
|
1956
|
+
/**
|
|
1957
|
+
* This method processes the feature by executing all the stages
|
|
1958
|
+
*
|
|
1959
|
+
*/
|
|
1960
|
+
process(
|
|
1961
|
+
/**
|
|
1962
|
+
* Optional scope to be used to resolve the steps dependencies
|
|
1963
|
+
* If not provided, the scope of the caller component will be used
|
|
1964
|
+
*/
|
|
1965
|
+
scope?: A_Scope): Promise<void> | void;
|
|
1966
|
+
/**
|
|
1967
|
+
* Process stages one by one, ensuring each stage completes before starting the next
|
|
1968
|
+
*/
|
|
1969
|
+
private processStagesSequentially;
|
|
1970
|
+
/**
|
|
1971
|
+
* This method moves the feature to the next stage
|
|
1972
|
+
*
|
|
1973
|
+
* @param stage
|
|
1974
|
+
*/
|
|
1975
|
+
next(stage: any): void;
|
|
1976
|
+
/**
|
|
1977
|
+
* This method marks the feature as completed and returns the result
|
|
1978
|
+
* Uses to interrupt or end the feature processing
|
|
1979
|
+
*
|
|
1980
|
+
* @param result
|
|
1981
|
+
* @returns
|
|
1982
|
+
*/
|
|
1983
|
+
completed(): void;
|
|
1984
|
+
/**
|
|
1985
|
+
* This method marks the feature as failed and returns the error
|
|
1986
|
+
* Uses to mark the feature as failed
|
|
1987
|
+
*
|
|
1988
|
+
* @param error
|
|
1989
|
+
* @returns The error that caused the failure
|
|
1990
|
+
*/
|
|
1991
|
+
failed(error: A_FeatureError): A_FeatureError;
|
|
1992
|
+
/**
|
|
1993
|
+
* This method marks the feature as interrupted and throws an error
|
|
1994
|
+
* Uses to interrupt or end the feature processing
|
|
1995
|
+
*
|
|
1996
|
+
* @param error
|
|
1997
|
+
*/
|
|
1998
|
+
interrupt(
|
|
1999
|
+
/**
|
|
2000
|
+
* The reason of feature interruption
|
|
2001
|
+
*/
|
|
2002
|
+
reason?: string | A_StageError | Error): A_FeatureError;
|
|
2003
|
+
/**
|
|
2004
|
+
* Allows to chain the feature to another feature.
|
|
2005
|
+
* In this case the parent feature scope (if new not provided), stages, caller will be used.
|
|
2006
|
+
*
|
|
2007
|
+
* [!] Note: Chained feature will use the same caller as the parent feature.
|
|
2008
|
+
*
|
|
2009
|
+
* @param feature
|
|
2010
|
+
*/
|
|
2011
|
+
chain(
|
|
2012
|
+
/**
|
|
2013
|
+
* A Feature to be chained
|
|
2014
|
+
*/
|
|
2015
|
+
feature: A_Feature,
|
|
2016
|
+
/**
|
|
2017
|
+
* Optional scope to be used for the chained feature.
|
|
2018
|
+
*/
|
|
2019
|
+
scope?: A_Scope): any;
|
|
2020
|
+
chain<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__FeatureAvailableComponents>(
|
|
2021
|
+
/**
|
|
2022
|
+
* Component whose feature should be chained
|
|
2023
|
+
*/
|
|
2024
|
+
component: A_TYPES__FeatureAvailableComponents,
|
|
2025
|
+
/**
|
|
2026
|
+
* A Feature Name to be chained
|
|
2027
|
+
*/
|
|
2028
|
+
feature: string,
|
|
2029
|
+
/**
|
|
2030
|
+
* Optional scope to be used for the chained feature.
|
|
2031
|
+
*/
|
|
2032
|
+
scope?: A_Scope): any;
|
|
2033
|
+
toString(): string;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
/**
|
|
2037
|
+
* This is a common class that uses to return an entity that initiates a feature call
|
|
2038
|
+
*
|
|
2039
|
+
* It can be used then in @A_Inject(A_Caller) to get the entity that initiated the feature call
|
|
2040
|
+
*
|
|
2041
|
+
* [!] the class itself may be retrieved, but may require additional processing inside the feature
|
|
2042
|
+
*
|
|
2043
|
+
*/
|
|
2044
|
+
declare class A_Caller<T extends A_TYPES__FeatureAvailableComponents = A_TYPES__FeatureAvailableComponents> {
|
|
2045
|
+
/**
|
|
2046
|
+
* The component that initiated the feature call
|
|
2047
|
+
*/
|
|
2048
|
+
protected _component: T;
|
|
2049
|
+
/**
|
|
2050
|
+
* A_Caller allows to get the component that initiated the feature call
|
|
2051
|
+
*
|
|
2052
|
+
* It can be used then in @A_Inject(A_Caller) to get the entity that initiated the feature call
|
|
2053
|
+
*
|
|
2054
|
+
* [!] If Scope is not provided, a new empty scope will be created and inherited from the global scope
|
|
2055
|
+
*
|
|
2056
|
+
* @param component
|
|
2057
|
+
* @param scope
|
|
2058
|
+
*/
|
|
2059
|
+
constructor(component: T);
|
|
2060
|
+
get component(): T;
|
|
2061
|
+
/**
|
|
2062
|
+
* Validates the provided parameters and Ensures that the component is of an allowed type
|
|
2063
|
+
*
|
|
2064
|
+
* @param component
|
|
2065
|
+
*/
|
|
2066
|
+
protected validateParams(component: T): void;
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
declare class A_CallerError extends Error {
|
|
2070
|
+
/**
|
|
2071
|
+
* This error code indicates that there was an issue initializing the A-Caller
|
|
2072
|
+
*/
|
|
2073
|
+
static readonly CallerInitializationError = "Unable to initialize A-Caller";
|
|
2074
|
+
}
|
|
2075
|
+
|
|
2076
|
+
type A_TYPES__CallerComponent = A_Container | A_Component | A_Entity;
|
|
2077
|
+
/**
|
|
2078
|
+
* Caller constructor type
|
|
2079
|
+
* Uses the generic type T to specify the type of the caller component
|
|
2080
|
+
*/
|
|
2081
|
+
type A_TYPES__Caller_Constructor<T = A_Caller> = A_TYPES__Ctor<T>;
|
|
2082
|
+
/**
|
|
2083
|
+
* Caller initialization type
|
|
2084
|
+
*/
|
|
2085
|
+
type A_TYPES__Caller_Init = {};
|
|
2086
|
+
/**
|
|
2087
|
+
* Caller serialized type
|
|
2088
|
+
*/
|
|
2089
|
+
type A_TYPES__Caller_Serialized = {};
|
|
2090
|
+
|
|
2091
|
+
type A_TYPES__A_DependencyConstructor<T extends A_Dependency> = A_TYPES__Ctor<T>;
|
|
2092
|
+
type A_TYPES__A_DependencyInjectable = A_Entity | A_Container | A_Component | A_Fragment | A_Feature | A_Caller | A_Error | A_Scope;
|
|
2093
|
+
type A_TYPES__A_DependencyResolutionType<T> = T extends string ? string : T extends A_TYPES__Ctor<infer R> ? R : never;
|
|
2094
|
+
type A_TYPES__A_DependencyResolutionStrategy<T extends A_TYPES__A_DependencyInjectable = A_TYPES__A_DependencyInjectable> = {
|
|
2095
|
+
/**
|
|
2096
|
+
* If tru will throw an error if the dependency is not found
|
|
2097
|
+
*/
|
|
2098
|
+
require: boolean;
|
|
2099
|
+
/**
|
|
2100
|
+
* Indicates that dependency should be loaded from a specific path before resolution
|
|
2101
|
+
*/
|
|
2102
|
+
load: boolean;
|
|
2103
|
+
/**
|
|
2104
|
+
* Number of levels to go up in the parent chain when resolving the dependency
|
|
2105
|
+
*/
|
|
2106
|
+
parent: number;
|
|
2107
|
+
/**
|
|
2108
|
+
* If true, will only resolve the dependency in the current scope without going up to parent scopes
|
|
2109
|
+
*/
|
|
2110
|
+
flat: boolean;
|
|
2111
|
+
/**
|
|
2112
|
+
* If has any value indicates that entity should be created with default parameters provided
|
|
2113
|
+
*/
|
|
2114
|
+
create: boolean;
|
|
2115
|
+
/**
|
|
2116
|
+
* Default constructor arguments to use when creating the dependency
|
|
2117
|
+
*/
|
|
2118
|
+
args: any[];
|
|
2119
|
+
/**
|
|
2120
|
+
* Allows to query by specific entity properties e.g. ASEID, name, type, custom properties, etc.
|
|
2121
|
+
*/
|
|
2122
|
+
query: Partial<A_TYPES__A_Dependency_EntityInjectionQuery<T>>;
|
|
2123
|
+
/**
|
|
2124
|
+
* Pagination settings for the entity search
|
|
2125
|
+
*/
|
|
2126
|
+
pagination: A_TYPES__A_Dependency_EntityInjectionPagination;
|
|
2127
|
+
};
|
|
2128
|
+
type A_TYPES__A_Dependency_Serialized<T extends A_TYPES__A_DependencyInjectable = A_TYPES__A_DependencyInjectable> = {
|
|
2129
|
+
name: string;
|
|
2130
|
+
all: boolean;
|
|
2131
|
+
require: boolean;
|
|
2132
|
+
load: boolean;
|
|
2133
|
+
parent: number;
|
|
2134
|
+
flat: boolean;
|
|
2135
|
+
create: any;
|
|
2136
|
+
args: any[];
|
|
2137
|
+
query: Partial<A_TYPES__A_Dependency_EntityInjectionQuery<T>>;
|
|
2138
|
+
pagination: A_TYPES__A_Dependency_EntityInjectionPagination;
|
|
2139
|
+
};
|
|
2140
|
+
type A_TYPES__A_Dependency_EntityResolutionConfig<T extends A_TYPES__A_DependencyInjectable = A_TYPES__A_DependencyInjectable> = {
|
|
2141
|
+
query: Partial<A_TYPES__A_Dependency_EntityInjectionQuery<T>>;
|
|
2142
|
+
pagination: Partial<A_TYPES__A_Dependency_EntityInjectionPagination>;
|
|
2143
|
+
};
|
|
2144
|
+
type A_TYPES__A_Dependency_EntityInjectionQuery<T extends A_TYPES__A_DependencyInjectable = A_TYPES__A_DependencyInjectable> = T extends A_Entity ? {
|
|
2145
|
+
aseid: string;
|
|
2146
|
+
} & {
|
|
2147
|
+
[key in keyof T]?: any;
|
|
2148
|
+
} : never;
|
|
2149
|
+
type A_TYPES__A_Dependency_EntityInjectionPagination = {
|
|
2150
|
+
count: number;
|
|
2151
|
+
from: 'start' | 'end';
|
|
2152
|
+
};
|
|
2153
|
+
/**
|
|
2154
|
+
* A-Dependency require decorator return type
|
|
2155
|
+
*/
|
|
2156
|
+
type A_TYPES__A_Dependency_RequireDecoratorReturn<T = any> = (target: T, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
2157
|
+
/**
|
|
2158
|
+
* A-Dependency load decorator return type
|
|
2159
|
+
*/
|
|
2160
|
+
type A_TYPES__A_Dependency_LoadDecoratorReturn<T = any> = (target: T, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
2161
|
+
/**
|
|
2162
|
+
* A-Dependency default decorator return type
|
|
2163
|
+
*/
|
|
2164
|
+
type A_TYPES__A_Dependency_DefaultDecoratorReturn<T = any> = (target: T, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
2165
|
+
/**
|
|
2166
|
+
* A-Dependency parent decorator return type
|
|
2167
|
+
*/
|
|
2168
|
+
type A_TYPES__A_Dependency_ParentDecoratorReturn<T = any> = (target: T, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
2169
|
+
/**
|
|
2170
|
+
* A-Dependency flat decorator return type
|
|
2171
|
+
*/
|
|
2172
|
+
type A_TYPES__A_Dependency_FlatDecoratorReturn<T = any> = (target: T, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
2173
|
+
/**
|
|
2174
|
+
* A-Dependency All decorator return type
|
|
2175
|
+
*/
|
|
2176
|
+
type A_TYPES__A_Dependency_AllDecoratorReturn<T = any> = (target: T, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
2177
|
+
|
|
2178
|
+
/**
|
|
2179
|
+
* Should indicate which Default is required
|
|
2180
|
+
*/
|
|
2181
|
+
declare function A_Dependency_Default(
|
|
2182
|
+
/**
|
|
2183
|
+
* Constructor Parameters that will be used to create the default instance
|
|
2184
|
+
*/
|
|
2185
|
+
...args: any[]): A_TYPES__A_Dependency_DefaultDecoratorReturn;
|
|
2186
|
+
|
|
2187
|
+
/**
|
|
2188
|
+
* Should indicate which dependency is required
|
|
2189
|
+
*/
|
|
2190
|
+
declare function A_Dependency_Flat(): A_TYPES__A_Dependency_FlatDecoratorReturn;
|
|
2191
|
+
|
|
2192
|
+
/**
|
|
2193
|
+
* Should indicate which Load is required
|
|
2194
|
+
*/
|
|
2195
|
+
declare function A_Dependency_Load(): A_TYPES__A_Dependency_LoadDecoratorReturn;
|
|
2196
|
+
|
|
2197
|
+
/**
|
|
2198
|
+
* Should indicate which dependency is required
|
|
2199
|
+
*/
|
|
2200
|
+
declare function A_Dependency_Parent(
|
|
2201
|
+
/**
|
|
2202
|
+
* Indicates how many layers up the parent dependency should be resolved from current dependency
|
|
2203
|
+
*
|
|
2204
|
+
* Default: -1 (one layer up)
|
|
2205
|
+
*/
|
|
2206
|
+
layerOffset?: number): A_TYPES__A_Dependency_ParentDecoratorReturn;
|
|
2207
|
+
|
|
2208
|
+
/**
|
|
2209
|
+
* Should indicate which dependency is required
|
|
2210
|
+
*/
|
|
2211
|
+
declare function A_Dependency_Require(): A_TYPES__A_Dependency_RequireDecoratorReturn;
|
|
2212
|
+
|
|
2213
|
+
/**
|
|
2214
|
+
* Should indicate which All is required
|
|
2215
|
+
*/
|
|
2216
|
+
declare function A_Dependency_All(): A_TYPES__A_Dependency_AllDecoratorReturn;
|
|
2217
|
+
|
|
2218
|
+
declare class A_Dependency<T extends A_TYPES__A_DependencyInjectable = A_TYPES__A_DependencyInjectable> {
|
|
2219
|
+
/**
|
|
2220
|
+
* Allows to indicate which Injected parameter is required
|
|
2221
|
+
*
|
|
2222
|
+
* [!] If parameter marked as required is not provided, an error will be thrown
|
|
2223
|
+
*
|
|
2224
|
+
* @returns
|
|
2225
|
+
*/
|
|
2226
|
+
static get Required(): typeof A_Dependency_Require;
|
|
2227
|
+
/**
|
|
2228
|
+
* Allows to indicate which dependency should be loaded from a specific path
|
|
2229
|
+
*
|
|
2230
|
+
* @returns
|
|
2231
|
+
*/
|
|
2232
|
+
static get Loaded(): typeof A_Dependency_Load;
|
|
2233
|
+
/**
|
|
2234
|
+
* Allows to indicate which dependency default parameters should be used
|
|
2235
|
+
*
|
|
2236
|
+
* @returns
|
|
2237
|
+
*/
|
|
2238
|
+
static get Default(): typeof A_Dependency_Default;
|
|
2239
|
+
/**
|
|
2240
|
+
* Allows to indicate which parent dependency should be resolved
|
|
2241
|
+
* e.g. from which layer up the parent should be taken
|
|
2242
|
+
*
|
|
2243
|
+
* @returns
|
|
2244
|
+
*/
|
|
2245
|
+
static get Parent(): typeof A_Dependency_Parent;
|
|
2246
|
+
/**
|
|
2247
|
+
* Allows to indicate that the dependency should be resolved in a flat manner
|
|
2248
|
+
* Only in the same scope, without going up to parent scopes
|
|
2249
|
+
*
|
|
2250
|
+
* @returns
|
|
2251
|
+
*/
|
|
2252
|
+
static get Flat(): typeof A_Dependency_Flat;
|
|
2253
|
+
/**
|
|
2254
|
+
* Allows to indicate that all instances of the dependency should be resolved
|
|
2255
|
+
*
|
|
2256
|
+
* @returns
|
|
2257
|
+
*/
|
|
2258
|
+
static get All(): typeof A_Dependency_All;
|
|
2259
|
+
protected _name: string;
|
|
2260
|
+
protected _target?: A_TYPES__Ctor<T>;
|
|
2261
|
+
protected _resolutionStrategy: A_TYPES__A_DependencyResolutionStrategy;
|
|
2262
|
+
protected _defaultPagination: A_TYPES__A_DependencyResolutionStrategy['pagination'];
|
|
2263
|
+
protected _defaultResolutionStrategy: A_TYPES__A_DependencyResolutionStrategy;
|
|
2264
|
+
get flat(): boolean;
|
|
2265
|
+
get require(): boolean;
|
|
2266
|
+
get load(): boolean;
|
|
2267
|
+
/**
|
|
2268
|
+
* Indicates cases when it's necessary to search across all instances
|
|
2269
|
+
*/
|
|
2270
|
+
get all(): boolean;
|
|
2271
|
+
get parent(): number;
|
|
2272
|
+
get create(): any;
|
|
2273
|
+
get args(): any[];
|
|
2274
|
+
get query(): Partial<A_TYPES__A_Dependency_EntityInjectionQuery<T>>;
|
|
2275
|
+
get pagination(): A_TYPES__A_Dependency_EntityInjectionPagination;
|
|
2276
|
+
/**
|
|
2277
|
+
* Class instances allows to identify dependencies by name and use them for better type checking
|
|
2278
|
+
*
|
|
2279
|
+
* @param name
|
|
2280
|
+
*/
|
|
2281
|
+
constructor(name: string | A_TYPES__Ctor<T>, resolutionStrategy?: Partial<Omit<A_TYPES__A_DependencyResolutionStrategy<T>, 'pagination'> & {
|
|
2282
|
+
pagination: Partial<A_TYPES__A_Dependency_EntityInjectionPagination>;
|
|
2283
|
+
}>);
|
|
2284
|
+
/**
|
|
2285
|
+
* Gets the dependency name
|
|
2286
|
+
*
|
|
2287
|
+
* Can be identifier, url or any string value
|
|
2288
|
+
*
|
|
2289
|
+
* @returns
|
|
2290
|
+
*/
|
|
2291
|
+
get name(): string;
|
|
2292
|
+
/**
|
|
2293
|
+
* Returns the original class of the dependency if provided
|
|
2294
|
+
*
|
|
2295
|
+
*/
|
|
2296
|
+
get target(): A_TYPES__Ctor<T> | undefined;
|
|
2297
|
+
/**
|
|
2298
|
+
* Gets the dependency resolution strategy
|
|
2299
|
+
*/
|
|
2300
|
+
get resolutionStrategy(): A_TYPES__A_DependencyResolutionStrategy<T>;
|
|
2301
|
+
/**
|
|
2302
|
+
* Sets the dependency resolution strategy
|
|
2303
|
+
*/
|
|
2304
|
+
set resolutionStrategy(strategy: Partial<Omit<A_TYPES__A_DependencyResolutionStrategy<T>, 'pagination'> & {
|
|
2305
|
+
pagination: Partial<A_TYPES__A_Dependency_EntityInjectionPagination>;
|
|
2306
|
+
}>);
|
|
2307
|
+
/**
|
|
2308
|
+
* Method for the parameters check and all input data before usage
|
|
2309
|
+
*
|
|
2310
|
+
* @returns
|
|
2311
|
+
*/
|
|
2312
|
+
private initCheck;
|
|
2313
|
+
/**
|
|
2314
|
+
* Serializes the dependency to a JSON object
|
|
2315
|
+
*
|
|
2316
|
+
* @returns
|
|
2317
|
+
*/
|
|
2318
|
+
toJSON(): A_TYPES__A_Dependency_Serialized<T>;
|
|
2319
|
+
}
|
|
2320
|
+
|
|
2321
|
+
declare class A_DependencyError extends A_Error {
|
|
2322
|
+
static readonly InvalidDependencyTarget = "Invalid Dependency Target";
|
|
2323
|
+
static readonly InvalidLoadTarget = "Invalid Load Target";
|
|
2324
|
+
static readonly InvalidLoadPath = "Invalid Load Path";
|
|
2325
|
+
static readonly InvalidDefaultTarget = "Invalid Default Target";
|
|
2326
|
+
static readonly ResolutionParametersError = "Dependency Resolution Parameters Error";
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
/**
|
|
2330
|
+
* A-Inject decorator descriptor type
|
|
2331
|
+
* Indicates the type of the decorator function
|
|
2332
|
+
*/
|
|
2333
|
+
type A_TYPES__A_InjectDecoratorDescriptor = TypedPropertyDescriptor<(...args: any[]) => Promise<void>>;
|
|
2334
|
+
/**
|
|
2335
|
+
* A-Inject decorator return type
|
|
2336
|
+
* Indicates what the decorator function returns
|
|
2337
|
+
*/
|
|
2338
|
+
type A_TYPES__A_InjectDecoratorReturn<T = any> = (target: T, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
2339
|
+
type A_TYPES__A_InjectDecorator_Meta = Array<A_Dependency>;
|
|
2340
|
+
/**
|
|
2341
|
+
* Targets that can be injected into Extended functions or constructors
|
|
2342
|
+
*/
|
|
2343
|
+
type A_TYPES__InjectableTargets = A_TYPES__Component_Constructor | InstanceType<A_TYPES__Component_Constructor> | InstanceType<A_TYPES__Container_Constructor>;
|
|
2344
|
+
|
|
2345
|
+
/**
|
|
2346
|
+
* A-Inject decorator
|
|
2347
|
+
*
|
|
2348
|
+
* This Decorator allows to inject dependencies into the module like
|
|
2349
|
+
* - Namespaces
|
|
2350
|
+
* - Other Concepts
|
|
2351
|
+
* - or maybe Components
|
|
2352
|
+
*
|
|
2353
|
+
* @param params - see overloads
|
|
2354
|
+
* @returns - decorator function
|
|
2355
|
+
*/
|
|
2356
|
+
declare function A_Inject<T extends A_Component>(
|
|
2357
|
+
/**
|
|
2358
|
+
* Provide the Component constructor that will be associated with the injection.
|
|
2359
|
+
*
|
|
2360
|
+
* [!] It returns an Instance of the Component from current Scope or from Parent Scopes.
|
|
2361
|
+
*/
|
|
2362
|
+
component: A_TYPES__Component_Constructor<T>,
|
|
2363
|
+
/**
|
|
2364
|
+
* Provide additional instructions on how to perform the injection
|
|
2365
|
+
*
|
|
2366
|
+
* [!] Default Pagination is 1 if it's necessary to get multiple Fragments please customize it in the instructions
|
|
2367
|
+
*/
|
|
2368
|
+
config?: Omit<Partial<A_TYPES__A_DependencyResolutionStrategy<T>>, 'query' | 'pagination'>): A_TYPES__A_InjectDecoratorReturn;
|
|
2369
|
+
declare function A_Inject<T extends A_Fragment>(
|
|
2370
|
+
/**
|
|
2371
|
+
* Provide the Fragment constructor to inject the Fragment instance
|
|
2372
|
+
*
|
|
2373
|
+
* [!] It returns the Fragment instance from current Scope or from Parent Scopes.
|
|
2374
|
+
*/
|
|
2375
|
+
fragment: A_TYPES__Fragment_Constructor<T>,
|
|
2376
|
+
/**
|
|
2377
|
+
* Provide additional instructions on how to perform the injection
|
|
2378
|
+
*
|
|
2379
|
+
* [!] Default Pagination is 1 if it's necessary to get multiple Fragments please customize it in the instructions
|
|
2380
|
+
*/
|
|
2381
|
+
config?: Omit<Partial<A_TYPES__A_DependencyResolutionStrategy<T>>, 'query' | 'pagination'>): A_TYPES__A_InjectDecoratorReturn;
|
|
2382
|
+
declare function A_Inject<T extends A_Entity>(
|
|
2383
|
+
/**
|
|
2384
|
+
* Provide the Entity constructor to inject the Entity instance
|
|
2385
|
+
*
|
|
2386
|
+
* [!] Note: It returns the Entity instance from current Scope or from Parent Scopes.
|
|
2387
|
+
* [!] Note: If instance has more than one Entity of the same type It returns FIRST found Entity
|
|
2388
|
+
* [!] Note: Use 'config' to specify to inject specific one or even Array of Entities
|
|
2389
|
+
*/
|
|
2390
|
+
entity: A_TYPES__Entity_Constructor<T>,
|
|
2391
|
+
/**
|
|
2392
|
+
* Provide additional instructions on how to perform the injection
|
|
2393
|
+
*
|
|
2394
|
+
* [!] Default Pagination is 1 if it's necessary to get multiple Entities please customize it in the instructions
|
|
2395
|
+
*/
|
|
2396
|
+
config?: Partial<A_TYPES__A_DependencyResolutionStrategy<T>>): A_TYPES__A_InjectDecoratorReturn<T>;
|
|
2397
|
+
declare function A_Inject<T extends A_Component>(
|
|
2398
|
+
/**
|
|
2399
|
+
* Provide the name of Component constructor to inject the Component instance
|
|
2400
|
+
*
|
|
2401
|
+
* [!] You can use both customized one or original depending on your overriding strategy
|
|
2402
|
+
*/
|
|
2403
|
+
ctor: string): A_TYPES__A_InjectDecoratorReturn;
|
|
2404
|
+
declare function A_Inject<T extends A_Caller>(
|
|
2405
|
+
/**
|
|
2406
|
+
* Provide the A_Caller constructor to inject the Caller instance
|
|
2407
|
+
*
|
|
2408
|
+
* [!] It returns initiator of the call, e.g. Container/Component/Command who called Feature
|
|
2409
|
+
*/
|
|
2410
|
+
caller: A_TYPES__Caller_Constructor<T>): A_TYPES__A_InjectDecoratorReturn;
|
|
2411
|
+
declare function A_Inject<T extends A_Error>(
|
|
2412
|
+
/***
|
|
2413
|
+
* Provide the Error constructor that will be associated with the injection.
|
|
2414
|
+
*
|
|
2415
|
+
* [!] It returns an Instance of the Error what is executed.
|
|
2416
|
+
*/
|
|
2417
|
+
error: A_TYPES__Error_Constructor<T>,
|
|
2418
|
+
/**
|
|
2419
|
+
* Provide additional instructions on how to perform the injection
|
|
2420
|
+
*
|
|
2421
|
+
* [!] Default Pagination is 1 if it's necessary to get multiple Fragments please customize it in the instructions
|
|
2422
|
+
*/
|
|
2423
|
+
config?: Omit<Partial<A_TYPES__A_DependencyResolutionStrategy<T>>, 'query' | 'pagination'>): A_TYPES__A_InjectDecoratorReturn;
|
|
2424
|
+
declare function A_Inject<T extends A_Feature>(
|
|
2425
|
+
/**
|
|
2426
|
+
* Provide the Feature constructor that will be associated with the injection.
|
|
2427
|
+
*
|
|
2428
|
+
* [!] It returns an Instance of the Feature what is executed.
|
|
2429
|
+
*/
|
|
2430
|
+
feature: A_TYPES__Feature_Constructor<T>): A_TYPES__A_InjectDecoratorReturn;
|
|
2431
|
+
declare function A_Inject<T extends A_Scope>(
|
|
2432
|
+
/***
|
|
2433
|
+
* Provide the Scope constructor that will be associated with the injection.
|
|
2434
|
+
*
|
|
2435
|
+
* [!] It returns an instance of the Scope where the Entity/Component/Container is defined.
|
|
2436
|
+
*/
|
|
2437
|
+
scope: A_TYPES__Scope_Constructor<T>): A_TYPES__A_InjectDecoratorReturn;
|
|
2438
|
+
declare function A_Inject<T extends A_TYPES__A_DependencyInjectable>(
|
|
2439
|
+
/***
|
|
2440
|
+
* Provide the Scope constructor that will be associated with the injection.
|
|
2441
|
+
*
|
|
2442
|
+
* [!] It returns an instance of the Scope where the Entity/Component/Container is defined.
|
|
2443
|
+
*/
|
|
2444
|
+
dependency: A_Dependency<T>): A_TYPES__A_InjectDecoratorReturn;
|
|
2445
|
+
|
|
2446
|
+
declare class A_InjectError extends A_Error {
|
|
2447
|
+
static readonly InvalidInjectionTarget = "Invalid target for A-Inject decorator";
|
|
2448
|
+
static readonly MissingInjectionTarget = "Missing target for A-Inject decorator";
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
/**
|
|
2452
|
+
* Concept constructor type
|
|
2453
|
+
* Uses the generic type T to specify the type of the concept
|
|
2454
|
+
*/
|
|
2455
|
+
type A_TYPES__Concept_Constructor<T = A_Concept> = A_TYPES__Ctor<T>;
|
|
2456
|
+
/**
|
|
2457
|
+
* Concept initialization type
|
|
2458
|
+
* Uses the generic type T to specify the type of containers that the concept will use
|
|
2459
|
+
*/
|
|
2460
|
+
type A_TYPES__Concept_Init<T extends Array<A_Container>> = {
|
|
2461
|
+
/**
|
|
2462
|
+
* The name of the Concept
|
|
2463
|
+
* If name is not provided, will be used from environment variable A_CONCEPT_NAME
|
|
2464
|
+
*
|
|
2465
|
+
* By default, the name of the Concept is 'a-concept'
|
|
2466
|
+
*
|
|
2467
|
+
*/
|
|
2468
|
+
name?: string;
|
|
2469
|
+
/**
|
|
2470
|
+
* A set of Context Fragments to register globally for the concept.
|
|
2471
|
+
* These fragments will be available in the global context.
|
|
2472
|
+
*
|
|
2473
|
+
*/
|
|
2474
|
+
fragments?: Array<InstanceType<A_TYPES__Fragment_Constructor>>;
|
|
2475
|
+
/**
|
|
2476
|
+
* A set of Containers that the concept depends on.
|
|
2477
|
+
* These containers will create a new Container for the concept.
|
|
2478
|
+
*/
|
|
2479
|
+
containers?: T;
|
|
2480
|
+
/**
|
|
2481
|
+
* A set of Entities that the concept can use.
|
|
2482
|
+
* These components will be used in the concept.
|
|
2483
|
+
*/
|
|
2484
|
+
entities?: Array<InstanceType<A_TYPES__Entity_Constructor> | A_TYPES__Entity_Constructor>;
|
|
2485
|
+
/**
|
|
2486
|
+
* A set of Components available for all containers and fragments in the concept.
|
|
2487
|
+
* These components will be registered in the root scope of the concept.
|
|
2488
|
+
*
|
|
2489
|
+
* [!] Note that these components will be available in all containers and fragments in the concept.
|
|
2490
|
+
*/
|
|
2491
|
+
components?: Array<A_TYPES__Component_Constructor>;
|
|
2492
|
+
};
|
|
2493
|
+
/**
|
|
2494
|
+
* Concept serialized type
|
|
2495
|
+
*/
|
|
2496
|
+
type A_TYPES__Concept_Serialized = {};
|
|
2497
|
+
/**
|
|
2498
|
+
* Uses as a transfer object to pass configurations to Feature constructor
|
|
2499
|
+
*/
|
|
2500
|
+
type A_TYPES__ConceptAbstractionMeta = {
|
|
2501
|
+
/**
|
|
2502
|
+
* The arguments that will be passed to the handler
|
|
2503
|
+
*/
|
|
2504
|
+
args: A_TYPES__A_InjectDecorator_Meta;
|
|
2505
|
+
} & A_TYPES__FeatureExtendDecoratorMeta;
|
|
2506
|
+
/**
|
|
2507
|
+
* Uses to define the extension that will be applied to the Concept
|
|
2508
|
+
*/
|
|
2509
|
+
type A_TYPES__ConceptAbstraction = A_TYPES__FeatureExtendDecoratorMeta;
|
|
2510
|
+
|
|
2511
|
+
declare class A_Concept<_Imports extends A_Container[] = A_Container[]> {
|
|
2512
|
+
protected props: A_TYPES__Concept_Init<_Imports>;
|
|
2513
|
+
/**
|
|
2514
|
+
* Load the concept. This step runs before any other steps to ensure that all components are loaded.
|
|
2515
|
+
*/
|
|
2516
|
+
static Load(
|
|
2517
|
+
/**
|
|
2518
|
+
* provide additional configuration for the abstraction extension to make it dependent on other factors
|
|
2519
|
+
*/
|
|
2520
|
+
config?: Partial<A_TYPES__AbstractionDecoratorConfig>): ReturnType<typeof A_Abstraction_Extend>;
|
|
2521
|
+
/**
|
|
2522
|
+
* Publish the concept to ADAAS platform. (Or any other place defined in the concept)
|
|
2523
|
+
*
|
|
2524
|
+
* [!] To extend the logic just create a custom containers and override the default behavior.
|
|
2525
|
+
*/
|
|
2526
|
+
static Publish(
|
|
2527
|
+
/**
|
|
2528
|
+
* provide additional configuration for the abstraction extension to make it dependent on other factors
|
|
2529
|
+
*/
|
|
2530
|
+
config?: Partial<A_TYPES__AbstractionDecoratorConfig>): ReturnType<typeof A_Abstraction_Extend>;
|
|
2531
|
+
/**
|
|
2532
|
+
* Deploy the concept to the environment.
|
|
2533
|
+
*/
|
|
2534
|
+
static Deploy(
|
|
2535
|
+
/**
|
|
2536
|
+
* provide additional configuration for the abstraction extension to make it dependent on other factors
|
|
2537
|
+
*/
|
|
2538
|
+
config?: Partial<A_TYPES__AbstractionDecoratorConfig>): (target: A_Container | A_Component, propertyKey: string, descriptor: A_TYPES__AbstractionDecoratorDescriptor) => void;
|
|
2539
|
+
/**
|
|
2540
|
+
* Compiles the Concept in case there are some containers that require that.
|
|
2541
|
+
*
|
|
2542
|
+
* Can be used for static websites or any other concept that requires a build step.
|
|
2543
|
+
*
|
|
2544
|
+
*/
|
|
2545
|
+
static Build(
|
|
2546
|
+
/**
|
|
2547
|
+
* provide additional configuration for the abstraction extension to make it dependent on other factors
|
|
2548
|
+
*/
|
|
2549
|
+
config?: Partial<A_TYPES__AbstractionDecoratorConfig>): (target: A_Container | A_Component, propertyKey: string, descriptor: A_TYPES__AbstractionDecoratorDescriptor) => void;
|
|
2550
|
+
/**
|
|
2551
|
+
* Main execution of the concept.
|
|
2552
|
+
*/
|
|
2553
|
+
static Run(
|
|
2554
|
+
/**
|
|
2555
|
+
* provide additional configuration for the abstraction extension to make it dependent on other factors
|
|
2556
|
+
*/
|
|
2557
|
+
config?: Partial<A_TYPES__AbstractionDecoratorConfig>): (target: A_Container | A_Component, propertyKey: string, descriptor: A_TYPES__AbstractionDecoratorDescriptor) => void;
|
|
2558
|
+
/**
|
|
2559
|
+
* Start the concept. Uses for servers or any other background services.
|
|
2560
|
+
*/
|
|
2561
|
+
static Start(
|
|
2562
|
+
/**
|
|
2563
|
+
* provide additional configuration for the abstraction extension to make it dependent on other factors
|
|
2564
|
+
*/
|
|
2565
|
+
config?: Partial<A_TYPES__AbstractionDecoratorConfig>): (target: A_Container | A_Component, propertyKey: string, descriptor: A_TYPES__AbstractionDecoratorDescriptor) => void;
|
|
2566
|
+
/**
|
|
2567
|
+
* Stop the concept. Uses for servers or any other background services.
|
|
2568
|
+
*/
|
|
2569
|
+
static Stop(
|
|
2570
|
+
/**
|
|
2571
|
+
* provide additional configuration for the abstraction extension to make it dependent on other factors
|
|
2572
|
+
*/
|
|
2573
|
+
config?: Partial<A_TYPES__AbstractionDecoratorConfig>): (target: A_Container | A_Component, propertyKey: string, descriptor: A_TYPES__AbstractionDecoratorDescriptor) => void;
|
|
2574
|
+
/**
|
|
2575
|
+
* Name of the concept
|
|
2576
|
+
*
|
|
2577
|
+
* By default, the name of the Concept is 'a-concept'
|
|
2578
|
+
*/
|
|
2579
|
+
private _name;
|
|
2580
|
+
/**
|
|
2581
|
+
* A list of internally defined containers that the concept uses.
|
|
2582
|
+
*/
|
|
2583
|
+
protected _containers: A_Container[];
|
|
2584
|
+
/**
|
|
2585
|
+
* A-Concept is a placeholder for the concept of the any program.
|
|
2586
|
+
*
|
|
2587
|
+
* Concept - could be any Program regardless environment and it's goal.
|
|
2588
|
+
* It could be mobile, web or simple html page.
|
|
2589
|
+
* All depends on Containers and Components installed and provided in the Concept.
|
|
2590
|
+
*
|
|
2591
|
+
*
|
|
2592
|
+
* [!] Concept operates ONLY with all Components and Containers provided to achieve the goal.
|
|
2593
|
+
*
|
|
2594
|
+
*
|
|
2595
|
+
* @param props - Initialization properties for the Concept
|
|
2596
|
+
*/
|
|
2597
|
+
constructor(props: A_TYPES__Concept_Init<_Imports>);
|
|
2598
|
+
/**
|
|
2599
|
+
* Name of the concept
|
|
2600
|
+
*/
|
|
2601
|
+
get name(): string;
|
|
2602
|
+
/**
|
|
2603
|
+
* The primary Root scope of the concept.
|
|
2604
|
+
*/
|
|
2605
|
+
get scope(): A_Scope<any, A_TYPES__Component_Constructor[], A_TYPES__Error_Constructor[], A_TYPES__Entity_Constructor[], A_Fragment<A_TYPES__Fragment_Serialized>[]>;
|
|
2606
|
+
/**
|
|
2607
|
+
* Register a class or value in the concept scope.
|
|
2608
|
+
*/
|
|
2609
|
+
get register(): A_Scope['register'];
|
|
2610
|
+
/**
|
|
2611
|
+
* Resolve a class or value from the concept scope.
|
|
2612
|
+
*/
|
|
2613
|
+
get resolve(): A_Scope['resolve'];
|
|
2614
|
+
/**
|
|
2615
|
+
* Load the concept.
|
|
2616
|
+
*/
|
|
2617
|
+
load(scope?: A_Scope): Promise<void>;
|
|
2618
|
+
/**
|
|
2619
|
+
* Run the concept.
|
|
2620
|
+
*/
|
|
2621
|
+
run(scope?: A_Scope): Promise<void>;
|
|
2622
|
+
/**
|
|
2623
|
+
* Start the concept.
|
|
2624
|
+
*
|
|
2625
|
+
* @param params
|
|
2626
|
+
*/
|
|
2627
|
+
start(scope?: A_Scope): Promise<void>;
|
|
2628
|
+
/**
|
|
2629
|
+
* Stop the concept.
|
|
2630
|
+
*
|
|
2631
|
+
* @param params
|
|
2632
|
+
*/
|
|
2633
|
+
stop(scope?: A_Scope): Promise<void>;
|
|
2634
|
+
/**
|
|
2635
|
+
* Build the concept.
|
|
2636
|
+
*/
|
|
2637
|
+
build(scope?: A_Scope): Promise<void>;
|
|
2638
|
+
/**
|
|
2639
|
+
* Deploy the concept.
|
|
2640
|
+
*/
|
|
2641
|
+
deploy(scope?: A_Scope): Promise<void>;
|
|
2642
|
+
/**
|
|
2643
|
+
* Publish the concept.
|
|
2644
|
+
*/
|
|
2645
|
+
publish(scope?: A_Scope): Promise<void>;
|
|
2646
|
+
/**
|
|
2647
|
+
* Call the specific method of the concept or included modules.
|
|
2648
|
+
*/
|
|
2649
|
+
call<K extends Record<_Imports[number]['name'], string>>(
|
|
2650
|
+
/**
|
|
2651
|
+
* Name of the method to call
|
|
2652
|
+
*/
|
|
2653
|
+
method: K[keyof K],
|
|
2654
|
+
/**
|
|
2655
|
+
* Container in which the method is located
|
|
2656
|
+
*/
|
|
2657
|
+
container: _Imports[number]): Promise<void>;
|
|
2658
|
+
}
|
|
2659
|
+
|
|
2660
|
+
declare class A_ConceptMeta extends A_Meta<any> {
|
|
2661
|
+
private containers;
|
|
2662
|
+
constructor(containers: Array<A_Container>);
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
declare enum A_TYPES__ConceptAbstractions {
|
|
2666
|
+
/**
|
|
2667
|
+
* Run the concept.
|
|
2668
|
+
*/
|
|
2669
|
+
Run = "run",
|
|
2670
|
+
/**
|
|
2671
|
+
* Build the concept.
|
|
2672
|
+
*/
|
|
2673
|
+
Build = "build",
|
|
2674
|
+
/**
|
|
2675
|
+
* Publish the concept.
|
|
2676
|
+
*/
|
|
2677
|
+
Publish = "publish",
|
|
2678
|
+
/**
|
|
2679
|
+
* Deploy the concept.
|
|
2680
|
+
*/
|
|
2681
|
+
Deploy = "deploy",
|
|
2682
|
+
/**
|
|
2683
|
+
* Load the concept.
|
|
2684
|
+
*/
|
|
2685
|
+
Load = "load",
|
|
2686
|
+
/**
|
|
2687
|
+
* Start the concept.
|
|
2688
|
+
*/
|
|
2689
|
+
Start = "start",
|
|
2690
|
+
/**
|
|
2691
|
+
* Stop the concept.
|
|
2692
|
+
*/
|
|
2693
|
+
Stop = "stop"
|
|
2694
|
+
}
|
|
2695
|
+
declare enum A_TYPES__ConceptMetaKey {
|
|
2696
|
+
LIFECYCLE = "a-component-extensions"
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
declare enum A_TYPES__ContainerMetaKey {
|
|
2700
|
+
FEATURES = "a-container-features",
|
|
2701
|
+
INJECTIONS = "a-container-injections",
|
|
2702
|
+
ABSTRACTIONS = "a-container-abstractions",
|
|
2703
|
+
EXTENSIONS = "a-container-extensions"
|
|
2704
|
+
}
|
|
2705
|
+
|
|
2706
|
+
/**
|
|
2707
|
+
* Container constructor type
|
|
2708
|
+
* Uses the generic type T to specify the type of the container
|
|
2709
|
+
*/
|
|
2710
|
+
type A_TYPES__Container_Constructor<T = A_Container> = A_TYPES__Ctor<T>;
|
|
2711
|
+
/**
|
|
2712
|
+
* Container initialization type
|
|
2713
|
+
*/
|
|
2714
|
+
type A_TYPES__Container_Init = {
|
|
2715
|
+
/**
|
|
2716
|
+
* The extra name for the container (optional)
|
|
2717
|
+
*/
|
|
2718
|
+
name?: string;
|
|
2719
|
+
} & A_TYPES__Scope_Init;
|
|
2720
|
+
/**
|
|
2721
|
+
* Container serialized type
|
|
2722
|
+
*/
|
|
2723
|
+
type A_TYPES__Container_Serialized = {
|
|
2724
|
+
/**
|
|
2725
|
+
* The ASEID of the container
|
|
2726
|
+
*/
|
|
2727
|
+
aseid: string;
|
|
2728
|
+
};
|
|
2729
|
+
/**
|
|
2730
|
+
* Meta information stored in each Container
|
|
2731
|
+
*/
|
|
2732
|
+
type A_TYPES__ContainerMeta = {
|
|
2733
|
+
/**
|
|
2734
|
+
* Extensions applied to the component per handler
|
|
2735
|
+
*/
|
|
2736
|
+
[A_TYPES__ContainerMetaKey.EXTENSIONS]: A_Meta<{
|
|
2737
|
+
/**
|
|
2738
|
+
* Where Key the regexp for what to apply the extension
|
|
2739
|
+
* A set of container names or a wildcard, or a regexp
|
|
2740
|
+
*
|
|
2741
|
+
*
|
|
2742
|
+
* Where value is the extension instructions
|
|
2743
|
+
*/
|
|
2744
|
+
[Key: string]: A_TYPES__FeatureExtendDecoratorMeta[];
|
|
2745
|
+
}>;
|
|
2746
|
+
[A_TYPES__ContainerMetaKey.FEATURES]: A_Meta<{
|
|
2747
|
+
/**
|
|
2748
|
+
* Where Key is the name of the feature
|
|
2749
|
+
*
|
|
2750
|
+
* Where value is the list of features
|
|
2751
|
+
*/
|
|
2752
|
+
[Key: string]: A_TYPES__FeatureDefineDecoratorMeta;
|
|
2753
|
+
}>;
|
|
2754
|
+
[A_TYPES__ContainerMetaKey.ABSTRACTIONS]: A_Meta<{
|
|
2755
|
+
/**
|
|
2756
|
+
* Where Key the regexp for what to apply the extension
|
|
2757
|
+
* A set of container names or a wildcard, or a regexp
|
|
2758
|
+
*
|
|
2759
|
+
*
|
|
2760
|
+
* Where value is the extension instructions
|
|
2761
|
+
*/
|
|
2762
|
+
[Key: string]: A_TYPES__ConceptAbstraction[];
|
|
2763
|
+
}>;
|
|
2764
|
+
[A_TYPES__ContainerMetaKey.INJECTIONS]: A_Meta<{
|
|
2765
|
+
/**
|
|
2766
|
+
* Where Key is the name of the injection
|
|
2767
|
+
*
|
|
2768
|
+
* Where value is the list of injections
|
|
2769
|
+
*/
|
|
2770
|
+
[Key: string]: A_TYPES__A_InjectDecorator_Meta;
|
|
2771
|
+
}>;
|
|
2772
|
+
};
|
|
2773
|
+
type A_TYPES__ContainerMetaExtension = A_TYPES__FeatureExtendDecoratorMeta;
|
|
2774
|
+
|
|
2775
|
+
declare class A_Container {
|
|
2776
|
+
/**
|
|
2777
|
+
* Configuration of the container that will be used to run it.
|
|
2778
|
+
*/
|
|
2779
|
+
protected readonly config: Partial<A_TYPES__Container_Init>;
|
|
2780
|
+
/**
|
|
2781
|
+
* Name of the container
|
|
2782
|
+
*/
|
|
2783
|
+
get name(): string;
|
|
2784
|
+
/**
|
|
2785
|
+
* Returns the scope where the container is registered
|
|
2786
|
+
*/
|
|
2787
|
+
get scope(): A_Scope;
|
|
2788
|
+
/**
|
|
2789
|
+
* This class should combine Components to achieve the goal withing Concept
|
|
2790
|
+
*
|
|
2791
|
+
* Container is a direct container that should be "run" to make Concept work.
|
|
2792
|
+
* So because of that Container can be:
|
|
2793
|
+
* - HTTP Server
|
|
2794
|
+
* - BASH Script
|
|
2795
|
+
* - Database Connection
|
|
2796
|
+
* - Microservice
|
|
2797
|
+
* - etc.
|
|
2798
|
+
*
|
|
2799
|
+
* @param config - Configuration of the container that will be used to run it.
|
|
2800
|
+
*/
|
|
2801
|
+
constructor(
|
|
2802
|
+
/**
|
|
2803
|
+
* Configuration of the container that will be used to run it.
|
|
2804
|
+
*/
|
|
2805
|
+
config?: Partial<A_TYPES__Container_Init>);
|
|
2806
|
+
/**
|
|
2807
|
+
* Calls the feature with the given name in the given scope
|
|
2808
|
+
*
|
|
2809
|
+
* [!] Note: This method creates a new instance of the feature every time it is called
|
|
2810
|
+
*
|
|
2811
|
+
* @param feature - the name of the feature to call
|
|
2812
|
+
* @param scope - the scope in which to call the feature
|
|
2813
|
+
* @returns - void
|
|
2814
|
+
*/
|
|
2815
|
+
call(
|
|
2816
|
+
/**
|
|
2817
|
+
* Name of the feature to call
|
|
2818
|
+
*/
|
|
2819
|
+
feature: string,
|
|
2820
|
+
/**
|
|
2821
|
+
* scope in which the feature will be executed
|
|
2822
|
+
*/
|
|
2823
|
+
scope?: A_Scope): Promise<void>;
|
|
2824
|
+
}
|
|
2825
|
+
|
|
2826
|
+
declare class A_ContainerMeta extends A_Meta<A_TYPES__ContainerMeta> {
|
|
2827
|
+
/**
|
|
2828
|
+
* Allows to get all the injections for a given handler
|
|
2829
|
+
*
|
|
2830
|
+
* @param handler
|
|
2831
|
+
* @returns
|
|
2832
|
+
*/
|
|
2833
|
+
injections(handler: string): A_TYPES__A_InjectDecorator_Meta;
|
|
2834
|
+
/**
|
|
2835
|
+
* Returns all features defined in the Container
|
|
2836
|
+
*
|
|
2837
|
+
* @returns
|
|
2838
|
+
*/
|
|
2839
|
+
features(): Array<A_TYPES__FeatureDefineDecoratorMeta>;
|
|
2840
|
+
/**
|
|
2841
|
+
* Returns a set of instructions to run proper methods in Container during A-Concept Stage
|
|
2842
|
+
*
|
|
2843
|
+
* @param stage
|
|
2844
|
+
* @returns
|
|
2845
|
+
*/
|
|
2846
|
+
abstractions(abstraction: A_TYPES__ConceptAbstractions): A_TYPES__ConceptAbstractionMeta[];
|
|
2847
|
+
/**
|
|
2848
|
+
* Allows to get all the extensions for a given feature
|
|
2849
|
+
*
|
|
2850
|
+
* @param feature
|
|
2851
|
+
* @returns
|
|
2852
|
+
*/
|
|
2853
|
+
extensions(feature: string): A_TYPES__ContainerMetaExtension[];
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
/**
|
|
2857
|
+
* Scope constructor type
|
|
2858
|
+
* Uses the generic type T to specify the type of the Scope
|
|
2859
|
+
*/
|
|
2860
|
+
type A_TYPES__Scope_Constructor<T = A_Scope> = A_TYPES__Ctor<T>;
|
|
2861
|
+
/**
|
|
2862
|
+
* Scope initialization type
|
|
2863
|
+
*/
|
|
2864
|
+
type A_TYPES__Scope_Init<_MetaItems extends Record<string, any> = any, _ComponentType extends A_TYPES__Component_Constructor[] = A_TYPES__Component_Constructor[], _ErrorType extends A_TYPES__Error_Constructor[] = A_TYPES__Error_Constructor[], _EntityType extends A_TYPES__Entity_Constructor[] = A_TYPES__Entity_Constructor[], _FragmentType extends A_Fragment[] = A_Fragment[]> = {
|
|
2865
|
+
/**
|
|
2866
|
+
* Scope Name
|
|
2867
|
+
*/
|
|
2868
|
+
name: string;
|
|
2869
|
+
/**
|
|
2870
|
+
* A list of Context Fragments available in the Scope
|
|
2871
|
+
*/
|
|
2872
|
+
fragments: [..._FragmentType];
|
|
2873
|
+
/**
|
|
2874
|
+
* A set of Components available in the Scope
|
|
2875
|
+
*/
|
|
2876
|
+
components: [..._ComponentType];
|
|
2877
|
+
/**
|
|
2878
|
+
* A set of Errors available in the Scope
|
|
2879
|
+
*/
|
|
2880
|
+
errors: [..._ErrorType];
|
|
2881
|
+
/**
|
|
2882
|
+
* A set of Entities available in the Scope
|
|
2883
|
+
*
|
|
2884
|
+
*/
|
|
2885
|
+
entities: [
|
|
2886
|
+
..._EntityType,
|
|
2887
|
+
...InstanceType<_EntityType[number]>[]
|
|
2888
|
+
];
|
|
2889
|
+
meta: Partial<_MetaItems>;
|
|
2890
|
+
};
|
|
2891
|
+
/**
|
|
2892
|
+
* Scope configuration type
|
|
2893
|
+
*/
|
|
2894
|
+
type A_TYPES__ScopeConfig = {
|
|
2895
|
+
/**
|
|
2896
|
+
* Allows to define a parent to take dependencies from in case of the current scope does not have the required component
|
|
2897
|
+
*/
|
|
2898
|
+
parent: A_Scope;
|
|
2899
|
+
};
|
|
2900
|
+
/**
|
|
2901
|
+
* Scope serialized type
|
|
2902
|
+
*/
|
|
2903
|
+
type A_TYPES__Scope_Serialized = {};
|
|
2904
|
+
/**
|
|
2905
|
+
* A list of constructors that can have a scope associated with them
|
|
2906
|
+
*/
|
|
2907
|
+
type A_TYPES__ScopeLinkedConstructors = A_TYPES__Container_Constructor | A_TYPES__Feature_Constructor;
|
|
2908
|
+
/**
|
|
2909
|
+
* A list of components that can have a scope associated with them
|
|
2910
|
+
*/
|
|
2911
|
+
type A_TYPES__ScopeLinkedComponents = A_Container | A_Feature;
|
|
2912
|
+
/**
|
|
2913
|
+
* A list of components that are dependent on a scope and do not have their own scope
|
|
2914
|
+
*/
|
|
2915
|
+
type A_TYPES_ScopeDependentComponents = A_Component | A_Entity | A_Fragment | A_Error;
|
|
2916
|
+
/**
|
|
2917
|
+
* A list of components that are independent of a scope. They don't need a scope to be resolved
|
|
2918
|
+
* Those components haven't scope dependent features.
|
|
2919
|
+
*/
|
|
2920
|
+
type A_TYPES_ScopeIndependentComponents = A_Error | A_Scope | A_Caller;
|
|
2921
|
+
|
|
2922
|
+
declare class A_Scope<_MetaItems extends Record<string, any> = any, _ComponentType extends A_TYPES__Component_Constructor[] = A_TYPES__Component_Constructor[], _ErrorType extends A_TYPES__Error_Constructor[] = A_TYPES__Error_Constructor[], _EntityType extends A_TYPES__Entity_Constructor[] = A_TYPES__Entity_Constructor[], _FragmentType extends A_Fragment[] = A_Fragment[]> {
|
|
2923
|
+
/**
|
|
2924
|
+
* Scope Name uses for identification and logging purposes
|
|
2925
|
+
*/
|
|
2926
|
+
protected _name: string;
|
|
2927
|
+
/**
|
|
2928
|
+
* Parent scope reference, used for inheritance of components, fragments, entities and commands
|
|
2929
|
+
*/
|
|
2930
|
+
protected _parent?: A_Scope;
|
|
2931
|
+
/**
|
|
2932
|
+
* Internal meta storage using A_Meta for type-safe key-value operations.
|
|
2933
|
+
* This stores all the scope's runtime data that can be accessed and modified
|
|
2934
|
+
* throughout the execution pipeline or within running containers.
|
|
2935
|
+
*/
|
|
2936
|
+
protected _meta: A_Meta<_MetaItems>;
|
|
2937
|
+
/**
|
|
2938
|
+
* A set of allowed components, A set of constructors that are allowed in the scope
|
|
2939
|
+
*
|
|
2940
|
+
*/
|
|
2941
|
+
protected _allowedComponents: Set<_ComponentType[number]>;
|
|
2942
|
+
/**
|
|
2943
|
+
* A set of allowed errors, A set of constructors that are allowed in the scope
|
|
2944
|
+
*/
|
|
2945
|
+
protected _allowedErrors: Set<_ErrorType[number]>;
|
|
2946
|
+
/**
|
|
2947
|
+
* A set of allowed entities, A set of constructors that are allowed in the scope
|
|
2948
|
+
*/
|
|
2949
|
+
protected _allowedEntities: Set<_EntityType[number]>;
|
|
2950
|
+
/**
|
|
2951
|
+
* A set of allowed fragments, A set of constructors that are allowed in the scope
|
|
2952
|
+
*/
|
|
2953
|
+
protected _allowedFragments: Set<A_TYPES__Fragment_Constructor<_FragmentType[number]>>;
|
|
2954
|
+
/**
|
|
2955
|
+
* Storage for the components, should be strong as components are unique per scope
|
|
2956
|
+
*/
|
|
2957
|
+
protected _components: Map<_ComponentType[number], InstanceType<_ComponentType[number]>>;
|
|
2958
|
+
/**
|
|
2959
|
+
* Storage for the errors, should be strong as errors are unique per code
|
|
2960
|
+
*/
|
|
2961
|
+
protected _errors: Map<string, InstanceType<_ErrorType[number]>>;
|
|
2962
|
+
/**
|
|
2963
|
+
* Storage for the entities, should be strong as entities are unique per aseid
|
|
2964
|
+
*/
|
|
2965
|
+
protected _entities: Map<string, InstanceType<_EntityType[number]>>;
|
|
2966
|
+
/**
|
|
2967
|
+
* Storage for the fragments, should be weak as fragments are singletons per scope
|
|
2968
|
+
*/
|
|
2969
|
+
protected _fragments: Map<A_TYPES__Fragment_Constructor<_FragmentType[number]>, _FragmentType[number]>;
|
|
2970
|
+
/**
|
|
2971
|
+
* Storage for imported scopes
|
|
2972
|
+
*/
|
|
2973
|
+
protected _imports: Set<A_Scope>;
|
|
2974
|
+
/**
|
|
2975
|
+
* Returns the name of the scope
|
|
2976
|
+
*/
|
|
2977
|
+
get name(): string;
|
|
2978
|
+
/**
|
|
2979
|
+
* Returns the meta object of the scope
|
|
2980
|
+
*/
|
|
2981
|
+
get meta(): A_Meta<_MetaItems, Record<string, any>>;
|
|
2982
|
+
/**
|
|
2983
|
+
* Returns a list of Constructors for A-Components that are available in the scope
|
|
2984
|
+
*/
|
|
2985
|
+
get allowedComponents(): Set<_ComponentType[number]>;
|
|
2986
|
+
/**
|
|
2987
|
+
* Returns a list of Constructors for A-Entities that are available in the scope
|
|
2988
|
+
*/
|
|
2989
|
+
get allowedEntities(): Set<_EntityType[number]>;
|
|
2990
|
+
/**
|
|
2991
|
+
* Returns a list of Constructors for A-Fragments that are available in the scope
|
|
2992
|
+
*/
|
|
2993
|
+
get allowedFragments(): Set<A_TYPES__Fragment_Constructor<_FragmentType[number]>>;
|
|
2994
|
+
/**
|
|
2995
|
+
* Returns a list of Constructors for A-Errors that are available in the scope
|
|
2996
|
+
*/
|
|
2997
|
+
get allowedErrors(): Set<_ErrorType[number]>;
|
|
2998
|
+
/**
|
|
2999
|
+
* Returns an Array of entities registered in the scope
|
|
3000
|
+
*
|
|
3001
|
+
* [!] One entity per aseid
|
|
3002
|
+
*/
|
|
3003
|
+
get entities(): Array<InstanceType<_EntityType[number]>>;
|
|
3004
|
+
/**
|
|
3005
|
+
* Returns an Array of fragments registered in the scope
|
|
3006
|
+
*
|
|
3007
|
+
* [!] One fragment per scope
|
|
3008
|
+
*/
|
|
3009
|
+
get fragments(): Array<_FragmentType[number]>;
|
|
3010
|
+
/**
|
|
3011
|
+
* Returns an Array of components registered in the scope
|
|
3012
|
+
*
|
|
3013
|
+
* [!] One component instance per scope
|
|
3014
|
+
*/
|
|
3015
|
+
get components(): Array<InstanceType<_ComponentType[number]>>;
|
|
3016
|
+
/**
|
|
3017
|
+
* Returns an Array of errors registered in the scope
|
|
3018
|
+
*
|
|
3019
|
+
* [!] One error per code
|
|
3020
|
+
*/
|
|
3021
|
+
get errors(): Array<InstanceType<_ErrorType[number]>>;
|
|
3022
|
+
/**
|
|
3023
|
+
* Returns an Array of imported scopes
|
|
3024
|
+
* [!] Imported scopes are scopes that have been imported into the current scope using the import() method
|
|
3025
|
+
*/
|
|
3026
|
+
get imports(): Array<A_Scope>;
|
|
3027
|
+
/**
|
|
3028
|
+
* Returns the parent scope of the current scope
|
|
3029
|
+
*
|
|
3030
|
+
* @param setValue
|
|
3031
|
+
* @returns
|
|
3032
|
+
*/
|
|
3033
|
+
get parent(): A_Scope | undefined;
|
|
3034
|
+
/**
|
|
3035
|
+
* A_Scope refers to the visibility and accessibility of :
|
|
3036
|
+
* - variables,
|
|
3037
|
+
* - Components,
|
|
3038
|
+
* - Context Fragments
|
|
3039
|
+
* - Entities
|
|
3040
|
+
* - and objects in different parts of your code.
|
|
3041
|
+
* Scope determines where a particular piece of data (like a variable or function)
|
|
3042
|
+
* can be accessed, modified, or referenced, and it plays a crucial role in avoiding naming collisions and ensuring data integrity.
|
|
3043
|
+
*
|
|
3044
|
+
* [!] The scope behavior is similar to tree structure where each scope can have a parent scope and inherit its components, fragments, entities and errors
|
|
3045
|
+
*
|
|
3046
|
+
* @param params
|
|
3047
|
+
* @param config
|
|
3048
|
+
*/
|
|
3049
|
+
constructor();
|
|
3050
|
+
constructor(
|
|
3051
|
+
/**
|
|
3052
|
+
* A set of constructors that are allowed in the scope
|
|
3053
|
+
*/
|
|
3054
|
+
params: Partial<A_TYPES__Scope_Init<_MetaItems, _ComponentType, _ErrorType, _EntityType, _FragmentType>>,
|
|
3055
|
+
/**
|
|
3056
|
+
* Configuration options for the scope
|
|
3057
|
+
*/
|
|
3058
|
+
config?: Partial<A_TYPES__ScopeConfig>);
|
|
3059
|
+
/**
|
|
3060
|
+
* Generator to iterate through all parent scopes
|
|
3061
|
+
*/
|
|
3062
|
+
parents(): Generator<A_Scope>;
|
|
3063
|
+
/**
|
|
3064
|
+
* This method is used to retrieve a parent scope at a specific level
|
|
3065
|
+
*
|
|
3066
|
+
* [!] Note that if the level is out of bounds, undefined is returned
|
|
3067
|
+
* [!!] Uses negative values for levels (e.g. -1 for immediate parent, -2 for grandparent, etc.)
|
|
3068
|
+
*
|
|
3069
|
+
* @param level
|
|
3070
|
+
* @returns
|
|
3071
|
+
*/
|
|
3072
|
+
parentOffset<T extends A_Scope>(
|
|
3073
|
+
/**
|
|
3074
|
+
* Level of the parent scope to retrieve
|
|
3075
|
+
*
|
|
3076
|
+
* Examples:
|
|
3077
|
+
* - level 0 - this scope
|
|
3078
|
+
* - level -1 - parent
|
|
3079
|
+
* - level -2 - grandparent
|
|
3080
|
+
*/
|
|
3081
|
+
layerOffset: number): T | undefined;
|
|
3082
|
+
/**
|
|
3083
|
+
* Determines which initializer method to use based on the type of the first parameter.
|
|
3084
|
+
*
|
|
3085
|
+
* @param param1
|
|
3086
|
+
* @returns
|
|
3087
|
+
*/
|
|
3088
|
+
protected getInitializer(param1?: Partial<A_TYPES__Scope_Init<_MetaItems, _ComponentType, _ErrorType, _EntityType, _FragmentType>>, param2?: Partial<A_TYPES__ScopeConfig>): (param1: any, param2: any) => void | (() => void);
|
|
3089
|
+
protected defaultInitialized(params?: Partial<A_TYPES__Scope_Init<_MetaItems, _ComponentType, _ErrorType, _EntityType, _FragmentType>>, config?: Partial<A_TYPES__ScopeConfig>): void;
|
|
3090
|
+
/**
|
|
3091
|
+
* This method is used to initialize the components in the scope
|
|
3092
|
+
* To save memory components are initialized only when they are requested
|
|
3093
|
+
*
|
|
3094
|
+
* This method only registers the component in the scope in case they are not registered yet
|
|
3095
|
+
*
|
|
3096
|
+
* @param _components
|
|
3097
|
+
*/
|
|
3098
|
+
protected initComponents(_components?: _ComponentType): void;
|
|
3099
|
+
/**
|
|
3100
|
+
* This method is used to initialize the errors in the scope
|
|
3101
|
+
*
|
|
3102
|
+
* This method only registers the errors in the scope in case they are not registered yet
|
|
3103
|
+
*
|
|
3104
|
+
* @param _errors
|
|
3105
|
+
*/
|
|
3106
|
+
protected initErrors(_errors?: _ErrorType): void;
|
|
3107
|
+
/**
|
|
3108
|
+
* This method is used to initialize the entities in the scope
|
|
3109
|
+
*
|
|
3110
|
+
* This method only registers the entities in the scope in case they are not registered yet
|
|
3111
|
+
*
|
|
3112
|
+
* @param _entities
|
|
3113
|
+
*/
|
|
3114
|
+
protected initEntities(_entities?: [
|
|
3115
|
+
..._EntityType,
|
|
3116
|
+
...InstanceType<_EntityType[number]>[]
|
|
3117
|
+
]): void;
|
|
3118
|
+
/**
|
|
3119
|
+
* This method is used to initialize the fragments in the scope
|
|
3120
|
+
*
|
|
3121
|
+
* This method only registers the fragments in the scope in case they are not registered yet
|
|
3122
|
+
*
|
|
3123
|
+
* @param _fragments
|
|
3124
|
+
*/
|
|
3125
|
+
protected initFragments(_fragments?: _FragmentType): void;
|
|
3126
|
+
/**
|
|
3127
|
+
* This method is used to initialize the meta in the scope
|
|
3128
|
+
*
|
|
3129
|
+
* This method only sets the meta values in the scope in case they are not set yet
|
|
3130
|
+
*
|
|
3131
|
+
* @param _meta
|
|
3132
|
+
*/
|
|
3133
|
+
protected initMeta(_meta?: Partial<_MetaItems>): void;
|
|
3134
|
+
/**
|
|
3135
|
+
* This method is used to destroy the scope and all its registered components, fragments and entities
|
|
3136
|
+
*
|
|
3137
|
+
* [!] This method deregisters all components, fragments and entities from the A-Context
|
|
3138
|
+
* [!] This method also clears all internal registries and collections
|
|
3139
|
+
*/
|
|
3140
|
+
destroy(): void;
|
|
3141
|
+
/**
|
|
3142
|
+
* Retrieves a value from the scope's meta.
|
|
3143
|
+
*
|
|
3144
|
+
* @param param - The key to retrieve
|
|
3145
|
+
* @returns The value associated with the key, or undefined if not found
|
|
3146
|
+
*
|
|
3147
|
+
* @example
|
|
3148
|
+
* ```typescript
|
|
3149
|
+
* const userId = scope.get('userId');
|
|
3150
|
+
* if (userId) {
|
|
3151
|
+
* console.log(`Current user: ${userId}`);
|
|
3152
|
+
* }
|
|
3153
|
+
* ```
|
|
3154
|
+
*/
|
|
3155
|
+
get<K extends keyof _MetaItems>(param: K): _MetaItems[K] | undefined;
|
|
3156
|
+
/**
|
|
3157
|
+
* Stores a value in the scope's meta.
|
|
3158
|
+
*
|
|
3159
|
+
* @param param - The key to store the value under
|
|
3160
|
+
* @param value - The value to store
|
|
3161
|
+
*
|
|
3162
|
+
* @example
|
|
3163
|
+
* ```typescript
|
|
3164
|
+
* scope.set('userId', '12345');
|
|
3165
|
+
* scope.set('role', 'admin');
|
|
3166
|
+
* ```
|
|
3167
|
+
*/
|
|
3168
|
+
set<K extends keyof _MetaItems>(param: K, value: _MetaItems[K]): void;
|
|
3169
|
+
/**
|
|
3170
|
+
* Returns the issuer of the scope, useful for debugging and tracking purposes
|
|
3171
|
+
*
|
|
3172
|
+
* Issuer can be:
|
|
3173
|
+
* - A Container that allocated the scope
|
|
3174
|
+
* - A Feature that allocated the scope
|
|
3175
|
+
*
|
|
3176
|
+
* [!] Note that the issuer is the direct allocator of the scope, so if a Container allocated a Feature that allocated the scope, the issuer will be the Feature
|
|
3177
|
+
*
|
|
3178
|
+
* @returns
|
|
3179
|
+
*/
|
|
3180
|
+
issuer<T extends A_TYPES__ScopeLinkedComponents>(): T | undefined;
|
|
3181
|
+
/**
|
|
3182
|
+
* This method is used to inherit from a parent scope
|
|
3183
|
+
*
|
|
3184
|
+
* [!] This method checks for circular inheritance and throws an error if detected
|
|
3185
|
+
*
|
|
3186
|
+
* @param parent
|
|
3187
|
+
* @returns
|
|
3188
|
+
*/
|
|
3189
|
+
inherit(parent: A_Scope): A_Scope;
|
|
3190
|
+
/**
|
|
3191
|
+
* This method allows to import other scopes, to make their dependencies available in the current scope
|
|
3192
|
+
*
|
|
3193
|
+
* [!] Import doesn't create a parent-child relationship between scopes, it just copies the dependencies from the imported scopes
|
|
3194
|
+
* [!] It doesn't change the entities ownership, so entities remain unique to their original scopes
|
|
3195
|
+
*
|
|
3196
|
+
* @param scopes
|
|
3197
|
+
* @returns
|
|
3198
|
+
*/
|
|
3199
|
+
import(...scopes: A_Scope[]): A_Scope;
|
|
3200
|
+
/**
|
|
3201
|
+
* This method allows to deimport other scopes, to remove their dependencies from the current scope
|
|
3202
|
+
*
|
|
3203
|
+
*
|
|
3204
|
+
* @param scopes
|
|
3205
|
+
* @returns
|
|
3206
|
+
*/
|
|
3207
|
+
deimport(...scopes: A_Scope[]): A_Scope;
|
|
3208
|
+
/**
|
|
3209
|
+
* This method is used to check if the component is available in the scope
|
|
3210
|
+
*
|
|
3211
|
+
* [!] Note that this method checks for the component in the current scope and all parent scopes
|
|
3212
|
+
*
|
|
3213
|
+
* @param component
|
|
3214
|
+
* @returns
|
|
3215
|
+
*/
|
|
3216
|
+
has<T extends A_Component>(
|
|
3217
|
+
/**
|
|
3218
|
+
* Provide a component constructor to check if it's available in the scope
|
|
3219
|
+
*/
|
|
3220
|
+
component: A_TYPES__Component_Constructor<T>): boolean;
|
|
3221
|
+
has<T extends A_Entity>(
|
|
3222
|
+
/**
|
|
3223
|
+
* Provide an entity constructor to check if it's available in the scope
|
|
3224
|
+
*
|
|
3225
|
+
* [!] Note that entities are unique per aseid, so this method checks if there's at least one entity of the provided type in the scope
|
|
3226
|
+
*/
|
|
3227
|
+
entity: A_TYPES__Entity_Constructor<T>): boolean;
|
|
3228
|
+
has<T extends A_Fragment>(
|
|
3229
|
+
/**
|
|
3230
|
+
* Provide a fragment constructor to check if it's available in the scope
|
|
3231
|
+
*/
|
|
3232
|
+
fragment: A_TYPES__Fragment_Constructor<T>): boolean;
|
|
3233
|
+
has<T extends A_Error>(
|
|
3234
|
+
/**
|
|
3235
|
+
* Provide an error constructor to check if it's available in the scope
|
|
3236
|
+
*/
|
|
3237
|
+
error: A_TYPES__Error_Constructor<T>): boolean;
|
|
3238
|
+
has(
|
|
3239
|
+
/**
|
|
3240
|
+
* Provide a string to check if a component, entity or fragment with the provided name is available in the scope
|
|
3241
|
+
*/
|
|
3242
|
+
constructor: string): boolean;
|
|
3243
|
+
has<T extends A_TYPES__A_DependencyInjectable>(ctor: A_TYPES__Ctor<T> | string): boolean;
|
|
3244
|
+
/**
|
|
3245
|
+
* This method is used to check if the component is available in the scope
|
|
3246
|
+
*
|
|
3247
|
+
* [!] Note that this method checks for the component ONLY in the current scope
|
|
3248
|
+
*
|
|
3249
|
+
* @param component
|
|
3250
|
+
* @returns
|
|
3251
|
+
*/
|
|
3252
|
+
hasFlat<T extends A_Component>(
|
|
3253
|
+
/**
|
|
3254
|
+
* Provide a component constructor to check if it's available in the scope
|
|
3255
|
+
*/
|
|
3256
|
+
component: A_TYPES__Component_Constructor<T>): boolean;
|
|
3257
|
+
hasFlat<T extends A_Entity>(
|
|
3258
|
+
/**
|
|
3259
|
+
* Provide an entity constructor to check if it's available in the scope
|
|
3260
|
+
*
|
|
3261
|
+
* [!] Note that entities are unique per aseid, so this method checks if there's at least one entity of the provided type in the scope
|
|
3262
|
+
*/
|
|
3263
|
+
entity: A_TYPES__Entity_Constructor<T>): boolean;
|
|
3264
|
+
hasFlat<T extends A_Fragment>(
|
|
3265
|
+
/**
|
|
3266
|
+
* Provide a fragment constructor to check if it's available in the scope
|
|
3267
|
+
*/
|
|
3268
|
+
fragment: A_TYPES__Fragment_Constructor<T>): boolean;
|
|
3269
|
+
hasFlat<T extends A_Error>(
|
|
3270
|
+
/**
|
|
3271
|
+
* Provide an error constructor to check if it's available in the scope
|
|
3272
|
+
*/
|
|
3273
|
+
error: A_TYPES__Error_Constructor<T>): boolean;
|
|
3274
|
+
hasFlat(
|
|
3275
|
+
/**
|
|
3276
|
+
* Provide a string to check if a component, entity or fragment with the provided name is available in the scope
|
|
3277
|
+
*/
|
|
3278
|
+
constructor: string): boolean;
|
|
3279
|
+
/**
|
|
3280
|
+
* Allows to resolve a specific dependency
|
|
3281
|
+
*
|
|
3282
|
+
* @param dependency
|
|
3283
|
+
* @returns
|
|
3284
|
+
*/
|
|
3285
|
+
resolveDependency<T extends A_TYPES__A_DependencyInjectable>(dependency: A_Dependency<T>): T | Array<T> | undefined;
|
|
3286
|
+
/**
|
|
3287
|
+
* Allows to retrieve the constructor of the component or entity by its name
|
|
3288
|
+
*
|
|
3289
|
+
* [!] Notes:
|
|
3290
|
+
* - In case of search for A-Entity please ensure that provided string corresponds to the static entity property of the class. [!] By default it's the kebab-case of the class name
|
|
3291
|
+
* - In case of search for A_Component please ensure that provided string corresponds to the class name in PascalCase
|
|
3292
|
+
*
|
|
3293
|
+
* @param name
|
|
3294
|
+
* @returns
|
|
3295
|
+
*/
|
|
3296
|
+
resolveConstructor<T extends A_Entity>(
|
|
3297
|
+
/**
|
|
3298
|
+
* Provide the entity name or static entity property to retrieve its constructor
|
|
3299
|
+
*/
|
|
3300
|
+
name: string): A_TYPES__Entity_Constructor<T>;
|
|
3301
|
+
resolveConstructor<T extends A_Component>(
|
|
3302
|
+
/**
|
|
3303
|
+
* Provide the component name in PascalCase to retrieve its constructor
|
|
3304
|
+
*/
|
|
3305
|
+
name: string): A_TYPES__Component_Constructor<T>;
|
|
3306
|
+
resolveConstructor<T extends A_Fragment>(
|
|
3307
|
+
/**
|
|
3308
|
+
* Provide the fragment name in PascalCase to retrieve its constructor
|
|
3309
|
+
*/
|
|
3310
|
+
name: string): A_TYPES__Fragment_Constructor<T>;
|
|
3311
|
+
resolveConstructor<T extends A_TYPES__A_DependencyInjectable>(name: string): A_TYPES__Entity_Constructor<T> | A_TYPES__Component_Constructor<T> | A_TYPES__Fragment_Constructor<T> | undefined;
|
|
3312
|
+
/**
|
|
3313
|
+
* This method should resolve all instances of the components, or entities within the scope, by provided parent class
|
|
3314
|
+
* So in case of providing a base class it should return all instances that extends this base class
|
|
3315
|
+
*
|
|
3316
|
+
* [!] Applicable for the current scope ONLY, no parent scopes are checked
|
|
3317
|
+
*
|
|
3318
|
+
* @param component
|
|
3319
|
+
*/
|
|
3320
|
+
resolveAll<T extends A_Component>(
|
|
3321
|
+
/**
|
|
3322
|
+
* Provide a component constructor to resolve its instance from the scope
|
|
3323
|
+
*/
|
|
3324
|
+
component: A_TYPES__Component_Constructor<T>): Array<T>;
|
|
3325
|
+
resolveAll<T extends A_Fragment>(
|
|
3326
|
+
/**
|
|
3327
|
+
* Provide a fragment constructor to resolve its instance from the scope
|
|
3328
|
+
*/
|
|
3329
|
+
fragment: A_TYPES__Fragment_Constructor<T>): Array<T>;
|
|
3330
|
+
resolveAll<T extends A_Entity>(
|
|
3331
|
+
/**
|
|
3332
|
+
* Provide an entity constructor to resolve its instance or an array of instances from the scope
|
|
3333
|
+
*/
|
|
3334
|
+
entity: A_TYPES__Entity_Constructor<T>): Array<T>;
|
|
3335
|
+
resolveAll<T extends A_TYPES__A_DependencyInjectable>(
|
|
3336
|
+
/**
|
|
3337
|
+
* Provide a component, fragment or entity constructor to resolve its instance(s) from the scope
|
|
3338
|
+
*/
|
|
3339
|
+
constructorName: string): Array<T>;
|
|
3340
|
+
resolveAll<T extends A_TYPES__A_DependencyInjectable>(
|
|
3341
|
+
/**
|
|
3342
|
+
* Provide a component, fragment or entity constructor or an array of constructors to resolve its instance(s) from the scope
|
|
3343
|
+
*/
|
|
3344
|
+
ctor: A_TYPES__Ctor<A_TYPES__A_DependencyInjectable> | string): Array<T>;
|
|
3345
|
+
/**
|
|
3346
|
+
* This method should resolve all instances of the components, or entities within the scope, by provided parent class
|
|
3347
|
+
* So in case of providing a base class it should return all instances that extends this base class
|
|
3348
|
+
*
|
|
3349
|
+
* [!] Applicable for the current scope ONLY, no parent scopes are checked
|
|
3350
|
+
*
|
|
3351
|
+
* @param component
|
|
3352
|
+
*/
|
|
3353
|
+
resolveFlatAll<T extends A_Component>(
|
|
3354
|
+
/**
|
|
3355
|
+
* Provide a component constructor to resolve its instance from the scope
|
|
3356
|
+
*/
|
|
3357
|
+
component: A_TYPES__Component_Constructor<T>): Array<T>;
|
|
3358
|
+
resolveFlatAll<T extends A_Fragment>(
|
|
3359
|
+
/**
|
|
3360
|
+
* Provide a fragment constructor to resolve its instance from the scope
|
|
3361
|
+
*/
|
|
3362
|
+
fragment: A_TYPES__Fragment_Constructor<T>): Array<T>;
|
|
3363
|
+
resolveFlatAll<T extends A_Entity>(
|
|
3364
|
+
/**
|
|
3365
|
+
* Provide an entity constructor to resolve its instance or an array of instances from the scope
|
|
3366
|
+
*/
|
|
3367
|
+
entity: A_TYPES__Entity_Constructor<T>): Array<T>;
|
|
3368
|
+
resolveFlatAll<T extends A_TYPES__A_DependencyInjectable>(
|
|
3369
|
+
/**
|
|
3370
|
+
* Provide a component, fragment or entity constructor to resolve its instance(s) from the scope
|
|
3371
|
+
*/
|
|
3372
|
+
constructorName: string): Array<T>;
|
|
3373
|
+
resolveFlatAll<T extends A_TYPES__A_DependencyInjectable>(
|
|
3374
|
+
/**
|
|
3375
|
+
* Provide a component, fragment or entity constructor or an array of constructors to resolve its instance(s) from the scope
|
|
3376
|
+
*/
|
|
3377
|
+
ctor: A_TYPES__Ctor<A_TYPES__A_DependencyInjectable> | string): Array<T>;
|
|
3378
|
+
/**
|
|
3379
|
+
* This method allows to resolve/inject a component, fragment or entity from the scope
|
|
3380
|
+
* Depending on the provided parameters it can resolve:
|
|
3381
|
+
* - A single component/fragment/entity by its constructor or name
|
|
3382
|
+
* - An array of components/fragments/entities by providing an array of constructors
|
|
3383
|
+
* - An entity or an array of entities by providing the entity constructor and query instructions
|
|
3384
|
+
*
|
|
3385
|
+
* @param component
|
|
3386
|
+
* @returns
|
|
3387
|
+
*/
|
|
3388
|
+
resolve<T extends A_TYPES__A_DependencyInjectable>(
|
|
3389
|
+
/**
|
|
3390
|
+
* Provide a component constructor to resolve its instance from the scope
|
|
3391
|
+
*/
|
|
3392
|
+
component: A_TYPES__Ctor<T>): T | undefined;
|
|
3393
|
+
resolve<T extends A_TYPES__A_DependencyInjectable>(
|
|
3394
|
+
/**
|
|
3395
|
+
* Provide a target dependency to resolve its instance from the scope
|
|
3396
|
+
*
|
|
3397
|
+
* [!] In this case its possible to provide a custom resolution strategy via A_Dependency options
|
|
3398
|
+
*/
|
|
3399
|
+
dependency: A_Dependency<T>): T | Array<T> | undefined;
|
|
3400
|
+
resolve<T extends A_TYPES__A_DependencyInjectable>(
|
|
3401
|
+
/**
|
|
3402
|
+
* Provide a component constructor to resolve its instance from the scope
|
|
3403
|
+
*/
|
|
3404
|
+
component: string): T | Array<T> | undefined;
|
|
3405
|
+
/**
|
|
3406
|
+
* This method allows to resolve/inject a component, fragment or entity from the scope
|
|
3407
|
+
* Depending on the provided parameters it can resolve:
|
|
3408
|
+
* - A single component/fragment/entity by its constructor or name
|
|
3409
|
+
* - An array of components/fragments/entities by providing an array of constructors
|
|
3410
|
+
* - An entity or an array of entities by providing the entity constructor and query instructions
|
|
3411
|
+
*
|
|
3412
|
+
* @param component
|
|
3413
|
+
* @returns
|
|
3414
|
+
*/
|
|
3415
|
+
resolveOnce<T extends A_Component>(
|
|
3416
|
+
/**
|
|
3417
|
+
* Provide a component constructor to resolve its instance from the scope
|
|
3418
|
+
*/
|
|
3419
|
+
component: A_TYPES__Component_Constructor<T>): T | undefined;
|
|
3420
|
+
resolveOnce<T extends A_Fragment>(
|
|
3421
|
+
/**
|
|
3422
|
+
* Provide a fragment constructor to resolve its instance from the scope
|
|
3423
|
+
*/
|
|
3424
|
+
fragment: A_TYPES__Fragment_Constructor<T>): T | undefined;
|
|
3425
|
+
resolveOnce<T extends A_Entity>(
|
|
3426
|
+
/**
|
|
3427
|
+
* Provide an entity constructor to resolve its instance or an array of instances from the scope
|
|
3428
|
+
*/
|
|
3429
|
+
entity: A_TYPES__Entity_Constructor<T>): T | undefined;
|
|
3430
|
+
resolveOnce<T extends A_Scope>(
|
|
3431
|
+
/**
|
|
3432
|
+
* Uses only in case of resolving a single entity
|
|
3433
|
+
*
|
|
3434
|
+
* Provide an entity constructor to resolve its instance from the scope
|
|
3435
|
+
*/
|
|
3436
|
+
scope: A_TYPES__Scope_Constructor<T>): T | undefined;
|
|
3437
|
+
resolveOnce<T extends A_Error>(
|
|
3438
|
+
/**
|
|
3439
|
+
* Uses only in case of resolving a single entity
|
|
3440
|
+
*
|
|
3441
|
+
* Provide an entity constructor to resolve its instance from the scope
|
|
3442
|
+
*/
|
|
3443
|
+
error: A_TYPES__Error_Constructor<T>): T | undefined;
|
|
3444
|
+
resolveOnce<T extends A_TYPES__A_DependencyInjectable>(
|
|
3445
|
+
/**
|
|
3446
|
+
* Provide a component, fragment or entity constructor to resolve its instance(s) from the scope
|
|
3447
|
+
*/
|
|
3448
|
+
constructorName: string): T | undefined;
|
|
3449
|
+
resolveOnce<T extends A_TYPES__A_DependencyInjectable>(
|
|
3450
|
+
/**
|
|
3451
|
+
* Provide a component, fragment or entity constructor or an array of constructors to resolve its instance(s) from the scope
|
|
3452
|
+
*/
|
|
3453
|
+
ctor: A_TYPES__Ctor<A_TYPES__A_DependencyInjectable> | string): T | undefined;
|
|
3454
|
+
/**
|
|
3455
|
+
* This polymorphic method allows to resolve/inject a component, fragment or entity from the scope
|
|
3456
|
+
* Depending on the provided parameters it can resolve:
|
|
3457
|
+
* - A single component/fragment/entity by its constructor or name
|
|
3458
|
+
* - An array of components/fragments/entities by providing an array of constructors
|
|
3459
|
+
* - An entity or an array of entities by providing the entity constructor and query instructions
|
|
3460
|
+
*
|
|
3461
|
+
* [!] Applicable for the current scope ONLY, no parent scopes are checked
|
|
3462
|
+
*
|
|
3463
|
+
* @param component
|
|
3464
|
+
*/
|
|
3465
|
+
resolveFlat<T extends A_Component>(
|
|
3466
|
+
/**
|
|
3467
|
+
* Provide a component constructor to resolve its instance from the scope
|
|
3468
|
+
*/
|
|
3469
|
+
component: A_TYPES__Component_Constructor<T>): T | undefined;
|
|
3470
|
+
resolveFlat<T extends A_Fragment>(
|
|
3471
|
+
/**
|
|
3472
|
+
* Provide a fragment constructor to resolve its instance from the scope
|
|
3473
|
+
*/
|
|
3474
|
+
fragment: A_TYPES__Fragment_Constructor<T>): T | undefined;
|
|
3475
|
+
resolveFlat<T extends A_Entity>(
|
|
3476
|
+
/**
|
|
3477
|
+
* Provide an entity constructor to resolve its instance or an array of instances from the scope
|
|
3478
|
+
*/
|
|
3479
|
+
entity: A_TYPES__Entity_Constructor<T>): T | undefined;
|
|
3480
|
+
resolveFlat<T extends A_Scope>(
|
|
3481
|
+
/**
|
|
3482
|
+
* Uses only in case of resolving a single entity
|
|
3483
|
+
*
|
|
3484
|
+
* Provide an entity constructor to resolve its instance from the scope
|
|
3485
|
+
*/
|
|
3486
|
+
scope: A_TYPES__Scope_Constructor<T>): T | undefined;
|
|
3487
|
+
resolveFlat<T extends A_Error>(
|
|
3488
|
+
/**
|
|
3489
|
+
* Uses only in case of resolving a single entity
|
|
3490
|
+
*
|
|
3491
|
+
* Provide an entity constructor to resolve its instance from the scope
|
|
3492
|
+
*/
|
|
3493
|
+
error: A_TYPES__Error_Constructor<T>): T | undefined;
|
|
3494
|
+
resolveFlat<T extends A_TYPES__A_DependencyInjectable>(
|
|
3495
|
+
/**
|
|
3496
|
+
* Provide a component, fragment or entity constructor to resolve its instance(s) from the scope
|
|
3497
|
+
*/
|
|
3498
|
+
constructorName: string): T | undefined;
|
|
3499
|
+
resolveFlat<T extends A_TYPES__A_DependencyInjectable>(
|
|
3500
|
+
/**
|
|
3501
|
+
* Provide a component, fragment or entity constructor or an array of constructors to resolve its instance(s) from the scope
|
|
3502
|
+
*/
|
|
3503
|
+
ctor: A_TYPES__Ctor<A_TYPES__A_DependencyInjectable>): T | undefined;
|
|
3504
|
+
/**
|
|
3505
|
+
* Resolves a component, fragment or entity from the scope without checking parent scopes
|
|
3506
|
+
*
|
|
3507
|
+
* @param component
|
|
3508
|
+
* @param instructions
|
|
3509
|
+
*/
|
|
3510
|
+
resolveFlatOnce<T extends A_TYPES__A_DependencyInjectable>(component: A_TYPES__Ctor<A_TYPES__A_DependencyInjectable> | string): T | undefined;
|
|
3511
|
+
/**
|
|
3512
|
+
* This method is used internally to resolve a component, fragment or entity by its constructor name
|
|
3513
|
+
*
|
|
3514
|
+
* [!] Note that this method checks for the component, fragment or entity in the current scope and all parent scopes
|
|
3515
|
+
* [!!] Note: No parent scopes are checked
|
|
3516
|
+
*
|
|
3517
|
+
* @param name - name of the component, fragment or entity to resolve (constructor name for components and fragments, static entity property for entities, static code property for commands)
|
|
3518
|
+
* @returns
|
|
3519
|
+
*/
|
|
3520
|
+
private resolveByName;
|
|
3521
|
+
/**
|
|
3522
|
+
* Resolves the issuer of the scope by provided constructor
|
|
3523
|
+
*
|
|
3524
|
+
* [!] Note that this method checks ONLY for the direct issuer of the scope
|
|
3525
|
+
* [!!] No parent scopes are checked
|
|
3526
|
+
*
|
|
3527
|
+
*
|
|
3528
|
+
* @param ctor
|
|
3529
|
+
* @returns
|
|
3530
|
+
*/
|
|
3531
|
+
private resolveIssuer;
|
|
3532
|
+
/**
|
|
3533
|
+
* This method is used internally to resolve a single entity from the scope based on the provided instructions
|
|
3534
|
+
*
|
|
3535
|
+
* [!] Note that this method can return either a single entity or an array of entities depending on the instructions provided
|
|
3536
|
+
* [!!] Note: No parent scopes are checked
|
|
3537
|
+
*
|
|
3538
|
+
* @param entity
|
|
3539
|
+
* @param instructions
|
|
3540
|
+
* @returns
|
|
3541
|
+
*/
|
|
3542
|
+
private resolveEntity;
|
|
3543
|
+
/**
|
|
3544
|
+
* This method is used internally to resolve a single error from the scope
|
|
3545
|
+
*
|
|
3546
|
+
* [!] Note that errors are singleton instances within the scope
|
|
3547
|
+
* [!!] No parent scopes are checked
|
|
3548
|
+
*
|
|
3549
|
+
* @param error
|
|
3550
|
+
* @returns
|
|
3551
|
+
*/
|
|
3552
|
+
private resolveError;
|
|
3553
|
+
/**
|
|
3554
|
+
* This method is used internally to resolve a single fragment from the scope
|
|
3555
|
+
*
|
|
3556
|
+
* [!] Note that this method checks for the fragment in the current scope and all parent scopes
|
|
3557
|
+
*
|
|
3558
|
+
* @param fragment
|
|
3559
|
+
* @returns
|
|
3560
|
+
*/
|
|
3561
|
+
private resolveFragment;
|
|
3562
|
+
/**
|
|
3563
|
+
* This method is used internally to resolve a single scope from the current scope
|
|
3564
|
+
*
|
|
3565
|
+
* @param scope
|
|
3566
|
+
* @returns
|
|
3567
|
+
*/
|
|
3568
|
+
private resolveScope;
|
|
3569
|
+
/**
|
|
3570
|
+
* This method is used internally to resolve a single component from the scope
|
|
3571
|
+
*
|
|
3572
|
+
* [!!] Note: No parent scopes are checked
|
|
3573
|
+
*
|
|
3574
|
+
* @param component
|
|
3575
|
+
* @returns
|
|
3576
|
+
*/
|
|
3577
|
+
private resolveComponent;
|
|
3578
|
+
/**
|
|
3579
|
+
* This method is used to register the component in the scope
|
|
3580
|
+
*
|
|
3581
|
+
* @param fragment
|
|
3582
|
+
*/
|
|
3583
|
+
register<T extends A_Component>(
|
|
3584
|
+
/**
|
|
3585
|
+
* Provide a component constructor to register it in the scope
|
|
3586
|
+
*/
|
|
3587
|
+
component: A_TYPES__Component_Constructor<T>): void;
|
|
3588
|
+
register<T extends A_Component>(
|
|
3589
|
+
/**
|
|
3590
|
+
* Provide a command instance to register it in the scope
|
|
3591
|
+
*/
|
|
3592
|
+
component: T): void;
|
|
3593
|
+
register<T extends A_Error>(
|
|
3594
|
+
/**
|
|
3595
|
+
* Provide an error constructor to register it in the scope
|
|
3596
|
+
*/
|
|
3597
|
+
error: A_TYPES__Error_Constructor<T>): void;
|
|
3598
|
+
register<T extends A_Error>(
|
|
3599
|
+
/**
|
|
3600
|
+
* Provide an error instance to register it in the scope
|
|
3601
|
+
*/
|
|
3602
|
+
error: T): void;
|
|
3603
|
+
register<T extends A_Fragment>(
|
|
3604
|
+
/**
|
|
3605
|
+
* Provide a command instance to register it in the scope
|
|
3606
|
+
*/
|
|
3607
|
+
fragment: A_TYPES__Fragment_Constructor<T>): void;
|
|
3608
|
+
register<T extends A_Fragment>(
|
|
3609
|
+
/**
|
|
3610
|
+
* Provide a fragment instance to register it in the scope
|
|
3611
|
+
*/
|
|
3612
|
+
fragment: T): void;
|
|
3613
|
+
register<T extends A_Entity>(
|
|
3614
|
+
/**
|
|
3615
|
+
* Provide an entity constructor to register it in the scope
|
|
3616
|
+
*/
|
|
3617
|
+
entity: A_TYPES__Entity_Constructor<T>): void;
|
|
3618
|
+
register<T extends A_Entity>(
|
|
3619
|
+
/**
|
|
3620
|
+
* Provide an entity instance to register it in the scope
|
|
3621
|
+
*/
|
|
3622
|
+
entity: T): void;
|
|
3623
|
+
register<T extends A_TYPES__A_DependencyInjectable>(
|
|
3624
|
+
/**
|
|
3625
|
+
* Provide an entity instance to register it in the scope
|
|
3626
|
+
*/
|
|
3627
|
+
entity: T): void;
|
|
3628
|
+
/**
|
|
3629
|
+
* This method is used to deregister the component from the scope
|
|
3630
|
+
*
|
|
3631
|
+
* @param fragment
|
|
3632
|
+
*/
|
|
3633
|
+
deregister<T extends A_Component>(
|
|
3634
|
+
/**
|
|
3635
|
+
* Provide a component constructor to deregister it in the scope
|
|
3636
|
+
*/
|
|
3637
|
+
component: A_TYPES__Component_Constructor<T>): void;
|
|
3638
|
+
deregister(
|
|
3639
|
+
/**
|
|
3640
|
+
* Provide a command instance to deregister it in the scope
|
|
3641
|
+
*/
|
|
3642
|
+
component: A_Component): void;
|
|
3643
|
+
deregister<T extends A_Error>(
|
|
3644
|
+
/**
|
|
3645
|
+
* Provide an error constructor to deregister it in the scope
|
|
3646
|
+
*/
|
|
3647
|
+
error: A_TYPES__Error_Constructor<T>): void;
|
|
3648
|
+
deregister(
|
|
3649
|
+
/**
|
|
3650
|
+
* Provide an error instance to deregister it in the scope
|
|
3651
|
+
*/
|
|
3652
|
+
error: A_Error): void;
|
|
3653
|
+
deregister<T extends A_Fragment>(
|
|
3654
|
+
/**
|
|
3655
|
+
* Provide a command instance to deregister it in the scope
|
|
3656
|
+
*/
|
|
3657
|
+
fragment: A_TYPES__Fragment_Constructor<T>): void;
|
|
3658
|
+
deregister(
|
|
3659
|
+
/**
|
|
3660
|
+
* Provide a fragment instance to deregister it in the scope
|
|
3661
|
+
*/
|
|
3662
|
+
fragment: A_Fragment): void;
|
|
3663
|
+
deregister<T extends A_Entity>(
|
|
3664
|
+
/**
|
|
3665
|
+
* Provide an entity constructor to deregister it in the scope
|
|
3666
|
+
*/
|
|
3667
|
+
entity: A_TYPES__Entity_Constructor<T>): void;
|
|
3668
|
+
deregister(
|
|
3669
|
+
/**
|
|
3670
|
+
* Provide an entity instance to deregister it in the scope
|
|
3671
|
+
*/
|
|
3672
|
+
entity: A_Entity): void;
|
|
3673
|
+
/**
|
|
3674
|
+
* This method is useful when you want to serialize the scope to JSON
|
|
3675
|
+
*
|
|
3676
|
+
* [!] Note this is not a deep serialization, only the fragments are serialized
|
|
3677
|
+
* [!] Fragments are a storage for information which is relevant to the scope
|
|
3678
|
+
*
|
|
3679
|
+
* @returns
|
|
3680
|
+
*/
|
|
3681
|
+
toJSON(): Record<string, any>;
|
|
3682
|
+
/**
|
|
3683
|
+
* Type guard to check if the constructor is of type A_Component and is allowed in the scope
|
|
3684
|
+
*
|
|
3685
|
+
* @param ctor
|
|
3686
|
+
* @returns
|
|
3687
|
+
*/
|
|
3688
|
+
protected isAllowedComponent(ctor: unknown): ctor is _ComponentType[number];
|
|
3689
|
+
/**
|
|
3690
|
+
* Type guard to check if the constructor is of type A_Entity and is allowed in the scope
|
|
3691
|
+
*
|
|
3692
|
+
* @param ctor
|
|
3693
|
+
* @returns
|
|
3694
|
+
*/
|
|
3695
|
+
protected isAllowedEntity(ctor: unknown): ctor is A_TYPES__Entity_Constructor<_EntityType[number]>;
|
|
3696
|
+
/**
|
|
3697
|
+
* Type guard to check if the constructor is of type A_Fragment and is allowed in the scope
|
|
3698
|
+
*
|
|
3699
|
+
* @param ctor
|
|
3700
|
+
* @returns
|
|
3701
|
+
*/
|
|
3702
|
+
protected isAllowedFragment(ctor: unknown): ctor is A_TYPES__Fragment_Constructor<_FragmentType[number]>;
|
|
3703
|
+
/**
|
|
3704
|
+
* Type guard to check if the constructor is of type A_Error and is allowed in the scope
|
|
3705
|
+
*
|
|
3706
|
+
* @param ctor
|
|
3707
|
+
* @returns
|
|
3708
|
+
*/
|
|
3709
|
+
protected isAllowedError(ctor: unknown): ctor is A_TYPES__Error_Constructor<_ErrorType[number]>;
|
|
3710
|
+
/**
|
|
3711
|
+
* This method is used to check if the scope is inherited from another scope
|
|
3712
|
+
*
|
|
3713
|
+
* @param scope
|
|
3714
|
+
* @returns
|
|
3715
|
+
*/
|
|
3716
|
+
isInheritedFrom(scope: A_Scope): boolean;
|
|
3717
|
+
/**
|
|
3718
|
+
* Helper method to check circular inheritance
|
|
3719
|
+
* Should return a full sequence of inheritance for logging purposes
|
|
3720
|
+
*
|
|
3721
|
+
* @param scope
|
|
3722
|
+
* @returns
|
|
3723
|
+
*/
|
|
3724
|
+
checkCircularInheritance(scope: A_Scope): Array<string> | false;
|
|
3725
|
+
/**
|
|
3726
|
+
* Helper method to print the inheritance chain of the scope
|
|
3727
|
+
*/
|
|
3728
|
+
printInheritanceChain(): void;
|
|
3729
|
+
}
|
|
3
3730
|
|
|
4
|
-
declare
|
|
3731
|
+
declare class A_ScopeError extends A_Error {
|
|
3732
|
+
static readonly InitializationError = "A-Scope Initialization Error";
|
|
3733
|
+
static readonly ConstructorError = "Unable to construct A-Scope instance";
|
|
3734
|
+
static readonly ResolutionError = "A-Scope Resolution Error";
|
|
3735
|
+
static readonly RegistrationError = "A-Scope Registration Error";
|
|
3736
|
+
static readonly CircularInheritanceError = "A-Scope Circular Inheritance Error";
|
|
3737
|
+
static readonly CircularImportError = "A-Scope Circular Import Error";
|
|
3738
|
+
static readonly DeregistrationError = "A-Scope Deregistration Error";
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3741
|
+
/**
|
|
3742
|
+
* A-Component is a primary "extendable" object in the system
|
|
3743
|
+
* A unique combination of Components creates completely new functionality
|
|
3744
|
+
*
|
|
3745
|
+
* The most important thing is that A-Component is STATELESS, it means that it doesn't store any state in itself
|
|
3746
|
+
*
|
|
3747
|
+
*
|
|
3748
|
+
* [!] Every A-Component is a singleton, so if you need to create multiple instances of the same logic - use A-Container
|
|
3749
|
+
* [!] So one scope can have only one instance of the same A-Component
|
|
3750
|
+
* [!] Every A-Component can be extended by features and extensions
|
|
3751
|
+
* [!] ONLY A-Component can have A-Feature extensions
|
|
3752
|
+
*
|
|
3753
|
+
*/
|
|
3754
|
+
declare class A_Component {
|
|
5
3755
|
/**
|
|
6
|
-
*
|
|
3756
|
+
* Calls the feature with the given name in the given scope
|
|
7
3757
|
*
|
|
8
|
-
*
|
|
3758
|
+
* [!] Note: This method creates a new instance of the feature every time it is called
|
|
9
3759
|
*
|
|
10
|
-
*
|
|
3760
|
+
* @param feature - the name of the feature to call
|
|
3761
|
+
* @param scope - the scope in which to call the feature
|
|
3762
|
+
* @returns - void
|
|
11
3763
|
*/
|
|
12
|
-
|
|
3764
|
+
call(
|
|
13
3765
|
/**
|
|
14
|
-
*
|
|
3766
|
+
* Name of the feature to call
|
|
3767
|
+
*/
|
|
3768
|
+
feature: string,
|
|
3769
|
+
/**
|
|
3770
|
+
* Scope in which the feature will be executed
|
|
3771
|
+
*/
|
|
3772
|
+
scope?: A_Scope): Promise<any> | void;
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3775
|
+
declare enum A_TYPES__ComponentMetaKey {
|
|
3776
|
+
EXTENSIONS = "a-component-extensions",
|
|
3777
|
+
FEATURES = "a-component-features",
|
|
3778
|
+
INJECTIONS = "a-component-injections",
|
|
3779
|
+
ABSTRACTIONS = "a-component-abstractions"
|
|
3780
|
+
}
|
|
3781
|
+
|
|
3782
|
+
/**
|
|
3783
|
+
* Component constructor type
|
|
3784
|
+
* Uses the generic type T to specify the type of the component
|
|
3785
|
+
*/
|
|
3786
|
+
type A_TYPES__Component_Constructor<T = A_Component> = A_TYPES__Ctor<T>;
|
|
3787
|
+
/**
|
|
3788
|
+
* Component initialization type
|
|
3789
|
+
*/
|
|
3790
|
+
type A_TYPES__Component_Init = any;
|
|
3791
|
+
/**
|
|
3792
|
+
* Component serialized type
|
|
3793
|
+
*/
|
|
3794
|
+
type A_TYPES__Component_Serialized = {
|
|
3795
|
+
/**
|
|
3796
|
+
* The ASEID of the component
|
|
3797
|
+
*/
|
|
3798
|
+
aseid: string;
|
|
3799
|
+
};
|
|
3800
|
+
/**
|
|
3801
|
+
* Component meta type
|
|
3802
|
+
*/
|
|
3803
|
+
type A_TYPES__ComponentMeta = {
|
|
3804
|
+
/**
|
|
3805
|
+
* Extensions applied to the component per handler
|
|
3806
|
+
*/
|
|
3807
|
+
[A_TYPES__ComponentMetaKey.EXTENSIONS]: A_Meta<{
|
|
3808
|
+
/**
|
|
3809
|
+
* Where Key the regexp for what to apply the extension
|
|
3810
|
+
* A set of container names or a wildcard, or a regexp
|
|
3811
|
+
*
|
|
3812
|
+
*
|
|
3813
|
+
* Where value is the extension instructions
|
|
3814
|
+
*/
|
|
3815
|
+
[Key: string]: A_TYPES__FeatureExtendDecoratorMeta[];
|
|
3816
|
+
}>;
|
|
3817
|
+
/**
|
|
3818
|
+
* Features defined on the component per handler
|
|
3819
|
+
*/
|
|
3820
|
+
[A_TYPES__ComponentMetaKey.FEATURES]: A_Meta<{
|
|
3821
|
+
/**
|
|
3822
|
+
* Where Key is the name of the feature
|
|
3823
|
+
*
|
|
3824
|
+
* Where value is the list of features
|
|
3825
|
+
*/
|
|
3826
|
+
[Key: string]: A_TYPES__FeatureDefineDecoratorMeta;
|
|
3827
|
+
}>;
|
|
3828
|
+
/**
|
|
3829
|
+
* Injections defined on the component per handler
|
|
3830
|
+
*/
|
|
3831
|
+
[A_TYPES__ComponentMetaKey.INJECTIONS]: A_Meta<{
|
|
3832
|
+
/**
|
|
3833
|
+
* Where Key is the name of the injection
|
|
3834
|
+
*
|
|
3835
|
+
* Where value is the list of injections
|
|
3836
|
+
*/
|
|
3837
|
+
[Key: string]: A_TYPES__A_InjectDecorator_Meta;
|
|
3838
|
+
}>;
|
|
3839
|
+
/**
|
|
3840
|
+
* Abstractions extended by the component per handler
|
|
3841
|
+
*/
|
|
3842
|
+
[A_TYPES__ComponentMetaKey.ABSTRACTIONS]: A_Meta<{
|
|
3843
|
+
/**
|
|
3844
|
+
* Where Key is the name of the stage
|
|
3845
|
+
*
|
|
3846
|
+
* Where value is the list of injections
|
|
3847
|
+
*/
|
|
3848
|
+
[Key: string]: A_TYPES__ConceptAbstraction[];
|
|
3849
|
+
}>;
|
|
3850
|
+
};
|
|
3851
|
+
type A_TYPES__ComponentMetaExtension = A_TYPES__FeatureExtendDecoratorMeta;
|
|
3852
|
+
|
|
3853
|
+
declare class A_ComponentMeta<T extends A_TYPES__ComponentMeta = A_TYPES__ComponentMeta> extends A_Meta<T> {
|
|
3854
|
+
/**
|
|
3855
|
+
* Allows to get all the injections for a given handler
|
|
15
3856
|
*
|
|
16
|
-
*
|
|
3857
|
+
* @param handler
|
|
3858
|
+
* @returns
|
|
3859
|
+
*/
|
|
3860
|
+
injections(handler: string): A_TYPES__A_InjectDecorator_Meta;
|
|
3861
|
+
/**
|
|
3862
|
+
* Allows to get all the extensions for a given feature
|
|
17
3863
|
*
|
|
18
|
-
*
|
|
3864
|
+
* @param feature
|
|
3865
|
+
* @returns
|
|
19
3866
|
*/
|
|
20
|
-
|
|
3867
|
+
extensions(feature: string): A_TYPES__ComponentMetaExtension[];
|
|
21
3868
|
/**
|
|
22
|
-
*
|
|
3869
|
+
* Returns all features defined in the Component
|
|
3870
|
+
*
|
|
3871
|
+
* @returns
|
|
23
3872
|
*/
|
|
24
|
-
|
|
3873
|
+
features(): Array<A_TYPES__FeatureDefineDecoratorMeta>;
|
|
25
3874
|
/**
|
|
26
|
-
*
|
|
3875
|
+
* Returns a set of instructions to run proper methods in Component during A-Concept Stage
|
|
3876
|
+
*
|
|
3877
|
+
* @param stage
|
|
3878
|
+
* @returns
|
|
27
3879
|
*/
|
|
28
|
-
|
|
3880
|
+
abstractions(abstraction: any): A_TYPES__ConceptAbstractionMeta[];
|
|
3881
|
+
}
|
|
3882
|
+
|
|
3883
|
+
/**
|
|
3884
|
+
* Abstraction constructor type
|
|
3885
|
+
* Uses the generic type T to specify the type of the abstraction
|
|
3886
|
+
*/
|
|
3887
|
+
type A_TYPES__Abstraction_Constructor<T = A_Abstraction> = A_TYPES__Ctor<T>;
|
|
3888
|
+
/**
|
|
3889
|
+
* Abstraction initialization type
|
|
3890
|
+
*/
|
|
3891
|
+
type A_TYPES__Abstraction_Init = {
|
|
29
3892
|
/**
|
|
30
|
-
*
|
|
31
|
-
* [!] Automatically set by A-Concept when the application starts
|
|
3893
|
+
* Name of the A-Abstraction
|
|
32
3894
|
*/
|
|
33
|
-
|
|
3895
|
+
name: A_TYPES__ConceptAbstractions;
|
|
34
3896
|
/**
|
|
35
|
-
*
|
|
3897
|
+
* Features that compose the A-Abstraction
|
|
36
3898
|
*/
|
|
37
|
-
|
|
3899
|
+
containers: Array<A_Container>;
|
|
38
3900
|
};
|
|
39
|
-
|
|
40
|
-
|
|
3901
|
+
/**
|
|
3902
|
+
* Abstraction serialized type
|
|
3903
|
+
*/
|
|
3904
|
+
type A_TYPES__Abstraction_Serialized = {
|
|
3905
|
+
/**
|
|
3906
|
+
* The ASEID of the abstraction
|
|
3907
|
+
*/
|
|
3908
|
+
aseid: string;
|
|
3909
|
+
};
|
|
3910
|
+
/**
|
|
3911
|
+
* Components that can extend Abstractions
|
|
3912
|
+
*/
|
|
3913
|
+
type A_TYPES__AbstractionAvailableComponents = A_Component | A_Container;
|
|
3914
|
+
type A_TYPES__AbstractionDecoratorDescriptor = TypedPropertyDescriptor<() => any> | TypedPropertyDescriptor<(...args: any[]) => any> | TypedPropertyDescriptor<(...args: any[]) => Promise<any>> | TypedPropertyDescriptor<() => Promise<any>>;
|
|
3915
|
+
type A_TYPES__AbstractionDecoratorConfig = A_TYPES__FeatureExtendDecoratorConfig;
|
|
3916
|
+
|
|
3917
|
+
/**
|
|
3918
|
+
* A-Abstraction Extend decorator allows to extends behavior of each concept abstraction execution.
|
|
3919
|
+
* In case some components or containers requires to extend the behavior of the abstraction like 'start', 'build' or 'deploy'
|
|
3920
|
+
* for example, this decorator allows to do so.
|
|
3921
|
+
*
|
|
3922
|
+
* @param name - abstraction name
|
|
3923
|
+
* @param config - configuration of the abstraction extension
|
|
3924
|
+
* @returns
|
|
3925
|
+
*/
|
|
3926
|
+
declare function A_Abstraction_Extend(
|
|
3927
|
+
/**
|
|
3928
|
+
* Name of the Concept Abstraction to extend
|
|
3929
|
+
*/
|
|
3930
|
+
name: A_TYPES__ConceptAbstractions,
|
|
3931
|
+
/**
|
|
3932
|
+
* Configuration of the Abstraction Extension
|
|
3933
|
+
*
|
|
3934
|
+
*/
|
|
3935
|
+
config?: Partial<A_TYPES__AbstractionDecoratorConfig>): (target: A_Container | A_Component, propertyKey: string, descriptor: A_TYPES__AbstractionDecoratorDescriptor) => void;
|
|
3936
|
+
|
|
3937
|
+
declare class A_Abstraction {
|
|
3938
|
+
/**
|
|
3939
|
+
* The name of the Abstraction e.g. 'deploy', 'start', 'test', etc.
|
|
3940
|
+
*/
|
|
3941
|
+
protected _name: A_TYPES__ConceptAbstractions;
|
|
3942
|
+
/**
|
|
3943
|
+
* List of features that are part of this Abstraction
|
|
3944
|
+
*/
|
|
3945
|
+
protected _features: A_Feature[];
|
|
3946
|
+
/**
|
|
3947
|
+
* The Feature currently being processed
|
|
3948
|
+
*/
|
|
3949
|
+
protected _current?: A_Feature;
|
|
3950
|
+
/**
|
|
3951
|
+
* Actual Index of the current Feature being processed
|
|
3952
|
+
*/
|
|
3953
|
+
protected _index: number;
|
|
3954
|
+
/**
|
|
3955
|
+
* Allows to extends A-Abstraction with additional methods
|
|
3956
|
+
*/
|
|
3957
|
+
static get Extend(): typeof A_Abstraction_Extend;
|
|
3958
|
+
/**
|
|
3959
|
+
* A-Abstraction is an object that is common for any application.
|
|
3960
|
+
* By providing components and creating abstraction extensions it's possible to create a unique behavior of the whole solution.
|
|
3961
|
+
*
|
|
3962
|
+
* Every application has basic abstractions like 'start', 'stop', 'deploy', 'test', etc.
|
|
3963
|
+
* They can be easily extended with additional logic from both containers and components.
|
|
3964
|
+
*
|
|
3965
|
+
*
|
|
3966
|
+
* @param params
|
|
3967
|
+
*/
|
|
3968
|
+
constructor(
|
|
3969
|
+
/**
|
|
3970
|
+
* Parameters to define the A-Abstraction
|
|
3971
|
+
*/
|
|
3972
|
+
params: A_TYPES__Abstraction_Init);
|
|
3973
|
+
/**
|
|
3974
|
+
* Returns the name of the Abstraction
|
|
3975
|
+
*/
|
|
3976
|
+
get name(): string;
|
|
3977
|
+
/**
|
|
3978
|
+
* Returns the current Feature being processed
|
|
3979
|
+
*/
|
|
3980
|
+
get feature(): A_Feature | undefined;
|
|
3981
|
+
/**
|
|
3982
|
+
* This method checks if the A-Feature is done
|
|
3983
|
+
*
|
|
3984
|
+
* @returns
|
|
3985
|
+
*/
|
|
3986
|
+
get isDone(): boolean;
|
|
3987
|
+
[Symbol.iterator](): Iterator<A_Feature, any>;
|
|
3988
|
+
/**
|
|
3989
|
+
* This method moves the Abstraction processing to the next Feature in the list
|
|
3990
|
+
*
|
|
3991
|
+
* @param stage
|
|
3992
|
+
*/
|
|
3993
|
+
next(stage: any): void;
|
|
3994
|
+
/**
|
|
3995
|
+
* Allows to process all stages of the Abstraction
|
|
3996
|
+
*
|
|
3997
|
+
* @returns
|
|
3998
|
+
*/
|
|
3999
|
+
process(
|
|
4000
|
+
/**
|
|
4001
|
+
* Allows to override the scope in which the Abstraction will be processed
|
|
4002
|
+
*
|
|
4003
|
+
*/
|
|
4004
|
+
scope?: A_Scope): Promise<void>;
|
|
4005
|
+
}
|
|
4006
|
+
|
|
4007
|
+
declare class A_AbstractionError extends A_Error {
|
|
4008
|
+
/**
|
|
4009
|
+
* This error code indicates that there was an issue extending the abstraction execution
|
|
4010
|
+
*/
|
|
4011
|
+
static readonly AbstractionExtensionError = "Unable to extend abstraction execution";
|
|
4012
|
+
}
|
|
4013
|
+
|
|
4014
|
+
type A_TYPES__ContextEnvironment = 'server' | 'browser' | 'mobile' | 'desktop' | 'embedded' | 'unknown';
|
|
4015
|
+
type A_TYPES__FeatureExtendableMeta = A_ContainerMeta | A_ComponentMeta | A_EntityMeta;
|
|
41
4016
|
|
|
42
4017
|
declare class A_Context {
|
|
43
4018
|
/**
|
|
@@ -193,11 +4168,11 @@ declare class A_Context {
|
|
|
193
4168
|
* Get meta for the specific container class by constructor.
|
|
194
4169
|
*/
|
|
195
4170
|
container: A_TYPES__Container_Constructor): T;
|
|
196
|
-
static meta<T extends A_ContainerMeta>(
|
|
4171
|
+
static meta<T extends A_ContainerMeta, S extends A_Container>(
|
|
197
4172
|
/**
|
|
198
4173
|
* Get meta for the specific container instance.
|
|
199
4174
|
*/
|
|
200
|
-
container:
|
|
4175
|
+
container: S): T;
|
|
201
4176
|
static meta<T extends A_EntityMeta>(
|
|
202
4177
|
/**
|
|
203
4178
|
* Get meta for the specific entity class by constructor.
|
|
@@ -213,11 +4188,11 @@ declare class A_Context {
|
|
|
213
4188
|
* Get meta for the specific component class by constructor.
|
|
214
4189
|
*/
|
|
215
4190
|
component: A_TYPES__Component_Constructor): T;
|
|
216
|
-
static meta<T extends A_ComponentMeta>(
|
|
4191
|
+
static meta<T extends A_ComponentMeta, S extends A_Component>(
|
|
217
4192
|
/**
|
|
218
4193
|
* Get meta for the specific component instance.
|
|
219
4194
|
*/
|
|
220
|
-
component:
|
|
4195
|
+
component: S): T;
|
|
221
4196
|
static meta<T extends A_Meta>(
|
|
222
4197
|
/**
|
|
223
4198
|
* Get meta for the specific component class by constructor.
|
|
@@ -455,191 +4430,108 @@ declare class A_ContextError extends A_Error {
|
|
|
455
4430
|
static InvalidDeregisterParameterError: string;
|
|
456
4431
|
}
|
|
457
4432
|
|
|
458
|
-
declare class
|
|
459
|
-
private containers;
|
|
460
|
-
constructor(containers: Array<A_Container>);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
declare class A_EntityError extends A_Error {
|
|
4433
|
+
declare class A_CONCEPT_BASE_ENV {
|
|
464
4434
|
/**
|
|
465
|
-
*
|
|
4435
|
+
* Name of the application
|
|
4436
|
+
*
|
|
4437
|
+
* DEFAULT value is 'a-concept'
|
|
4438
|
+
*
|
|
4439
|
+
* [!] Provided name will be used for all aseids in the application by default
|
|
466
4440
|
*/
|
|
467
|
-
static
|
|
4441
|
+
static get A_CONCEPT_NAME(): string;
|
|
4442
|
+
/**
|
|
4443
|
+
* Root scope of the application
|
|
4444
|
+
*
|
|
4445
|
+
* DEFAULT value is 'root'
|
|
4446
|
+
*
|
|
4447
|
+
* [!] Provided name will be used for all aseids in the application by default
|
|
4448
|
+
*/
|
|
4449
|
+
static get A_CONCEPT_ROOT_SCOPE(): string;
|
|
4450
|
+
/**
|
|
4451
|
+
* Environment of the application e.g. development, production, staging
|
|
4452
|
+
*/
|
|
4453
|
+
static get A_CONCEPT_ENVIRONMENT(): string;
|
|
4454
|
+
/**
|
|
4455
|
+
* Runtime environment of the application e.g. browser, node
|
|
4456
|
+
*/
|
|
4457
|
+
static get A_CONCEPT_RUNTIME_ENVIRONMENT(): A_TYPES__ContextEnvironment;
|
|
4458
|
+
/**
|
|
4459
|
+
* Root folder of the application
|
|
4460
|
+
* [!] Automatically set by A-Concept when the application starts
|
|
4461
|
+
*/
|
|
4462
|
+
static get A_CONCEPT_ROOT_FOLDER(): string;
|
|
4463
|
+
/**
|
|
4464
|
+
* Allows to define a default error description for errors thrown without a description
|
|
4465
|
+
*/
|
|
4466
|
+
static get A_ERROR_DEFAULT_DESCRIPTION(): string;
|
|
4467
|
+
/**
|
|
4468
|
+
* Generic getter for environment variables. This allows to access environment variables dynamically by name. It will return undefined if the variable does not exist.
|
|
4469
|
+
*
|
|
4470
|
+
* @param name
|
|
4471
|
+
* @returns
|
|
4472
|
+
*/
|
|
4473
|
+
static get(name: string): any;
|
|
4474
|
+
/**
|
|
4475
|
+
* Generic setter for environment variables. This allows to set environment variables dynamically by name.
|
|
4476
|
+
*
|
|
4477
|
+
* @param name
|
|
4478
|
+
* @param value
|
|
4479
|
+
*/
|
|
4480
|
+
static set(name: string, value: string): void;
|
|
4481
|
+
/**
|
|
4482
|
+
* This method returns all the environment variables that are available in the application. It combines the variables from process.env and the default environment variables defined in A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY.
|
|
4483
|
+
*
|
|
4484
|
+
* @returns
|
|
4485
|
+
*/
|
|
4486
|
+
static getAll<T extends Record<string, any>>(): T;
|
|
4487
|
+
/**
|
|
4488
|
+
* This method returns all the keys of the environment variables that are available in the application. It combines the keys from process.env and the default environment variables defined in A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY.
|
|
4489
|
+
*
|
|
4490
|
+
* @returns
|
|
4491
|
+
*/
|
|
4492
|
+
static getAllKeys<T extends Array<string>>(): T;
|
|
468
4493
|
}
|
|
469
4494
|
|
|
470
|
-
declare class
|
|
4495
|
+
declare class A_CONCEPT_ENV extends A_CONCEPT_BASE_ENV {
|
|
471
4496
|
/**
|
|
472
|
-
*
|
|
4497
|
+
* Name of the application
|
|
4498
|
+
*
|
|
4499
|
+
* DEFAULT value is 'a-concept'
|
|
4500
|
+
*
|
|
4501
|
+
* [!] Provided name will be used for all aseids in the application by default
|
|
4502
|
+
*/
|
|
4503
|
+
static get A_CONCEPT_NAME(): string;
|
|
4504
|
+
/**
|
|
4505
|
+
* Root scope of the application
|
|
4506
|
+
*
|
|
4507
|
+
* DEFAULT value is 'root'
|
|
4508
|
+
*
|
|
4509
|
+
* [!] Provided name will be used for all aseids in the application by default
|
|
4510
|
+
*/
|
|
4511
|
+
static get A_CONCEPT_ROOT_SCOPE(): string;
|
|
4512
|
+
/**
|
|
4513
|
+
* Environment of the application e.g. development, production, staging
|
|
4514
|
+
*/
|
|
4515
|
+
static get A_CONCEPT_ENVIRONMENT(): string;
|
|
4516
|
+
/**
|
|
4517
|
+
* Runtime environment of the application e.g. browser, node
|
|
4518
|
+
*/
|
|
4519
|
+
static get A_CONCEPT_RUNTIME_ENVIRONMENT(): A_TYPES__ContextEnvironment;
|
|
4520
|
+
/**
|
|
4521
|
+
* Root folder of the application
|
|
4522
|
+
* [!] Automatically set by A-Concept when the application starts
|
|
473
4523
|
*/
|
|
474
|
-
static
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
declare class A_CallerError extends A_Error {
|
|
4524
|
+
static get A_CONCEPT_ROOT_FOLDER(): string;
|
|
478
4525
|
/**
|
|
479
|
-
*
|
|
4526
|
+
* Allows to define a default error description for errors thrown without a description
|
|
480
4527
|
*/
|
|
481
|
-
static
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
* Caller constructor type
|
|
487
|
-
* Uses the generic type T to specify the type of the caller component
|
|
488
|
-
*/
|
|
489
|
-
type A_TYPES__Caller_Constructor<T = A_Caller> = A_TYPES__Ctor<T>;
|
|
490
|
-
/**
|
|
491
|
-
* Caller initialization type
|
|
492
|
-
*/
|
|
493
|
-
type A_TYPES__Caller_Init = {};
|
|
494
|
-
/**
|
|
495
|
-
* Caller serialized type
|
|
496
|
-
*/
|
|
497
|
-
type A_TYPES__Caller_Serialized = {};
|
|
498
|
-
|
|
499
|
-
declare const A_CONSTANTS__ERROR_CODES: {
|
|
500
|
-
readonly UNEXPECTED_ERROR: "A-Error Unexpected Error";
|
|
501
|
-
readonly VALIDATION_ERROR: "A-Error Validation Error";
|
|
502
|
-
};
|
|
503
|
-
declare const A_CONSTANTS__ERROR_DESCRIPTION = "If you see this error please let us know.";
|
|
504
|
-
|
|
505
|
-
declare class ASEID_Error extends A_Error {
|
|
506
|
-
static readonly ASEIDInitializationError = "ASEID Initialization Error";
|
|
507
|
-
static readonly ASEIDValidationError = "ASEID Validation Error";
|
|
508
|
-
}
|
|
509
|
-
|
|
510
|
-
declare class A_ScopeError extends A_Error {
|
|
511
|
-
static readonly InitializationError = "A-Scope Initialization Error";
|
|
512
|
-
static readonly ConstructorError = "Unable to construct A-Scope instance";
|
|
513
|
-
static readonly ResolutionError = "A-Scope Resolution Error";
|
|
514
|
-
static readonly RegistrationError = "A-Scope Registration Error";
|
|
515
|
-
static readonly CircularInheritanceError = "A-Scope Circular Inheritance Error";
|
|
516
|
-
static readonly CircularImportError = "A-Scope Circular Import Error";
|
|
517
|
-
static readonly DeregistrationError = "A-Scope Deregistration Error";
|
|
518
|
-
}
|
|
519
|
-
|
|
520
|
-
/**
|
|
521
|
-
*
|
|
522
|
-
* This decorator should allow to set a default meta type for the class, this helps to avoid
|
|
523
|
-
* the need to create custom meta classes for each class.
|
|
524
|
-
*
|
|
525
|
-
* @returns
|
|
526
|
-
*/
|
|
527
|
-
declare function A_MetaDecorator<T extends A_Meta>(constructor: A_TYPES__Ctor<T>): <TTarget extends A_TYPES__MetaLinkedComponentConstructors>(target: TTarget) => TTarget;
|
|
528
|
-
|
|
529
|
-
declare class A_DependencyError extends A_Error {
|
|
530
|
-
static readonly InvalidDependencyTarget = "Invalid Dependency Target";
|
|
531
|
-
static readonly InvalidLoadTarget = "Invalid Load Target";
|
|
532
|
-
static readonly InvalidLoadPath = "Invalid Load Path";
|
|
533
|
-
static readonly InvalidDefaultTarget = "Invalid Default Target";
|
|
534
|
-
static readonly ResolutionParametersError = "Dependency Resolution Parameters Error";
|
|
4528
|
+
static get A_ERROR_DEFAULT_DESCRIPTION(): string;
|
|
4529
|
+
static get(name: string): any;
|
|
4530
|
+
static set(name: string, value: string): void;
|
|
4531
|
+
static getAll<T extends Record<string, any>>(): T;
|
|
4532
|
+
static getAllKeys<T extends Array<string>>(): T;
|
|
535
4533
|
}
|
|
536
4534
|
|
|
537
|
-
declare class A_InjectError extends A_Error {
|
|
538
|
-
static readonly InvalidInjectionTarget = "Invalid target for A-Inject decorator";
|
|
539
|
-
static readonly MissingInjectionTarget = "Missing target for A-Inject decorator";
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* A-Inject decorator
|
|
544
|
-
*
|
|
545
|
-
* This Decorator allows to inject dependencies into the module like
|
|
546
|
-
* - Namespaces
|
|
547
|
-
* - Other Concepts
|
|
548
|
-
* - or maybe Components
|
|
549
|
-
*
|
|
550
|
-
* @param params - see overloads
|
|
551
|
-
* @returns - decorator function
|
|
552
|
-
*/
|
|
553
|
-
declare function A_Inject<T extends A_Component>(
|
|
554
|
-
/**
|
|
555
|
-
* Provide the Component constructor that will be associated with the injection.
|
|
556
|
-
*
|
|
557
|
-
* [!] It returns an Instance of the Component from current Scope or from Parent Scopes.
|
|
558
|
-
*/
|
|
559
|
-
component: A_TYPES__Component_Constructor<T>,
|
|
560
|
-
/**
|
|
561
|
-
* Provide additional instructions on how to perform the injection
|
|
562
|
-
*
|
|
563
|
-
* [!] Default Pagination is 1 if it's necessary to get multiple Fragments please customize it in the instructions
|
|
564
|
-
*/
|
|
565
|
-
config?: Omit<Partial<A_TYPES__A_DependencyResolutionStrategy<T>>, 'query' | 'pagination'>): A_TYPES__A_InjectDecoratorReturn;
|
|
566
|
-
declare function A_Inject<T extends A_Fragment>(
|
|
567
|
-
/**
|
|
568
|
-
* Provide the Fragment constructor to inject the Fragment instance
|
|
569
|
-
*
|
|
570
|
-
* [!] It returns the Fragment instance from current Scope or from Parent Scopes.
|
|
571
|
-
*/
|
|
572
|
-
fragment: A_TYPES__Fragment_Constructor<T>,
|
|
573
|
-
/**
|
|
574
|
-
* Provide additional instructions on how to perform the injection
|
|
575
|
-
*
|
|
576
|
-
* [!] Default Pagination is 1 if it's necessary to get multiple Fragments please customize it in the instructions
|
|
577
|
-
*/
|
|
578
|
-
config?: Omit<Partial<A_TYPES__A_DependencyResolutionStrategy<T>>, 'query' | 'pagination'>): A_TYPES__A_InjectDecoratorReturn;
|
|
579
|
-
declare function A_Inject<T extends A_Entity>(
|
|
580
|
-
/**
|
|
581
|
-
* Provide the Entity constructor to inject the Entity instance
|
|
582
|
-
*
|
|
583
|
-
* [!] Note: It returns the Entity instance from current Scope or from Parent Scopes.
|
|
584
|
-
* [!] Note: If instance has more than one Entity of the same type It returns FIRST found Entity
|
|
585
|
-
* [!] Note: Use 'config' to specify to inject specific one or even Array of Entities
|
|
586
|
-
*/
|
|
587
|
-
entity: A_TYPES__Entity_Constructor<T>,
|
|
588
|
-
/**
|
|
589
|
-
* Provide additional instructions on how to perform the injection
|
|
590
|
-
*
|
|
591
|
-
* [!] Default Pagination is 1 if it's necessary to get multiple Entities please customize it in the instructions
|
|
592
|
-
*/
|
|
593
|
-
config?: Partial<A_TYPES__A_DependencyResolutionStrategy<T>>): A_TYPES__A_InjectDecoratorReturn<T>;
|
|
594
|
-
declare function A_Inject<T extends A_Component>(
|
|
595
|
-
/**
|
|
596
|
-
* Provide the name of Component constructor to inject the Component instance
|
|
597
|
-
*
|
|
598
|
-
* [!] You can use both customized one or original depending on your overriding strategy
|
|
599
|
-
*/
|
|
600
|
-
ctor: string): A_TYPES__A_InjectDecoratorReturn;
|
|
601
|
-
declare function A_Inject<T extends A_Caller>(
|
|
602
|
-
/**
|
|
603
|
-
* Provide the A_Caller constructor to inject the Caller instance
|
|
604
|
-
*
|
|
605
|
-
* [!] It returns initiator of the call, e.g. Container/Component/Command who called Feature
|
|
606
|
-
*/
|
|
607
|
-
caller: A_TYPES__Caller_Constructor<T>): A_TYPES__A_InjectDecoratorReturn;
|
|
608
|
-
declare function A_Inject<T extends A_Error>(
|
|
609
|
-
/***
|
|
610
|
-
* Provide the Error constructor that will be associated with the injection.
|
|
611
|
-
*
|
|
612
|
-
* [!] It returns an Instance of the Error what is executed.
|
|
613
|
-
*/
|
|
614
|
-
error: A_TYPES__Error_Constructor<T>,
|
|
615
|
-
/**
|
|
616
|
-
* Provide additional instructions on how to perform the injection
|
|
617
|
-
*
|
|
618
|
-
* [!] Default Pagination is 1 if it's necessary to get multiple Fragments please customize it in the instructions
|
|
619
|
-
*/
|
|
620
|
-
config?: Omit<Partial<A_TYPES__A_DependencyResolutionStrategy<T>>, 'query' | 'pagination'>): A_TYPES__A_InjectDecoratorReturn;
|
|
621
|
-
declare function A_Inject<T extends A_Feature>(
|
|
622
|
-
/**
|
|
623
|
-
* Provide the Feature constructor that will be associated with the injection.
|
|
624
|
-
*
|
|
625
|
-
* [!] It returns an Instance of the Feature what is executed.
|
|
626
|
-
*/
|
|
627
|
-
feature: A_TYPES__Feature_Constructor<T>): A_TYPES__A_InjectDecoratorReturn;
|
|
628
|
-
declare function A_Inject<T extends A_Scope>(
|
|
629
|
-
/***
|
|
630
|
-
* Provide the Scope constructor that will be associated with the injection.
|
|
631
|
-
*
|
|
632
|
-
* [!] It returns an instance of the Scope where the Entity/Component/Container is defined.
|
|
633
|
-
*/
|
|
634
|
-
scope: A_TYPES__Scope_Constructor<T>): A_TYPES__A_InjectDecoratorReturn;
|
|
635
|
-
declare function A_Inject<T extends A_TYPES__A_DependencyInjectable>(
|
|
636
|
-
/***
|
|
637
|
-
* Provide the Scope constructor that will be associated with the injection.
|
|
638
|
-
*
|
|
639
|
-
* [!] It returns an instance of the Scope where the Entity/Component/Container is defined.
|
|
640
|
-
*/
|
|
641
|
-
dependency: A_Dependency<T>): A_TYPES__A_InjectDecoratorReturn;
|
|
642
|
-
|
|
643
4535
|
declare class A_CommonHelper {
|
|
644
4536
|
/**
|
|
645
4537
|
* A simple promise that resolves immediately.
|
|
@@ -739,10 +4631,6 @@ declare class A_FormatterHelper {
|
|
|
739
4631
|
static toKebabCase(str: string): string;
|
|
740
4632
|
}
|
|
741
4633
|
|
|
742
|
-
type A_ID_TYPES__TimeId_Parts = {
|
|
743
|
-
timestamp: Date;
|
|
744
|
-
random: string;
|
|
745
|
-
};
|
|
746
4634
|
declare class A_IdentityHelper {
|
|
747
4635
|
/**
|
|
748
4636
|
* Generates a short, time-based unique ID.
|
|
@@ -777,10 +4665,6 @@ declare class A_IdentityHelper {
|
|
|
777
4665
|
static hashString(input: string): string;
|
|
778
4666
|
}
|
|
779
4667
|
|
|
780
|
-
declare class A_StepManagerError extends A_Error {
|
|
781
|
-
static readonly CircularDependencyError = "A-StepManager Circular Dependency Error";
|
|
782
|
-
}
|
|
783
|
-
|
|
784
4668
|
declare class A_TypeGuards {
|
|
785
4669
|
/**
|
|
786
4670
|
* Check if value is a string
|
|
@@ -944,7 +4828,7 @@ declare class A_TypeGuards {
|
|
|
944
4828
|
* @param instance
|
|
945
4829
|
* @returns
|
|
946
4830
|
*/
|
|
947
|
-
static isErrorInstance(instance: any):
|
|
4831
|
+
static isErrorInstance(instance: any): boolean;
|
|
948
4832
|
/**
|
|
949
4833
|
* Type guard to check if the instance is of type A_ComponentMeta
|
|
950
4834
|
*
|
|
@@ -966,7 +4850,9 @@ declare class A_TypeGuards {
|
|
|
966
4850
|
* @returns
|
|
967
4851
|
*/
|
|
968
4852
|
static isEntityMetaInstance(instance: any): instance is A_EntityMeta;
|
|
969
|
-
static hasASEID(value: any): value is A_Entity |
|
|
4853
|
+
static hasASEID(value: any): value is A_Entity | {
|
|
4854
|
+
aseid: any;
|
|
4855
|
+
};
|
|
970
4856
|
static isConstructorAllowedForScopeAllocation(target: any): target is A_TYPES__ScopeLinkedConstructors;
|
|
971
4857
|
static isInstanceAllowedForScopeAllocation(target: any): target is A_TYPES__ScopeLinkedComponents;
|
|
972
4858
|
static isConstructorAvailableForAbstraction(target: any): target is A_TYPES__AbstractionAvailableComponents;
|
|
@@ -987,4 +4873,99 @@ declare class A_TypeGuards {
|
|
|
987
4873
|
static isPromiseInstance<T>(value: any): value is Promise<T>;
|
|
988
4874
|
}
|
|
989
4875
|
|
|
990
|
-
|
|
4876
|
+
/**
|
|
4877
|
+
* Basic TypeGuards that don't create circular dependencies
|
|
4878
|
+
* These are used by A_Error and other core classes
|
|
4879
|
+
*/
|
|
4880
|
+
declare class A_BasicTypeGuards {
|
|
4881
|
+
/**
|
|
4882
|
+
* Check if value is a string
|
|
4883
|
+
*
|
|
4884
|
+
* @param value
|
|
4885
|
+
* @returns
|
|
4886
|
+
*/
|
|
4887
|
+
static isString(value: any): value is string;
|
|
4888
|
+
/**
|
|
4889
|
+
* Check if value is a number
|
|
4890
|
+
*
|
|
4891
|
+
* @param value
|
|
4892
|
+
* @returns
|
|
4893
|
+
*/
|
|
4894
|
+
static isNumber(value: any): value is number;
|
|
4895
|
+
/**
|
|
4896
|
+
* Check if value is a boolean
|
|
4897
|
+
*
|
|
4898
|
+
* @param value
|
|
4899
|
+
* @returns
|
|
4900
|
+
*/
|
|
4901
|
+
static isBoolean(value: any): value is boolean;
|
|
4902
|
+
/**
|
|
4903
|
+
* Check if value is an object
|
|
4904
|
+
*
|
|
4905
|
+
* @param value
|
|
4906
|
+
* @returns
|
|
4907
|
+
*/
|
|
4908
|
+
static isObject<T = object>(value: any): value is T;
|
|
4909
|
+
/**
|
|
4910
|
+
* Check if value is an array
|
|
4911
|
+
*
|
|
4912
|
+
* @param value
|
|
4913
|
+
* @returns
|
|
4914
|
+
*/
|
|
4915
|
+
static isArray(value: any): value is any[];
|
|
4916
|
+
/**
|
|
4917
|
+
* Allows to check if the provided param is of constructor type.
|
|
4918
|
+
*
|
|
4919
|
+
* @param param
|
|
4920
|
+
* @returns
|
|
4921
|
+
*/
|
|
4922
|
+
static isErrorConstructorType<T = any>(param: any): param is T;
|
|
4923
|
+
static isErrorSerializedType<T = any>(param: any): param is T;
|
|
4924
|
+
/**
|
|
4925
|
+
* Check if scope is of type A_Scope instance
|
|
4926
|
+
*
|
|
4927
|
+
* @param scope
|
|
4928
|
+
* @returns
|
|
4929
|
+
*/
|
|
4930
|
+
static isScopeInstance(scope: any): boolean;
|
|
4931
|
+
}
|
|
4932
|
+
|
|
4933
|
+
declare const A_CONSTANTS__DEFAULT_ENV_VARIABLES: {
|
|
4934
|
+
/**
|
|
4935
|
+
* Name of the application
|
|
4936
|
+
*
|
|
4937
|
+
* DEFAULT value is 'a-concept'
|
|
4938
|
+
*
|
|
4939
|
+
* [!] Provided name will be used for all aseids in the application by default
|
|
4940
|
+
*/
|
|
4941
|
+
readonly A_CONCEPT_NAME: "A_CONCEPT_NAME";
|
|
4942
|
+
/**
|
|
4943
|
+
* Root scope of the application
|
|
4944
|
+
*
|
|
4945
|
+
* DEFAULT value is 'root'
|
|
4946
|
+
*
|
|
4947
|
+
* [!] Provided name will be used for all aseids in the application by default
|
|
4948
|
+
*/
|
|
4949
|
+
readonly A_CONCEPT_ROOT_SCOPE: "A_CONCEPT_ROOT_SCOPE";
|
|
4950
|
+
/**
|
|
4951
|
+
* Environment of the application e.g. development, production, staging
|
|
4952
|
+
*/
|
|
4953
|
+
readonly A_CONCEPT_ENVIRONMENT: "A_CONCEPT_ENVIRONMENT";
|
|
4954
|
+
/**
|
|
4955
|
+
* Runtime environment of the application e.g. browser, node
|
|
4956
|
+
*/
|
|
4957
|
+
readonly A_CONCEPT_RUNTIME_ENVIRONMENT: "A_CONCEPT_RUNTIME_ENVIRONMENT";
|
|
4958
|
+
/**
|
|
4959
|
+
* Root folder of the application
|
|
4960
|
+
* [!] Automatically set by A-Concept when the application starts
|
|
4961
|
+
*/
|
|
4962
|
+
readonly A_CONCEPT_ROOT_FOLDER: "A_CONCEPT_ROOT_FOLDER";
|
|
4963
|
+
/**
|
|
4964
|
+
* Allows to define a default error description for errors thrown without a description
|
|
4965
|
+
*/
|
|
4966
|
+
readonly A_ERROR_DEFAULT_DESCRIPTION: "A_ERROR_DEFAULT_DESCRIPTION";
|
|
4967
|
+
};
|
|
4968
|
+
type A_TYPES__ConceptENVVariables = (typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES)[keyof typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES][];
|
|
4969
|
+
declare const A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY: readonly ["A_CONCEPT_NAME", "A_CONCEPT_ROOT_SCOPE", "A_CONCEPT_ENVIRONMENT", "A_CONCEPT_RUNTIME_ENVIRONMENT", "A_CONCEPT_ROOT_FOLDER", "A_ERROR_DEFAULT_DESCRIPTION"];
|
|
4970
|
+
|
|
4971
|
+
export { ASEID, A_Abstraction, A_AbstractionError, A_Abstraction_Extend, A_BasicTypeGuards, A_CONCEPT_ENV, A_CONSTANTS__DEFAULT_ENV_VARIABLES, A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_CONSTANTS__ERROR_CODES, A_CONSTANTS__ERROR_DESCRIPTION, A_Caller, A_CallerError, A_CommonHelper, A_Component, A_ComponentMeta, A_Concept, A_ConceptMeta, A_Container, A_ContainerMeta, A_Context, A_ContextError, A_Dependency, A_DependencyError, A_Dependency_All, A_Dependency_Default, A_Dependency_Flat, A_Dependency_Load, A_Dependency_Parent, A_Dependency_Require, A_Entity, A_EntityError, A_EntityMeta, A_Error, A_Feature, A_FeatureError, A_Feature_Define, A_Feature_Extend, A_FormatterHelper, A_Fragment, type A_ID_TYPES__TimeId_Parts, A_IdentityHelper, A_Inject, A_InjectError, A_Meta, A_MetaDecorator, A_Scope, A_ScopeError, A_Stage, A_StageError, A_StepManagerError, A_StepsManager, type A_TYPES_ScopeDependentComponents, type A_TYPES_ScopeIndependentComponents, type A_TYPES_StageExecutionBehavior, type A_TYPES__ASEID_Constructor, type A_TYPES__ASEID_ConstructorConfig, type A_TYPES__ASEID_JSON, type A_TYPES__A_DependencyConstructor, type A_TYPES__A_DependencyInjectable, type A_TYPES__A_DependencyResolutionStrategy, type A_TYPES__A_DependencyResolutionType, type A_TYPES__A_Dependency_AllDecoratorReturn, type A_TYPES__A_Dependency_DefaultDecoratorReturn, type A_TYPES__A_Dependency_EntityInjectionPagination, type A_TYPES__A_Dependency_EntityInjectionQuery, type A_TYPES__A_Dependency_EntityResolutionConfig, type A_TYPES__A_Dependency_FlatDecoratorReturn, type A_TYPES__A_Dependency_LoadDecoratorReturn, type A_TYPES__A_Dependency_ParentDecoratorReturn, type A_TYPES__A_Dependency_RequireDecoratorReturn, type A_TYPES__A_Dependency_Serialized, type A_TYPES__A_InjectDecoratorDescriptor, type A_TYPES__A_InjectDecoratorReturn, type A_TYPES__A_InjectDecorator_Meta, type A_TYPES__A_StageStep, type A_TYPES__A_StageStepProcessingExtraParams, A_TYPES__A_Stage_Status, type A_TYPES__AbstractionAvailableComponents, type A_TYPES__AbstractionDecoratorConfig, type A_TYPES__AbstractionDecoratorDescriptor, type A_TYPES__Abstraction_Constructor, type A_TYPES__Abstraction_Init, type A_TYPES__Abstraction_Serialized, type A_TYPES__CallerComponent, type A_TYPES__Caller_Constructor, type A_TYPES__Caller_Init, type A_TYPES__Caller_Serialized, type A_TYPES__ComponentMeta, type A_TYPES__ComponentMetaExtension, A_TYPES__ComponentMetaKey, type A_TYPES__Component_Constructor, type A_TYPES__Component_Init, type A_TYPES__Component_Serialized, type A_TYPES__ConceptAbstraction, type A_TYPES__ConceptAbstractionMeta, A_TYPES__ConceptAbstractions, type A_TYPES__ConceptENVVariables, A_TYPES__ConceptMetaKey, type A_TYPES__Concept_Constructor, type A_TYPES__Concept_Init, type A_TYPES__Concept_Serialized, type A_TYPES__ContainerMeta, type A_TYPES__ContainerMetaExtension, A_TYPES__ContainerMetaKey, type A_TYPES__Container_Constructor, type A_TYPES__Container_Init, type A_TYPES__Container_Serialized, type A_TYPES__ContextEnvironment, type A_TYPES__Ctor, type A_TYPES__DeepPartial, type A_TYPES__Dictionary, A_TYPES__EntityFeatures, type A_TYPES__EntityMeta, A_TYPES__EntityMetaKey, type A_TYPES__Entity_Constructor, type A_TYPES__Entity_Init, type A_TYPES__Entity_Serialized, type A_TYPES__Error_Constructor, type A_TYPES__Error_Init, type A_TYPES__Error_Serialized, type A_TYPES__ExtractNested, type A_TYPES__ExtractProperties, type A_TYPES__FeatureAvailableComponents, type A_TYPES__FeatureAvailableConstructors, type A_TYPES__FeatureDefineDecoratorConfig, type A_TYPES__FeatureDefineDecoratorDescriptor, type A_TYPES__FeatureDefineDecoratorMeta, type A_TYPES__FeatureDefineDecoratorTarget, type A_TYPES__FeatureDefineDecoratorTemplateItem, type A_TYPES__FeatureError_Init, type A_TYPES__FeatureExtendDecoratorConfig, type A_TYPES__FeatureExtendDecoratorDescriptor, type A_TYPES__FeatureExtendDecoratorMeta, type A_TYPES__FeatureExtendDecoratorScopeConfig, type A_TYPES__FeatureExtendDecoratorScopeItem, type A_TYPES__FeatureExtendDecoratorTarget, type A_TYPES__FeatureExtendableMeta, A_TYPES__FeatureState, type A_TYPES__Feature_Constructor, type A_TYPES__Feature_Init, type A_TYPES__Feature_InitWithComponent, type A_TYPES__Feature_InitWithTemplate, type A_TYPES__Feature_Serialized, type A_TYPES__Fragment_Constructor, type A_TYPES__Fragment_Init, type A_TYPES__Fragment_Serialized, type A_TYPES__IEntity, type A_TYPES__InjectableTargets, type A_TYPES__MetaLinkedComponentConstructors, type A_TYPES__MetaLinkedComponents, type A_TYPES__Meta_Constructor, type A_TYPES__NonObjectPaths, type A_TYPES__ObjectKeyEnum, type A_TYPES__Paths, type A_TYPES__PathsToObject, type A_TYPES__Required, type A_TYPES__ScopeConfig, type A_TYPES__ScopeLinkedComponents, type A_TYPES__ScopeLinkedConstructors, type A_TYPES__Scope_Constructor, type A_TYPES__Scope_Init, type A_TYPES__Scope_Serialized, type A_TYPES__Stage_Serialized, type A_TYPES__UnionToIntersection, A_TypeGuards };
|