@atlantjs/arch 3.1.0 → 3.1.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/arch/@atlantjs.json +3 -0
- package/arch/modules/application/databases/database.config.d.ts +19 -0
- package/arch/modules/application/databases/database.config.js +42 -0
- package/arch/modules/application/databases/database.helper.abstract.commit.failure.d.ts +4 -0
- package/arch/modules/application/databases/database.helper.abstract.commit.failure.js +14 -0
- package/arch/modules/application/databases/database.helper.abstract.d.ts +17 -2
- package/arch/modules/application/databases/database.helper.abstract.get-manager.failure.d.ts +4 -0
- package/arch/modules/application/databases/database.helper.abstract.get-manager.failure.js +14 -0
- package/arch/modules/application/databases/database.helper.abstract.js +99 -0
- package/arch/modules/application/databases/database.helper.abstract.rollback.failure.d.ts +4 -0
- package/arch/modules/application/databases/database.helper.abstract.rollback.failure.js +14 -0
- package/arch/modules/application/failures/failure.abstract.d.ts +2 -2
- package/arch/modules/domain/entities/entity.abstract.d.ts +10 -0
- package/arch/modules/domain/entities/entity.abstract.js +26 -0
- package/arch/modules/domain/entities/solid.abstract.d.ts +2 -2
- package/arch/modules/domain/entities/solid.abstract.js +4 -0
- package/arch/modules/infrastructure/repositories/schemas/schema.abstract.d.ts +9 -0
- package/arch/modules/infrastructure/repositories/schemas/schema.abstract.js +43 -0
- package/arch/modules/infrastructure/services/http-client.abstract.d.ts +0 -0
- package/arch/modules/infrastructure/services/http-client.abstract.js +1 -0
- package/arch/modules/infrastructure/services/payloads/service.payload.abstract.d.ts +0 -0
- package/arch/modules/infrastructure/services/payloads/service.payload.abstract.js +1 -0
- package/arch/modules/infrastructure/services/responses/service.response.abstract.d.ts +0 -0
- package/arch/modules/infrastructure/services/responses/service.response.abstract.js +1 -0
- package/index.d.ts +3 -3
- package/index.js +6 -2
- package/package.json +2 -1
- package/setup/index.d.ts +4 -5
- package/setup/index.js +8 -7
- package/tsconfig.tsbuildinfo +1 -1
- package/arch/modules/application/databases/database.factory.abstract.d.ts +0 -3
- package/arch/modules/application/databases/database.factory.abstract.js +0 -2
- package/arch/modules/domain/solid.abstract.d.ts +0 -4
- package/arch/modules/domain/solid.abstract.js +0 -2
- package/arch/modules/infrastructure/repositories/entities/entity.abstract.d.ts +0 -6
- package/arch/modules/infrastructure/repositories/entities/entity.abstract.js +0 -6
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DataSource, DatabaseType } from "typeorm";
|
|
2
|
+
interface DatabaseConfigProps {
|
|
3
|
+
type: DatabaseType;
|
|
4
|
+
host: string;
|
|
5
|
+
port: number;
|
|
6
|
+
username: string;
|
|
7
|
+
password: string;
|
|
8
|
+
database: string;
|
|
9
|
+
region?: string;
|
|
10
|
+
secretArn?: string;
|
|
11
|
+
resourceArn?: string;
|
|
12
|
+
}
|
|
13
|
+
export declare abstract class DatabaseConfigAbstract {
|
|
14
|
+
private readonly props;
|
|
15
|
+
configs: DataSource;
|
|
16
|
+
private productionOrHomologConfigs;
|
|
17
|
+
constructor(props: DatabaseConfigProps);
|
|
18
|
+
}
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseConfigAbstract = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const guardian_1 = require("../../../../@tool-box/utils/type-guard/guardian");
|
|
6
|
+
const env_vars_1 = require("../../../../setup/env/env-vars");
|
|
7
|
+
class DatabaseConfigAbstract {
|
|
8
|
+
constructor(props) {
|
|
9
|
+
this.props = props;
|
|
10
|
+
this.productionOrHomologConfigs = {
|
|
11
|
+
ssl: true,
|
|
12
|
+
extra: {
|
|
13
|
+
ssl: {
|
|
14
|
+
rejectUnauthorized: false,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
const baseConfig = {
|
|
19
|
+
type: this.props.type,
|
|
20
|
+
host: this.props.host,
|
|
21
|
+
port: this.props.port,
|
|
22
|
+
username: this.props.username,
|
|
23
|
+
password: this.props.password,
|
|
24
|
+
database: this.props.database,
|
|
25
|
+
synchronize: guardian_1.Guardian.isFalsy((0, env_vars_1.isProdOrHomolog)()),
|
|
26
|
+
entities: [`${__dirname}/../../**/*.schema{.ts,.js}`],
|
|
27
|
+
migrations: ["./migrations/*.ts"],
|
|
28
|
+
};
|
|
29
|
+
if (guardian_1.Guardian.isEqual(this.props.type, "aurora-mysql")) {
|
|
30
|
+
Object.assign(baseConfig, {
|
|
31
|
+
region: this.props.region ?? "",
|
|
32
|
+
secretArn: this.props.secretArn ?? "",
|
|
33
|
+
resourceArn: this.props.resourceArn ?? "",
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
if (this.props.host.indexOf("localhost") < 0) {
|
|
37
|
+
Object.assign(baseConfig, this.productionOrHomologConfigs);
|
|
38
|
+
}
|
|
39
|
+
this.configs = new typeorm_1.DataSource(baseConfig);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.DatabaseConfigAbstract = DatabaseConfigAbstract;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseHelperAbstractCommitFailure = void 0;
|
|
4
|
+
const failure_abstract_1 = require("../failures/failure.abstract");
|
|
5
|
+
class DatabaseHelperAbstractCommitFailure extends failure_abstract_1.FailureAbstract {
|
|
6
|
+
constructor(error) {
|
|
7
|
+
super({
|
|
8
|
+
className: DatabaseHelperAbstractCommitFailure.name,
|
|
9
|
+
message: "Transaction is not open",
|
|
10
|
+
error,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.DatabaseHelperAbstractCommitFailure = DatabaseHelperAbstractCommitFailure;
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
import { DataSource, EntityTarget, FindOptionsRelations, FindOptionsWhere, ObjectLiteral } from "typeorm";
|
|
2
|
+
import { Optional } from "../../../../@tool-box/utils/ducts/optional-type";
|
|
3
|
+
import { Return } from "../../../../@tool-box/utils/ducts/return-type";
|
|
4
|
+
import { DatabaseConfigAbstract } from "./database.config";
|
|
5
|
+
import { FailureAbstract } from "../failures/failure.abstract";
|
|
6
|
+
import { EntityAbstract } from "../../../../index";
|
|
1
7
|
export declare abstract class DatabaseHelperAbstract {
|
|
2
|
-
|
|
3
|
-
|
|
8
|
+
private database;
|
|
9
|
+
private queryRunner;
|
|
10
|
+
connect(db: DatabaseConfigAbstract): Promise<DataSource>;
|
|
11
|
+
disconnect(): Promise<void>;
|
|
12
|
+
read<T extends EntityTarget<ObjectLiteral>, E extends ObjectLiteral>(schema: T, relations: FindOptionsRelations<E>, condition: FindOptionsWhere<T>[] | FindOptionsWhere<T>): Promise<Return<Optional<ObjectLiteral[]>, FailureAbstract>>;
|
|
13
|
+
write<T extends EntityTarget<ObjectLiteral>>(schema: T, sortedEntities: EntityAbstract[]): Promise<any>;
|
|
14
|
+
delete<T extends EntityTarget<ObjectLiteral>>(entity: T, condition: FindOptionsWhere<T>[] | FindOptionsWhere<T>): Promise<Return<undefined, undefined>>;
|
|
15
|
+
private getManager;
|
|
16
|
+
private openTransaction;
|
|
17
|
+
private commit;
|
|
18
|
+
private rollback;
|
|
4
19
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseHelperAbstractGetManagerFailure = void 0;
|
|
4
|
+
const failure_abstract_1 = require("../failures/failure.abstract");
|
|
5
|
+
class DatabaseHelperAbstractGetManagerFailure extends failure_abstract_1.FailureAbstract {
|
|
6
|
+
constructor(error) {
|
|
7
|
+
super({
|
|
8
|
+
className: DatabaseHelperAbstractGetManagerFailure.name,
|
|
9
|
+
message: "The database is not connected",
|
|
10
|
+
error,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.DatabaseHelperAbstractGetManagerFailure = DatabaseHelperAbstractGetManagerFailure;
|
|
@@ -1,6 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DatabaseHelperAbstract = void 0;
|
|
4
|
+
const optional_type_1 = require("../../../../@tool-box/utils/ducts/optional-type");
|
|
5
|
+
const return_type_1 = require("../../../../@tool-box/utils/ducts/return-type");
|
|
6
|
+
const guardian_1 = require("../../../../@tool-box/utils/type-guard/guardian");
|
|
7
|
+
const database_helper_abstract_commit_failure_1 = require("./database.helper.abstract.commit.failure");
|
|
8
|
+
const database_helper_abstract_get_manager_failure_1 = require("./database.helper.abstract.get-manager.failure");
|
|
9
|
+
const database_helper_abstract_rollback_failure_1 = require("./database.helper.abstract.rollback.failure");
|
|
4
10
|
class DatabaseHelperAbstract {
|
|
11
|
+
constructor() {
|
|
12
|
+
this.database = optional_type_1.Nothing;
|
|
13
|
+
this.queryRunner = optional_type_1.Nothing;
|
|
14
|
+
}
|
|
15
|
+
async connect(db) {
|
|
16
|
+
this.database = (0, optional_type_1.Optional)(db.configs);
|
|
17
|
+
await this.database.unpack().initialize();
|
|
18
|
+
return this.database.unpack();
|
|
19
|
+
}
|
|
20
|
+
async disconnect() {
|
|
21
|
+
await this.database.unpack().destroy();
|
|
22
|
+
this.database = optional_type_1.Nothing;
|
|
23
|
+
}
|
|
24
|
+
async read(schema, relations, condition) {
|
|
25
|
+
const clientWrapped = this.getManager();
|
|
26
|
+
if (clientWrapped.hasFailure())
|
|
27
|
+
return (0, return_type_1.Failure)(clientWrapped.unwrapFail());
|
|
28
|
+
const client = clientWrapped.unwrap();
|
|
29
|
+
const repository = client.getRepository(schema);
|
|
30
|
+
const registryPacked = (0, optional_type_1.Optional)(await repository.find({ where: condition, relations }));
|
|
31
|
+
return (0, return_type_1.Success)(registryPacked);
|
|
32
|
+
}
|
|
33
|
+
async write(schema, sortedEntities) {
|
|
34
|
+
try {
|
|
35
|
+
const client = await this.openTransaction();
|
|
36
|
+
const repository = client.getRepository(schema);
|
|
37
|
+
sortedEntities.forEach(async (sortedEntity) => {
|
|
38
|
+
if (sortedEntity.id.hasNothing()) {
|
|
39
|
+
return (0, return_type_1.Failure)();
|
|
40
|
+
}
|
|
41
|
+
const registryPacked = (0, optional_type_1.Optional)(await repository.findOne({
|
|
42
|
+
where: { id: sortedEntity.id.toString() },
|
|
43
|
+
}));
|
|
44
|
+
if (guardian_1.Guardian.isUndefined(sortedEntity.toPersist)) {
|
|
45
|
+
return (0, return_type_1.Failure)();
|
|
46
|
+
}
|
|
47
|
+
if (registryPacked.hasNothing()) {
|
|
48
|
+
await repository.save(sortedEntity.toPersist());
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
await repository.update({ id: sortedEntity.id.toString() }, sortedEntity.toPersist());
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
await this.commit();
|
|
55
|
+
return (0, return_type_1.Success)();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
await this.rollback();
|
|
59
|
+
return (0, return_type_1.Failure)();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async delete(entity, condition) {
|
|
63
|
+
const client = await this.openTransaction();
|
|
64
|
+
const repository = client.getRepository(entity);
|
|
65
|
+
const registryPacked = (0, optional_type_1.Optional)(await repository.find({ where: condition }));
|
|
66
|
+
if (registryPacked.hasNothing()) {
|
|
67
|
+
return (0, return_type_1.Failure)();
|
|
68
|
+
}
|
|
69
|
+
repository.delete(condition);
|
|
70
|
+
return (0, return_type_1.Success)();
|
|
71
|
+
}
|
|
72
|
+
getManager() {
|
|
73
|
+
if (this.database.hasNothing()) {
|
|
74
|
+
return (0, return_type_1.Failure)(new database_helper_abstract_get_manager_failure_1.DatabaseHelperAbstractGetManagerFailure());
|
|
75
|
+
}
|
|
76
|
+
return (0, return_type_1.Success)(this.database.unpack().manager);
|
|
77
|
+
}
|
|
78
|
+
async openTransaction() {
|
|
79
|
+
if (this.queryRunner.hasNothing()) {
|
|
80
|
+
this.queryRunner = (0, optional_type_1.Optional)(this.database.unpack().createQueryRunner());
|
|
81
|
+
await this.queryRunner.unpack().connect();
|
|
82
|
+
await this.queryRunner.unpack().startTransaction();
|
|
83
|
+
}
|
|
84
|
+
return this.queryRunner.unpack().manager;
|
|
85
|
+
}
|
|
86
|
+
async commit() {
|
|
87
|
+
if (this.queryRunner.hasNothing()) {
|
|
88
|
+
return (0, return_type_1.Failure)(new database_helper_abstract_commit_failure_1.DatabaseHelperAbstractCommitFailure());
|
|
89
|
+
}
|
|
90
|
+
await this.queryRunner.unpack().commitTransaction();
|
|
91
|
+
await this.queryRunner.unpack().release();
|
|
92
|
+
this.queryRunner = optional_type_1.Nothing;
|
|
93
|
+
return (0, return_type_1.Success)();
|
|
94
|
+
}
|
|
95
|
+
async rollback() {
|
|
96
|
+
if (this.queryRunner.hasNothing()) {
|
|
97
|
+
return (0, return_type_1.Failure)(new database_helper_abstract_rollback_failure_1.DatabaseHelperAbstractRollbackFailure());
|
|
98
|
+
}
|
|
99
|
+
await this.queryRunner.unpack().rollbackTransaction();
|
|
100
|
+
await this.queryRunner.unpack().release();
|
|
101
|
+
this.queryRunner = optional_type_1.Nothing;
|
|
102
|
+
return (0, return_type_1.Success)();
|
|
103
|
+
}
|
|
5
104
|
}
|
|
6
105
|
exports.DatabaseHelperAbstract = DatabaseHelperAbstract;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DatabaseHelperAbstractRollbackFailure = void 0;
|
|
4
|
+
const failure_abstract_1 = require("../failures/failure.abstract");
|
|
5
|
+
class DatabaseHelperAbstractRollbackFailure extends failure_abstract_1.FailureAbstract {
|
|
6
|
+
constructor(error) {
|
|
7
|
+
super({
|
|
8
|
+
className: DatabaseHelperAbstractRollbackFailure.name,
|
|
9
|
+
message: "Transaction is not open",
|
|
10
|
+
error,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.DatabaseHelperAbstractRollbackFailure = DatabaseHelperAbstractRollbackFailure;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SolidAbstract } from "../../domain/solid.abstract";
|
|
1
|
+
import { FailurePrimitive, FailureProps } from "./failure.abstract.type";
|
|
2
|
+
import { SolidAbstract } from "../../domain/entities/solid.abstract";
|
|
3
3
|
export declare abstract class FailureAbstract implements SolidAbstract {
|
|
4
4
|
private readonly props;
|
|
5
5
|
protected readonly _code: string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Optional } from "../../../../@tool-box/utils/ducts/optional-type";
|
|
2
|
+
import { UuidAbstract } from "./uuid.abstract";
|
|
3
|
+
import { SolidAbstract } from "../../../../index";
|
|
4
|
+
export declare abstract class EntityAbstract extends SolidAbstract {
|
|
5
|
+
protected _id?: UuidAbstract | undefined;
|
|
6
|
+
constructor(_id?: UuidAbstract | undefined);
|
|
7
|
+
get id(): Optional<UuidAbstract>;
|
|
8
|
+
private requireToPersist;
|
|
9
|
+
abstract toPersist?(): EntityAbstract;
|
|
10
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.EntityAbstract = void 0;
|
|
7
|
+
const optional_type_1 = require("../../../../@tool-box/utils/ducts/optional-type");
|
|
8
|
+
const guardian_1 = require("../../../../@tool-box/utils/type-guard/guardian");
|
|
9
|
+
const _atlantjs_json_1 = __importDefault(require("../../../@atlantjs.json"));
|
|
10
|
+
const index_1 = require("../../../../index");
|
|
11
|
+
class EntityAbstract extends index_1.SolidAbstract {
|
|
12
|
+
constructor(_id) {
|
|
13
|
+
super();
|
|
14
|
+
this._id = _id;
|
|
15
|
+
if (guardian_1.Guardian.isEqual(_atlantjs_json_1.default.projectType, "backend")) {
|
|
16
|
+
this.requireToPersist();
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
get id() {
|
|
20
|
+
return (0, optional_type_1.Optional)(this._id);
|
|
21
|
+
}
|
|
22
|
+
requireToPersist() {
|
|
23
|
+
throw new Error("toPersist method must be implemented");
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.EntityAbstract = EntityAbstract;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { EntityAbstract } from "../../../domain/entities/entity.abstract";
|
|
2
|
+
import { BaseEntity } from "typeorm";
|
|
3
|
+
export declare abstract class SchemaAbstract extends BaseEntity {
|
|
4
|
+
createdAt: Date;
|
|
5
|
+
updatedAt: Date;
|
|
6
|
+
abstract toEntity(): EntityAbstract;
|
|
7
|
+
protected beforeInsert(): void;
|
|
8
|
+
protected beforeUpdate(): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SchemaAbstract = void 0;
|
|
13
|
+
const typeorm_1 = require("typeorm");
|
|
14
|
+
class SchemaAbstract extends typeorm_1.BaseEntity {
|
|
15
|
+
beforeInsert() {
|
|
16
|
+
this.createdAt = new Date(Date.now());
|
|
17
|
+
this.updatedAt = new Date(Date.now());
|
|
18
|
+
}
|
|
19
|
+
beforeUpdate() {
|
|
20
|
+
this.updatedAt = new Date(Date.now());
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.SchemaAbstract = SchemaAbstract;
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, typeorm_1.Column)({ name: "createdAt", type: "date" }),
|
|
26
|
+
__metadata("design:type", Date)
|
|
27
|
+
], SchemaAbstract.prototype, "createdAt", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, typeorm_1.Column)({ name: "updatedAt", type: "date" }),
|
|
30
|
+
__metadata("design:type", Date)
|
|
31
|
+
], SchemaAbstract.prototype, "updatedAt", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, typeorm_1.BeforeInsert)(),
|
|
34
|
+
__metadata("design:type", Function),
|
|
35
|
+
__metadata("design:paramtypes", []),
|
|
36
|
+
__metadata("design:returntype", void 0)
|
|
37
|
+
], SchemaAbstract.prototype, "beforeInsert", null);
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, typeorm_1.BeforeUpdate)(),
|
|
40
|
+
__metadata("design:type", Function),
|
|
41
|
+
__metadata("design:paramtypes", []),
|
|
42
|
+
__metadata("design:returntype", void 0)
|
|
43
|
+
], SchemaAbstract.prototype, "beforeUpdate", null);
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/index.d.ts
CHANGED
|
@@ -11,7 +11,6 @@ export { Success, Failure, Return } from "./@tool-box/utils/ducts/return-type";
|
|
|
11
11
|
export { HttpClient } from "./@tool-box/utils/http-client/http-client";
|
|
12
12
|
export { RandomValue } from "./@tool-box/utils/randoms/random-value";
|
|
13
13
|
export { Guardian } from "./@tool-box/utils/type-guard/guardian";
|
|
14
|
-
export { DatabaseFactoryAbstract } from "./arch/modules/application/databases/database.factory.abstract";
|
|
15
14
|
export { DatabaseHelperAbstract } from "./arch/modules/application/databases/database.helper.abstract";
|
|
16
15
|
export { FailureAbstract } from "./arch/modules/application/failures/failure.abstract";
|
|
17
16
|
export { UnknownFailure } from "./arch/modules/application/failures/unknown-failure";
|
|
@@ -29,13 +28,14 @@ export { MiddlewareHandlerAbstract } from "./arch/modules/domain/middlewares/mid
|
|
|
29
28
|
export { ProviderAbstract } from "./arch/modules/domain/providers/provider.abstract";
|
|
30
29
|
export { RepositoryAbstract } from "./arch/modules/domain/repositories/repository.abstract";
|
|
31
30
|
export { ServiceAbstract } from "./arch/modules/domain/services/service.abstract";
|
|
32
|
-
export { SolidAbstract } from "./arch/modules/domain/solid.abstract";
|
|
31
|
+
export { SolidAbstract } from "./arch/modules/domain/entities/solid.abstract";
|
|
33
32
|
export { UsecaseAbstract } from "./arch/modules/domain/usecases/usecase.abstract";
|
|
34
33
|
export { ControllerAbstract } from "./arch/modules/infrastructure/controllers/controller.abstract";
|
|
35
34
|
export { PayloadAbstract } from "./arch/modules/infrastructure/controllers/payloads/payload.abstract";
|
|
36
35
|
export { ValidatorAbstract } from "./arch/modules/infrastructure/controllers/payloads/validators/validator.abstract";
|
|
37
36
|
export { ResponseAbstract } from "./arch/modules/infrastructure/controllers/responses/response.abstract";
|
|
38
|
-
export { EntityAbstract } from "./arch/modules/
|
|
37
|
+
export { EntityAbstract } from "./arch/modules/domain/entities/entity.abstract";
|
|
38
|
+
export { SchemaAbstract } from "./arch/modules/infrastructure/repositories/schemas/schema.abstract";
|
|
39
39
|
export { ENVIRONMENT, IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256, APP_PORT, LOAD_MODULES, CORS_ALLOWED_ORIGINS, isProdOrHomolog, } from "./setup/env/env-vars";
|
|
40
40
|
export { initializeApi as initializeAtlantjs } from "./setup";
|
|
41
41
|
export { diContainer } from "./setup/dependency-injections";
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.diContainer = exports.initializeAtlantjs = exports.isProdOrHomolog = exports.CORS_ALLOWED_ORIGINS = exports.LOAD_MODULES = exports.APP_PORT = exports.IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256 = exports.ENVIRONMENT = exports.EntityAbstract = exports.ResponseAbstract = exports.ValidatorAbstract = exports.PayloadAbstract = exports.ControllerAbstract = exports.UsecaseAbstract = exports.ServiceAbstract = exports.RepositoryAbstract = exports.ProviderAbstract = exports.MiddlewareHandlerAbstract = exports.NodeEnvs = exports.HttpStatusCodes = exports.UuidAbstract = exports.$string = exports.$object = exports.$number = exports.$date = exports.$boolean = exports.$array = exports.InjectionsAbstract = exports.UnknownFailure = exports.FailureAbstract = exports.DatabaseHelperAbstract = exports.Guardian = exports.RandomValue = exports.HttpClient = exports.Return = exports.Failure = exports.Success = exports.Optional = exports.Nothing = exports.Something = exports.ExtendedMap = exports.EntityBuilder = exports.CreateFakeUsecase = exports.UuidBuilder = exports.FailureBuilder = void 0;
|
|
3
|
+
exports.diContainer = exports.initializeAtlantjs = exports.isProdOrHomolog = exports.CORS_ALLOWED_ORIGINS = exports.LOAD_MODULES = exports.APP_PORT = exports.IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256 = exports.ENVIRONMENT = exports.SchemaAbstract = exports.EntityAbstract = exports.ResponseAbstract = exports.ValidatorAbstract = exports.PayloadAbstract = exports.ControllerAbstract = exports.UsecaseAbstract = exports.SolidAbstract = exports.ServiceAbstract = exports.RepositoryAbstract = exports.ProviderAbstract = exports.MiddlewareHandlerAbstract = exports.NodeEnvs = exports.HttpStatusCodes = exports.UuidAbstract = exports.$string = exports.$object = exports.$number = exports.$date = exports.$boolean = exports.$array = exports.InjectionsAbstract = exports.UnknownFailure = exports.FailureAbstract = exports.DatabaseHelperAbstract = exports.Guardian = exports.RandomValue = exports.HttpClient = exports.Return = exports.Failure = exports.Success = exports.Optional = exports.Nothing = exports.Something = exports.ExtendedMap = exports.EntityBuilder = exports.CreateFakeUsecase = exports.UuidBuilder = exports.FailureBuilder = void 0;
|
|
4
4
|
require("#/utils/datatypes/string-utils");
|
|
5
5
|
require("#/utils/datatypes/boolean-utils");
|
|
6
6
|
var failure_builder_1 = require("./@tool-box/tests/builders/failures/failure.builder");
|
|
@@ -61,6 +61,8 @@ var repository_abstract_1 = require("./arch/modules/domain/repositories/reposito
|
|
|
61
61
|
Object.defineProperty(exports, "RepositoryAbstract", { enumerable: true, get: function () { return repository_abstract_1.RepositoryAbstract; } });
|
|
62
62
|
var service_abstract_1 = require("./arch/modules/domain/services/service.abstract");
|
|
63
63
|
Object.defineProperty(exports, "ServiceAbstract", { enumerable: true, get: function () { return service_abstract_1.ServiceAbstract; } });
|
|
64
|
+
var solid_abstract_1 = require("./arch/modules/domain/entities/solid.abstract");
|
|
65
|
+
Object.defineProperty(exports, "SolidAbstract", { enumerable: true, get: function () { return solid_abstract_1.SolidAbstract; } });
|
|
64
66
|
var usecase_abstract_1 = require("./arch/modules/domain/usecases/usecase.abstract");
|
|
65
67
|
Object.defineProperty(exports, "UsecaseAbstract", { enumerable: true, get: function () { return usecase_abstract_1.UsecaseAbstract; } });
|
|
66
68
|
var controller_abstract_1 = require("./arch/modules/infrastructure/controllers/controller.abstract");
|
|
@@ -71,8 +73,10 @@ var validator_abstract_1 = require("./arch/modules/infrastructure/controllers/pa
|
|
|
71
73
|
Object.defineProperty(exports, "ValidatorAbstract", { enumerable: true, get: function () { return validator_abstract_1.ValidatorAbstract; } });
|
|
72
74
|
var response_abstract_1 = require("./arch/modules/infrastructure/controllers/responses/response.abstract");
|
|
73
75
|
Object.defineProperty(exports, "ResponseAbstract", { enumerable: true, get: function () { return response_abstract_1.ResponseAbstract; } });
|
|
74
|
-
var entity_abstract_1 = require("./arch/modules/
|
|
76
|
+
var entity_abstract_1 = require("./arch/modules/domain/entities/entity.abstract");
|
|
75
77
|
Object.defineProperty(exports, "EntityAbstract", { enumerable: true, get: function () { return entity_abstract_1.EntityAbstract; } });
|
|
78
|
+
var schema_abstract_1 = require("./arch/modules/infrastructure/repositories/schemas/schema.abstract");
|
|
79
|
+
Object.defineProperty(exports, "SchemaAbstract", { enumerable: true, get: function () { return schema_abstract_1.SchemaAbstract; } });
|
|
76
80
|
var env_vars_1 = require("./setup/env/env-vars");
|
|
77
81
|
Object.defineProperty(exports, "ENVIRONMENT", { enumerable: true, get: function () { return env_vars_1.ENVIRONMENT; } });
|
|
78
82
|
Object.defineProperty(exports, "IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256", { enumerable: true, get: function () { return env_vars_1.IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlantjs/arch",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"publishConfig": {
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"module-alias": "^2.2.3",
|
|
49
49
|
"reflect-metadata": "^0.2.2",
|
|
50
50
|
"routing-controllers": "^0.10.4",
|
|
51
|
+
"typeorm": "^0.3.20",
|
|
51
52
|
"uuid": "^10.0.0"
|
|
52
53
|
},
|
|
53
54
|
"devDependencies": {
|
package/setup/index.d.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import "./env/load-envs";
|
|
3
3
|
import { Newable } from "../@tool-box/utils/datatypes/generic-types";
|
|
4
|
-
import {
|
|
4
|
+
import { DatabaseConfigAbstract } from "../arch/modules/application/databases/database.config";
|
|
5
5
|
import { DatabaseHelperAbstract } from "../arch/modules/application/databases/database.helper.abstract";
|
|
6
6
|
interface ServerProps {
|
|
7
|
-
databases
|
|
7
|
+
databases?: [
|
|
8
8
|
{
|
|
9
9
|
ref: Newable<Symbol>;
|
|
10
|
-
target:
|
|
10
|
+
target: DatabaseHelperAbstract;
|
|
11
|
+
configs: DatabaseConfigAbstract;
|
|
11
12
|
}
|
|
12
13
|
];
|
|
13
|
-
databaseFactories: DatabaseFactoryAbstract[];
|
|
14
|
-
databaseHelpers: DatabaseHelperAbstract[];
|
|
15
14
|
}
|
|
16
15
|
export declare function initializeApi(props: ServerProps): void;
|
|
17
16
|
export {};
|
package/setup/index.js
CHANGED
|
@@ -12,13 +12,14 @@ function initializeApi(props) {
|
|
|
12
12
|
initializeModules();
|
|
13
13
|
(0, dependency_injections_1.startContainer)();
|
|
14
14
|
server_1.Server.initialize();
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
if (guardian_1.Guardian.isNotUndefined(props.databases)) {
|
|
16
|
+
Promise.all([
|
|
17
|
+
props.databases.map((database) => {
|
|
18
|
+
dependency_injections_1.diContainer.bind(database.ref).toConstantValue(database.target);
|
|
19
|
+
database.target.connect(database.configs);
|
|
20
|
+
}),
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
22
23
|
}
|
|
23
24
|
catch (error) {
|
|
24
25
|
console.error(`❌ Error occurred: ${error}`);
|