@atlantjs/backend 5.1.0 → 6.0.0

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.
Files changed (62) hide show
  1. package/README.md +0 -8
  2. package/backend/application/databases/database-lite.config.js +7 -9
  3. package/backend/application/databases/database.config.js +18 -20
  4. package/backend/application/databases/database.helper.abstract.commit.failure.d.ts +2 -2
  5. package/backend/application/databases/database.helper.abstract.commit.failure.js +4 -8
  6. package/backend/application/databases/database.helper.abstract.d.ts +12 -12
  7. package/backend/application/databases/database.helper.abstract.delete.failure.d.ts +2 -2
  8. package/backend/application/databases/database.helper.abstract.delete.failure.js +5 -9
  9. package/backend/application/databases/database.helper.abstract.get-manager.failure.d.ts +2 -2
  10. package/backend/application/databases/database.helper.abstract.get-manager.failure.js +4 -8
  11. package/backend/application/databases/database.helper.abstract.js +51 -61
  12. package/backend/application/databases/database.helper.abstract.rollback.failure.d.ts +2 -2
  13. package/backend/application/databases/database.helper.abstract.rollback.failure.js +4 -8
  14. package/backend/application/databases/database.helper.abstract.write.failure.d.ts +2 -2
  15. package/backend/application/databases/database.helper.abstract.write.failure.js +4 -8
  16. package/backend/application/env/env-vars.js +19 -22
  17. package/backend/application/env/load-envs.js +8 -13
  18. package/backend/application/injections.abstract.js +9 -12
  19. package/backend/application/injections.abstract.type.js +1 -2
  20. package/backend/domain/commands/command.abstract.js +1 -5
  21. package/backend/domain/middlewares/middleware.handler.abstract.js +1 -5
  22. package/backend/domain/objects/edges/metadata.edge.d.ts +10 -0
  23. package/backend/domain/objects/edges/metadata.edge.js +21 -0
  24. package/backend/domain/objects/edges/metadata.polygon.d.ts +4 -0
  25. package/backend/domain/objects/edges/metadata.polygon.js +1 -0
  26. package/backend/domain/objects/face.abstract.d.ts +8 -0
  27. package/backend/domain/objects/face.abstract.js +2 -0
  28. package/backend/domain/objects/solid.abstract.d.ts +12 -0
  29. package/backend/domain/objects/solid.abstract.js +9 -0
  30. package/backend/domain/objects/vertices/vertex.abstract.d.ts +11 -0
  31. package/backend/domain/objects/vertices/vertex.abstract.js +9 -0
  32. package/backend/domain/providers/provider.abstract.js +1 -5
  33. package/backend/domain/repositories/repository.abstract.js +1 -5
  34. package/backend/domain/services/service.abstract.js +1 -5
  35. package/backend/infrastructure/controllers/controller.abstract.d.ts +3 -3
  36. package/backend/infrastructure/controllers/controller.abstract.js +6 -10
  37. package/backend/infrastructure/controllers/payloads/payload.abstract.js +1 -5
  38. package/backend/infrastructure/controllers/payloads/validators/validator.abstract.js +1 -5
  39. package/backend/infrastructure/controllers/responses/response.abstract.d.ts +1 -1
  40. package/backend/infrastructure/controllers/responses/response.abstract.js +1 -5
  41. package/backend/infrastructure/controllers/validators/is-time-string.js +4 -7
  42. package/index.d.ts +2 -2
  43. package/index.js +34 -137
  44. package/package.json +3 -5
  45. package/setup/dependency-injections/di-container.abstract.js +8 -12
  46. package/setup/dependency-injections/di-container.js +3 -6
  47. package/setup/dependency-injections/index.js +5 -10
  48. package/setup/index.js +12 -16
  49. package/setup/parchment/parchment.error.js +1 -5
  50. package/setup/parchment/parchment.js +18 -20
  51. package/setup/parchment/parchment.type.js +1 -2
  52. package/setup/server/body-parser-middleware.js +7 -16
  53. package/setup/server/cors-middleware.js +9 -15
  54. package/setup/server/default-error-handler-middleware.js +11 -18
  55. package/setup/server/server.js +28 -35
  56. package/setup/server/unknow.error.d.ts +1 -1
  57. package/setup/server/unknow.error.js +8 -10
  58. package/tsconfig.tsbuildinfo +1 -1
  59. package/backend/domain/entities/entity.abstract.d.ts +0 -9
  60. package/backend/domain/entities/entity.abstract.js +0 -11
  61. package/backend/infrastructure/repositories/schemas/schema.abstract.d.ts +0 -8
  62. package/backend/infrastructure/repositories/schemas/schema.abstract.js +0 -6
