@adaas/a-concept 0.0.56 → 0.0.58

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.
Files changed (104) hide show
  1. package/.nvmrc +1 -1
  2. package/dist/src/base/A-Command/A_Command.constants.d.ts +12 -0
  3. package/dist/src/base/A-Command/A_Command.constants.js +17 -0
  4. package/dist/src/base/A-Command/A_Command.constants.js.map +1 -0
  5. package/dist/src/base/A-Command/A_Command.entity.d.ts +123 -0
  6. package/dist/src/base/A-Command/A_Command.entity.js +259 -0
  7. package/dist/src/base/A-Command/A_Command.entity.js.map +1 -0
  8. package/dist/src/base/A-Command/A_Command.types.d.ts +15 -0
  9. package/dist/src/base/A-Command/A_Command.types.js +3 -0
  10. package/dist/src/base/A-Command/A_Command.types.js.map +1 -0
  11. package/dist/src/base/A-Command/context/A_Command.context.d.ts +64 -0
  12. package/dist/src/base/A-Command/context/A_Command.context.js +85 -0
  13. package/dist/src/base/A-Command/context/A_Command.context.js.map +1 -0
  14. package/dist/src/base/A-Command/context/A_CommandFactory.context.js +2 -0
  15. package/dist/src/base/A-Command/context/A_CommandFactory.context.js.map +1 -0
  16. package/dist/src/base/A-Config/A-Config.container.d.ts +1 -2
  17. package/dist/src/base/A-Config/A-Config.container.js +2 -4
  18. package/dist/src/base/A-Config/A-Config.container.js.map +1 -1
  19. package/dist/src/base/A-Config/A-Config.context.d.ts +10 -11
  20. package/dist/src/base/A-Config/A-Config.context.js +5 -24
  21. package/dist/src/base/A-Config/A-Config.context.js.map +1 -1
  22. package/dist/src/base/A-Config/A-Config.types.d.ts +4 -4
  23. package/dist/src/base/A-Config/A-Config.types.js.map +1 -1
  24. package/dist/src/base/A-Config/components/ConfigReader.component.js +6 -12
  25. package/dist/src/base/A-Config/components/ConfigReader.component.js.map +1 -1
  26. package/dist/src/base/A-Config/components/ENVConfigReader.component.js +5 -1
  27. package/dist/src/base/A-Config/components/ENVConfigReader.component.js.map +1 -1
  28. package/dist/src/constants/env.constants.d.ts +26 -0
  29. package/dist/src/constants/env.constants.js +40 -0
  30. package/dist/src/constants/env.constants.js.map +1 -0
  31. package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +3 -3
  32. package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +9 -10
  33. package/dist/src/global/A-Channel/A-Channel.class.d.ts +2 -0
  34. package/dist/src/global/A-Channel/A-Channel.class.js +2 -0
  35. package/dist/src/global/A-Channel/A-Channel.class.js.map +1 -1
  36. package/dist/src/global/A-Concept/A_Concept.class.d.ts +5 -3
  37. package/dist/src/global/A-Concept/A_Concept.class.js +32 -27
  38. package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
  39. package/dist/src/global/A-Concept/A_Concept.meta.d.ts +1 -8
  40. package/dist/src/global/A-Concept/A_Concept.meta.js +1 -25
  41. package/dist/src/global/A-Concept/A_Concept.meta.js.map +1 -1
  42. package/dist/src/global/A-Concept/A_Concept.types.d.ts +10 -1
  43. package/dist/src/global/A-Container/A-Container.class.d.ts +5 -0
  44. package/dist/src/global/A-Container/A-Container.class.js +5 -0
  45. package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
  46. package/dist/src/global/A-Context/A-Context.class.d.ts +23 -1
  47. package/dist/src/global/A-Context/A-Context.class.js +38 -1
  48. package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
  49. package/dist/src/global/A-Entity/A-Entity.class.d.ts +124 -23
  50. package/dist/src/global/A-Entity/A-Entity.class.js +159 -49
  51. package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
  52. package/dist/src/global/A-Scope/A-Scope.class.d.ts +7 -6
  53. package/dist/src/global/A-Scope/A-Scope.class.js +57 -20
  54. package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
  55. package/dist/src/global/A-Stage/A-Stage.class.d.ts +3 -2
  56. package/dist/src/global/A-Stage/A-Stage.class.js +9 -6
  57. package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -1
  58. package/dist/src/global/A-Stage/A-Stage.types.d.ts +1 -1
  59. package/dist/src/helpers/StepsManager.class.js +1 -1
  60. package/dist/src/helpers/StepsManager.class.js.map +1 -1
  61. package/examples/simple/components/A.component.ts +9 -2
  62. package/examples/simple/concept.ts +6 -0
  63. package/examples/simple/entities/EntityA.entity.ts +18 -0
  64. package/jest.config.ts +1 -1
  65. package/package.json +3 -3
  66. package/src/base/A-Command/A_Command.constants.ts +20 -0
  67. package/src/base/A-Command/A_Command.entity.ts +287 -0
  68. package/src/base/A-Command/A_Command.types.ts +34 -0
  69. package/src/base/A-Command/context/A_Command.context.ts +114 -0
  70. package/src/base/A-Command/context/A_CommandFactory.context.ts +0 -0
  71. package/src/base/A-Config/A-Config.container.ts +0 -1
  72. package/src/base/A-Config/A-Config.context.ts +22 -28
  73. package/src/base/A-Config/A-Config.types.ts +5 -24
  74. package/src/base/A-Config/components/ConfigReader.component.ts +6 -15
  75. package/src/base/A-Config/components/ENVConfigReader.component.ts +6 -1
  76. package/src/constants/env.constants.ts +44 -0
  77. package/src/decorators/A-Inject/A-Inject.decorator.ts +3 -3
  78. package/src/decorators/A-Inject/A-Inject.decorator.types.ts +10 -9
  79. package/src/global/A-Channel/A-Channel.class.ts +2 -0
  80. package/src/global/A-Concept/A_Concept.class.ts +49 -32
  81. package/src/global/A-Concept/A_Concept.meta.ts +3 -41
  82. package/src/global/A-Concept/A_Concept.types.ts +6 -4
  83. package/src/global/A-Container/A-Container.class.ts +5 -2
  84. package/src/global/A-Context/A-Context.class.ts +67 -8
  85. package/src/global/A-Entity/A-Entity.class.ts +203 -73
  86. package/src/global/A-Scope/A-Scope.class.ts +88 -39
  87. package/src/global/A-Stage/A-Stage.class.ts +11 -7
  88. package/src/global/A-Stage/A-Stage.types.ts +1 -1
  89. package/src/helpers/StepsManager.class.ts +2 -2
  90. package/tests/A-Command.test.ts +130 -0
  91. package/tests/A-Component.test.ts +25 -0
  92. package/tests/A-Config.test.ts +106 -0
  93. package/tests/A-Entity.test.ts +191 -0
  94. package/tests/A-Feature.test.ts +131 -0
  95. package/tests/A-Scope.test.ts +163 -0
  96. package/dist/src/constants/A_ConceptLifecycle.constants.js +0 -11
  97. package/dist/src/constants/A_ConceptLifecycle.constants.js.map +0 -1
  98. package/src/constants/A_ConceptLifecycle.constants.ts +0 -12
  99. package/tests/channel.ts +0 -213
  100. package/tests/context.test.ts +0 -124
  101. package/tests/default.test.ts +0 -159
  102. package/tests/log.ts +0 -102
  103. package/tests/polyfill.test.ts +0 -37
  104. /package/dist/src/{constants/A_ConceptLifecycle.constants.d.ts → base/A-Command/context/A_CommandFactory.context.d.ts} +0 -0
