@atlantjs/arch 3.2.21 → 4.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 (83) hide show
  1. package/@tool-box/utils/secret-manager/cache.d.ts +8 -0
  2. package/@tool-box/utils/secret-manager/cache.js +29 -0
  3. package/@tool-box/utils/secret-manager/clients/aws-client.d.ts +10 -0
  4. package/@tool-box/utils/secret-manager/clients/aws-client.js +52 -0
  5. package/@tool-box/utils/secret-manager/clients/client.d.ts +4 -0
  6. package/@tool-box/utils/secret-manager/clients/null-client.d.ts +5 -0
  7. package/@tool-box/utils/secret-manager/clients/null-client.js +12 -0
  8. package/@tool-box/utils/secret-manager/secret-manager-options.d.ts +3 -0
  9. package/@tool-box/utils/secret-manager/secret-manager-options.js +2 -0
  10. package/@tool-box/utils/secret-manager/secret-manager.d.ts +11 -0
  11. package/@tool-box/utils/secret-manager/secret-manager.js +34 -0
  12. package/arch/modules/application/env/env-vars.d.ts +3 -0
  13. package/{setup → arch/modules/application}/env/env-vars.js +2 -11
  14. package/{setup → arch/modules/application}/env/load-envs.js +2 -2
  15. package/arch/modules/application/failures/failure.abstract.js +1 -1
  16. package/index.d.ts +1 -19
  17. package/index.js +3 -44
  18. package/package.json +11 -2
  19. package/tsconfig.tsbuildinfo +1 -1
  20. package/arch/modules/application/databases/database.config.d.ts +0 -23
  21. package/arch/modules/application/databases/database.config.js +0 -43
  22. package/arch/modules/application/databases/database.helper.abstract.commit.failure.d.ts +0 -4
  23. package/arch/modules/application/databases/database.helper.abstract.commit.failure.js +0 -14
  24. package/arch/modules/application/databases/database.helper.abstract.d.ts +0 -25
  25. package/arch/modules/application/databases/database.helper.abstract.get-manager.failure.d.ts +0 -4
  26. package/arch/modules/application/databases/database.helper.abstract.get-manager.failure.js +0 -14
  27. package/arch/modules/application/databases/database.helper.abstract.js +0 -106
  28. package/arch/modules/application/databases/database.helper.abstract.rollback.failure.d.ts +0 -4
  29. package/arch/modules/application/databases/database.helper.abstract.rollback.failure.js +0 -14
  30. package/arch/modules/application/injections.abstract.d.ts +0 -11
  31. package/arch/modules/application/injections.abstract.js +0 -45
  32. package/arch/modules/application/injections.abstract.type.d.ts +0 -21
  33. package/arch/modules/domain/entities/entity-backend.abstract.d.ts +0 -9
  34. package/arch/modules/domain/entities/entity-backend.abstract.js +0 -11
  35. package/arch/modules/domain/middlewares/middleware.handler.abstract.d.ts +0 -4
  36. package/arch/modules/domain/middlewares/middleware.handler.abstract.js +0 -6
  37. package/arch/modules/domain/providers/provider.abstract.d.ts +0 -2
  38. package/arch/modules/domain/providers/provider.abstract.js +0 -6
  39. package/arch/modules/domain/repositories/repository.abstract.d.ts +0 -2
  40. package/arch/modules/domain/repositories/repository.abstract.js +0 -6
  41. package/arch/modules/domain/services/service.abstract.d.ts +0 -2
  42. package/arch/modules/domain/services/service.abstract.js +0 -6
  43. package/arch/modules/domain/usecases/usecase.abstract.d.ts +0 -4
  44. package/arch/modules/domain/usecases/usecase.abstract.js +0 -6
  45. package/arch/modules/infrastructure/controllers/controller.abstract.d.ts +0 -10
  46. package/arch/modules/infrastructure/controllers/controller.abstract.js +0 -23
  47. package/arch/modules/infrastructure/controllers/payloads/payload.abstract.d.ts +0 -2
  48. package/arch/modules/infrastructure/controllers/payloads/payload.abstract.js +0 -6
  49. package/arch/modules/infrastructure/controllers/payloads/validators/validator.abstract.d.ts +0 -2
  50. package/arch/modules/infrastructure/controllers/payloads/validators/validator.abstract.js +0 -6
  51. package/arch/modules/infrastructure/controllers/responses/response.abstract.d.ts +0 -4
  52. package/arch/modules/infrastructure/controllers/responses/response.abstract.js +0 -6
  53. package/arch/modules/infrastructure/repositories/schemas/schema.abstract.d.ts +0 -7
  54. package/arch/modules/infrastructure/repositories/schemas/schema.abstract.js +0 -43
  55. package/arch/modules/infrastructure/services/http-client.abstract.d.ts +0 -0
  56. package/arch/modules/infrastructure/services/http-client.abstract.js +0 -1
  57. package/arch/modules/infrastructure/services/payloads/service.payload.abstract.d.ts +0 -0
  58. package/arch/modules/infrastructure/services/payloads/service.payload.abstract.js +0 -1
  59. package/arch/modules/infrastructure/services/responses/service.response.abstract.d.ts +0 -0
  60. package/arch/modules/infrastructure/services/responses/service.response.abstract.js +0 -1
  61. package/setup/dependency-injections/container.d.ts +0 -11
  62. package/setup/dependency-injections/container.js +0 -14
  63. package/setup/dependency-injections/default-container.d.ts +0 -4
  64. package/setup/dependency-injections/default-container.js +0 -20
  65. package/setup/dependency-injections/di-container.abstract.d.ts +0 -30
  66. package/setup/dependency-injections/di-container.abstract.js +0 -45
  67. package/setup/dependency-injections/di-container.d.ts +0 -3
  68. package/setup/dependency-injections/di-container.js +0 -6
  69. package/setup/dependency-injections/index.d.ts +0 -3
  70. package/setup/dependency-injections/index.js +0 -15
  71. package/setup/env/env-vars.d.ts +0 -7
  72. package/setup/index.d.ts +0 -18
  73. package/setup/index.js +0 -48
  74. package/setup/server/body-parser-middleware.d.ts +0 -9
  75. package/setup/server/body-parser-middleware.js +0 -31
  76. package/setup/server/cors-middleware.d.ts +0 -10
  77. package/setup/server/cors-middleware.js +0 -38
  78. package/setup/server/default-error-handler-middleware.d.ts +0 -8
  79. package/setup/server/default-error-handler-middleware.js +0 -45
  80. package/setup/server/server.d.ts +0 -6
  81. package/setup/server/server.js +0 -61
  82. /package/{arch/modules/application/injections.abstract.type.js → @tool-box/utils/secret-manager/clients/client.js} +0 -0
  83. /package/{setup → arch/modules/application}/env/load-envs.d.ts +0 -0
