@atlantjs/arch 3.1.16 → 3.2.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.
@@ -3,7 +3,7 @@ import { Optional } from "../../../../@tool-box/utils/ducts/optional-type";
3
3
  import { Return } from "../../../../@tool-box/utils/ducts/return-type";
4
4
  import { DatabaseConfigAbstract } from "./database.config";
5
5
  import { FailureAbstract } from "../failures/failure.abstract";
6
- import { EntityAbstract } from "../../../../index";
6
+ import { EntityBackendAbstract } from "../../domain/entities/entity-backend.abstract";
7
7
  type SchemaAbstract = EntityTarget<ObjectLiteral>;
8
8
  export declare abstract class DatabaseHelperAbstract {
9
9
  private database;
@@ -11,7 +11,7 @@ export declare abstract class DatabaseHelperAbstract {
11
11
  connect(db: DatabaseConfigAbstract): Promise<DataSource>;
12
12
  disconnect(): Promise<void>;
13
13
  read<T extends SchemaAbstract, E extends ObjectLiteral>(schema: T, relations: FindOptionsRelations<E>, condition: FindOptionsWhere<T>[] | FindOptionsWhere<T>): Promise<Return<Optional<ObjectLiteral[]>, FailureAbstract>>;
14
- write<T extends SchemaAbstract>(schema: T, sortedEntities: EntityAbstract[]): Promise<any>;
14
+ write<T extends SchemaAbstract>(schema: T, sortedEntities: EntityBackendAbstract[]): Promise<any>;
15
15
  delete<T extends SchemaAbstract>(entity: T, condition: FindOptionsWhere<T>[] | FindOptionsWhere<T>): Promise<Return<undefined, undefined>>;
16
16
  private getManager;
17
17
  private openTransaction;
@@ -36,17 +36,17 @@ class DatabaseHelperAbstract {
36
36
  const repository = client.getRepository(schema);
37
37
  sortedEntities.forEach(async (sortedEntity) => {
38
38
  if (guardian_1.Guardian.isUndefined(sortedEntity.toPersist) ||
39
- guardian_1.Guardian.isUndefined(sortedEntity.getId)) {
39
+ guardian_1.Guardian.isUndefined(sortedEntity.id)) {
40
40
  return (0, return_type_1.Failure)();
41
41
  }
42
42
  const registryPacked = (0, optional_type_1.Optional)(await repository.findOne({
43
- where: { id: sortedEntity.getId().toString() },
43
+ where: { id: sortedEntity.id.toString() },
44
44
  }));
45
45
  if (registryPacked.hasNothing()) {
46
46
  await repository.save(sortedEntity.toPersist());
47
47
  }
48
48
  else {
49
- await repository.update({ id: sortedEntity.getId().toString() }, sortedEntity.toPersist());
49
+ await repository.update({ id: sortedEntity.id.toString() }, sortedEntity.toPersist());
50
50
  }
51
51
  });
52
52
  await this.commit();
@@ -0,0 +1,9 @@
1
+ import { SolidAbstract } from "./solid.abstract";
2
+ import { UuidAbstract } from "./uuid.abstract";
3
+ import { SchemaAbstract } from "../../infrastructure/repositories/schemas/schema.abstract";
4
+ export declare abstract class EntityBackendAbstract extends SolidAbstract {
5
+ protected _id: UuidAbstract;
6
+ constructor(_id: UuidAbstract);
7
+ abstract get id(): UuidAbstract;
8
+ abstract toPersist(): SchemaAbstract;
9
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityBackendAbstract = void 0;
4
+ const solid_abstract_1 = require("./solid.abstract");
5
+ class EntityBackendAbstract extends solid_abstract_1.SolidAbstract {
6
+ constructor(_id) {
7
+ super();
8
+ this._id = _id;
9
+ }
10
+ }
11
+ exports.EntityBackendAbstract = EntityBackendAbstract;
@@ -0,0 +1,6 @@
1
+ import { SolidAbstract } from "./solid.abstract";
2
+ import { UuidAbstract } from "./uuid.abstract";
3
+ export declare abstract class EntityFrontendAbstract extends SolidAbstract {
4
+ protected _id: UuidAbstract;
5
+ constructor(_id: UuidAbstract);
6
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityFrontendAbstract = void 0;
4
+ const solid_abstract_1 = require("./solid.abstract");
5
+ class EntityFrontendAbstract extends solid_abstract_1.SolidAbstract {
6
+ constructor(_id) {
7
+ super();
8
+ this._id = _id;
9
+ }
10
+ }
11
+ exports.EntityFrontendAbstract = EntityFrontendAbstract;
@@ -0,0 +1,3 @@
1
+ import { SolidAbstract } from "./solid.abstract";
2
+ export declare abstract class ValueObjectAbstract extends SolidAbstract {
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ValueObjectAbstract = void 0;
4
+ const solid_abstract_1 = require("./solid.abstract");
5
+ class ValueObjectAbstract extends solid_abstract_1.SolidAbstract {
6
+ }
7
+ exports.ValueObjectAbstract = ValueObjectAbstract;
@@ -1,9 +1,10 @@
1
1
  import { BaseEntity } from "typeorm";
2
- import { EntityAbstract } from "../../../domain/entities/entity.abstract";
2
+ import { EntityBackendAbstract } from "../../../domain/entities/entity-backend.abstract";
3
+ import { EntityFrontendAbstract } from "../../../domain/entities/entity-frontend.abstract";
3
4
  export declare abstract class SchemaAbstract extends BaseEntity {
4
5
  createdAt: Date;
5
6
  updatedAt: Date;
6
- abstract toEntity?(): EntityAbstract;
7
+ abstract toEntity?(): EntityBackendAbstract | EntityFrontendAbstract;
7
8
  protected beforeInsert(): void;
8
9
  protected beforeUpdate(): void;
9
10
  }
package/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import "#/utils/datatypes/string-utils";
2
2
  import "#/utils/datatypes/boolean-utils";
3
+ export { ValueObjectAbstract } from "./arch/modules/domain/entities/value-object.abstract";
3
4
  export { FailureBuilder } from "./@tool-box/tests/builders/failures/failure.builder";
4
5
  export { UuidBuilder } from "./@tool-box/tests/builders/generic/uuid.builder";
5
6
  export { CreateFakeUsecase } from "./@tool-box/tests/create-fake-usecase";
@@ -34,7 +35,8 @@ export { ControllerAbstract } from "./arch/modules/infrastructure/controllers/co
34
35
  export { PayloadAbstract } from "./arch/modules/infrastructure/controllers/payloads/payload.abstract";
35
36
  export { ValidatorAbstract } from "./arch/modules/infrastructure/controllers/payloads/validators/validator.abstract";
36
37
  export { ResponseAbstract } from "./arch/modules/infrastructure/controllers/responses/response.abstract";
37
- export { EntityAbstract } from "./arch/modules/domain/entities/entity.abstract";
38
+ export { EntityBackendAbstract } from "./arch/modules/domain/entities/entity-backend.abstract";
39
+ export { EntityFrontendAbstract } from "./arch/modules/domain/entities/entity-frontend.abstract";
38
40
  export { SchemaAbstract } from "./arch/modules/infrastructure/repositories/schemas/schema.abstract";
39
41
  export { ENVIRONMENT, IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256, APP_PORT, LOAD_MODULES, CORS_ALLOWED_ORIGINS, isProdOrHomolog, } from "./setup/env/env-vars";
40
42
  export { initializeApi } from "./setup";
package/index.js CHANGED
@@ -1,8 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.diContainer = exports.initializeApi = 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.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.initializeApi = exports.isProdOrHomolog = exports.CORS_ALLOWED_ORIGINS = exports.LOAD_MODULES = exports.APP_PORT = exports.IAM_MOVINGAPP_REALM_PUBLIC_KEY_RS256 = exports.ENVIRONMENT = exports.SchemaAbstract = exports.EntityFrontendAbstract = exports.EntityBackendAbstract = 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 = exports.ValueObjectAbstract = void 0;
4
4
  require("#/utils/datatypes/string-utils");
5
5
  require("#/utils/datatypes/boolean-utils");
6
+ var value_object_abstract_1 = require("./arch/modules/domain/entities/value-object.abstract");
7
+ Object.defineProperty(exports, "ValueObjectAbstract", { enumerable: true, get: function () { return value_object_abstract_1.ValueObjectAbstract; } });
6
8
  var failure_builder_1 = require("./@tool-box/tests/builders/failures/failure.builder");
7
9
  Object.defineProperty(exports, "FailureBuilder", { enumerable: true, get: function () { return failure_builder_1.FailureBuilder; } });
8
10
  var uuid_builder_1 = require("./@tool-box/tests/builders/generic/uuid.builder");
@@ -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/domain/entities/entity.abstract");
75
- Object.defineProperty(exports, "EntityAbstract", { enumerable: true, get: function () { return entity_abstract_1.EntityAbstract; } });
76
+ var entity_backend_abstract_1 = require("./arch/modules/domain/entities/entity-backend.abstract");
77
+ Object.defineProperty(exports, "EntityBackendAbstract", { enumerable: true, get: function () { return entity_backend_abstract_1.EntityBackendAbstract; } });
78
+ var entity_frontend_abstract_1 = require("./arch/modules/domain/entities/entity-frontend.abstract");
79
+ Object.defineProperty(exports, "EntityFrontendAbstract", { enumerable: true, get: function () { return entity_frontend_abstract_1.EntityFrontendAbstract; } });
76
80
  var schema_abstract_1 = require("./arch/modules/infrastructure/repositories/schemas/schema.abstract");
77
81
  Object.defineProperty(exports, "SchemaAbstract", { enumerable: true, get: function () { return schema_abstract_1.SchemaAbstract; } });
78
82
  var env_vars_1 = require("./setup/env/env-vars");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlantjs/arch",
3
- "version": "3.1.16",
3
+ "version": "3.2.0",
4
4
  "main": "index.js",
5
5
  "license": "UNLICENSED",
6
6
  "publishConfig": {