@adaas/a-concept 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/examples/simple/concept.js +1 -1
- package/dist/examples/simple/concept.js.map +1 -1
- package/dist/examples/simple/containers/Main.container.d.ts +1 -1
- package/dist/examples/simple/containers/Main.container.js +10 -3
- package/dist/examples/simple/containers/Main.container.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/src/base/A-Config/A-Config.types.d.ts +2 -0
- package/dist/src/base/A-Config/A-Config.types.js +4 -0
- package/dist/src/base/A-Config/A-Config.types.js.map +1 -1
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.class.d.ts +1 -0
- package/dist/src/global/A-Context/A-Context.class.js +3 -1
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Dependency/A-DependencyReference.class.d.ts +0 -17
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js +47 -65
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +49 -2
- package/dist/src/global/A-Entity/A-Entity.class.js +88 -2
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.types.d.ts +13 -0
- package/dist/src/global/A-Entity/A-Entity.types.js +2 -0
- package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
- package/dist/src/global/A-Meta/A-Meta.class.d.ts +5 -0
- package/dist/src/global/A-Meta/A-Meta.class.js +26 -0
- package/dist/src/global/A-Meta/A-Meta.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.class.js +4 -2
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
- package/examples/simple/concept.ts +1 -1
- package/examples/simple/containers/Main.container.ts +9 -3
- package/index.ts +3 -0
- package/jest.config.ts +0 -4
- package/package.json +1 -1
- package/src/base/A-Config/A-Config.types.ts +6 -1
- package/src/decorators/A-Inject/A-Inject.decorator.ts +0 -1
- package/src/global/A-Container/A-Container.class.ts +0 -5
- package/src/global/A-Context/A-Context.class.ts +3 -1
- package/src/global/A-Dependency/A-DependencyReference.class.ts +61 -61
- package/src/global/A-Entity/A-Entity.class.ts +128 -3
- package/src/global/A-Entity/A-Entity.types.ts +17 -0
- package/src/global/A-Meta/A-Meta.class.ts +36 -0
- package/src/global/A-Scope/A-Scope.class.ts +5 -2
- package/tsconfig.json +0 -4
- package/src/storage/A_Component.storage.ts +0 -28
- package/src/storage/A_Concept.storage.ts +0 -49
- package/src/storage/A_Container.storage.ts +0 -21
- package/src/storage/A_Inject.storage.ts +0 -30
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.A_Scope = void 0;
|
|
4
4
|
const a_utils_1 = require("@adaas/a-utils");
|
|
5
|
-
const A_Inject_storage_1 = require("../../storage/A_Inject.storage");
|
|
6
5
|
const A_Fragment_class_1 = require("../A-Fragment/A-Fragment.class");
|
|
6
|
+
const A_Context_class_1 = require("../A-Context/A-Context.class");
|
|
7
|
+
const A_Component_types_1 = require("../A-Component/A-Component.types");
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
9
10
|
*
|
|
@@ -101,7 +102,8 @@ class A_Scope {
|
|
|
101
102
|
return this._components.get(component);
|
|
102
103
|
}
|
|
103
104
|
case this.components.includes(component) && !this._components.has(component): {
|
|
104
|
-
const
|
|
105
|
+
const componentMeta = A_Context_class_1.A_Context.meta(component);
|
|
106
|
+
const argsMeta = componentMeta.get(A_Component_types_1.A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
105
107
|
let resolvedArgs = [];
|
|
106
108
|
if (argsMeta)
|
|
107
109
|
resolvedArgs = (argsMeta.get('constructor') || [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Scope.class.js","sourceRoot":"","sources":["../../../../src/global/A-Scope/A-Scope.class.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD,
|
|
1
|
+
{"version":3,"file":"A-Scope.class.js","sourceRoot":"","sources":["../../../../src/global/A-Scope/A-Scope.class.ts"],"names":[],"mappings":";;;AAAA,4CAAgD;AAEhD,qEAA4D;AAC5D,kEAAyD;AACzD,wEAA6E;AAE7E;;;;;;;;;;;;GAYG;AACH,MAAa,OAAO;IAYhB,YACI,MAA0C,EAC1C,SAAwC,EAAE;QAZ9C,SAAI,GAAW,EAAE,CAAC;QAEV,gBAAW,GAA+C,IAAI,OAAO,EAAE,CAAC;QACxE,eAAU,GAAgD,IAAI,OAAO,EAAE,CAAC;QAW5E,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAEjD,yBAAyB;QACzB,MAAM,aAAa,GAA8B;YAC7C,IAAI,EAAE,EAAE;YACR,UAAU,EAAE,EAAE;YACd,SAAS,EAAE,EAAE;YACb,MAAM,EAAE,EAAE;YACV,MAAM,EAAE,EAAE;SACb,CAAC;QAGF,IAAI,CAAC,MAAM,GAAG,wBAAc,CAAC,iBAAiB,CAA4B,MAAM,EAAE,aAAa,CAAC,CAAC;QAEjG,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC;QAC7C,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;QAE3C,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;YAChB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAChC,CAAC;IACL,CAAC;IAGO,cAAc,CAAC,WAAgD;QACnE,qCAAqC;QACrC,wDAAwD;QACxD,KAAK;IACT,CAAC;IAGO,aAAa,CAAC,UAA6B;QAC/C,UAAU,CAA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context";
|
|
4
4
|
import { ContextFragmentB } from "../context/Fragment_B.context";
|
|
5
5
|
import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class";
|
|
6
|
+
import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
@@ -16,12 +17,17 @@ export class MainContainer extends A_Container<
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
@A_Concept.Start()
|
|
19
|
-
async start
|
|
20
|
-
|
|
20
|
+
async start(
|
|
21
|
+
@A_Inject(MainContainer) params?: any
|
|
22
|
+
) {
|
|
23
|
+
if (params) {
|
|
24
|
+
console.log('Start');
|
|
25
|
+
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
|
|
25
31
|
|
|
26
32
|
@A_Feature.Define()
|
|
27
33
|
async method_A() {
|
package/index.ts
CHANGED
|
@@ -18,6 +18,9 @@ export { A_Component } from './src/global/A-Component/A-Component.class';
|
|
|
18
18
|
export { A_ComponentMeta } from './src/global/A-Component/A-Component.meta';
|
|
19
19
|
export * from './src/global/A-Component/A-Component.types';
|
|
20
20
|
|
|
21
|
+
export { A_Entity } from './src/global/A-Entity/A-Entity.class';
|
|
22
|
+
export * from './src/global/A-Entity/A-Entity.types';
|
|
23
|
+
|
|
21
24
|
|
|
22
25
|
// ---------------------- Common Components ----------------------
|
|
23
26
|
export { A_Feature } from './src/global/A-Feature/A-Feature.class';
|
package/jest.config.ts
CHANGED
|
@@ -13,10 +13,6 @@ const config: Config.InitialOptions = {
|
|
|
13
13
|
"@adaas/a-concept/types/(.*)": ["<rootDir>/src/types/$1"],
|
|
14
14
|
"@adaas/a-concept/helpers/(.*)": ["<rootDir>/src/helpers/$1"],
|
|
15
15
|
"@adaas/a-concept/decorators/(.*)": ["<rootDir>/src/decorators/$1"],
|
|
16
|
-
"@adaas/a-concept/managers/(.*)": ["<rootDir>/src/managers/$1"],
|
|
17
|
-
"@adaas/a-concept/providers/(.*)": ["<rootDir>/src/providers/$1"],
|
|
18
|
-
"@adaas/a-concept/modules/(.*)": ["<rootDir>/src/modules/$1"],
|
|
19
|
-
"@adaas/a-concept/storage/(.*)": ["<rootDir>/src/storage/$1"],
|
|
20
16
|
"@adaas/a-concept/base/(.*)": ["<rootDir>/src/base/$1"],
|
|
21
17
|
}
|
|
22
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-concept",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "A-Concept is a framework to build new Applications within or outside the ADAAS ecosystem. This framework is designed to be modular structure regardless environment and program goal.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { A_TYPES__FragmentConstructor } from "@adaas/a-concept/global/A-Fragment/A-Fragment.types";
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export enum A_TYPES__ConfigFeature {
|
|
5
|
+
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
|
|
4
9
|
export type A_TYPES__ConfigContainerConstructor<T extends string> = {
|
|
5
10
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
2
2
|
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
3
3
|
import { A_TYPES__A_InjectDecoratorReturn, A_TYPES__A_InjectDecoratorStorageInstruction } from "./A-Inject.decorator.types";
|
|
4
|
-
import { A_STORAGE__A_Inject_Instructions } from "@adaas/a-concept/storage/A_Inject.storage";
|
|
5
4
|
import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
|
|
6
5
|
import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
|
|
7
6
|
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { A_TYPES__ContainerCallParams, A_TYPES__ContainerConstructor } from "./A-Container.types";
|
|
2
|
-
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
3
2
|
import { A_TYPES__Required } from "@adaas/a-utils";
|
|
4
3
|
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
5
|
-
import { A_CONTAINER_Storage, A_CONTAINER_STORAGE__Definition__Lifecycle } from "@adaas/a-concept/storage/A_Container.storage";
|
|
6
|
-
import { A_COMPONENT_Storage } from "@adaas/a-concept/storage/A_Component.storage";
|
|
7
|
-
import { A_TYPES__FeatureStep } from "../A-Feature/A-Feature.types";
|
|
8
4
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
9
|
-
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
10
5
|
|
|
11
6
|
|
|
12
7
|
|
|
@@ -47,6 +47,8 @@ export class A_Context {
|
|
|
47
47
|
protected conceptsMeta: Map<typeof A_Concept.constructor, A_Meta<any>> = new Map();
|
|
48
48
|
protected containersMeta: Map<typeof A_Container.constructor, A_ContainerMeta> = new Map();
|
|
49
49
|
protected componentsMeta: Map<typeof A_Container.constructor, A_ComponentMeta> = new Map();
|
|
50
|
+
// uses to allow to store custom meta data
|
|
51
|
+
protected customMeta: Map<typeof A_Container.constructor, A_Meta<any>> = new Map();
|
|
50
52
|
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -223,7 +225,7 @@ export class A_Context {
|
|
|
223
225
|
}
|
|
224
226
|
|
|
225
227
|
default: {
|
|
226
|
-
metaStorage = instance.
|
|
228
|
+
metaStorage = instance.customMeta;
|
|
227
229
|
property = typeof (param1 as any) === 'function' ? param1 : param1.constructor;
|
|
228
230
|
|
|
229
231
|
if (!metaStorage.has(property)) {
|
|
@@ -1,61 +1,61 @@
|
|
|
1
|
-
class RealDependency {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
class DependencyReference<T> {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// Example usage:
|
|
53
|
-
(async () => {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
})();
|
|
1
|
+
// class RealDependency {
|
|
2
|
+
// constructor(private name: string) { }
|
|
3
|
+
|
|
4
|
+
// getName() {
|
|
5
|
+
// return this.name;
|
|
6
|
+
// }
|
|
7
|
+
|
|
8
|
+
// performAction() {
|
|
9
|
+
// console.log(`${this.name} is performing an action.`);
|
|
10
|
+
// }
|
|
11
|
+
// }
|
|
12
|
+
|
|
13
|
+
// class DependencyReference<T> {
|
|
14
|
+
// private proxyInstance: T | null = null;
|
|
15
|
+
// private realInstance: T | null = null;
|
|
16
|
+
|
|
17
|
+
// constructor(private realClass: { new(...args: any[]): T }, private args: any[]) { }
|
|
18
|
+
|
|
19
|
+
// // Simulate async loading (e.g., dynamic imports, API calls, etc.)
|
|
20
|
+
// private async loadInstance(): Promise<T> {
|
|
21
|
+
// if (!this.realInstance) {
|
|
22
|
+
// console.log('Loading real dependency...');
|
|
23
|
+
// // Simulate async loading with a delay
|
|
24
|
+
// await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
25
|
+
// this.realInstance = new this.realClass(...this.args);
|
|
26
|
+
// }
|
|
27
|
+
// return this.realInstance;
|
|
28
|
+
// }
|
|
29
|
+
|
|
30
|
+
// public async resolve(): Promise<T> {
|
|
31
|
+
// if (!this.proxyInstance) {
|
|
32
|
+
// const realInstance = await this.loadInstance();
|
|
33
|
+
|
|
34
|
+
// this.proxyInstance = new Proxy({}, {
|
|
35
|
+
// get: (target, prop) => {
|
|
36
|
+
// const value = (realInstance as any)[prop];
|
|
37
|
+
|
|
38
|
+
// // If the property is a method, return a bound function
|
|
39
|
+
// if (typeof value === 'function') {
|
|
40
|
+
// return value.bind(realInstance);
|
|
41
|
+
// }
|
|
42
|
+
// return value;
|
|
43
|
+
// }
|
|
44
|
+
// }) as T;
|
|
45
|
+
// }
|
|
46
|
+
|
|
47
|
+
// return this.proxyInstance;
|
|
48
|
+
// }
|
|
49
|
+
// }
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// // Example usage:
|
|
53
|
+
// (async () => {
|
|
54
|
+
// const lazyDependency = new DependencyReference(RealDependency, ['ComponentA']);
|
|
55
|
+
|
|
56
|
+
// const proxy = await lazyDependency.resolve(); // Loads the instance asynchronously
|
|
57
|
+
|
|
58
|
+
// proxy.performAction(); // Will call the method on the real instance
|
|
59
|
+
|
|
60
|
+
// console.log(proxy.getName()); // Calls method on the real instance
|
|
61
|
+
// })();
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import { A_Error, ASEID } from "@adaas/a-utils";
|
|
1
2
|
|
|
3
|
+
import { A_CONSTANTS__DEFAULT_ERRORS } from "@adaas/a-utils/dist/src/constants/errors.constants";
|
|
4
|
+
import { A_TYPES__Entity_JSON, A_TYPES__IEntity } from "./A-Entity.types";
|
|
5
|
+
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
2
6
|
|
|
3
7
|
/**
|
|
4
8
|
* A_Entity is another abstraction that describes all major participants in the system business logic.
|
|
@@ -7,10 +11,131 @@
|
|
|
7
11
|
*
|
|
8
12
|
* Each entity should be connected to the ContextFragment (Scope) and should be able to communicate with other entities.
|
|
9
13
|
*/
|
|
10
|
-
export class A_Entity
|
|
14
|
+
export class A_Entity<
|
|
15
|
+
_ConstructorType = any,
|
|
16
|
+
_SerializedType extends A_TYPES__Entity_JSON = A_TYPES__Entity_JSON,
|
|
17
|
+
>
|
|
18
|
+
extends A_Fragment
|
|
19
|
+
implements A_TYPES__IEntity {
|
|
11
20
|
|
|
12
|
-
|
|
21
|
+
aseid!: ASEID;
|
|
13
22
|
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
aseid: string
|
|
26
|
+
)
|
|
27
|
+
constructor(
|
|
28
|
+
aseid: ASEID
|
|
29
|
+
)
|
|
30
|
+
constructor(
|
|
31
|
+
serialized: _SerializedType
|
|
32
|
+
)
|
|
33
|
+
constructor(
|
|
34
|
+
newEntity: _ConstructorType
|
|
35
|
+
)
|
|
36
|
+
constructor(props: string | ASEID | _SerializedType | _ConstructorType) {
|
|
37
|
+
super();
|
|
38
|
+
|
|
39
|
+
switch (true) {
|
|
40
|
+
case (typeof props === 'string' && ASEID.isASEID(props)):
|
|
41
|
+
this.aseid = new ASEID(props);
|
|
42
|
+
break;
|
|
43
|
+
case (props instanceof ASEID):
|
|
44
|
+
this.aseid = props;
|
|
45
|
+
break;
|
|
46
|
+
case (typeof props === 'object' && (props as any).aseid):
|
|
47
|
+
this.fromSerialized(props as _SerializedType);
|
|
48
|
+
break;
|
|
49
|
+
|
|
50
|
+
case (typeof props === 'object'):
|
|
51
|
+
this.fromNewEntity(props as _ConstructorType);
|
|
52
|
+
break
|
|
53
|
+
|
|
54
|
+
default:
|
|
55
|
+
throw new A_Error(A_CONSTANTS__DEFAULT_ERRORS.INCORRECT_A_ENTITY_CONSTRUCTOR);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ====================================================================
|
|
61
|
+
// ================== DUPLICATED ASEID Getters ========================
|
|
62
|
+
// ====================================================================
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Extracts the ID from the ASEID
|
|
66
|
+
* ID is the unique identifier of the entity
|
|
67
|
+
*/
|
|
68
|
+
get id(): string | number {
|
|
69
|
+
return this.aseid.id;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Extracts the namespace from the ASEID
|
|
74
|
+
* namespace is an application specific identifier from where the entity is coming from
|
|
75
|
+
*/
|
|
76
|
+
get namespace(): string {
|
|
77
|
+
return this.aseid.namespace
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Extracts the scope from the ASEID
|
|
82
|
+
* scope is the scope of the entity from Application Namespace
|
|
83
|
+
*/
|
|
84
|
+
get scope(): string {
|
|
85
|
+
return this.aseid.scope;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Extracts the entity from the ASEID
|
|
90
|
+
* entity is the name of the entity from Application Namespace
|
|
91
|
+
*/
|
|
92
|
+
get entity(): string {
|
|
93
|
+
return this.aseid.entity;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Extracts the version from the ASEID
|
|
98
|
+
* version is the version of the entity
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
get version(): string | undefined {
|
|
102
|
+
return this.aseid.version;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Extracts the shard from the ASEID
|
|
107
|
+
* shard is the shard of the entity
|
|
108
|
+
*/
|
|
109
|
+
get shard(): string | undefined {
|
|
110
|
+
return this.aseid.shard;
|
|
14
111
|
}
|
|
15
112
|
|
|
16
|
-
|
|
113
|
+
|
|
114
|
+
protected fromNewEntity(newEntity: _ConstructorType): void {
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
protected fromSerialized(serialized: _SerializedType): void {
|
|
119
|
+
this.aseid = new ASEID((serialized).aseid);
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Converts the entity to a JSON object
|
|
126
|
+
*
|
|
127
|
+
*
|
|
128
|
+
* @returns
|
|
129
|
+
*/
|
|
130
|
+
toJSON(): _SerializedType {
|
|
131
|
+
return {
|
|
132
|
+
aseid: this.aseid.toString()
|
|
133
|
+
} as _SerializedType;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
toString(): string {
|
|
139
|
+
return this.aseid.toString();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ASEID } from "@adaas/a-utils";
|
|
2
|
+
|
|
3
|
+
export interface A_TYPES__IEntity {
|
|
4
|
+
/**
|
|
5
|
+
* The ASEID of the entity
|
|
6
|
+
*/
|
|
7
|
+
aseid: ASEID
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export type A_TYPES__Entity_JSON = {
|
|
12
|
+
/**
|
|
13
|
+
* The ASEID of the entity
|
|
14
|
+
*/
|
|
15
|
+
aseid: string
|
|
16
|
+
};
|
|
17
|
+
|
|
@@ -55,6 +55,42 @@ export class A_Meta<
|
|
|
55
55
|
get<K extends keyof _StorageItems>(key: K): _StorageItems[K] | undefined {
|
|
56
56
|
return this.meta.get(key) as _StorageItems[K];
|
|
57
57
|
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// Delete a key-value pair by key
|
|
61
|
+
delete(key: keyof _StorageItems): boolean {
|
|
62
|
+
return this.meta.delete(key);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Search for keys by regex
|
|
66
|
+
findByRegex(regex: RegExp): Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
67
|
+
const results: Array<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> = [];
|
|
68
|
+
for (const [key, value] of this.meta.entries()) {
|
|
69
|
+
if (regex.test(String(key))) {
|
|
70
|
+
results.push([key, value]);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return results;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Check if a key exists
|
|
77
|
+
has(key: keyof _StorageItems): boolean {
|
|
78
|
+
return this.meta.has(key);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Get all entries in the map
|
|
82
|
+
entries(): IterableIterator<[keyof _StorageItems, _StorageItems[keyof _StorageItems]]> {
|
|
83
|
+
return this.meta.entries();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
// Clear all entries
|
|
88
|
+
clear(): void {
|
|
89
|
+
this.meta.clear();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
58
94
|
}
|
|
59
95
|
|
|
60
96
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { A_CommonHelper } from "@adaas/a-utils";
|
|
2
2
|
import { A_TYPES__ScopeConfig, A_TYPES__ScopeConstructor } from "./A-Scope.types";
|
|
3
|
-
import { A_STORAGE__A_Inject_Instructions } from "@adaas/a-concept/storage/A_Inject.storage";
|
|
4
3
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
4
|
+
import { A_Context } from "../A-Context/A-Context.class";
|
|
5
|
+
import { A_TYPES__ComponentMetaKey } from "../A-Component/A-Component.types";
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
@@ -163,7 +164,9 @@ export class A_Scope {
|
|
|
163
164
|
}
|
|
164
165
|
case this.components.includes(component) && !this._components.has(component): {
|
|
165
166
|
|
|
166
|
-
const
|
|
167
|
+
const componentMeta = A_Context.meta(component)
|
|
168
|
+
|
|
169
|
+
const argsMeta = componentMeta.get(A_TYPES__ComponentMetaKey.INJECTIONS);
|
|
167
170
|
|
|
168
171
|
let resolvedArgs: Array<any> = [];
|
|
169
172
|
|
package/tsconfig.json
CHANGED
|
@@ -35,10 +35,6 @@
|
|
|
35
35
|
"@adaas/a-concept/types/*": ["src/types/*"],
|
|
36
36
|
"@adaas/a-concept/helpers/*": ["src/helpers/*"],
|
|
37
37
|
"@adaas/a-concept/decorators/*": ["src/decorators/*"],
|
|
38
|
-
"@adaas/a-concept/managers/*": ["src/managers/*"],
|
|
39
|
-
"@adaas/a-concept/providers/*": ["src/providers/*"],
|
|
40
|
-
"@adaas/a-concept/modules/*": ["src/modules/*"],
|
|
41
|
-
"@adaas/a-concept/storage/*": ["src/storage/*"],
|
|
42
38
|
"@adaas/a-concept/base/*": ["src/base/*"]
|
|
43
39
|
},
|
|
44
40
|
"lib": [
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
// =================================================================================================
|
|
2
|
-
// ========== Component Storage ====================================================================
|
|
3
|
-
// =================================================================================================
|
|
4
|
-
|
|
5
|
-
import { A_Component } from "../global/A-Component/A-Component.class";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
// -------------------------------------------------------------------------------
|
|
9
|
-
// ----- A Concept -> Component Declaration -> Symbol Declaration Keys ---------------
|
|
10
|
-
// -------------------------------------------------------------------------------
|
|
11
|
-
export const A_COMPONENT_STORAGE__Definition__Extensions = Symbol('a-container-extensions');
|
|
12
|
-
export const A_COMPONENT_STORAGE__Definition__Feature = Symbol('a-container-feature');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* This storage is used to store the containers metadata, definitions and configurations
|
|
19
|
-
*/
|
|
20
|
-
export const A_COMPONENT_Storage: Map<
|
|
21
|
-
typeof A_Component | { new(...args: any[]): any },
|
|
22
|
-
Map<
|
|
23
|
-
Symbol | string,
|
|
24
|
-
any
|
|
25
|
-
>
|
|
26
|
-
> = new Map();
|
|
27
|
-
|
|
28
|
-
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// --------------------------------------------------------------
|
|
4
|
-
// ----- A Concept -> Module Declaration -> Main Config ---------
|
|
5
|
-
|
|
6
|
-
import { A_Container } from "../global/A-Container/A-Container.class";
|
|
7
|
-
|
|
8
|
-
// --------------------------------------------------------------
|
|
9
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Config = Symbol('a-concept-modules-declaration');
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
// -------------------------------------------------------------------------------
|
|
14
|
-
// ----- A Concept -> Module Declaration -> Concept Lifecycle Extension_ ---------
|
|
15
|
-
// -------------------------------------------------------------------------------
|
|
16
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootRun = Symbol('a-concept-modules-declaration-lifecycle-root-run');
|
|
17
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootLoad = Symbol('a-concept-modules-declaration-lifecycle-root-load');
|
|
18
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootBuild = Symbol('a-concept-modules-declaration-lifecycle-root-build');
|
|
19
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootPublish = Symbol('a-concept-modules-declaration-lifecycle-root-publish');
|
|
20
|
-
export const A_CONCEPT_STORAGE__MODULE_DECLARATION_Lifecycle_RootTest = Symbol('a-concept-modules-declaration-lifecycle-root-test');
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Storage to keep the module declarations across all modules
|
|
27
|
-
*/
|
|
28
|
-
export const A_CONCEPT_ModulesDeclarationStorage: WeakMap<
|
|
29
|
-
any,
|
|
30
|
-
Map<string | Symbol, any>
|
|
31
|
-
> = new WeakMap();
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Storage to keep the lifecycle declarations across all modules
|
|
37
|
-
*/
|
|
38
|
-
export const A_CONCEPT_LifecycleDeclarationsStorage: Map<Symbol, any> = new Map();
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* The simplest way to store the decorators
|
|
46
|
-
* If any extra API is needed, it can be added here or replaced with a new class
|
|
47
|
-
*/
|
|
48
|
-
export const A_CONCEPT_Storage = new WeakMap();
|
|
49
|
-
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// =================================================================================================
|
|
2
|
-
// ========== Container Storage ====================================================================
|
|
3
|
-
// =================================================================================================
|
|
4
|
-
|
|
5
|
-
import { A_Container } from "../global/A-Container/A-Container.class";
|
|
6
|
-
|
|
7
|
-
// -------------------------------------------------------------------------------
|
|
8
|
-
// ----- A Concept -> Container Declaration -> Symbol Declaration Keys ---------------
|
|
9
|
-
// -------------------------------------------------------------------------------
|
|
10
|
-
export const A_CONTAINER_STORAGE__Definition__Lifecycle = Symbol('a-container-lifecycle');
|
|
11
|
-
export const A_CONTAINER_STORAGE__Definition__Feature = Symbol('a-container-feature');
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* This storage is used to store the containers metadata, definitions and configurations
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
export const A_CONTAINER_Storage: WeakMap<typeof A_Container.constructor, Map<Symbol | string, any>> = new WeakMap();
|
|
20
|
-
|
|
21
|
-
|