@adaas/a-concept 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 +22 -0
- package/README.md +19 -0
- package/dist/examples/sdk/concept.d.ts +0 -0
- package/dist/examples/sdk/concept.js +21 -0
- package/dist/examples/sdk/concept.js.map +1 -0
- package/dist/examples/sdk/orders.api.d.ts +0 -0
- package/dist/examples/sdk/orders.api.js +16 -0
- package/dist/examples/sdk/orders.api.js.map +1 -0
- package/dist/examples/sdk/users.api.d.ts +0 -0
- package/dist/examples/sdk/users.api.js +16 -0
- package/dist/examples/sdk/users.api.js.map +1 -0
- package/dist/examples/simple/concept.d.ts +0 -0
- package/dist/examples/simple/concept.js +13 -0
- package/dist/examples/simple/concept.js.map +1 -0
- package/dist/examples/simple-http-server/concept.d.ts +1 -0
- package/dist/examples/simple-http-server/concept.js +36 -0
- package/dist/examples/simple-http-server/concept.js.map +1 -0
- package/dist/examples/simple-http-server/containers/http-server.container.d.ts +12 -0
- package/dist/examples/simple-http-server/containers/http-server.container.js +69 -0
- package/dist/examples/simple-http-server/containers/http-server.container.js.map +1 -0
- package/dist/examples/simple-http-server/containers/http-server.controller.d.ts +7 -0
- package/dist/examples/simple-http-server/containers/http-server.controller.js +37 -0
- package/dist/examples/simple-http-server/containers/http-server.controller.js.map +1 -0
- package/dist/examples/simple-http-server/containers/http-server.router.d.ts +6 -0
- package/dist/examples/simple-http-server/containers/http-server.router.js +39 -0
- package/dist/examples/simple-http-server/containers/http-server.router.js.map +1 -0
- package/dist/examples/simple-http-server/contexts/http-server.context.types.d.ts +4 -0
- package/dist/examples/simple-http-server/contexts/http-server.context.types.js +100 -0
- package/dist/examples/simple-http-server/contexts/http-server.context.types.js.map +1 -0
- package/dist/examples/simple-http-server/contexts/http-server.namespace.d.ts +10 -0
- package/dist/examples/simple-http-server/contexts/http-server.namespace.js +26 -0
- package/dist/examples/simple-http-server/contexts/http-server.namespace.js.map +1 -0
- package/dist/examples/simple-http-server/controllers/orders.controller.d.ts +5 -0
- package/dist/examples/simple-http-server/controllers/orders.controller.js +32 -0
- package/dist/examples/simple-http-server/controllers/orders.controller.js.map +1 -0
- package/dist/examples/simple-http-server/controllers/users.controller.d.ts +0 -0
- package/dist/examples/simple-http-server/controllers/users.controller.js +87 -0
- package/dist/examples/simple-http-server/controllers/users.controller.js.map +1 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.context.d.ts +5 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.context.js +25 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.context.js.map +1 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.module.d.ts +16 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.module.js +8 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.module.js.map +1 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.types.d.ts +2 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.types.js +3 -0
- package/dist/examples/simple-http-server/modules/simple-http-server.types.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/src/constants/A_ConceptLifecycle.constants.d.ts +2 -0
- package/dist/src/constants/A_ConceptLifecycle.constants.js +12 -0
- package/dist/src/constants/A_ConceptLifecycle.constants.js.map +1 -0
- package/dist/src/containers/A-Config/A-Config.container.d.ts +7 -0
- package/dist/src/containers/A-Config/A-Config.container.js +65 -0
- package/dist/src/containers/A-Config/A-Config.container.js.map +1 -0
- package/dist/src/containers/A-Config/A-Config.namespace.d.ts +28 -0
- package/dist/src/containers/A-Config/A-Config.namespace.js +54 -0
- package/dist/src/containers/A-Config/A-Config.namespace.js.map +1 -0
- package/dist/src/containers/A-Config/A-Config.types.d.ts +12 -0
- package/dist/src/containers/A-Config/A-Config.types.js +3 -0
- package/dist/src/containers/A-Config/A-Config.types.js.map +1 -0
- package/dist/src/containers/A-Config/components/ConfigReader.component.d.ts +18 -0
- package/dist/src/containers/A-Config/components/ConfigReader.component.js +37 -0
- package/dist/src/containers/A-Config/components/ConfigReader.component.js.map +1 -0
- package/dist/src/containers/A-Config/components/ENVConfigReader.component.d.ts +10 -0
- package/dist/src/containers/A-Config/components/ENVConfigReader.component.js +37 -0
- package/dist/src/containers/A-Config/components/ENVConfigReader.component.js.map +1 -0
- package/dist/src/containers/A-Config/components/FileConfigReader.component.d.ts +11 -0
- package/dist/src/containers/A-Config/components/FileConfigReader.component.js +47 -0
- package/dist/src/containers/A-Config/components/FileConfigReader.component.js.map +1 -0
- package/dist/src/containers/A-Errors/A-Errors.container.d.ts +5 -0
- package/dist/src/containers/A-Errors/A-Errors.container.js +32 -0
- package/dist/src/containers/A-Errors/A-Errors.container.js.map +1 -0
- package/dist/src/containers/A-Errors/A-Errors.namespace.d.ts +40 -0
- package/dist/src/containers/A-Errors/A-Errors.namespace.js +76 -0
- package/dist/src/containers/A-Errors/A-Errors.namespace.js.map +1 -0
- package/dist/src/containers/A-Errors/A-Errors.types.d.ts +5 -0
- package/dist/src/containers/A-Errors/A-Errors.types.js +3 -0
- package/dist/src/containers/A-Errors/A-Errors.types.js.map +1 -0
- package/dist/src/containers/A-Logger/A-Logger.container.d.ts +6 -0
- package/dist/src/containers/A-Logger/A-Logger.container.js +41 -0
- package/dist/src/containers/A-Logger/A-Logger.container.js.map +1 -0
- package/dist/src/containers/A-Logger/A-Logger.namespace.d.ts +17 -0
- package/dist/src/containers/A-Logger/A-Logger.namespace.js +22 -0
- package/dist/src/containers/A-Logger/A-Logger.namespace.js.map +1 -0
- package/dist/src/containers/A-Logger/A-Logger.types.d.ts +0 -0
- package/dist/src/containers/A-Logger/A-Logger.types.js +2 -0
- package/dist/src/containers/A-Logger/A-Logger.types.js.map +1 -0
- package/dist/src/containers/A-Logger/components/Logger.component.d.ts +29 -0
- package/dist/src/containers/A-Logger/components/Logger.component.js +128 -0
- package/dist/src/containers/A-Logger/components/Logger.component.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.d.ts +34 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.js +3 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.d.ts +11 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.js +36 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.d.ts +7 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.js +3 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.d.ts +17 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.js +42 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.d.ts +8 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.js +3 -0
- package/dist/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-ConceptLifecycle/index.d.ts +7 -0
- package/dist/src/decorators/A-ConceptLifecycle/index.js +11 -0
- package/dist/src/decorators/A-ConceptLifecycle/index.js.map +1 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.d.ts +0 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.js +11 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.js.map +1 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.d.ts +0 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js +2 -0
- package/dist/src/decorators/A-Feature/A-Feature.decorator.types.js.map +1 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.d.ts +22 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js +32 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.js.map +1 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.d.ts +4 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.js +3 -0
- package/dist/src/decorators/A-Inject/A-Inject.decorator.types.js.map +1 -0
- package/dist/src/decorators/A_ConceptMethods.decorator.d.ts +0 -0
- package/dist/src/decorators/A_ConceptMethods.decorator.js +2 -0
- package/dist/src/decorators/A_ConceptMethods.decorator.js.map +1 -0
- package/dist/src/decorators/A_Lazy.decorator.d.ts +5 -0
- package/dist/src/decorators/A_Lazy.decorator.js +20 -0
- package/dist/src/decorators/A_Lazy.decorator.js.map +1 -0
- package/dist/src/global/A-Component/A-Component.class.d.ts +16 -0
- package/dist/src/global/A-Component/A-Component.class.js +18 -0
- package/dist/src/global/A-Component/A-Component.class.js.map +1 -0
- package/dist/src/global/A-Concept/A_Concept.class.d.ts +46 -0
- package/dist/src/global/A-Concept/A_Concept.class.js +106 -0
- package/dist/src/global/A-Concept/A_Concept.class.js.map +1 -0
- package/dist/src/global/A-Concept/A_Concept.types.d.ts +26 -0
- package/dist/src/global/A-Concept/A_Concept.types.js +3 -0
- package/dist/src/global/A-Concept/A_Concept.types.js.map +1 -0
- package/dist/src/global/A-Container/A-Container.class.d.ts +14 -0
- package/dist/src/global/A-Container/A-Container.class.js +21 -0
- package/dist/src/global/A-Container/A-Container.class.js.map +1 -0
- package/dist/src/global/A-Context/A-Context.class.d.ts +88 -0
- package/dist/src/global/A-Context/A-Context.class.js +118 -0
- package/dist/src/global/A-Context/A-Context.class.js.map +1 -0
- package/dist/src/global/A-Context/A-Context.types.d.ts +0 -0
- package/dist/src/global/A-Context/A-Context.types.js +2 -0
- package/dist/src/global/A-Context/A-Context.types.js.map +1 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.class.d.ts +17 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js +67 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.class.js.map +1 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.types.d.ts +55 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.types.js +3 -0
- package/dist/src/global/A-Dependency/A-DependencyReference.types.js.map +1 -0
- package/dist/src/global/A-Namespace/A_Namespace.class.d.ts +47 -0
- package/dist/src/global/A-Namespace/A_Namespace.class.js +112 -0
- package/dist/src/global/A-Namespace/A_Namespace.class.js.map +1 -0
- package/dist/src/global/A-Namespace/A_Namespace.types.d.ts +19 -0
- package/dist/src/global/A-Namespace/A_Namespace.types.js +3 -0
- package/dist/src/global/A-Namespace/A_Namespace.types.js.map +1 -0
- package/dist/src/managers/A_DependencyManager.class.d.ts +24 -0
- package/dist/src/managers/A_DependencyManager.class.js +129 -0
- package/dist/src/managers/A_DependencyManager.class.js.map +1 -0
- package/dist/src/storage/A_Concept.storage.d.ts +19 -0
- package/dist/src/storage/A_Concept.storage.js +29 -0
- package/dist/src/storage/A_Concept.storage.js.map +1 -0
- package/dist/src/types/A_DependencyManager.types.d.ts +15 -0
- package/dist/src/types/A_DependencyManager.types.js +3 -0
- package/dist/src/types/A_DependencyManager.types.js.map +1 -0
- package/dist/src/types/A_Module.types.d.ts +17 -0
- package/dist/src/types/A_Module.types.js +22 -0
- package/dist/src/types/A_Module.types.js.map +1 -0
- package/docs/logo.png +0 -0
- package/examples/sdk/concept.ts +24 -0
- package/examples/sdk/orders.api.ts +21 -0
- package/examples/sdk/users.api.ts +21 -0
- package/examples/simple/concept.ts +16 -0
- package/examples/simple-http-server/concept.ts +30 -0
- package/examples/simple-http-server/containers/http-server.container.ts +69 -0
- package/examples/simple-http-server/containers/http-server.controller.ts +24 -0
- package/examples/simple-http-server/containers/http-server.router.ts +23 -0
- package/examples/simple-http-server/contexts/http-server.context.types.ts +108 -0
- package/examples/simple-http-server/contexts/http-server.namespace.ts +36 -0
- package/examples/simple-http-server/controllers/orders.controller.ts +20 -0
- package/examples/simple-http-server/controllers/users.controller.ts +104 -0
- package/index.ts +14 -0
- package/jest.config.ts +22 -0
- package/package.json +73 -0
- package/src/constants/A_ConceptLifecycle.constants.ts +12 -0
- package/src/containers/A-Config/A-Config.container.ts +60 -0
- package/src/containers/A-Config/A-Config.namespace.ts +98 -0
- package/src/containers/A-Config/A-Config.types.ts +31 -0
- package/src/containers/A-Config/components/ConfigReader.component.ts +30 -0
- package/src/containers/A-Config/components/ENVConfigReader.component.ts +31 -0
- package/src/containers/A-Config/components/FileConfigReader.component.ts +42 -0
- package/src/containers/A-Errors/A-Errors.container.ts +14 -0
- package/src/containers/A-Errors/A-Errors.namespace.ts +104 -0
- package/src/containers/A-Errors/A-Errors.types.ts +6 -0
- package/src/containers/A-Logger/A-Logger.container.ts +22 -0
- package/src/containers/A-Logger/A-Logger.namespace.ts +26 -0
- package/src/containers/A-Logger/A-Logger.types.ts +0 -0
- package/src/containers/A-Logger/components/Logger.component.ts +169 -0
- package/src/decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types.ts +46 -0
- package/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.ts +55 -0
- package/src/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator.types.ts +20 -0
- package/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.ts +62 -0
- package/src/decorators/A-ConceptLifecycle/A-Run/A-Run.decorator.types.ts +28 -0
- package/src/decorators/A-ConceptLifecycle/index.ts +9 -0
- package/src/decorators/A-Feature/A-Feature.decorator.ts +13 -0
- package/src/decorators/A-Feature/A-Feature.decorator.types.ts +0 -0
- package/src/decorators/A-Inject/A-Inject.decorator.ts +75 -0
- package/src/decorators/A-Inject/A-Inject.decorator.types.ts +10 -0
- package/src/decorators/A_ConceptMethods.decorator.ts +0 -0
- package/src/decorators/A_Lazy.decorator.ts +31 -0
- package/src/global/A-Component/A-Component.class.ts +33 -0
- package/src/global/A-Concept/A_Concept.class.ts +143 -0
- package/src/global/A-Concept/A_Concept.types.ts +44 -0
- package/src/global/A-Container/A-Container.class.ts +39 -0
- package/src/global/A-Context/A-Context.class.ts +230 -0
- package/src/global/A-Context/A-Context.types.ts +0 -0
- package/src/global/A-Dependency/A-DependencyReference.class.ts +61 -0
- package/src/global/A-Dependency/A-DependencyReference.types.ts +61 -0
- package/src/global/A-Namespace/A_Namespace.class.ts +128 -0
- package/src/global/A-Namespace/A_Namespace.types.ts +24 -0
- package/src/storage/A_Concept.storage.ts +45 -0
- package/src/types/A_Module.types.ts +23 -0
- package/tests/context.test.ts +124 -0
- package/tests/default.test.ts +159 -0
- package/tests/log.ts +54 -0
- package/tests/polyfill.test.ts +37 -0
- package/tsconfig.json +61 -0
- package/tslint.json +98 -0
package/jest.config.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Config } from '@jest/types';
|
|
2
|
+
|
|
3
|
+
// Sync object
|
|
4
|
+
const config: Config.InitialOptions = {
|
|
5
|
+
verbose: true,
|
|
6
|
+
|
|
7
|
+
transform: {
|
|
8
|
+
'^.+\\.tsx?$': 'ts-jest'
|
|
9
|
+
},
|
|
10
|
+
moduleNameMapper: {
|
|
11
|
+
"@adaas/a-concept/constants/(.*)": ["<rootDir>/src/constants/$1"],
|
|
12
|
+
"@adaas/a-concept/global/(.*)": ["<rootDir>/src/global/$1"],
|
|
13
|
+
"@adaas/a-concept/types/(.*)": ["<rootDir>/src/types/$1"],
|
|
14
|
+
"@adaas/a-concept/helpers/(.*)": ["<rootDir>/src/helpers/$1"],
|
|
15
|
+
"@adaas/a-concept/decorators/(.*)": ["<rootDir>/src/decorators/$1"],
|
|
16
|
+
"@adaas/a-concept/managers/(.*)": ["<rootDir>/src/managers/$1"],
|
|
17
|
+
"@adaas/a-concept/providers/(.*)": ["<rootDir>/src/providers/$1"],
|
|
18
|
+
"@adaas/a-concept/modules/(.*)": ["<rootDir>/src/modules/$1"],
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
};
|
|
22
|
+
export default config;
|
package/package.json
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@adaas/a-concept",
|
|
3
|
+
"version": "0.0.2",
|
|
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
|
+
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"nodemonConfig": {
|
|
9
|
+
"ignore": [
|
|
10
|
+
"**/*.test.ts",
|
|
11
|
+
"**/*.spec.ts",
|
|
12
|
+
".git",
|
|
13
|
+
"node_modules"
|
|
14
|
+
],
|
|
15
|
+
"watch": [
|
|
16
|
+
"config",
|
|
17
|
+
"constants",
|
|
18
|
+
"src",
|
|
19
|
+
"lib",
|
|
20
|
+
"db",
|
|
21
|
+
"shared"
|
|
22
|
+
],
|
|
23
|
+
"exec": "node -r tsconfig-paths/register -r ts-node/register ",
|
|
24
|
+
"ext": "ts, js"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"test": "jest",
|
|
28
|
+
"start": "nodemon ./tests/log.ts",
|
|
29
|
+
"publish": "npm run build && git add . && git commit -m \"new version created :: $(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g')\" && npm version patch && npm publish --access public",
|
|
30
|
+
"preversion": "echo test",
|
|
31
|
+
"version": "echo git add .",
|
|
32
|
+
"postversion": "git push --no-verify && git push --tags --no-verify && echo \"\n======Version Pushed Successfully=====\n\" ",
|
|
33
|
+
"echo-version": "echo $npm_package_version",
|
|
34
|
+
"build": "tsc --declaration --project tsconfig.json && tscpaths -p tsconfig.json -s ./ -o ./dist && rm -r ./dist/tests"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/ADAAS-org/adaas-adf-auth.git"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"sdk",
|
|
42
|
+
"ai",
|
|
43
|
+
"rag"
|
|
44
|
+
],
|
|
45
|
+
"author": "adaas.org",
|
|
46
|
+
"license": "ISC",
|
|
47
|
+
"bugs": {
|
|
48
|
+
"url": "https://github.com/ADAAS-org/adaas-adf-auth/issues"
|
|
49
|
+
},
|
|
50
|
+
"homepage": "https://github.com/ADAAS-org/adaas-adf-auth#readme",
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@adaas/a-utils": "^0.0.3",
|
|
53
|
+
"@types/node": "^20.10.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/chai": "^4.3.14",
|
|
57
|
+
"@types/jest": "^29.5.12",
|
|
58
|
+
"@types/mocha": "^10.0.6",
|
|
59
|
+
"chai": "^5.1.0",
|
|
60
|
+
"dotenv": "^16.4.5",
|
|
61
|
+
"jest": "^29.7.0",
|
|
62
|
+
"mocha": "^10.4.0",
|
|
63
|
+
"nodemon": "^3.1.4",
|
|
64
|
+
"ts-jest": "^29.1.2",
|
|
65
|
+
"ts-node": "^10.9.2",
|
|
66
|
+
"tsconfig-paths": "^4.2.0",
|
|
67
|
+
"tscpaths": "^0.0.9"
|
|
68
|
+
},
|
|
69
|
+
"directories": {
|
|
70
|
+
"doc": "docs",
|
|
71
|
+
"test": "tests"
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { A_TYPES__ConceptLifecycle_MethodDeclarationConfig } from "../decorators/A-ConceptLifecycle/A-ConceptLifecycle.decorator.types";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export const A_CONSTANTS__DEFAULT_CONCEPT_LIFECYCLE_METHOD_DECLARATION_CONFIG: A_TYPES__ConceptLifecycle_MethodDeclarationConfig = {
|
|
6
|
+
name: '',
|
|
7
|
+
behavior: 'sync',
|
|
8
|
+
type: 'extension',
|
|
9
|
+
after: [],
|
|
10
|
+
before: [],
|
|
11
|
+
override: []
|
|
12
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
2
|
+
import { A_Config } from "./A-Config.namespace";
|
|
3
|
+
import { A_Load } from "@adaas/a-concept/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator";
|
|
4
|
+
import { A_Polyfills } from "@adaas/a-utils";
|
|
5
|
+
import { FileConfigReader } from "./components/FileConfigReader.component";
|
|
6
|
+
import { ENVConfigReader } from "./components/ENVConfigReader.component";
|
|
7
|
+
import { ConfigReader } from "./components/ConfigReader.component";
|
|
8
|
+
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// @A_Injectable({
|
|
13
|
+
|
|
14
|
+
// })
|
|
15
|
+
export class A_ConfigInitializer extends A_Container<A_Config> {
|
|
16
|
+
|
|
17
|
+
private reader!: ConfigReader
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
@A_Load({
|
|
21
|
+
})
|
|
22
|
+
async identifyReader(
|
|
23
|
+
// @A_Inject(A_LoggerContext) logger: A_LoggerContext
|
|
24
|
+
) {
|
|
25
|
+
|
|
26
|
+
// OR Inject the logger by calling Context Provider
|
|
27
|
+
// const logger2 = await this.CP.resolve(A_LoggerContext);
|
|
28
|
+
|
|
29
|
+
const fs = await A_Polyfills.fs();
|
|
30
|
+
|
|
31
|
+
switch (true) {
|
|
32
|
+
|
|
33
|
+
case A_Context.environment === 'server' && !!fs.existsSync(`${this.namespace}.conf.json`):
|
|
34
|
+
this.reader = A_Context.resolve(FileConfigReader);
|
|
35
|
+
break;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
case A_Context.environment === 'server': !fs.existsSync(`${this.namespace}.conf.json`)
|
|
39
|
+
this.reader = A_Context.resolve(ENVConfigReader);
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
case A_Context.environment === 'browser':
|
|
43
|
+
this.reader = A_Context.resolve(ENVConfigReader);
|
|
44
|
+
break;
|
|
45
|
+
|
|
46
|
+
default:
|
|
47
|
+
throw new Error(`Environment ${A_Context.environment} is not supported`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@A_Load({})
|
|
53
|
+
async readVariables() {
|
|
54
|
+
const config = await this.reader.read(this.namespace.CONFIG_PROPERTIES);
|
|
55
|
+
|
|
56
|
+
this.namespace.set(config);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { A_Namespace } from "@adaas/a-concept/global/A-Namespace/A_Namespace.class";
|
|
2
|
+
import { A_TYPES__ConfigContainerConstructor } from "./A-Config.types";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class A_Config<
|
|
6
|
+
T extends string = any
|
|
7
|
+
> extends A_Namespace<A_TYPES__ConfigContainerConstructor<T>> {
|
|
8
|
+
|
|
9
|
+
// Custom properties
|
|
10
|
+
private VARIABLES: Map<string, any> = new Map<string, any>();
|
|
11
|
+
CONFIG_PROPERTIES: T[] = [];
|
|
12
|
+
|
|
13
|
+
protected DEFAULT_ALLOWED_TO_READ_PROPERTIES = [
|
|
14
|
+
'CONFIG_SDK_VALIDATION',
|
|
15
|
+
'CONFIG_VERBOSE',
|
|
16
|
+
'CONFIG_IGNORE_ERRORS',
|
|
17
|
+
] as const;
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
constructor(
|
|
21
|
+
config: A_TYPES__ConfigContainerConstructor<T>
|
|
22
|
+
) {
|
|
23
|
+
super(config);
|
|
24
|
+
|
|
25
|
+
const targetConfig = config
|
|
26
|
+
|
|
27
|
+
this.CONFIG_PROPERTIES = targetConfig.variables ? targetConfig.variables : [];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* This method is used to get the configuration property by name
|
|
33
|
+
*
|
|
34
|
+
* @param property
|
|
35
|
+
* @returns
|
|
36
|
+
*/
|
|
37
|
+
get<_OutType = any>(
|
|
38
|
+
property: T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]
|
|
39
|
+
): _OutType {
|
|
40
|
+
if (this.CONFIG_PROPERTIES.includes(property as any))
|
|
41
|
+
return this.VARIABLES.get(property as string) as _OutType;
|
|
42
|
+
|
|
43
|
+
throw new Error('Property not exists or not allowed to read') as never;
|
|
44
|
+
// return this.concept.Errors.throw(A_SDK_CONSTANTS__ERROR_CODES.CONFIGURATION_PROPERTY_NOT_EXISTS_OR_NOT_ALLOWED_TO_READ) as never;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* This method is used to set the configuration property by name
|
|
52
|
+
* OR set multiple properties at once by passing an array of objects
|
|
53
|
+
*
|
|
54
|
+
* @param variables
|
|
55
|
+
*/
|
|
56
|
+
set<V extends string = T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]>(
|
|
57
|
+
variables: Array<{
|
|
58
|
+
property: V,
|
|
59
|
+
value: any
|
|
60
|
+
}>
|
|
61
|
+
)
|
|
62
|
+
set<V extends string = T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]>(
|
|
63
|
+
variables: Record<V, any>
|
|
64
|
+
)
|
|
65
|
+
set<V extends string = T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]>(
|
|
66
|
+
property: V,
|
|
67
|
+
value: any
|
|
68
|
+
)
|
|
69
|
+
set<V extends string = T | typeof this.DEFAULT_ALLOWED_TO_READ_PROPERTIES[number]>(
|
|
70
|
+
property: V | Array<{
|
|
71
|
+
property: V,
|
|
72
|
+
value: any
|
|
73
|
+
}> | Record<V, any>,
|
|
74
|
+
value?: any
|
|
75
|
+
) {
|
|
76
|
+
const array = Array.isArray(property)
|
|
77
|
+
? property
|
|
78
|
+
: typeof property === 'string'
|
|
79
|
+
? [{ property, value }]
|
|
80
|
+
: Object
|
|
81
|
+
.keys(property)
|
|
82
|
+
.map((key) => ({
|
|
83
|
+
property: key,
|
|
84
|
+
value: property[key]
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
for (const { property, value } of array) {
|
|
88
|
+
|
|
89
|
+
let targetValue = value
|
|
90
|
+
? value
|
|
91
|
+
: this.config?.defaults
|
|
92
|
+
? this.config.defaults[property as T]
|
|
93
|
+
: undefined;
|
|
94
|
+
|
|
95
|
+
this.VARIABLES.set(property as string, targetValue);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { A_TYPES__NamespaceConstructor } from "@adaas/a-concept/global/A-Namespace/A_Namespace.types";
|
|
2
|
+
|
|
3
|
+
export type A_TYPES__ConfigContainerConstructor<T extends string> = {
|
|
4
|
+
/**
|
|
5
|
+
* The name of the Config Container
|
|
6
|
+
*/
|
|
7
|
+
variables?: Array<T>
|
|
8
|
+
/**
|
|
9
|
+
* Allows to set the default values for the variables
|
|
10
|
+
*/
|
|
11
|
+
defaults?: Record<T, any>
|
|
12
|
+
// credentials?: {
|
|
13
|
+
// /**
|
|
14
|
+
// * Api Credentials Client ID to authenticate the SDK
|
|
15
|
+
// * can be skipped for the FrontEnd SDKs
|
|
16
|
+
// */
|
|
17
|
+
// client_id: string,
|
|
18
|
+
|
|
19
|
+
// /**
|
|
20
|
+
// * Api Credentials Client Secret to authenticate the SDK
|
|
21
|
+
// * can be skipped for the FrontEnd SDKs
|
|
22
|
+
// */
|
|
23
|
+
// client_secret: string
|
|
24
|
+
|
|
25
|
+
// }
|
|
26
|
+
} & A_TYPES__NamespaceConstructor
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export type A_TYPES__ConfigContainer_DefaultProperties = 'CONFIG_SDK_VALIDATION'
|
|
30
|
+
| 'CONFIG_VERBOSE'
|
|
31
|
+
| 'CONFIG_IGNORE_ERRORS';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { A_Component } from "@adaas/a-concept/global/A-Component/A-Component.class";
|
|
2
|
+
import { A_Config } from "../A-Config.namespace";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Config Reader
|
|
8
|
+
*/
|
|
9
|
+
export class ConfigReader extends A_Component<A_Config> {
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Get the configuration property by Name
|
|
14
|
+
* @param property
|
|
15
|
+
*/
|
|
16
|
+
resolve<_ReturnType = any>(property: string): _ReturnType {
|
|
17
|
+
return property as _ReturnType;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* This method reads the configuration and sets the values to the context
|
|
22
|
+
*
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
async read<T extends string>(
|
|
26
|
+
variables: Array<T> = []
|
|
27
|
+
): Promise<Record<T, any>> {
|
|
28
|
+
return {} as Record<T, any>;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { A_CommonHelper } from "@adaas/a-utils";
|
|
2
|
+
import { ConfigReader } from "./ConfigReader.component";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class ENVConfigReader extends ConfigReader {
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get the configuration property Name
|
|
10
|
+
* @param property
|
|
11
|
+
*/
|
|
12
|
+
getConfigurationProperty_ENV_Alias(property: string): string {
|
|
13
|
+
return `${A_CommonHelper.toUpperSnakeCase(this.namespace.name)}_${A_CommonHelper.toUpperSnakeCase(property)}`;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
resolve<_ReturnType = any>(property: string): _ReturnType {
|
|
18
|
+
return process.env[this.getConfigurationProperty_ENV_Alias(property)] as _ReturnType;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
async read<T extends string>(variables: Array<T> = []): Promise<Record<T, any>> {
|
|
23
|
+
const config: Record<T, any> = {} as Record<T, any>;
|
|
24
|
+
|
|
25
|
+
variables.forEach(variable => {
|
|
26
|
+
config[variable] = this.resolve(variable);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return config;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { A_CommonHelper, A_Polyfills } from "@adaas/a-utils";
|
|
2
|
+
import { ConfigReader } from "./ConfigReader.component";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export class FileConfigReader extends ConfigReader {
|
|
7
|
+
|
|
8
|
+
private FileData: Map<string, any> = new Map<string, any>();
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Get the configuration property Name
|
|
12
|
+
* @param property
|
|
13
|
+
*/
|
|
14
|
+
getConfigurationProperty_File_Alias(property: string): string {
|
|
15
|
+
return A_CommonHelper.toCamelCase(property);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
resolve<_ReturnType = any>(property: string): _ReturnType {
|
|
20
|
+
return this.FileData.get(this.getConfigurationProperty_File_Alias(property)) as _ReturnType;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
async read<T extends string>(
|
|
25
|
+
variables?: Array<T>
|
|
26
|
+
): Promise<Record<T, any>> {
|
|
27
|
+
const fs = await A_Polyfills.fs();
|
|
28
|
+
try {
|
|
29
|
+
const data = fs.readFileSync(`${this.namespace.name}.conf.json`, 'utf8');
|
|
30
|
+
|
|
31
|
+
const config: Record<T, any> = JSON.parse(data);
|
|
32
|
+
|
|
33
|
+
this.FileData = new Map(Object.entries(config));
|
|
34
|
+
|
|
35
|
+
return config;
|
|
36
|
+
|
|
37
|
+
} catch (error) {
|
|
38
|
+
// this.context.Logger.error(error);
|
|
39
|
+
return {} as Record<T, any>;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
2
|
+
import { A_Errors } from "./A-Errors.namespace";
|
|
3
|
+
import { A_Load } from "@adaas/a-concept/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator";
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export class A_ErrorsInitializer extends A_Container<A_Errors> {
|
|
8
|
+
|
|
9
|
+
@A_Load({})
|
|
10
|
+
async init() {
|
|
11
|
+
await this.namespace.ready;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { A_Namespace } from "@adaas/a-concept/global/A-Namespace/A_Namespace.class";
|
|
2
|
+
import { A_CONSTANTS__ERROR_CODES, A_Error, A_ServerError, A_TYPES__Dictionary, A_TYPES__Error, A_TYPES__ServerError } from "@adaas/a-utils";
|
|
3
|
+
import { A_TYPES__A_ErrorsConstructor } from "./A-Errors.types";
|
|
4
|
+
import { A_CONSTANTS__DEFAULT_ERRORS } from "@adaas/a-utils/dist/src/constants/errors.constants";
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
export class A_Errors extends A_Namespace<Partial<A_TYPES__A_ErrorsConstructor>> {
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
protected registeredErrors: Map<string, A_TYPES__Error | A_TYPES__ServerError> = new Map();
|
|
12
|
+
|
|
13
|
+
constructor(
|
|
14
|
+
params: Partial<A_TYPES__A_ErrorsConstructor>
|
|
15
|
+
) {
|
|
16
|
+
super(params);
|
|
17
|
+
|
|
18
|
+
if (params.errors) {
|
|
19
|
+
this.addRegistry(params.errors);
|
|
20
|
+
}
|
|
21
|
+
this.addRegistry(A_CONSTANTS__DEFAULT_ERRORS);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* This method adds a dictionary of errors to the registry.
|
|
27
|
+
*
|
|
28
|
+
* @param registry
|
|
29
|
+
*/
|
|
30
|
+
addRegistry(
|
|
31
|
+
registry: A_TYPES__Dictionary<A_TYPES__Error> | A_TYPES__Error[]
|
|
32
|
+
): A_Errors {
|
|
33
|
+
const errors = Array.isArray(registry) ? registry : Object.values(registry);
|
|
34
|
+
|
|
35
|
+
errors.forEach(err => this.registerError(err));
|
|
36
|
+
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
*
|
|
43
|
+
* Adds an error to the registry
|
|
44
|
+
*
|
|
45
|
+
* @param error
|
|
46
|
+
*/
|
|
47
|
+
registerError(error: A_TYPES__Error): A_Errors {
|
|
48
|
+
this.registeredErrors.set(error.code, {
|
|
49
|
+
...error,
|
|
50
|
+
code: `${this.name}@error:${error.code}`
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return this;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* This method returns an error object by its code.
|
|
58
|
+
*
|
|
59
|
+
* @param code
|
|
60
|
+
* @returns
|
|
61
|
+
*/
|
|
62
|
+
getError(code: A_CONSTANTS__ERROR_CODES | string): A_ServerError | A_Error | undefined {
|
|
63
|
+
let template = this.registeredErrors.get(code);
|
|
64
|
+
|
|
65
|
+
if (!template)
|
|
66
|
+
template = this.registeredErrors.get(A_CONSTANTS__ERROR_CODES.UNEXPECTED_ERROR);
|
|
67
|
+
|
|
68
|
+
if ((template as A_TYPES__ServerError).serverCode) {
|
|
69
|
+
return new A_ServerError(template as A_TYPES__ServerError);
|
|
70
|
+
} else {
|
|
71
|
+
return new A_Error(template);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* This method throws an error by its code.
|
|
78
|
+
*
|
|
79
|
+
* @param code
|
|
80
|
+
*/
|
|
81
|
+
throw(code: A_CONSTANTS__ERROR_CODES | string): never {
|
|
82
|
+
|
|
83
|
+
const err = this.getError(code);
|
|
84
|
+
|
|
85
|
+
throw err;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* This method wraps an error into the SDK error object.
|
|
91
|
+
*
|
|
92
|
+
* @param error
|
|
93
|
+
* @returns
|
|
94
|
+
*/
|
|
95
|
+
wrap(error: Error | A_Error | unknown): A_ServerError | A_Error {
|
|
96
|
+
if (error instanceof A_Error) {
|
|
97
|
+
return new A_ServerError(error);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return new A_Error(error);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { A_TYPES__NamespaceConstructor } from "@adaas/a-concept/global/A-Namespace/A_Namespace.types"
|
|
2
|
+
import { A_TYPES__Dictionary, A_TYPES__Error } from "@adaas/a-utils"
|
|
3
|
+
|
|
4
|
+
export type A_TYPES__A_ErrorsConstructor = {
|
|
5
|
+
errors: A_TYPES__Dictionary<A_TYPES__Error> | A_TYPES__Error[]
|
|
6
|
+
} & A_TYPES__NamespaceConstructor
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { A_Container } from "@adaas/a-concept/global/A-Container/A-Container.class";
|
|
2
|
+
import { A_Load } from "@adaas/a-concept/decorators/A-ConceptLifecycle/A-Load/A-Load.decorator";
|
|
3
|
+
import { Logger } from "./components/Logger.component";
|
|
4
|
+
import { A_LoggerContext } from "./A-Logger.namespace";
|
|
5
|
+
import { A_Inject } from "@adaas/a-concept/decorators/A-Inject/A-Inject.decorator";
|
|
6
|
+
import { A_Context } from "@adaas/a-concept/global/A-Context/A-Context.class";
|
|
7
|
+
import { A_Config } from "../A-Config/A-Config.namespace";
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export class A_Logger extends A_Container<A_LoggerContext> {
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
@A_Load({})
|
|
15
|
+
async init(
|
|
16
|
+
@A_Inject(A_Config) config: A_Config
|
|
17
|
+
) {
|
|
18
|
+
await this.namespace.ready;
|
|
19
|
+
|
|
20
|
+
this.namespace.Logger = A_Context.resolve(Logger);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { A_Namespace } from "@adaas/a-concept/global/A-Namespace/A_Namespace.class";
|
|
2
|
+
import { Logger } from "./components/Logger.component";
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
export class A_LoggerContext extends A_Namespace {
|
|
6
|
+
|
|
7
|
+
Logger!: Logger
|
|
8
|
+
|
|
9
|
+
readonly colors = {
|
|
10
|
+
green: '32',
|
|
11
|
+
blue: '34',
|
|
12
|
+
red: '31',
|
|
13
|
+
yellow: '33',
|
|
14
|
+
gray: '90',
|
|
15
|
+
magenta: '35',
|
|
16
|
+
cyan: '36',
|
|
17
|
+
white: '37',
|
|
18
|
+
pink: '95',
|
|
19
|
+
} as const
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
}
|
|
File without changes
|