@atlantjs/arch 3.2.2 → 3.2.4
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/modules/application/databases/database.config.d.ts +1 -1
- package/arch/modules/application/databases/database.helper.abstract.commit.failure.js +1 -1
- package/arch/modules/application/databases/database.helper.abstract.d.ts +7 -2
- package/arch/modules/application/databases/database.helper.abstract.js +1 -1
- package/arch/modules/application/databases/database.helper.abstract.rollback.failure.js +1 -1
- package/package.json +1 -1
- package/setup/index.d.ts +2 -1
- package/setup/index.js +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -17,7 +17,7 @@ interface DatabaseConfigProps {
|
|
|
17
17
|
export declare abstract class DatabaseConfigAbstract {
|
|
18
18
|
private readonly props;
|
|
19
19
|
configs: DataSource;
|
|
20
|
-
private productionOrHomologConfigs;
|
|
20
|
+
private readonly productionOrHomologConfigs;
|
|
21
21
|
constructor(props: DatabaseConfigProps);
|
|
22
22
|
}
|
|
23
23
|
export {};
|
|
@@ -6,7 +6,7 @@ class DatabaseHelperAbstractCommitFailure extends failure_abstract_1.FailureAbst
|
|
|
6
6
|
constructor(error) {
|
|
7
7
|
super({
|
|
8
8
|
className: DatabaseHelperAbstractCommitFailure.name,
|
|
9
|
-
message: "Transaction is not open",
|
|
9
|
+
message: "Transaction is not open. Run '.openTransaction()' before commit",
|
|
10
10
|
error,
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { DataSource, EntityTarget,
|
|
1
|
+
import { DataSource, EntityTarget, FindOptionsWhere, ObjectLiteral } from "typeorm";
|
|
2
|
+
import { FindOptionsRelations } from "typeorm";
|
|
3
|
+
import { Newable } from "../../../../@tool-box/utils/datatypes/generic-types";
|
|
2
4
|
import { Optional } from "../../../../@tool-box/utils/ducts/optional-type";
|
|
3
5
|
import { Return } from "../../../../@tool-box/utils/ducts/return-type";
|
|
4
6
|
import { DatabaseConfigAbstract } from "./database.config";
|
|
5
7
|
import { FailureAbstract } from "../failures/failure.abstract";
|
|
6
8
|
import { EntityBackendAbstract } from "../../domain/entities/entity-backend.abstract";
|
|
7
9
|
type SchemaAbstract = EntityTarget<ObjectLiteral>;
|
|
10
|
+
type PropertyEntity<T> = {
|
|
11
|
+
[K in keyof InstanceType<Newable<T>>]: InstanceType<Newable<T>>[K];
|
|
12
|
+
};
|
|
8
13
|
export declare abstract class DatabaseHelperAbstract {
|
|
9
14
|
private database;
|
|
10
15
|
private queryRunner;
|
|
11
16
|
connect(db: DatabaseConfigAbstract): Promise<DataSource>;
|
|
12
17
|
disconnect(): Promise<void>;
|
|
13
|
-
read<T extends SchemaAbstract, E extends ObjectLiteral>(schema: T,
|
|
18
|
+
read<T extends SchemaAbstract, E extends ObjectLiteral>(schema: T, condition: PropertyEntity<E>, relations: FindOptionsRelations<E>): Promise<Return<Optional<ObjectLiteral[]>, FailureAbstract>>;
|
|
14
19
|
write<T extends SchemaAbstract>(schema: T, sortedEntities: EntityBackendAbstract[]): Promise<Return<undefined, undefined>>;
|
|
15
20
|
delete<T extends SchemaAbstract>(entity: T, condition: FindOptionsWhere<T>[] | FindOptionsWhere<T>): Promise<Return<undefined, undefined>>;
|
|
16
21
|
private getManager;
|
|
@@ -21,7 +21,7 @@ class DatabaseHelperAbstract {
|
|
|
21
21
|
await this.database.unpack().destroy();
|
|
22
22
|
this.database = optional_type_1.Nothing;
|
|
23
23
|
}
|
|
24
|
-
async read(schema,
|
|
24
|
+
async read(schema, condition, relations) {
|
|
25
25
|
const clientWrapped = this.getManager();
|
|
26
26
|
if (clientWrapped.hasFailure())
|
|
27
27
|
return (0, return_type_1.Failure)(clientWrapped.unwrapFail());
|
|
@@ -6,7 +6,7 @@ class DatabaseHelperAbstractRollbackFailure extends failure_abstract_1.FailureAb
|
|
|
6
6
|
constructor(error) {
|
|
7
7
|
super({
|
|
8
8
|
className: DatabaseHelperAbstractRollbackFailure.name,
|
|
9
|
-
message: "Transaction is not open",
|
|
9
|
+
message: "Transaction is not open. Run '.openTransaction()' before commit",
|
|
10
10
|
error,
|
|
11
11
|
});
|
|
12
12
|
}
|
package/package.json
CHANGED
package/setup/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
import "./env/load-envs";
|
|
3
3
|
import { interfaces } from "inversify";
|
|
4
|
+
import { Newable } from "../@tool-box/utils/datatypes/generic-types";
|
|
4
5
|
import { DatabaseConfigAbstract } from "../arch/modules/application/databases/database.config";
|
|
5
6
|
import { DatabaseHelperAbstract } from "../arch/modules/application/databases/database.helper.abstract";
|
|
6
7
|
interface ServerProps {
|
|
@@ -8,7 +9,7 @@ interface ServerProps {
|
|
|
8
9
|
{
|
|
9
10
|
ref: interfaces.ServiceIdentifier<unknown>;
|
|
10
11
|
target: InstanceType<typeof DatabaseHelperAbstract>;
|
|
11
|
-
configs: DatabaseConfigAbstract
|
|
12
|
+
configs: Newable<DatabaseConfigAbstract>;
|
|
12
13
|
}
|
|
13
14
|
];
|
|
14
15
|
}
|
package/setup/index.js
CHANGED
|
@@ -16,7 +16,7 @@ function initializeApi(props) {
|
|
|
16
16
|
Promise.all([
|
|
17
17
|
props.databases.map((database) => {
|
|
18
18
|
dependency_injections_1.diContainer.bind(database.ref).toConstantValue(database.target);
|
|
19
|
-
database.target.connect(database.configs);
|
|
19
|
+
database.target.connect(new database.configs());
|
|
20
20
|
}),
|
|
21
21
|
]);
|
|
22
22
|
}
|