@adaas/a-concept 0.0.11 → 0.0.12
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/src/global/A-Container/A-Container.class.d.ts +25 -0
- package/dist/src/global/A-Container/A-Container.class.js +9 -0
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -1
- package/dist/src/global/A-Context/A-Context.class.d.ts +11 -0
- package/dist/src/global/A-Context/A-Context.class.js +38 -0
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -1
- package/package.json +1 -1
- package/src/global/A-Container/A-Container.class.ts +48 -0
- package/src/global/A-Context/A-Context.class.ts +75 -2
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { A_TYPES__ContainerCallParams, A_TYPES__ContainerConstructor } from "./A-Container.types";
|
|
2
2
|
import { A_TYPES__Required } from "@adaas/a-utils";
|
|
3
3
|
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
4
|
+
import { A_TYPES__FeatureConstructor } from "../A-Feature/A-Feature.types";
|
|
4
5
|
/**
|
|
5
6
|
* This class should combine Components to achieve the goal withing Concept
|
|
6
7
|
*
|
|
@@ -58,6 +59,30 @@ export declare class A_Container<_FeatureNames extends Array<string>> {
|
|
|
58
59
|
* Parameters to provide additional data to the feature
|
|
59
60
|
*/
|
|
60
61
|
params: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>): Promise<any>;
|
|
62
|
+
/**
|
|
63
|
+
* This method allows to get a feature Definition for the future reuse with custom Feature classes
|
|
64
|
+
*
|
|
65
|
+
* @param feature
|
|
66
|
+
*/
|
|
67
|
+
feature(
|
|
68
|
+
/**
|
|
69
|
+
* A-Feature method name to be called
|
|
70
|
+
*/
|
|
71
|
+
feature: _FeatureNames[number]): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>;
|
|
72
|
+
feature(
|
|
73
|
+
/**
|
|
74
|
+
* A-Feature name to be called
|
|
75
|
+
*/
|
|
76
|
+
params: A_TYPES__Required<Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>, ['name']>): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>;
|
|
77
|
+
feature(
|
|
78
|
+
/**
|
|
79
|
+
* A-Feature method name to be called
|
|
80
|
+
*/
|
|
81
|
+
feature: _FeatureNames[number],
|
|
82
|
+
/**
|
|
83
|
+
* Parameters to provide additional data to the feature
|
|
84
|
+
*/
|
|
85
|
+
params: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>;
|
|
61
86
|
/**
|
|
62
87
|
* Before init hook to be used in inherited classes
|
|
63
88
|
*
|
|
@@ -84,6 +84,15 @@ class A_Container {
|
|
|
84
84
|
return yield newFeature.process();
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
+
feature(param1, param2) {
|
|
88
|
+
const feature = typeof param1 === 'string'
|
|
89
|
+
? param1
|
|
90
|
+
: param1.name;
|
|
91
|
+
const params = typeof param1 === 'string'
|
|
92
|
+
? param2 || {}
|
|
93
|
+
: param1;
|
|
94
|
+
return A_Context_class_1.A_Context.featureDefinition(this, feature, params);
|
|
95
|
+
}
|
|
87
96
|
// ==============================================================
|
|
88
97
|
// ======================= HOOKS ================================
|
|
89
98
|
// ==============================================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Container.class.js","sourceRoot":"","sources":["../../../../src/global/A-Container/A-Container.class.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,kEAAyD;
|
|
1
|
+
{"version":3,"file":"A-Container.class.js","sourceRoot":"","sources":["../../../../src/global/A-Container/A-Container.class.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,kEAAyD;AAMzD;;;;;;;;;;GAUG;AACH,MAAa,WAAW;IAYpB,IAAI,OAAO;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO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qE;;YAGrE,MAAM,OAAO,GAAW,OAAO,MAAM,KAAK,QAAQ;gBAC9C,CAAC,CAAC,MAAM;gBACR,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;YAClB,MAAM,MAAM,GAAiE,OAAO,MAAM,KAAK,QAAQ;gBACnG,CAAC,CAAC,MAAM,IAAI,EAAE;gBACd,CAAC,CAAC,MAAM,CAAC;YAEb,MAAM,UAAU,GAAG,2BAAS,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;YAE5D,OAAO,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;QACtC,CAAC;KAAA;IAkCD,OAAO,CACH,MAAyH,EACzH,MAAqE;QAGrE,MAAM,OAAO,GAAW,OAAO,MAAM,KAAK,QAAQ;YAC9C,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;QAClB,MAAM,MAAM,GAAiE,OAAO,MAAM,KAAK,QAAQ;YACnG,CAAC,CAAC,MAAM,IAAI,EAAE;YACd,CAAC,CAAC,MAAM,CAAC;QAEb,OAAO,2BAAS,CAAC,iBAAiB,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IAC9D,CAAC;IAID,iEAAiE;IACjE,iEAAiE;IACjE,iEAAiE;IAEjE;;;;OAIG;IACa,YAAY;;YACxB,OAAO;QACX,CAAC;KAAA;IAED;;OAEG;IACa,MAAM;;YAClB,OAAO;QACX,CAAC;KAAA;IAED;;;;OAIG;IACa,WAAW;;YACvB,OAAO;QACX,CAAC;KAAA;CAEJ;AA5MD,kCA4MC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { A_TYPES__Required } from "@adaas/a-utils";
|
|
1
2
|
import { A_Component } from "../A-Component/A-Component.class";
|
|
2
3
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
3
4
|
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
@@ -11,6 +12,7 @@ import { A_Concept } from "../A-Concept/A_Concept.class";
|
|
|
11
12
|
import { A_TYPES__EntityBaseMethod } from "../A-Entity/A-Entity.types";
|
|
12
13
|
import { A_Entity } from "../A-Entity/A-Entity.class";
|
|
13
14
|
import { A_EntityMeta } from "../A-Entity/A-Entity.meta";
|
|
15
|
+
import { A_TYPES__FeatureConstructor } from "../A-Feature/A-Feature.types";
|
|
14
16
|
/**
|
|
15
17
|
* Namespace Provider is responsible for providing the Namespace to the Containers and other Namespaces.
|
|
16
18
|
* This class stores all Namespaces across the Program.
|
|
@@ -82,6 +84,15 @@ export declare class A_Context {
|
|
|
82
84
|
* @returns
|
|
83
85
|
*/
|
|
84
86
|
static component(meta: A_ComponentMeta): typeof A_Component;
|
|
87
|
+
/**
|
|
88
|
+
* This method returns a constructor params to create a new feature
|
|
89
|
+
*
|
|
90
|
+
* @param scope
|
|
91
|
+
* @returns
|
|
92
|
+
*/
|
|
93
|
+
static featureDefinition<T extends Array<string>>(entity: A_Entity<any, any, T>, feature: A_TYPES__EntityBaseMethod | string | T[number] | RegExp, params?: Partial<A_TYPES__ScopeConstructor>): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>;
|
|
94
|
+
static featureDefinition<T extends Array<string>>(container: A_Container<T>, feature: T[number], params?: Partial<A_TYPES__ScopeConstructor>): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>;
|
|
95
|
+
static featureDefinition(component: A_Component, feature: string, params?: Partial<A_TYPES__ScopeConstructor>): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>;
|
|
85
96
|
/**
|
|
86
97
|
* This method returns a step-by-step instructions of feature implementation depending on the feature name and the class.
|
|
87
98
|
*
|
|
@@ -180,6 +180,44 @@ class A_Context {
|
|
|
180
180
|
}
|
|
181
181
|
return component;
|
|
182
182
|
}
|
|
183
|
+
static featureDefinition(param1, param2, param3) {
|
|
184
|
+
const instance = this.getInstance();
|
|
185
|
+
const component = param1;
|
|
186
|
+
const feature = `${component.constructor.name}.${param2}`;
|
|
187
|
+
const config = param3 || {};
|
|
188
|
+
// TODO: have no idea why it's not working because of that "any"
|
|
189
|
+
const scope = this.scope(component);
|
|
190
|
+
const steps = [];
|
|
191
|
+
// Now we need to resolve the method from all registered components
|
|
192
|
+
// We need to get all components that has extensions for the feature in component
|
|
193
|
+
instance.componentsMeta
|
|
194
|
+
.forEach((meta, constructor) => {
|
|
195
|
+
try {
|
|
196
|
+
// Just try to make sure that component not only Indexed but also presented in scope
|
|
197
|
+
scope.resolve(constructor);
|
|
198
|
+
// Get all extensions for the feature
|
|
199
|
+
meta
|
|
200
|
+
.extensions(feature)
|
|
201
|
+
.forEach(({ handler, args }) => {
|
|
202
|
+
steps.push({
|
|
203
|
+
component: constructor,
|
|
204
|
+
handler,
|
|
205
|
+
args
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
catch (error) {
|
|
210
|
+
// do nothing
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
return {
|
|
214
|
+
name: `${component.constructor.name}.${feature}`,
|
|
215
|
+
fragments: config.fragments || [],
|
|
216
|
+
components: config.components || [],
|
|
217
|
+
steps,
|
|
218
|
+
parent: component instanceof A_Container_class_1.A_Container ? this.scope(component) : undefined
|
|
219
|
+
};
|
|
220
|
+
}
|
|
183
221
|
static feature(param1, param2, param3) {
|
|
184
222
|
const instance = this.getInstance();
|
|
185
223
|
const component = param1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"A-Context.class.js","sourceRoot":"","sources":["../../../../src/global/A-Context/A-Context.class.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"A-Context.class.js","sourceRoot":"","sources":["../../../../src/global/A-Context/A-Context.class.ts"],"names":[],"mappings":";;;AAAA,4CAAgF;AAChF,wEAA+D;AAC/D,qEAA4D;AAC5D,kEAAyD;AACzD,wEAA+D;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gFAAgF;QAChF,UAAU;QACV,iBAAiB;QACjB,2BAA2B;QAC3B,6CAA6C;QAC7C,yCAAyC;QACzC,iDAAiD;QACjD,6BAA6B;QAG7B,sBAAsB;QACtB,iCAAiC;QAEjC,4DAA4D;QAE5D,mBAAmB;IAEvB,CAAC;CACJ;AAviBD,8BAuiBC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adaas/a-concept",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
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",
|
|
@@ -3,6 +3,7 @@ import { A_TYPES__Required } from "@adaas/a-utils";
|
|
|
3
3
|
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
4
4
|
import { A_Context } from "../A-Context/A-Context.class";
|
|
5
5
|
import { A_Scope } from "../A-Scope/A-Scope.class";
|
|
6
|
+
import { A_TYPES__FeatureConstructor } from "../A-Feature/A-Feature.types";
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
@@ -145,6 +146,53 @@ export class A_Container<
|
|
|
145
146
|
|
|
146
147
|
|
|
147
148
|
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* This method allows to get a feature Definition for the future reuse with custom Feature classes
|
|
152
|
+
*
|
|
153
|
+
* @param feature
|
|
154
|
+
*/
|
|
155
|
+
feature(
|
|
156
|
+
/**
|
|
157
|
+
* A-Feature method name to be called
|
|
158
|
+
*/
|
|
159
|
+
feature: _FeatureNames[number],
|
|
160
|
+
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
161
|
+
feature(
|
|
162
|
+
/**
|
|
163
|
+
* A-Feature name to be called
|
|
164
|
+
*/
|
|
165
|
+
params: A_TYPES__Required<Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>, ['name']>,
|
|
166
|
+
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
167
|
+
|
|
168
|
+
feature(
|
|
169
|
+
/**
|
|
170
|
+
* A-Feature method name to be called
|
|
171
|
+
*/
|
|
172
|
+
feature: _FeatureNames[number],
|
|
173
|
+
/**
|
|
174
|
+
* Parameters to provide additional data to the feature
|
|
175
|
+
*/
|
|
176
|
+
params: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>,
|
|
177
|
+
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
178
|
+
|
|
179
|
+
feature(
|
|
180
|
+
param1: _FeatureNames[number] | A_TYPES__Required<Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>, ['name']>,
|
|
181
|
+
param2?: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>>
|
|
182
|
+
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']> {
|
|
183
|
+
|
|
184
|
+
const feature: string = typeof param1 === 'string'
|
|
185
|
+
? param1
|
|
186
|
+
: param1.name;
|
|
187
|
+
const params: Partial<A_TYPES__ContainerCallParams<_FeatureNames[number]>> = typeof param1 === 'string'
|
|
188
|
+
? param2 || {}
|
|
189
|
+
: param1;
|
|
190
|
+
|
|
191
|
+
return A_Context.featureDefinition(this, feature, params);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
148
196
|
// ==============================================================
|
|
149
197
|
// ======================= HOOKS ================================
|
|
150
198
|
// ==============================================================
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A_CommonHelper, A_Polyfills } from "@adaas/a-utils";
|
|
1
|
+
import { A_CommonHelper, A_Polyfills, A_TYPES__Required } from "@adaas/a-utils";
|
|
2
2
|
import { A_Component } from "../A-Component/A-Component.class";
|
|
3
3
|
import { A_Fragment } from "../A-Fragment/A-Fragment.class";
|
|
4
4
|
import { A_Feature } from "../A-Feature/A-Feature.class";
|
|
@@ -12,7 +12,7 @@ import { A_Concept } from "../A-Concept/A_Concept.class";
|
|
|
12
12
|
import { A_TYPES__EntityBaseMethod } from "../A-Entity/A-Entity.types";
|
|
13
13
|
import { A_Entity } from "../A-Entity/A-Entity.class";
|
|
14
14
|
import { A_EntityMeta } from "../A-Entity/A-Entity.meta";
|
|
15
|
-
import { A_TYPES__FeatureStep } from "../A-Feature/A-Feature.types";
|
|
15
|
+
import { A_TYPES__FeatureConstructor, A_TYPES__FeatureStep } from "../A-Feature/A-Feature.types";
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
/**
|
|
@@ -339,6 +339,79 @@ export class A_Context {
|
|
|
339
339
|
}
|
|
340
340
|
|
|
341
341
|
|
|
342
|
+
/**
|
|
343
|
+
* This method returns a constructor params to create a new feature
|
|
344
|
+
*
|
|
345
|
+
* @param scope
|
|
346
|
+
* @returns
|
|
347
|
+
*/
|
|
348
|
+
static featureDefinition<T extends Array<string>>(
|
|
349
|
+
entity: A_Entity<any, any, T>,
|
|
350
|
+
feature: A_TYPES__EntityBaseMethod | string | T[number] | RegExp,
|
|
351
|
+
params?: Partial<A_TYPES__ScopeConstructor>
|
|
352
|
+
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
353
|
+
static featureDefinition<T extends Array<string>>(
|
|
354
|
+
container: A_Container<T>,
|
|
355
|
+
feature: T[number],
|
|
356
|
+
params?: Partial<A_TYPES__ScopeConstructor>
|
|
357
|
+
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
358
|
+
static featureDefinition(
|
|
359
|
+
component: A_Component,
|
|
360
|
+
feature: string,
|
|
361
|
+
params?: Partial<A_TYPES__ScopeConstructor>
|
|
362
|
+
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']>
|
|
363
|
+
static featureDefinition<T extends Array<string>>(
|
|
364
|
+
param1: A_Component<T> | A_Container<T> | A_Entity<any, any, T>,
|
|
365
|
+
param2: string | T[number],
|
|
366
|
+
param3?: Partial<A_TYPES__ScopeConstructor>
|
|
367
|
+
): A_TYPES__Required<Partial<A_TYPES__FeatureConstructor>, ['steps', 'fragments', 'name', 'components']> {
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
const instance = this.getInstance();
|
|
371
|
+
|
|
372
|
+
const component = param1;
|
|
373
|
+
const feature: string = `${component.constructor.name}.${param2}`;
|
|
374
|
+
const config = param3 || {};
|
|
375
|
+
// TODO: have no idea why it's not working because of that "any"
|
|
376
|
+
const scope = this.scope(component as any);
|
|
377
|
+
const steps: A_TYPES__FeatureStep[] = [];
|
|
378
|
+
|
|
379
|
+
// Now we need to resolve the method from all registered components
|
|
380
|
+
|
|
381
|
+
// We need to get all components that has extensions for the feature in component
|
|
382
|
+
instance.componentsMeta
|
|
383
|
+
.forEach((meta, constructor) => {
|
|
384
|
+
try {
|
|
385
|
+
// Just try to make sure that component not only Indexed but also presented in scope
|
|
386
|
+
scope.resolve(constructor);
|
|
387
|
+
|
|
388
|
+
// Get all extensions for the feature
|
|
389
|
+
meta
|
|
390
|
+
.extensions(feature)
|
|
391
|
+
.forEach(({ handler, args }) => {
|
|
392
|
+
steps.push({
|
|
393
|
+
component: constructor,
|
|
394
|
+
handler,
|
|
395
|
+
args
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
} catch (error) {
|
|
400
|
+
// do nothing
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
return {
|
|
406
|
+
name: `${component.constructor.name}.${feature}`,
|
|
407
|
+
fragments: config.fragments || [],
|
|
408
|
+
components: config.components || [],
|
|
409
|
+
steps,
|
|
410
|
+
parent: component instanceof A_Container ? this.scope(component) : undefined
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
|
|
342
415
|
|
|
343
416
|
/**
|
|
344
417
|
* This method returns a step-by-step instructions of feature implementation depending on the feature name and the class.
|