@adaas/a-frame 0.0.2
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/.nvmrc +1 -0
- package/LICENSE +13 -0
- package/README.md +2 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +145 -0
- package/dist/index.d.ts +145 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/index.ts +22 -0
- package/jest.config.ts +22 -0
- package/package.json +86 -0
- package/src/index.ts +24 -0
- package/src/lib/components/Builder.component.ts/Builder.component.ts +0 -0
- package/src/lib/components/Index.component.ts/Index.component.ts +79 -0
- package/src/lib/components/Index.component.ts/Index.constants.ts +0 -0
- package/src/lib/components/Index.component.ts/Index.error.ts +14 -0
- package/src/lib/components/Index.component.ts/Index.guard.ts +34 -0
- package/src/lib/components/Index.component.ts/Index.meta.ts +28 -0
- package/src/lib/components/Index.component.ts/Index.types.ts +132 -0
- package/src/lib/components/Index.component.ts/IndexConfigurations.meta.ts +78 -0
- package/src/lib/components/Index.component.ts/decorators/IndexComponent.decorator.ts +97 -0
- package/src/lib/components/Index.component.ts/decorators/IndexDescribe.decorator.ts +59 -0
- package/src/lib/components/Index.component.ts/decorators/IndexNamespace.decorator.ts +57 -0
- package/src/lib/containers/CLI.container.ts +27 -0
- package/src/lib/entities/Namespace/Namespace.entity.ts +8 -0
- package/tests/A-Frame.test.ts +91 -0
- package/tests/jest.setup.ts +30 -0
- package/tsconfig.json +60 -0
- package/tslint.json +98 -0
- package/tsup.config.ts +32 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// A-Frame CLI Exports
|
|
3
|
+
// ============================================================================
|
|
4
|
+
export { A_Frame_CLIContainer } from './lib/containers/CLI.container';
|
|
5
|
+
|
|
6
|
+
// ============================================================================
|
|
7
|
+
// A-Frame Index Exports
|
|
8
|
+
// ============================================================================
|
|
9
|
+
export { A_Frame_Index as A_Frame } from './lib/components/Index.component.ts/Index.component';
|
|
10
|
+
export { A_Frame_IndexMeta } from './lib/components/Index.component.ts/Index.meta';
|
|
11
|
+
export { A_Frame_IndexError } from './lib/components/Index.component.ts/Index.error';
|
|
12
|
+
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// A-Frame Types Exports
|
|
15
|
+
// ============================================================================
|
|
16
|
+
export type {
|
|
17
|
+
A_Frame_IndexOptions,
|
|
18
|
+
A_Frame_IndexDecoratorTarget,
|
|
19
|
+
A_Frame_IndexDecoratorMeta,
|
|
20
|
+
A_Frame_IndexNamespaceDecoratorTarget
|
|
21
|
+
} from './lib/components/Index.component.ts/Index.types';
|
|
22
|
+
|
|
23
|
+
// Export the enum as both type and value
|
|
24
|
+
export { A_Frame_IndexTargetType } from './lib/components/Index.component.ts/Index.types';
|
|
File without changes
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { A_Component, A_Meta } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame_IndexOptions, A_Frame_IndexTargetType } from "./Index.types";
|
|
3
|
+
import { A_Frame_IndexDecorator } from "./decorators/IndexComponent.decorator";
|
|
4
|
+
import { A_Frame_IndexNamespaceDecorator } from "./decorators/IndexNamespace.decorator";
|
|
5
|
+
import { A_Frame_IndexDescribeDecorator } from "./decorators/IndexDescribe.decorator";
|
|
6
|
+
import { A_Frame_IndexMeta } from "./Index.meta";
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@A_Meta.Define(A_Frame_IndexMeta)
|
|
11
|
+
export class A_Frame_Index extends A_Component {
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Allows to mark namespace and add it to index structure,
|
|
16
|
+
*/
|
|
17
|
+
static Namespace(name: string): ClassDecorator & MethodDecorator {
|
|
18
|
+
return A_Frame_IndexNamespaceDecorator(name) as ClassDecorator & MethodDecorator;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Allows to add description to a class and add it to index structure
|
|
23
|
+
*/
|
|
24
|
+
static Describe(description: string): ClassDecorator & MethodDecorator {
|
|
25
|
+
return A_Frame_IndexDescribeDecorator(description) as ClassDecorator & MethodDecorator;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Allows to mark component and add it to index structure,
|
|
32
|
+
*/
|
|
33
|
+
static Component(): ClassDecorator
|
|
34
|
+
static Component(options: Partial<A_Frame_IndexOptions>): ClassDecorator
|
|
35
|
+
static Component(options: Partial<A_Frame_IndexOptions> = {}): ClassDecorator {
|
|
36
|
+
return A_Frame_IndexDecorator(A_Frame_IndexTargetType.COMPONENT, options) as ClassDecorator;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Allows to mark container and add it to index structure,
|
|
41
|
+
*/
|
|
42
|
+
static Container(): ClassDecorator
|
|
43
|
+
static Container(options: Partial<A_Frame_IndexOptions>): ClassDecorator
|
|
44
|
+
static Container(options: Partial<A_Frame_IndexOptions> = {}): ClassDecorator {
|
|
45
|
+
return A_Frame_IndexDecorator(A_Frame_IndexTargetType.CONTAINER, options) as ClassDecorator;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Allows to mark entity and add it to index structure,
|
|
50
|
+
* so it can be reused in other components or structures
|
|
51
|
+
*/
|
|
52
|
+
static Entity(): ClassDecorator
|
|
53
|
+
static Entity(options: Partial<A_Frame_IndexOptions>): ClassDecorator
|
|
54
|
+
static Entity(options: Partial<A_Frame_IndexOptions> = {}): ClassDecorator {
|
|
55
|
+
return A_Frame_IndexDecorator(A_Frame_IndexTargetType.ENTITY, options) as ClassDecorator;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Allows to mark fragment and add it to index structure,
|
|
61
|
+
* so it can be reused in other components or structures
|
|
62
|
+
*/
|
|
63
|
+
static Fragment(): ClassDecorator
|
|
64
|
+
static Fragment(options: Partial<A_Frame_IndexOptions>): ClassDecorator
|
|
65
|
+
static Fragment(options: Partial<A_Frame_IndexOptions> = {}): ClassDecorator {
|
|
66
|
+
return A_Frame_IndexDecorator(A_Frame_IndexTargetType.FRAGMENT, options) as ClassDecorator;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Allows to define a reusable AI method from components,
|
|
71
|
+
* that can be reused in other components. to build new Features
|
|
72
|
+
*/
|
|
73
|
+
static Method(): MethodDecorator
|
|
74
|
+
static Method(options: Partial<A_Frame_IndexOptions>): MethodDecorator
|
|
75
|
+
static Method(options: Partial<A_Frame_IndexOptions> = {}): MethodDecorator {
|
|
76
|
+
return A_Frame_IndexDecorator(A_Frame_IndexTargetType.METHOD, options) as MethodDecorator;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { A_Error } from "@adaas/a-concept";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class A_Frame_IndexError extends A_Error {
|
|
5
|
+
|
|
6
|
+
static readonly InvalidTarget = 'A-Frame Index Invalid Target Error';
|
|
7
|
+
|
|
8
|
+
static readonly InvalidConfiguration = 'A-Frame Index Invalid Configuration Error';
|
|
9
|
+
|
|
10
|
+
static readonly IndexDefinitionError = 'A-Frame Index Definition Error';
|
|
11
|
+
static readonly IndexMetadataError = 'A-Frame Index Metadata Error';
|
|
12
|
+
static readonly IndexRegistryError = 'A-Frame Index Registry Error';
|
|
13
|
+
static readonly IndexComponentNotFoundError = 'A-Frame Index Component Not Found Error';
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { A_CommonHelper, A_TypeGuards } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame_IndexDecoratorTarget, A_Frame_IndexMetaTarget } from "./Index.types";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class A_Frame_IndexTypeGuard {
|
|
7
|
+
/**
|
|
8
|
+
* Determines if the target is an allowed type for indexing
|
|
9
|
+
*
|
|
10
|
+
* @param target
|
|
11
|
+
* @returns
|
|
12
|
+
*/
|
|
13
|
+
static isAllowedTarget(target: any): target is A_Frame_IndexDecoratorTarget {
|
|
14
|
+
return A_TypeGuards.isEntityConstructor(target)
|
|
15
|
+
|| A_TypeGuards.isComponentConstructor(target)
|
|
16
|
+
|| A_TypeGuards.isContainerConstructor(target)
|
|
17
|
+
|| A_TypeGuards.isFragmentConstructor(target)
|
|
18
|
+
|| A_TypeGuards.isComponentInstance(target)
|
|
19
|
+
|| A_TypeGuards.isContainerInstance(target)
|
|
20
|
+
|| A_TypeGuards.isEntityInstance(target)
|
|
21
|
+
|| A_TypeGuards.isFragmentInstance(target);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
static getTargetName(target: A_Frame_IndexDecoratorTarget): string {
|
|
27
|
+
return A_CommonHelper.getComponentName(target);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
static getTargetConstructor(target: A_Frame_IndexDecoratorTarget): A_Frame_IndexMetaTarget {
|
|
32
|
+
return typeof target === 'function' ? target : target.constructor as A_Frame_IndexMetaTarget;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { A_ComponentMeta, A_Context, A_Meta } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame_IndexDecoratorMeta, A_Frame_IndexTargetType, A_Frame_IndexMetaTarget } from "./Index.types";
|
|
3
|
+
import { A_Frame_Index } from "./Index.component";
|
|
4
|
+
import { A_Frame_IndexConfigurationsMeta } from "./IndexConfigurations.meta";
|
|
5
|
+
|
|
6
|
+
export class A_Frame_IndexMeta extends A_ComponentMeta {
|
|
7
|
+
|
|
8
|
+
getMetaFor(target: A_Frame_IndexMetaTarget): A_Frame_IndexConfigurationsMeta {
|
|
9
|
+
|
|
10
|
+
const targetSpace = this.get('A_FRAME_INDEX_CONFIGURATIONS_META' as any) || new Map<A_Frame_IndexMetaTarget, A_Frame_IndexConfigurationsMeta>();
|
|
11
|
+
|
|
12
|
+
if (!targetSpace.has(target)) {
|
|
13
|
+
targetSpace.set(target, new A_Frame_IndexConfigurationsMeta());
|
|
14
|
+
this.set('A_FRAME_INDEX_CONFIGURATIONS_META' as any, targetSpace);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return targetSpace.get(target)!;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
seMetaFor(target: A_Frame_IndexMetaTarget, meta: A_Frame_IndexConfigurationsMeta): void {
|
|
22
|
+
const targetSpace = this.get('A_FRAME_INDEX_CONFIGURATIONS_META' as any) || new Map<A_Frame_IndexMetaTarget, A_Frame_IndexConfigurationsMeta>();
|
|
23
|
+
|
|
24
|
+
targetSpace.set(target, meta);
|
|
25
|
+
|
|
26
|
+
this.set('A_FRAME_INDEX_CONFIGURATIONS_META' as any, targetSpace);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { A_Component, A_Container, A_Entity, A_Fragment, A_TYPES__Component_Constructor, A_TYPES__Container_Constructor, A_TYPES__Entity_Constructor, A_TYPES__Fragment_Constructor, A_TYPES__Required } from "@adaas/a-concept"
|
|
2
|
+
import { A_Namespace } from "src/lib/entities/Namespace/Namespace.entity"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export type A_Frame_IndexOptions = {
|
|
6
|
+
name?: string,
|
|
7
|
+
namespace?: string | A_Namespace
|
|
8
|
+
description?: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export type A_Frame_IndexMetaTarget = A_TYPES__Container_Constructor
|
|
14
|
+
| A_TYPES__Entity_Constructor
|
|
15
|
+
| A_TYPES__Component_Constructor
|
|
16
|
+
| A_TYPES__Fragment_Constructor
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
// ===========================================================================
|
|
20
|
+
// --------------------------- Decorator Types -------------------------------
|
|
21
|
+
// ===========================================================================
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
// -------------------- A-Frame Index Decorator Types-------------------------
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
/**
|
|
26
|
+
* Indicates a type of Feature Define decorator
|
|
27
|
+
*/
|
|
28
|
+
export type A_Frame_IndexDecoratorDescriptor =
|
|
29
|
+
TypedPropertyDescriptor<(...args: any[]) => any>
|
|
30
|
+
| TypedPropertyDescriptor<(...args: any[]) => any>
|
|
31
|
+
| TypedPropertyDescriptor<(...args: any[]) => Promise<any>>
|
|
32
|
+
| TypedPropertyDescriptor<(...args: any[]) => Promise<any>>
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Describes a target where Feature Define decorator can be applied
|
|
37
|
+
*
|
|
38
|
+
* [!] The feature can be defined on Container, Entity, Component or Command
|
|
39
|
+
*/
|
|
40
|
+
export type A_Frame_IndexDecoratorTarget = A_Frame_IndexMetaTarget
|
|
41
|
+
| A_Component
|
|
42
|
+
| A_Container
|
|
43
|
+
| A_Entity
|
|
44
|
+
| A_Fragment
|
|
45
|
+
/**
|
|
46
|
+
* Targets types that can be indexed
|
|
47
|
+
*/
|
|
48
|
+
export enum A_Frame_IndexTargetType {
|
|
49
|
+
COMPONENT = 'component',
|
|
50
|
+
ENTITY = 'entity',
|
|
51
|
+
CONTAINER = 'container',
|
|
52
|
+
FRAGMENT = 'fragment',
|
|
53
|
+
METHOD = 'method'
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A type of Meta information stored by Index decorator
|
|
58
|
+
* This information is used by A-Context to build a proper index structure
|
|
59
|
+
*/
|
|
60
|
+
export type A_Frame_IndexDecoratorMeta = {
|
|
61
|
+
/**
|
|
62
|
+
* Component name
|
|
63
|
+
*/
|
|
64
|
+
name: string,
|
|
65
|
+
/**
|
|
66
|
+
* Component description
|
|
67
|
+
*/
|
|
68
|
+
description?: string,
|
|
69
|
+
/**
|
|
70
|
+
* Type of the component
|
|
71
|
+
*/
|
|
72
|
+
type: A_Frame_IndexTargetType,
|
|
73
|
+
/**
|
|
74
|
+
* Namespace for the component
|
|
75
|
+
*/
|
|
76
|
+
namespace?: string | A_Namespace,
|
|
77
|
+
/**
|
|
78
|
+
* Constructor reference
|
|
79
|
+
*/
|
|
80
|
+
constructor: A_Frame_IndexDecoratorTarget
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// -------------------- A-Frame Index Decorator Types-------------------------
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
/**
|
|
88
|
+
* Indicates a type of Feature Define decorator
|
|
89
|
+
*/
|
|
90
|
+
export type A_Frame_IndexNamespaceDecoratorDescriptor =
|
|
91
|
+
TypedPropertyDescriptor<(...args: any[]) => any>
|
|
92
|
+
| TypedPropertyDescriptor<(...args: any[]) => any>
|
|
93
|
+
| TypedPropertyDescriptor<(...args: any[]) => Promise<any>>
|
|
94
|
+
| TypedPropertyDescriptor<(...args: any[]) => Promise<any>>
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Describes a target where Feature Define decorator can be applied
|
|
99
|
+
*
|
|
100
|
+
* [!] The feature can be defined on Container, Entity, Component or Command
|
|
101
|
+
*/
|
|
102
|
+
export type A_Frame_IndexNamespaceDecoratorTarget = A_Container
|
|
103
|
+
| A_Entity
|
|
104
|
+
| A_Component
|
|
105
|
+
| A_Fragment
|
|
106
|
+
| A_TYPES__Fragment_Constructor
|
|
107
|
+
| A_TYPES__Component_Constructor
|
|
108
|
+
| A_TYPES__Container_Constructor
|
|
109
|
+
| A_TYPES__Entity_Constructor
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
// ---------------------------------------------------------------------------
|
|
115
|
+
// ------------- A-Frame Index Configurations Meta Types----------------------
|
|
116
|
+
// ---------------------------------------------------------------------------
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
export type A_Frame_IndexConfigurationsMetaType = {
|
|
120
|
+
namespaces: string,
|
|
121
|
+
descriptions: string,
|
|
122
|
+
type: string,
|
|
123
|
+
name: string,
|
|
124
|
+
methods: Map<string, A_Frame_IndexConfigurationsMetaMethodMeta>
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
export type A_Frame_IndexConfigurationsMetaMethodMeta = {
|
|
129
|
+
name: string,
|
|
130
|
+
description?: string,
|
|
131
|
+
methodName: string
|
|
132
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { A_Meta } from "@adaas/a-concept";
|
|
2
|
+
import { A_Namespace } from "../../entities/Namespace/Namespace.entity";
|
|
3
|
+
import { A_Frame_IndexConfigurationsMetaMethodMeta, A_Frame_IndexConfigurationsMetaType } from "./Index.types";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export class A_Frame_IndexConfigurationsMeta extends A_Meta<Partial<A_Frame_IndexConfigurationsMetaType>> {
|
|
8
|
+
|
|
9
|
+
get name(): string | undefined {
|
|
10
|
+
return this.get('name');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
set name(value: string | undefined) {
|
|
14
|
+
if (value)
|
|
15
|
+
this.set('name', value);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
get type(): string | undefined {
|
|
20
|
+
return this.get('type');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
set type(value: string | undefined) {
|
|
24
|
+
if (value)
|
|
25
|
+
this.set('type', value);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
get namespace(): string | undefined {
|
|
30
|
+
return this.get('namespaces');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
set namespace(value: string | undefined | A_Namespace) {
|
|
34
|
+
if (value) {
|
|
35
|
+
const target = value instanceof A_Namespace ? value.aseid.toString() : value;
|
|
36
|
+
this.set('namespaces', target);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
get description(): string | undefined {
|
|
42
|
+
return this.get('descriptions');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
set description(value: string | undefined) {
|
|
46
|
+
if (value)
|
|
47
|
+
this.set('descriptions', value);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
get methods(): Map<string, A_Frame_IndexConfigurationsMetaMethodMeta> {
|
|
53
|
+
if (!this.get('methods')) {
|
|
54
|
+
this.set('methods', new Map());
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return this.get('methods')!;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
clear(): void {
|
|
62
|
+
this.set('name', undefined);
|
|
63
|
+
this.set('type', undefined);
|
|
64
|
+
this.set('namespaces', undefined);
|
|
65
|
+
this.set('descriptions', undefined);
|
|
66
|
+
this.set('methods', new Map());
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
addMethod(methodMeta: A_Frame_IndexConfigurationsMetaMethodMeta): void {
|
|
71
|
+
const methods = this.methods;
|
|
72
|
+
|
|
73
|
+
if (!methods.has(methodMeta.name)) {
|
|
74
|
+
methods.set(methodMeta.name, methodMeta);
|
|
75
|
+
this.set('methods', methods);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { A_CommonHelper, A_Context, A_Meta } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame_IndexError } from "../Index.error";
|
|
3
|
+
import { A_Frame_IndexDecoratorTarget, A_Frame_IndexOptions, A_Frame_IndexTargetType, A_Frame_IndexDecoratorDescriptor, A_Frame_IndexMetaTarget } from "../Index.types";
|
|
4
|
+
import { A_Frame_Index } from "../Index.component";
|
|
5
|
+
import { A_Frame_IndexMeta } from "../Index.meta";
|
|
6
|
+
import { A_Frame_IndexTypeGuard } from "../Index.guard";
|
|
7
|
+
|
|
8
|
+
export function A_Frame_IndexDecorator(
|
|
9
|
+
componentType: A_Frame_IndexTargetType,
|
|
10
|
+
config: Partial<A_Frame_IndexOptions> = {}
|
|
11
|
+
) {
|
|
12
|
+
return function (
|
|
13
|
+
target: A_Frame_IndexDecoratorTarget,
|
|
14
|
+
propertyKey?: string | symbol,
|
|
15
|
+
descriptor?: A_Frame_IndexDecoratorDescriptor
|
|
16
|
+
): any {
|
|
17
|
+
|
|
18
|
+
// Handle method decorator case
|
|
19
|
+
if (propertyKey && descriptor && componentType === A_Frame_IndexTargetType.METHOD) {
|
|
20
|
+
// For methods, target is the class prototype
|
|
21
|
+
const targetClass = target.constructor as A_Frame_IndexMetaTarget;
|
|
22
|
+
const methodName = String(propertyKey);
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const indexMeta: A_Frame_IndexMeta = A_Context.meta(A_Frame_Index) as any;
|
|
26
|
+
const targetMeta = indexMeta.getMetaFor(targetClass);
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
if (!!config.namespace && !!targetMeta.namespace && config.namespace !== targetMeta.namespace) {
|
|
30
|
+
throw new A_Frame_IndexError(
|
|
31
|
+
A_Frame_IndexError.InvalidConfiguration,
|
|
32
|
+
`Method namespace '${config.namespace}' does not match target class namespace '${targetMeta.namespace}'.`
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Store method information
|
|
37
|
+
const methodInfo = {
|
|
38
|
+
name: config.name || methodName,
|
|
39
|
+
description: config.description,
|
|
40
|
+
namespace: config.namespace || targetMeta.namespace,
|
|
41
|
+
methodName: methodName
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// Add to methods array
|
|
45
|
+
targetMeta.addMethod(methodInfo);
|
|
46
|
+
|
|
47
|
+
indexMeta.seMetaFor(targetClass, targetMeta);
|
|
48
|
+
|
|
49
|
+
return descriptor;
|
|
50
|
+
|
|
51
|
+
} catch (error) {
|
|
52
|
+
|
|
53
|
+
throw new A_Frame_IndexError(
|
|
54
|
+
A_Frame_IndexError.IndexDefinitionError,
|
|
55
|
+
`Unable to apply @A_Frame_Index.Method decorator on '${targetClass.name}.${methodName}': ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Handle class decorator case
|
|
62
|
+
if (!A_Frame_IndexTypeGuard.isAllowedTarget(target)) {
|
|
63
|
+
throw new A_Frame_IndexError(
|
|
64
|
+
A_Frame_IndexError.InvalidTarget,
|
|
65
|
+
`@A_Frame_Index.${componentType} decorator can only be applied to allowed targets.`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// for error messages
|
|
70
|
+
const componentName = A_CommonHelper.getComponentName(target);
|
|
71
|
+
|
|
72
|
+
try {
|
|
73
|
+
// Get the index meta for the global A_Frame_Index component
|
|
74
|
+
const indexMeta: A_Frame_IndexMeta = A_Context.meta(A_Frame_Index) as any;
|
|
75
|
+
|
|
76
|
+
const targetClass = A_Frame_IndexTypeGuard.getTargetConstructor(target);
|
|
77
|
+
|
|
78
|
+
// Check for pending namespace and description from other decorators
|
|
79
|
+
const targetMeta = indexMeta.getMetaFor(targetClass);
|
|
80
|
+
|
|
81
|
+
targetMeta.name = config.name || componentName;
|
|
82
|
+
targetMeta.description = config.description;
|
|
83
|
+
targetMeta.namespace = config.namespace;
|
|
84
|
+
targetMeta.type = componentType;
|
|
85
|
+
|
|
86
|
+
indexMeta.seMetaFor(targetClass, targetMeta);
|
|
87
|
+
|
|
88
|
+
return target;
|
|
89
|
+
|
|
90
|
+
} catch (error) {
|
|
91
|
+
throw new A_Frame_IndexError(
|
|
92
|
+
A_Frame_IndexError.IndexDefinitionError,
|
|
93
|
+
`Unable to apply @A_Frame_Index.${componentType} decorator on '${componentName}': ${error instanceof Error ? error.message : 'Unknown error'}`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { A_CommonHelper, A_Context } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame_IndexDecoratorDescriptor, A_Frame_IndexDecoratorTarget, A_Frame_IndexNamespaceDecoratorTarget } from "../Index.types";
|
|
3
|
+
import { A_Frame_Index } from "../Index.component";
|
|
4
|
+
import { A_Frame_IndexMeta } from "../Index.meta";
|
|
5
|
+
import { A_Frame_IndexTypeGuard } from "../Index.guard";
|
|
6
|
+
import { A_Frame_IndexError } from "../Index.error";
|
|
7
|
+
|
|
8
|
+
export function A_Frame_IndexDescribeDecorator(description: string) {
|
|
9
|
+
return function (
|
|
10
|
+
target: A_Frame_IndexDecoratorTarget,
|
|
11
|
+
propertyKey?: string | symbol,
|
|
12
|
+
descriptor?: A_Frame_IndexDecoratorDescriptor
|
|
13
|
+
|
|
14
|
+
): A_Frame_IndexDecoratorTarget {
|
|
15
|
+
const componentName = A_CommonHelper.getComponentName(target);
|
|
16
|
+
|
|
17
|
+
if (!A_Frame_IndexTypeGuard.isAllowedTarget(target)) {
|
|
18
|
+
throw new A_Frame_IndexError(
|
|
19
|
+
A_Frame_IndexError.InvalidTarget,
|
|
20
|
+
`Unable Apply Describe Index Decorator for '${componentName}': Target type is not allowed.`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// for error messages
|
|
25
|
+
|
|
26
|
+
// for error messages
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
// Get the index meta for the global A_Frame_Index component
|
|
30
|
+
// TODO: Type casting hack to avoid circular dependency issues
|
|
31
|
+
const indexMeta: A_Frame_IndexMeta = A_Context.meta(A_Frame_Index) as any;
|
|
32
|
+
|
|
33
|
+
const targetClass = A_Frame_IndexTypeGuard.getTargetConstructor(target);
|
|
34
|
+
|
|
35
|
+
// Check for pending namespace and description from other decorators
|
|
36
|
+
const targetMeta = indexMeta.getMetaFor(targetClass)
|
|
37
|
+
if (!!propertyKey || !!descriptor) {
|
|
38
|
+
|
|
39
|
+
const targetMethodName = propertyKey ? propertyKey.toString() : '';
|
|
40
|
+
|
|
41
|
+
const methodMeta = targetMeta.methods.get(targetMethodName);
|
|
42
|
+
if (!!methodMeta) {
|
|
43
|
+
methodMeta.description = description;
|
|
44
|
+
targetMeta.methods.set(targetMethodName, methodMeta);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
} else {
|
|
48
|
+
targetMeta.description = description;
|
|
49
|
+
|
|
50
|
+
indexMeta.seMetaFor(targetClass, targetMeta);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return target;
|
|
54
|
+
|
|
55
|
+
} catch (error) {
|
|
56
|
+
throw new A_Frame_IndexError(error);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { A_CommonHelper, A_Context } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame_IndexDecoratorDescriptor, A_Frame_IndexDecoratorTarget, A_Frame_IndexNamespaceDecoratorTarget } from "../Index.types";
|
|
3
|
+
import { A_Frame_Index } from "../Index.component";
|
|
4
|
+
import { A_Frame_IndexTypeGuard } from "../Index.guard";
|
|
5
|
+
import { A_Frame_IndexMeta } from "../Index.meta";
|
|
6
|
+
import { A_Frame_IndexError } from "../Index.error";
|
|
7
|
+
|
|
8
|
+
export function A_Frame_IndexNamespaceDecorator(name?: string) {
|
|
9
|
+
return function (
|
|
10
|
+
target: A_Frame_IndexDecoratorTarget,
|
|
11
|
+
propertyKey?: string | symbol,
|
|
12
|
+
descriptor?: A_Frame_IndexDecoratorDescriptor
|
|
13
|
+
|
|
14
|
+
): A_Frame_IndexDecoratorTarget {
|
|
15
|
+
const componentName = A_CommonHelper.getComponentName(target);
|
|
16
|
+
|
|
17
|
+
if (!A_Frame_IndexTypeGuard.isAllowedTarget(target)) {
|
|
18
|
+
throw new A_Frame_IndexError(
|
|
19
|
+
A_Frame_IndexError.InvalidTarget,
|
|
20
|
+
`Unable Apply Describe Index Decorator for '${componentName}': Target type is not allowed.`
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// for error messages
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
// Get the index meta for the global A_Frame_Index component
|
|
28
|
+
// TODO: Type casting hack to avoid circular dependency issues
|
|
29
|
+
const indexMeta: A_Frame_IndexMeta = A_Context.meta(A_Frame_Index) as any;
|
|
30
|
+
|
|
31
|
+
const targetClass = A_Frame_IndexTypeGuard.getTargetConstructor(target);
|
|
32
|
+
|
|
33
|
+
// Check for pending namespace and description from other decorators
|
|
34
|
+
const targetMeta = indexMeta.getMetaFor(targetClass)
|
|
35
|
+
if (!!propertyKey || !!descriptor) {
|
|
36
|
+
|
|
37
|
+
// const targetMethodName = propertyKey ? propertyKey.toString() : '';
|
|
38
|
+
|
|
39
|
+
// const methodMeta = targetMeta.methods.get(targetMethodName);
|
|
40
|
+
// if (!!methodMeta) {
|
|
41
|
+
// methodMeta.namespace = name;
|
|
42
|
+
// targetMeta.methods.set(targetMethodName, methodMeta);
|
|
43
|
+
// }
|
|
44
|
+
|
|
45
|
+
} else {
|
|
46
|
+
targetMeta.namespace = name;
|
|
47
|
+
|
|
48
|
+
indexMeta.seMetaFor(targetClass, targetMeta);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return target;
|
|
52
|
+
|
|
53
|
+
} catch (error) {
|
|
54
|
+
throw new A_Frame_IndexError(error);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { A_Concept, A_Container, A_Context, A_Error } from "@adaas/a-concept";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export class A_Frame_CLIContainer extends A_Container {
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@A_Concept.Load()
|
|
9
|
+
async initialize() {
|
|
10
|
+
if (A_Context.environment !== 'server') {
|
|
11
|
+
throw new A_Error('A-Frame CLI can only be used in Node.js environment.');
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
@A_Concept.Start()
|
|
17
|
+
async readCommandParams() {
|
|
18
|
+
console.log('Reading command parameters from CLI...');
|
|
19
|
+
|
|
20
|
+
const args = process.argv.slice(2);
|
|
21
|
+
|
|
22
|
+
console.log('Command Line Arguments:', args);
|
|
23
|
+
|
|
24
|
+
// Here you can parse the args and set them to the container's state or properties as needed
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|