@steroidsjs/nest 1.0.2 → 1.0.6
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/infrastructure/decorators/fields/CoordinateField.js +12 -7
- package/infrastructure/decorators/fields/CoordinateField.js.map +1 -1
- package/infrastructure/decorators/fields/DecimalField.js +12 -7
- package/infrastructure/decorators/fields/DecimalField.js.map +1 -1
- package/infrastructure/decorators/fields/EnumField.js +10 -5
- package/infrastructure/decorators/fields/EnumField.js.map +1 -1
- package/infrastructure/decorators/fields/FileField.js +1 -1
- package/infrastructure/decorators/fields/FileField.js.map +1 -1
- package/infrastructure/decorators/fields/IntegerField.js +1 -0
- package/infrastructure/decorators/fields/IntegerField.js.map +1 -1
- package/infrastructure/decorators/fields/RelationField.d.ts +5 -3
- package/infrastructure/decorators/fields/RelationField.js +24 -6
- package/infrastructure/decorators/fields/RelationField.js.map +1 -1
- package/infrastructure/decorators/fields/index.d.ts +2 -0
- package/infrastructure/decorators/fields/index.js +5 -1
- package/infrastructure/decorators/fields/index.js.map +1 -1
- package/infrastructure/filters/ValidationExceptionFilter.d.ts +1 -0
- package/infrastructure/filters/ValidationExceptionFilter.js +17 -12
- package/infrastructure/filters/ValidationExceptionFilter.js.map +1 -1
- package/infrastructure/pipes/CreateDtoPipe.d.ts +4 -0
- package/infrastructure/pipes/CreateDtoPipe.js +21 -0
- package/infrastructure/pipes/CreateDtoPipe.js.map +1 -0
- package/infrastructure/repositories/CrudRepository.d.ts +1 -1
- package/infrastructure/repositories/CrudRepository.js +6 -9
- package/infrastructure/repositories/CrudRepository.js.map +1 -1
- package/infrastructure/schemas/BaseSchema.d.ts +1 -1
- package/infrastructure/schemas/BaseSchema.js +2 -1
- package/infrastructure/schemas/BaseSchema.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/usecases/services/CrudService.d.ts +1 -1
- package/usecases/services/CrudService.js +5 -6
- package/usecases/services/CrudService.js.map +1 -1
|
@@ -12,5 +12,5 @@ export declare class CrudService<TModel, TSearchDto = ISearchInputDto, TSaveDto
|
|
|
12
12
|
create(dto: TSaveDto): Promise<TModel>;
|
|
13
13
|
update(id: number | string, dto: TSaveDto): Promise<TModel>;
|
|
14
14
|
remove(id: number | string): Promise<void>;
|
|
15
|
-
protected dtoToModel(dto: TSaveDto
|
|
15
|
+
protected dtoToModel(dto: TSaveDto): TModel;
|
|
16
16
|
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CrudService = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
|
-
const DataMapperHelper_1 = require("../helpers/DataMapperHelper");
|
|
6
5
|
const ValidationHelper_1 = require("../helpers/ValidationHelper");
|
|
6
|
+
const class_transformer_1 = require("class-transformer");
|
|
7
7
|
class CrudService {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.primaryKey = 'id';
|
|
@@ -27,14 +27,14 @@ class CrudService {
|
|
|
27
27
|
}
|
|
28
28
|
async create(dto) {
|
|
29
29
|
await (0, ValidationHelper_1.validateOrReject)(dto);
|
|
30
|
-
let model = this.dtoToModel(dto
|
|
30
|
+
let model = this.dtoToModel(dto);
|
|
31
31
|
await (0, ValidationHelper_1.validateOrReject)(model);
|
|
32
32
|
const tmodel = await this.repository.create(model);
|
|
33
33
|
return tmodel;
|
|
34
34
|
}
|
|
35
35
|
async update(id, dto) {
|
|
36
36
|
await (0, ValidationHelper_1.validateOrReject)(dto);
|
|
37
|
-
let model = this.dtoToModel(dto
|
|
37
|
+
let model = this.dtoToModel(dto);
|
|
38
38
|
await (0, ValidationHelper_1.validateOrReject)(model);
|
|
39
39
|
model = await this.repository.update((0, lodash_1.toInteger)(id), model);
|
|
40
40
|
return model;
|
|
@@ -42,9 +42,8 @@ class CrudService {
|
|
|
42
42
|
async remove(id) {
|
|
43
43
|
await this.repository.remove((0, lodash_1.toInteger)(id));
|
|
44
44
|
}
|
|
45
|
-
dtoToModel(dto
|
|
46
|
-
|
|
47
|
-
return model;
|
|
45
|
+
dtoToModel(dto) {
|
|
46
|
+
return (0, class_transformer_1.plainToInstance)(this.modelClass, dto);
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
exports.CrudService = CrudService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudService.js","sourceRoot":"","sources":["../../../src/usecases/services/CrudService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;
|
|
1
|
+
{"version":3,"file":"CrudService.js","sourceRoot":"","sources":["../../../src/usecases/services/CrudService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAK/C,kEAA6D;AAC7D,yDAAkD;AAKlD,MAAa,WAAW;IAAxB;QAQc,eAAU,GAAW,IAAI,CAAC;IAsFxC,CAAC;IAvEG,IAAI,CAAC,UAAmC,EAAE,UAAU;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAED,WAAW;QACP,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QACnC,OAAO,IAAI,UAAU,EAAE,CAAC;IAC5B,CAAC;IAMD,KAAK,CAAC,MAAM,CAAC,GAAe;QACxB,MAAM,IAAA,mCAAgB,EAAC,GAAG,CAAC,CAAC;QAC5B,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC3D,OAAO,gBAAgB,CAAC;IAC5B,CAAC;IAMD,KAAK,CAAC,QAAQ,CAAC,EAAmB;QAC9B,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAA,kBAAU,EAAC,EAAE,CAAC,EAAC,CAAC,CAAC;QACjF,OAAO,KAAK,CAAC;IACjB,CAAC;IAMD,KAAK,CAAC,MAAM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