package/README.md CHANGED
@@ -1,8 +0,0 @@
1
- # String Utils
2
-
3
- ## Install
4
-
5
- ```
6
- npm install @atlantjs/string-utils
7
- yarn add @atlantjs/string-utils
8
- ```
@@ -1,15 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseLiteConfigAbstract = void 0;
4
- const typeorm_1 = require("typeorm");
5
- const env_vars_1 = require("../env/env-vars");
6
- class DatabaseLiteConfigAbstract {
1
+ import { DataSource } from "typeorm";
2
+ import { DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED } from "../env/env-vars";
3
+ export class DatabaseLiteConfigAbstract {
4
+ props;
5
+ configs;
7
6
  constructor(props) {
8
7
  this.props = props;
9
8
  const baseConfig = {
10
9
  type: this.props.type,
11
10
  database: this.props.binaryFilePath,
12
- synchronize: env_vars_1.DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED,
11
+ synchronize: DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED,
13
12
  extra: {
14
13
  cipher: "aes-256-cbc",
15
14
  key: props.accessKey,
@@ -17,7 +16,6 @@ class DatabaseLiteConfigAbstract {
17
16
  entities: props.schemaPaths,
18
17
  migrations: props.migrationPaths,
19
18
  };
20
- this.configs = new typeorm_1.DataSource(baseConfig);
19
+ this.configs = new DataSource(baseConfig);
21
20
  }
22
21
  }
23
- exports.DatabaseLiteConfigAbstract = DatabaseLiteConfigAbstract;
@@ -1,20 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseConfigAbstract = void 0;
4
- const arch_1 = require("@atlantjs/arch");
5
- const typeorm_1 = require("typeorm");
6
- const env_vars_1 = require("../env/env-vars");
7
- class DatabaseConfigAbstract {
1
+ import { _ } from "@atlantjs/arch";
2
+ import { DataSource } from "typeorm";
3
+ import { DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED, DATABASE_SSL_ENABLED, } from "../env/env-vars";
4
+ export class DatabaseConfigAbstract {
5
+ props;
6
+ configs;
7
+ sslConfig = {
8
+ ssl: true,
9
+ extra: {
10
+ ssl: {
11
+ rejectUnauthorized: false,
12
+ },
13
+ },
14
+ };
8
15
  constructor(props) {
9
16
  this.props = props;
10
- this.sslConfig = {
11
- ssl: true,
12
- extra: {
13
- ssl: {
14
- rejectUnauthorized: false,
15
- },
16
- },
17
- };
18
17
  const baseConfig = {
19
18
  type: this.props.type,
20
19
  host: this.props.host,
@@ -23,21 +22,20 @@ class DatabaseConfigAbstract {
23
22
  password: this.props.adminPassword,
24
23
  database: this.props.name,
25
24
  schema: this.props.schemaName,
26
- synchronize: env_vars_1.DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED,
25
+ synchronize: DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED,
27
26
  entities: this.props.schemaPaths,
28
27
  migrations: this.props.migrationPaths,
29
28
  };
30
- if (arch_1._.isEqual(this.props.type, "aurora-mysql")) {
29
+ if (_.isEqual(this.props.type, "aurora-mysql")) {
31
30
  Object.assign(baseConfig, {
32
31
  region: this.props.region ?? "",
33
32
  secretArn: this.props.secretArn ?? "",
34
33
  resourceArn: this.props.resourceArn ?? "",
35
34
  });
36
35
  }
37
- if (env_vars_1.DATABASE_SSL_ENABLED) {
36
+ if (DATABASE_SSL_ENABLED) {
38
37
  Object.assign(baseConfig, this.sslConfig);
39
38
  }
40
- this.configs = new typeorm_1.DataSource(baseConfig);
39
+ this.configs = new DataSource(baseConfig);
41
40
  }
42
41
  }
43
- exports.DatabaseConfigAbstract = DatabaseConfigAbstract;
@@ -1,4 +1,4 @@
1
- import { FailureAbstract } from "@atlantjs/arch";
2
- export declare class DatabaseHelperAbstractCommitFailure extends FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export declare class DatabaseHelperAbstractCommitFailure extends FailureSketchEdge {
3
3
  constructor(error?: any);
4
4
  }
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseHelperAbstractCommitFailure = void 0;
4
- const arch_1 = require("@atlantjs/arch");
5
- class DatabaseHelperAbstractCommitFailure extends arch_1.FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export class DatabaseHelperAbstractCommitFailure extends FailureSketchEdge {
6
3
  constructor(error) {
7
4
  super({
8
- className: DatabaseHelperAbstractCommitFailure.name,
5
+ failureClass: DatabaseHelperAbstractCommitFailure,
9
6
  message: "Transaction is not open. Run '.openTransaction()' before commit",
10
- error,
7
+ stackTrace: error,
11
8
  });
12
9
  }
13
10
  }
14
- exports.DatabaseHelperAbstractCommitFailure = DatabaseHelperAbstractCommitFailure;
@@ -1,15 +1,15 @@
1
- import { FailureAbstract, Newable, Optional, Return } from "@atlantjs/arch";
1
+ import { FailureSketchEdge, Newable, Optional, Return } from "@atlantjs/arch";
2
2
  import { DataSource, EntityTarget, FindOptionsRelations, ObjectLiteral } from "typeorm";
3
3
  import { DatabaseLiteConfigAbstract } from "./database-lite.config";
4
4
  import { DatabaseConfigAbstract } from "./database.config";
5
- import { EntityAbstract } from "../../domain/entities/entity.abstract";
6
- interface SchemaEntity {
7
- schema: EntityTarget<ObjectLiteral>;
8
- entity: EntityAbstract;
9
- unique?: keyof EntityAbstract;
5
+ import { SolidAbstract } from "../../domain/objects/solid.abstract";
6
+ import { VertexAbstract } from "../../domain/objects/vertices/vertex.abstract";
7
+ interface FaceEntity {
8
+ face: EntityTarget<ObjectLiteral>;
9
+ entity: SolidAbstract | VertexAbstract;
10
10
  }
11
- interface SchemaEntityReturn {
12
- schema: EntityTarget<ObjectLiteral>;
11
+ interface FaceEntityReturn {
12
+ face: EntityTarget<ObjectLiteral>;
13
13
  id: string;
14
14
  }
15
15
  export declare abstract class DatabaseHelperAbstract {
@@ -17,13 +17,13 @@ export declare abstract class DatabaseHelperAbstract {
17
17
  private queryRunner;
18
18
  connect(db: DatabaseConfigAbstract | DatabaseLiteConfigAbstract): Promise<DataSource>;
19
19
  disconnect(): Promise<void>;
20
- read<T extends Newable<ObjectLiteral>, E extends ObjectLiteral>(schema: T, condition: {
20
+ read<T extends Newable<ObjectLiteral>, E extends ObjectLiteral>(face: T, condition: {
21
21
  [K in keyof InstanceType<T>]?: InstanceType<T>[K];
22
- }, relations: FindOptionsRelations<E>): Promise<Return<Optional<InstanceType<T>[]>, FailureAbstract>>;
23
- write(schemaEntities: SchemaEntity[]): Promise<Return<SchemaEntityReturn[], FailureAbstract>>;
22
+ }, relations: FindOptionsRelations<E>): Promise<Return<Optional<InstanceType<T>[]>, FailureSketchEdge>>;
23
+ write(faceEntities: FaceEntity[]): Promise<Return<FaceEntityReturn[], FailureSketchEdge>>;
24
24
  delete<T extends Newable<ObjectLiteral>>(schema: T, condition: {
25
25
  [K in keyof InstanceType<T>]?: InstanceType<T>[K];
26
- }, isSoft?: boolean): Promise<Return<undefined, FailureAbstract>>;
26
+ }, isSoft?: boolean): Promise<Return<undefined, FailureSketchEdge>>;
27
27
  private getManager;
28
28
  private openTransaction;
29
29
  private commit;
@@ -1,4 +1,4 @@
1
- import { FailureAbstract } from "@atlantjs/arch";
2
- export declare class DatabaseHelperAbstractDeleteFailure extends FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export declare class DatabaseHelperAbstractDeleteFailure extends FailureSketchEdge {
3
3
  constructor(isSoft: boolean, error?: any);
4
4
  }
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseHelperAbstractDeleteFailure = void 0;
4
- const arch_1 = require("@atlantjs/arch");
5
- class DatabaseHelperAbstractDeleteFailure extends arch_1.FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export class DatabaseHelperAbstractDeleteFailure extends FailureSketchEdge {
6
3
  constructor(isSoft, error) {
7
4
  super({
8
- className: DatabaseHelperAbstractDeleteFailure.name,
9
- message: `Failed to ${arch_1._.isTruthy(isSoft) ? "soft" : "hard"} delete the record in the database`,
10
- error,
5
+ failureClass: DatabaseHelperAbstractDeleteFailure,
6
+ message: `Failed to ${isSoft.truthy() ? "soft" : "hard"} delete the record in the database`,
7
+ stackTrace: error,
11
8
  });
12
9
  }
13
10
  }
14
- exports.DatabaseHelperAbstractDeleteFailure = DatabaseHelperAbstractDeleteFailure;
@@ -1,4 +1,4 @@
1
- import { FailureAbstract } from "@atlantjs/arch";
2
- export declare class DatabaseHelperAbstractGetManagerFailure extends FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export declare class DatabaseHelperAbstractGetManagerFailure extends FailureSketchEdge {
3
3
  constructor(error?: any);
4
4
  }
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseHelperAbstractGetManagerFailure = void 0;
4
- const arch_1 = require("@atlantjs/arch");
5
- class DatabaseHelperAbstractGetManagerFailure extends arch_1.FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export class DatabaseHelperAbstractGetManagerFailure extends FailureSketchEdge {
6
3
  constructor(error) {
7
4
  super({
8
- className: DatabaseHelperAbstractGetManagerFailure.name,
5
+ failureClass: DatabaseHelperAbstractGetManagerFailure,
9
6
  message: "The database is not connected",
10
- error,
7
+ stackTrace: error,
11
8
  });
12
9
  }
13
10
  }
14
- exports.DatabaseHelperAbstractGetManagerFailure = DatabaseHelperAbstractGetManagerFailure;
@@ -1,103 +1,94 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseHelperAbstract = void 0;
4
- const arch_1 = require("@atlantjs/arch");
5
- const database_helper_abstract_commit_failure_1 = require("./database.helper.abstract.commit.failure");
6
- const database_helper_abstract_delete_failure_1 = require("./database.helper.abstract.delete.failure");
7
- const database_helper_abstract_get_manager_failure_1 = require("./database.helper.abstract.get-manager.failure");
8
- const database_helper_abstract_rollback_failure_1 = require("./database.helper.abstract.rollback.failure");
9
- const database_helper_abstract_write_failure_1 = require("./database.helper.abstract.write.failure");
10
- class DatabaseHelperAbstract {
11
- constructor() {
12
- this.database = arch_1.Nothing;
13
- this.queryRunner = arch_1.Nothing;
14
- }
1
+ import { Failure, Nothing, Optional, Success, _, } from "@atlantjs/arch";
2
+ import { DatabaseHelperAbstractCommitFailure } from "./database.helper.abstract.commit.failure";
3
+ import { DatabaseHelperAbstractDeleteFailure } from "./database.helper.abstract.delete.failure";
4
+ import { DatabaseHelperAbstractGetManagerFailure } from "./database.helper.abstract.get-manager.failure";
5
+ import { DatabaseHelperAbstractRollbackFailure } from "./database.helper.abstract.rollback.failure";
6
+ import { DatabaseHelperAbstractWriteFailure } from "./database.helper.abstract.write.failure";
7
+ export class DatabaseHelperAbstract {
8
+ database = Nothing;
9
+ queryRunner = Nothing;
15
10
  async connect(db) {
16
- this.database = (0, arch_1.Optional)(db.configs);
11
+ this.database = Optional(db.configs);
17
12
  await this.database.unpack().initialize();
18
13
  return this.database.unpack();
19
14
  }
20
15
  async disconnect() {
21
16
  await this.database.unpack().destroy();
22
- this.database = arch_1.Nothing;
17
+ this.database = Nothing;
23
18
  }
24
- async read(schema, condition, relations) {
19
+ async read(face, condition, relations) {
25
20
  const clientWrapped = this.getManager();
26
21
  if (clientWrapped.hasFailure())
27
- return (0, arch_1.Failure)(clientWrapped.unwrapFail());
22
+ return Failure(clientWrapped.unwrapFail());
28
23
  const client = clientWrapped.unwrap();
29
- const repository = client.getRepository(schema);
30
- const registryPacked = (0, arch_1.Optional)((await repository.find({
24
+ const repository = client.getRepository(face);
25
+ const registryPacked = Optional((await repository.find({
31
26
  where: { ...condition, deleted: false },
32
27
  relations,
33
28
  })));
34
29
  if (relations && registryPacked.hasSomething()) {
35
- const filterDeletedRelations = (schema, rels) => {
36
- if (!schema || typeof schema !== "object" || !rels)
30
+ const filterDeletedRelations = (face, rels) => {
31
+ if (!face || typeof face !== "object" || !rels)
37
32
  return;
38
33
  for (const rel of rels) {
39
- const relValue = schema[rel];
34
+ const relValue = face[rel];
40
35
  if (Array.isArray(relValue)) {
41
- schema[rel] = relValue.filter((item) => !item?.deleted);
36
+ face[rel] = relValue.filter((item) => !item?.deleted);
42
37
  }
43
38
  else if (relValue.deleted) {
44
- schema[rel] = undefined;
39
+ face[rel] = undefined;
45
40
  }
46
41
  }
47
42
  };
48
- for (const schemas of registryPacked.unpack()) {
49
- filterDeletedRelations(schemas, relations);
43
+ for (const faces of registryPacked.unpack()) {
44
+ filterDeletedRelations(faces, relations);
50
45
  }
51
46
  }
52
- return (0, arch_1.Success)(registryPacked);
47
+ return Success(registryPacked);
53
48
  }
54
- async write(schemaEntities) {
49
+ async write(faceEntities) {
55
50
  try {
56
51
  const client = await this.openTransaction();
57
52
  const ids = [];
58
- for (const schemaEntity of schemaEntities) {
59
- const repository = client.getRepository(schemaEntity.schema);
60
- if (arch_1._.isUndefined(schemaEntity.entity.toSchema) ||
61
- arch_1._.isUndefined(schemaEntity.entity.id)) {
62
- return (0, arch_1.Failure)(new database_helper_abstract_write_failure_1.DatabaseHelperAbstractWriteFailure());
53
+ for (const faceEntity of faceEntities) {
54
+ const repository = client.getRepository(faceEntity.face);
55
+ if (_.isUndefined(faceEntity.entity.toSeal) ||
56
+ _.isUndefined(faceEntity.entity.id)) {
57
+ return Failure(new DatabaseHelperAbstractWriteFailure());
63
58
  }
64
- const uniqueColumnName = schemaEntity.unique ?? "id";
65
- const uniqueColumnValue = arch_1._.isNotUndefined(schemaEntity.unique)
66
- ? String(schemaEntity.entity[schemaEntity.unique])
67
- : schemaEntity.entity.id.toString();
68
- const registryFoundedPacked = (0, arch_1.Optional)(await repository.findOne({
59
+ const registryFoundedPacked = Optional(await repository.findOne({
69
60
  where: {
70
- [uniqueColumnName]: uniqueColumnValue,
61
+ id: faceEntity.entity.id.toString(),
71
62
  },
72
63
  }));
73
64
  if (registryFoundedPacked.hasNothing()) {
74
- await repository.save(schemaEntity.entity.toSchema());
65
+ await repository.save(faceEntity.entity.toSeal());
75
66
  }
76
67
  else {
77
- await repository.update({ id: schemaEntity.entity.id.toString() }, schemaEntity.entity.toSchema());
68
+ await repository.update({ id: faceEntity.entity.id.toString() }, faceEntity.entity.toSeal());
78
69
  }
79
70
  ids.push({
80
- schema: schemaEntity.schema,
81
- id: schemaEntity.entity.id.toString(),
71
+ face: faceEntity.face,
72
+ id: faceEntity.entity.id.toString(),
82
73
  });
83
74
  }
84
75
  await this.commit();
85
- return (0, arch_1.Success)(ids);
76
+ return Success(ids);
86
77
  }
87
78
  catch (error) {
88
79
  await this.rollback();
89
- return (0, arch_1.Failure)(new database_helper_abstract_write_failure_1.DatabaseHelperAbstractWriteFailure(error));
80
+ return Failure(new DatabaseHelperAbstractWriteFailure(error));
90
81
  }
91
82
  }
92
83
  async delete(schema, condition, isSoft = true) {
93
84
  try {
94
85
  const client = await this.openTransaction();
95
86
  const repository = client.getRepository(schema);
96
- const registriesPacked = (0, arch_1.Optional)(await repository.find({ where: condition }));
87
+ const registriesPacked = Optional(await repository.find({ where: condition }));
97
88
  if (registriesPacked.hasNothing()) {
98
- return (0, arch_1.Failure)(new database_helper_abstract_delete_failure_1.DatabaseHelperAbstractDeleteFailure(isSoft));
89
+ return Failure(new DatabaseHelperAbstractDeleteFailure(isSoft));
99
90
  }
100
- if (arch_1._.isFalsy(isSoft)) {
91
+ if (isSoft.falsy()) {
101
92
  repository.delete(condition);
102
93
  }
103
94
  else {
@@ -108,22 +99,22 @@ class DatabaseHelperAbstract {
108
99
  }
109
100
  }
110
101
  await this.commit();
111
- return (0, arch_1.Success)();
102
+ return Success();
112
103
  }
113
104
  catch (error) {
114
105
  await this.rollback();
115
- return (0, arch_1.Failure)(new database_helper_abstract_delete_failure_1.DatabaseHelperAbstractDeleteFailure(isSoft, error));
106
+ return Failure(new DatabaseHelperAbstractDeleteFailure(isSoft, error));
116
107
  }
117
108
  }
118
109
  getManager() {
119
110
  if (this.database.hasNothing()) {
120
- return (0, arch_1.Failure)(new database_helper_abstract_get_manager_failure_1.DatabaseHelperAbstractGetManagerFailure());
111
+ return Failure(new DatabaseHelperAbstractGetManagerFailure());
121
112
  }
122
- return (0, arch_1.Success)(this.database.unpack().manager);
113
+ return Success(this.database.unpack().manager);
123
114
  }
124
115
  async openTransaction() {
125
116
  if (this.queryRunner.hasNothing()) {
126
- this.queryRunner = (0, arch_1.Optional)(this.database.unpack().createQueryRunner());
117
+ this.queryRunner = Optional(this.database.unpack().createQueryRunner());
127
118
  await this.queryRunner.unpack().connect();
128
119
  await this.queryRunner.unpack().startTransaction();
129
120
  }
@@ -131,21 +122,20 @@ class DatabaseHelperAbstract {
131
122
  }
132
123
  async commit() {
133
124
  if (this.queryRunner.hasNothing()) {
134
- return (0, arch_1.Failure)(new database_helper_abstract_commit_failure_1.DatabaseHelperAbstractCommitFailure());
125
+ return Failure(new DatabaseHelperAbstractCommitFailure());
135
126
  }
136
127
  await this.queryRunner.unpack().commitTransaction();
137
128
  await this.queryRunner.unpack().release();
138
- this.queryRunner = arch_1.Nothing;
139
- return (0, arch_1.Success)();
129
+ this.queryRunner = Nothing;
130
+ return Success();
140
131
  }
141
132
  async rollback() {
142
133
  if (this.queryRunner.hasNothing()) {
143
- return (0, arch_1.Failure)(new database_helper_abstract_rollback_failure_1.DatabaseHelperAbstractRollbackFailure());
134
+ return Failure(new DatabaseHelperAbstractRollbackFailure());
144
135
  }
145
136
  await this.queryRunner.unpack().rollbackTransaction();
146
137
  await this.queryRunner.unpack().release();
147
- this.queryRunner = arch_1.Nothing;
148
- return (0, arch_1.Success)();
138
+ this.queryRunner = Nothing;
139
+ return Success();
149
140
  }
150
141
  }
151
- exports.DatabaseHelperAbstract = DatabaseHelperAbstract;
@@ -1,4 +1,4 @@
1
- import { FailureAbstract } from "@atlantjs/arch";
2
- export declare class DatabaseHelperAbstractRollbackFailure extends FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export declare class DatabaseHelperAbstractRollbackFailure extends FailureSketchEdge {
3
3
  constructor(error?: any);
4
4
  }
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseHelperAbstractRollbackFailure = void 0;
4
- const arch_1 = require("@atlantjs/arch");
5
- class DatabaseHelperAbstractRollbackFailure extends arch_1.FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export class DatabaseHelperAbstractRollbackFailure extends FailureSketchEdge {
6
3
  constructor(error) {
7
4
  super({
8
- className: DatabaseHelperAbstractRollbackFailure.name,
5
+ failureClass: DatabaseHelperAbstractRollbackFailure,
9
6
  message: "Transaction is not open. Run '.openTransaction()' before commit",
10
- error,
7
+ stackTrace: error,
11
8
  });
12
9
  }
13
10
  }
14
- exports.DatabaseHelperAbstractRollbackFailure = DatabaseHelperAbstractRollbackFailure;
@@ -1,4 +1,4 @@
1
- import { FailureAbstract } from "@atlantjs/arch";
2
- export declare class DatabaseHelperAbstractWriteFailure extends FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export declare class DatabaseHelperAbstractWriteFailure extends FailureSketchEdge {
3
3
  constructor(error?: any);
4
4
  }
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DatabaseHelperAbstractWriteFailure = void 0;
4
- const arch_1 = require("@atlantjs/arch");
5
- class DatabaseHelperAbstractWriteFailure extends arch_1.FailureAbstract {
1
+ import { FailureSketchEdge } from "@atlantjs/arch";
2
+ export class DatabaseHelperAbstractWriteFailure extends FailureSketchEdge {
6
3
  constructor(error) {
7
4
  super({
8
- className: DatabaseHelperAbstractWriteFailure.name,
5
+ failureClass: DatabaseHelperAbstractWriteFailure,
9
6
  message: "Failed to insert or update the record in the database",
10
- error,
7
+ stackTrace: error,
11
8
  });
12
9
  }
13
10
  }
14
- exports.DatabaseHelperAbstractWriteFailure = DatabaseHelperAbstractWriteFailure;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ENVIRONMENT = exports.CORS_ALLOWED_ORIGINS = exports.LOAD_MODULES = exports.APP_PORT = exports.DATABASE_SSL_ENABLED = exports.DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED = exports.DATABASE_ADMIN_USER = exports.DATABASE_PORT = exports.DATABASE_ADMIN_PASSWORD = exports.DATABASE_HOST = exports.DATABASE_DEFAULT_SCHEMA = exports.DATABASE_NAME = exports.DATABASE_TYPE = void 0;
4
- const arch_1 = require("@atlantjs/arch");
5
- const parchment_1 = require("../../../setup/parchment/parchment");
6
- exports.DATABASE_TYPE = parchment_1.Parchment.verse({
1
+ import { NodeEnvs } from "@atlantjs/arch";
2
+ import { Parchment } from "../../../setup/parchment/parchment";
3
+ export const DATABASE_TYPE = Parchment.verse({
7
4
  name: "DATABASE_TYPE",
8
5
  type: "enum",
9
6
  description: "The type of the database",
@@ -11,82 +8,82 @@ exports.DATABASE_TYPE = parchment_1.Parchment.verse({
11
8
  values: ["aurora-postgres", "postgres", "sqlite"],
12
9
  isRequired: true,
13
10
  });
14
- exports.DATABASE_NAME = parchment_1.Parchment.verse({
11
+ export const DATABASE_NAME = Parchment.verse({
15
12
  name: "DATABASE_NAME",
16
13
  type: "text",
17
14
  description: "The name of the database",
18
15
  isRequired: true,
19
16
  });
20
- exports.DATABASE_DEFAULT_SCHEMA = parchment_1.Parchment.verse({
17
+ export const DATABASE_DEFAULT_SCHEMA = Parchment.verse({
21
18
  name: "DATABASE_DEFAULT_SCHEMA",
22
19
  type: "text",
23
20
  description: "The name of default schema the database",
24
21
  isRequired: true,
25
22
  });
26
- exports.DATABASE_HOST = parchment_1.Parchment.verse({
23
+ export const DATABASE_HOST = Parchment.verse({
27
24
  name: "DATABASE_HOST",
28
25
  description: "The host address of the database server",
29
26
  type: "text",
30
27
  isRequired: true,
31
28
  });
32
- exports.DATABASE_ADMIN_PASSWORD = parchment_1.Parchment.verse({
29
+ export const DATABASE_ADMIN_PASSWORD = Parchment.verse({
33
30
  name: "DATABASE_ADMIN_PASSWORD",
34
31
  description: "The password for the database user",
35
32
  type: "text",
36
33
  isRequired: true,
37
34
  });
38
- exports.DATABASE_PORT = parchment_1.Parchment.verse({
35
+ export const DATABASE_PORT = Parchment.verse({
39
36
  name: "DATABASE_PORT",
40
37
  type: "port-number",
41
38
  description: "The port number on which the database server is running",
42
39
  isRequired: true,
43
40
  });
44
- exports.DATABASE_ADMIN_USER = parchment_1.Parchment.verse({
41
+ export const DATABASE_ADMIN_USER = Parchment.verse({
45
42
  name: "DATABASE_ADMIN_USER",
46
43
  description: "The username for the database database",
47
44
  type: "text",
48
45
  isRequired: true,
49
46
  });
50
- exports.DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED = parchment_1.Parchment.verse({
47
+ export const DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED = Parchment.verse({
51
48
  name: "DATABASE_AUTOMATICALLY_CREATE_TABLES_ENABLED",
52
49
  type: "boolean",
53
50
  description: "Flag indicating whether the ORM automatically creates tables in the database based on .schema.ts files",
54
51
  isRequired: true,
55
52
  });
56
- exports.DATABASE_SSL_ENABLED = parchment_1.Parchment.verse({
53
+ export const DATABASE_SSL_ENABLED = Parchment.verse({
57
54
  name: "DATABASE_SSL_ENABLED",
58
55
  type: "boolean",
59
56
  description: "Flag indicating whether the database requires an SSL connection",
60
57
  isRequired: true,
61
58
  });
62
- exports.APP_PORT = parchment_1.Parchment.verse({
59
+ export const APP_PORT = Parchment.verse({
63
60
  name: "APP_PORT",
64
61
  type: "port-number",
65
62
  description: "The port number on which the application will run",
66
63
  isRequired: true,
67
64
  });
68
- exports.LOAD_MODULES = parchment_1.Parchment.verse({
65
+ export const LOAD_MODULES = Parchment.verse({
69
66
  name: "LOAD_MODULES",
70
67
  type: "array",
71
68
  description: "List of modules, separated by commas, to be loaded by the application",
72
69
  isRequired: true,
73
70
  });
74
- exports.CORS_ALLOWED_ORIGINS = parchment_1.Parchment.verse({
71
+ export const CORS_ALLOWED_ORIGINS = Parchment.verse({
75
72
  name: "CORS_ALLOWED_ORIGINS",
76
73
  default: "*",
77
74
  description: "Allowed origins for CORS",
78
75
  type: "text",
79
76
  isRequired: true,
80
77
  });
81
- exports.ENVIRONMENT = parchment_1.Parchment.verse({
78
+ export const ENVIRONMENT = Parchment.verse({
82
79
  name: "ENVIRONMENT",
83
80
  type: "enum",
84
81
  isRequired: true,
85
82
  values: [
86
- arch_1.NodeEnvs.test,
87
- arch_1.NodeEnvs.development,
88
- arch_1.NodeEnvs.production,
89
- arch_1.NodeEnvs.homolog,
83
+ NodeEnvs.test,
84
+ NodeEnvs.development,
85
+ NodeEnvs.production,
86
+ NodeEnvs.homolog,
90
87
  ],
91
88
  description: "The current environment in which the application is running",
92
89
  });
@@ -1,14 +1,9 @@
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
- const node_fs_1 = __importDefault(require("node:fs"));
7
- const node_path_1 = __importDefault(require("node:path"));
8
- const arch_1 = require("@atlantjs/arch");
9
- const dotenv_1 = __importDefault(require("dotenv"));
10
- const envFilePath = node_path_1.default.join(__dirname, "..", "..", "..", "..", "..", "..", process.env.ENVIRONMENT === arch_1.NodeEnvs.test ? ".env.test" : ".env");
11
- if (!node_fs_1.default.existsSync(envFilePath)) {
12
- console.error(`The ${process.env.ENVIRONMENT === arch_1.NodeEnvs.test ? ".env.test" : ".env"} file is missing with the variables and their values`);
1
+ import * as fs from "node:fs";
2
+ import * as path from "node:path";
3
+ import { NodeEnvs } from "@atlantjs/arch";
4
+ import * as dotenv from "dotenv";
5
+ const envFilePath = path.join(__dirname, "..", "..", "..", "..", "..", "..", process.env.ENVIRONMENT === NodeEnvs.test ? ".env.test" : ".env");
6
+ if (!fs.existsSync(envFilePath)) {
7
+ console.error(`The ${process.env.ENVIRONMENT === NodeEnvs.test ? ".env.test" : ".env"} file is missing with the variables and their values`);
13
8
  }
14
- dotenv_1.default.config({ path: envFilePath });
9
+ dotenv.config({ path: envFilePath });