@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,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConditionHelper = void 0;
|
|
4
|
+
const typeorm_1 = require("typeorm");
|
|
5
|
+
const notCondition = (isNot, condition) => isNot ? (0, typeorm_1.Not)(condition) : condition;
|
|
6
|
+
class ConditionHelper {
|
|
7
|
+
static toTypeOrm(condition) {
|
|
8
|
+
if (typeof condition === 'function') {
|
|
9
|
+
return new typeorm_1.Brackets(condition);
|
|
10
|
+
}
|
|
11
|
+
if (typeof condition === 'object' && !Array.isArray(condition)) {
|
|
12
|
+
return condition;
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(condition) && condition.length > 1 && typeof condition[0] === 'string') {
|
|
15
|
+
let operator = condition[0].toLowerCase();
|
|
16
|
+
const isNot = operator.indexOf('not') === 0;
|
|
17
|
+
if (isNot) {
|
|
18
|
+
operator = operator.replace(/^not\s+/, '');
|
|
19
|
+
}
|
|
20
|
+
const key = condition[1];
|
|
21
|
+
const value = condition[2];
|
|
22
|
+
switch (operator) {
|
|
23
|
+
case '=':
|
|
24
|
+
return { [key]: notCondition(isNot, value) };
|
|
25
|
+
case '>':
|
|
26
|
+
return { [key]: notCondition(isNot, (0, typeorm_1.MoreThan)(value)) };
|
|
27
|
+
case '>=':
|
|
28
|
+
case '=>':
|
|
29
|
+
return { [key]: notCondition(isNot, (0, typeorm_1.MoreThanOrEqual)(value)) };
|
|
30
|
+
case '<':
|
|
31
|
+
return { [key]: notCondition(isNot, (0, typeorm_1.LessThan)(value)) };
|
|
32
|
+
case '<=':
|
|
33
|
+
case '=<':
|
|
34
|
+
return { [key]: notCondition(isNot, (0, typeorm_1.LessThanOrEqual)(value)) };
|
|
35
|
+
case 'like':
|
|
36
|
+
return { [key]: notCondition(isNot, (0, typeorm_1.Like)(value)) };
|
|
37
|
+
case 'ilike':
|
|
38
|
+
return { [key]: notCondition(isNot, (0, typeorm_1.ILike)(value)) };
|
|
39
|
+
case 'between':
|
|
40
|
+
return { [key]: notCondition(isNot, (0, typeorm_1.Between)(condition[2], condition[3])) };
|
|
41
|
+
case 'in':
|
|
42
|
+
if (!Array.isArray(value)) {
|
|
43
|
+
throw Error('Wrong value for IN operator: ' + JSON.stringify(value));
|
|
44
|
+
}
|
|
45
|
+
return { [key]: notCondition(isNot, (0, typeorm_1.In)(value)) };
|
|
46
|
+
case 'and':
|
|
47
|
+
case '&&':
|
|
48
|
+
if (isNot) {
|
|
49
|
+
throw Error('Unsupport NOT for AND operator. Operator: ' + operator);
|
|
50
|
+
}
|
|
51
|
+
return new typeorm_1.Brackets(query2 => {
|
|
52
|
+
condition.slice(1).forEach(item => {
|
|
53
|
+
query2.andWhere(ConditionHelper.toTypeOrm(item));
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
case 'or':
|
|
57
|
+
case '||':
|
|
58
|
+
if (isNot) {
|
|
59
|
+
throw Error('Unsupport NOT for OR operator. Operator: ' + operator);
|
|
60
|
+
}
|
|
61
|
+
return new typeorm_1.Brackets(query2 => {
|
|
62
|
+
condition.slice(1).forEach(item => {
|
|
63
|
+
query2.orWhere(ConditionHelper.toTypeOrm(item));
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
default:
|
|
67
|
+
throw Error('Wrong operator: ' + operator);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
throw Error('Wrong condition: ' + JSON.stringify(condition));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.ConditionHelper = ConditionHelper;
|
|
74
|
+
//# sourceMappingURL=ConditionHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConditionHelper.js","sourceRoot":"","sources":["../../../src/infrastructure/helpers/ConditionHelper.ts"],"names":[],"mappings":";;;AAAA,qCAAsH;AAYtH,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,aAAG,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AAE9E,MAAa,eAAe;IACxB,MAAM,CAAC,SAAS,CAAC,SAAqB;QAClC,IAAI,OAAO,SAAS,KAAK,UAAU,EAAE;YACjC,OAAO,IAAI,kBAAQ,CAAC,SAAS,CAAC,CAAC;SAClC;QAED,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE;YAC5D,OAAO,SAAS,CAAC;SACpB;QAED,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,IAAI,OAAO,SAAS,C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,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;4BAC9B,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;wBACpD,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;gBAEP;oBACI,MAAM,KAAK,CAAC,kBAAkB,GAAG,QAAQ,CAAC,CAAC;aAClD;SACJ;QAED,MAAM,KAAK,CAAC,mBAAmB,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;IACjE,CAAC;CACJ;AAnFD,0CAmFC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataMapperHelper = void 0;
|
|
4
|
+
const lodash_1 = require("lodash");
|
|
5
|
+
class DataMapperHelper {
|
|
6
|
+
static anyToModel(obj, ModelClass) {
|
|
7
|
+
const result = new ModelClass();
|
|
8
|
+
Object.assign(result, obj);
|
|
9
|
+
return result;
|
|
10
|
+
}
|
|
11
|
+
static applyFields(target, source, fields = null) {
|
|
12
|
+
if ((0, lodash_1.isObject)(source)) {
|
|
13
|
+
Object.assign(target, source);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.DataMapperHelper = DataMapperHelper;
|
|
18
|
+
//# sourceMappingURL=DataMapperHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataMapperHelper.js","sourceRoot":"","sources":["../../../src/infrastructure/helpers/DataMapperHelper.ts"],"names":[],"mappings":";;;AAAA,mCAIgB;AAGhB,MAAa,gBAAgB;IACzB,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,UAAU;QAC7B,MAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,MAAqC,EAAE,MAAW,EAAE,SAAmB,IAAI;QAC1F,IAAI,IAAA,iBAAS,EAAC,MAAM,CAAC,EAAE;YACnB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAkBjC;IACL,CAAC;CACJ;AA7BD,4CA6BC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MetaHelper = void 0;
|
|
4
|
+
const constants_1 = require("@nestjs/swagger/dist/constants");
|
|
5
|
+
const BaseField_1 = require("../decorators/fields/BaseField");
|
|
6
|
+
class MetaHelper {
|
|
7
|
+
static exportModels(connection, types) {
|
|
8
|
+
const result = {};
|
|
9
|
+
types.forEach(type => {
|
|
10
|
+
const typeormMeta = connection.getMetadata(type);
|
|
11
|
+
result[typeormMeta.name] = {
|
|
12
|
+
attributes: typeormMeta.columns.map(column => {
|
|
13
|
+
const attribute = column.propertyName;
|
|
14
|
+
const apiMeta = Reflect.getMetadata(constants_1.DECORATORS.API_MODEL_PROPERTIES, type.prototype, attribute);
|
|
15
|
+
const modelMeta = Reflect.getMetadata(BaseField_1.MODEL_META_KEY, type.prototype, attribute);
|
|
16
|
+
return Object.assign({ attribute, type: modelMeta.appType || 'string', label: modelMeta.label || apiMeta.description, required: apiMeta.required }, (modelMeta.items ? { items: modelMeta.items } : {}));
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
static exportEnums(types) {
|
|
23
|
+
const result = {};
|
|
24
|
+
types.forEach(type => {
|
|
25
|
+
if (type.toArray) {
|
|
26
|
+
result[type.name] = {
|
|
27
|
+
labels: type.toArray(),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.MetaHelper = MetaHelper;
|
|
35
|
+
//# sourceMappingURL=MetaHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MetaHelper.js","sourceRoot":"","sources":["../../../src/infrastructure/helpers/MetaHelper.ts"],"names":[],"mappings":";;;AACA,8DAA0D;AAC1D,8DAA8D;AAE9D,MAAa,UAAU;IACnB,MAAM,CAAC,YAAY,CAAC,UAAsB,EAAE,KAAY;QACpD,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,MAAM,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;YACjD,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG;gBACvB,UAAU,EAAE,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;oBACzC,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC;oBACtC,MAAM,OAAO,GAAG,OAAO,CAAC,WAAW,CAAC,sBAAU,CAAC,oBAAoB,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;oBAChG,MAAM,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,0BAAc,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;oBAEjF,uBACI,SAAS,EACT,IAAI,EAAE,SAAS,CAAC,OAAO,IAAI,QAAQ,EACnC,KAAK,EAAE,SAAS,CAAC,KAAK,IAAI,OAAO,CAAC,WAAW,EAC7C,QAAQ,EAAE,OAAO,CAAC,QAAQ,IACvB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC,KAAK,EAAE,SAAS,CAAC,KAAK,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EACtD;gBACN,CAAC,CAAC;aACL,CAAC;QAGN,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,KAAY;QAC3B,MAAM,MAAM,GAAG,EAAE,CAAC;QAClB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;YACjB,IAAI,IAAI,CAAC,OAAO,EAAE;gBACd,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;oBAChB,MAAM,EAAE,IAAI,CAAC,OAAO,EAAE;iBACzB,CAAC;aACL;QACL,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AArCD,gCAqCC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { SelectQueryBuilder } from 'typeorm/query-builder/SelectQueryBuilder';
|
|
3
|
+
import { SearchInputDto } from '../../usecases/dtos/SearchInputDto';
|
|
4
|
+
import { SearchResultDto } from '../../usecases/dtos/SearchResultDto';
|
|
5
|
+
export declare class SearchHelper {
|
|
6
|
+
static search<T>(repository: Repository<T>, dto: SearchInputDto, prepareHandler?: (query: SelectQueryBuilder<T>) => void | null): Promise<SearchResultDto<T>>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchHelper = void 0;
|
|
4
|
+
const SearchResultDto_1 = require("../../usecases/dtos/SearchResultDto");
|
|
5
|
+
class SearchHelper {
|
|
6
|
+
static async search(repository, dto, prepareHandler = null) {
|
|
7
|
+
const result = new SearchResultDto_1.SearchResultDto();
|
|
8
|
+
dto = Object.assign({ page: 1, pageSize: 50 }, dto);
|
|
9
|
+
const query = repository.createQueryBuilder();
|
|
10
|
+
const sort = typeof dto.sort === 'string' ? dto.sort.split(',') : (dto.sort || []);
|
|
11
|
+
if (sort.length === 0) {
|
|
12
|
+
query.orderBy(sort.reduce((obj, value) => {
|
|
13
|
+
obj[value.replace('!', '')] = value.indexOf('!') === 0 ? 'DESC' : 'ASC';
|
|
14
|
+
return obj;
|
|
15
|
+
}, {}));
|
|
16
|
+
}
|
|
17
|
+
if (prepareHandler) {
|
|
18
|
+
prepareHandler.call(null, query);
|
|
19
|
+
}
|
|
20
|
+
query
|
|
21
|
+
.offset((dto.page - 1) * dto.pageSize)
|
|
22
|
+
.limit(dto.pageSize);
|
|
23
|
+
const [items, total] = await query.getManyAndCount();
|
|
24
|
+
result.items = items;
|
|
25
|
+
result.total = total;
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.SearchHelper = SearchHelper;
|
|
30
|
+
//# sourceMappingURL=SearchHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchHelper.js","sourceRoot":"","sources":["../../../src/infrastructure/helpers/SearchHelper.ts"],"names":[],"mappings":";;;AAGA,yEAAoE;AAEpE,MAAa,YAAY;IACrB,MAAM,CAAC,KAAK,CAAC,MAAM,CACf,UAAyB,EACzB,GAAmB,EACnB,iBAAgE,IAAI;QAEpE,MAAM,MAAM,GAAG,IAAI,iCAAe,EAAK,CAAC;QAGxC,GAAG,mBACC,IAAI,EAAE,CAAC,EACP,QAAQ,EAAE,EAAE,IACT,GAAG,CACT,CAAC;QAGF,MAAM,KAAK,GAAG,UAAU,CAAC,kBAAkB,EAAE,CAAC;QAG9C,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,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE;gBACrC,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,KAAK,CAAC,CAAC;SACpC;QAGD,KAAK;aACA,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,KAAK,CAAC,eAAe,EAAE,CAAC;QACrD,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC;QAErB,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AA5CD,oCA4CC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.ValidationPipe = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const class_transformer_1 = require("class-transformer");
|
|
12
|
+
const class_validator_1 = require("class-validator");
|
|
13
|
+
const ValidationException_1 = require("../exception/ValidationException");
|
|
14
|
+
let ValidationPipe = class ValidationPipe {
|
|
15
|
+
async transform(value, metadata) {
|
|
16
|
+
const obj = (0, class_transformer_1.plainToInstance)(metadata.metatype, value) || {};
|
|
17
|
+
if (typeof obj === 'object') {
|
|
18
|
+
const errors = await (0, class_validator_1.validate)(obj);
|
|
19
|
+
if (errors.length) {
|
|
20
|
+
throw new ValidationException_1.ValidationException({
|
|
21
|
+
errors: errors.reduce((result, item) => {
|
|
22
|
+
result[item.property] = []
|
|
23
|
+
.concat(obj[item.property] || [])
|
|
24
|
+
.concat(Object.values(item.constraints));
|
|
25
|
+
return result;
|
|
26
|
+
}, {}),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
ValidationPipe = __decorate([
|
|
34
|
+
(0, common_1.Injectable)()
|
|
35
|
+
], ValidationPipe);
|
|
36
|
+
exports.ValidationPipe = ValidationPipe;
|
|
37
|
+
//# sourceMappingURL=ValidationPipe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ValidationPipe.js","sourceRoot":"","sources":["../../../src/infrastructure/pipes/ValidationPipe.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAC3E,yDAAkD;AAClD,qDAAyC;AACzC,0EAAqE;AAGrE,IAAa,cAAc,GAA3B,MAAa,cAAc;IACvB,KAAK,CAAC,SAAS,CAAC,KAAU,EAAE,QAA0B;QAClD,MAAM,GAAG,GAAG,IAAA,mCAAe,EAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QAC5D,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YACzB,MAAM,MAAM,GAAG,MAAM,IAAA,0BAAQ,EAAC,GAAG,CAAC,CAAC;YACnC,IAAI,MAAM,CAAC,MAAM,EAAE;gBACf,MAAM,IAAI,yCAAmB,CAAC;oBAC1B,MAAM,EAAE,MAAM,CAAC,MAAM,CACjB,CAAC,MAAW,EAAE,IAAI,EAAE,EAAE;wBAClB,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE;6BACrB,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;6BAChC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;wBAC7C,OAAO,MAAM,CAAC;oBAClB,CAAC,EACD,EAAE,CACL;iBACJ,CAAC,CAAC;aACN;SACJ;QACD,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ,CAAA;AArBY,cAAc;IAD1B,IAAA,mBAAU,GAAE;GACA,cAAc,CAqB1B;AArBY,wCAAc"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Repository } from 'typeorm';
|
|
2
|
+
import { ICrudRepository } from '../../usecases/interfaces/ICrudRepository';
|
|
3
|
+
import { SearchInputDto } from '../../usecases/dtos/SearchInputDto';
|
|
4
|
+
import { ICondition } from '../helpers/ConditionHelper';
|
|
5
|
+
import { SearchResultDto } from '../../usecases/dtos/SearchResultDto';
|
|
6
|
+
export declare class CrudRepository<TModel> implements ICrudRepository<TModel> {
|
|
7
|
+
primaryKey: string;
|
|
8
|
+
dbRepository: Repository<TModel>;
|
|
9
|
+
protected modelClass: any;
|
|
10
|
+
init(dbRepository: Repository<TModel>, modelClass: any): void;
|
|
11
|
+
search(dto: SearchInputDto): Promise<SearchResultDto<TModel>>;
|
|
12
|
+
findOne(condition: ICondition): Promise<TModel>;
|
|
13
|
+
create(model: TModel): Promise<TModel>;
|
|
14
|
+
update(id: number, model: TModel): Promise<TModel>;
|
|
15
|
+
remove(id: number): Promise<void>;
|
|
16
|
+
protected modelToEntity(model: any): Record<string, unknown>;
|
|
17
|
+
protected entityToModel(obj: any): TModel;
|
|
18
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrudRepository = void 0;
|
|
4
|
+
const class_transformer_1 = require("class-transformer");
|
|
5
|
+
const SearchHelper_1 = require("../helpers/SearchHelper");
|
|
6
|
+
const ConditionHelper_1 = require("../helpers/ConditionHelper");
|
|
7
|
+
class CrudRepository {
|
|
8
|
+
constructor() {
|
|
9
|
+
this.primaryKey = 'id';
|
|
10
|
+
}
|
|
11
|
+
init(dbRepository, modelClass) {
|
|
12
|
+
this.dbRepository = dbRepository;
|
|
13
|
+
this.modelClass = modelClass;
|
|
14
|
+
}
|
|
15
|
+
async search(dto) {
|
|
16
|
+
const result = await SearchHelper_1.SearchHelper.search(this.dbRepository, dto);
|
|
17
|
+
result.items = result.items.map(item => this.entityToModel(item));
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
async findOne(condition) {
|
|
21
|
+
const entity = await this.dbRepository.createQueryBuilder()
|
|
22
|
+
.where(ConditionHelper_1.ConditionHelper.toTypeOrm(condition))
|
|
23
|
+
.getOne();
|
|
24
|
+
return this.entityToModel(entity);
|
|
25
|
+
}
|
|
26
|
+
async create(model) {
|
|
27
|
+
const entity = await this.dbRepository.manager.save(this.modelToEntity(model));
|
|
28
|
+
return this.entityToModel(entity);
|
|
29
|
+
}
|
|
30
|
+
async update(id, model) {
|
|
31
|
+
const prevModel = await this.findOne({ [this.primaryKey]: id });
|
|
32
|
+
const toSave = Object.assign(Object.assign({}, prevModel), model);
|
|
33
|
+
const entity = await this.dbRepository.update(id, toSave);
|
|
34
|
+
return this.entityToModel(entity);
|
|
35
|
+
}
|
|
36
|
+
async remove(id) {
|
|
37
|
+
await this.dbRepository.delete(id);
|
|
38
|
+
}
|
|
39
|
+
modelToEntity(model) {
|
|
40
|
+
const EntityClass = this.dbRepository.target;
|
|
41
|
+
const entity = new EntityClass();
|
|
42
|
+
Object.assign(entity, (0, class_transformer_1.instanceToPlain)(model));
|
|
43
|
+
return entity;
|
|
44
|
+
}
|
|
45
|
+
entityToModel(obj) {
|
|
46
|
+
const ModelClass = this.modelClass;
|
|
47
|
+
const model = new ModelClass();
|
|
48
|
+
Object.assign(model, (0, class_transformer_1.instanceToPlain)(obj));
|
|
49
|
+
return model;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.CrudRepository = CrudRepository;
|
|
53
|
+
//# sourceMappingURL=CrudRepository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CrudRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/CrudRepository.ts"],"names":[],"mappings":";;;AACA,yDAAkD;AAClD,0DAAqD;AAGrD,gEAAuE;AAMvE,MAAa,cAAc;IAA3B;QAIW,eAAU,GAAW,IAAI,CAAC;IAwGrC,CAAC;IA1FU,IAAI,CAAC,YAAgC,EAAE,UAAe;QACzD,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IACjC,CAAC;IAMD,KAAK,CAAC,MAAM,CAAC,GAAmB;QAC5B,MAAM,MAAM,GAAG,MAAM,2BAAY,CAAC,MAAM,CAAS,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;QACzE,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,OAAO,MAAM,CAAC;IAClB,CAAC;IAMD,KAAK,CAAC,OAAO,CAAC,SAAqB;QAC/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,kBAAkB,EAAE;aACtD,KAAK,CAAC,iCAAe,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;aAC3C,MAAM,EAAE,CAAC;QACd,OAAO,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAMD,K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GD,wCA4GC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SearchSchema } from './SearchSchema';
|
|
2
|
+
export default class BaseSchema<Model> {
|
|
3
|
+
constructor();
|
|
4
|
+
static createFromModel(model: any): BaseSchema<unknown>;
|
|
5
|
+
static createFromSearch<Model>(searchResult: SearchSchema<Model>): SearchSchema<BaseSchema<Model>>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
class BaseSchema {
|
|
4
|
+
constructor() {
|
|
5
|
+
}
|
|
6
|
+
static createFromModel(model) {
|
|
7
|
+
const schema = new this();
|
|
8
|
+
return schema;
|
|
9
|
+
}
|
|
10
|
+
static createFromSearch(searchResult) {
|
|
11
|
+
const result = { total: null, items: [] };
|
|
12
|
+
result.total = searchResult.total;
|
|
13
|
+
result.meta = searchResult.meta;
|
|
14
|
+
result.items = searchResult.items.map(model => BaseSchema.createFromModel(model));
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.default = BaseSchema;
|
|
19
|
+
//# sourceMappingURL=BaseSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseSchema.js","sourceRoot":"","sources":["../../../src/infrastructure/schemas/BaseSchema.ts"],"names":[],"mappings":";;AAEA,MAAqB,UAAU;IAC3B;IAEA,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,KAAU;QAC7B,MAAM,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QAC1B,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAQ,YAAiC;QAC5D,MAAM,MAAM,GAAoC,EAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAC,CAAC;QACzE,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;QAClC,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;QAChC,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,UAAU,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;QAClF,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAjBD,6BAiBC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.SearchSchema = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
class SearchSchema {
|
|
15
|
+
static createFromDto(searchResult) {
|
|
16
|
+
const result = new this();
|
|
17
|
+
result.items = searchResult.items;
|
|
18
|
+
result.meta = searchResult.meta;
|
|
19
|
+
result.total = searchResult.total;
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, swagger_1.ApiProperty)(),
|
|
25
|
+
__metadata("design:type", Number)
|
|
26
|
+
], SearchSchema.prototype, "total", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, swagger_1.ApiProperty)(),
|
|
29
|
+
__metadata("design:type", Object)
|
|
30
|
+
], SearchSchema.prototype, "meta", void 0);
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, swagger_1.ApiProperty)(),
|
|
33
|
+
__metadata("design:type", Array)
|
|
34
|
+
], SearchSchema.prototype, "items", void 0);
|
|
35
|
+
exports.SearchSchema = SearchSchema;
|
|
36
|
+
//# sourceMappingURL=SearchSchema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchSchema.js","sourceRoot":"","sources":["../../../src/infrastructure/schemas/SearchSchema.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA4C;AAG5C,MAAa,YAAY;IAUrB,MAAM,CAAC,aAAa,CAAI,YAAgC;QACpD,MAAM,MAAM,GAAG,IAAI,IAAI,EAAK,CAAC;QAC7B,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;QAClC,MAAM,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;QAChC,MAAM,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC;QAClC,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ;AAfG;IADC,IAAA,qBAAW,GAAE;;2CACC;AAGf;IADC,IAAA,qBAAW,GAAE;;0CACH;AAGX;IADC,IAAA,qBAAW,GAAE;;2CACE;AARpB,oCAiBC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@steroidsjs/nest",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"build": "tsc && copyfiles ./{package.json,LICENSE,README.md} dist/"
|
|
6
|
+
},
|
|
7
|
+
"description": "",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"author": "Vladimir Kozhin <hello@kozhindev.com>",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/steroids/nest"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"homepage": "https://github.com/steroids/nest",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/steroids/nest/issues"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@nestjs/cli": "^8.1.6",
|
|
21
|
+
"@nestjs/common": "^8.0.0",
|
|
22
|
+
"@nestjs/config": "^1.1.5",
|
|
23
|
+
"@nestjs/core": "^8.0.0",
|
|
24
|
+
"@nestjs/swagger": "^5.1.5",
|
|
25
|
+
"@nestjs/typeorm": "^8.0.2",
|
|
26
|
+
"@sqltools/formatter": "^1.2.3",
|
|
27
|
+
"class-transformer": "^0.5.1",
|
|
28
|
+
"class-validator": "^0.13.2",
|
|
29
|
+
"lodash": "^4.17.21",
|
|
30
|
+
"nestjs-command": "^3.1.1",
|
|
31
|
+
"typeorm": "^0.2.41",
|
|
32
|
+
"uuid": "^8.3.2"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"copyfiles": "^2.4.1",
|
|
36
|
+
"tsconfig-paths": "^3.10.1",
|
|
37
|
+
"typescript": "^4.3.5",
|
|
38
|
+
"@types/node": "^16.11.7"
|
|
39
|
+
}
|
|
40
|
+
}
|