@koalarx/nest 3.0.3 → 3.0.5
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/core/backgroud-services/cron-service/cron-job.handler.base.d.ts +16 -0
- package/core/backgroud-services/cron-service/cron-job.handler.base.js +49 -0
- package/core/backgroud-services/event-service/event-class.d.ts +5 -0
- package/core/backgroud-services/event-service/event-class.js +11 -0
- package/core/backgroud-services/event-service/event-handler.base.d.ts +8 -0
- package/core/backgroud-services/event-service/event-handler.base.js +14 -0
- package/core/backgroud-services/event-service/event-is-trigger.d.ts +3 -0
- package/core/backgroud-services/event-service/event-is-trigger.js +7 -0
- package/core/backgroud-services/event-service/event-job.d.ts +13 -0
- package/core/backgroud-services/event-service/event-job.js +21 -0
- package/core/backgroud-services/event-service/event-queue.d.ts +17 -0
- package/core/backgroud-services/event-service/event-queue.js +62 -0
- package/core/constants/query-params.d.ts +6 -0
- package/core/constants/query-params.js +8 -0
- package/core/controllers/base.controller.d.ts +4 -0
- package/core/controllers/base.controller.js +6 -0
- package/core/controllers/controller.decorator.d.ts +2 -0
- package/core/controllers/controller.decorator.js +11 -0
- package/core/controllers/created-registre-response.base.d.ts +10 -0
- package/core/controllers/created-registre-response.base.js +35 -0
- package/core/controllers/list-response.base.d.ts +4 -0
- package/core/controllers/list-response.base.js +21 -0
- package/core/controllers/pagination.request.d.ts +10 -0
- package/core/controllers/pagination.request.js +56 -0
- package/core/controllers/router-config.base.d.ts +7 -0
- package/core/controllers/router-config.base.js +18 -0
- package/core/controllers/schemas/boolean.schema.d.ts +2 -0
- package/core/controllers/schemas/boolean.schema.js +12 -0
- package/core/controllers/schemas/document-number.schema.d.ts +1 -0
- package/core/controllers/schemas/document-number.schema.js +26 -0
- package/core/controllers/schemas/email.schema.d.ts +1 -0
- package/core/controllers/schemas/email.schema.js +13 -0
- package/core/controllers/schemas/list-query.schema.d.ts +17 -0
- package/core/controllers/schemas/list-query.schema.js +19 -0
- package/core/controllers/schemas/native-enum.schema.d.ts +7 -0
- package/core/controllers/schemas/native-enum.schema.js +28 -0
- package/core/controllers/schemas/set-mask-document-number.schema.d.ts +1 -0
- package/core/controllers/schemas/set-mask-document-number.schema.js +13 -0
- package/core/database/entity.base.d.ts +20 -0
- package/core/database/entity.base.js +71 -0
- package/core/database/entity.decorator.d.ts +13 -0
- package/core/database/entity.decorator.js +23 -0
- package/core/database/prisma-client-with-custom-transaction.interface.d.ts +8 -0
- package/core/database/prisma-client-with-custom-transaction.interface.js +2 -0
- package/core/database/prisma-resolver.d.ts +2 -0
- package/core/database/prisma-resolver.js +74 -0
- package/core/database/prisma-transactional-client.d.ts +11 -0
- package/core/database/prisma-transactional-client.js +25 -0
- package/core/database/prisma.service.d.ts +24 -0
- package/core/database/prisma.service.js +104 -0
- package/core/database/repository.base.d.ts +44 -0
- package/core/database/repository.base.js +360 -0
- package/core/dtos/pagination.dto.d.ts +9 -0
- package/core/dtos/pagination.dto.js +49 -0
- package/core/errors/bad-request.error.d.ts +5 -0
- package/core/errors/bad-request.error.js +10 -0
- package/core/errors/conflict.error.d.ts +4 -0
- package/core/errors/conflict.error.js +10 -0
- package/core/errors/error.base.d.ts +4 -0
- package/core/errors/error.base.js +11 -0
- package/core/errors/no-content.error.d.ts +5 -0
- package/core/errors/no-content.error.js +10 -0
- package/core/errors/not-allowed.error.d.ts +5 -0
- package/core/errors/not-allowed.error.js +10 -0
- package/core/errors/resource-not-found.error.d.ts +5 -0
- package/core/errors/resource-not-found.error.js +10 -0
- package/{src/core/errors/use-case-error.ts → core/errors/use-case-error.d.ts} +1 -1
- package/core/errors/use-case-error.js +2 -0
- package/core/errors/user-already-exist.error.d.ts +4 -0
- package/core/errors/user-already-exist.error.js +10 -0
- package/core/errors/wrong-credentials.error.d.ts +4 -0
- package/core/errors/wrong-credentials.error.js +10 -0
- package/core/health-check/health-check.controller.d.ts +5 -0
- package/core/health-check/health-check.controller.js +32 -0
- package/core/health-check/health-check.module.d.ts +2 -0
- package/core/health-check/health-check.module.js +19 -0
- package/core/index.d.ts +18 -0
- package/core/index.js +7 -0
- package/core/koala-app.d.ts +64 -0
- package/core/koala-app.js +252 -0
- package/core/koala-global-vars.d.ts +7 -0
- package/core/koala-global-vars.js +9 -0
- package/core/koala-nest-database.module.d.ts +16 -0
- package/core/koala-nest-database.module.js +52 -0
- package/core/koala-nest-http.module.d.ts +13 -0
- package/core/koala-nest-http.module.js +37 -0
- package/core/koala-nest.module.d.ts +17 -0
- package/core/koala-nest.module.js +66 -0
- package/core/mapping/auto-mapping-class-context.d.ts +16 -0
- package/core/mapping/auto-mapping-class-context.js +18 -0
- package/core/mapping/auto-mapping-context.d.ts +11 -0
- package/core/mapping/auto-mapping-context.js +24 -0
- package/core/mapping/auto-mapping-list.d.ts +27 -0
- package/core/mapping/auto-mapping-list.js +94 -0
- package/core/mapping/auto-mapping-profile.d.ts +3 -0
- package/core/mapping/auto-mapping-profile.js +6 -0
- package/core/mapping/auto-mapping.decorator.d.ts +9 -0
- package/core/mapping/auto-mapping.decorator.js +27 -0
- package/core/mapping/auto-mapping.module.d.ts +5 -0
- package/core/mapping/auto-mapping.module.js +29 -0
- package/core/mapping/auto-mapping.service.d.ts +14 -0
- package/core/mapping/auto-mapping.service.js +140 -0
- package/core/mapping/create-map.d.ts +3 -0
- package/core/mapping/create-map.js +7 -0
- package/core/mapping/for-member.d.ts +5 -0
- package/core/mapping/for-member.js +8 -0
- package/core/request-overflow/request-handler.base.d.ts +4 -0
- package/core/request-overflow/request-handler.base.js +6 -0
- package/core/request-overflow/request-result.d.ts +15 -0
- package/core/request-overflow/request-result.js +37 -0
- package/core/request-overflow/request-validator.base.d.ts +7 -0
- package/core/request-overflow/request-validator.base.js +26 -0
- package/core/security/strategies/api-key.strategy.d.ts +16 -0
- package/core/security/strategies/api-key.strategy.js +31 -0
- package/core/utils/assing-object.d.ts +5 -0
- package/core/utils/assing-object.js +6 -0
- package/core/utils/env.config.d.ts +6 -0
- package/core/utils/env.config.js +18 -0
- package/core/utils/filter-request-params.d.ts +13 -0
- package/core/utils/filter-request-params.js +22 -0
- package/core/utils/find-on-list.d.ts +2 -0
- package/core/utils/find-on-list.js +13 -0
- package/core/utils/get-type-by-prop.d.ts +2 -0
- package/core/utils/get-type-by-prop.js +11 -0
- package/core/utils/instanciate-class-with-dependencies-injection.d.ts +2 -0
- package/core/utils/instanciate-class-with-dependencies-injection.js +10 -0
- package/core/utils/interfaces/icomparable.d.ts +5 -0
- package/core/utils/interfaces/icomparable.js +6 -0
- package/core/utils/list.d.ts +39 -0
- package/core/utils/list.js +168 -0
- package/core/utils/promise-all.d.ts +7 -0
- package/core/utils/promise-all.js +19 -0
- package/core/utils/set-mask-document-number.d.ts +1 -0
- package/core/utils/set-mask-document-number.js +13 -0
- package/core/validators/file-validator.d.ts +27 -0
- package/core/validators/file-validator.js +94 -0
- package/decorators/api-exclude-endpoint-diff-develop.decorator.d.ts +1 -0
- package/decorators/api-exclude-endpoint-diff-develop.decorator.js +9 -0
- package/decorators/api-property-enum.decorator.d.ts +8 -0
- package/decorators/api-property-enum.decorator.js +21 -0
- package/decorators/api-property-only-develop.decorator.d.ts +2 -0
- package/decorators/api-property-only-develop.decorator.js +9 -0
- package/decorators/cookies.decorator.d.ts +1 -0
- package/decorators/cookies.decorator.js +8 -0
- package/decorators/is-public.decorator.d.ts +2 -0
- package/decorators/is-public.decorator.js +7 -0
- package/decorators/upload.decorator.d.ts +1 -0
- package/decorators/upload.decorator.js +18 -0
- package/env/env.d.ts +25 -0
- package/env/env.js +14 -0
- package/env/env.module.d.ts +2 -0
- package/env/env.module.js +20 -0
- package/env/env.service.d.ts +7 -0
- package/env/env.service.js +28 -0
- package/filters/domain-errors.filter.d.ts +18 -0
- package/filters/domain-errors.filter.js +92 -0
- package/filters/global-exception.filter.d.ts +8 -0
- package/filters/global-exception.filter.js +68 -0
- package/filters/prisma-validation-exception.filter.d.ts +10 -0
- package/filters/prisma-validation-exception.filter.js +82 -0
- package/filters/zod-errors.filter.d.ts +9 -0
- package/filters/zod-errors.filter.js +60 -0
- package/package.json +29 -2
- package/services/logging/ilogging.service.d.ts +16 -0
- package/services/logging/ilogging.service.js +6 -0
- package/services/logging/logging.service.d.ts +4 -0
- package/services/logging/logging.service.js +20 -0
- package/services/redis/iredis.service.d.ts +6 -0
- package/services/redis/iredis.service.js +6 -0
- package/services/redis/redis.service.d.ts +14 -0
- package/services/redis/redis.service.js +65 -0
- package/services/redlock/ired-lock.service.d.ts +4 -0
- package/services/redlock/ired-lock.service.js +6 -0
- package/services/redlock/red-lock.service.d.ts +9 -0
- package/services/redlock/red-lock.service.js +46 -0
- package/test/koala-app-test-dependencies.d.ts +10 -0
- package/test/koala-app-test-dependencies.js +13 -0
- package/test/koala-app-test.d.ts +22 -0
- package/test/koala-app-test.js +77 -0
- package/test/repositories/in-memory-base.repository.d.ts +17 -0
- package/test/repositories/in-memory-base.repository.js +65 -0
- package/test/services/fake-logging.service.d.ts +4 -0
- package/test/services/fake-logging.service.js +9 -0
- package/test/services/fake-red-lock.service.d.ts +5 -0
- package/test/services/fake-red-lock.service.js +11 -0
- package/test/utils/create-e2e-database.d.ts +2 -0
- package/test/utils/create-e2e-database.js +47 -0
- package/test/utils/drop-e2e-database.d.ts +2 -0
- package/test/utils/drop-e2e-database.js +33 -0
- package/test/utils/wait-for.d.ts +1 -0
- package/test/utils/wait-for.js +21 -0
- package/tsconfig.lib.tsbuildinfo +1 -0
- package/CHANGELOG.md +0 -27
- package/src/core/backgroud-services/cron-service/cron-job.handler.base.ts +0 -66
- package/src/core/backgroud-services/cron-service/cron-job.handler.spec.ts +0 -38
- package/src/core/backgroud-services/event-service/event-class.ts +0 -5
- package/src/core/backgroud-services/event-service/event-handler.base.ts +0 -17
- package/src/core/backgroud-services/event-service/event-is-trigger.ts +0 -3
- package/src/core/backgroud-services/event-service/event-job.ts +0 -28
- package/src/core/backgroud-services/event-service/event-queue.spec.ts +0 -47
- package/src/core/backgroud-services/event-service/event-queue.ts +0 -107
- package/src/core/constants/query-params.ts +0 -7
- package/src/core/controllers/base.controller.ts +0 -9
- package/src/core/controllers/controller.decorator.ts +0 -10
- package/src/core/controllers/created-registre-response.base.ts +0 -17
- package/src/core/controllers/list-response.base.ts +0 -8
- package/src/core/controllers/pagination.request.ts +0 -41
- package/src/core/controllers/router-config.base.ts +0 -14
- package/src/core/controllers/schemas/boolean.schema.ts +0 -10
- package/src/core/controllers/schemas/document-number.schema.ts +0 -23
- package/src/core/controllers/schemas/email.schema.ts +0 -13
- package/src/core/controllers/schemas/list-query.schema.ts +0 -17
- package/src/core/controllers/schemas/native-enum.schema.ts +0 -34
- package/src/core/controllers/schemas/set-mask-document-number.schema.ts +0 -13
- package/src/core/database/entity.base.ts +0 -95
- package/src/core/database/entity.decorator.spec.ts +0 -71
- package/src/core/database/entity.decorator.ts +0 -39
- package/src/core/database/prisma-client-with-custom-transaction.interface.ts +0 -13
- package/src/core/database/prisma-resolver.ts +0 -99
- package/src/core/database/prisma-transactional-client.ts +0 -43
- package/src/core/database/prisma.service.ts +0 -136
- package/src/core/database/repository.base.ts +0 -548
- package/src/core/dtos/pagination.dto.ts +0 -35
- package/src/core/errors/bad-request.error.ts +0 -8
- package/src/core/errors/conflict.error.ts +0 -7
- package/src/core/errors/error.base.ts +0 -5
- package/src/core/errors/no-content.error.ts +0 -8
- package/src/core/errors/not-allowed.error.ts +0 -8
- package/src/core/errors/resource-not-found.error.ts +0 -8
- package/src/core/errors/user-already-exist.error.ts +0 -7
- package/src/core/errors/wrong-credentials.error.ts +0 -7
- package/src/core/health-check/health-check.controller.ts +0 -13
- package/src/core/health-check/health-check.module.ts +0 -7
- package/src/core/index.ts +0 -56
- package/src/core/koala-app.ts +0 -379
- package/src/core/koala-global-vars.ts +0 -8
- package/src/core/koala-nest-database.module.ts +0 -65
- package/src/core/koala-nest-http.module.ts +0 -44
- package/src/core/koala-nest.module.ts +0 -67
- package/src/core/mapping/auto-mapping-class-context.ts +0 -28
- package/src/core/mapping/auto-mapping-context.ts +0 -26
- package/src/core/mapping/auto-mapping-list.ts +0 -154
- package/src/core/mapping/auto-mapping-profile.ts +0 -3
- package/src/core/mapping/auto-mapping.decorator.ts +0 -54
- package/src/core/mapping/auto-mapping.module.ts +0 -17
- package/src/core/mapping/auto-mapping.service.ts +0 -187
- package/src/core/mapping/create-map.ts +0 -11
- package/src/core/mapping/for-member.ts +0 -16
- package/src/core/request-overflow/request-handler.base.ts +0 -8
- package/src/core/request-overflow/request-result.spec.ts +0 -23
- package/src/core/request-overflow/request-result.ts +0 -41
- package/src/core/request-overflow/request-validator.base.ts +0 -33
- package/src/core/security/strategies/api-key.strategy.ts +0 -45
- package/src/core/utils/assing-object.ts +0 -9
- package/src/core/utils/env.config.ts +0 -17
- package/src/core/utils/filter-request-params.ts +0 -23
- package/src/core/utils/find-on-list.ts +0 -18
- package/src/core/utils/get-type-by-prop.ts +0 -9
- package/src/core/utils/instanciate-class-with-dependencies-injection.ts +0 -12
- package/src/core/utils/interfaces/icomparable.ts +0 -6
- package/src/core/utils/list.spec.ts +0 -81
- package/src/core/utils/list.ts +0 -223
- package/src/core/utils/promise-all.ts +0 -24
- package/src/core/utils/set-mask-document-number.ts +0 -13
- package/src/core/validators/file-validator.ts +0 -113
- package/src/decorators/api-exclude-endpoint-diff-develop.decorator.ts +0 -15
- package/src/decorators/api-property-enum.decorator.ts +0 -58
- package/src/decorators/api-property-only-develop.decorator.ts +0 -6
- package/src/decorators/cookies.decorator.ts +0 -8
- package/src/decorators/is-public.decorator.ts +0 -5
- package/src/decorators/upload.decorator.ts +0 -31
- package/src/env/env.module.ts +0 -8
- package/src/env/env.service.ts +0 -12
- package/src/env/env.ts +0 -14
- package/src/filters/domain-errors.filter.ts +0 -97
- package/src/filters/global-exception.filter.ts +0 -60
- package/src/filters/prisma-validation-exception.filter.ts +0 -73
- package/src/filters/zod-errors.filter.ts +0 -48
- package/src/services/logging/ilogging.service.ts +0 -17
- package/src/services/logging/logging.service.ts +0 -10
- package/src/services/redis/iredis.service.ts +0 -11
- package/src/services/redis/redis.service.ts +0 -70
- package/src/services/redlock/ired-lock.service.ts +0 -4
- package/src/services/redlock/red-lock.service.ts +0 -36
- package/src/test/koala-app-test-dependencies.ts +0 -15
- package/src/test/koala-app-test.ts +0 -103
- package/src/test/repositories/in-memory-base.repository.ts +0 -90
- package/src/test/services/fake-logging.service.ts +0 -7
- package/src/test/services/fake-red-lock.service.ts +0 -11
- package/src/test/utils/create-e2e-database.ts +0 -55
- package/src/test/utils/drop-e2e-database.ts +0 -36
- package/src/test/utils/wait-for.ts +0 -31
- package/tsconfig.lib.json +0 -11
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
2
|
+
import 'reflect-metadata';
|
|
3
|
+
import { IComparableId } from './interfaces/icomparable';
|
|
4
|
+
export type OrderDirection = 'asc' | 'desc';
|
|
5
|
+
export type ListActionType = 'added' | 'updated' | 'removed';
|
|
6
|
+
export interface ListProps<T> {
|
|
7
|
+
list?: T[];
|
|
8
|
+
entityType?: Type<T>;
|
|
9
|
+
}
|
|
10
|
+
export declare class List<T> {
|
|
11
|
+
readonly entityType?: Type<T> | undefined;
|
|
12
|
+
private _list;
|
|
13
|
+
private _addedItemsList;
|
|
14
|
+
private _updatedItemsList;
|
|
15
|
+
private _removedItemsList;
|
|
16
|
+
constructor(entityType?: Type<T> | undefined);
|
|
17
|
+
private indexOf;
|
|
18
|
+
private contains;
|
|
19
|
+
private mapInternalIdIfIsEmpty;
|
|
20
|
+
get length(): number;
|
|
21
|
+
orderBy(by: keyof T, direction?: OrderDirection): this;
|
|
22
|
+
first(): NonNullable<T> | null;
|
|
23
|
+
last(): NonNullable<T> | null;
|
|
24
|
+
findById(id: IComparableId): T | null;
|
|
25
|
+
findByValue(value: any): T | null;
|
|
26
|
+
setList(list: T[]): this;
|
|
27
|
+
add(item: T): this | undefined;
|
|
28
|
+
remove(item: T): this;
|
|
29
|
+
update(items: T[]): this;
|
|
30
|
+
clear(): this;
|
|
31
|
+
forEach(callback: (item: T, index: number) => void): this;
|
|
32
|
+
forEachAsync(callback: (item: T, index: number) => Promise<void>): Promise<this>;
|
|
33
|
+
map<U>(callback: (item: T, index: number) => U): List<U>;
|
|
34
|
+
mapAsync<U>(callback: (item: T, index: number) => Promise<U>): Promise<List<U>>;
|
|
35
|
+
filter(callback: (item: T, index: number) => boolean): List<T>;
|
|
36
|
+
filterAsync(callback: (item: T, index: number) => Promise<boolean>): Promise<List<T>>;
|
|
37
|
+
find(callback: (item: T, index: number) => boolean): T | null;
|
|
38
|
+
toArray(type?: ListActionType): T[];
|
|
39
|
+
}
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.List = void 0;
|
|
4
|
+
require("reflect-metadata");
|
|
5
|
+
const entity_base_1 = require("../database/entity.base");
|
|
6
|
+
class List {
|
|
7
|
+
entityType;
|
|
8
|
+
_list = [];
|
|
9
|
+
_addedItemsList = [];
|
|
10
|
+
_updatedItemsList = [];
|
|
11
|
+
_removedItemsList = [];
|
|
12
|
+
constructor(entityType) {
|
|
13
|
+
this.entityType = entityType;
|
|
14
|
+
}
|
|
15
|
+
indexOf(item, list = this._list) {
|
|
16
|
+
if (item instanceof entity_base_1.EntityBase) {
|
|
17
|
+
return list
|
|
18
|
+
.filter((i) => i instanceof entity_base_1.EntityBase)
|
|
19
|
+
.filter((i) => !!i._id)
|
|
20
|
+
.findIndex((i) => item._id === i._id ||
|
|
21
|
+
item.id === i.id);
|
|
22
|
+
}
|
|
23
|
+
return list
|
|
24
|
+
.filter((i) => !(i instanceof entity_base_1.EntityBase))
|
|
25
|
+
.findIndex((i) => item === i);
|
|
26
|
+
}
|
|
27
|
+
contains(item, list = this._list) {
|
|
28
|
+
return this.indexOf(item, list) > -1;
|
|
29
|
+
}
|
|
30
|
+
mapInternalIdIfIsEmpty(list) {
|
|
31
|
+
return list.map((item) => {
|
|
32
|
+
if (item instanceof entity_base_1.EntityBase && !item._id) {
|
|
33
|
+
item._id = item.id;
|
|
34
|
+
}
|
|
35
|
+
return item;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
get length() {
|
|
39
|
+
return this._list.length;
|
|
40
|
+
}
|
|
41
|
+
orderBy(by, direction = 'asc') {
|
|
42
|
+
const inverse = direction === 'desc';
|
|
43
|
+
this._list.sort((a, b) => {
|
|
44
|
+
if (typeof a !== 'string' && typeof b !== 'string') {
|
|
45
|
+
if ((!inverse && a[by] > b[by]) || (inverse && a[by] < b[by])) {
|
|
46
|
+
return 1;
|
|
47
|
+
}
|
|
48
|
+
else if ((!inverse && a[by] < b[by]) || (inverse && a[by] > b[by])) {
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return this;
|
|
60
|
+
}
|
|
61
|
+
first() {
|
|
62
|
+
return this._list[0] ?? null;
|
|
63
|
+
}
|
|
64
|
+
last() {
|
|
65
|
+
return this._list[this._list.length - 1] ?? null;
|
|
66
|
+
}
|
|
67
|
+
findById(id) {
|
|
68
|
+
return (this._list
|
|
69
|
+
.filter((item) => item instanceof entity_base_1.EntityBase)
|
|
70
|
+
.find((item) => item._id === id || item.id === id) ??
|
|
71
|
+
null);
|
|
72
|
+
}
|
|
73
|
+
findByValue(value) {
|
|
74
|
+
return this._list.find((item) => item === value) ?? null;
|
|
75
|
+
}
|
|
76
|
+
setList(list) {
|
|
77
|
+
this._list = this.mapInternalIdIfIsEmpty(list);
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
add(item) {
|
|
81
|
+
if (this.contains(item)) {
|
|
82
|
+
this._list[this.indexOf(item)] = item;
|
|
83
|
+
if (!this.contains(item, this._updatedItemsList)) {
|
|
84
|
+
this._updatedItemsList.push(item);
|
|
85
|
+
}
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
this._list.push(item);
|
|
89
|
+
this._addedItemsList.push(item);
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
remove(item) {
|
|
93
|
+
const index = this.indexOf(item);
|
|
94
|
+
if (index > -1) {
|
|
95
|
+
this._list.splice(index, 1);
|
|
96
|
+
if (!this.contains(item, this._removedItemsList)) {
|
|
97
|
+
this._removedItemsList.push(item);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return this;
|
|
101
|
+
}
|
|
102
|
+
update(items) {
|
|
103
|
+
items = this.mapInternalIdIfIsEmpty(items);
|
|
104
|
+
items.forEach((item) => this.add(item));
|
|
105
|
+
this._list
|
|
106
|
+
.filter((item) => !this.contains(item, items))
|
|
107
|
+
.forEach((item) => this.remove(item));
|
|
108
|
+
return this;
|
|
109
|
+
}
|
|
110
|
+
clear() {
|
|
111
|
+
this._addedItemsList = [];
|
|
112
|
+
this._updatedItemsList = [];
|
|
113
|
+
this._removedItemsList = this._list;
|
|
114
|
+
this._list = [];
|
|
115
|
+
return this;
|
|
116
|
+
}
|
|
117
|
+
forEach(callback) {
|
|
118
|
+
this._list.forEach(callback);
|
|
119
|
+
return this;
|
|
120
|
+
}
|
|
121
|
+
async forEachAsync(callback) {
|
|
122
|
+
return Promise.all(this._list.map(callback)).then(() => this);
|
|
123
|
+
}
|
|
124
|
+
map(callback) {
|
|
125
|
+
const mappedItems = this._list.map(callback);
|
|
126
|
+
const list = new List();
|
|
127
|
+
list.setList(mappedItems);
|
|
128
|
+
return list;
|
|
129
|
+
}
|
|
130
|
+
async mapAsync(callback) {
|
|
131
|
+
return Promise.all(this._list.map(callback)).then((mappedItems) => {
|
|
132
|
+
const mappedList = new List();
|
|
133
|
+
mappedList.setList(mappedItems);
|
|
134
|
+
return mappedList;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
filter(callback) {
|
|
138
|
+
const filteredItems = this._list.filter(callback);
|
|
139
|
+
const list = new List();
|
|
140
|
+
list.setList(filteredItems);
|
|
141
|
+
return list;
|
|
142
|
+
}
|
|
143
|
+
async filterAsync(callback) {
|
|
144
|
+
return Promise.all(this._list.filter(callback))
|
|
145
|
+
.then((list) => list.filter((item) => item))
|
|
146
|
+
.then((filteredItems) => {
|
|
147
|
+
const list = new List();
|
|
148
|
+
list.setList(filteredItems);
|
|
149
|
+
return list;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
find(callback) {
|
|
153
|
+
return this._list.find(callback) ?? null;
|
|
154
|
+
}
|
|
155
|
+
toArray(type) {
|
|
156
|
+
switch (type) {
|
|
157
|
+
case 'added':
|
|
158
|
+
return this._addedItemsList;
|
|
159
|
+
case 'updated':
|
|
160
|
+
return this._updatedItemsList;
|
|
161
|
+
case 'removed':
|
|
162
|
+
return this._removedItemsList;
|
|
163
|
+
default:
|
|
164
|
+
return this._list;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
exports.List = List;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Promises = void 0;
|
|
4
|
+
class Promises {
|
|
5
|
+
static async result(requests) {
|
|
6
|
+
const promises = [];
|
|
7
|
+
Object.values(requests).forEach((promise) => promises.push(promise));
|
|
8
|
+
return Promise.all(promises).then((result) => {
|
|
9
|
+
let currentIndex = 0;
|
|
10
|
+
const response = {};
|
|
11
|
+
Object.keys(requests).forEach((propName) => {
|
|
12
|
+
response[propName] = result[currentIndex];
|
|
13
|
+
currentIndex++;
|
|
14
|
+
});
|
|
15
|
+
return response;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.Promises = Promises;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function setMaskDocumentNumber(document?: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setMaskDocumentNumber = setMaskDocumentNumber;
|
|
4
|
+
const KlString_1 = require("@koalarx/utils/KlString");
|
|
5
|
+
function setMaskDocumentNumber(document) {
|
|
6
|
+
if (!document) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
const documentWithoutMask = document.replace(/[^0-9]/g, '');
|
|
10
|
+
return documentWithoutMask.length === 11
|
|
11
|
+
? (0, KlString_1.maskCpf)(documentWithoutMask)
|
|
12
|
+
: (0, KlString_1.maskCnpj)(documentWithoutMask);
|
|
13
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { FileValidator } from '@nestjs/common';
|
|
2
|
+
import { FileType } from '..';
|
|
3
|
+
type FileTypeInternal = FileType | FileType[] | Record<string, FileType[]>;
|
|
4
|
+
export declare class FileSizeValidator extends FileValidator {
|
|
5
|
+
private maxSizeBytes;
|
|
6
|
+
private multiple;
|
|
7
|
+
private errorFileName;
|
|
8
|
+
constructor(args: {
|
|
9
|
+
maxSizeBytes: number;
|
|
10
|
+
multiple: boolean;
|
|
11
|
+
});
|
|
12
|
+
isValid(file?: FileTypeInternal): Promise<boolean>;
|
|
13
|
+
buildErrorMessage(file: any): string;
|
|
14
|
+
}
|
|
15
|
+
export declare class FileTypeValidator extends FileValidator {
|
|
16
|
+
private multiple;
|
|
17
|
+
private errorFileName;
|
|
18
|
+
private filetype;
|
|
19
|
+
constructor(args: {
|
|
20
|
+
multiple: boolean;
|
|
21
|
+
filetype: RegExp | string;
|
|
22
|
+
});
|
|
23
|
+
isMimeTypeValid(file: FileType): boolean;
|
|
24
|
+
isValid(file?: FileTypeInternal): Promise<boolean>;
|
|
25
|
+
buildErrorMessage(file: any): string;
|
|
26
|
+
}
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileTypeValidator = exports.FileSizeValidator = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const runFileValidation = async (args) => {
|
|
6
|
+
if (args.multiple) {
|
|
7
|
+
const fileFields = Object.keys(args.file);
|
|
8
|
+
for (const field of fileFields) {
|
|
9
|
+
const fieldFile = args.file[field];
|
|
10
|
+
if (Array.isArray(fieldFile)) {
|
|
11
|
+
for (const f of fieldFile) {
|
|
12
|
+
if (!args.validator(f)) {
|
|
13
|
+
return { errorFileName: f.originalname, isValid: false };
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
if (!args.validator(fieldFile)) {
|
|
19
|
+
return { errorFileName: fieldFile.originalname, isValid: false };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return { isValid: true };
|
|
24
|
+
}
|
|
25
|
+
if (Array.isArray(args.file)) {
|
|
26
|
+
for (const f of args.file) {
|
|
27
|
+
if (!args.validator(f)) {
|
|
28
|
+
return { errorFileName: f.originalname, isValid: false };
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { isValid: true };
|
|
32
|
+
}
|
|
33
|
+
if (args.validator(args.file)) {
|
|
34
|
+
return { errorFileName: args.file.originalname, isValid: false };
|
|
35
|
+
}
|
|
36
|
+
return { isValid: true };
|
|
37
|
+
};
|
|
38
|
+
class FileSizeValidator extends common_1.FileValidator {
|
|
39
|
+
maxSizeBytes;
|
|
40
|
+
multiple;
|
|
41
|
+
errorFileName;
|
|
42
|
+
constructor(args) {
|
|
43
|
+
super({});
|
|
44
|
+
this.maxSizeBytes = args.maxSizeBytes;
|
|
45
|
+
this.multiple = args.multiple;
|
|
46
|
+
}
|
|
47
|
+
async isValid(file) {
|
|
48
|
+
if (!file) {
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
const result = await runFileValidation({
|
|
52
|
+
file,
|
|
53
|
+
multiple: this.multiple,
|
|
54
|
+
validator: (f) => f.size < this.maxSizeBytes,
|
|
55
|
+
});
|
|
56
|
+
this.errorFileName = result.errorFileName ?? '';
|
|
57
|
+
return result.isValid;
|
|
58
|
+
}
|
|
59
|
+
buildErrorMessage(file) {
|
|
60
|
+
return (`file ${this.errorFileName || ''} exceeded the size limit ` +
|
|
61
|
+
parseFloat((this.maxSizeBytes / 1024 / 1024).toFixed(2)) +
|
|
62
|
+
'MB');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.FileSizeValidator = FileSizeValidator;
|
|
66
|
+
class FileTypeValidator extends common_1.FileValidator {
|
|
67
|
+
multiple;
|
|
68
|
+
errorFileName;
|
|
69
|
+
filetype;
|
|
70
|
+
constructor(args) {
|
|
71
|
+
super({});
|
|
72
|
+
this.multiple = args.multiple;
|
|
73
|
+
this.filetype = args.filetype;
|
|
74
|
+
}
|
|
75
|
+
isMimeTypeValid(file) {
|
|
76
|
+
return file.mimetype.search(this.filetype) === 0;
|
|
77
|
+
}
|
|
78
|
+
async isValid(file) {
|
|
79
|
+
if (!file) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const result = await runFileValidation({
|
|
83
|
+
multiple: this.multiple,
|
|
84
|
+
file,
|
|
85
|
+
validator: (f) => this.isMimeTypeValid(f),
|
|
86
|
+
});
|
|
87
|
+
this.errorFileName = result.errorFileName ?? '';
|
|
88
|
+
return result.isValid;
|
|
89
|
+
}
|
|
90
|
+
buildErrorMessage(file) {
|
|
91
|
+
return `file ${this.errorFileName || ''} must be of type ${this.filetype}`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.FileTypeValidator = FileTypeValidator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ApiExcludeEndpointDiffDevelop: () => MethodDecorator;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiExcludeEndpointDiffDevelop = void 0;
|
|
4
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
5
|
+
const env_config_1 = require("../core/utils/env.config");
|
|
6
|
+
const ApiExcludeEndpointDiffDevelop = () => {
|
|
7
|
+
return (0, swagger_1.ApiExcludeEndpoint)(!env_config_1.EnvConfig.isEnvDevelop);
|
|
8
|
+
};
|
|
9
|
+
exports.ApiExcludeEndpointDiffDevelop = ApiExcludeEndpointDiffDevelop;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EnumAllowedTypes } from '@nestjs/swagger/dist/interfaces/schema-object-metadata.interface';
|
|
2
|
+
interface ApiPropertyEnumOptions {
|
|
3
|
+
enum: EnumAllowedTypes;
|
|
4
|
+
isArray?: boolean;
|
|
5
|
+
required?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function ApiPropertyEnum(options: ApiPropertyEnumOptions): (target: any, propertyKey: string) => void;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiPropertyEnum = ApiPropertyEnum;
|
|
4
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
5
|
+
function ApiPropertyEnum(options) {
|
|
6
|
+
return function (target, propertyKey) {
|
|
7
|
+
const enumValues = Object.values(options.enum)
|
|
8
|
+
.filter((value) => typeof value === 'number')
|
|
9
|
+
.map((value) => ({
|
|
10
|
+
value,
|
|
11
|
+
description: options.enum[value],
|
|
12
|
+
}));
|
|
13
|
+
const description = enumValues
|
|
14
|
+
.map((enumValue) => `${enumValue.description}: ${enumValue.value}`)
|
|
15
|
+
.join('\n');
|
|
16
|
+
(0, swagger_1.ApiProperty)({
|
|
17
|
+
...options,
|
|
18
|
+
description: ['```', description, '```'].join('\n'),
|
|
19
|
+
})(target, propertyKey);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApiPropertyOnlyDevelop = void 0;
|
|
4
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
5
|
+
const env_config_1 = require("../core/utils/env.config");
|
|
6
|
+
const ApiPropertyOnlyDevelop = (propertyOptions) => {
|
|
7
|
+
return env_config_1.EnvConfig.isEnvDevelop ? (0, swagger_1.ApiProperty)(propertyOptions) : () => { };
|
|
8
|
+
};
|
|
9
|
+
exports.ApiPropertyOnlyDevelop = ApiPropertyOnlyDevelop;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const Cookies: (...dataOrPipes: (string | import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>>)[]) => ParameterDecorator;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Cookies = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.Cookies = (0, common_1.createParamDecorator)((data, ctx) => {
|
|
6
|
+
const request = ctx.switchToHttp().getRequest();
|
|
7
|
+
return data ? request.cookies?.[data] : request.cookies;
|
|
8
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsPublic = exports.IS_PUBLIC_KEY = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
exports.IS_PUBLIC_KEY = 'isPublic';
|
|
6
|
+
const IsPublic = () => (0, common_1.SetMetadata)(exports.IS_PUBLIC_KEY, true);
|
|
7
|
+
exports.IsPublic = IsPublic;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function UploadDecorator(maxSizeInKb: number, filetype: RegExp): ParameterDecorator;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UploadDecorator = UploadDecorator;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const file_validator_1 = require("../core/validators/file-validator");
|
|
6
|
+
function UploadDecorator(maxSizeInKb, filetype) {
|
|
7
|
+
const maxSizeBytes = maxSizeInKb * 1024;
|
|
8
|
+
return (0, common_1.UploadedFiles)(new common_1.ParseFilePipe({
|
|
9
|
+
validators: [
|
|
10
|
+
new file_validator_1.FileSizeValidator({ maxSizeBytes, multiple: true }),
|
|
11
|
+
new file_validator_1.FileTypeValidator({
|
|
12
|
+
filetype,
|
|
13
|
+
multiple: true,
|
|
14
|
+
}),
|
|
15
|
+
],
|
|
16
|
+
fileIsRequired: false,
|
|
17
|
+
}));
|
|
18
|
+
}
|
package/env/env.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const envSchema: z.ZodObject<{
|
|
4
|
+
PORT: z.ZodDefault<z.ZodNumber>;
|
|
5
|
+
NODE_ENV: z.ZodEnum<["test", "develop", "staging", "production"]>;
|
|
6
|
+
PRISMA_QUERY_LOG: z.ZodOptional<z.ZodEffects<z.ZodString, boolean | undefined, string>>;
|
|
7
|
+
SWAGGER_USERNAME: z.ZodOptional<z.ZodString>;
|
|
8
|
+
SWAGGER_PASSWORD: z.ZodOptional<z.ZodString>;
|
|
9
|
+
REDIS_CONNECTION_STRING: z.ZodOptional<z.ZodString>;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
PORT: number;
|
|
12
|
+
NODE_ENV: "test" | "develop" | "staging" | "production";
|
|
13
|
+
PRISMA_QUERY_LOG?: boolean | undefined;
|
|
14
|
+
SWAGGER_USERNAME?: string | undefined;
|
|
15
|
+
SWAGGER_PASSWORD?: string | undefined;
|
|
16
|
+
REDIS_CONNECTION_STRING?: string | undefined;
|
|
17
|
+
}, {
|
|
18
|
+
NODE_ENV: "test" | "develop" | "staging" | "production";
|
|
19
|
+
PORT?: number | undefined;
|
|
20
|
+
PRISMA_QUERY_LOG?: string | undefined;
|
|
21
|
+
SWAGGER_USERNAME?: string | undefined;
|
|
22
|
+
SWAGGER_PASSWORD?: string | undefined;
|
|
23
|
+
REDIS_CONNECTION_STRING?: string | undefined;
|
|
24
|
+
}>;
|
|
25
|
+
export type Env = z.infer<typeof envSchema>;
|
package/env/env.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.envSchema = void 0;
|
|
4
|
+
require("dotenv/config");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
const boolean_schema_1 = require("../core/controllers/schemas/boolean.schema");
|
|
7
|
+
exports.envSchema = zod_1.z.object({
|
|
8
|
+
PORT: zod_1.z.coerce.number().default(3000),
|
|
9
|
+
NODE_ENV: zod_1.z.enum(['test', 'develop', 'staging', 'production']),
|
|
10
|
+
PRISMA_QUERY_LOG: (0, boolean_schema_1.booleanSchema)().optional(),
|
|
11
|
+
SWAGGER_USERNAME: zod_1.z.string().optional(),
|
|
12
|
+
SWAGGER_PASSWORD: zod_1.z.string().optional(),
|
|
13
|
+
REDIS_CONNECTION_STRING: zod_1.z.string().optional(),
|
|
14
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
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.EnvModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const env_service_1 = require("./env.service");
|
|
12
|
+
let EnvModule = class EnvModule {
|
|
13
|
+
};
|
|
14
|
+
exports.EnvModule = EnvModule;
|
|
15
|
+
exports.EnvModule = EnvModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [env_service_1.EnvService],
|
|
18
|
+
exports: [env_service_1.EnvService],
|
|
19
|
+
})
|
|
20
|
+
], EnvModule);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { Env } from './env';
|
|
3
|
+
export declare class EnvService<TEnv extends Env = Env> {
|
|
4
|
+
private readonly configService;
|
|
5
|
+
constructor(configService: ConfigService<TEnv, true>);
|
|
6
|
+
get<T extends keyof TEnv>(key: T): (string extends infer T_1 ? T_1 extends string ? T_1 extends keyof TEnv ? string extends infer T_2 ? T_2 extends string ? T_2 extends import("@nestjs/config").Path<TEnv[T_1]> ? import("@nestjs/config").PathValue<TEnv[T_1], T_2> : never : never : never : never : never : never) | (any extends infer T_3 ? T_3 extends any ? T_3 extends keyof TEnv ? TEnv[T_3] : never : never : never);
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
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.EnvService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const config_1 = require("@nestjs/config");
|
|
15
|
+
let EnvService = class EnvService {
|
|
16
|
+
configService;
|
|
17
|
+
constructor(configService) {
|
|
18
|
+
this.configService = configService;
|
|
19
|
+
}
|
|
20
|
+
get(key) {
|
|
21
|
+
return this.configService.get(key, { infer: true });
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.EnvService = EnvService;
|
|
25
|
+
exports.EnvService = EnvService = __decorate([
|
|
26
|
+
(0, common_1.Injectable)(),
|
|
27
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
28
|
+
], EnvService);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ArgumentsHost } from '@nestjs/common';
|
|
2
|
+
import { BaseExceptionFilter } from '@nestjs/core';
|
|
3
|
+
import { BadRequestError } from '../core/errors/bad-request.error';
|
|
4
|
+
import { ConflictError } from '../core/errors/conflict.error';
|
|
5
|
+
import { NoContentError } from '../core/errors/no-content.error';
|
|
6
|
+
import { NotAllowedError } from '../core/errors/not-allowed.error';
|
|
7
|
+
import { ResourceNotFoundError } from '../core/errors/resource-not-found.error';
|
|
8
|
+
import { UserAlreadyExist } from '../core/errors/user-already-exist.error';
|
|
9
|
+
import { WrongCredentialsError } from '../core/errors/wrong-credentials.error';
|
|
10
|
+
import { ILoggingService } from '../services/logging/ilogging.service';
|
|
11
|
+
type DomainErrors = NotAllowedError | ResourceNotFoundError | UserAlreadyExist | WrongCredentialsError | ConflictError | BadRequestError | NoContentError;
|
|
12
|
+
export declare class DomainErrorsFilter extends BaseExceptionFilter {
|
|
13
|
+
private readonly loggingService;
|
|
14
|
+
constructor(loggingService: ILoggingService);
|
|
15
|
+
catch(exception: DomainErrors, host: ArgumentsHost): import("express").Response<any, Record<string, any>>;
|
|
16
|
+
private map;
|
|
17
|
+
}
|
|
18
|
+
export {};
|