@nest-omni/core 1.0.14 → 1.0.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/common/abstract-client.service.d.ts +16 -0
- package/dist/common/abstract-client.service.js +35 -0
- package/dist/common/abstract.entity.d.ts +17 -0
- package/dist/common/abstract.entity.js +64 -0
- package/dist/common/boilerplate.polyfill.d.ts +39 -0
- package/dist/common/boilerplate.polyfill.js +77 -0
- package/dist/common/dto/abstract.dto.d.ts +13 -0
- package/dist/common/dto/abstract.dto.js +59 -0
- package/dist/common/dto/bulk-id.dto.d.ts +3 -0
- package/dist/common/dto/bulk-id.dto.js +27 -0
- package/dist/common/dto/create-translation.dto.d.ts +5 -0
- package/dist/common/dto/create-translation.dto.js +25 -0
- package/dist/common/dto/index.d.ts +6 -0
- package/dist/common/dto/index.js +22 -0
- package/dist/common/dto/page-meta.dto.d.ts +15 -0
- package/dist/common/dto/page-meta.dto.js +48 -0
- package/dist/common/dto/page-options.dto.d.ts +8 -0
- package/dist/common/dto/page-options.dto.js +52 -0
- package/dist/common/dto/page.dto.d.ts +11 -0
- package/dist/common/dto/page.dto.js +53 -0
- package/dist/common/index.d.ts +7 -0
- package/dist/common/index.js +23 -0
- package/dist/common/snake-naming.strategy.d.ts +11 -0
- package/dist/common/snake-naming.strategy.js +37 -0
- package/dist/common/types.d.ts +9 -0
- package/dist/common/types.js +2 -0
- package/dist/common/utils.d.ts +3 -0
- package/dist/common/utils.js +25 -0
- package/dist/constants/index.d.ts +2 -0
- package/dist/constants/index.js +18 -0
- package/dist/constants/language-code.d.ts +5 -0
- package/dist/constants/language-code.js +9 -0
- package/dist/constants/order.d.ts +4 -0
- package/dist/constants/order.js +8 -0
- package/dist/decorators/api-page-ok-response.decorator.d.ts +5 -0
- package/dist/decorators/api-page-ok-response.decorator.js +25 -0
- package/dist/decorators/auth-user.decorator.d.ts +1 -0
- package/dist/decorators/auth-user.decorator.js +15 -0
- package/dist/decorators/controller.decorator.d.ts +1 -0
- package/dist/decorators/controller.decorator.js +11 -0
- package/dist/decorators/field.decorators.d.ts +71 -0
- package/dist/decorators/field.decorators.js +449 -0
- package/dist/decorators/http.decorators.d.ts +3 -0
- package/dist/decorators/http.decorators.js +8 -0
- package/dist/decorators/index.d.ts +12 -0
- package/dist/decorators/index.js +28 -0
- package/dist/decorators/omni-auth.decorator.d.ts +8 -0
- package/dist/decorators/omni-auth.decorator.js +35 -0
- package/dist/decorators/operation.decorator.d.ts +1 -0
- package/dist/decorators/operation.decorator.js +6 -0
- package/dist/decorators/property.decorators.d.ts +15 -0
- package/dist/decorators/property.decorators.js +32 -0
- package/dist/decorators/public-route.decorator.d.ts +3 -0
- package/dist/decorators/public-route.decorator.js +7 -0
- package/dist/decorators/swagger.schema.d.ts +5 -0
- package/dist/decorators/swagger.schema.js +79 -0
- package/dist/decorators/timestamp-column.decorator.d.ts +1 -0
- package/dist/decorators/timestamp-column.decorator.js +28 -0
- package/dist/decorators/transform.decorators.d.ts +8 -0
- package/dist/decorators/transform.decorators.js +95 -0
- package/dist/decorators/translate.decorator.d.ts +5 -0
- package/dist/decorators/translate.decorator.js +17 -0
- package/dist/decorators/use-dto.decorator.d.ts +4 -0
- package/dist/decorators/use-dto.decorator.js +9 -0
- package/dist/decorators/user-check.decorator.d.ts +6 -0
- package/dist/decorators/user-check.decorator.js +21 -0
- package/dist/decorators/user.decorator.d.ts +8 -0
- package/dist/decorators/user.decorator.js +38 -0
- package/dist/decorators/user_auth.decorator.d.ts +1 -0
- package/dist/decorators/user_auth.decorator.js +16 -0
- package/dist/decorators/validator.decorators.d.ts +10 -0
- package/dist/decorators/validator.decorators.js +59 -0
- package/dist/exceptions/file-not-image.exception.d.ts +4 -0
- package/dist/exceptions/file-not-image.exception.js +10 -0
- package/dist/exceptions/index.d.ts +2 -0
- package/dist/exceptions/index.js +18 -0
- package/dist/exceptions/page-type.exception.d.ts +4 -0
- package/dist/exceptions/page-type.exception.js +10 -0
- package/dist/exceptions/user-not-found.exception.d.ts +4 -0
- package/dist/exceptions/user-not-found.exception.js +10 -0
- package/dist/filters/bad-request.filter.d.ts +5 -0
- package/dist/filters/bad-request.filter.js +60 -0
- package/dist/filters/constraint-errors.d.ts +1 -0
- package/dist/filters/constraint-errors.js +6 -0
- package/dist/filters/index.d.ts +3 -0
- package/dist/filters/index.js +19 -0
- package/dist/filters/query-failed.filter.d.ts +10 -0
- package/dist/filters/query-failed.filter.js +42 -0
- package/dist/health-checker/health-checker.controller.d.ts +15 -0
- package/dist/health-checker/health-checker.controller.js +72 -0
- package/dist/health-checker/health-checker.module.d.ts +2 -0
- package/dist/health-checker/health-checker.module.js +25 -0
- package/dist/health-checker/health-indicators/service.indicator.d.ts +8 -0
- package/dist/health-checker/health-indicators/service.indicator.js +66 -0
- package/dist/helpers/common.helper.d.ts +3 -0
- package/dist/helpers/common.helper.js +36 -0
- package/dist/helpers/date.helper.d.ts +10 -0
- package/dist/helpers/date.helper.js +58 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.js +18 -0
- package/dist/i18n/en_US/validation.json +38 -0
- package/dist/i18n/zh_CN/validation.json +38 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +27 -0
- package/dist/interceptors/auth-user.interceptor.d.ts +4 -0
- package/dist/interceptors/auth-user.interceptor.js +24 -0
- package/dist/interceptors/index.d.ts +2 -0
- package/dist/interceptors/index.js +18 -0
- package/dist/interceptors/language-interceptor.service.d.ts +6 -0
- package/dist/interceptors/language-interceptor.service.js +30 -0
- package/dist/interceptors/translation-interceptor.service.d.ts +5 -0
- package/dist/interceptors/translation-interceptor.service.js +34 -0
- package/dist/interfaces/IApiFile.d.ts +4 -0
- package/dist/interfaces/IApiFile.js +2 -0
- package/dist/interfaces/IFile.d.ts +9 -0
- package/dist/interfaces/IFile.js +2 -0
- package/dist/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
- package/dist/interfaces/ITranslationDecoratorInterface.js +2 -0
- package/dist/interfaces/index.d.ts +3 -0
- package/dist/interfaces/index.js +19 -0
- package/dist/interfaces/response.d.ts +25 -0
- package/dist/interfaces/response.js +2 -0
- package/dist/middlewares/index.d.ts +3 -0
- package/dist/middlewares/index.js +19 -0
- package/dist/middlewares/omni-auth.middleware.d.ts +1 -0
- package/dist/middlewares/omni-auth.middleware.js +13 -0
- package/dist/middlewares/powerby.middleware.d.ts +1 -0
- package/dist/middlewares/powerby.middleware.js +10 -0
- package/dist/middlewares/request-id.middleware.d.ts +7 -0
- package/dist/middlewares/request-id.middleware.js +22 -0
- package/dist/providers/context.provider.d.ts +32 -0
- package/dist/providers/context.provider.js +71 -0
- package/dist/providers/generator.provider.d.ts +9 -0
- package/dist/providers/generator.provider.js +50 -0
- package/dist/providers/index.d.ts +2 -0
- package/dist/providers/index.js +18 -0
- package/dist/setup/bootstrap.setup.d.ts +5 -0
- package/dist/setup/bootstrap.setup.js +112 -0
- package/dist/setup/index.d.ts +1 -0
- package/dist/setup/index.js +17 -0
- package/dist/shared/index.d.ts +2 -0
- package/dist/shared/index.js +18 -0
- package/dist/shared/serviceRegistryModule.d.ts +2 -0
- package/dist/shared/serviceRegistryModule.js +110 -0
- package/dist/shared/services/api-config.service.d.ts +70 -0
- package/dist/shared/services/api-config.service.js +290 -0
- package/dist/shared/services/aws-s3.service.d.ts +10 -0
- package/dist/shared/services/aws-s3.service.js +56 -0
- package/dist/shared/services/generator.service.d.ts +4 -0
- package/dist/shared/services/generator.service.js +23 -0
- package/dist/shared/services/index.d.ts +5 -0
- package/dist/shared/services/index.js +21 -0
- package/dist/shared/services/translation.service.d.ts +9 -0
- package/dist/shared/services/translation.service.js +70 -0
- package/dist/shared/services/validator.service.d.ts +3 -0
- package/dist/shared/services/validator.service.js +20 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/validator-json/decorators.d.ts +6 -0
- package/dist/validator-json/decorators.js +23 -0
- package/dist/validator-json/default.d.ts +6 -0
- package/dist/validator-json/default.js +130 -0
- package/dist/validator-json/defaultConverters.d.ts +8 -0
- package/dist/validator-json/defaultConverters.js +376 -0
- package/dist/validator-json/index.d.ts +4 -0
- package/dist/validator-json/index.js +20 -0
- package/dist/validator-json/options.d.ts +11 -0
- package/dist/validator-json/options.js +10 -0
- package/dist/validators/file-mimetype.validator.d.ts +13 -0
- package/dist/validators/file-mimetype.validator.js +21 -0
- package/dist/validators/index.d.ts +6 -0
- package/dist/validators/index.js +22 -0
- package/dist/validators/is-exists.validator.d.ts +18 -0
- package/dist/validators/is-exists.validator.js +61 -0
- package/dist/validators/is-unique.validator.d.ts +17 -0
- package/dist/validators/is-unique.validator.js +92 -0
- package/dist/validators/phone-country-code.validator.d.ts +2 -0
- package/dist/validators/phone-country-code.validator.js +30 -0
- package/dist/validators/same-as.validator.d.ts +2 -0
- package/dist/validators/same-as.validator.js +25 -0
- package/dist/validators/skip-empty.validator.d.ts +1 -0
- package/dist/validators/skip-empty.validator.js +18 -0
- package/package.json +2 -17
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
+
import type { EntitySchema, FindOptionsWhere, ObjectType } from 'typeorm';
|
|
3
|
+
import { DataSource } from 'typeorm';
|
|
4
|
+
export declare class IsExistsValidator implements ValidatorConstraintInterface {
|
|
5
|
+
private readonly dataSource;
|
|
6
|
+
constructor(dataSource: DataSource);
|
|
7
|
+
validate<E>(value: string, args: IExistsValidationArguments<E>): Promise<boolean>;
|
|
8
|
+
defaultMessage(args: ValidationArguments): string;
|
|
9
|
+
}
|
|
10
|
+
type ExistsValidationConstraints<E> = [
|
|
11
|
+
ObjectType<E> | EntitySchema<E> | string,
|
|
12
|
+
(validationArguments: ValidationArguments) => FindOptionsWhere<E>
|
|
13
|
+
];
|
|
14
|
+
interface IExistsValidationArguments<E> extends ValidationArguments {
|
|
15
|
+
constraints: ExistsValidationConstraints<E>;
|
|
16
|
+
}
|
|
17
|
+
export declare function IsExists<E>(constraints: Partial<ExistsValidationConstraints<E>>, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.IsExists = exports.IsExistsValidator = void 0;
|
|
22
|
+
const class_validator_1 = require("class-validator");
|
|
23
|
+
const typeorm_1 = require("typeorm");
|
|
24
|
+
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
25
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
26
|
+
const common_1 = require("@nestjs/common");
|
|
27
|
+
let IsExistsValidator = class IsExistsValidator {
|
|
28
|
+
constructor(dataSource) {
|
|
29
|
+
this.dataSource = dataSource;
|
|
30
|
+
this.dataSource = (0, typeorm_transactional_1.getDataSourceByName)('default');
|
|
31
|
+
}
|
|
32
|
+
validate(value, args) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const [entityClass, findCondition] = args.constraints;
|
|
35
|
+
return ((yield this.dataSource.getRepository(entityClass).count({
|
|
36
|
+
where: findCondition(args),
|
|
37
|
+
})) > 0);
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
defaultMessage(args) {
|
|
41
|
+
return (0, nestjs_i18n_1.i18nValidationMessage)('validation.IS_EXISTS')(args);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.IsExistsValidator = IsExistsValidator;
|
|
45
|
+
exports.IsExistsValidator = IsExistsValidator = __decorate([
|
|
46
|
+
(0, common_1.Injectable)(),
|
|
47
|
+
(0, class_validator_1.ValidatorConstraint)({ name: 'isExists', async: true }),
|
|
48
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
49
|
+
], IsExistsValidator);
|
|
50
|
+
function IsExists(constraints, validationOptions) {
|
|
51
|
+
return (object, propertyName) => {
|
|
52
|
+
(0, class_validator_1.registerDecorator)({
|
|
53
|
+
target: object.constructor,
|
|
54
|
+
propertyName,
|
|
55
|
+
options: validationOptions,
|
|
56
|
+
constraints,
|
|
57
|
+
validator: IsExistsValidator,
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
exports.IsExists = IsExists;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ValidationArguments, ValidationOptions, ValidatorConstraintInterface } from 'class-validator';
|
|
2
|
+
import { DataSource, EntitySchema, FindOptionsWhere, ObjectType } from 'typeorm';
|
|
3
|
+
export declare class IsUniqueValidator implements ValidatorConstraintInterface {
|
|
4
|
+
private readonly dataSource;
|
|
5
|
+
constructor(dataSource: DataSource);
|
|
6
|
+
validate<E>(value: string, args: IUniqueValidationArguments<E>): Promise<boolean>;
|
|
7
|
+
defaultMessage(args: ValidationArguments): string;
|
|
8
|
+
}
|
|
9
|
+
type UniqueValidationConstraints<E> = [
|
|
10
|
+
ObjectType<E> | EntitySchema<E> | string,
|
|
11
|
+
(validationArguments: ValidationArguments) => FindOptionsWhere<E>
|
|
12
|
+
];
|
|
13
|
+
interface IUniqueValidationArguments<E> extends ValidationArguments {
|
|
14
|
+
constraints: UniqueValidationConstraints<E>;
|
|
15
|
+
}
|
|
16
|
+
export declare function IsUnique<E>(constraints: Partial<UniqueValidationConstraints<E>>, validationOptions?: ValidationOptions): PropertyDecorator;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
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
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.IsUnique = exports.IsUniqueValidator = void 0;
|
|
22
|
+
const class_validator_1 = require("class-validator");
|
|
23
|
+
const typeorm_1 = require("typeorm");
|
|
24
|
+
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
25
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
26
|
+
let IsUniqueValidator = class IsUniqueValidator {
|
|
27
|
+
constructor(dataSource) {
|
|
28
|
+
this.dataSource = dataSource;
|
|
29
|
+
this.dataSource = (0, typeorm_transactional_1.getDataSourceByName)('default');
|
|
30
|
+
}
|
|
31
|
+
validate(value, args) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const [entityClass, findCondition] = args.constraints;
|
|
34
|
+
let exists;
|
|
35
|
+
const defCon = findCondition(args);
|
|
36
|
+
const pkCols = this.dataSource
|
|
37
|
+
.getMetadata(entityClass)
|
|
38
|
+
.primaryColumns.map((column) => column.propertyName);
|
|
39
|
+
const isNew = pkCols.some((pk) => args.object[pk]);
|
|
40
|
+
if (!isNew) {
|
|
41
|
+
exists =
|
|
42
|
+
(yield this.dataSource
|
|
43
|
+
.getRepository(entityClass)
|
|
44
|
+
.count({ where: defCon })) < 1;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
const entities = yield this.dataSource
|
|
48
|
+
.getRepository(entityClass)
|
|
49
|
+
.createQueryBuilder()
|
|
50
|
+
.where(defCon)
|
|
51
|
+
.select(pkCols)
|
|
52
|
+
.limit(2)
|
|
53
|
+
.execute();
|
|
54
|
+
const entityCount = entities.length;
|
|
55
|
+
if (entityCount === 1) {
|
|
56
|
+
const entity = entities[0];
|
|
57
|
+
const oldPk = {};
|
|
58
|
+
const newPk = {};
|
|
59
|
+
pkCols.map((pk) => {
|
|
60
|
+
oldPk[pk] = entity[pk];
|
|
61
|
+
newPk[pk] = args.object[pk];
|
|
62
|
+
});
|
|
63
|
+
exists = JSON.stringify(oldPk) === JSON.stringify(newPk);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
exists = entityCount < 1;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return exists;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
defaultMessage(args) {
|
|
73
|
+
return (0, nestjs_i18n_1.i18nValidationMessage)('validation.IS_UNIQUE')(args);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
exports.IsUniqueValidator = IsUniqueValidator;
|
|
77
|
+
exports.IsUniqueValidator = IsUniqueValidator = __decorate([
|
|
78
|
+
(0, class_validator_1.ValidatorConstraint)({ name: 'isUnique', async: true }),
|
|
79
|
+
__metadata("design:paramtypes", [typeorm_1.DataSource])
|
|
80
|
+
], IsUniqueValidator);
|
|
81
|
+
function IsUnique(constraints, validationOptions) {
|
|
82
|
+
return function (object, propertyName) {
|
|
83
|
+
(0, class_validator_1.registerDecorator)({
|
|
84
|
+
target: object.constructor,
|
|
85
|
+
propertyName,
|
|
86
|
+
options: validationOptions,
|
|
87
|
+
constraints,
|
|
88
|
+
validator: IsUniqueValidator,
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
exports.IsUnique = IsUnique;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsPhoneNumberWithCountryCode = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function IsPhoneNumberWithCountryCode(validationOptions) {
|
|
6
|
+
return function (object, propertyName) {
|
|
7
|
+
(0, class_validator_1.ValidateIf)((_, value) => !!value)(object, propertyName);
|
|
8
|
+
const countryCodePropertyName = 'countryCode';
|
|
9
|
+
(0, class_validator_1.registerDecorator)({
|
|
10
|
+
name: 'isPhoneNumberWithCountryCode',
|
|
11
|
+
target: object.constructor,
|
|
12
|
+
propertyName: propertyName,
|
|
13
|
+
constraints: [countryCodePropertyName],
|
|
14
|
+
options: validationOptions,
|
|
15
|
+
validator: {
|
|
16
|
+
validate(value, args) {
|
|
17
|
+
const [countryCodePropertyName] = args.constraints;
|
|
18
|
+
const countryCode = args.object[countryCodePropertyName];
|
|
19
|
+
return (0, class_validator_1.isPhoneNumber)(value, countryCode);
|
|
20
|
+
},
|
|
21
|
+
defaultMessage(args) {
|
|
22
|
+
const [countryCodePropertyName] = args.constraints;
|
|
23
|
+
const countryCode = args.object[countryCodePropertyName];
|
|
24
|
+
return `$property must be a valid phone number in the country code ${countryCode}`;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.IsPhoneNumberWithCountryCode = IsPhoneNumberWithCountryCode;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SameAs = void 0;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function SameAs(property, validationOptions) {
|
|
6
|
+
return function (object, propertyName) {
|
|
7
|
+
(0, class_validator_1.registerDecorator)({
|
|
8
|
+
name: 'sameAs',
|
|
9
|
+
target: object.constructor,
|
|
10
|
+
propertyName,
|
|
11
|
+
options: validationOptions,
|
|
12
|
+
constraints: [property],
|
|
13
|
+
validator: {
|
|
14
|
+
validate(value, args) {
|
|
15
|
+
const [relatedPropertyName] = args.constraints;
|
|
16
|
+
return (args === null || args === void 0 ? void 0 : args.object[relatedPropertyName]) === value;
|
|
17
|
+
},
|
|
18
|
+
defaultMessage() {
|
|
19
|
+
return '$property must match $constraint1';
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
exports.SameAs = SameAs;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SkipEmpty(field?: string): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkipEmpty = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const class_validator_1 = require("class-validator");
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
|
+
function SkipEmpty(field) {
|
|
9
|
+
return (0, common_1.applyDecorators)((0, swagger_1.ApiProperty)({ required: false }), (0, class_validator_1.ValidateIf)((obj, value) => {
|
|
10
|
+
if (field) {
|
|
11
|
+
value = obj[field];
|
|
12
|
+
}
|
|
13
|
+
return !(value === null ||
|
|
14
|
+
value === undefined ||
|
|
15
|
+
((0, lodash_1.isString)(value) && value.trim() === ''));
|
|
16
|
+
}));
|
|
17
|
+
}
|
|
18
|
+
exports.SkipEmpty = SkipEmpty;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-omni/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -18,22 +18,7 @@
|
|
|
18
18
|
"typescript": "^5.4.5"
|
|
19
19
|
},
|
|
20
20
|
"files": [
|
|
21
|
-
"
|
|
22
|
-
"constants",
|
|
23
|
-
"decorators",
|
|
24
|
-
"exceptions",
|
|
25
|
-
"filters",
|
|
26
|
-
"health-checker",
|
|
27
|
-
"helpers",
|
|
28
|
-
"i18n",
|
|
29
|
-
"interceptors",
|
|
30
|
-
"interfaces",
|
|
31
|
-
"middlewares",
|
|
32
|
-
"providers",
|
|
33
|
-
"setup",
|
|
34
|
-
"shared",
|
|
35
|
-
"validators",
|
|
36
|
-
"validator-json"
|
|
21
|
+
"dist"
|
|
37
22
|
],
|
|
38
23
|
"peerDependencies": {
|
|
39
24
|
"@dataui/crud": "^5.3.0",
|