@steroidsjs/nest 1.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.
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/domain/base/BaseEnum.d.ts +9 -0
- package/domain/base/BaseEnum.js +35 -0
- package/domain/base/BaseEnum.js.map +1 -0
- package/index.d.ts +0 -0
- package/index.js +1 -0
- package/index.js.map +1 -0
- package/infrastructure/commands/MigrateCommand.d.ts +23 -0
- package/infrastructure/commands/MigrateCommand.js +186 -0
- package/infrastructure/commands/MigrateCommand.js.map +1 -0
- package/infrastructure/decorators/ApiOkSearchResponse.d.ts +1 -0
- package/infrastructure/decorators/ApiOkSearchResponse.js +25 -0
- package/infrastructure/decorators/ApiOkSearchResponse.js.map +1 -0
- package/infrastructure/decorators/fields/BaseField.d.ts +17 -0
- package/infrastructure/decorators/fields/BaseField.js +24 -0
- package/infrastructure/decorators/fields/BaseField.js.map +1 -0
- package/infrastructure/decorators/fields/BooleanField.d.ts +2 -0
- package/infrastructure/decorators/fields/BooleanField.js +17 -0
- package/infrastructure/decorators/fields/BooleanField.js.map +1 -0
- package/infrastructure/decorators/fields/CoordinateField.d.ts +7 -0
- package/infrastructure/decorators/fields/CoordinateField.js +18 -0
- package/infrastructure/decorators/fields/CoordinateField.js.map +1 -0
- package/infrastructure/decorators/fields/CreateTimeField.d.ts +5 -0
- package/infrastructure/decorators/fields/CreateTimeField.js +35 -0
- package/infrastructure/decorators/fields/CreateTimeField.js.map +1 -0
- package/infrastructure/decorators/fields/DateField.d.ts +2 -0
- package/infrastructure/decorators/fields/DateField.js +17 -0
- package/infrastructure/decorators/fields/DateField.js.map +1 -0
- package/infrastructure/decorators/fields/DateTimeField.d.ts +5 -0
- package/infrastructure/decorators/fields/DateTimeField.js +19 -0
- package/infrastructure/decorators/fields/DateTimeField.js.map +1 -0
- package/infrastructure/decorators/fields/DecimalField.d.ts +7 -0
- package/infrastructure/decorators/fields/DecimalField.js +18 -0
- package/infrastructure/decorators/fields/DecimalField.js.map +1 -0
- package/infrastructure/decorators/fields/EmailField.d.ts +2 -0
- package/infrastructure/decorators/fields/EmailField.js +19 -0
- package/infrastructure/decorators/fields/EmailField.js.map +1 -0
- package/infrastructure/decorators/fields/EnumField.d.ts +6 -0
- package/infrastructure/decorators/fields/EnumField.js +31 -0
- package/infrastructure/decorators/fields/EnumField.js.map +1 -0
- package/infrastructure/decorators/fields/ExtendField.d.ts +5 -0
- package/infrastructure/decorators/fields/ExtendField.js +20 -0
- package/infrastructure/decorators/fields/ExtendField.js.map +1 -0
- package/infrastructure/decorators/fields/ExtendFields.d.ts +1 -0
- package/infrastructure/decorators/fields/ExtendFields.js +15 -0
- package/infrastructure/decorators/fields/ExtendFields.js.map +1 -0
- package/infrastructure/decorators/fields/FileField.d.ts +2 -0
- package/infrastructure/decorators/fields/FileField.js +16 -0
- package/infrastructure/decorators/fields/FileField.js.map +1 -0
- package/infrastructure/decorators/fields/HtmlField.d.ts +2 -0
- package/infrastructure/decorators/fields/HtmlField.js +15 -0
- package/infrastructure/decorators/fields/HtmlField.js.map +1 -0
- package/infrastructure/decorators/fields/IntegerField.d.ts +2 -0
- package/infrastructure/decorators/fields/IntegerField.js +22 -0
- package/infrastructure/decorators/fields/IntegerField.js.map +1 -0
- package/infrastructure/decorators/fields/PasswordField.d.ts +2 -0
- package/infrastructure/decorators/fields/PasswordField.js +20 -0
- package/infrastructure/decorators/fields/PasswordField.js.map +1 -0
- package/infrastructure/decorators/fields/PhoneField.d.ts +2 -0
- package/infrastructure/decorators/fields/PhoneField.js +20 -0
- package/infrastructure/decorators/fields/PhoneField.js.map +1 -0
- package/infrastructure/decorators/fields/PrimaryKeyField.d.ts +2 -0
- package/infrastructure/decorators/fields/PrimaryKeyField.js +14 -0
- package/infrastructure/decorators/fields/PrimaryKeyField.js.map +1 -0
- package/infrastructure/decorators/fields/RelationField.d.ts +6 -0
- package/infrastructure/decorators/fields/RelationField.js +16 -0
- package/infrastructure/decorators/fields/RelationField.js.map +1 -0
- package/infrastructure/decorators/fields/StringField.d.ts +2 -0
- package/infrastructure/decorators/fields/StringField.js +24 -0
- package/infrastructure/decorators/fields/StringField.js.map +1 -0
- package/infrastructure/decorators/fields/TextField.d.ts +2 -0
- package/infrastructure/decorators/fields/TextField.js +16 -0
- package/infrastructure/decorators/fields/TextField.js.map +1 -0
- package/infrastructure/decorators/fields/TimeField.d.ts +2 -0
- package/infrastructure/decorators/fields/TimeField.js +17 -0
- package/infrastructure/decorators/fields/TimeField.js.map +1 -0
- package/infrastructure/decorators/fields/UidField.d.ts +2 -0
- package/infrastructure/decorators/fields/UidField.js +34 -0
- package/infrastructure/decorators/fields/UidField.js.map +1 -0
- package/infrastructure/decorators/fields/UpdateTimeField.d.ts +5 -0
- package/infrastructure/decorators/fields/UpdateTimeField.js +37 -0
- package/infrastructure/decorators/fields/UpdateTimeField.js.map +1 -0
- package/infrastructure/decorators/fields/index.d.ts +18 -0
- package/infrastructure/decorators/fields/index.js +40 -0
- package/infrastructure/decorators/fields/index.js.map +1 -0
- package/infrastructure/exception/ValidationException.d.ts +5 -0
- package/infrastructure/exception/ValidationException.js +12 -0
- package/infrastructure/exception/ValidationException.js.map +1 -0
- package/infrastructure/helpers/ConditionHelper.d.ts +8 -0
- package/infrastructure/helpers/ConditionHelper.js +74 -0
- package/infrastructure/helpers/ConditionHelper.js.map +1 -0
- package/infrastructure/helpers/DataMapperHelper.d.ts +4 -0
- package/infrastructure/helpers/DataMapperHelper.js +18 -0
- package/infrastructure/helpers/DataMapperHelper.js.map +1 -0
- package/infrastructure/helpers/MetaHelper.d.ts +5 -0
- package/infrastructure/helpers/MetaHelper.js +35 -0
- package/infrastructure/helpers/MetaHelper.js.map +1 -0
- package/infrastructure/helpers/SearchHelper.d.ts +7 -0
- package/infrastructure/helpers/SearchHelper.js +30 -0
- package/infrastructure/helpers/SearchHelper.js.map +1 -0
- package/infrastructure/pipes/ValidationPipe.d.ts +4 -0
- package/infrastructure/pipes/ValidationPipe.js +37 -0
- package/infrastructure/pipes/ValidationPipe.js.map +1 -0
- package/infrastructure/repositories/CrudRepository.d.ts +18 -0
- package/infrastructure/repositories/CrudRepository.js +53 -0
- package/infrastructure/repositories/CrudRepository.js.map +1 -0
- package/infrastructure/schemas/BaseSchema.d.ts +6 -0
- package/infrastructure/schemas/BaseSchema.js +19 -0
- package/infrastructure/schemas/BaseSchema.js.map +1 -0
- package/infrastructure/schemas/SearchSchema.d.ts +7 -0
- package/infrastructure/schemas/SearchSchema.js +36 -0
- package/infrastructure/schemas/SearchSchema.js.map +1 -0
- package/package.json +40 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/usecases/dtos/SearchInputDto.d.ts +10 -0
- package/usecases/dtos/SearchInputDto.js +29 -0
- package/usecases/dtos/SearchInputDto.js.map +1 -0
- package/usecases/dtos/SearchResultDto.d.ts +5 -0
- package/usecases/dtos/SearchResultDto.js +7 -0
- package/usecases/dtos/SearchResultDto.js.map +1 -0
- package/usecases/interfaces/ICrudRepository.d.ts +12 -0
- package/usecases/interfaces/ICrudRepository.js +3 -0
- package/usecases/interfaces/ICrudRepository.js.map +1 -0
- package/usecases/services/CrudService.d.ts +16 -0
- package/usecases/services/CrudService.js +45 -0
- package/usecases/services/CrudService.js.map +1 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ICrudRepository } from '../interfaces/ICrudRepository';
|
|
2
|
+
import { ISearchInputDto } from '../dtos/SearchInputDto';
|
|
3
|
+
import { SearchResultDto } from '../dtos/SearchResultDto';
|
|
4
|
+
export declare class CrudService<TModel, TSearchDto = ISearchInputDto, TSaveDto = TModel> {
|
|
5
|
+
protected primaryKey: string;
|
|
6
|
+
protected repository: ICrudRepository<TModel>;
|
|
7
|
+
protected modelClass: any;
|
|
8
|
+
init(repository: ICrudRepository<TModel>, ModelClass: any): void;
|
|
9
|
+
createModel(): TModel | any;
|
|
10
|
+
search(dto: TSearchDto): Promise<SearchResultDto<TModel>>;
|
|
11
|
+
findById(id: number | string): Promise<TModel>;
|
|
12
|
+
create(dto: TSaveDto): Promise<TModel>;
|
|
13
|
+
update(id: number | string, dto: TSaveDto): Promise<TModel>;
|
|
14
|
+
remove(id: number | string): Promise<void>;
|
|
15
|
+
protected dtoToModel(dto: TSaveDto, model: TModel): TModel;
|
|
16
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudService = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
const DataMapperHelper_1 = require("../../infrastructure/helpers/DataMapperHelper");
|
|
6
|
+
class CrudService {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.primaryKey = 'id';
|
|
9
|
+
}
|
|
10
|
+
init(repository, ModelClass) {
|
|
11
|
+
this.repository = repository;
|
|
12
|
+
this.modelClass = ModelClass;
|
|
13
|
+
}
|
|
14
|
+
createModel() {
|
|
15
|
+
const ModelClass = this.modelClass;
|
|
16
|
+
return new ModelClass();
|
|
17
|
+
}
|
|
18
|
+
async search(dto) {
|
|
19
|
+
const repositoryResult = await this.repository.search(dto);
|
|
20
|
+
return repositoryResult;
|
|
21
|
+
}
|
|
22
|
+
async findById(id) {
|
|
23
|
+
const model = await this.repository.findOne({ [this.primaryKey]: (0, lodash_1.toInteger)(id) });
|
|
24
|
+
return model;
|
|
25
|
+
}
|
|
26
|
+
async create(dto) {
|
|
27
|
+
let model = this.dtoToModel(dto, this.createModel());
|
|
28
|
+
model = await this.repository.create(model);
|
|
29
|
+
return model;
|
|
30
|
+
}
|
|
31
|
+
async update(id, dto) {
|
|
32
|
+
let model = this.dtoToModel(dto, this.createModel());
|
|
33
|
+
model = await this.repository.update((0, lodash_1.toInteger)(id), model);
|
|
34
|
+
return model;
|
|
35
|
+
}
|
|
36
|
+
async remove(id) {
|
|
37
|
+
await this.repository.remove((0, lodash_1.toInteger)(id));
|
|
38
|
+
}
|
|
39
|
+
dtoToModel(dto, model) {
|
|
40
|
+
DataMapperHelper_1.DataMapperHelper.applyFields(model, dto);
|
|
41
|
+
return model;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.CrudService = CrudService;
|
|
45
|
+
//# sourceMappingURL=CrudService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CrudService.js","sourceRoot":"","sources":["../../../src/usecases/services/CrudService.ts"],"names":[],"mappings":";;;AAAA,mCAA+C;AAE/C,oFAA+E;AAO/E,MAAa,WAAW;IAAxB;QAQc,eAAU,GAAW,IAAI,CAAC;IAkFxC,CAAC;IAnEG,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,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,CAAC,GAAa;QACtB,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACrD,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC5C,OAAO,KAAK,CAAC;IACjB,CAAC;IAOD,KAAK,CAAC,MAAM,CAAC,EAAmB,EAAE,GAAa;QAC3C,IAAI,KAAK,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QACrD,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAA,kBAAU,EAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC5D,OAAO,KAAK,CAAC;IACjB,CAAC;IAMD,KAAK,CAAC,MAAM,CAAC,EAAmB;QAC5B,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAA,kBAAU,EAAC,EAAE,CAAC,CAAC,CAAC;IACjD,CAAC;IAQS,UAAU,CAAC,GAAa,EAAE,KAAa;QAC7C,mCAAgB,CAAC,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACzC,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ;AA1FD,kCA0FC"}
|