@@ -1,43 +1,37 @@
1
1
  import { A_CommonHelper, A_TYPES__Required } from "@adaas/a-utils";
2
2
  import { A_TYPES__ConfigContainerConstructor } from "./A-Config.types";
3
3
  import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
4
+ import { A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY, A_TYPES__ConceptENVVariables } from "@adaas/a-concept/constants/env.constants";
4
5
 
5
6
 
6
7
  export class A_Config<
7
- T extends string = any
8
+ T extends Array<string | A_TYPES__ConceptENVVariables[number]> = A_TYPES__ConceptENVVariables
8
9
  > extends A_Fragment {
9
10
 
10
11
  config: A_TYPES__ConfigContainerConstructor<T>;
11
12
 
12
- // Custom properties
13
- private VARIABLES: Map<string, any> = new Map<string, any>();
14
13
 
15
- CONFIG_PROPERTIES: T[] = [];
14
+ private VARIABLES: Map<T[number], any> = new Map<T[number], any>();
16
15
 
17
- protected DEFAULT_ALLOWED_TO_READ_PROPERTIES = [
18
- 'CONFIG_SDK_VALIDATION',
19
- 'CONFIG_VERBOSE',
20
- 'CONFIG_IGNORE_ERRORS',
21
- 'CONCEPT_ROOT_FOLDER',
22
- ] as const;
16
+ CONFIG_PROPERTIES!: T;
17
+
18
+ protected DEFAULT_ALLOWED_TO_READ_PROPERTIES = A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY;
23
19
 
24
20
 
25
21
  constructor(
26
- config: A_TYPES__Required<Partial<A_TYPES__ConfigContainerConstructor<T>>, ['variables']>
22
+ config: Partial<A_TYPES__ConfigContainerConstructor<T>>
27
23
  ) {
28
24
  super(config);
29
25
 
30
26
  this.config = A_CommonHelper.deepCloneAndMerge<A_TYPES__ConfigContainerConstructor<T>>(config as any, {
31
27
  name: this.name,
32
28
  strict: false,
33
- defaults: {} as Record<T, any>,
34
- variables: [] as T[]
29
+ defaults: {},
30
+ variables: A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY as any as T
35
31
  });
36
32
 
37
- this.CONFIG_PROPERTIES = this.config.variables ? this.config.variables : [];
38
- }
33
+ this.CONFIG_PROPERTIES = this.config.variables ? this.config.variables : [] as any as T;
39
34
 
40
- protected async onInit(): Promise<void> {
41
35
  this.config.variables.forEach((variable) => {
42
36
  this.VARIABLES.set(variable, this.config.defaults[variable]);
43
37
  });
@@ -51,7 +45,7 @@ export class A_Config<
51
45
  * @returns
52
46
  */
53
47
  get<_OutType = any>(
54
- property: T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]
48
+ property: T[number] | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]
55
49
  ): _OutType {
56
50
  if (this.CONFIG_PROPERTIES.includes(property as any)
57
51
  || this.DEFAULT_ALLOWED_TO_READ_PROPERTIES.includes(property as any)
@@ -72,24 +66,24 @@ export class A_Config<
72
66
  *
73
67
  * @param variables
74
68
  */
75
- set<V extends string = T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]>(
69
+ set(
76
70
  variables: Array<{
77
- property: V,
71
+ property: T[number] | A_TYPES__ConceptENVVariables[number],
78
72
  value: any
79
73
  }>
80
74
  )
81
- set<V extends string = T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]>(
82
- variables: Record<V, any>
75
+ set(
76
+ variables: Partial<Record<T[number] | A_TYPES__ConceptENVVariables[number], any>>
83
77
  )
84
- set<V extends string = T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]>(
85
- property: V,
78
+ set(
79
+ property: T[number] | A_TYPES__ConceptENVVariables[number],
86
80
  value: any
87
81
  )
88
- set<V extends string = T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]>(
89
- property: V | Array<{
90
- property: V,
82
+ set(
83
+ property: T[number] | A_TYPES__ConceptENVVariables[number] | Array<{
84
+ property: T[number] | A_TYPES__ConceptENVVariables[number],
91
85
  value: any
92
- }> | Record<V, any>,
86
+ }> | Partial<Record<T[number] | A_TYPES__ConceptENVVariables[number], any>>,
93
87
  value?: any
94
88
  ) {
95
89
  const array = Array.isArray(property)
@@ -108,7 +102,7 @@ export class A_Config<
108
102
  let targetValue = value
109
103
  ? value
110
104
  : this.config?.defaults
111
- ? this.config.defaults[property as T]
105
+ ? this.config.defaults[property as T[number]]
112
106
  : undefined;
113
107
 
114
108
  this.VARIABLES.set(property as string, targetValue);
@@ -1,3 +1,4 @@
1
+ import { A_TYPES__ConceptENVVariables } from "@adaas/a-concept/constants/env.constants";
1
2
  import { A_TYPES__FragmentConstructor } from "@adaas/a-concept/global/A-Fragment/A-Fragment.types";
2
3
 
3
4
 
@@ -6,8 +7,8 @@ export enum A_TYPES__ConfigFeature {
6
7
  }
7
8
 
8
9
 
9
- export type A_TYPES__ConfigContainerConstructor<T extends string> = {
10
-
10
+ export type A_TYPES__ConfigContainerConstructor<T extends Array<string | A_TYPES__ConceptENVVariables[number]>> = {
11
+
11
12
  /**
12
13
  * If set to true, the SDK will throw an error if the variable is not defined OR not presented in the defaults
13
14
  */
@@ -16,32 +17,12 @@ export type A_TYPES__ConfigContainerConstructor<T extends string> = {
16
17
  /**
17
18
  * Allows to define the names of variable to be loaded
18
19
  */
19
- variables: Array<T>
20
+ variables: T
20
21
 
21
22
  /**
22
23
  * Allows to set the default values for the variables
23
24
  */
24
25
  defaults: {
25
- [key in T]?: any
26
+ [key in T[number]]?: any
26
27
  }
27
-
28
- // credentials?: {
29
- // /**
30
- // * Api Credentials Client ID to authenticate the SDK
31
- // * can be skipped for the FrontEnd SDKs
32
- // */
33
- // client_id: string,
34
-
35
- // /**
36
- // * Api Credentials Client Secret to authenticate the SDK
37
- // * can be skipped for the FrontEnd SDKs
38
- // */
39
- // client_secret: string
40
-
41
- // }
42
28
  } & A_TYPES__FragmentConstructor;
43
-
44
-
45
- export type A_TYPES__ConfigContainer_DefaultProperties = 'CONFIG_SDK_VALIDATION'
46
- | 'CONFIG_VERBOSE'
47
- | 'CONFIG_IGNORE_ERRORS';
@@ -4,6 +4,7 @@ import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorato
4
4
  import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
5
5
  import { A_Config } from "../A-Config.context";
6
6
  import { A_Concept } from "@adaas/a-concept/global/A-Concept/A_Concept.class";
7
+ import { A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY } from "@adaas/a-concept/constants/env.constants";
7
8
 
8
9
  /**
9
10
  * Config Reader
@@ -22,13 +23,16 @@ export class ConfigReader extends A_Component {
22
23
  @A_Inject(A_Config) config: A_Config,
23
24
  ) {
24
25
 
25
- const data = this.read(config.CONFIG_PROPERTIES);
26
+ const data = await this.read([
27
+ ...config.CONFIG_PROPERTIES,
28
+ ...A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY
29
+ ]);
26
30
 
27
31
  config.set(data);
28
32
 
29
33
  const rootDir = await this.getProjectRoot();
30
34
 
31
- config.set('CONCEPT_ROOT_FOLDER', rootDir);
35
+ config.set('A_CONCEPT_ROOT_FOLDER', rootDir);
32
36
  }
33
37
 
34
38
 
@@ -59,19 +63,6 @@ export class ConfigReader extends A_Component {
59
63
  * @returns {string|null} - The path to the root directory or null if package.json is not found
60
64
  */
61
65
  protected async getProjectRoot(startPath = __dirname) {
62
- // let currentPath = startPath;
63
-
64
- // const fs = await A_Polyfills.fs();
65
-
66
- // while (!fs.existsSync(`${currentPath}/package.json`)) {
67
- // const parentPath = currentPath.substring(0, currentPath.lastIndexOf('/'));
68
- // if (parentPath === currentPath || parentPath === '') {
69
- // // Reached the root of the filesystem without finding package.json
70
- // return null;
71
- // }
72
- // currentPath = parentPath;
73
- // }
74
-
75
66
  return process.cwd();
76
67
  }
77
68
  }
@@ -1,5 +1,7 @@
1
1
  import { A_CommonHelper } from "@adaas/a-utils";
2
2
  import { ConfigReader } from "./ConfigReader.component";
3
+ import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
4
+ import { A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY } from "@adaas/a-concept/constants/env.constants";
3
5
 
4
6
 
5
7
  export class ENVConfigReader extends ConfigReader {
@@ -10,7 +12,10 @@ export class ENVConfigReader extends ConfigReader {
10
12
  * @param property
11
13
  */
12
14
  getConfigurationProperty_ENV_Alias(property: string): string {
13
- return `${A_CommonHelper.toUpperSnakeCase(this.scope.name)}_${A_CommonHelper.toUpperSnakeCase(property)}`;
15
+ if (A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY.some(p => p === property))
16
+ return A_CommonHelper.toUpperSnakeCase(property);
17
+
18
+ return `${A_CommonHelper.toUpperSnakeCase(A_Context.root.name)}_${A_CommonHelper.toUpperSnakeCase(property)}`;
14
19
  }
15
20
 
16
21
 
@@ -0,0 +1,44 @@
1
+ export const A_CONSTANTS__DEFAULT_ENV_VARIABLES = {
2
+ // ----------------------------------------------------------
3
+ // A-Concept Core Environment Variables
4
+ // ----------------------------------------------------------
5
+ // These environment variables are used by A-Concept core to configure the application
6
+ // ----------------------------------------------------------
7
+ /**
8
+ * Namespace of the application
9
+ * [!] Provided name will be used for all aseids in the application by default
10
+ */
11
+ A_CONCEPT_NAMESPACE: 'A_CONCEPT_NAMESPACE',
12
+ /**
13
+ * Default scope of the application
14
+ * [!] Provided name will be used for all aseids in the application by default
15
+ */
16
+ A_CONCEPT_DEFAULT_SCOPE: 'A_CONCEPT_DEFAULT_SCOPE',
17
+ /**
18
+ * Environment of the application e.g. development, production, staging
19
+ */
20
+ A_CONCEPT_ENVIRONMENT: 'A_CONCEPT_ENVIRONMENT',
21
+ /**
22
+ * Root folder of the application
23
+ * [!] Automatically set by A-Concept when the application starts
24
+ */
25
+ A_CONCEPT_ROOT_FOLDER: 'A_CONCEPT_ROOT_FOLDER',
26
+
27
+ CONFIG_SDK_VALIDATION: 'CONFIG_SDK_VALIDATION',
28
+ CONFIG_VERBOSE: 'CONFIG_VERBOSE',
29
+ CONFIG_IGNORE_ERRORS: 'CONFIG_IGNORE_ERRORS',
30
+ } as const
31
+
32
+
33
+ //should be an array
34
+ export type A_TYPES__ConceptENVVariables = (typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES)[keyof typeof A_CONSTANTS__DEFAULT_ENV_VARIABLES][];
35
+
36
+
37
+ export const A_CONSTANTS__DEFAULT_ENV_VARIABLES_ARRAY = [
38
+ A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_NAMESPACE,
39
+ A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_ENVIRONMENT,
40
+ A_CONSTANTS__DEFAULT_ENV_VARIABLES.A_CONCEPT_ROOT_FOLDER,
41
+ A_CONSTANTS__DEFAULT_ENV_VARIABLES.CONFIG_VERBOSE,
42
+ A_CONSTANTS__DEFAULT_ENV_VARIABLES.CONFIG_IGNORE_ERRORS,
43
+ ] as const;
44
+
@@ -46,9 +46,9 @@ export function A_Inject(
46
46
  fragment: { new(...args: any[]): A_Fragment }
47
47
  ): A_TYPES__A_InjectDecoratorReturn
48
48
 
49
- export function A_Inject(
50
- entity: { new(...args: any[]): A_Entity },
51
- config: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions>
49
+ export function A_Inject<T extends A_Entity>(
50
+ entity: { new(...args: any[]): T },
51
+ config: Partial<A_TYPES__A_InjectDecorator_EntityInjectionInstructions<T>>
52
52
  ): A_TYPES__A_InjectDecoratorReturn
53
53
 
54
54
  // ====================== BASE FUNCTION ======================
@@ -2,6 +2,7 @@ import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.cla
2
2
  import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
3
3
  import { A_Entity } from "@adaas/a-concept/global/A-Entity/A-Entity.class";
4
4
  import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
5
+ import { A_FeatureCaller } from "@adaas/a-concept/global/A-Feature/A-FeatureCaller.class";
5
6
  import { A_Fragment } from "@adaas/a-concept/global/A-Fragment/A-Fragment.class";
6
7
  import { A_Scope } from "@adaas/a-concept/global/A-Scope/A-Scope.class";
7
8
  import { ASEID } from "@adaas/a-utils";
@@ -60,21 +61,21 @@ export type A_TYPES__A_InjectDecorator_Injectable =
60
61
  | { new(...args: any[]): A_Container }
61
62
  | { new(...args: any[]): A_Scope }
62
63
  | { new(...args: any[]): A_Feature }
63
- | { new(...args: any[]): A_Entity };
64
+ | { new(...args: any[]): A_Entity }
65
+ | { new(...args: any[]): A_FeatureCaller };
64
66
 
65
67
 
66
- export type A_TYPES__A_InjectDecorator_EntityInjectionInstructions = {
67
- query: Partial<A_TYPES__A_InjectDecorator_EntityInjectionQuery>,
68
+ export type A_TYPES__A_InjectDecorator_EntityInjectionInstructions<T extends A_Entity = A_Entity> = {
69
+ query: Partial<A_TYPES__A_InjectDecorator_EntityInjectionQuery<T>>,
68
70
  pagination: Partial<A_TYPES__A_InjectDecorator_EntityInjectionPagination>
69
71
  }
70
72
 
71
73
 
72
- export type A_TYPES__A_InjectDecorator_EntityInjectionQuery = {
73
- aseid: string | ASEID,
74
- id: string,
75
- type: { new(...args: any[]): A_Entity },
76
- entity: string
77
- }
74
+ export type A_TYPES__A_InjectDecorator_EntityInjectionQuery<T extends A_Entity = A_Entity> = {
75
+ aseid: string,
76
+ } & {
77
+ [key in keyof T]?: any
78
+ };
78
79
 
79
80
 
80
81
  export type A_TYPES__A_InjectDecorator_EntityInjectionPagination = {
@@ -4,6 +4,8 @@ import { A_TYPES__A_ChannelAggregated, A_TYPES__A_ChannelAggregateMethods, A_TYP
4
4
 
5
5
 
6
6
  /**
7
+ * [!] DEPRECATED - use simply A_Component instead
8
+ *
7
9
  * A_Channel is an abstraction over any Communication Type from event emitters to message queues, HTTP requests, etc.
8
10
  *
9
11
  * A_Channel uses to connect Containers between each other. When
@@ -1,14 +1,10 @@
1
- import { A_TYPES__ConceptStage, A_TYPES__ConceptAbstractionCallParams, A_TYPES__IConceptConstructor, A_TYPES__ConceptAbstractionMeta } from "./A_Concept.types";
1
+ import { A_TYPES__ConceptStage, A_TYPES__IConceptConstructor } from "./A_Concept.types";
2
2
  import { A_Container } from "../A-Container/A-Container.class";
3
3
  import { A_Abstraction } from "../A-Abstraction/A-Abstraction.class";
4
4
  import { A_ConceptMeta } from "./A_Concept.meta";
5
5
  import { A_Abstraction_Extend } from "@adaas/a-concept/decorators/A-Abstraction/A-Abstraction-Extend.decorator";
6
6
  import { A_Scope } from "../A-Scope/A-Scope.class";
7
- import { A_TYPES__A_InjectDecorator_EntityInjectionInstructions, A_TYPES__A_InjectDecorator_Injectable } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator.types";
8
-
9
-
10
- // export type RunParams<T> = T extends A_Container<any, infer Params> ? Params : never;
11
-
7
+ import { A_Context } from "../A-Context/A-Context.class";
12
8
 
13
9
 
14
10
  /**
@@ -24,7 +20,7 @@ import { A_TYPES__A_InjectDecorator_EntityInjectionInstructions, A_TYPES__A_Inje
24
20
  *
25
21
  */
26
22
  export class A_Concept<
27
- _Imports extends A_Container[] = any
23
+ _Imports extends A_Container[] = A_Container[]
28
24
  > {
29
25
 
30
26
  // ==============================================================================
@@ -85,8 +81,8 @@ export class A_Concept<
85
81
  }
86
82
 
87
83
 
88
- private sharedBase!: A_Container;
89
84
  private meta!: A_ConceptMeta
85
+ private _name!: string;
90
86
 
91
87
 
92
88
 
@@ -99,44 +95,41 @@ export class A_Concept<
99
95
  constructor(
100
96
  protected props: A_TYPES__IConceptConstructor<_Imports>
101
97
  ) {
102
- this.sharedBase = new A_Container({
103
- name: `${props.name}::base`,
104
- fragments: props.fragments || [],
105
- entities: props.entities || [],
106
- components: [
107
- // A_Logger,
108
- ],
109
- });
98
+ this._name = props.name || A_Context.root.name;
110
99
 
111
- this.containers = (props.containers || []).map(container => {
112
- container.Scope.parent(this.Scope);
113
- return container;
114
- });
100
+ if (props.components && props.components.length)
101
+ props.components.forEach(component => this.Scope.register(component))
102
+
103
+ if (props.fragments && props.fragments.length)
104
+ props.fragments.forEach(fragment => this.Scope.register(fragment))
115
105
 
116
- this.meta = new A_ConceptMeta(this.containers, this.sharedBase);
106
+ if (props.entities && props.entities.length)
107
+ props.entities.forEach(entity => this.Scope.register(entity))
108
+
109
+ this.containers = props.containers || [];
117
110
  }
118
111
 
119
112
 
120
113
  get namespace() {
121
- return this.sharedBase.name;
114
+ return A_Context.root.name;
122
115
  }
123
116
 
124
117
  get Scope() {
125
- return this.sharedBase.Scope;
118
+ return A_Context.root;
126
119
  }
127
120
 
128
121
  /**
129
122
  * Register a class or value in the concept scope.
130
123
  */
131
124
  get register(): A_Scope['register'] {
132
- return this.sharedBase.Scope.register.bind(this.sharedBase.Scope);
125
+ return this.Scope.register.bind(this.Scope);
133
126
  }
134
127
 
135
128
  /**
136
129
  * Resolve a class or value from the concept scope.
137
130
  */
138
131
  get resolve(): A_Scope['resolve'] {
139
- return this.sharedBase.Scope.resolve.bind(this.sharedBase.Scope);
132
+ return this.Scope.resolve.bind(this.Scope);
140
133
  }
141
134
 
142
135
 
@@ -153,7 +146,7 @@ export class A_Concept<
153
146
  ) {
154
147
  scope = scope ? scope.inherit(this.Scope) : this.Scope;
155
148
 
156
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Load, scope);
149
+ const abstraction = this.abstraction(A_TYPES__ConceptStage.Load, scope);
157
150
 
158
151
  await abstraction.process();
159
152
  }
@@ -168,7 +161,7 @@ export class A_Concept<
168
161
  ) {
169
162
  scope = scope ? scope.inherit(this.Scope) : this.Scope;
170
163
 
171
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Run, scope);
164
+ const abstraction = this.abstraction(A_TYPES__ConceptStage.Run, scope);
172
165
 
173
166
  await abstraction.process();
174
167
  }
@@ -184,7 +177,7 @@ export class A_Concept<
184
177
  ) {
185
178
  scope = scope ? scope.inherit(this.Scope) : this.Scope;
186
179
 
187
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Start, scope);
180
+ const abstraction = this.abstraction(A_TYPES__ConceptStage.Start, scope);
188
181
 
189
182
  await abstraction.process();
190
183
  }
@@ -200,7 +193,7 @@ export class A_Concept<
200
193
  ) {
201
194
  scope = scope ? scope.inherit(this.Scope) : this.Scope;
202
195
 
203
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Stop, scope);
196
+ const abstraction = this.abstraction(A_TYPES__ConceptStage.Stop, scope);
204
197
 
205
198
  await abstraction.process();
206
199
  }
@@ -214,7 +207,7 @@ export class A_Concept<
214
207
  ) {
215
208
  scope = scope ? scope.inherit(this.Scope) : this.Scope;
216
209
 
217
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Build, scope);
210
+ const abstraction = this.abstraction(A_TYPES__ConceptStage.Build, scope);
218
211
 
219
212
  await abstraction.process();
220
213
  }
