@mondart/nestjs-common-module 1.1.14 → 1.1.15
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/dist/entities/index.d.ts +1 -1
- package/dist/entities/index.js +1 -1
- package/dist/entities/parent-with-action-dates.entity.d.ts +10 -0
- package/dist/entities/{action-dates.entity.js → parent-with-action-dates.entity.js} +19 -8
- package/dist/entities/parent.entity.d.ts +2 -5
- package/dist/entities/parent.entity.js +1 -12
- package/dist/services/core-crud.service.d.ts +1 -1
- package/dist/services/core-crud.service.js +8 -8
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/entities/action-dates.entity.d.ts +0 -8
package/dist/entities/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './action-dates.entity';
|
|
1
|
+
export * from './parent-with-action-dates.entity';
|
|
2
2
|
export * from './parent.entity';
|
package/dist/entities/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./action-dates.entity"), exports);
|
|
17
|
+
__exportStar(require("./parent-with-action-dates.entity"), exports);
|
|
18
18
|
__exportStar(require("./parent.entity"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ParentEntity } from "./parent.entity";
|
|
2
|
+
export declare class ParentWithActionDatesEntity extends ParentEntity {
|
|
3
|
+
createdAt: Date;
|
|
4
|
+
updatedAt: Date;
|
|
5
|
+
deletedAt: Date;
|
|
6
|
+
createdBy?: string;
|
|
7
|
+
updatedBy?: string;
|
|
8
|
+
isActive: boolean;
|
|
9
|
+
metadata?: any;
|
|
10
|
+
}
|
|
@@ -9,34 +9,45 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.ParentWithActionDatesEntity = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const entity_order_decorator_1 = require("../decorators/entity-order.decorator");
|
|
15
|
-
|
|
15
|
+
const parent_entity_1 = require("./parent.entity");
|
|
16
|
+
class ParentWithActionDatesEntity extends parent_entity_1.ParentEntity {
|
|
16
17
|
}
|
|
17
|
-
exports.
|
|
18
|
+
exports.ParentWithActionDatesEntity = ParentWithActionDatesEntity;
|
|
18
19
|
__decorate([
|
|
19
20
|
(0, entity_order_decorator_1.Order)(9999),
|
|
20
21
|
(0, typeorm_1.CreateDateColumn)(),
|
|
21
22
|
__metadata("design:type", Date)
|
|
22
|
-
],
|
|
23
|
+
], ParentWithActionDatesEntity.prototype, "createdAt", void 0);
|
|
23
24
|
__decorate([
|
|
24
25
|
(0, entity_order_decorator_1.Order)(9999),
|
|
25
26
|
(0, typeorm_1.UpdateDateColumn)(),
|
|
26
27
|
__metadata("design:type", Date)
|
|
27
|
-
],
|
|
28
|
+
], ParentWithActionDatesEntity.prototype, "updatedAt", void 0);
|
|
28
29
|
__decorate([
|
|
29
30
|
(0, entity_order_decorator_1.Order)(9999),
|
|
30
31
|
(0, typeorm_1.DeleteDateColumn)(),
|
|
31
32
|
__metadata("design:type", Date)
|
|
32
|
-
],
|
|
33
|
+
], ParentWithActionDatesEntity.prototype, "deletedAt", void 0);
|
|
33
34
|
__decorate([
|
|
34
35
|
(0, entity_order_decorator_1.Order)(9999),
|
|
35
36
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
36
37
|
__metadata("design:type", String)
|
|
37
|
-
],
|
|
38
|
+
], ParentWithActionDatesEntity.prototype, "createdBy", void 0);
|
|
38
39
|
__decorate([
|
|
39
40
|
(0, entity_order_decorator_1.Order)(9999),
|
|
40
41
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
41
42
|
__metadata("design:type", String)
|
|
42
|
-
],
|
|
43
|
+
], ParentWithActionDatesEntity.prototype, "updatedBy", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
(0, entity_order_decorator_1.Order)(9999),
|
|
46
|
+
(0, typeorm_1.Column)({ default: true }),
|
|
47
|
+
__metadata("design:type", Boolean)
|
|
48
|
+
], ParentWithActionDatesEntity.prototype, "isActive", void 0);
|
|
49
|
+
__decorate([
|
|
50
|
+
(0, entity_order_decorator_1.Order)(9999),
|
|
51
|
+
(0, typeorm_1.Column)({ type: 'json', nullable: true }),
|
|
52
|
+
__metadata("design:type", Object)
|
|
53
|
+
], ParentWithActionDatesEntity.prototype, "metadata", void 0);
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { DataSource } from 'typeorm';
|
|
2
|
-
|
|
3
|
-
export declare class ParentEntity extends ActionDatesEntity {
|
|
1
|
+
import { BaseEntity, DataSource } from 'typeorm';
|
|
2
|
+
export declare class ParentEntity extends BaseEntity {
|
|
4
3
|
id: number;
|
|
5
|
-
isActive: boolean;
|
|
6
|
-
metadata?: any;
|
|
7
4
|
static useDataSource(dataSource: DataSource): void;
|
|
8
5
|
}
|
|
@@ -11,9 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.ParentEntity = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
|
-
const action_dates_entity_1 = require("./action-dates.entity");
|
|
15
14
|
const entity_order_decorator_1 = require("../decorators/entity-order.decorator");
|
|
16
|
-
class ParentEntity extends
|
|
15
|
+
class ParentEntity extends typeorm_1.BaseEntity {
|
|
17
16
|
static useDataSource(dataSource) {
|
|
18
17
|
typeorm_1.BaseEntity.useDataSource.call(this, dataSource);
|
|
19
18
|
const meta = dataSource.entityMetadatasMap.get(this);
|
|
@@ -32,13 +31,3 @@ __decorate([
|
|
|
32
31
|
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
|
33
32
|
__metadata("design:type", Number)
|
|
34
33
|
], ParentEntity.prototype, "id", void 0);
|
|
35
|
-
__decorate([
|
|
36
|
-
(0, entity_order_decorator_1.Order)(9998),
|
|
37
|
-
(0, typeorm_1.Column)({ default: true }),
|
|
38
|
-
__metadata("design:type", Boolean)
|
|
39
|
-
], ParentEntity.prototype, "isActive", void 0);
|
|
40
|
-
__decorate([
|
|
41
|
-
(0, entity_order_decorator_1.Order)(9999),
|
|
42
|
-
(0, typeorm_1.Column)({ type: 'json', nullable: true }),
|
|
43
|
-
__metadata("design:type", Object)
|
|
44
|
-
], ParentEntity.prototype, "metadata", void 0);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DeepPartial, DeleteResult, FindManyOptions, FindOptionsWhere, Repository, UpdateResult } from 'typeorm';
|
|
2
|
-
import { ParentEntity } from '../entities
|
|
2
|
+
import { ParentEntity } from '../entities';
|
|
3
3
|
import { QueryDeepPartialEntity } from 'typeorm/query-builder/QueryPartialEntity';
|
|
4
4
|
import { Paginated } from 'nestjs-paginate';
|
|
5
5
|
import { PaginateConfig } from 'nestjs-paginate/lib/paginate';
|
|
@@ -13,8 +13,8 @@ exports.CoreCrudService = void 0;
|
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const common_1 = require("@nestjs/common");
|
|
15
15
|
const nestjs_paginate_1 = require("nestjs-paginate");
|
|
16
|
-
const
|
|
17
|
-
const
|
|
16
|
+
const enums_1 = require("../enums");
|
|
17
|
+
const helpers_1 = require("../helpers");
|
|
18
18
|
let CoreCrudService = class CoreCrudService {
|
|
19
19
|
constructor(repository) {
|
|
20
20
|
this.repository = repository;
|
|
@@ -55,7 +55,7 @@ let CoreCrudService = class CoreCrudService {
|
|
|
55
55
|
...query,
|
|
56
56
|
});
|
|
57
57
|
if (options?.existsCheck && !result) {
|
|
58
|
-
throw new common_1.NotFoundException(
|
|
58
|
+
throw new common_1.NotFoundException(enums_1.SharedMessages.RESOURCE_NOT_FOUND);
|
|
59
59
|
}
|
|
60
60
|
return result;
|
|
61
61
|
}
|
|
@@ -78,7 +78,7 @@ let CoreCrudService = class CoreCrudService {
|
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
80
|
if (options?.existsCheck && !result) {
|
|
81
|
-
throw new common_1.NotFoundException(
|
|
81
|
+
throw new common_1.NotFoundException(enums_1.SharedMessages.RESOURCE_NOT_FOUND);
|
|
82
82
|
}
|
|
83
83
|
return result;
|
|
84
84
|
}
|
|
@@ -102,7 +102,7 @@ let CoreCrudService = class CoreCrudService {
|
|
|
102
102
|
});
|
|
103
103
|
}
|
|
104
104
|
if (options?.existsCheck && !result) {
|
|
105
|
-
throw new common_1.NotFoundException(
|
|
105
|
+
throw new common_1.NotFoundException(enums_1.SharedMessages.RESOURCE_NOT_FOUND);
|
|
106
106
|
}
|
|
107
107
|
return result;
|
|
108
108
|
}
|
|
@@ -175,7 +175,7 @@ let CoreCrudService = class CoreCrudService {
|
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
177
|
catch (error) {
|
|
178
|
-
throw new common_1.BadRequestException(
|
|
178
|
+
throw new common_1.BadRequestException(helpers_1.MessageFormatter.replace(enums_1.SharedMessages.UPSERT_FAILED, error));
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
async update(id, updateDto, options) {
|
|
@@ -185,7 +185,7 @@ let CoreCrudService = class CoreCrudService {
|
|
|
185
185
|
relations: this.relationsPath,
|
|
186
186
|
});
|
|
187
187
|
if (!fetchedItem)
|
|
188
|
-
throw new common_1.NotFoundException(
|
|
188
|
+
throw new common_1.NotFoundException(enums_1.SharedMessages.RESOURCE_NOT_FOUND);
|
|
189
189
|
const relationEntityName = Object.keys(updateDto).filter((item) => this.relationsPath.includes(item) && updateDto[item]);
|
|
190
190
|
relationEntityName.map((item) => {
|
|
191
191
|
delete fetchedItem[item];
|
|
@@ -207,7 +207,7 @@ let CoreCrudService = class CoreCrudService {
|
|
|
207
207
|
relations: this.relationsPath,
|
|
208
208
|
});
|
|
209
209
|
if (!fetchedItem)
|
|
210
|
-
throw new common_1.NotFoundException(
|
|
210
|
+
throw new common_1.NotFoundException(enums_1.SharedMessages.RESOURCE_NOT_FOUND);
|
|
211
211
|
const relationEntityName = Object.keys(updateDto).filter((item) => this.relationsPath.includes(item) && updateDto[item]);
|
|
212
212
|
relationEntityName.map((item) => {
|
|
213
213
|
delete fetchedItem[item];
|