@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
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { A_Component, A_Container, A_Context, A_Entity, A_Fragment } from "@adaas/a-concept";
|
|
2
|
+
import { A_Frame, A_Frame_IndexError, A_Frame_IndexMeta, A_Frame_IndexTargetType } from "../src/index";
|
|
3
|
+
describe('A-Frame Tests', () => {
|
|
4
|
+
it('Standard basic test ', async () => {
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@A_Frame.Namespace('MyTestNamespace')
|
|
8
|
+
@A_Frame.Component()
|
|
9
|
+
class MyComponent extends A_Component {
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
@A_Frame.Entity({
|
|
14
|
+
name: 'MyTestEntity',
|
|
15
|
+
description: 'This entity is uses for the test purpose'
|
|
16
|
+
})
|
|
17
|
+
class MyEntity extends A_Entity {
|
|
18
|
+
|
|
19
|
+
@A_Frame.Namespace('MethodNamespace')
|
|
20
|
+
@A_Frame.Describe('MethodNamespace')
|
|
21
|
+
@A_Frame.Method()
|
|
22
|
+
async testMethod() {
|
|
23
|
+
return 'test';
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@A_Frame.Container()
|
|
29
|
+
class MyContainer extends A_Container {
|
|
30
|
+
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@A_Frame.Describe('This is a test fragment for demonstration purposes')
|
|
34
|
+
@A_Frame.Fragment()
|
|
35
|
+
class MyFragment extends A_Fragment {
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
// Test standalone decorators (without index decorators)
|
|
42
|
+
@A_Frame.Namespace('StandaloneNamespace')
|
|
43
|
+
@A_Frame.Describe('Standalone description')
|
|
44
|
+
class StandaloneClass { }
|
|
45
|
+
} catch (error) {
|
|
46
|
+
// SHould trow error because standalone decorators should not create index entries
|
|
47
|
+
expect(error).toBeInstanceOf(A_Frame_IndexError);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
// Test that components are properly registered
|
|
52
|
+
const indexMeta = A_Context.meta<A_Frame_IndexMeta>(A_Frame);
|
|
53
|
+
const registeredComponents = indexMeta.getMetaFor(MyFragment);
|
|
54
|
+
|
|
55
|
+
expect(registeredComponents).toBeDefined();
|
|
56
|
+
expect(registeredComponents.name).toBe('MyFragment');
|
|
57
|
+
expect(registeredComponents.type).toBe(A_Frame_IndexTargetType.FRAGMENT);
|
|
58
|
+
expect(registeredComponents.description).toBe('This is a test fragment for demonstration purposes');
|
|
59
|
+
|
|
60
|
+
const registeredEntity = indexMeta.getMetaFor(MyEntity);
|
|
61
|
+
|
|
62
|
+
expect(registeredEntity).toBeDefined();
|
|
63
|
+
expect(registeredEntity.name).toBe('MyTestEntity');
|
|
64
|
+
expect(registeredEntity.type).toBe(A_Frame_IndexTargetType.ENTITY);
|
|
65
|
+
expect(registeredEntity.description).toBe('This entity is uses for the test purpose');
|
|
66
|
+
|
|
67
|
+
const registeredComponent = indexMeta.getMetaFor(MyComponent);
|
|
68
|
+
|
|
69
|
+
expect(registeredComponent).toBeDefined();
|
|
70
|
+
expect(registeredComponent.name).toBe('MyComponent');
|
|
71
|
+
expect(registeredComponent.type).toBe(A_Frame_IndexTargetType.COMPONENT);
|
|
72
|
+
expect(registeredComponent.description).toBeUndefined();
|
|
73
|
+
|
|
74
|
+
const registeredContainer = indexMeta.getMetaFor(MyContainer);
|
|
75
|
+
|
|
76
|
+
expect(registeredContainer).toBeDefined();
|
|
77
|
+
expect(registeredContainer.name).toBe('MyContainer');
|
|
78
|
+
expect(registeredContainer.type).toBe(A_Frame_IndexTargetType.CONTAINER);
|
|
79
|
+
expect(registeredContainer.description).toBeUndefined();
|
|
80
|
+
|
|
81
|
+
// Test that method is properly registered
|
|
82
|
+
const registeredMethod = registeredEntity.methods.get('testMethod');
|
|
83
|
+
|
|
84
|
+
console.log('registeredEntity.methods: ', registeredEntity.methods)
|
|
85
|
+
|
|
86
|
+
expect(registeredMethod).toBeDefined();
|
|
87
|
+
expect(registeredMethod?.name).toBe('testMethod');
|
|
88
|
+
expect(registeredMethod?.description).toBe('MethodNamespace');
|
|
89
|
+
|
|
90
|
+
});
|
|
91
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { A_Context } from '@adaas/a-concept';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Base hooks for tests
|
|
6
|
+
*/
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
|
|
9
|
+
return Promise.resolve();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
afterAll(async () => {
|
|
13
|
+
try {
|
|
14
|
+
fs.unlinkSync('a-concept.conf.json');
|
|
15
|
+
|
|
16
|
+
} catch (error) {
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
return Promise.resolve();
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
beforeEach(async () => {
|
|
23
|
+
A_Context.reset();
|
|
24
|
+
return Promise.resolve();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
afterEach(async () => {
|
|
28
|
+
A_Context.reset();
|
|
29
|
+
return Promise.resolve();
|
|
30
|
+
});
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compileOnSave": false,
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"noImplicitAny": false,
|
|
7
|
+
"noFallthroughCasesInSwitch": true,
|
|
8
|
+
"downlevelIteration": true,
|
|
9
|
+
"strictFunctionTypes": true,
|
|
10
|
+
"strictNullChecks": true,
|
|
11
|
+
"strictPropertyInitialization": true,
|
|
12
|
+
"forceConsistentCasingInFileNames": true,
|
|
13
|
+
"resolveJsonModule": true,
|
|
14
|
+
"noErrorTruncation": true,
|
|
15
|
+
"jsx": "react",
|
|
16
|
+
"target": "es2015",
|
|
17
|
+
"module": "commonjs",
|
|
18
|
+
"moduleResolution": "node",
|
|
19
|
+
"allowSyntheticDefaultImports": true,
|
|
20
|
+
"esModuleInterop": true,
|
|
21
|
+
"noUnusedLocals": false,
|
|
22
|
+
"noUnusedParameters": false,
|
|
23
|
+
"removeComments": false,
|
|
24
|
+
"preserveConstEnums": true,
|
|
25
|
+
"sourceMap": true,
|
|
26
|
+
"baseUrl": ".",
|
|
27
|
+
"experimentalDecorators": true,
|
|
28
|
+
"skipLibCheck": true,
|
|
29
|
+
"typeRoots": [
|
|
30
|
+
"node_modules/@types"
|
|
31
|
+
],
|
|
32
|
+
"paths": {
|
|
33
|
+
"@adaas/a-frame/constants/*": ["src/constants/*"],
|
|
34
|
+
"@adaas/a-frame/lib/*": ["src/lib/*"],
|
|
35
|
+
"@adaas/a-frame/types/*": ["src/types/*"],
|
|
36
|
+
"@adaas/a-frame/helpers/*": ["src/helpers/*"],
|
|
37
|
+
"@adaas/a-frame/decorators/*": ["src/decorators/*"],
|
|
38
|
+
"@adaas/a-frame/utils/*": ["src/utils/*"]
|
|
39
|
+
},
|
|
40
|
+
"lib": [
|
|
41
|
+
"dom",
|
|
42
|
+
"esnext.asynciterable",
|
|
43
|
+
"es2015",
|
|
44
|
+
"es2016",
|
|
45
|
+
"es2017.object"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"include": [
|
|
49
|
+
"src/**/*",
|
|
50
|
+
"tests/**/*",
|
|
51
|
+
"examples/**/*",
|
|
52
|
+
"src/index.ts",
|
|
53
|
+
"./index.ts"
|
|
54
|
+
],
|
|
55
|
+
"exclude": [
|
|
56
|
+
"node_modules/**/*",
|
|
57
|
+
"dist/**/*",
|
|
58
|
+
"node_modules/@types/mocha/index.d.ts"
|
|
59
|
+
]
|
|
60
|
+
}
|
package/tslint.json
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": [
|
|
3
|
+
"tslint-react",
|
|
4
|
+
"tslint-config-standard",
|
|
5
|
+
"tslint-microsoft-contrib",
|
|
6
|
+
"tslint-config-prettier"
|
|
7
|
+
],
|
|
8
|
+
"rules": {
|
|
9
|
+
"array-bracket-spacing": [true, "never"],
|
|
10
|
+
"arrow-return-shorthand": true,
|
|
11
|
+
"no-backbone-get-set-outside-model": false,
|
|
12
|
+
"completed-docs": false,
|
|
13
|
+
"curly": [true, "ignore-same-line"],
|
|
14
|
+
"cyclomatic-complexity": [true, 24],
|
|
15
|
+
"eofline": true,
|
|
16
|
+
"export-name": false,
|
|
17
|
+
"function-name": false,
|
|
18
|
+
"import-name": false,
|
|
19
|
+
"import-spacing": true,
|
|
20
|
+
"interface-name": [true, "never-prefix"],
|
|
21
|
+
"jsx-alignment": false,
|
|
22
|
+
"jsx-boolean-value": false,
|
|
23
|
+
"jsx-curly-spacing": false,
|
|
24
|
+
"jsx-no-multiline-js": false,
|
|
25
|
+
"match-default-export-name": false,
|
|
26
|
+
"max-func-body-length": 200,
|
|
27
|
+
"member-access": [true, "no-public"],
|
|
28
|
+
"member-ordering": {"options": [{"order": "fields-first"}]},
|
|
29
|
+
"missing-jsdoc": false,
|
|
30
|
+
"mocha-no-side-effect-code": false,
|
|
31
|
+
"no-arg": true,
|
|
32
|
+
"no-bitwise": true,
|
|
33
|
+
"no-console": false,
|
|
34
|
+
"no-construct": true,
|
|
35
|
+
"no-default-export": false,
|
|
36
|
+
"no-duplicate-switch-case": true,
|
|
37
|
+
"no-duplicate-variable": true,
|
|
38
|
+
"no-empty-interface": false,
|
|
39
|
+
"no-eval": true,
|
|
40
|
+
"no-function-expression": false,
|
|
41
|
+
"no-http-string": false,
|
|
42
|
+
"no-implicit-dependencies": false,
|
|
43
|
+
"no-multiline-string": false,
|
|
44
|
+
"no-non-null-assertion": true,
|
|
45
|
+
"no-relative-imports": false,
|
|
46
|
+
"no-require-imports": {"severity": "warning"},
|
|
47
|
+
"no-reserved-keywords": false,
|
|
48
|
+
"no-return-await": true,
|
|
49
|
+
"no-single-line-block-comment": false,
|
|
50
|
+
"no-string-throw": true,
|
|
51
|
+
"no-submodule-imports": false,
|
|
52
|
+
"no-suspicious-comment": false,
|
|
53
|
+
"no-unsafe-any": false,
|
|
54
|
+
"no-unused-variable": false,
|
|
55
|
+
"no-var-requires": true,
|
|
56
|
+
"no-void-expression": false,
|
|
57
|
+
"object-curly-spacing": [true, "never"],
|
|
58
|
+
"ordered-imports": false,
|
|
59
|
+
"prefer-for-of": true,
|
|
60
|
+
"prefer-object-spread": true,
|
|
61
|
+
"prefer-type-cast": false,
|
|
62
|
+
"quotemark": [true, "single", "jsx-double", "avoid-escape"],
|
|
63
|
+
"semicolon": [true, "never"],
|
|
64
|
+
"strict-boolean-expressions": false,
|
|
65
|
+
"strict-type-predicates": false,
|
|
66
|
+
"ter-func-call-spacing": [true, "never"],
|
|
67
|
+
"trailing-comma": [true, "always"],
|
|
68
|
+
"type-literal-delimiter": false,
|
|
69
|
+
"typedef": false,
|
|
70
|
+
"typedef-whitespace": [
|
|
71
|
+
true,
|
|
72
|
+
{
|
|
73
|
+
"call-signature": "nospace",
|
|
74
|
+
"index-signature": "nospace",
|
|
75
|
+
"parameter": "nospace",
|
|
76
|
+
"property-declaration": "nospace",
|
|
77
|
+
"variable-declaration": "nospace"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"call-signature": "onespace",
|
|
81
|
+
"index-signature": "onespace",
|
|
82
|
+
"parameter": "onespace",
|
|
83
|
+
"property-declaration": "onespace",
|
|
84
|
+
"variable-declaration": "onespace"
|
|
85
|
+
}
|
|
86
|
+
],
|
|
87
|
+
"unified-signatures": true,
|
|
88
|
+
"variable-name": false,
|
|
89
|
+
"whitespace": [
|
|
90
|
+
true,
|
|
91
|
+
"check-branch",
|
|
92
|
+
"check-operator",
|
|
93
|
+
"check-typecast",
|
|
94
|
+
"check-rest-spread",
|
|
95
|
+
"check-type-operator"
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
}
|
package/tsup.config.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { defineConfig } from "tsup";
|
|
2
|
+
|
|
3
|
+
export default defineConfig((options) => ({
|
|
4
|
+
entry: ["src/index.ts"],
|
|
5
|
+
format: ["esm", "cjs"],
|
|
6
|
+
dts: true,
|
|
7
|
+
clean: !options.watch,
|
|
8
|
+
sourcemap: true,
|
|
9
|
+
target: "es2020",
|
|
10
|
+
minify: !options.watch,
|
|
11
|
+
treeshake: "recommended",
|
|
12
|
+
skipNodeModulesBundle: true,
|
|
13
|
+
splitting: false,
|
|
14
|
+
silent: false,
|
|
15
|
+
platform: "neutral",
|
|
16
|
+
// Add hash to filenames for cache busting in production builds
|
|
17
|
+
outExtension({ format }) {
|
|
18
|
+
return {
|
|
19
|
+
js: format === "esm" ? `.mjs` : `.cjs`,
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
// Extra optimization options (for 2025 esbuild)
|
|
23
|
+
esbuildOptions(options) {
|
|
24
|
+
options.keepNames = true; // Preserve class/function names for better debugging
|
|
25
|
+
options.charset = "utf8";
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
// Enable minification for output size (production only)
|
|
29
|
+
minifyWhitespace: !options.watch,
|
|
30
|
+
minifyIdentifiers: !options.watch,
|
|
31
|
+
minifySyntax: !options.watch,
|
|
32
|
+
}));
|