@steroidsjs/nest 1.0.15 → 1.1.3
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/commands/dbml/dbml2code.js +1 -1
- package/infrastructure/commands/dbml/dbml2code.js.map +1 -1
- package/infrastructure/commands/generate/index.js +18 -10
- package/infrastructure/commands/generate/index.js.map +1 -1
- package/infrastructure/decorators/Context.d.ts +1 -0
- package/infrastructure/decorators/Context.js +12 -0
- package/infrastructure/decorators/Context.js.map +1 -0
- package/infrastructure/decorators/SteroidsSchema.d.ts +6 -0
- package/infrastructure/decorators/SteroidsSchema.js +11 -0
- package/infrastructure/decorators/SteroidsSchema.js.map +1 -0
- package/infrastructure/decorators/TableFromModel.js.map +1 -1
- package/infrastructure/decorators/fields/BaseField.d.ts +14 -3
- package/infrastructure/decorators/fields/BaseField.js +18 -15
- package/infrastructure/decorators/fields/BaseField.js.map +1 -1
- package/infrastructure/decorators/fields/BooleanField.js +5 -1
- package/infrastructure/decorators/fields/BooleanField.js.map +1 -1
- package/infrastructure/decorators/fields/CoordinateField.d.ts +1 -2
- package/infrastructure/decorators/fields/CoordinateField.js +5 -1
- package/infrastructure/decorators/fields/CoordinateField.js.map +1 -1
- package/infrastructure/decorators/fields/CreateTimeField.js +5 -1
- package/infrastructure/decorators/fields/CreateTimeField.js.map +1 -1
- package/infrastructure/decorators/fields/DateField.js +5 -1
- package/infrastructure/decorators/fields/DateField.js.map +1 -1
- package/infrastructure/decorators/fields/DateTimeField.js +5 -1
- package/infrastructure/decorators/fields/DateTimeField.js.map +1 -1
- package/infrastructure/decorators/fields/DecimalField.d.ts +1 -2
- package/infrastructure/decorators/fields/DecimalField.js +5 -1
- package/infrastructure/decorators/fields/DecimalField.js.map +1 -1
- package/infrastructure/decorators/fields/EmailField.js +5 -1
- package/infrastructure/decorators/fields/EmailField.js.map +1 -1
- package/infrastructure/decorators/fields/EnumField.d.ts +2 -3
- package/infrastructure/decorators/fields/EnumField.js +5 -1
- package/infrastructure/decorators/fields/EnumField.js.map +1 -1
- package/infrastructure/decorators/fields/ExtendField.js +18 -5
- package/infrastructure/decorators/fields/ExtendField.js.map +1 -1
- package/infrastructure/decorators/fields/FileField.d.ts +1 -2
- package/infrastructure/decorators/fields/FileField.js +5 -1
- package/infrastructure/decorators/fields/FileField.js.map +1 -1
- package/infrastructure/decorators/fields/HtmlField.js +5 -1
- package/infrastructure/decorators/fields/HtmlField.js.map +1 -1
- package/infrastructure/decorators/fields/IntegerField.js +5 -1
- package/infrastructure/decorators/fields/IntegerField.js.map +1 -1
- package/infrastructure/decorators/fields/PasswordField.js +5 -1
- package/infrastructure/decorators/fields/PasswordField.js.map +1 -1
- package/infrastructure/decorators/fields/PhoneField.js +5 -1
- package/infrastructure/decorators/fields/PhoneField.js.map +1 -1
- package/infrastructure/decorators/fields/PrimaryKeyField.js +5 -1
- package/infrastructure/decorators/fields/PrimaryKeyField.js.map +1 -1
- package/infrastructure/decorators/fields/RelationField.d.ts +1 -1
- package/infrastructure/decorators/fields/RelationField.js +6 -1
- package/infrastructure/decorators/fields/RelationField.js.map +1 -1
- package/infrastructure/decorators/fields/StringField.js +5 -1
- package/infrastructure/decorators/fields/StringField.js.map +1 -1
- package/infrastructure/decorators/fields/TextField.js +5 -1
- package/infrastructure/decorators/fields/TextField.js.map +1 -1
- package/infrastructure/decorators/fields/TimeField.js +5 -1
- package/infrastructure/decorators/fields/TimeField.js.map +1 -1
- package/infrastructure/decorators/fields/UidField.js +5 -1
- package/infrastructure/decorators/fields/UidField.js.map +1 -1
- package/infrastructure/decorators/fields/UpdateTimeField.js +5 -1
- package/infrastructure/decorators/fields/UpdateTimeField.js.map +1 -1
- package/infrastructure/decorators/fields/index.d.ts +10 -0
- package/infrastructure/decorators/fields/index.js.map +1 -1
- package/infrastructure/helpers/MetaHelper.d.ts +12 -2
- package/infrastructure/helpers/MetaHelper.js +50 -8
- package/infrastructure/helpers/MetaHelper.js.map +1 -1
- package/infrastructure/pipes/SchemaSerializer.d.ts +5 -0
- package/infrastructure/pipes/SchemaSerializer.js +12 -0
- package/infrastructure/pipes/SchemaSerializer.js.map +1 -0
- package/infrastructure/repositories/CrudRepository.d.ts +7 -3
- package/infrastructure/repositories/CrudRepository.js +29 -15
- package/infrastructure/repositories/CrudRepository.js.map +1 -1
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/usecases/base/SearchQuery.d.ts +17 -0
- package/usecases/base/SearchQuery.js +40 -0
- package/usecases/base/SearchQuery.js.map +1 -0
- package/usecases/dtos/ContextDto.d.ts +8 -0
- package/usecases/dtos/ContextDto.js +7 -0
- package/usecases/dtos/ContextDto.js.map +1 -0
- package/usecases/helpers/DataMapperHelper.d.ts +3 -2
- package/usecases/helpers/DataMapperHelper.js +62 -6
- package/usecases/helpers/DataMapperHelper.js.map +1 -1
- package/usecases/helpers/SearchHelper.d.ts +4 -3
- package/usecases/helpers/SearchHelper.js +9 -7
- package/usecases/helpers/SearchHelper.js.map +1 -1
- package/usecases/helpers/ValidationHelper.d.ts +1 -1
- package/usecases/helpers/ValidationHelper.js +2 -2
- package/usecases/helpers/ValidationHelper.js.map +1 -1
- package/usecases/interfaces/ICrudRepository.d.ts +5 -2
- package/usecases/services/CrudService.d.ts +16 -7
- package/usecases/services/CrudService.js +33 -23
- package/usecases/services/CrudService.js.map +1 -1
- package/infrastructure/decorators/fields/ExtendFields.d.ts +0 -1
- package/infrastructure/decorators/fields/ExtendFields.js +0 -15
- package/infrastructure/decorators/fields/ExtendFields.js.map +0 -1
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ICondition } from '../../infrastructure/helpers/ConditionHelper';
|
|
2
|
+
import { Repository } from 'typeorm';
|
|
3
|
+
import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder';
|
|
4
|
+
export interface IQueryRelation {
|
|
5
|
+
name: string;
|
|
6
|
+
alias?: string;
|
|
7
|
+
isId?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export default class SearchQuery {
|
|
10
|
+
select?: string[];
|
|
11
|
+
excludeSelect?: string[];
|
|
12
|
+
relations?: IQueryRelation[];
|
|
13
|
+
condition?: ICondition;
|
|
14
|
+
static createFromSchema(SchemaClass: any): SearchQuery;
|
|
15
|
+
static prepare(dbRepository: Repository<any>, dbQuery: SelectQueryBuilder<any>, searchQuery: SearchQuery): void;
|
|
16
|
+
constructor(data?: SearchQuery);
|
|
17
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const MetaHelper_1 = require("../../infrastructure/helpers/MetaHelper");
|
|
4
|
+
const ConditionHelper_1 = require("../../infrastructure/helpers/ConditionHelper");
|
|
5
|
+
class SearchQuery {
|
|
6
|
+
constructor(data = {}) {
|
|
7
|
+
this.select = data.select;
|
|
8
|
+
this.excludeSelect = data.excludeSelect;
|
|
9
|
+
this.relations = data.relations;
|
|
10
|
+
this.condition = data.condition;
|
|
11
|
+
}
|
|
12
|
+
static createFromSchema(SchemaClass) {
|
|
13
|
+
return new SearchQuery(MetaHelper_1.MetaHelper.getSchemaQueryData(SchemaClass));
|
|
14
|
+
}
|
|
15
|
+
static prepare(dbRepository, dbQuery, searchQuery) {
|
|
16
|
+
const prefix = dbQuery.expressionMap.mainAlias.name + '.';
|
|
17
|
+
let select = searchQuery.select;
|
|
18
|
+
if (searchQuery.excludeSelect) {
|
|
19
|
+
select = dbRepository.metadata.columns
|
|
20
|
+
.map(column => column.propertyName)
|
|
21
|
+
.filter(name => !searchQuery.excludeSelect.includes(name));
|
|
22
|
+
}
|
|
23
|
+
if (select) {
|
|
24
|
+
dbQuery.select(select.map(name => prefix + name));
|
|
25
|
+
}
|
|
26
|
+
(searchQuery.relations || []).forEach(relation => {
|
|
27
|
+
if (relation.isId) {
|
|
28
|
+
dbQuery.loadRelationIdAndMap(prefix + (relation.alias || relation.name), prefix + relation.name);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
dbQuery.leftJoinAndSelect(prefix + relation.name, prefix + relation.name);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
if (searchQuery.condition) {
|
|
35
|
+
dbQuery.andWhere(ConditionHelper_1.ConditionHelper.toTypeOrm(searchQuery.condition));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.default = SearchQuery;
|
|
40
|
+
//# sourceMappingURL=SearchQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchQuery.js","sourceRoot":"","sources":["../../../src/usecases/base/SearchQuery.ts"],"names":[],"mappings":";;AAAA,wEAAmE;AACnE,kFAAyF;AAUzF,MAAqB,WAAW;IAiD5B,YAAY,OAAoB,EAAE;QAC9B,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;QAChC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IACpC,CAAC;IAhDD,MAAM,CAAC,gBAAgB,CAAC,WAAW;QAC/B,OAAO,IAAI,WAAW,CAAC,uBAAU,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAC,CAAC;IACvE,CAAC;IAED,MAAM,CAAC,OAAO,CACV,YAA6B,EAC7B,OAAgC,EAChC,WAAwB;QAGxB,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,SAAS,CAAC,IAAI,GAAG,GAAG,CAAC;QAG1D,IAAI,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;QAChC,IAAI,WAAW,CAAC,aAAa,EAAE;YAC3B,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,OAAO;iBACjC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC;iBAClC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;SAClE;QAED,IAAI,MAAM,EAAE;YACR,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;SACrD;QAGD,CAAC,WAAW,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC7C,IAAI,QAAQ,CAAC,IAAI,EAAE;gBACf,OAAO,CAAC,oBAAoB,CACxB,MAAM,GAAG,CAAC,QAAQ,CAAC,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC,EAC1C,MAAM,GAAG,QAAQ,CAAC,IAAI,CACzB,CAAC;aACL;iBAAM;gBACH,OAAO,CAAC,iBAAiB,CAAC,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;aAE7E;QACL,CAAC,CAAC,CAAC;QAGH,IAAI,WAAW,CAAC,SAAS,EAAE;YACvB,OAAO,CAAC,QAAQ,CAAC,iCAAe,CAAC,SAAS,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC;SACtE;IACL,CAAC;CAQJ;AAvDD,8BAuDC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextDto.js","sourceRoot":"","sources":["../../../src/usecases/dtos/ContextDto.ts"],"names":[],"mappings":";;;AAMA,MAAa,UAAU;CAEtB;AAFD,gCAEC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare class DataMapperHelper {
|
|
2
2
|
static getKeys(object: any): any;
|
|
3
|
-
static anyToModel(
|
|
4
|
-
static
|
|
3
|
+
static anyToModel(source: any, ModelClass: any, fieldNames?: any): any;
|
|
4
|
+
static anyToSchema(source: any, SchemaClass: any): any;
|
|
5
|
+
static anyToPlain(source: any): any;
|
|
5
6
|
}
|
|
@@ -3,19 +3,75 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.DataMapperHelper = void 0;
|
|
4
4
|
const lodash_1 = require("lodash");
|
|
5
5
|
const BaseField_1 = require("../../infrastructure/decorators/fields/BaseField");
|
|
6
|
+
const MetaHelper_1 = require("../../infrastructure/helpers/MetaHelper");
|
|
6
7
|
class DataMapperHelper {
|
|
7
8
|
static getKeys(object) {
|
|
8
9
|
return Reflect.getMetadata(BaseField_1.MODEL_FIELD_NAMES_KEY, object.prototype) || [];
|
|
9
10
|
}
|
|
10
|
-
static anyToModel(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
static anyToModel(source, ModelClass, fieldNames = null) {
|
|
12
|
+
if (!fieldNames) {
|
|
13
|
+
fieldNames = this.getKeys(ModelClass);
|
|
14
|
+
}
|
|
15
|
+
const model = new ModelClass();
|
|
16
|
+
fieldNames.forEach(fieldName => {
|
|
17
|
+
if ((0, lodash_1.has)(source, fieldName)) {
|
|
18
|
+
const value = source[fieldName];
|
|
19
|
+
if ((0, lodash_1.isObject)(value)) {
|
|
20
|
+
const modelMeta = MetaHelper_1.MetaHelper.getFieldOptions(ModelClass, fieldName);
|
|
21
|
+
if (modelMeta.appType === 'relation') {
|
|
22
|
+
model[fieldName] = this.anyToModel(value, modelMeta.modelClass());
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
model[fieldName] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else if ((0, lodash_1.has)(source, fieldName + 'Id')) {
|
|
32
|
+
model[fieldName + 'Id'] = source[fieldName + 'Id'];
|
|
33
|
+
}
|
|
34
|
+
else if ((0, lodash_1.has)(source, fieldName + 'Ids')) {
|
|
35
|
+
model[fieldName + 'Ids'] = source[fieldName + 'Ids'];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return model;
|
|
39
|
+
}
|
|
40
|
+
static anyToSchema(source, SchemaClass) {
|
|
41
|
+
const schema = new SchemaClass();
|
|
42
|
+
const keys = MetaHelper_1.MetaHelper.getFieldNames(SchemaClass);
|
|
43
|
+
keys.forEach(key => {
|
|
44
|
+
const meta = MetaHelper_1.MetaHelper.getFieldOptions(SchemaClass, key);
|
|
45
|
+
if (meta.appType === 'relation' && !/Ids?$/.exec(key)) {
|
|
46
|
+
let subSchemaClass = Reflect.getOwnMetadata('design:type', SchemaClass.prototype, key);
|
|
47
|
+
if (!(typeof subSchemaClass === 'function')) {
|
|
48
|
+
subSchemaClass = meta.modelClass();
|
|
49
|
+
}
|
|
50
|
+
schema[key] = DataMapperHelper.anyToSchema((0, lodash_1.has)(source, key) ? source[key] : null, subSchemaClass);
|
|
51
|
+
}
|
|
52
|
+
else if ((0, lodash_1.has)(source, key)) {
|
|
53
|
+
schema[key] = source[key];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
return schema;
|
|
14
57
|
}
|
|
15
|
-
static
|
|
58
|
+
static anyToPlain(source) {
|
|
59
|
+
if (Array.isArray(source)) {
|
|
60
|
+
return source.map(item => this.anyToPlain(item));
|
|
61
|
+
}
|
|
62
|
+
if ((0, lodash_1.isDate)(source)) {
|
|
63
|
+
return source;
|
|
64
|
+
}
|
|
16
65
|
if ((0, lodash_1.isObject)(source)) {
|
|
17
|
-
|
|
66
|
+
const keys = MetaHelper_1.MetaHelper.getFieldNames(source.constructor);
|
|
67
|
+
return Object.keys(source).reduce((obj, key) => {
|
|
68
|
+
if (!keys || keys.includes(key)) {
|
|
69
|
+
obj[key] = DataMapperHelper.anyToPlain(source[key]);
|
|
70
|
+
}
|
|
71
|
+
return obj;
|
|
72
|
+
}, {});
|
|
18
73
|
}
|
|
74
|
+
return source;
|
|
19
75
|
}
|
|
20
76
|
}
|
|
21
77
|
exports.DataMapperHelper = DataMapperHelper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataMapperHelper.js","sourceRoot":"","sources":["../../../src/usecases/helpers/DataMapperHelper.ts"],"names":[],"mappings":";;;AAAA,mCAIgB;
|
|
1
|
+
{"version":3,"file":"DataMapperHelper.js","sourceRoot":"","sources":["../../../src/usecases/helpers/DataMapperHelper.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Repository } from 'typeorm';
|
|
2
2
|
import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder';
|
|
3
|
-
import { SearchInputDto } from '
|
|
4
|
-
import { SearchResultDto } from '
|
|
3
|
+
import { SearchInputDto } from '../dtos/SearchInputDto';
|
|
4
|
+
import { SearchResultDto } from '../dtos/SearchResultDto';
|
|
5
|
+
import SearchQuery from '../base/SearchQuery';
|
|
5
6
|
export declare class SearchHelper {
|
|
6
|
-
static search<TTable>(repository: Repository<any>, dto: SearchInputDto, prepareHandler?: (query: SelectQueryBuilder<TTable>) => void | null): Promise<SearchResultDto<TTable>>;
|
|
7
|
+
static search<TTable>(repository: Repository<any>, dto: SearchInputDto, query: SearchQuery, prepareHandler?: (query: SelectQueryBuilder<TTable>) => void | null): Promise<SearchResultDto<TTable>>;
|
|
7
8
|
}
|
|
@@ -1,26 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SearchHelper = void 0;
|
|
4
|
-
const SearchResultDto_1 = require("
|
|
4
|
+
const SearchResultDto_1 = require("../dtos/SearchResultDto");
|
|
5
|
+
const SearchQuery_1 = require("../base/SearchQuery");
|
|
5
6
|
class SearchHelper {
|
|
6
|
-
static async search(repository, dto, prepareHandler = null) {
|
|
7
|
+
static async search(repository, dto, query, prepareHandler = null) {
|
|
7
8
|
const result = new SearchResultDto_1.SearchResultDto();
|
|
8
9
|
dto = Object.assign({ page: 1, pageSize: 50 }, dto);
|
|
9
|
-
const
|
|
10
|
+
const dbQuery = repository.createQueryBuilder();
|
|
11
|
+
SearchQuery_1.default.prepare(repository, dbQuery, query);
|
|
10
12
|
const sort = typeof dto.sort === 'string' ? dto.sort.split(',') : (dto.sort || []);
|
|
11
13
|
if (sort.length === 0) {
|
|
12
|
-
|
|
14
|
+
dbQuery.orderBy(sort.reduce((obj, value) => {
|
|
13
15
|
obj[value.replace('!', '')] = value.indexOf('!') === 0 ? 'DESC' : 'ASC';
|
|
14
16
|
return obj;
|
|
15
17
|
}, {}));
|
|
16
18
|
}
|
|
17
19
|
if (prepareHandler) {
|
|
18
|
-
prepareHandler.call(null,
|
|
20
|
+
prepareHandler.call(null, dbQuery);
|
|
19
21
|
}
|
|
20
|
-
|
|
22
|
+
dbQuery
|
|
21
23
|
.offset((dto.page - 1) * dto.pageSize)
|
|
22
24
|
.limit(dto.pageSize);
|
|
23
|
-
const [items, total] = await
|
|
25
|
+
const [items, total] = await dbQuery.getManyAndCount();
|
|
24
26
|
result.items = items;
|
|
25
27
|
result.total = total;
|
|
26
28
|
return result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchHelper.js","sourceRoot":"","sources":["../../../src/usecases/helpers/SearchHelper.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"SearchHelper.js","sourceRoot":"","sources":["../../../src/usecases/helpers/SearchHelper.ts"],"names":[],"mappings":";;;AAGA,6DAAwD;AACxD,qDAA8C;AAE9C,MAAa,YAAY;IAErB,MAAM,CAAC,KAAK,CAAC,MAAM,CACf,UAA2B,EAC3B,GAAmB,EACnB,KAAkB,EAClB,iBAAqE,IAAI;QAEzE,MAAM,MAAM,GAAG,IAAI,iCAAe,EAAU,CAAC;QAG7C,GAAG,mBACC,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,EAAE,IACT,GAAG,CACT,CAAC;QAGF,MAAM,OAAO,GAAG,UAAU,CAAC,kBAAkB,EAAE,CAAC;QAEhD,qBAAW,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;QAGhD,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;QACnF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE;YACnB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBACvC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;gBACxE,OAAO,GAAG,CAAC;YACf,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;SACX;QAGD,IAAI,cAAc,EAAE;YAChB,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;SACtC;QAGD,OAAO;aACF,MAAM,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,QAAQ,CAAC;aACrC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAGzB,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,MAAM,OAAO,CAAC,eAAe,EAAE,CAAC;QACvD,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QAErB,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAhDD,oCAgDC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { ValidatorOptions } from 'class-validator';
|
|
2
|
-
export declare function validateOrReject(
|
|
2
|
+
export declare function validateOrReject(dto: any, validatorOptions?: ValidatorOptions): Promise<void>;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.validateOrReject = void 0;
|
|
4
4
|
const class_validator_1 = require("class-validator");
|
|
5
5
|
const ValidationException_1 = require("../exceptions/ValidationException");
|
|
6
|
-
async function validateOrReject(
|
|
7
|
-
const errors = await (0, class_validator_1.validate)(
|
|
6
|
+
async function validateOrReject(dto, validatorOptions) {
|
|
7
|
+
const errors = await (0, class_validator_1.validate)(dto, validatorOptions);
|
|
8
8
|
if (errors.length) {
|
|
9
9
|
throw new ValidationException_1.ValidationException(errors);
|
|
10
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ValidationHelper.js","sourceRoot":"","sources":["../../../src/usecases/helpers/ValidationHelper.ts"],"names":[],"mappings":";;;AAAA,qDAA2D;AAC3D,2EAAsE;AAE/D,KAAK,UAAU,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"ValidationHelper.js","sourceRoot":"","sources":["../../../src/usecases/helpers/ValidationHelper.ts"],"names":[],"mappings":";;;AAAA,qDAA2D;AAC3D,2EAAsE;AAE/D,KAAK,UAAU,gBAAgB,CAAC,GAAQ,EAAE,gBAAmC;IAChF,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,EAAE;QACf,MAAM,IAAI,yCAAmB,CAAC,MAAM,CAAC,CAAC;KACzC;AACL,CAAC;AALD,4CAKC"}
|
|
@@ -2,10 +2,13 @@ import { Repository } from 'typeorm';
|
|
|
2
2
|
import { SearchResultDto } from '../dtos/SearchResultDto';
|
|
3
3
|
import { SearchInputDto } from '../dtos/SearchInputDto';
|
|
4
4
|
import { ICondition } from '../../infrastructure/helpers/ConditionHelper';
|
|
5
|
+
import { Type } from '@nestjs/common';
|
|
6
|
+
import SearchQuery from '../base/SearchQuery';
|
|
5
7
|
export interface ICrudRepository<TModel> {
|
|
6
8
|
dbRepository: Repository<any>;
|
|
7
|
-
search: (dto: SearchInputDto) => Promise<SearchResultDto<TModel
|
|
8
|
-
findOne: (
|
|
9
|
+
search: <TItem>(dto: SearchInputDto, searchQuery: SearchQuery) => Promise<SearchResultDto<TModel | Type<TItem>>>;
|
|
10
|
+
findOne: (conditionOrQuery: ICondition | SearchQuery) => Promise<TModel | null>;
|
|
11
|
+
findMany: (conditionOrQuery: ICondition | SearchQuery) => Promise<TModel[]>;
|
|
9
12
|
create: (model: TModel) => Promise<TModel>;
|
|
10
13
|
update: (id: number, model: TModel) => Promise<TModel>;
|
|
11
14
|
remove: (id: number) => Promise<void>;
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
+
import { Type } from '@nestjs/common';
|
|
1
2
|
import { ICrudRepository } from '../interfaces/ICrudRepository';
|
|
2
3
|
import { ISearchInputDto } from '../dtos/SearchInputDto';
|
|
3
4
|
import { SearchResultDto } from '../dtos/SearchResultDto';
|
|
5
|
+
import SearchQuery from '../base/SearchQuery';
|
|
6
|
+
import { ContextDto } from '../dtos/ContextDto';
|
|
4
7
|
export declare class CrudService<TModel, TSearchDto = ISearchInputDto, TSaveDto = TModel> {
|
|
5
8
|
protected primaryKey: string;
|
|
6
9
|
protected repository: ICrudRepository<TModel>;
|
|
7
10
|
protected modelClass: any;
|
|
8
11
|
init(repository: ICrudRepository<TModel>, ModelClass: any): void;
|
|
9
|
-
|
|
10
|
-
search(dto: TSearchDto): Promise<SearchResultDto<
|
|
11
|
-
findById(id: number | string): Promise<TModel>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
search(dto: TSearchDto, context?: ContextDto | null): Promise<SearchResultDto<TModel>>;
|
|
13
|
+
search<TSchema>(dto: TSearchDto, context?: ContextDto | null, schemaClass?: Type<TSchema>): Promise<SearchResultDto<Type<TSchema>>>;
|
|
14
|
+
findById(id: number | string, context?: ContextDto | null): Promise<TModel>;
|
|
15
|
+
findById<TSchema>(id: number | string, context?: ContextDto | null, schemaClass?: Type<TSchema>): Promise<Type<TSchema>>;
|
|
16
|
+
findOne(searchQuery: SearchQuery): Promise<TModel>;
|
|
17
|
+
findMany(searchQuery: SearchQuery): Promise<TModel[]>;
|
|
18
|
+
create(dto: TSaveDto, context?: ContextDto | null): Promise<TModel>;
|
|
19
|
+
create<TSchema>(dto: TSaveDto, context?: ContextDto | null, schemaClass?: Type<TSchema>): Promise<Type<TSchema>>;
|
|
20
|
+
update<TSchema>(id: number | string, dto: TSaveDto, context?: ContextDto | null): Promise<TModel>;
|
|
21
|
+
update<TSchema>(id: number | string, dto: TSaveDto, context?: ContextDto | null, schemaClass?: Type<TSchema>): Promise<Type<TSchema>>;
|
|
22
|
+
remove(id: number | string, context?: ContextDto): Promise<void>;
|
|
23
|
+
protected modelToSchema<TSchema>(model: TModel, schemaClass: Type<TSchema>): Type<TSchema>;
|
|
24
|
+
protected dtoToModel(dto: TSaveDto): Promise<TModel>;
|
|
16
25
|
}
|
|
@@ -2,8 +2,9 @@
|
|
|
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");
|
|
5
6
|
const ValidationHelper_1 = require("../helpers/ValidationHelper");
|
|
6
|
-
const
|
|
7
|
+
const SearchQuery_1 = require("../base/SearchQuery");
|
|
7
8
|
class CrudService {
|
|
8
9
|
constructor() {
|
|
9
10
|
this.primaryKey = 'id';
|
|
@@ -12,38 +13,47 @@ class CrudService {
|
|
|
12
13
|
this.repository = repository;
|
|
13
14
|
this.modelClass = ModelClass;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
const ModelClass = this.modelClass;
|
|
17
|
-
return new ModelClass();
|
|
18
|
-
}
|
|
19
|
-
async search(dto) {
|
|
16
|
+
async search(dto, context = null, schemaClass = null) {
|
|
20
17
|
await (0, ValidationHelper_1.validateOrReject)(dto);
|
|
21
|
-
const
|
|
22
|
-
|
|
18
|
+
const result = await this.repository.search(dto, SearchQuery_1.default.createFromSchema(schemaClass));
|
|
19
|
+
if (schemaClass) {
|
|
20
|
+
result.items = result.items.map((model) => this.modelToSchema(model, schemaClass));
|
|
21
|
+
}
|
|
22
|
+
return result;
|
|
23
|
+
}
|
|
24
|
+
async findById(id, context = null, schemaClass = null) {
|
|
25
|
+
const searchQuery = SearchQuery_1.default.createFromSchema(schemaClass);
|
|
26
|
+
searchQuery.condition = { [this.primaryKey]: (0, lodash_1.toInteger)(id) };
|
|
27
|
+
const model = await this.findOne(searchQuery);
|
|
28
|
+
return schemaClass ? this.modelToSchema(model, schemaClass) : model;
|
|
23
29
|
}
|
|
24
|
-
async
|
|
25
|
-
|
|
26
|
-
return model;
|
|
30
|
+
async findOne(searchQuery) {
|
|
31
|
+
return await this.repository.findOne(searchQuery);
|
|
27
32
|
}
|
|
28
|
-
async
|
|
33
|
+
async findMany(searchQuery) {
|
|
34
|
+
return await this.repository.findMany(searchQuery);
|
|
35
|
+
}
|
|
36
|
+
async create(dto, context = null, schemaClass = null) {
|
|
29
37
|
await (0, ValidationHelper_1.validateOrReject)(dto);
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const tmodel = await this.repository.create(model);
|
|
33
|
-
return tmodel;
|
|
38
|
+
const model = await this.repository.create(await this.dtoToModel(dto));
|
|
39
|
+
return schemaClass ? this.findById(model[this.primaryKey], context, schemaClass) : model;
|
|
34
40
|
}
|
|
35
|
-
async update(id, dto) {
|
|
41
|
+
async update(id, dto, context = null, schemaClass = null) {
|
|
36
42
|
await (0, ValidationHelper_1.validateOrReject)(dto);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
model = await this.repository.update((0, lodash_1.toInteger)(id), model);
|
|
40
|
-
return model;
|
|
43
|
+
const model = await this.repository.update((0, lodash_1.toInteger)(id), await this.dtoToModel(dto));
|
|
44
|
+
return schemaClass ? this.findById(id, context, schemaClass) : model;
|
|
41
45
|
}
|
|
42
|
-
async remove(id) {
|
|
46
|
+
async remove(id, context = null) {
|
|
43
47
|
await this.repository.remove((0, lodash_1.toInteger)(id));
|
|
44
48
|
}
|
|
49
|
+
modelToSchema(model, schemaClass) {
|
|
50
|
+
return DataMapperHelper_1.DataMapperHelper.anyToSchema(model, schemaClass);
|
|
51
|
+
}
|
|
45
52
|
dtoToModel(dto) {
|
|
46
|
-
|
|
53
|
+
if (!this.modelClass) {
|
|
54
|
+
throw new Error('Property modelClass is not set in service: ' + this.constructor.name);
|
|
55
|
+
}
|
|
56
|
+
return DataMapperHelper_1.DataMapperHelper.anyToModel(dto, this.modelClass);
|
|
47
57
|
}
|
|
48
58
|
}
|
|
49
59
|
exports.CrudService = CrudService;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CrudService.js","sourceRoot":"","sources":["../../../src/usecases/services/CrudService.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CrudService.js","sourceRoot":"","sources":["../../../src/usecases/services/CrudService.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function ExtendFields(modelClass: any): (object: any) => void;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtendFields = void 0;
|
|
4
|
-
const constants_1 = require("@nestjs/swagger/dist/constants");
|
|
5
|
-
function ExtendFields(modelClass) {
|
|
6
|
-
return (object) => {
|
|
7
|
-
const properties = Reflect.getMetadata(constants_1.DECORATORS.API_MODEL_PROPERTIES_ARRAY, modelClass.prototype);
|
|
8
|
-
(properties || []).forEach(propertyName => {
|
|
9
|
-
propertyName = propertyName.replace(/^:/, '');
|
|
10
|
-
console.log(11, Object.keys(object.prototype));
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
exports.ExtendFields = ExtendFields;
|
|
15
|
-
//# sourceMappingURL=ExtendFields.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExtendFields.js","sourceRoot":"","sources":["../../../../src/infrastructure/decorators/fields/ExtendFields.ts"],"names":[],"mappings":";;;AAAA,8DAA0D;AAG1D,SAAgB,YAAY,CAAC,UAAU;IACnC,OAAO,CAAC,MAAM,EAAE,EAAE;QACd,MAAM,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,sBAAU,CAAC,0BAA0B,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;QACpG,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE;YACtC,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YAE9C,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;QAEnD,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;AACN,CAAC;AAVD,oCAUC"}
|