@adaas/a-concept 0.2.2 → 0.2.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adaas/a-concept",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "A-Concept is a framework of the new generation that is tailored to use AI, enabling developers to create AI-powered applications with ease. It provides a structured approach to building, managing, and deploying AI-driven solutions.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "./dist/index.cjs",
@@ -10,6 +10,7 @@ import { A_DependencyError } from "./A-Dependency.error";
10
10
  import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
11
11
  import { A_Entity } from "../A-Entity/A-Entity.class";
12
12
  import { A_TYPES__Entity_Constructor } from "../A-Entity/A-Entity.types";
13
+ import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.constants";
13
14
 
14
15
 
15
16
  /**
@@ -49,6 +50,10 @@ export function A_Dependency_All<T extends A_Entity>(
49
50
  case A_TypeGuards.isContainerInstance(target):
50
51
  metaKey = A_TYPES__ContainerMetaKey.INJECTIONS;
51
52
  break;
53
+
54
+ case A_TypeGuards.isEntityInstance(target):
55
+ metaKey = A_TYPES__EntityMetaKey.INJECTIONS;
56
+ break;
52
57
  }
53
58
 
54
59
  // get existing meta or create a new one
@@ -8,6 +8,7 @@ import { A_TYPES__A_InjectDecorator_Meta, A_TYPES__InjectableTargets } from "../
8
8
  import { A_TYPES__A_Dependency_DefaultDecoratorReturn } from "./A-Dependency.types";
9
9
  import { A_DependencyError } from "./A-Dependency.error";
10
10
  import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
11
+ import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.constants";
11
12
 
12
13
 
13
14
  /**
@@ -48,6 +49,10 @@ export function A_Dependency_Default(
48
49
  case A_TypeGuards.isContainerInstance(target):
49
50
  metaKey = A_TYPES__ContainerMetaKey.INJECTIONS;
50
51
  break;
52
+
53
+ case A_TypeGuards.isEntityInstance(target):
54
+ metaKey = A_TYPES__EntityMetaKey.INJECTIONS;
55
+ break;
51
56
  }
52
57
 
53
58
  // get existing meta or create a new one
@@ -8,6 +8,7 @@ import { A_TYPES__A_InjectDecorator_Meta, A_TYPES__InjectableTargets } from "../
8
8
  import { A_TYPES__A_Dependency_FlatDecoratorReturn } from "./A-Dependency.types";
9
9
  import { A_DependencyError } from "./A-Dependency.error";
10
10
  import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
11
+ import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.constants";
11
12
 
12
13
 
13
14
  /**
@@ -42,6 +43,10 @@ export function A_Dependency_Flat(): A_TYPES__A_Dependency_FlatDecoratorReturn {
42
43
  case A_TypeGuards.isContainerInstance(target):
43
44
  metaKey = A_TYPES__ContainerMetaKey.INJECTIONS;
44
45
  break;
46
+
47
+ case A_TypeGuards.isEntityInstance(target):
48
+ metaKey = A_TYPES__EntityMetaKey.INJECTIONS;
49
+ break;
45
50
  }
46
51
 
47
52
  // get existing meta or create a new one
@@ -8,6 +8,7 @@ import { A_TYPES__A_InjectDecorator_Meta, A_TYPES__InjectableTargets } from "../
8
8
  import { A_TYPES__A_Dependency_LoadDecoratorReturn } from "./A-Dependency.types";
9
9
  import { A_DependencyError } from "./A-Dependency.error";
10
10
  import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
11
+ import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.constants";
11
12
 
12
13
 
13
14
  /**
@@ -51,6 +52,10 @@ export function A_Dependency_Load(
51
52
  case A_TypeGuards.isContainerInstance(target):
52
53
  metaKey = A_TYPES__ContainerMetaKey.INJECTIONS;
53
54
  break;
55
+
56
+ case A_TypeGuards.isEntityInstance(target):
57
+ metaKey = A_TYPES__EntityMetaKey.INJECTIONS;
58
+ break;
54
59
  }
55
60
 
56
61
  // get existing meta or create a new one
@@ -8,6 +8,7 @@ import { A_TYPES__A_InjectDecorator_Meta, A_TYPES__InjectableTargets } from "../
8
8
  import { A_TYPES__A_Dependency_ParentDecoratorReturn } from "./A-Dependency.types";
9
9
  import { A_DependencyError } from "./A-Dependency.error";
10
10
  import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
11
+ import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.constants";
11
12
 
12
13
 
13
14
  /**
@@ -49,6 +50,10 @@ export function A_Dependency_Parent(
49
50
  case A_TypeGuards.isContainerInstance(target):
50
51
  metaKey = A_TYPES__ContainerMetaKey.INJECTIONS;
51
52
  break;
53
+
54
+ case A_TypeGuards.isEntityInstance(target):
55
+ metaKey = A_TYPES__EntityMetaKey.INJECTIONS;
56
+ break;
52
57
  }
53
58
 
54
59
  // get existing meta or create a new one
@@ -8,6 +8,7 @@ import { A_TYPES__A_InjectDecorator_Meta, A_TYPES__InjectableTargets } from "../
8
8
  import { A_TYPES__A_Dependency_RequireDecoratorReturn } from "./A-Dependency.types";
9
9
  import { A_DependencyError } from "./A-Dependency.error";
10
10
  import { A_CommonHelper } from "@adaas/a-concept/helpers/A_Common.helper";
11
+ import { A_TYPES__EntityMetaKey } from "../A-Entity/A-Entity.constants";
11
12
 
12
13
 
13
14
  /**
@@ -42,6 +43,10 @@ export function A_Dependency_Require(): A_TYPES__A_Dependency_RequireDecoratorRe
42
43
  case A_TypeGuards.isContainerInstance(target):
43
44
  metaKey = A_TYPES__ContainerMetaKey.INJECTIONS;
44
45
  break;
46
+
47
+ case A_TypeGuards.isEntityInstance(target):
48
+ metaKey = A_TYPES__EntityMetaKey.INJECTIONS;
49
+ break;
45
50
  }
46
51
 
47
52
  // get existing meta or create a new one
@@ -1,4 +1,4 @@
1
- import { A_Component, A_Dependency, A_Entity, A_Error, A_Inject, A_Scope, A_ScopeError } from "../src";
1
+ import { A_Component, A_Dependency, A_Entity, A_Error, A_Feature, A_FeatureError, A_Inject, A_Scope, A_ScopeError } from "../src";
2
2
 
3
3
 
4
4
 
@@ -45,9 +45,23 @@ describe('A-Dependency tests', () => {
45
45
  ) {
46
46
  super();
47
47
  }
48
+
48
49
  }
49
50
 
50
- const scope = new A_Scope({ components: [Test] });
51
+ class testEntity extends A_Entity {
52
+
53
+ @A_Feature.Extend({
54
+ name: 'test'
55
+ })
56
+ async test(
57
+ @A_Dependency.Required()
58
+ @A_Inject(DependencyRequiredComponent) component: DependencyRequiredComponent,
59
+ ) {
60
+
61
+ }
62
+ }
63
+
64
+ const scope = new A_Scope({ components: [Test], entities: [new testEntity()] });
51
65
 
52
66
  try {
53
67
  scope.resolve(Test);
@@ -59,6 +73,18 @@ describe('A-Dependency tests', () => {
59
73
  const dependency = scope.resolve(DependencyRequiredComponent);
60
74
 
61
75
  expect(dependency).toBeUndefined();
76
+
77
+
78
+ const entityInstance = scope.resolve(testEntity);
79
+
80
+ try {
81
+ await entityInstance?.call('test');
82
+ } catch (error) {
83
+ expect(error).toBeInstanceOf(A_FeatureError);
84
+ expect((error as A_FeatureError).originalError).toBeInstanceOf(A_ScopeError);
85
+ expect((error as A_FeatureError).originalError.title).toBe(A_ScopeError.ResolutionError);
86
+ }
87
+
62
88
  });
63
89
  it('Should resolve a component if it has default constructor for dependency', async () => {
64
90
  class MyCustomEntity extends A_Entity<{ foo: string }> {