@nest-omni/core 3.1.1-9 → 3.1.1
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/.hygen/new/crud/controller.ejs.t +82 -0
- package/.hygen/new/crud/create.dto.ejs.t +12 -0
- package/.hygen/new/crud/entity.ejs.t +26 -0
- package/.hygen/new/crud/get.dto.ejs.t +19 -0
- package/.hygen/new/crud/index-dto.ejs.t +29 -0
- package/.hygen/new/crud/index-response.dto.ejs.t +18 -0
- package/.hygen/new/crud/module.ejs.t +32 -0
- package/.hygen/new/crud/prompt.js +89 -0
- package/.hygen/new/crud/service.ejs.t +76 -0
- package/.hygen/new/crud/update.dto.ejs.t +11 -0
- package/.hygen/new/module/controller.ejs.t +93 -0
- package/.hygen/new/module/create-command.ejs.t +90 -0
- package/.hygen/new/module/create.dto.ejs.t +11 -0
- package/.hygen/new/module/dto.ejs.t +24 -0
- package/.hygen/new/module/entity.ejs.t +33 -0
- package/.hygen/new/module/get-query.ejs.t +57 -0
- package/.hygen/new/module/module.ejs.t +44 -0
- package/.hygen/new/module/not-found.exception.ejs.t +18 -0
- package/.hygen/new/module/page-options.dto.ejs.t +12 -0
- package/.hygen/new/module/prompt.js +104 -0
- package/.hygen/new/module/repository.ejs.t +16 -0
- package/.hygen/new/module/service.ejs.t +139 -0
- package/.hygen/new/module/translation-dto.ejs.t +27 -0
- package/.hygen/new/module/translation-entity.ejs.t +40 -0
- package/.hygen/new/module/translation-repository.ejs.t +16 -0
- package/.hygen/new/module/update.dto.ejs.t +10 -0
- package/.hygen.js +116 -0
- package/cache/cache-metrics.service.d.ts +83 -0
- package/cache/cache-metrics.service.js +298 -0
- package/cache/cache-serialization.service.d.ts +22 -0
- package/cache/cache-serialization.service.js +122 -0
- package/cache/cache.constants.d.ts +2 -0
- package/cache/cache.constants.js +5 -0
- package/cache/cache.health.d.ts +35 -0
- package/cache/cache.health.js +193 -0
- package/cache/cache.module.d.ts +26 -0
- package/cache/cache.module.js +155 -0
- package/cache/cache.service.d.ts +37 -0
- package/cache/cache.service.js +308 -0
- package/cache/cache.warmup.service.d.ts +34 -0
- package/cache/cache.warmup.service.js +199 -0
- package/cache/decorators/cache-evict.decorator.d.ts +2 -0
- package/cache/decorators/cache-evict.decorator.js +72 -0
- package/cache/decorators/cache-put.decorator.d.ts +2 -0
- package/cache/decorators/cache-put.decorator.js +48 -0
- package/cache/decorators/cacheable.decorator.d.ts +4 -0
- package/cache/decorators/cacheable.decorator.js +68 -0
- package/cache/decorators/index.d.ts +3 -0
- package/cache/decorators/index.js +11 -0
- package/cache/dependencies/callback.dependency.d.ts +11 -0
- package/cache/dependencies/callback.dependency.js +92 -0
- package/cache/dependencies/chain.dependency.d.ts +20 -0
- package/cache/dependencies/chain.dependency.js +113 -0
- package/cache/dependencies/db.dependency.d.ts +15 -0
- package/cache/dependencies/db.dependency.js +71 -0
- package/cache/dependencies/file.dependency.d.ts +17 -0
- package/cache/dependencies/file.dependency.js +63 -0
- package/cache/dependencies/index.d.ts +6 -0
- package/cache/dependencies/index.js +22 -0
- package/cache/dependencies/tag.dependency.d.ts +16 -0
- package/cache/dependencies/tag.dependency.js +75 -0
- package/cache/dependencies/time.dependency.d.ts +19 -0
- package/cache/dependencies/time.dependency.js +71 -0
- package/cache/examples/basic-usage.d.ts +58 -0
- package/cache/examples/basic-usage.js +379 -0
- package/cache/index.d.ts +15 -0
- package/cache/index.js +44 -0
- package/cache/interfaces/cache-dependency.interface.d.ts +11 -0
- package/cache/interfaces/cache-dependency.interface.js +2 -0
- package/cache/interfaces/cache-options.interface.d.ts +32 -0
- package/cache/interfaces/cache-options.interface.js +9 -0
- package/cache/interfaces/cache-provider.interface.d.ts +28 -0
- package/cache/interfaces/cache-provider.interface.js +2 -0
- package/cache/interfaces/index.d.ts +3 -0
- package/cache/interfaces/index.js +19 -0
- package/cache/providers/base-cache.provider.d.ts +16 -0
- package/cache/providers/base-cache.provider.js +32 -0
- package/cache/providers/cls-cache.provider.d.ts +16 -0
- package/cache/providers/cls-cache.provider.js +140 -0
- package/cache/providers/index.d.ts +4 -0
- package/cache/providers/index.js +23 -0
- package/cache/providers/memory-cache.provider.d.ts +26 -0
- package/cache/providers/memory-cache.provider.js +171 -0
- package/cache/providers/redis-cache.provider.d.ts +23 -0
- package/cache/providers/redis-cache.provider.js +215 -0
- package/cache/utils/dependency-manager.util.d.ts +15 -0
- package/cache/utils/dependency-manager.util.js +141 -0
- package/cache/utils/index.d.ts +2 -0
- package/cache/utils/index.js +18 -0
- package/cache/utils/key-generator.util.d.ts +13 -0
- package/cache/utils/key-generator.util.js +74 -0
- package/common/abstract.entity.d.ts +20 -0
- package/common/abstract.entity.js +81 -0
- package/common/boilerplate.polyfill.d.ts +50 -0
- package/common/boilerplate.polyfill.js +152 -0
- package/common/dto/abstract.dto.d.ts +13 -0
- package/common/dto/abstract.dto.js +59 -0
- package/common/dto/bulk-id.dto.d.ts +3 -0
- package/common/dto/bulk-id.dto.js +27 -0
- package/common/dto/create-translation.dto.d.ts +5 -0
- package/common/dto/create-translation.dto.js +25 -0
- package/common/dto/dto-container.d.ts +9 -0
- package/common/dto/dto-container.js +59 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +59 -0
- package/common/dto/dto-extensions.d.ts +12 -0
- package/common/dto/dto-extensions.js +63 -0
- package/common/dto/dto-service-accessor.d.ts +7 -0
- package/common/dto/dto-service-accessor.js +49 -0
- package/common/dto/dto-transformer.d.ts +11 -0
- package/common/dto/dto-transformer.js +49 -0
- package/common/dto/index.d.ts +12 -0
- package/common/dto/index.js +28 -0
- package/common/dto/page-meta.dto.d.ts +15 -0
- package/common/dto/page-meta.dto.js +48 -0
- package/common/dto/page-options.dto.d.ts +5 -0
- package/common/dto/page-options.dto.js +40 -0
- package/common/dto/page.dto.d.ts +11 -0
- package/common/dto/page.dto.js +53 -0
- package/common/examples/paginate-and-map.example.d.ts +14 -0
- package/common/examples/paginate-and-map.example.js +158 -0
- package/common/index.d.ts +6 -0
- package/common/index.js +22 -0
- package/common/snake-naming.strategy.d.ts +11 -0
- package/common/snake-naming.strategy.js +37 -0
- package/common/types.d.ts +9 -0
- package/common/types.js +2 -0
- package/common/utils.d.ts +3 -0
- package/common/utils.js +24 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +18 -0
- package/constants/language-code.d.ts +5 -0
- package/constants/language-code.js +9 -0
- package/constants/order.d.ts +4 -0
- package/constants/order.js +8 -0
- package/decorators/api-page-ok-response.decorator.d.ts +5 -0
- package/decorators/api-page-ok-response.decorator.js +24 -0
- package/decorators/auth-user.decorator.d.ts +1 -0
- package/decorators/auth-user.decorator.js +14 -0
- package/decorators/controller.decorator.d.ts +1 -0
- package/decorators/controller.decorator.js +10 -0
- package/decorators/examples/validation-decorators.example.d.ts +69 -0
- package/decorators/examples/validation-decorators.example.js +331 -0
- package/decorators/field.decorators.d.ts +79 -0
- package/decorators/field.decorators.js +499 -0
- package/decorators/http.decorators.d.ts +3 -0
- package/decorators/http.decorators.js +7 -0
- package/decorators/index.d.ts +12 -0
- package/decorators/index.js +28 -0
- package/decorators/operation.decorator.d.ts +1 -0
- package/decorators/operation.decorator.js +6 -0
- package/decorators/property.decorators.d.ts +15 -0
- package/decorators/property.decorators.js +31 -0
- package/decorators/public-route.decorator.d.ts +3 -0
- package/decorators/public-route.decorator.js +7 -0
- package/decorators/swagger.schema.d.ts +5 -0
- package/decorators/swagger.schema.js +78 -0
- package/decorators/timestamp-column.decorator.d.ts +1 -0
- package/decorators/timestamp-column.decorator.js +27 -0
- package/decorators/transform.decorators.d.ts +8 -0
- package/decorators/transform.decorators.js +100 -0
- package/decorators/translate.decorator.d.ts +5 -0
- package/decorators/translate.decorator.js +17 -0
- package/decorators/use-dto.decorator.d.ts +4 -0
- package/decorators/use-dto.decorator.js +8 -0
- package/decorators/user-check.decorator.d.ts +6 -0
- package/decorators/user-check.decorator.js +21 -0
- package/decorators/user.decorator.d.ts +12 -0
- package/decorators/user.decorator.js +44 -0
- package/decorators/user_auth.decorator.d.ts +1 -0
- package/decorators/user_auth.decorator.js +15 -0
- package/decorators/validator.decorators.d.ts +18 -0
- package/decorators/validator.decorators.js +193 -0
- package/exceptions/file-not-image.exception.d.ts +4 -0
- package/exceptions/file-not-image.exception.js +10 -0
- package/exceptions/index.d.ts +2 -0
- package/exceptions/index.js +18 -0
- package/exceptions/page-type.exception.d.ts +4 -0
- package/exceptions/page-type.exception.js +10 -0
- package/exceptions/user-not-found.exception.d.ts +4 -0
- package/exceptions/user-not-found.exception.js +10 -0
- package/filters/bad-request.filter.d.ts +5 -0
- package/filters/bad-request.filter.js +71 -0
- package/filters/constraint-errors.d.ts +1 -0
- package/filters/constraint-errors.js +6 -0
- package/filters/index.d.ts +3 -0
- package/filters/index.js +19 -0
- package/filters/query-failed.filter.d.ts +10 -0
- package/filters/query-failed.filter.js +42 -0
- package/health-checker/health-checker.controller.d.ts +13 -0
- package/health-checker/health-checker.controller.js +69 -0
- package/health-checker/health-checker.module.d.ts +2 -0
- package/health-checker/health-checker.module.js +24 -0
- package/health-checker/index.d.ts +2 -0
- package/health-checker/index.js +18 -0
- package/helpers/common.helper.d.ts +3 -0
- package/helpers/common.helper.js +36 -0
- package/helpers/date.helper.d.ts +10 -0
- package/helpers/date.helper.js +57 -0
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +18 -0
- package/i18n/en_US/validation.json +44 -0
- package/i18n/zh_CN/validation.json +44 -0
- package/index.d.ts +18 -0
- package/index.js +3 -0
- package/interceptors/index.d.ts +2 -0
- package/interceptors/index.js +18 -0
- package/interceptors/language-interceptor.service.d.ts +6 -0
- package/interceptors/language-interceptor.service.js +29 -0
- package/interceptors/translation-interceptor.service.d.ts +5 -0
- package/interceptors/translation-interceptor.service.js +34 -0
- package/interfaces/IApiFile.d.ts +4 -0
- package/interfaces/IApiFile.js +2 -0
- package/interfaces/IFile.d.ts +8 -0
- package/interfaces/IFile.js +2 -0
- package/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
- package/interfaces/ITranslationDecoratorInterface.js +2 -0
- package/interfaces/index.d.ts +3 -0
- package/interfaces/index.js +19 -0
- package/interfaces/response.d.ts +25 -0
- package/interfaces/response.js +2 -0
- package/middlewares/index.d.ts +4 -0
- package/middlewares/index.js +20 -0
- package/middlewares/omni-auth.middleware.d.ts +1 -0
- package/middlewares/omni-auth.middleware.js +13 -0
- package/middlewares/powerby.middleware.d.ts +1 -0
- package/middlewares/powerby.middleware.js +10 -0
- package/middlewares/request-id.middleware.d.ts +7 -0
- package/middlewares/request-id.middleware.js +22 -0
- package/middlewares/xml.middleware.d.ts +4 -0
- package/middlewares/xml.middleware.js +24 -0
- package/package.json +41 -116
- package/providers/context.provider.d.ts +34 -0
- package/providers/context.provider.js +80 -0
- package/providers/generator.provider.d.ts +9 -0
- package/providers/generator.provider.js +50 -0
- package/providers/index.d.ts +2 -0
- package/providers/index.js +18 -0
- package/redis-lock/examples/lock-strategy.examples.d.ts +73 -0
- package/redis-lock/examples/lock-strategy.examples.js +387 -0
- package/redis-lock/index.d.ts +4 -0
- package/redis-lock/index.js +16 -0
- package/redis-lock/redis-lock.decorator.d.ts +12 -0
- package/redis-lock/redis-lock.decorator.js +125 -0
- package/redis-lock/redis-lock.module.d.ts +23 -0
- package/redis-lock/redis-lock.module.js +117 -0
- package/redis-lock/redis-lock.service.d.ts +66 -0
- package/redis-lock/redis-lock.service.js +413 -0
- package/setup/bootstrap.setup.d.ts +2 -0
- package/setup/bootstrap.setup.js +184 -0
- package/setup/index.d.ts +4 -0
- package/setup/index.js +20 -0
- package/setup/mode.setup.d.ts +12 -0
- package/setup/mode.setup.js +60 -0
- package/setup/schedule.decorator.d.ts +23 -0
- package/setup/schedule.decorator.js +233 -0
- package/setup/worker.decorator.d.ts +14 -0
- package/setup/worker.decorator.js +130 -0
- package/shared/index.d.ts +2 -0
- package/shared/index.js +18 -0
- package/shared/serviceRegistryModule.d.ts +2 -0
- package/shared/serviceRegistryModule.js +170 -0
- package/shared/services/api-config.service.d.ts +54 -0
- package/shared/services/api-config.service.js +287 -0
- package/shared/services/generator.service.d.ts +4 -0
- package/shared/services/generator.service.js +23 -0
- package/shared/services/index.d.ts +4 -0
- package/shared/services/index.js +20 -0
- package/shared/services/translation.service.d.ts +9 -0
- package/shared/services/translation.service.js +70 -0
- package/shared/services/validator.service.d.ts +3 -0
- package/shared/services/validator.service.js +20 -0
- package/validator-json/decorators.d.ts +6 -0
- package/validator-json/decorators.js +22 -0
- package/validator-json/default.d.ts +6 -0
- package/validator-json/default.js +138 -0
- package/validator-json/defaultConverters.d.ts +8 -0
- package/validator-json/defaultConverters.js +376 -0
- package/validator-json/index.d.ts +4 -0
- package/validator-json/index.js +20 -0
- package/validator-json/options.d.ts +11 -0
- package/validator-json/options.js +10 -0
- package/validators/file-mimetype.validator.d.ts +13 -0
- package/validators/file-mimetype.validator.js +21 -0
- package/validators/index.d.ts +6 -0
- package/validators/index.js +22 -0
- package/validators/is-exists.validator.d.ts +18 -0
- package/validators/is-exists.validator.js +60 -0
- package/validators/is-unique.validator.d.ts +17 -0
- package/validators/is-unique.validator.js +91 -0
- package/validators/phone-country-code.validator.d.ts +2 -0
- package/validators/phone-country-code.validator.js +29 -0
- package/validators/same-as.validator.d.ts +2 -0
- package/validators/same-as.validator.js +24 -0
- package/validators/skip-empty.validator.d.ts +1 -0
- package/validators/skip-empty.validator.js +17 -0
- package/vault/index.d.ts +4 -0
- package/vault/index.js +20 -0
- package/vault/interfaces/vault-options.interface.d.ts +22 -0
- package/vault/interfaces/vault-options.interface.js +2 -0
- package/vault/vault-config.loader.d.ts +13 -0
- package/vault/vault-config.loader.js +246 -0
- package/vault/vault-config.service.d.ts +18 -0
- package/vault/vault-config.service.js +174 -0
- package/vault/vault.module.d.ts +2 -0
- package/vault/vault.module.js +21 -0
|
@@ -0,0 +1,331 @@
|
|
|
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.PaymentMethodDto = exports.EmployeeDto = exports.CreateProductDto = exports.UserRegistrationDto = exports.DiscountDto = exports.OrderDto = exports.EmailCheckDto = exports.PasswordDto = exports.SearchDto = exports.ContactDto = void 0;
|
|
22
|
+
const class_validator_1 = require("class-validator");
|
|
23
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
24
|
+
const validator_decorators_1 = require("../validator.decorators");
|
|
25
|
+
const field_decorators_1 = require("../field.decorators");
|
|
26
|
+
class ContactDto {
|
|
27
|
+
}
|
|
28
|
+
exports.ContactDto = ContactDto;
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
31
|
+
(0, class_validator_1.IsEmail)(),
|
|
32
|
+
(0, validator_decorators_1.AtLeastOneField)(['email', 'phone', 'wechat']),
|
|
33
|
+
__metadata("design:type", String)
|
|
34
|
+
], ContactDto.prototype, "email", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
37
|
+
(0, class_validator_1.IsString)(),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], ContactDto.prototype, "phone", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
42
|
+
(0, class_validator_1.IsString)(),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], ContactDto.prototype, "wechat", void 0);
|
|
45
|
+
class SearchDto {
|
|
46
|
+
}
|
|
47
|
+
exports.SearchDto = SearchDto;
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, field_decorators_1.StringFieldOptional)(),
|
|
50
|
+
(0, validator_decorators_1.AtLeastOneField)(['keyword', 'category', 'tags'], {
|
|
51
|
+
message: 'Please provide at least one search criteria: keyword, category, or tags',
|
|
52
|
+
}),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], SearchDto.prototype, "keyword", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, field_decorators_1.StringFieldOptional)(),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], SearchDto.prototype, "category", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, field_decorators_1.StringFieldOptional)({ each: true }),
|
|
61
|
+
__metadata("design:type", Array)
|
|
62
|
+
], SearchDto.prototype, "tags", void 0);
|
|
63
|
+
class PasswordDto {
|
|
64
|
+
}
|
|
65
|
+
exports.PasswordDto = PasswordDto;
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, validator_decorators_1.CustomValidation)((value) => {
|
|
68
|
+
if (!value || value.length < 8)
|
|
69
|
+
return false;
|
|
70
|
+
const hasUppercase = /[A-Z]/.test(value);
|
|
71
|
+
const hasLowercase = /[a-z]/.test(value);
|
|
72
|
+
const hasNumber = /[0-9]/.test(value);
|
|
73
|
+
return hasUppercase && hasLowercase && hasNumber;
|
|
74
|
+
}, {
|
|
75
|
+
message: 'Password must be at least 8 characters with uppercase, lowercase, and number',
|
|
76
|
+
}),
|
|
77
|
+
(0, swagger_1.ApiProperty)(),
|
|
78
|
+
__metadata("design:type", String)
|
|
79
|
+
], PasswordDto.prototype, "password", void 0);
|
|
80
|
+
class EmailCheckDto {
|
|
81
|
+
}
|
|
82
|
+
exports.EmailCheckDto = EmailCheckDto;
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, validator_decorators_1.CustomValidation)((value, args) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const userService = args.object.userService;
|
|
86
|
+
if (!userService) {
|
|
87
|
+
console.warn('UserService not found, skipping email check');
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
const exists = yield userService.checkEmailExists(value);
|
|
91
|
+
return !exists;
|
|
92
|
+
}), {
|
|
93
|
+
message: 'Email already exists in the system',
|
|
94
|
+
}),
|
|
95
|
+
(0, class_validator_1.IsEmail)(),
|
|
96
|
+
(0, swagger_1.ApiProperty)(),
|
|
97
|
+
__metadata("design:type", String)
|
|
98
|
+
], EmailCheckDto.prototype, "email", void 0);
|
|
99
|
+
class OrderDto {
|
|
100
|
+
}
|
|
101
|
+
exports.OrderDto = OrderDto;
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, swagger_1.ApiProperty)({ enum: ['standard', 'express'] }),
|
|
104
|
+
(0, class_validator_1.IsString)(),
|
|
105
|
+
__metadata("design:type", String)
|
|
106
|
+
], OrderDto.prototype, "orderType", void 0);
|
|
107
|
+
__decorate([
|
|
108
|
+
(0, validator_decorators_1.CustomValidation)((value, args) => {
|
|
109
|
+
const object = args.object;
|
|
110
|
+
if (object.orderType === 'express') {
|
|
111
|
+
return value !== null && value !== undefined;
|
|
112
|
+
}
|
|
113
|
+
return true;
|
|
114
|
+
}, {
|
|
115
|
+
message: 'Delivery date is required for express orders',
|
|
116
|
+
}),
|
|
117
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
118
|
+
__metadata("design:type", Date)
|
|
119
|
+
], OrderDto.prototype, "deliveryDate", void 0);
|
|
120
|
+
class DiscountDto {
|
|
121
|
+
get validatedDiscountValue() {
|
|
122
|
+
return this.discountValue;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
exports.DiscountDto = DiscountDto;
|
|
126
|
+
__decorate([
|
|
127
|
+
(0, swagger_1.ApiProperty)(),
|
|
128
|
+
__metadata("design:type", String)
|
|
129
|
+
], DiscountDto.prototype, "discountType", void 0);
|
|
130
|
+
__decorate([
|
|
131
|
+
(0, swagger_1.ApiProperty)(),
|
|
132
|
+
__metadata("design:type", Number)
|
|
133
|
+
], DiscountDto.prototype, "discountValue", void 0);
|
|
134
|
+
__decorate([
|
|
135
|
+
(0, validator_decorators_1.CustomValidation)((value, args) => {
|
|
136
|
+
const object = args.object;
|
|
137
|
+
if (object.discountType === 'percentage') {
|
|
138
|
+
return value >= 0 && value <= 100;
|
|
139
|
+
}
|
|
140
|
+
else if (object.discountType === 'fixed') {
|
|
141
|
+
return value > 0;
|
|
142
|
+
}
|
|
143
|
+
return false;
|
|
144
|
+
}, {
|
|
145
|
+
message: 'Invalid discount value for the selected discount type',
|
|
146
|
+
}),
|
|
147
|
+
__metadata("design:type", Object),
|
|
148
|
+
__metadata("design:paramtypes", [])
|
|
149
|
+
], DiscountDto.prototype, "validatedDiscountValue", null);
|
|
150
|
+
class UserRegistrationDto {
|
|
151
|
+
validatePassword(password) {
|
|
152
|
+
if (!password || password.length < 8)
|
|
153
|
+
return false;
|
|
154
|
+
const hasUppercase = /[A-Z]/.test(password);
|
|
155
|
+
const hasLowercase = /[a-z]/.test(password);
|
|
156
|
+
const hasNumber = /[0-9]/.test(password);
|
|
157
|
+
const hasSpecial = /[!@#$%^&*]/.test(password);
|
|
158
|
+
return hasUppercase && hasLowercase && hasNumber && hasSpecial;
|
|
159
|
+
}
|
|
160
|
+
validatePasswordMatch(confirmPassword) {
|
|
161
|
+
return confirmPassword === this.password;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
exports.UserRegistrationDto = UserRegistrationDto;
|
|
165
|
+
__decorate([
|
|
166
|
+
(0, swagger_1.ApiProperty)(),
|
|
167
|
+
(0, class_validator_1.IsString)(),
|
|
168
|
+
__metadata("design:type", String)
|
|
169
|
+
], UserRegistrationDto.prototype, "username", void 0);
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, validator_decorators_1.CustomValidationMethod)('validatePassword', {
|
|
172
|
+
message: 'Password does not meet security requirements',
|
|
173
|
+
}),
|
|
174
|
+
(0, swagger_1.ApiProperty)(),
|
|
175
|
+
__metadata("design:type", String)
|
|
176
|
+
], UserRegistrationDto.prototype, "password", void 0);
|
|
177
|
+
__decorate([
|
|
178
|
+
(0, validator_decorators_1.CustomValidationMethod)('validatePasswordMatch'),
|
|
179
|
+
(0, swagger_1.ApiProperty)(),
|
|
180
|
+
__metadata("design:type", String)
|
|
181
|
+
], UserRegistrationDto.prototype, "confirmPassword", void 0);
|
|
182
|
+
class CreateProductDto {
|
|
183
|
+
get validatedCategoryId() {
|
|
184
|
+
return this.categoryId;
|
|
185
|
+
}
|
|
186
|
+
checkSkuUniqueness(sku) {
|
|
187
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
188
|
+
if (!this.productService) {
|
|
189
|
+
console.warn('ProductService not found');
|
|
190
|
+
return true;
|
|
191
|
+
}
|
|
192
|
+
const exists = yield this.productService.skuExists(sku);
|
|
193
|
+
return !exists;
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
validateCategoryExists(categoryId) {
|
|
197
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
198
|
+
if (!this.categoryService) {
|
|
199
|
+
console.warn('CategoryService not found');
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
return yield this.categoryService.exists(categoryId);
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.CreateProductDto = CreateProductDto;
|
|
207
|
+
__decorate([
|
|
208
|
+
(0, swagger_1.ApiProperty)(),
|
|
209
|
+
(0, class_validator_1.IsString)(),
|
|
210
|
+
__metadata("design:type", String)
|
|
211
|
+
], CreateProductDto.prototype, "name", void 0);
|
|
212
|
+
__decorate([
|
|
213
|
+
(0, validator_decorators_1.CustomValidationMethod)('checkSkuUniqueness', {
|
|
214
|
+
message: 'SKU already exists',
|
|
215
|
+
}),
|
|
216
|
+
(0, swagger_1.ApiProperty)(),
|
|
217
|
+
__metadata("design:type", String)
|
|
218
|
+
], CreateProductDto.prototype, "sku", void 0);
|
|
219
|
+
__decorate([
|
|
220
|
+
(0, swagger_1.ApiProperty)(),
|
|
221
|
+
__metadata("design:type", String)
|
|
222
|
+
], CreateProductDto.prototype, "categoryId", void 0);
|
|
223
|
+
__decorate([
|
|
224
|
+
(0, validator_decorators_1.CustomValidationMethod)('validateCategoryExists', {
|
|
225
|
+
message: 'Category does not exist',
|
|
226
|
+
}),
|
|
227
|
+
__metadata("design:type", Object),
|
|
228
|
+
__metadata("design:paramtypes", [])
|
|
229
|
+
], CreateProductDto.prototype, "validatedCategoryId", null);
|
|
230
|
+
class EmployeeDto {
|
|
231
|
+
validatePhoneFormat(phone) {
|
|
232
|
+
if (!phone)
|
|
233
|
+
return true;
|
|
234
|
+
const phoneRegex = /^\+?[1-9]\d{1,14}$/;
|
|
235
|
+
return phoneRegex.test(phone);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
exports.EmployeeDto = EmployeeDto;
|
|
239
|
+
__decorate([
|
|
240
|
+
(0, swagger_1.ApiProperty)(),
|
|
241
|
+
(0, class_validator_1.IsString)(),
|
|
242
|
+
__metadata("design:type", String)
|
|
243
|
+
], EmployeeDto.prototype, "name", void 0);
|
|
244
|
+
__decorate([
|
|
245
|
+
(0, validator_decorators_1.CustomValidation)((value) => {
|
|
246
|
+
const workDomains = ['company.com', 'corp.com'];
|
|
247
|
+
const domain = value === null || value === void 0 ? void 0 : value.split('@')[1];
|
|
248
|
+
return !workDomains.includes(domain);
|
|
249
|
+
}, {
|
|
250
|
+
message: 'Personal email should not be from work domains',
|
|
251
|
+
}),
|
|
252
|
+
(0, class_validator_1.IsEmail)(),
|
|
253
|
+
(0, validator_decorators_1.AtLeastOneField)(['personalEmail', 'workEmail']),
|
|
254
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
255
|
+
__metadata("design:type", String)
|
|
256
|
+
], EmployeeDto.prototype, "personalEmail", void 0);
|
|
257
|
+
__decorate([
|
|
258
|
+
(0, validator_decorators_1.CustomValidation)((value) => {
|
|
259
|
+
const workDomains = ['company.com', 'corp.com'];
|
|
260
|
+
const domain = value === null || value === void 0 ? void 0 : value.split('@')[1];
|
|
261
|
+
return workDomains.includes(domain);
|
|
262
|
+
}, {
|
|
263
|
+
message: 'Work email must be from company domains',
|
|
264
|
+
}),
|
|
265
|
+
(0, class_validator_1.IsEmail)(),
|
|
266
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
267
|
+
__metadata("design:type", String)
|
|
268
|
+
], EmployeeDto.prototype, "workEmail", void 0);
|
|
269
|
+
__decorate([
|
|
270
|
+
(0, validator_decorators_1.CustomValidationMethod)('validatePhoneFormat'),
|
|
271
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
272
|
+
__metadata("design:type", String)
|
|
273
|
+
], EmployeeDto.prototype, "phone", void 0);
|
|
274
|
+
class PaymentMethodDto {
|
|
275
|
+
validateCreditCard(creditCard) {
|
|
276
|
+
var _a;
|
|
277
|
+
if (!creditCard)
|
|
278
|
+
return true;
|
|
279
|
+
const number = (_a = creditCard.number) === null || _a === void 0 ? void 0 : _a.replace(/\s/g, '');
|
|
280
|
+
if (!/^\d{13,19}$/.test(number))
|
|
281
|
+
return false;
|
|
282
|
+
let sum = 0;
|
|
283
|
+
let isEven = false;
|
|
284
|
+
for (let i = number.length - 1; i >= 0; i--) {
|
|
285
|
+
let digit = parseInt(number[i], 10);
|
|
286
|
+
if (isEven) {
|
|
287
|
+
digit *= 2;
|
|
288
|
+
if (digit > 9)
|
|
289
|
+
digit -= 9;
|
|
290
|
+
}
|
|
291
|
+
sum += digit;
|
|
292
|
+
isEven = !isEven;
|
|
293
|
+
}
|
|
294
|
+
return sum % 10 === 0;
|
|
295
|
+
}
|
|
296
|
+
validateBankAccount(bankAccount) {
|
|
297
|
+
if (!bankAccount)
|
|
298
|
+
return true;
|
|
299
|
+
const accountValid = /^\d{8,17}$/.test(bankAccount.accountNumber);
|
|
300
|
+
const routingValid = /^\d{9}$/.test(bankAccount.routingNumber);
|
|
301
|
+
return accountValid && routingValid;
|
|
302
|
+
}
|
|
303
|
+
validateDigitalWallet(digitalWallet) {
|
|
304
|
+
var _a;
|
|
305
|
+
if (!digitalWallet)
|
|
306
|
+
return true;
|
|
307
|
+
const validProviders = ['paypal', 'alipay', 'wechat_pay', 'apple_pay'];
|
|
308
|
+
return validProviders.includes((_a = digitalWallet.provider) === null || _a === void 0 ? void 0 : _a.toLowerCase());
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
exports.PaymentMethodDto = PaymentMethodDto;
|
|
312
|
+
__decorate([
|
|
313
|
+
(0, swagger_1.ApiProperty)(),
|
|
314
|
+
__metadata("design:type", String)
|
|
315
|
+
], PaymentMethodDto.prototype, "paymentType", void 0);
|
|
316
|
+
__decorate([
|
|
317
|
+
(0, validator_decorators_1.CustomValidationMethod)('validateCreditCard'),
|
|
318
|
+
(0, validator_decorators_1.AtLeastOneField)(['creditCard', 'bankAccount', 'digitalWallet']),
|
|
319
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
320
|
+
__metadata("design:type", Object)
|
|
321
|
+
], PaymentMethodDto.prototype, "creditCard", void 0);
|
|
322
|
+
__decorate([
|
|
323
|
+
(0, validator_decorators_1.CustomValidationMethod)('validateBankAccount'),
|
|
324
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
325
|
+
__metadata("design:type", Object)
|
|
326
|
+
], PaymentMethodDto.prototype, "bankAccount", void 0);
|
|
327
|
+
__decorate([
|
|
328
|
+
(0, validator_decorators_1.CustomValidationMethod)('validateDigitalWallet'),
|
|
329
|
+
(0, swagger_1.ApiProperty)({ required: false }),
|
|
330
|
+
__metadata("design:type", Object)
|
|
331
|
+
], PaymentMethodDto.prototype, "digitalWallet", void 0);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { ApiPropertyOptions } from '@nestjs/swagger';
|
|
2
|
+
import * as ValidatorJS from 'validator';
|
|
3
|
+
type RequireField<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
4
|
+
interface IFieldOptions {
|
|
5
|
+
each?: boolean;
|
|
6
|
+
swagger?: boolean;
|
|
7
|
+
nullable?: boolean;
|
|
8
|
+
group?: string[];
|
|
9
|
+
message?: string;
|
|
10
|
+
}
|
|
11
|
+
interface INumberFieldOptions extends IFieldOptions {
|
|
12
|
+
min?: number;
|
|
13
|
+
max?: number;
|
|
14
|
+
int?: boolean;
|
|
15
|
+
isPositive?: boolean;
|
|
16
|
+
}
|
|
17
|
+
interface IDateFieldOptions extends IFieldOptions {
|
|
18
|
+
minDate?: Date | (() => Date);
|
|
19
|
+
maxDate?: Date | (() => Date);
|
|
20
|
+
}
|
|
21
|
+
interface IStringFieldOptions extends IFieldOptions {
|
|
22
|
+
minLength?: number;
|
|
23
|
+
maxLength?: number;
|
|
24
|
+
toLowerCase?: boolean;
|
|
25
|
+
toUpperCase?: boolean;
|
|
26
|
+
}
|
|
27
|
+
interface IEmailFieldOptions {
|
|
28
|
+
emailOptions?: ValidatorJS.IsEmailOptions;
|
|
29
|
+
}
|
|
30
|
+
interface IIPFieldOptions {
|
|
31
|
+
version?: ValidatorJS.IPVersion;
|
|
32
|
+
}
|
|
33
|
+
interface IURLFieldOptions {
|
|
34
|
+
urlOptions?: ValidatorJS.IsURLOptions;
|
|
35
|
+
simpleUrl?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface IFQDNFieldOptions extends ValidatorJS.IsFQDNOptions {
|
|
38
|
+
}
|
|
39
|
+
type IClassFieldOptions = IFieldOptions;
|
|
40
|
+
type IBooleanFieldOptions = IFieldOptions;
|
|
41
|
+
type IEnumFieldOptions = IFieldOptions;
|
|
42
|
+
export declare function NumberField(options?: Omit<ApiPropertyOptions, 'type'> & INumberFieldOptions): PropertyDecorator;
|
|
43
|
+
export declare function NumberFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'> & INumberFieldOptions): PropertyDecorator;
|
|
44
|
+
export declare function StringField(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
45
|
+
export declare function StringFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IStringFieldOptions): PropertyDecorator;
|
|
46
|
+
export declare function PasswordField(options?: Omit<ApiPropertyOptions, 'type' | 'minLength'> & IStringFieldOptions): PropertyDecorator;
|
|
47
|
+
export declare function PasswordFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required' | 'minLength'> & IStringFieldOptions): PropertyDecorator;
|
|
48
|
+
export declare function BooleanField(options?: Omit<ApiPropertyOptions, 'type'> & IBooleanFieldOptions): PropertyDecorator;
|
|
49
|
+
export declare function BooleanFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IBooleanFieldOptions): PropertyDecorator;
|
|
50
|
+
export declare function TranslationsField(options: RequireField<Omit<ApiPropertyOptions, 'isArray'>, 'type'> & IFieldOptions): PropertyDecorator;
|
|
51
|
+
export declare function TranslationsFieldOptional(options: RequireField<Omit<ApiPropertyOptions, 'isArray'>, 'type'> & IFieldOptions): PropertyDecorator;
|
|
52
|
+
export declare function TmpKeyField(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
53
|
+
export declare function TmpKeyFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IStringFieldOptions): PropertyDecorator;
|
|
54
|
+
export declare function getEnumDescription(enumType: any): string;
|
|
55
|
+
export declare function EnumField<TEnum extends object>(getEnum: () => TEnum, options?: Omit<ApiPropertyOptions, 'type' | 'enum' | 'enumName' | 'isArray'> & IEnumFieldOptions): PropertyDecorator;
|
|
56
|
+
export declare function ClassField<TClass extends object>(getClass: () => TClass, options?: Omit<ApiPropertyOptions, 'type'> & IClassFieldOptions): PropertyDecorator;
|
|
57
|
+
export declare function EnumFieldOptional<TEnum extends object>(getEnum: () => TEnum, options?: Omit<ApiPropertyOptions, 'type' | 'required' | 'enum' | 'enumName'> & IEnumFieldOptions): PropertyDecorator;
|
|
58
|
+
export declare function ClassFieldOptional<TClass extends object>(getClass: () => TClass, options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IClassFieldOptions): PropertyDecorator;
|
|
59
|
+
export declare function EmailField(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions & IEmailFieldOptions): PropertyDecorator;
|
|
60
|
+
export declare function EmailFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions & IEmailFieldOptions): PropertyDecorator;
|
|
61
|
+
export declare function PhoneField(options?: Omit<ApiPropertyOptions, 'type'> & IFieldOptions): PropertyDecorator;
|
|
62
|
+
export declare function PhoneFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IFieldOptions): PropertyDecorator;
|
|
63
|
+
export declare function UUIDField(options?: Omit<ApiPropertyOptions, 'type' | 'format' | 'isArray'> & IFieldOptions): PropertyDecorator;
|
|
64
|
+
export declare function UUIDFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required' | 'isArray'> & IFieldOptions): PropertyDecorator;
|
|
65
|
+
export declare function URLField(options?: Omit<ApiPropertyOptions, 'type'> & IURLFieldOptions & IStringFieldOptions): PropertyDecorator;
|
|
66
|
+
export declare function URLFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IURLFieldOptions & IStringFieldOptions): PropertyDecorator;
|
|
67
|
+
export declare function FQDNField(options?: Omit<ApiPropertyOptions, 'type'> & IFQDNFieldOptions & IStringFieldOptions): PropertyDecorator;
|
|
68
|
+
export declare function FQDNFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IFQDNFieldOptions & IStringFieldOptions): PropertyDecorator;
|
|
69
|
+
export declare function DateField(options?: Omit<ApiPropertyOptions, 'type'> & IDateFieldOptions): PropertyDecorator;
|
|
70
|
+
export declare function DateFieldOptional(options?: Omit<ApiPropertyOptions, 'type' | 'required'> & IDateFieldOptions): PropertyDecorator;
|
|
71
|
+
export declare function IpFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IIPFieldOptions & IStringFieldOptions): PropertyDecorator;
|
|
72
|
+
export declare function IpField(options: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions & IIPFieldOptions): PropertyDecorator;
|
|
73
|
+
export declare function ObjectField(options?: Omit<ApiPropertyOptions, 'type'> & IFieldOptions): PropertyDecorator;
|
|
74
|
+
export declare function ObjectFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IFieldOptions): PropertyDecorator;
|
|
75
|
+
export declare function TimeZoneField(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
76
|
+
export declare function TimeZoneFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
77
|
+
export declare function LocaleField(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
78
|
+
export declare function LocaleFieldOptional(options?: Omit<ApiPropertyOptions, 'type'> & IStringFieldOptions): PropertyDecorator;
|
|
79
|
+
export {};
|