@@ -228,7 +221,7 @@ export class A_Concept<
228
221
  ) {
229
222
  scope = scope ? scope.inherit(this.Scope) : this.Scope;
230
223
 
231
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Deploy, scope);
224
+ const abstraction = this.abstraction(A_TYPES__ConceptStage.Deploy, scope);
232
225
 
233
226
  await abstraction.process();
234
227
 
@@ -243,7 +236,7 @@ export class A_Concept<
243
236
  ) {
244
237
  scope = scope ? scope.inherit(this.Scope) : this.Scope;
245
238
 
246
- const abstraction = this.meta.abstraction(A_TYPES__ConceptStage.Publish, scope);
239
+ const abstraction = this.abstraction(A_TYPES__ConceptStage.Publish, scope);
247
240
 
248
241
  await abstraction.process();
249
242
  }
@@ -272,6 +265,30 @@ export class A_Concept<
272
265
  // await feature.process();
273
266
  }
274
267
 
268
+
269
+
270
+ protected abstraction(
271
+ method: A_TYPES__ConceptStage,
272
+ scope: A_Scope
273
+ ): A_Abstraction {
274
+
275
+ const featureDefinitions = this.containers.map(container => {
276
+ const definition = A_Context.abstractionDefinition(container, method, container.Scope);
277
+
278
+ return {
279
+ ...definition,
280
+ steps: definition.steps.map(step => ({ ...step, component: step.component ? step.component : container }))
281
+ }
282
+ });
283
+
284
+ const definition = {
285
+ name: `${this.namespace}.${method}`,
286
+ features: featureDefinitions,
287
+ scope
288
+ };
289
+
290
+ return new A_Abstraction(definition);
291
+ }
275
292
  }
