@zanobijs/core 1.0.0-beta.1
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/CHANGELOG.md +8 -0
- package/LICENSE +33 -0
- package/README.md +11 -0
- package/__test__/factory.spec.d.ts +1 -0
- package/__test__/factory.spec.js +33 -0
- package/__test__/factory.spec.ts +37 -0
- package/__test__/injector/injector.spec.d.ts +1 -0
- package/__test__/injector/injector.spec.js +32 -0
- package/__test__/injector/injector.spec.ts +32 -0
- package/__test__/injector/module.spec.d.ts +1 -0
- package/__test__/injector/module.spec.js +60 -0
- package/__test__/injector/module.spec.ts +66 -0
- package/__test__/metadata.spec.d.ts +1 -0
- package/__test__/metadata.spec.js +70 -0
- package/__test__/metadata.spec.ts +71 -0
- package/__test__/mocks/classModule.mock.d.ts +10 -0
- package/__test__/mocks/classModule.mock.js +74 -0
- package/__test__/mocks/classModule.mock.ts +55 -0
- package/__test__/mocks/classWithDependeciesClass.mock.d.ts +13 -0
- package/__test__/mocks/classWithDependeciesClass.mock.js +40 -0
- package/__test__/mocks/classWithDependeciesClass.mock.ts +21 -0
- package/__test__/mocks/classWithDependeciesInject.mock.d.ts +24 -0
- package/__test__/mocks/classWithDependeciesInject.mock.js +74 -0
- package/__test__/mocks/classWithDependeciesInject.mock.ts +47 -0
- package/__test__/mocks/index.d.ts +1 -0
- package/__test__/mocks/index.js +4 -0
- package/__test__/mocks/index.ts +1 -0
- package/exceptions/constant.message.d.ts +1 -0
- package/exceptions/constant.message.js +5 -0
- package/exceptions/constant.message.ts +1 -0
- package/exceptions/index.d.ts +2 -0
- package/exceptions/index.js +5 -0
- package/exceptions/index.ts +2 -0
- package/exceptions/invalid.module.exception.d.ts +12 -0
- package/exceptions/invalid.module.exception.js +19 -0
- package/exceptions/invalid.module.exception.ts +16 -0
- package/factory.d.ts +37 -0
- package/factory.js +64 -0
- package/factory.ts +69 -0
- package/index.d.ts +2 -0
- package/index.js +7 -0
- package/index.ts +2 -0
- package/injector/index.d.ts +2 -0
- package/injector/index.js +5 -0
- package/injector/index.ts +2 -0
- package/injector/injector.d.ts +60 -0
- package/injector/injector.js +83 -0
- package/injector/injector.ts +89 -0
- package/injector/module.d.ts +76 -0
- package/injector/module.js +135 -0
- package/injector/module.ts +149 -0
- package/interface/index.d.ts +0 -0
- package/interface/index.js +1 -0
- package/interface/index.ts +1 -0
- package/metadata.d.ts +106 -0
- package/metadata.js +155 -0
- package/metadata.ts +178 -0
- package/package.json +34 -0
- package/tsconfig.build.json +17 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +11 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [1.0.0-beta.1](https://github.com/devdroide/ZanobiJS/compare/v1.0.0-beta.0...v1.0.0-beta.1) (2023-11-08)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @zanobijs/core
|
package/LICENSE
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Licencia de Uso para ZanobiJS
|
|
2
|
+
|
|
3
|
+
AVISO: El código fuente contenido o descrito en este documento y todos los documentos relacioandos
|
|
4
|
+
con el código fuente ("Material") son propiedad de John Edison Cortes Rivera [Devdroide].
|
|
5
|
+
|
|
6
|
+
1. La difusión de esta información o reproducción de este material está estrictamente prohibido
|
|
7
|
+
a menos que se obtenga un permiso previo por escrito de John Edison Cortes Rivera [Devdroide].
|
|
8
|
+
|
|
9
|
+
2. Se concede el permiso para usar este software en proyectos personales o comerciales sin costo
|
|
10
|
+
|
|
11
|
+
3. Queda prohibida la copia, modificación o redistribución de este software en cualquier forma.
|
|
12
|
+
|
|
13
|
+
4. John Edison Cortes Rivera [Devdroide] no se hace responsable de cualquier daño o pérdida derivados del uso de este software.
|
|
14
|
+
|
|
15
|
+
©2023 John Edison Cortes Rivera [Devdroide]. Todos los derechos reservados.
|
|
16
|
+
|
|
17
|
+
********************************************************************************************************************************
|
|
18
|
+
|
|
19
|
+
ZanobiJS Usage License
|
|
20
|
+
|
|
21
|
+
NOTICE: The source code contained or described in this document and all related documents
|
|
22
|
+
("Material") are the property of John Edison Cortes Rivera [Devdroide].
|
|
23
|
+
|
|
24
|
+
1. Dissemination of this information or reproduction of this material is strictly prohibited
|
|
25
|
+
unless prior written permission is obtained from John Edison Cortes Rivera [Devdroide].
|
|
26
|
+
|
|
27
|
+
2. Permission is granted to use this software in personal or commercial projects free of charge.
|
|
28
|
+
|
|
29
|
+
3. Copying, modifying, or redistributing this software in any form is prohibited.
|
|
30
|
+
|
|
31
|
+
4. John Edison Cortes Rivera [Devdroide] is not liable for any damage or loss arising from the use of this software.
|
|
32
|
+
|
|
33
|
+
©2023 John Edison Cortes Rivera [Devdroide]. All rights reserved.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
// import { Module } from "zanobijs-common";
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
const classModule_mock_1 = require("./mocks/classModule.mock");
|
|
7
|
+
describe("Core - factory", () => {
|
|
8
|
+
const factory = new index_1.Factory(classModule_mock_1.ModuleTestAll);
|
|
9
|
+
describe("Create Factory App", () => {
|
|
10
|
+
it("should respond error to create factory by error @Module", () => {
|
|
11
|
+
class ModuleWithoutDecorator {
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
const factoryError = new index_1.Factory(ModuleWithoutDecorator);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
(0, chai_1.expect)(error.message).to.be.equal("The class must have an annotation @Module()");
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
it("should respond create factory", () => {
|
|
21
|
+
const app = factory.create();
|
|
22
|
+
(0, chai_1.expect)(app).to.be.instanceOf(index_1.Factory);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe("Get Entities", () => {
|
|
26
|
+
it("should respond apiKey to controller the app", () => {
|
|
27
|
+
const app = factory.create();
|
|
28
|
+
const controllerWithDepen2 = app.get("controllerWithDepen2");
|
|
29
|
+
(0, chai_1.expect)(controllerWithDepen2.getApiKey()).to.be.equal("isApiKey_qwerty12345");
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
// it("", () => {});
|
|
33
|
+
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
// import { Module } from "zanobijs-common";
|
|
3
|
+
import { Factory } from "../index";
|
|
4
|
+
import { ModuleTestAll } from "./mocks/classModule.mock";
|
|
5
|
+
import { ControllerWithDepen2 } from "./mocks/classWithDependeciesInject.mock";
|
|
6
|
+
|
|
7
|
+
describe("Core - factory", () => {
|
|
8
|
+
const factory = new Factory(ModuleTestAll);
|
|
9
|
+
describe("Create Factory App", () => {
|
|
10
|
+
it("should respond error to create factory by error @Module", () => {
|
|
11
|
+
class ModuleWithoutDecorator {}
|
|
12
|
+
try {
|
|
13
|
+
const factoryError = new Factory(ModuleWithoutDecorator);
|
|
14
|
+
} catch (error) {
|
|
15
|
+
expect(error.message).to.be.equal(
|
|
16
|
+
"The class must have an annotation @Module()",
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
it("should respond create factory", () => {
|
|
21
|
+
const app = factory.create();
|
|
22
|
+
expect(app).to.be.instanceOf(Factory);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe("Get Entities", () => {
|
|
26
|
+
it("should respond apiKey to controller the app", () => {
|
|
27
|
+
const app = factory.create();
|
|
28
|
+
const controllerWithDepen2 = app.get<ControllerWithDepen2>(
|
|
29
|
+
"controllerWithDepen2",
|
|
30
|
+
);
|
|
31
|
+
expect(controllerWithDepen2.getApiKey()).to.be.equal(
|
|
32
|
+
"isApiKey_qwerty12345",
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
// it("", () => {});
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const injector_1 = require("../../injector");
|
|
5
|
+
const classModule_mock_1 = require("../mocks/classModule.mock");
|
|
6
|
+
const classWithDependeciesInject_mock_1 = require("../mocks/classWithDependeciesInject.mock");
|
|
7
|
+
const classWithDependeciesClass_mock_1 = require("../mocks/classWithDependeciesClass.mock");
|
|
8
|
+
describe("Core - Injector - injector", () => {
|
|
9
|
+
const injector = new injector_1.Injector(classModule_mock_1.ModuleTestWithInjector);
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
process.env.ZANOBI_DEBUG = "false";
|
|
12
|
+
});
|
|
13
|
+
it("Should respond an object with paramters to inject", () => {
|
|
14
|
+
const getInjectData = injector.getInjectData(classWithDependeciesClass_mock_1.ControllerWithDepenClass);
|
|
15
|
+
(0, chai_1.expect)(getInjectData).to.is.empty;
|
|
16
|
+
});
|
|
17
|
+
it("Should respond an object without paramters to inject", () => {
|
|
18
|
+
const getInjectData = injector.getInjectData(classWithDependeciesInject_mock_1.ControllerWithDepen2);
|
|
19
|
+
(0, chai_1.expect)(getInjectData).to.have.property("apiKey");
|
|
20
|
+
});
|
|
21
|
+
it("Should respond an object type asClass with paramters to inject", () => {
|
|
22
|
+
const getInject = injector.getInjector(classWithDependeciesInject_mock_1.ControllerWithDepen2);
|
|
23
|
+
(0, chai_1.expect)(getInject).to.have.property("lifetime");
|
|
24
|
+
(0, chai_1.expect)(getInject).to.have.property("inject");
|
|
25
|
+
(0, chai_1.expect)(getInject).to.have.property("injector");
|
|
26
|
+
});
|
|
27
|
+
it("Should respond an object type asClass without injector", () => {
|
|
28
|
+
const getInject = injector.getInjector(classWithDependeciesClass_mock_1.ControllerWithDepenClass);
|
|
29
|
+
(0, chai_1.expect)(getInject).to.not.have.property("injector");
|
|
30
|
+
});
|
|
31
|
+
// it("", () => {});
|
|
32
|
+
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { Injector } from "../../injector";
|
|
3
|
+
import { ModuleTestWithInjector } from "../mocks/classModule.mock";
|
|
4
|
+
import { ControllerWithDepen2 } from "../mocks/classWithDependeciesInject.mock";
|
|
5
|
+
import { ControllerWithDepenClass } from "../mocks/classWithDependeciesClass.mock";
|
|
6
|
+
|
|
7
|
+
describe("Core - Injector - injector", () => {
|
|
8
|
+
const injector = new Injector(ModuleTestWithInjector);
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
process.env.ZANOBI_DEBUG = "false";
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("Should respond an object with paramters to inject", () => {
|
|
14
|
+
const getInjectData = injector.getInjectData(ControllerWithDepenClass);
|
|
15
|
+
expect(getInjectData).to.is.empty;
|
|
16
|
+
});
|
|
17
|
+
it("Should respond an object without paramters to inject", () => {
|
|
18
|
+
const getInjectData = injector.getInjectData(ControllerWithDepen2);
|
|
19
|
+
expect(getInjectData).to.have.property("apiKey");
|
|
20
|
+
});
|
|
21
|
+
it("Should respond an object type asClass with paramters to inject", () => {
|
|
22
|
+
const getInject = injector.getInjector(ControllerWithDepen2);
|
|
23
|
+
expect(getInject).to.have.property("lifetime");
|
|
24
|
+
expect(getInject).to.have.property("inject");
|
|
25
|
+
expect(getInject).to.have.property("injector");
|
|
26
|
+
});
|
|
27
|
+
it("Should respond an object type asClass without injector", () => {
|
|
28
|
+
const getInject = injector.getInjector(ControllerWithDepenClass);
|
|
29
|
+
expect(getInject).to.not.have.property("injector");
|
|
30
|
+
});
|
|
31
|
+
// it("", () => {});
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
require("reflect-metadata");
|
|
4
|
+
const chai_1 = require("chai");
|
|
5
|
+
const injector_1 = require("../../injector");
|
|
6
|
+
const classModule_mock_1 = require("../mocks/classModule.mock");
|
|
7
|
+
describe("Core - Injector - module", () => {
|
|
8
|
+
let moduleInstance;
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
moduleInstance = new injector_1.Module();
|
|
11
|
+
});
|
|
12
|
+
describe("setup", () => {
|
|
13
|
+
it("should respond that setup no is a module", () => {
|
|
14
|
+
try {
|
|
15
|
+
const mockModule = {};
|
|
16
|
+
moduleInstance.setup(mockModule);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
(0, chai_1.expect)(error.message).to.equal("The class must have an annotation @Module()");
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
it("should respond no problem with the setup.", () => {
|
|
23
|
+
moduleInstance.setup(classModule_mock_1.ModuleTestWithInjector);
|
|
24
|
+
(0, chai_1.expect)(moduleInstance.getRegisterClass()).to.is.empty;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe("Module initialize", () => {
|
|
28
|
+
it("should respond that call getMetadataModule and register on Module", () => {
|
|
29
|
+
let metadataCalled = false;
|
|
30
|
+
let registerDependencies = false;
|
|
31
|
+
let registerDependenciesToAlias = false;
|
|
32
|
+
moduleInstance["getMetadataModule"] = () => {
|
|
33
|
+
metadataCalled = true;
|
|
34
|
+
};
|
|
35
|
+
moduleInstance["registerDependencies"] = () => {
|
|
36
|
+
registerDependencies = true;
|
|
37
|
+
};
|
|
38
|
+
moduleInstance["registerDependenciesToAlias"] = () => {
|
|
39
|
+
registerDependenciesToAlias = true;
|
|
40
|
+
};
|
|
41
|
+
moduleInstance.initialize();
|
|
42
|
+
(0, chai_1.expect)(metadataCalled).to.be.true;
|
|
43
|
+
(0, chai_1.expect)(registerDependencies).to.be.true;
|
|
44
|
+
(0, chai_1.expect)(registerDependenciesToAlias).to.be.true;
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("Module get information", () => {
|
|
48
|
+
it("Should respond apiKey and sContro2 in registered providers", () => {
|
|
49
|
+
moduleInstance.setup(classModule_mock_1.ModuleTestWithInjector);
|
|
50
|
+
moduleInstance.initialize();
|
|
51
|
+
(0, chai_1.expect)(moduleInstance.getRegisterClass()).to.have.property("sContro2");
|
|
52
|
+
(0, chai_1.expect)(moduleInstance.getRegisterClass()).to.have.property("apiKey");
|
|
53
|
+
});
|
|
54
|
+
it("Should respond imports of module", () => {
|
|
55
|
+
moduleInstance.setup(classModule_mock_1.ModuleTestWithImports);
|
|
56
|
+
moduleInstance.initialize();
|
|
57
|
+
(0, chai_1.expect)(moduleInstance.getImports()).to.not.empty;
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import "reflect-metadata";
|
|
2
|
+
import { expect } from "chai";
|
|
3
|
+
import { Module } from "../../injector";
|
|
4
|
+
import { ModuleTestWithImports, ModuleTestWithInjector } from "../mocks/classModule.mock";
|
|
5
|
+
|
|
6
|
+
describe("Core - Injector - module", () => {
|
|
7
|
+
let moduleInstance: Module;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
moduleInstance = new Module();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
describe("setup", () => {
|
|
14
|
+
it("should respond that setup no is a module", () => {
|
|
15
|
+
try {
|
|
16
|
+
const mockModule = {};
|
|
17
|
+
moduleInstance.setup(mockModule);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
expect(error.message).to.equal(
|
|
20
|
+
"The class must have an annotation @Module()",
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
it("should respond no problem with the setup.", () => {
|
|
25
|
+
moduleInstance.setup(ModuleTestWithInjector);
|
|
26
|
+
expect(moduleInstance.getRegisterClass()).to.is.empty;
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe("Module initialize", () => {
|
|
31
|
+
it("should respond that call getMetadataModule and register on Module", () => {
|
|
32
|
+
let metadataCalled = false;
|
|
33
|
+
let registerDependencies = false;
|
|
34
|
+
let registerDependenciesToAlias = false;
|
|
35
|
+
|
|
36
|
+
moduleInstance["getMetadataModule"] = () => {
|
|
37
|
+
metadataCalled = true;
|
|
38
|
+
};
|
|
39
|
+
moduleInstance["registerDependencies"] = () => {
|
|
40
|
+
registerDependencies = true;
|
|
41
|
+
};
|
|
42
|
+
moduleInstance["registerDependenciesToAlias"] = () => {
|
|
43
|
+
registerDependenciesToAlias = true;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
moduleInstance.initialize();
|
|
47
|
+
|
|
48
|
+
expect(metadataCalled).to.be.true;
|
|
49
|
+
expect(registerDependencies).to.be.true;
|
|
50
|
+
expect(registerDependenciesToAlias).to.be.true;
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
describe("Module get information", () => {
|
|
54
|
+
it("Should respond apiKey and sContro2 in registered providers", () => {
|
|
55
|
+
moduleInstance.setup(ModuleTestWithInjector);
|
|
56
|
+
moduleInstance.initialize();
|
|
57
|
+
expect(moduleInstance.getRegisterClass()).to.have.property("sContro2");
|
|
58
|
+
expect(moduleInstance.getRegisterClass()).to.have.property("apiKey");
|
|
59
|
+
});
|
|
60
|
+
it("Should respond imports of module", () => {
|
|
61
|
+
moduleInstance.setup(ModuleTestWithImports);
|
|
62
|
+
moduleInstance.initialize();
|
|
63
|
+
expect(moduleInstance.getImports()).to.not.empty
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const metadata_1 = require("../metadata");
|
|
5
|
+
const classModule_mock_1 = require("./mocks/classModule.mock");
|
|
6
|
+
const classWithDependeciesInject_mock_1 = require("./mocks/classWithDependeciesInject.mock");
|
|
7
|
+
const classWithDependeciesClass_mock_1 = require("./mocks/classWithDependeciesClass.mock");
|
|
8
|
+
describe("Core - metadata", () => {
|
|
9
|
+
class genericClassForTesting {
|
|
10
|
+
}
|
|
11
|
+
const metadata = metadata_1.Metadata.getInstance();
|
|
12
|
+
describe("Is Type", () => {
|
|
13
|
+
it("should respond false to is module", () => {
|
|
14
|
+
(0, chai_1.expect)(metadata.isTypeModule(genericClassForTesting)).to.be.false;
|
|
15
|
+
});
|
|
16
|
+
it("should respond false to is imports", () => {
|
|
17
|
+
(0, chai_1.expect)(metadata.isTypeImport(genericClassForTesting)).to.be.false;
|
|
18
|
+
});
|
|
19
|
+
it("should respond false to is controllers", () => {
|
|
20
|
+
(0, chai_1.expect)(metadata.isTypeController(genericClassForTesting)).to.be.false;
|
|
21
|
+
});
|
|
22
|
+
it("should respond false to is services", () => {
|
|
23
|
+
(0, chai_1.expect)(metadata.isTypeService(genericClassForTesting)).to.be.false;
|
|
24
|
+
});
|
|
25
|
+
it("should respond false to is exports", () => {
|
|
26
|
+
(0, chai_1.expect)(metadata.isTypeExports(genericClassForTesting)).to.be.false;
|
|
27
|
+
});
|
|
28
|
+
it("should respond true to is module", () => {
|
|
29
|
+
(0, chai_1.expect)(metadata.isTypeModule(classModule_mock_1.ModuleTestEmpty)).to.be.true;
|
|
30
|
+
});
|
|
31
|
+
it("should respond determine type of service", () => {
|
|
32
|
+
(0, chai_1.expect)(metadata.determineType(classWithDependeciesInject_mock_1.ServiceWithDepenParam)).to.be.equal("service");
|
|
33
|
+
});
|
|
34
|
+
it("should respond determine type of unknown", () => {
|
|
35
|
+
class ServiceTest {
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
metadata.determineType(ServiceTest);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
(0, chai_1.expect)(error.message).to.be.equal("ServiceTest type is unknown");
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
describe("Get Metadata", () => {
|
|
46
|
+
it("Should respond the metadata of the decorator module", () => {
|
|
47
|
+
const metadata2 = metadata_1.Metadata.getInstance();
|
|
48
|
+
const resultMetadata = metadata2.getMetadataModule(classModule_mock_1.ModuleTest);
|
|
49
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("imports");
|
|
50
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("controllers");
|
|
51
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("services");
|
|
52
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("exports");
|
|
53
|
+
});
|
|
54
|
+
it("should respond the dependency metadata of a controller", () => {
|
|
55
|
+
const resultMetadata = metadata.getAllDependencies(classWithDependeciesClass_mock_1.ControllerWithDepenClass);
|
|
56
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("dClass");
|
|
57
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("dParam");
|
|
58
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("dInject");
|
|
59
|
+
(0, chai_1.expect)(resultMetadata.dInject).to.be.empty;
|
|
60
|
+
});
|
|
61
|
+
it("should respond the dependency metadata of a service", () => {
|
|
62
|
+
const resultMetadata = metadata.getAllDependencies(classWithDependeciesInject_mock_1.ServiceWithDepenParam);
|
|
63
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("dClass");
|
|
64
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("dParam");
|
|
65
|
+
(0, chai_1.expect)(resultMetadata).to.have.property("dInject");
|
|
66
|
+
(0, chai_1.expect)(resultMetadata.dInject).to.not.be.empty;
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
describe("", () => { });
|
|
70
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { Metadata } from "../metadata";
|
|
3
|
+
import { ModuleTestEmpty, ModuleTest } from "./mocks/classModule.mock";
|
|
4
|
+
import { ServiceWithDepenParam } from "./mocks/classWithDependeciesInject.mock";
|
|
5
|
+
import { ControllerWithDepenClass } from "./mocks/classWithDependeciesClass.mock";
|
|
6
|
+
|
|
7
|
+
describe("Core - metadata", () => {
|
|
8
|
+
class genericClassForTesting {}
|
|
9
|
+
const metadata = Metadata.getInstance();
|
|
10
|
+
|
|
11
|
+
describe("Is Type", () => {
|
|
12
|
+
it("should respond false to is module", () => {
|
|
13
|
+
expect(metadata.isTypeModule(genericClassForTesting)).to.be.false;
|
|
14
|
+
});
|
|
15
|
+
it("should respond false to is imports", () => {
|
|
16
|
+
expect(metadata.isTypeImport(genericClassForTesting)).to.be.false;
|
|
17
|
+
});
|
|
18
|
+
it("should respond false to is controllers", () => {
|
|
19
|
+
expect(metadata.isTypeController(genericClassForTesting)).to.be.false;
|
|
20
|
+
});
|
|
21
|
+
it("should respond false to is services", () => {
|
|
22
|
+
expect(metadata.isTypeService(genericClassForTesting)).to.be.false;
|
|
23
|
+
});
|
|
24
|
+
it("should respond false to is exports", () => {
|
|
25
|
+
expect(metadata.isTypeExports(genericClassForTesting)).to.be.false;
|
|
26
|
+
});
|
|
27
|
+
it("should respond true to is module", () => {
|
|
28
|
+
expect(metadata.isTypeModule(ModuleTestEmpty)).to.be.true;
|
|
29
|
+
});
|
|
30
|
+
it("should respond determine type of service", () => {
|
|
31
|
+
expect(metadata.determineType(ServiceWithDepenParam)).to.be.equal(
|
|
32
|
+
"service",
|
|
33
|
+
);
|
|
34
|
+
});
|
|
35
|
+
it("should respond determine type of unknown", () => {
|
|
36
|
+
class ServiceTest {}
|
|
37
|
+
try {
|
|
38
|
+
metadata.determineType(ServiceTest);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
expect(error.message).to.be.equal("ServiceTest type is unknown");
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
describe("Get Metadata", () => {
|
|
45
|
+
it("Should respond the metadata of the decorator module", () => {
|
|
46
|
+
const metadata2 = Metadata.getInstance();
|
|
47
|
+
const resultMetadata = metadata2.getMetadataModule(ModuleTest);
|
|
48
|
+
expect(resultMetadata).to.have.property("imports");
|
|
49
|
+
expect(resultMetadata).to.have.property("controllers");
|
|
50
|
+
expect(resultMetadata).to.have.property("services");
|
|
51
|
+
expect(resultMetadata).to.have.property("exports");
|
|
52
|
+
});
|
|
53
|
+
it("should respond the dependency metadata of a controller", () => {
|
|
54
|
+
const resultMetadata = metadata.getAllDependencies(
|
|
55
|
+
ControllerWithDepenClass,
|
|
56
|
+
);
|
|
57
|
+
expect(resultMetadata).to.have.property("dClass");
|
|
58
|
+
expect(resultMetadata).to.have.property("dParam");
|
|
59
|
+
expect(resultMetadata).to.have.property("dInject");
|
|
60
|
+
expect(resultMetadata.dInject).to.be.empty;
|
|
61
|
+
});
|
|
62
|
+
it("should respond the dependency metadata of a service", () => {
|
|
63
|
+
const resultMetadata = metadata.getAllDependencies(ServiceWithDepenParam);
|
|
64
|
+
expect(resultMetadata).to.have.property("dClass");
|
|
65
|
+
expect(resultMetadata).to.have.property("dParam");
|
|
66
|
+
expect(resultMetadata).to.have.property("dInject");
|
|
67
|
+
expect(resultMetadata.dInject).to.not.be.empty;
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
describe("", () => {});
|
|
71
|
+
});
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModuleTestAll = exports.ModuleTestWithImports = exports.ModuleTestWithInjector = exports.ModuleTest = exports.ModuleTestEmpty = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const zanobijs_common_1 = require("zanobijs-common");
|
|
6
|
+
const classWithDependeciesClass_mock_1 = require("./classWithDependeciesClass.mock");
|
|
7
|
+
const classWithDependeciesInject_mock_1 = require("./classWithDependeciesInject.mock");
|
|
8
|
+
let ModuleTestEmpty = class ModuleTestEmpty {
|
|
9
|
+
};
|
|
10
|
+
exports.ModuleTestEmpty = ModuleTestEmpty;
|
|
11
|
+
exports.ModuleTestEmpty = ModuleTestEmpty = tslib_1.__decorate([
|
|
12
|
+
(0, zanobijs_common_1.Module)({
|
|
13
|
+
imports: [],
|
|
14
|
+
controllers: [],
|
|
15
|
+
services: [],
|
|
16
|
+
exports: [],
|
|
17
|
+
})
|
|
18
|
+
], ModuleTestEmpty);
|
|
19
|
+
let ModuleTest = class ModuleTest {
|
|
20
|
+
};
|
|
21
|
+
exports.ModuleTest = ModuleTest;
|
|
22
|
+
exports.ModuleTest = ModuleTest = tslib_1.__decorate([
|
|
23
|
+
(0, zanobijs_common_1.Module)({
|
|
24
|
+
imports: [],
|
|
25
|
+
controllers: [classWithDependeciesClass_mock_1.ControllerWithDepenClass],
|
|
26
|
+
services: [classWithDependeciesClass_mock_1.ServiceToController],
|
|
27
|
+
exports: [],
|
|
28
|
+
})
|
|
29
|
+
], ModuleTest);
|
|
30
|
+
let ModuleTestWithInjector = class ModuleTestWithInjector {
|
|
31
|
+
};
|
|
32
|
+
exports.ModuleTestWithInjector = ModuleTestWithInjector;
|
|
33
|
+
exports.ModuleTestWithInjector = ModuleTestWithInjector = tslib_1.__decorate([
|
|
34
|
+
(0, zanobijs_common_1.Module)({
|
|
35
|
+
imports: [],
|
|
36
|
+
controllers: [classWithDependeciesInject_mock_1.ControllerWithDepen2],
|
|
37
|
+
services: [
|
|
38
|
+
classWithDependeciesInject_mock_1.ServiceToController2,
|
|
39
|
+
{
|
|
40
|
+
provider: "API_KEY",
|
|
41
|
+
useValue: "isApiKey_qwerty12345"
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
exports: [],
|
|
45
|
+
})
|
|
46
|
+
], ModuleTestWithInjector);
|
|
47
|
+
let ModuleTestWithImports = class ModuleTestWithImports {
|
|
48
|
+
};
|
|
49
|
+
exports.ModuleTestWithImports = ModuleTestWithImports;
|
|
50
|
+
exports.ModuleTestWithImports = ModuleTestWithImports = tslib_1.__decorate([
|
|
51
|
+
(0, zanobijs_common_1.Module)({
|
|
52
|
+
imports: [ModuleTestWithInjector],
|
|
53
|
+
controllers: [],
|
|
54
|
+
services: [],
|
|
55
|
+
exports: [],
|
|
56
|
+
})
|
|
57
|
+
], ModuleTestWithImports);
|
|
58
|
+
let ModuleTestAll = class ModuleTestAll {
|
|
59
|
+
};
|
|
60
|
+
exports.ModuleTestAll = ModuleTestAll;
|
|
61
|
+
exports.ModuleTestAll = ModuleTestAll = tslib_1.__decorate([
|
|
62
|
+
(0, zanobijs_common_1.Module)({
|
|
63
|
+
imports: [ModuleTestWithInjector],
|
|
64
|
+
controllers: [classWithDependeciesInject_mock_1.ControllerWithDepen2],
|
|
65
|
+
services: [
|
|
66
|
+
classWithDependeciesInject_mock_1.ServiceToController2,
|
|
67
|
+
{
|
|
68
|
+
provider: "API_SECRET",
|
|
69
|
+
useValue: "isApiSecret_cvbdfgert"
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
exports: [],
|
|
73
|
+
})
|
|
74
|
+
], ModuleTestAll);
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Module } from "zanobijs-common";
|
|
2
|
+
import { ControllerWithDepenClass, ServiceToController } from "./classWithDependeciesClass.mock";
|
|
3
|
+
import { ControllerWithDepen2, ServiceToController2 } from "./classWithDependeciesInject.mock";
|
|
4
|
+
|
|
5
|
+
@Module({
|
|
6
|
+
imports: [],
|
|
7
|
+
controllers: [],
|
|
8
|
+
services: [],
|
|
9
|
+
exports: [],
|
|
10
|
+
})
|
|
11
|
+
export class ModuleTestEmpty {}
|
|
12
|
+
|
|
13
|
+
@Module({
|
|
14
|
+
imports: [],
|
|
15
|
+
controllers: [ControllerWithDepenClass],
|
|
16
|
+
services: [ServiceToController],
|
|
17
|
+
exports: [],
|
|
18
|
+
})
|
|
19
|
+
export class ModuleTest {}
|
|
20
|
+
|
|
21
|
+
@Module({
|
|
22
|
+
imports: [],
|
|
23
|
+
controllers: [ControllerWithDepen2],
|
|
24
|
+
services: [
|
|
25
|
+
ServiceToController2,
|
|
26
|
+
{
|
|
27
|
+
provider: "API_KEY",
|
|
28
|
+
useValue: "isApiKey_qwerty12345"
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
exports: [],
|
|
32
|
+
})
|
|
33
|
+
export class ModuleTestWithInjector {}
|
|
34
|
+
|
|
35
|
+
@Module({
|
|
36
|
+
imports: [ModuleTestWithInjector],
|
|
37
|
+
controllers: [],
|
|
38
|
+
services: [],
|
|
39
|
+
exports: [],
|
|
40
|
+
})
|
|
41
|
+
export class ModuleTestWithImports {}
|
|
42
|
+
|
|
43
|
+
@Module({
|
|
44
|
+
imports: [ModuleTestWithInjector],
|
|
45
|
+
controllers: [ControllerWithDepen2],
|
|
46
|
+
services: [
|
|
47
|
+
ServiceToController2,
|
|
48
|
+
{
|
|
49
|
+
provider: "API_SECRET",
|
|
50
|
+
useValue: "isApiSecret_cvbdfgert"
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
exports: [],
|
|
54
|
+
})
|
|
55
|
+
export class ModuleTestAll {}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class ServiceToService {
|
|
2
|
+
constructor();
|
|
3
|
+
}
|
|
4
|
+
export declare class Service {
|
|
5
|
+
constructor();
|
|
6
|
+
}
|
|
7
|
+
export declare class ServiceToController {
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
10
|
+
export declare class ControllerWithDepenClass {
|
|
11
|
+
private servicio;
|
|
12
|
+
constructor(servicio: ServiceToController);
|
|
13
|
+
}
|