@mondart/nestjs-common-module 1.1.72 → 2.1.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mondart/nestjs-common-module",
3
- "version": "1.1.72",
3
+ "version": "2.1.0",
4
4
  "description": "",
5
5
  "author": {
6
6
  "name": "Mondart"
@@ -1,18 +0,0 @@
1
- import { Paginated } from 'nestjs-paginate';
2
- import { PaginateConfig } from 'nestjs-paginate/lib/paginate';
3
- import { PaginationQueryCustom } from '../interfaces/pagination-query';
4
- import { BaseResponse, SuccessResponse } from '../dto';
5
- import { IdDto } from '../dto';
6
- import { CoreCrudService } from '../services';
7
- import { BaseModelEntity } from '../entities';
8
- export declare class CoreCrudController<T extends BaseModelEntity, CreateDto, UpdateDto, ResponseDto extends BaseResponse> {
9
- protected readonly coreService: CoreCrudService<T, CreateDto, UpdateDto>;
10
- protected readonly responseDto: any;
11
- protected constructor(coreService: CoreCrudService<T, CreateDto, UpdateDto>, responseDto: any);
12
- findAll(query: PaginationQueryCustom, paginateConfig: PaginateConfig<T>): Promise<Paginated<T>>;
13
- findOneById(id: number): Promise<SuccessResponse<ResponseDto>>;
14
- create(createDto: CreateDto): Promise<SuccessResponse<ResponseDto>>;
15
- update({ id }: IdDto, updateDto: UpdateDto): Promise<SuccessResponse<ResponseDto>>;
16
- deleteById({ id }: IdDto): Promise<SuccessResponse<void>>;
17
- softDeleteById({ id }: IdDto): Promise<SuccessResponse<void>>;
18
- }
@@ -1,71 +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
- var __param = (this && this.__param) || function (paramIndex, decorator) {
12
- return function (target, key) { decorator(target, key, paramIndex); }
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.CoreCrudController = void 0;
16
- const common_1 = require("@nestjs/common");
17
- const nestjs_paginate_1 = require("nestjs-paginate");
18
- const pagination_query_1 = require("../interfaces/pagination-query");
19
- const enums_1 = require("../enums");
20
- const dto_1 = require("../dto");
21
- class CoreCrudController {
22
- constructor(coreService, responseDto) {
23
- this.coreService = coreService;
24
- this.responseDto = responseDto;
25
- }
26
- async findAll(query, paginateConfig) {
27
- const response = await this.coreService.findAllWithPagination(query, paginateConfig);
28
- if (!response)
29
- throw new common_1.NotFoundException(enums_1.SharedMessages.FETCH_FAILED);
30
- response.data = response.data.map((item) => new this.responseDto(item));
31
- return response;
32
- }
33
- async findOneById(id) {
34
- const response = await this.coreService.findOneById(id);
35
- if (!response)
36
- throw new common_1.NotFoundException(enums_1.SharedMessages.RESOURCE_NOT_FOUND);
37
- return new dto_1.SuccessResponse(new this.responseDto(response), enums_1.SharedMessages.SUCCESSFUL, common_1.HttpStatus.OK);
38
- }
39
- async create(createDto) {
40
- const response = await this.coreService.create(createDto);
41
- if (!response)
42
- throw new common_1.BadRequestException(enums_1.SharedMessages.CREATE_FAILED);
43
- return new dto_1.SuccessResponse(new this.responseDto(response), enums_1.SharedMessages.SUCCESSFUL, common_1.HttpStatus.CREATED);
44
- }
45
- async update({ id }, updateDto) {
46
- const response = await this.coreService.update(id, updateDto);
47
- if (!response)
48
- throw new common_1.BadRequestException(enums_1.SharedMessages.UPDATE_FAILED);
49
- const foundItem = await this.coreService.findOneById(id);
50
- return new dto_1.SuccessResponse(new this.responseDto(foundItem), enums_1.SharedMessages.SUCCESSFUL, common_1.HttpStatus.OK);
51
- }
52
- async deleteById({ id }) {
53
- const result = await this.coreService.deleteById(id);
54
- if (!result)
55
- throw new common_1.BadRequestException(enums_1.SharedMessages.DELETE_FAILED);
56
- return new dto_1.SuccessResponse(undefined, enums_1.SharedMessages.SUCCESSFUL, common_1.HttpStatus.OK);
57
- }
58
- async softDeleteById({ id }) {
59
- const result = await this.coreService.softDeleteById(id);
60
- if (!result)
61
- throw new common_1.BadRequestException(enums_1.SharedMessages.DELETE_FAILED);
62
- return new dto_1.SuccessResponse(undefined, enums_1.SharedMessages.SUCCESSFUL, common_1.HttpStatus.OK);
63
- }
64
- }
65
- exports.CoreCrudController = CoreCrudController;
66
- __decorate([
67
- __param(0, (0, nestjs_paginate_1.Paginate)()),
68
- __metadata("design:type", Function),
69
- __metadata("design:paramtypes", [pagination_query_1.PaginationQueryCustom, Object]),
70
- __metadata("design:returntype", Promise)
71
- ], CoreCrudController.prototype, "findAll", null);
@@ -1 +0,0 @@
1
- export * from './core-crud.controller';
@@ -1,17 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./core-crud.controller"), exports);
@@ -1,7 +0,0 @@
1
- import { EntityManager } from 'typeorm';
2
- import { FindOptionsRelations } from 'typeorm/find-options/FindOptionsRelations';
3
- export declare class CrudServiceOption<T> {
4
- entityManager?: EntityManager;
5
- relations?: FindOptionsRelations<T>;
6
- existsCheck?: boolean;
7
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CrudServiceOption = void 0;
4
- class CrudServiceOption {
5
- constructor() {
6
- this.existsCheck = true;
7
- }
8
- }
9
- exports.CrudServiceOption = CrudServiceOption;
@@ -1,35 +0,0 @@
1
- import { DeepPartial, DeleteResult, FindManyOptions, FindOptionsWhere, Repository, UpdateResult } from 'typeorm';
2
- import { BaseModelEntity } from '../entities';
3
- import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
4
- import { Paginated } from 'nestjs-paginate';
5
- import { PaginateConfig } from 'nestjs-paginate/lib/paginate';
6
- import { PaginationQueryCustom } from '../interfaces/pagination-query';
7
- import { InsertResult } from 'typeorm/query-builder/result/InsertResult';
8
- import { CrudServiceOption } from '../interfaces';
9
- import { UpsertOptions } from 'typeorm/repository/UpsertOptions';
10
- export declare abstract class CoreCrudService<T extends BaseModelEntity, CreateDto, UpdateDto> {
11
- protected readonly repository: Repository<T>;
12
- private readonly relationsPath;
13
- protected constructor(repository: Repository<T>);
14
- create(createDto: CreateDto, options?: CrudServiceOption<T>): Promise<T>;
15
- findAllWithPagination(query: PaginationQueryCustom, paginateConfig: PaginateConfig<T>, options?: CrudServiceOption<T>): Promise<Paginated<T>>;
16
- findAll(query: FindManyOptions<T>, options?: CrudServiceOption<T>): Promise<T[]>;
17
- findOneById(id: number, options?: CrudServiceOption<T>): Promise<T>;
18
- findOne(query: FindManyOptions<T>, options?: CrudServiceOption<T>): Promise<T>;
19
- isExists(query: FindManyOptions<T>, options?: CrudServiceOption<T>): Promise<boolean>;
20
- count(query: FindManyOptions<T>, options?: CrudServiceOption<T>): Promise<number>;
21
- upsert(upsertDto: QueryDeepPartialEntity<T>, upsertOptions: UpsertOptions<T>, options?: CrudServiceOption<T>): Promise<InsertResult>;
22
- update(id: number, updateDto: Partial<UpdateDto> | DeepPartial<T> | QueryDeepPartialEntity<T>, options?: CrudServiceOption<T>): Promise<UpdateResult>;
23
- softDelete(query: FindOptionsWhere<T>, options?: CrudServiceOption<T>): Promise<UpdateResult>;
24
- softDeleteById(id: string | string[] | number | number[], options?: CrudServiceOption<T>): Promise<UpdateResult>;
25
- restore(query: FindOptionsWhere<T>, options?: CrudServiceOption<T>): Promise<UpdateResult>;
26
- restoreById(id: string | string[] | number | number[], options?: CrudServiceOption<T>): Promise<UpdateResult>;
27
- delete(query: FindOptionsWhere<T>, options?: CrudServiceOption<T>): Promise<DeleteResult>;
28
- deleteById(id: string | string[] | number | number[], options?: CrudServiceOption<T>): Promise<DeleteResult>;
29
- private relatedPropertyTransformer;
30
- private whereQueryTransformer;
31
- private isObject;
32
- private isArray;
33
- private isArrayOfObjectId;
34
- private isArrayOfNumbers;
35
- }
@@ -1 +0,0 @@
1
- export * from './core-crud.service';