276
293
 
277
294
 
@@ -10,6 +10,7 @@ import { A_TYPES__A_FeatureDecoratorConfig } from "@adaas/a-concept/decorators/A
10
10
  import { A_TYPES__A_AbstractionConstructor } from "../A-Abstraction/A-Abstraction.types";
11
11
  import { A_Abstraction } from "../A-Abstraction/A-Abstraction.class";
12
12
  import { A_Scope } from "../A-Scope/A-Scope.class";
13
+ import { A_Concept } from "./A_Concept.class";
13
14
  // import { A_TYPES__ComponentMeta } from "./A-Component.types";
14
15
 
15
16
 
@@ -18,53 +19,14 @@ export class A_ConceptMeta extends A_Meta<any> {
18
19
 
19
20
  constructor(
20
21
  private containers: Array<A_Container>,
21
- private base: A_Container
22
22
  ) {
23
23
  super();
24
24
  }
25
25
 
26
- abstractionDefinition(
27
- method: A_TYPES__ConceptStage,
28
- scope: A_Scope
29
- ): A_TYPES__A_AbstractionConstructor {
26
+
30
27
 
31
- const featureDefinitions = this.containers.map(container =>
32
- A_Context.abstractionDefinition(container, method, scope)
33
- );
34
28
 
35
- const definition = {
36
- name: `${this.base.name}.${method}`,
37
- features: featureDefinitions,
38
- scope
39
- };
40
29
 
41
- return definition;
42
- }
43
-
44
-
45
-
46
- abstraction(
47
- method: A_TYPES__ConceptStage,
48
- scope: A_Scope
49
- ): A_Abstraction {
50
-
51
- const featureDefinitions = this.containers.map(container => {
52
- const definition = A_Context.abstractionDefinition(container, method, container.Scope);
53
-
54
- return {
55
- ...definition,
56
- steps: definition.steps.map(step => ({ ...step, component: step.component ? step.component : container }))
57
- }
58
- });
59
-
60
-
61
- const definition = {
62
- name: `${this.base.name}.${method}`,
63
- features: featureDefinitions,
64
- scope
65
- };
66
-
67
- return new A_Abstraction(definition);
68
- }
30
+
69
31
 
70
32
  }