@@ -1,23 +0,0 @@
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
- schema: string;
10
- synchronize: boolean;
11
- entities: string[];
12
- migrations: string[];
13
- region?: string;
14
- secretArn?: string;
15
- resourceArn?: string;
16
- }
17
- export declare abstract class DatabaseConfigAbstract {
18
- private readonly props;
19
- configs: DataSource;
20
- private readonly productionOrHomologConfigs;
21
- constructor(props: DatabaseConfigProps);
22
- }
23
- export {};
@@ -1,43 +0,0 @@
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 url_abstract_1 = require("../../domain/entities/url.abstract");
7
- const env_vars_1 = require("../../../../setup/env/env-vars");
8
- class DatabaseConfigAbstract {
9
- constructor(props) {
10
- this.props = props;
11
- this.productionOrHomologConfigs = {
12
- ssl: true,
13
- extra: {
14
- ssl: {
15
- rejectUnauthorized: false,
16
- },
17
- },
18
- };
19
- const baseConfig = {
20
- type: this.props.type,
21
- host: this.props.host,
22
- port: this.props.port,
23
- username: this.props.username,
24
- password: this.props.password,
25
- database: this.props.database,
26
- synchronize: guardian_1.Guardian.isFalsy((0, env_vars_1.isProdOrHomolog)()),
27
- entities: [`${__dirname}/../../**/*.schema{.ts,.js}`],
28
- migrations: ["./migrations/*.ts"],
29
- };
30
- if (guardian_1.Guardian.isEqual(this.props.type, "aurora-mysql")) {
31
- Object.assign(baseConfig, {
32
- region: this.props.region ?? "",
33
- secretArn: this.props.secretArn ?? "",
34
- resourceArn: this.props.resourceArn ?? "",
35
- });
36
- }
37
- if (new url_abstract_1.UrlAbstract(this.props.host).has("@")) {
38
- Object.assign(baseConfig, this.productionOrHomologConfigs);
39
- }
40
- this.configs = new typeorm_1.DataSource(baseConfig);
41
- }
42
- }
43
- exports.DatabaseConfigAbstract = DatabaseConfigAbstract;
@@ -1,4 +0,0 @@
1
- import { FailureAbstract } from "../failures/failure.abstract";
2
- export declare class DatabaseHelperAbstractCommitFailure extends FailureAbstract {
3
- constructor(error?: any);
4
- }
@@ -1,14 +0,0 @@
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. Run '.openTransaction()' before commit",
10
- error,
11
- });
12
- }
13
- }
14
- exports.DatabaseHelperAbstractCommitFailure = DatabaseHelperAbstractCommitFailure;
@@ -1,25 +0,0 @@
1
- import { DataSource, ObjectLiteral } from "typeorm";
2
- import { FindOptionsRelations } from "typeorm";
3
- import { Newable } from "../../../../@tool-box/utils/datatypes/generic-types";
4
- import { Optional } from "../../../../@tool-box/utils/ducts/optional-type";
5
- import { Return } from "../../../../@tool-box/utils/ducts/return-type";
6
- import { DatabaseConfigAbstract } from "./database.config";
7
- import { FailureAbstract } from "../failures/failure.abstract";
8
- import { EntityBackendAbstract } from "../../domain/entities/entity-backend.abstract";
9
- export declare abstract class DatabaseHelperAbstract {
10
- private database;
11
- private queryRunner;
12
- connect(db: DatabaseConfigAbstract): Promise<DataSource>;
13
- disconnect(): Promise<void>;
14
- read<T extends Newable<ObjectLiteral>, E extends ObjectLiteral>(schema: T, condition: {
15
- [K in keyof InstanceType<T>]?: InstanceType<T>[K];
16
- }, relations: FindOptionsRelations<E>): Promise<Return<Optional<InstanceType<T>[]>, FailureAbstract>>;
17
- write<T extends Newable<ObjectLiteral>>(schema: T, sortedEntities: EntityBackendAbstract[]): Promise<Return<undefined, undefined>>;
18
- delete<T extends Newable<ObjectLiteral>>(entity: T, condition: {
19
- [K in keyof InstanceType<T>]?: InstanceType<T>[K];
20
- }): Promise<Return<undefined, undefined>>;
21
- private getManager;
22
- private openTransaction;
23
- private commit;
24
- private rollback;
25
- }
@@ -1,4 +0,0 @@
1
- import { FailureAbstract } from "../failures/failure.abstract";
2
- export declare class DatabaseHelperAbstractGetManagerFailure extends FailureAbstract {
3
- constructor(error?: any);
4
- }
@@ -1,14 +0,0 @@
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,106 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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");
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, condition, relations) {
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({
31
- where: condition,
32
- relations,
33
- })));
34
- return (0, return_type_1.Success)(registryPacked);
35
- }
36
- async write(schema, sortedEntities) {
37
- try {
38
- const client = await this.openTransaction();
39
- const repository = client.getRepository(schema);
40
- sortedEntities.forEach(async (sortedEntity) => {
41
- if (guardian_1.Guardian.isUndefined(sortedEntity.toPersist) ||
42
- guardian_1.Guardian.isUndefined(sortedEntity.id)) {
43
- return (0, return_type_1.Failure)();
44
- }
45
- const registryPacked = (0, optional_type_1.Optional)(await repository.findOne({
46
- where: { id: sortedEntity.id.toString() },
47
- }));
48
- if (registryPacked.hasNothing()) {
49
- await repository.save(sortedEntity.toPersist());
50
- }
51
- else {
52
- await repository.update({ id: sortedEntity.id.toString() }, sortedEntity.toPersist());
53
- }
54
- });
55
- await this.commit();
56
- return (0, return_type_1.Success)();
57
- }
58
- catch {
59
- await this.rollback();
60
- return (0, return_type_1.Failure)();
61
- }
62
- }
63
- async delete(entity, condition) {
64
- const client = await this.openTransaction();
65
- const repository = client.getRepository(entity);
66
- const registryPacked = (0, optional_type_1.Optional)(await repository.find({ where: condition }));
67
- if (registryPacked.hasNothing()) {
68
- return (0, return_type_1.Failure)();
69
- }
70
- repository.delete(condition);
71
- return (0, return_type_1.Success)();
72
- }
73
- getManager() {
74
- if (this.database.hasNothing()) {
75
- return (0, return_type_1.Failure)(new database_helper_abstract_get_manager_failure_1.DatabaseHelperAbstractGetManagerFailure());
76
- }
77
- return (0, return_type_1.Success)(this.database.unpack().manager);
78
- }
79
- async openTransaction() {
80
- if (this.queryRunner.hasNothing()) {
81
- this.queryRunner = (0, optional_type_1.Optional)(this.database.unpack().createQueryRunner());
82
- await this.queryRunner.unpack().connect();
83
- await this.queryRunner.unpack().startTransaction();
84
- }
85
- return this.queryRunner.unpack().manager;
86
- }
87
- async commit() {
88
- if (this.queryRunner.hasNothing()) {
89
- return (0, return_type_1.Failure)(new database_helper_abstract_commit_failure_1.DatabaseHelperAbstractCommitFailure());
90
- }
91
- await this.queryRunner.unpack().commitTransaction();
92
- await this.queryRunner.unpack().release();
93
- this.queryRunner = optional_type_1.Nothing;
94
- return (0, return_type_1.Success)();
95
- }
96
- async rollback() {
97
- if (this.queryRunner.hasNothing()) {
98
- return (0, return_type_1.Failure)(new database_helper_abstract_rollback_failure_1.DatabaseHelperAbstractRollbackFailure());
99
- }
100
- await this.queryRunner.unpack().rollbackTransaction();
101
- await this.queryRunner.unpack().release();
102
- this.queryRunner = optional_type_1.Nothing;
103
- return (0, return_type_1.Success)();
104
- }
105
- }
106
- exports.DatabaseHelperAbstract = DatabaseHelperAbstract;
@@ -1,4 +0,0 @@
1
- import { FailureAbstract } from "../failures/failure.abstract";
2
- export declare class DatabaseHelperAbstractRollbackFailure extends FailureAbstract {
3
- constructor(error?: any);
4
- }
@@ -1,14 +0,0 @@
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. Run '.openTransaction()' before commit",
10
- error,
11
- });
12
- }
13
- }
14
- exports.DatabaseHelperAbstractRollbackFailure = DatabaseHelperAbstractRollbackFailure;
@@ -1,11 +0,0 @@
1
- import { Injections } from "./injections.abstract.type";
2
- export declare abstract class InjectionsAbstract {
3
- protected abstract _injections: Injections;
4
- constructor();
5
- private injectControllers;
6
- private injectMiddlewares;
7
- private injectUsecases;
8
- private injectServices;
9
- private injectRepositories;
10
- private injectProviders;
11
- }
@@ -1,45 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectionsAbstract = void 0;
4
- const dependency_injections_1 = require("../../../setup/dependency-injections");
5
- class InjectionsAbstract {
6
- constructor() {
7
- this.injectControllers();
8
- this.injectMiddlewares();
9
- this.injectUsecases();
10
- this.injectServices();
11
- this.injectRepositories();
12
- this.injectProviders();
13
- }
14
- injectControllers() {
15
- this._injections.controllers?.map((controller) => {
16
- dependency_injections_1.diContainer.bind(controller).toSelf();
17
- });
18
- }
19
- injectMiddlewares() {
20
- this._injections.middlewares?.map((middleware) => {
21
- dependency_injections_1.diContainer.bind(middleware).toSelf();
22
- });
23
- }
24
- injectUsecases() {
25
- this._injections.usecases?.map((usecase) => {
26
- dependency_injections_1.diContainer.bind(usecase.ref).to(usecase.target);
27
- });
28
- }
29
- injectServices() {
30
- this._injections.services?.map((service) => {
31
- dependency_injections_1.diContainer.bind(service.ref).to(service.target);
32
- });
33
- }
34
- injectRepositories() {
35
- this._injections.repositories?.map((repository) => {
36
- dependency_injections_1.diContainer.bind(repository.ref).to(repository.target);
37
- });
38
- }
39
- injectProviders() {
40
- this._injections.providers?.map((provider) => {
41
- dependency_injections_1.diContainer.bind(provider.ref).to(provider.target);
42
- });
43
- }
44
- }
45
- exports.InjectionsAbstract = InjectionsAbstract;
@@ -1,21 +0,0 @@
1
- import { interfaces } from "inversify";
2
- import { Newable } from "../../../@tool-box/utils/datatypes/generic-types";
3
- import { MiddlewareHandlerAbstract } from "../domain/middlewares/middleware.handler.abstract";
4
- import { RepositoryAbstract } from "../domain/repositories/repository.abstract";
5
- import { ServiceAbstract } from "../domain/services/service.abstract";
6
- import { UsecaseAbstract } from "../domain/usecases/usecase.abstract";
7
- import { ControllerAbstract } from "../infrastructure/controllers/controller.abstract";
8
- type ServiceIdentifier<T> = interfaces.ServiceIdentifier<T>;
9
- interface BindTo<T> {
10
- ref: ServiceIdentifier<unknown>;
11
- target: Newable<T>;
12
- }
13
- export interface Injections {
14
- controllers?: ServiceIdentifier<ControllerAbstract>[];
15
- middlewares?: ServiceIdentifier<MiddlewareHandlerAbstract>[];
16
- usecases?: BindTo<UsecaseAbstract>[];
17
- services?: BindTo<ServiceAbstract>[];
18
- repositories?: BindTo<RepositoryAbstract>[];
19
- providers?: BindTo<RepositoryAbstract>[];
20
- }
21
- export {};
@@ -1,9 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
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;
@@ -1,4 +0,0 @@
1
- import { Return } from "../../../../@tool-box/utils/ducts/return-type";
2
- export declare abstract class MiddlewareHandlerAbstract {
3
- protected abstract use(...args: unknown[]): Promise<Return<any, any>>;
4
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MiddlewareHandlerAbstract = void 0;
4
- class MiddlewareHandlerAbstract {
5
- }
6
- exports.MiddlewareHandlerAbstract = MiddlewareHandlerAbstract;
@@ -1,2 +0,0 @@
1
- export declare abstract class ProviderAbstract {
2
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ProviderAbstract = void 0;
4
- class ProviderAbstract {
5
- }
6
- exports.ProviderAbstract = ProviderAbstract;
@@ -1,2 +0,0 @@
1
- export declare abstract class RepositoryAbstract {
2
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.RepositoryAbstract = void 0;
4
- class RepositoryAbstract {
5
- }
6
- exports.RepositoryAbstract = RepositoryAbstract;
@@ -1,2 +0,0 @@
1
- export declare abstract class ServiceAbstract {
2
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServiceAbstract = void 0;
4
- class ServiceAbstract {
5
- }
6
- exports.ServiceAbstract = ServiceAbstract;
@@ -1,4 +0,0 @@
1
- import { Return } from "../../../../@tool-box/utils/ducts/return-type";
2
- export declare abstract class UsecaseAbstract {
3
- abstract execute(...args: unknown[]): Promise<Return<unknown, unknown>>;
4
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UsecaseAbstract = void 0;
4
- class UsecaseAbstract {
5
- }
6
- exports.UsecaseAbstract = UsecaseAbstract;
@@ -1,10 +0,0 @@
1
- import { Response } from "express";
2
- import { FailureAbstract } from "../../application/failures/failure.abstract";
3
- import { HttpStatusCodes } from "../../domain/enums/http-status-codes.enum";
4
- import { ResponseAbstract } from "./responses/response.abstract";
5
- export declare abstract class ControllerAbstract {
6
- protected abstract readonly response: Response;
7
- abstract handler(...args: unknown[]): Promise<Response>;
8
- protected onSuccess<Payload extends ResponseAbstract>(payload?: Payload, httpStatusCode?: HttpStatusCodes): Response;
9
- protected onFailure(failure: FailureAbstract, httpStatusCode?: HttpStatusCodes): Response;
10
- }
@@ -1,23 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.ControllerAbstract = void 0;
10
- const routing_controllers_1 = require("routing-controllers");
11
- const http_status_codes_enum_1 = require("../../domain/enums/http-status-codes.enum");
12
- let ControllerAbstract = class ControllerAbstract {
13
- onSuccess(payload, httpStatusCode = http_status_codes_enum_1.HttpStatusCodes.OK) {
14
- return this.response.status(httpStatusCode).send(payload?.toPlain() ?? {});
15
- }
16
- onFailure(failure, httpStatusCode = http_status_codes_enum_1.HttpStatusCodes.BAD_REQUEST) {
17
- return this.response.status(httpStatusCode).send(failure.toPlain());
18
- }
19
- };
20
- exports.ControllerAbstract = ControllerAbstract;
21
- exports.ControllerAbstract = ControllerAbstract = __decorate([
22
- (0, routing_controllers_1.JsonController)()
23
- ], ControllerAbstract);
@@ -1,2 +0,0 @@
1
- export declare abstract class PayloadAbstract {
2
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PayloadAbstract = void 0;
4
- class PayloadAbstract {
5
- }
6
- exports.PayloadAbstract = PayloadAbstract;
@@ -1,2 +0,0 @@
1
- export declare abstract class ValidatorAbstract {
2
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValidatorAbstract = void 0;
4
- class ValidatorAbstract {
5
- }
6
- exports.ValidatorAbstract = ValidatorAbstract;
@@ -1,4 +0,0 @@
1
- import { ObjectType } from "../../../../../@tool-box/utils/datatypes/generic-types";
2
- export declare abstract class ResponseAbstract {
3
- abstract toPlain(): ObjectType;
4
- }
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResponseAbstract = void 0;
4
- class ResponseAbstract {
5
- }
6
- exports.ResponseAbstract = ResponseAbstract;
@@ -1,7 +0,0 @@
1
- import { BaseEntity } from "typeorm";
2
- export declare abstract class SchemaAbstract extends BaseEntity {
3
- createdAt: Date;
4
- updatedAt: Date;
5
- protected beforeInsert(): void;
6
- protected beforeUpdate(): void;
7
- }
@@ -1,43 +0,0 @@
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);
@@ -1,11 +0,0 @@
1
- import { Newable, Abstract } from "../../@tool-box/utils/datatypes/generic-types";
2
- type ServiceIdentifier<T = unknown> = Newable<T> | Abstract<T>;
3
- interface ContainerStorage {
4
- get<T>(type: ServiceIdentifier<T>): T;
5
- }
6
- export declare class Container {
7
- private static storage;
8
- static useStorage(newStorage: ContainerStorage): void;
9
- static get<T>(identifier: ServiceIdentifier<T>): T;
10
- }
11
- export {};
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Container = void 0;
4
- const default_container_1 = require("./default-container");
5
- class Container {
6
- static useStorage(newStorage) {
7
- Container.storage = newStorage;
8
- }
9
- static get(identifier) {
10
- return Container.storage.get(identifier);
11
- }
12
- }
13
- exports.Container = Container;
14
- Container.storage = new default_container_1.DefaultContainer();
@@ -1,4 +0,0 @@
1
- export declare class DefaultContainer {
2
- private readonly instances;
3
- get<T>(type: new (...args: never[]) => T): T;
4
- }
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DefaultContainer = void 0;
4
- class DefaultContainer {
5
- constructor() {
6
- this.instances = [];
7
- }
8
- get(type) {
9
- let instance = this.instances.find((instance) => instance.type === type);
10
- if (!instance) {
11
- instance = {
12
- type,
13
- object: new type(),
14
- };
15
- this.instances.push(instance);
16
- }
17
- return instance.object;
18
- }
19
- }
20
- exports.DefaultContainer = DefaultContainer;