@adaas/a-concept 0.0.29 → 0.0.30
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/fe-be/channels/Test.channel.d.ts +6 -0
- package/dist/examples/fe-be/channels/Test.channel.js +14 -0
- package/dist/examples/fe-be/channels/Test.channel.js.map +1 -0
- package/dist/examples/fe-be/components/BE-Controller.component.d.ts +4 -0
- package/dist/examples/fe-be/components/BE-Controller.component.js +24 -0
- package/dist/examples/fe-be/components/BE-Controller.component.js.map +1 -0
- package/dist/examples/fe-be/components/FE.component.d.ts +4 -0
- package/dist/examples/fe-be/components/FE.component.js +31 -0
- package/dist/examples/fe-be/components/FE.component.js.map +1 -0
- package/dist/examples/fe-be/components/UserActions.component.d.ts +5 -0
- package/dist/examples/fe-be/components/UserActions.component.js +25 -0
- package/dist/examples/fe-be/components/UserActions.component.js.map +1 -0
- package/dist/examples/fe-be/concept.d.ts +0 -0
- package/dist/examples/fe-be/concept.js +2 -0
- package/dist/examples/fe-be/concept.js.map +1 -0
- package/dist/examples/fe-be/containers/ServerApp.container.d.ts +3 -0
- package/dist/examples/fe-be/containers/ServerApp.container.js +8 -0
- package/dist/examples/fe-be/containers/ServerApp.container.js.map +1 -0
- package/dist/examples/fe-be/containers/WebApp.container.d.ts +3 -0
- package/dist/examples/fe-be/containers/WebApp.container.js +8 -0
- package/dist/examples/fe-be/containers/WebApp.container.js.map +1 -0
- package/dist/examples/multi-container/channels/Direct.channel.d.ts +9 -0
- package/dist/examples/multi-container/channels/Direct.channel.js +32 -0
- package/dist/examples/multi-container/channels/Direct.channel.js.map +1 -0
- package/dist/examples/multi-container/concept.d.ts +0 -0
- package/dist/examples/multi-container/concept.js +2 -0
- package/dist/examples/multi-container/concept.js.map +1 -0
- package/dist/examples/multi-container/containers/Command.container.d.ts +11 -0
- package/dist/examples/multi-container/containers/Command.container.js +51 -0
- package/dist/examples/multi-container/containers/Command.container.js.map +1 -0
- package/dist/examples/multi-container/containers/Schedule.container.d.ts +15 -0
- package/dist/examples/multi-container/containers/Schedule.container.js +67 -0
- package/dist/examples/multi-container/containers/Schedule.container.js.map +1 -0
- package/dist/examples/simple/components/A.component.js.map +1 -1
- package/dist/examples/simple/containers/Main.container.js +7 -3
- package/dist/examples/simple/containers/Main.container.js.map +1 -1
- package/dist/examples/simple/entities/EntityA.entity.d.ts +8 -0
- package/dist/examples/simple/entities/EntityA.entity.js +22 -0
- package/dist/examples/simple/entities/EntityA.entity.js.map +1 -0
- package/dist/examples/simple-http-server/contexts/http-request.context.d.ts +0 -1
- package/dist/examples/simple-http-server/contexts/http-request.context.js +6 -8
- package/dist/examples/simple-http-server/contexts/http-request.context.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.js +16 -7
- package/dist/index.js.map +1 -1
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.d.ts +14 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js +53 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.js.map +1 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.d.ts +2 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js +3 -0
- package/dist/src/decorators/A-Abstraction/A-Abstraction.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.d.ts +19 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.js +31 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.js.map +1 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.types.d.ts +1 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js +3 -0
- package/dist/src/decorators/A-Connect/A-Connect.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Entity/A-Entity-List.decorator.d.ts +1 -0
- package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js +8 -0
- package/dist/src/decorators/A-Entity/A-Entity-List.decorator.js.map +1 -0
- package/dist/src/decorators/A-Entity/A-Entity.decorator.types.d.ts +14 -0
- package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js +3 -0
- package/dist/src/decorators/A-Entity/A-Entity.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js +9 -0
- package/dist/src/decorators/A-Feature/A-Feature-Extend.decorator.js.map +1 -1
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +28 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +2 -3
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -1
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +44 -0
- package/dist/src/global/A-Channel/A-Channel.class.d.ts +8 -10
- package/dist/src/global/A-Channel/A-Channel.class.js +12 -26
- package/dist/src/global/A-Channel/A-Channel.class.js.map +1 -1
- package/dist/src/global/A-Channel/A-Channel.types.d.ts +32 -0
- package/dist/src/global/A-Component/A-Component.class.d.ts +2 -1
- package/dist/src/global/A-Component/A-Component.class.js +1 -0
- package/dist/src/global/A-Component/A-Component.class.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.meta.d.ts +8 -0
- package/dist/src/global/A-Component/A-Component.meta.js +27 -1
- package/dist/src/global/A-Component/A-Component.meta.js.map +1 -1
- package/dist/src/global/A-Component/A-Component.types.d.ts +19 -34
- package/dist/src/global/A-Component/A-Component.types.js +1 -7
- package/dist/src/global/A-Component/A-Component.types.js.map +1 -1
- package/dist/src/global/A-Concept/A_Concept.class.d.ts +7 -7
- package/dist/src/global/A-Concept/A_Concept.class.js +30 -30
- package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -1
- package/dist/src/global/A-Concept/A_Concept.types.d.ts +42 -2
- package/dist/src/global/A-Concept/A_Concept.types.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.class.d.ts +1 -8
- package/dist/src/global/A-Container/A-Container.class.js +1 -31
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.meta.d.ts +8 -0
- package/dist/src/global/A-Container/A-Container.meta.js +29 -0
- package/dist/src/global/A-Container/A-Container.meta.js.map +1 -1
- package/dist/src/global/A-Container/A-Container.types.d.ts +23 -7
- package/dist/src/global/A-Container/A-Container.types.js +2 -1
- package/dist/src/global/A-Container/A-Container.types.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.class.js +6 -35
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.class.d.ts +1 -2
- package/dist/src/global/A-Entity/A-Entity.class.js +6 -7
- package/dist/src/global/A-Entity/A-Entity.class.js.map +1 -1
- package/dist/src/global/A-Entity/A-Entity.types.d.ts +4 -5
- package/dist/src/global/A-Entity/A-Entity.types.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.class.d.ts +30 -6
- package/dist/src/global/A-Feature/A-Feature.class.js +49 -40
- package/dist/src/global/A-Feature/A-Feature.class.js.map +1 -1
- package/dist/src/global/A-Feature/A-Feature.types.d.ts +2 -24
- package/dist/src/global/A-Feature/A-Feature.types.js +21 -0
- package/dist/src/global/A-Feature/A-Feature.types.js.map +1 -1
- package/dist/src/global/A-Fragment/A-Fragment.class.d.ts +8 -0
- package/dist/src/global/A-Fragment/A-Fragment.class.js +10 -0
- package/dist/src/global/A-Fragment/A-Fragment.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.class.d.ts +7 -5
- package/dist/src/global/A-Scope/A-Scope.class.js +33 -10
- package/dist/src/global/A-Scope/A-Scope.class.js.map +1 -1
- package/dist/src/global/A-Scope/A-Scope.types.d.ts +2 -1
- package/dist/src/global/A-Stage/A-Stage.class.d.ts +69 -0
- package/dist/src/global/A-Stage/A-Stage.class.js +176 -0
- package/dist/src/global/A-Stage/A-Stage.class.js.map +1 -0
- package/dist/src/global/A-Stage/A-Stage.types.d.ts +83 -0
- package/dist/src/global/A-Stage/A-Stage.types.js +59 -0
- package/dist/src/global/A-Stage/A-Stage.types.js.map +1 -0
- package/dist/src/helpers/StepsManager.class.d.ts +15 -0
- package/dist/src/helpers/StepsManager.class.js +85 -0
- package/dist/src/helpers/StepsManager.class.js.map +1 -0
- package/examples/fe-be/channels/Test.channel.ts +24 -0
- package/examples/fe-be/components/BE-Controller.component.ts +20 -0
- package/examples/fe-be/components/FE.component.ts +13 -0
- package/examples/fe-be/concept.ts +0 -0
- package/examples/fe-be/containers/ServerApp.container.ts +8 -0
- package/examples/fe-be/containers/WebApp.container.ts +13 -0
- package/examples/multi-container/channels/Direct.channel.ts +39 -0
- package/examples/multi-container/concept.ts +0 -0
- package/examples/multi-container/containers/Command.container.ts +41 -0
- package/examples/multi-container/containers/Schedule.container.ts +57 -0
- package/examples/simple/components/A.component.ts +2 -1
- package/examples/simple/containers/Main.container.ts +11 -3
- package/examples/simple/entities/EntityA.entity.ts +16 -0
- package/examples/simple-http-server/contexts/http-request.context.ts +6 -6
- package/index.ts +12 -3
- package/package.json +1 -1
- package/src/decorators/A-Abstraction/A-Abstraction.decorator.ts +82 -0
- package/src/decorators/{A-Stage/A-Stage.decorator.types.ts → A-Abstraction/A-Abstraction.decorator.types.ts} +1 -3
- package/src/decorators/A-Connect/A-Connect.decorator.ts +71 -0
- package/src/decorators/A-Connect/A-Connect.decorator.types.ts +6 -0
- package/src/decorators/A-Entity/A-Entity-List.decorator.ts +12 -0
- package/src/decorators/A-Entity/A-Entity.decorator.types.ts +18 -0
- package/src/decorators/A-Feature/A-Feature-Extend.decorator.ts +10 -0
- package/src/decorators/A-Feature/A-Feature.decorator.types.ts +36 -0
- package/src/decorators/A-Inject/A-Inject.decorator.ts +7 -7
- package/src/decorators/A-Inject/A-Inject.decorator.types.ts +47 -1
- package/src/global/A-Channel/A-Channel.class.ts +25 -28
- package/src/global/A-Channel/A-Channel.types.ts +53 -0
- package/src/global/A-Component/A-Component.class.ts +10 -2
- package/src/global/A-Component/A-Component.meta.ts +42 -1
- package/src/global/A-Component/A-Component.types.ts +20 -40
- package/src/global/A-Concept/A_Concept.class.ts +52 -31
- package/src/global/A-Concept/A_Concept.types.ts +48 -3
- package/src/global/A-Container/A-Container.class.ts +3 -39
- package/src/global/A-Container/A-Container.meta.ts +41 -4
- package/src/global/A-Container/A-Container.types.ts +28 -7
- package/src/global/A-Context/A-Context.class.ts +9 -49
- package/src/global/A-Entity/A-Entity.class.ts +8 -6
- package/src/global/A-Entity/A-Entity.types.ts +4 -5
- package/src/global/A-Feature/A-Feature.class.ts +73 -61
- package/src/global/A-Feature/A-Feature.types.ts +24 -23
- package/src/global/A-Fragment/A-Fragment.class.ts +15 -0
- package/src/global/A-Scope/A-Scope.class.ts +58 -25
- package/src/global/A-Scope/A-Scope.types.ts +2 -1
- package/src/global/A-Stage/A-Stage.class.ts +225 -0
- package/src/global/A-Stage/A-Stage.types.ts +106 -0
- package/src/helpers/StepsManager.class.ts +104 -0
- package/tests/channel.ts +213 -0
- package/tests/log.ts +88 -40
- package/src/decorators/A-Stage/A-Stage.decorator.ts +0 -84
package/tests/channel.ts
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
2
|
+
// import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
3
|
+
// import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
4
|
+
// import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
5
|
+
// import { EventEmitter } from "stream";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// class ComponentA extends A_Component<[
|
|
9
|
+
// 'method1',
|
|
10
|
+
// 'method2'
|
|
11
|
+
// ]> {
|
|
12
|
+
|
|
13
|
+
// @A_Feature.Define({
|
|
14
|
+
// name: 'method1',
|
|
15
|
+
// channels: []
|
|
16
|
+
// } as any)
|
|
17
|
+
// async method1() {
|
|
18
|
+
|
|
19
|
+
// }
|
|
20
|
+
|
|
21
|
+
// @A_Feature.Define({
|
|
22
|
+
// name: 'method2',
|
|
23
|
+
// channels: []
|
|
24
|
+
// } as any)
|
|
25
|
+
// async method2() {
|
|
26
|
+
|
|
27
|
+
// }
|
|
28
|
+
// }
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
// class ComponentB extends A_Component<[
|
|
32
|
+
// 'ComponentB_method3',
|
|
33
|
+
// 'ComponentB_method4'
|
|
34
|
+
// ]> {
|
|
35
|
+
|
|
36
|
+
// @A_Feature.Define({
|
|
37
|
+
// name: 'ComponentB_method3',
|
|
38
|
+
// channels: []
|
|
39
|
+
// } as any)
|
|
40
|
+
// async ComponentB_method3(param1: {
|
|
41
|
+
// key: string
|
|
42
|
+
// }) {
|
|
43
|
+
|
|
44
|
+
// }
|
|
45
|
+
|
|
46
|
+
// @A_Feature.Define({
|
|
47
|
+
// name: 'ComponentB_method4',
|
|
48
|
+
// channels: []
|
|
49
|
+
// } as any)
|
|
50
|
+
// async ComponentB_method4(foo: number) {
|
|
51
|
+
|
|
52
|
+
// }
|
|
53
|
+
// }
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
// type MethodsWithSpecificArg<T, ArgType> = {
|
|
58
|
+
// [K in keyof T]: T[K] extends (arg: ArgType, ...args: any[]) => Promise<any> ? K : never
|
|
59
|
+
// }[keyof T];
|
|
60
|
+
|
|
61
|
+
// // Example argument type
|
|
62
|
+
// type SpecificArgType = { key: string };
|
|
63
|
+
|
|
64
|
+
// type AggregateMethods<TClasses extends A_Component[]> = {
|
|
65
|
+
// [K in keyof TClasses]: TClasses[K] extends infer Instance
|
|
66
|
+
// ? MethodsWithSpecificArg<Instance, SpecificArgType>
|
|
67
|
+
// : never;
|
|
68
|
+
// }[number];
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// type MethodObject2<TClasses extends any[]> = {
|
|
72
|
+
// [Method in AggregateMethods<TClasses>]: {
|
|
73
|
+
// [Class in keyof TClasses]: TClasses[Class] extends infer Instance
|
|
74
|
+
// ? Method extends keyof Instance
|
|
75
|
+
// ? Instance[Method]
|
|
76
|
+
// : never
|
|
77
|
+
// : never;
|
|
78
|
+
// }[number]; // Select the method signature from any matching class
|
|
79
|
+
// };
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
// // decorator to create a channel
|
|
84
|
+
// function A_Connect() {
|
|
85
|
+
// return function (target: any, prop: string) {
|
|
86
|
+
// console.log('A_Connect', target, prop);
|
|
87
|
+
// }
|
|
88
|
+
// }
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
// class Channel<T extends A_Component[]> {
|
|
93
|
+
|
|
94
|
+
// channel: MethodObject2<T>;
|
|
95
|
+
|
|
96
|
+
// constructor() {
|
|
97
|
+
// this.channel = new Proxy(
|
|
98
|
+
// {} as MethodObject2<T>,
|
|
99
|
+
// {
|
|
100
|
+
// get: (target, prop) => {
|
|
101
|
+
// return async (...args: any[]) => {
|
|
102
|
+
// this.call(prop as AggregateMethods<T>);
|
|
103
|
+
// };
|
|
104
|
+
// }
|
|
105
|
+
// });
|
|
106
|
+
// }
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
// async call(prop: AggregateMethods<T>) {
|
|
110
|
+
// // do HTTP Call or just inject class or whatever you want
|
|
111
|
+
|
|
112
|
+
// console.log('Calling method', prop);
|
|
113
|
+
// }
|
|
114
|
+
|
|
115
|
+
// }
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
// class HTTP<T extends A_Component[]> extends Channel<T> {
|
|
121
|
+
|
|
122
|
+
// async call(prop: AggregateMethods<T>): Promise<void> {
|
|
123
|
+
|
|
124
|
+
// console.log('HTTP Call', prop);
|
|
125
|
+
// }
|
|
126
|
+
// }
|
|
127
|
+
|
|
128
|
+
// class ConceptDirect<T extends A_Component[]> extends Channel<T> {
|
|
129
|
+
|
|
130
|
+
// // protected originalInstance: T;
|
|
131
|
+
|
|
132
|
+
// async call(prop: AggregateMethods<T>): Promise<void> {
|
|
133
|
+
// console.log('Direct Call', prop);
|
|
134
|
+
// }
|
|
135
|
+
|
|
136
|
+
// }
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
// class ConceptEE extends Channel<any> {
|
|
141
|
+
|
|
142
|
+
// private emitter: EventEmitter = new EventEmitter();
|
|
143
|
+
|
|
144
|
+
// constructor() {
|
|
145
|
+
// super();
|
|
146
|
+
// }
|
|
147
|
+
|
|
148
|
+
// async call(prop: string): Promise<void> {
|
|
149
|
+
// console.log('EE Call', prop);
|
|
150
|
+
// }
|
|
151
|
+
|
|
152
|
+
// on = this.emitter.on.bind(this.emitter);
|
|
153
|
+
|
|
154
|
+
// emit = this.emitter.emit.bind(this.emitter);
|
|
155
|
+
|
|
156
|
+
// }
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
// class FooContainer extends A_Container<[
|
|
179
|
+
// 'doSomething',
|
|
180
|
+
// 'doAnotherThing'
|
|
181
|
+
// ]> {
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
// @A_Feature.Define({
|
|
185
|
+
// name: 'doSomething',
|
|
186
|
+
// channels: [ConceptDirect, HTTP]
|
|
187
|
+
// } as any)
|
|
188
|
+
// async doSomething(
|
|
189
|
+
// @A_Inject(HTTP) http: HTTP<[ComponentA, ComponentB]>,
|
|
190
|
+
// ) {
|
|
191
|
+
|
|
192
|
+
// // @A_Connect(http, 'ComponentB_method3')
|
|
193
|
+
|
|
194
|
+
// const foo = await http.channel.ComponentB_method3({
|
|
195
|
+
// key: 'value'
|
|
196
|
+
// });
|
|
197
|
+
// }
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
// @A_Feature.Define({
|
|
203
|
+
// name: 'doAnotherThing',
|
|
204
|
+
// channels: [HTTP]
|
|
205
|
+
// } as any)
|
|
206
|
+
// async onRequest() {
|
|
207
|
+
// await this.call('doSomething');
|
|
208
|
+
// }
|
|
209
|
+
// }
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
package/tests/log.ts
CHANGED
|
@@ -1,54 +1,102 @@
|
|
|
1
|
-
// import {
|
|
2
|
-
// import {
|
|
3
|
-
// import
|
|
4
|
-
// import rl from 'readline';
|
|
1
|
+
// import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
2
|
+
// import { A_Feature } from "@adaas/a-concept/global/A-Feature/A-Feature.class";
|
|
3
|
+
// import EventEmitter from "events";
|
|
5
4
|
|
|
5
|
+
// type MethodsOfComponent<T> = T extends typeof BaseComponent<infer M extends Array<string>> ? M : never;
|
|
6
6
|
|
|
7
|
-
// (async () => {
|
|
8
7
|
|
|
9
|
-
// await A_Context.ready;
|
|
10
8
|
|
|
11
|
-
//
|
|
12
|
-
// verbose: true
|
|
13
|
-
// })
|
|
9
|
+
// class BaseComponent<_Methods extends string[] = []> {
|
|
14
10
|
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
//
|
|
21
|
-
//
|
|
11
|
+
// constructor(
|
|
12
|
+
// private params?: Partial<{
|
|
13
|
+
// exports: _Methods
|
|
14
|
+
// }>) {
|
|
15
|
+
|
|
16
|
+
// }
|
|
17
|
+
// }
|
|
18
|
+
|
|
19
|
+
// class BaseContainer<_AllComponents extends typeof BaseComponent<string[]>[]> {
|
|
20
|
+
|
|
21
|
+
// constructor(public components: _AllComponents) {
|
|
22
|
+
// // this.allMethods = components
|
|
23
|
+
// // .map((component) => component.methods)
|
|
24
|
+
// // .flat(); // Extract methods at runtime
|
|
25
|
+
// }
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
// callMethod(method: MethodsOfComponent<_AllComponents[number]>[number]) {
|
|
29
|
+
// // if (!this.allMethods.includes(method)) {
|
|
30
|
+
// // throw new Error(`Method ${method} is not available.`);
|
|
31
|
+
// // }
|
|
32
|
+
// console.log(`Calling method: ${method}`);
|
|
33
|
+
// }
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
// // Define your components
|
|
39
|
+
// class ComponentA extends BaseComponent<['doSomething']> {
|
|
40
|
+
// // constructor() {
|
|
41
|
+
// // super(['doSomething']);
|
|
42
|
+
// // }
|
|
43
|
+
// }
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
// type ProxyTypeWithMethods<T> = T extends BaseContainer<infer M extends typeof BaseComponent<string[]>[]> ? MethodsOfComponent<M[number]> : never;
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
// class channel<T extends BaseContainer<typeof BaseComponent<string[]>[]>> {
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// getProvider()
|
|
53
|
+
// : {
|
|
54
|
+
// [K in ProxyTypeWithMethods<T>[number]]: () => void
|
|
55
|
+
// } {
|
|
56
|
+
// return new Proxy({} as any, {
|
|
57
|
+
// get(target, prop, receiver) {
|
|
58
|
+
// return target[prop];
|
|
22
59
|
// }
|
|
23
|
-
// }
|
|
24
|
-
// }
|
|
60
|
+
// });
|
|
61
|
+
// }
|
|
62
|
+
// }
|
|
63
|
+
|
|
64
|
+
// class ComponentB extends BaseComponent<['doAnotherThing']> {
|
|
65
|
+
// // constructor() {
|
|
66
|
+
// // super(['doAnotherThing']);
|
|
67
|
+
// // }
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
// method3() {
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
// }
|
|
75
|
+
// }
|
|
76
|
+
|
|
77
|
+
// // Instantiate the container
|
|
78
|
+
// const container = new BaseContainer([
|
|
79
|
+
// ComponentA,
|
|
80
|
+
// ComponentB
|
|
81
|
+
// ]);
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
// // Correct usage
|
|
88
|
+
// container.callMethod('doSomething'); // Calling method: doSomething
|
|
89
|
+
// container.callMethod('doAnotherThing'); // Calling method: doAnotherThing
|
|
25
90
|
|
|
26
|
-
// A_Context.Logger.error(new Error('Test Error'), new A_Error(A_CONSTANTS__DEFAULT_ERRORS.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ));
|
|
27
|
-
// A_Context.Logger.error(new A_Error(A_CONSTANTS__DEFAULT_ERRORS.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ));
|
|
28
|
-
// A_Context.Logger.log(new A_Error(A_CONSTANTS__DEFAULT_ERRORS.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ));
|
|
29
91
|
|
|
30
|
-
// const rlInterface = rl.createInterface({
|
|
31
|
-
// input: process.stdin,
|
|
32
|
-
// output: process.stdout
|
|
33
|
-
// });
|
|
34
92
|
|
|
35
|
-
//
|
|
36
|
-
// .question(
|
|
37
|
-
// A_Context.Logger.compile('pink', 'What is your name?', '(1,2,3,4)').join(' ') + '\n' +
|
|
38
|
-
// A_Context.Logger.compile('pink', 'Answer (1,2,3,4)').join(' '),
|
|
39
|
-
// resolve));
|
|
93
|
+
// const channelInstance = new channel<typeof container>();
|
|
40
94
|
|
|
41
|
-
//
|
|
42
|
-
// rl.clearLine(process.stdout, 0); // Clear the current line
|
|
95
|
+
// const provider = channelInstance.getProvider();
|
|
43
96
|
|
|
44
|
-
//
|
|
45
|
-
// .question(
|
|
46
|
-
// A_Context.Logger.compile('pink', 'Answer (1,2,3,4)').join(' '),
|
|
47
|
-
// resolve));
|
|
97
|
+
// provider.doAnotherThing();
|
|
48
98
|
|
|
49
|
-
// rl.moveCursor(process.stdout, 0, -1); // Move cursor to the beginning of the previous line
|
|
50
|
-
// rl.clearLine(process.stdout, 0); // Clear the current line
|
|
51
|
-
// // console.log('Asnwer: ', answer);
|
|
52
99
|
|
|
100
|
+
// // Incorrect usage
|
|
101
|
+
// // container.callMethod('nonExistentMethod'); // Throws error: Method nonExistentMethod is not available
|
|
53
102
|
|
|
54
|
-
// })()
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
2
|
-
import {
|
|
3
|
-
A_TYPES__A_StageDecoratorConfig,
|
|
4
|
-
A_TYPES__A_StageDecoratorDescriptor,
|
|
5
|
-
} from "./A-Stage.decorator.types";
|
|
6
|
-
import { A_TYPES__ComponentMetaKey } from "@adaas/a-concept/global/A-Component/A-Component.types";
|
|
7
|
-
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
8
|
-
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
9
|
-
import { A_TYPES__ContainerMetaKey } from "@adaas/a-concept/global/A-Container/A-Container.types";
|
|
10
|
-
import { A_TYPES__ConceptStage } from "@adaas/a-concept/global/A-Concept/A_Concept.types";
|
|
11
|
-
import { A_ContainerMeta } from "@adaas/a-concept/global/A-Container/A-Container.meta";
|
|
12
|
-
import { A_ComponentMeta } from "@adaas/a-concept/global/A-Component/A-Component.meta";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* A_Stage Decorator uses to extend basic A-Concept Stage methods inside Containers.
|
|
19
|
-
*
|
|
20
|
-
* Using this decorator you can define extend a logic and sequence of the Container Stage methods execution.
|
|
21
|
-
*
|
|
22
|
-
* @param params
|
|
23
|
-
* @returns
|
|
24
|
-
*/
|
|
25
|
-
export function A_Stage(
|
|
26
|
-
method: A_TYPES__ConceptStage
|
|
27
|
-
) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return function A_Stage(
|
|
31
|
-
config: Partial<A_TYPES__A_StageDecoratorConfig> = {}
|
|
32
|
-
) {
|
|
33
|
-
return function (
|
|
34
|
-
target: A_Container<any> | A_Component,
|
|
35
|
-
propertyKey: string,
|
|
36
|
-
descriptor: A_TYPES__A_StageDecoratorDescriptor
|
|
37
|
-
) {
|
|
38
|
-
|
|
39
|
-
const meta: A_ContainerMeta | A_ComponentMeta = A_Context.meta(target as any);
|
|
40
|
-
|
|
41
|
-
let metaKey;
|
|
42
|
-
|
|
43
|
-
const StageKey = `CONCEPT_STAGE::${method}`
|
|
44
|
-
|
|
45
|
-
switch (true) {
|
|
46
|
-
case target instanceof A_Container:
|
|
47
|
-
metaKey = A_TYPES__ContainerMetaKey.STAGES
|
|
48
|
-
break;
|
|
49
|
-
case target instanceof A_Component:
|
|
50
|
-
metaKey = A_TYPES__ComponentMetaKey.STAGES
|
|
51
|
-
break;
|
|
52
|
-
default:
|
|
53
|
-
throw new Error(`A-Feature cannot be defined on the ${target} level`);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// Get the existed metadata or create a new one
|
|
57
|
-
const existedMeta = meta.get(metaKey)
|
|
58
|
-
|| new Map();
|
|
59
|
-
|
|
60
|
-
// Set the metadata of the method to define a custom Stage with name
|
|
61
|
-
|
|
62
|
-
const existedMetaValue = existedMeta.get(StageKey) || [];
|
|
63
|
-
|
|
64
|
-
// Add the new method to the metadata
|
|
65
|
-
existedMetaValue.push({
|
|
66
|
-
name: StageKey,
|
|
67
|
-
handler: propertyKey,
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
// Set the metadata of the method to define a custom Feature with name
|
|
71
|
-
existedMeta.set(StageKey, existedMetaValue);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// Update the metadata of the container with the new Stage definition
|
|
75
|
-
A_Context
|
|
76
|
-
.meta(target as any)
|
|
77
|
-
.set(
|
|
78
|
-
metaKey,
|
|
79
|
-
existedMeta
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
}
|