@@ -37,7 +37,7 @@ export enum A_TYPES__ConceptMetaKey {
37
37
  export interface A_TYPES__IConceptConstructor<
38
38
  T extends Array<A_Container>
39
39
  > {
40
- name: string,
40
+ name?: string,
41
41
 
42
42
  /**
43
43
  * A set of Context Fragments to register globally for the concept.
@@ -62,10 +62,12 @@ export interface A_TYPES__IConceptConstructor<
62
62
 
63
63
 
64
64
  /**
65
- * A set of external Concepts that can be used in the current Concept.
66
- * To provide additional functionality or extend the current Concept.
65
+ * A set of Components available for all containers and fragments in the concept.
66
+ * These components will be registered in the root scope of the concept.
67
+ *
68
+ * [!] Note that these components will be available in all containers and fragments in the concept.
67
69
  */
68
- // import?: Array<A_Concept>
70
+ components?: Array<{ new(...args: any[]): A_Component }>
69
71
  }
70
72
 
71
73
 
@@ -18,8 +18,6 @@ import { A_TYPES__FeatureCallParams, A_TYPES__FeatureConstructor } from "../A-Fe
18
18
  * - etc.
19
19
  */
20
20
  export class A_Container {
21
- // scope!: A_Scope
22
-
23
21
  protected readonly config!: Partial<A_TYPES__ContainerConstructor<any>>;
24
22
 
25
23
  /**
@@ -36,6 +34,11 @@ export class A_Container {
36
34
  }
37
35
 
38
36
 
37
+ /**
38
+ * Creates a new instance of A_Container
39
+ *
40
+ * @param config
41
+ */
39
42
  constructor(
40
43
  /**
41
44
  * Configuration of the container that will be used to run it.