@nest-omni/core 4.1.3-1 → 4.1.3-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/audit/audit.module.d.ts +10 -0
- package/audit/audit.module.js +15 -0
- package/audit/controllers/audit.controller.d.ts +24 -0
- package/audit/controllers/audit.controller.js +24 -0
- package/audit/decorators/audit-controller.decorator.d.ts +8 -0
- package/audit/decorators/audit-controller.decorator.js +9 -0
- package/audit/decorators/audit-operation.decorator.d.ts +45 -0
- package/audit/decorators/audit-operation.decorator.js +49 -0
- package/audit/decorators/entity-audit.decorator.d.ts +8 -0
- package/audit/decorators/entity-audit.decorator.js +9 -0
- package/audit/dto/audit-log-query.dto.d.ts +3 -0
- package/audit/dto/audit-log-query.dto.js +3 -0
- package/audit/dto/begin-transaction.dto.d.ts +3 -0
- package/audit/dto/begin-transaction.dto.js +3 -0
- package/audit/dto/compare-entities.dto.d.ts +3 -0
- package/audit/dto/compare-entities.dto.js +3 -0
- package/audit/dto/pre-check-restore.dto.d.ts +3 -0
- package/audit/dto/pre-check-restore.dto.js +3 -0
- package/audit/dto/restore-entity.dto.d.ts +3 -0
- package/audit/dto/restore-entity.dto.js +3 -0
- package/audit/entities/entity-audit-log.entity.d.ts +3 -0
- package/audit/entities/entity-audit-log.entity.js +3 -0
- package/audit/entities/entity-transaction.entity.d.ts +3 -0
- package/audit/entities/entity-transaction.entity.js +3 -0
- package/audit/entities/manual-operation-log.entity.d.ts +4 -0
- package/audit/entities/manual-operation-log.entity.js +4 -0
- package/audit/entities/operation-template.entity.d.ts +4 -0
- package/audit/entities/operation-template.entity.js +4 -0
- package/audit/enums/audit.enums.d.ts +17 -2
- package/audit/enums/audit.enums.js +15 -0
- package/audit/index.js +10 -0
- package/audit/interceptors/audit.interceptor.d.ts +15 -0
- package/audit/interceptors/audit.interceptor.js +23 -1
- package/audit/interfaces/audit.interfaces.d.ts +42 -0
- package/audit/services/audit-context.service.d.ts +15 -0
- package/audit/services/audit-context.service.js +15 -0
- package/audit/services/audit-strategy.service.d.ts +6 -0
- package/audit/services/audit-strategy.service.js +13 -0
- package/audit/services/entity-audit.service.d.ts +57 -0
- package/audit/services/entity-audit.service.js +91 -0
- package/audit/services/manual-audit-log.service.d.ts +124 -0
- package/audit/services/manual-audit-log.service.js +138 -0
- package/audit/services/multi-database.service.d.ts +12 -0
- package/audit/services/multi-database.service.js +12 -0
- package/audit/services/operation-description.service.d.ts +59 -0
- package/audit/services/operation-description.service.js +76 -2
- package/audit/services/transaction-audit.service.d.ts +30 -0
- package/audit/services/transaction-audit.service.js +47 -0
- package/audit/subscribers/entity-audit.subscriber.d.ts +15 -0
- package/audit/subscribers/entity-audit.subscriber.js +29 -1
- package/cache/cache-metrics.service.d.ts +67 -0
- package/cache/cache-metrics.service.js +68 -4
- package/cache/cache-serialization.service.d.ts +31 -0
- package/cache/cache-serialization.service.js +25 -0
- package/cache/cache.constants.d.ts +9 -0
- package/cache/cache.constants.js +9 -0
- package/cache/cache.health.d.ts +26 -0
- package/cache/cache.health.js +30 -0
- package/cache/cache.module.d.ts +86 -0
- package/cache/cache.module.js +71 -0
- package/cache/cache.service.d.ts +140 -0
- package/cache/cache.service.js +157 -0
- package/cache/cache.warmup.service.d.ts +39 -0
- package/cache/cache.warmup.service.js +32 -0
- package/cache/decorators/cache-evict.decorator.d.ts +47 -0
- package/cache/decorators/cache-evict.decorator.js +56 -0
- package/cache/decorators/cache-put.decorator.d.ts +34 -0
- package/cache/decorators/cache-put.decorator.js +39 -0
- package/cache/decorators/cacheable.decorator.d.ts +40 -0
- package/cache/decorators/cacheable.decorator.js +55 -0
- package/cache/dependencies/callback.dependency.d.ts +33 -0
- package/cache/dependencies/callback.dependency.js +39 -1
- package/cache/dependencies/chain.dependency.d.ts +28 -0
- package/cache/dependencies/chain.dependency.js +34 -0
- package/cache/dependencies/db.dependency.d.ts +45 -0
- package/cache/dependencies/db.dependency.js +48 -1
- package/cache/dependencies/file.dependency.d.ts +32 -0
- package/cache/dependencies/file.dependency.js +34 -0
- package/cache/dependencies/tag.dependency.d.ts +36 -0
- package/cache/dependencies/tag.dependency.js +36 -0
- package/cache/dependencies/time.dependency.d.ts +43 -0
- package/cache/dependencies/time.dependency.js +43 -0
- package/cache/examples/basic-usage.d.ts +15 -0
- package/cache/examples/basic-usage.js +62 -8
- package/cache/index.js +9 -0
- package/cache/interfaces/cache-dependency.interface.d.ts +53 -0
- package/cache/interfaces/cache-options.interface.d.ts +81 -0
- package/cache/interfaces/cache-options.interface.js +6 -0
- package/cache/interfaces/cache-provider.interface.d.ts +78 -0
- package/cache/providers/base-cache.provider.d.ts +14 -0
- package/cache/providers/base-cache.provider.js +16 -0
- package/cache/providers/cls-cache.provider.d.ts +20 -0
- package/cache/providers/cls-cache.provider.js +28 -0
- package/cache/providers/memory-cache.provider.d.ts +23 -0
- package/cache/providers/memory-cache.provider.js +26 -0
- package/cache/providers/redis-cache.provider.d.ts +26 -0
- package/cache/providers/redis-cache.provider.js +29 -0
- package/cache/utils/dependency-manager.util.d.ts +52 -0
- package/cache/utils/dependency-manager.util.js +59 -0
- package/cache/utils/key-generator.util.d.ts +42 -0
- package/cache/utils/key-generator.util.js +53 -1
- package/common/abstract.entity.d.ts +14 -0
- package/common/abstract.entity.js +14 -0
- package/common/boilerplate.polyfill.d.ts +142 -4
- package/common/boilerplate.polyfill.js +24 -100
- package/common/dto/dto-container.d.ts +16 -0
- package/common/dto/dto-container.js +20 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +14 -0
- package/common/dto/dto-extensions.d.ts +11 -0
- package/common/dto/dto-extensions.js +9 -0
- package/common/dto/dto-service-accessor.d.ts +17 -0
- package/common/dto/dto-service-accessor.js +18 -0
- package/common/dto/dto-transformer.d.ts +12 -0
- package/common/dto/dto-transformer.js +9 -0
- package/common/dto/index.js +2 -0
- package/common/examples/paginate-and-map.example.d.ts +6 -0
- package/common/examples/paginate-and-map.example.js +26 -0
- package/common/utils.d.ts +15 -0
- package/common/utils.js +15 -0
- package/constants/language-code.js +1 -0
- package/decorators/field.decorators.js +8 -1
- package/decorators/property.decorators.js +1 -0
- package/decorators/public-route.decorator.js +1 -0
- package/decorators/transform.decorators.d.ts +27 -0
- package/decorators/transform.decorators.js +29 -0
- package/decorators/translate.decorator.js +1 -0
- package/decorators/user.decorator.js +1 -0
- package/decorators/validator.decorators.d.ts +8 -18
- package/decorators/validator.decorators.js +22 -190
- package/filters/constraint-errors.js +1 -0
- package/helpers/common.helper.d.ts +13 -0
- package/helpers/common.helper.js +13 -0
- package/http-client/config/http-client.config.d.ts +15 -0
- package/http-client/config/http-client.config.js +25 -9
- package/http-client/decorators/http-client.decorators.d.ts +63 -0
- package/http-client/decorators/http-client.decorators.js +71 -3
- package/http-client/entities/http-log.entity.d.ts +229 -0
- package/http-client/entities/http-log.entity.js +6 -1
- package/http-client/errors/http-client.errors.d.ts +57 -0
- package/http-client/errors/http-client.errors.js +58 -0
- package/http-client/examples/advanced-usage.example.d.ts +41 -0
- package/http-client/examples/advanced-usage.example.js +68 -24
- package/http-client/examples/auth-with-waiting-lock.example.d.ts +31 -0
- package/http-client/examples/auth-with-waiting-lock.example.js +52 -5
- package/http-client/examples/basic-usage.example.d.ts +60 -0
- package/http-client/examples/basic-usage.example.js +60 -0
- package/http-client/examples/multi-api-configuration.example.d.ts +60 -0
- package/http-client/examples/multi-api-configuration.example.js +76 -5
- package/http-client/http-client.module.d.ts +13 -0
- package/http-client/http-client.module.js +19 -0
- package/http-client/index.js +8 -0
- package/http-client/interfaces/api-client-config.interface.d.ts +125 -0
- package/http-client/interfaces/api-client-config.interface.js +3 -0
- package/http-client/interfaces/http-client-config.interface.d.ts +60 -0
- package/http-client/services/api-client-registry.service.d.ts +57 -0
- package/http-client/services/api-client-registry.service.js +84 -1
- package/http-client/services/cache.service.d.ts +52 -0
- package/http-client/services/cache.service.js +72 -3
- package/http-client/services/circuit-breaker.service.d.ts +46 -0
- package/http-client/services/circuit-breaker.service.js +52 -0
- package/http-client/services/http-client.service.d.ts +67 -0
- package/http-client/services/http-client.service.js +105 -4
- package/http-client/services/http-log-query.service.d.ts +83 -0
- package/http-client/services/http-log-query.service.js +122 -1
- package/http-client/services/http-replay.service.d.ts +101 -0
- package/http-client/services/http-replay.service.js +86 -0
- package/http-client/services/log-cleanup.service.d.ts +63 -0
- package/http-client/services/log-cleanup.service.js +54 -2
- package/http-client/services/logging.service.d.ts +40 -0
- package/http-client/services/logging.service.js +53 -0
- package/http-client/utils/call-stack-extractor.util.d.ts +37 -0
- package/http-client/utils/call-stack-extractor.util.js +48 -0
- package/http-client/utils/context-extractor.util.d.ts +49 -0
- package/http-client/utils/context-extractor.util.js +52 -0
- package/http-client/utils/curl-generator.util.d.ts +21 -0
- package/http-client/utils/curl-generator.util.js +44 -3
- package/http-client/utils/request-id.util.d.ts +18 -0
- package/http-client/utils/request-id.util.js +20 -0
- package/http-client/utils/retry-recorder.util.d.ts +42 -0
- package/http-client/utils/retry-recorder.util.js +44 -0
- package/i18n/en_US/validation.json +2 -1
- package/i18n/zh_CN/validation.json +2 -1
- package/index.js +8 -0
- package/interceptors/translation-interceptor.service.js +5 -0
- package/package.json +1 -1
- package/providers/context.provider.js +2 -0
- package/providers/generator.provider.d.ts +4 -0
- package/providers/generator.provider.js +4 -0
- package/redis-lock/examples/lock-strategy.examples.d.ts +89 -0
- package/redis-lock/examples/lock-strategy.examples.js +130 -15
- package/redis-lock/index.js +3 -0
- package/redis-lock/redis-lock.decorator.d.ts +101 -0
- package/redis-lock/redis-lock.decorator.js +120 -0
- package/redis-lock/redis-lock.module.d.ts +60 -0
- package/redis-lock/redis-lock.module.js +46 -0
- package/redis-lock/redis-lock.service.d.ts +251 -0
- package/redis-lock/redis-lock.service.js +219 -3
- package/setup/bootstrap.setup.js +20 -0
- package/setup/mode.setup.d.ts +44 -0
- package/setup/mode.setup.js +44 -0
- package/setup/schedule.decorator.d.ts +226 -0
- package/setup/schedule.decorator.js +214 -1
- package/setup/worker.decorator.d.ts +86 -0
- package/setup/worker.decorator.js +88 -0
- package/shared/serviceRegistryModule.js +9 -1
- package/shared/services/api-config.service.d.ts +3 -0
- package/shared/services/api-config.service.js +20 -9
- package/validator-json/decorators.d.ts +17 -0
- package/validator-json/decorators.js +17 -2
- package/validator-json/default.d.ts +6 -0
- package/validator-json/default.js +30 -2
- package/validator-json/defaultConverters.js +1 -0
- package/validator-json/options.d.ts +23 -0
- package/validators/common-validators.d.ts +143 -0
- package/validators/common-validators.js +249 -0
- package/validators/custom-validate.examples.d.ts +96 -0
- package/validators/custom-validate.examples.js +400 -0
- package/validators/custom-validate.validator.d.ts +133 -0
- package/validators/custom-validate.validator.js +213 -0
- package/validators/index.d.ts +2 -0
- package/validators/index.js +2 -0
- package/validators/is-exists.validator.d.ts +18 -4
- package/validators/is-exists.validator.js +67 -6
- package/validators/is-unique.validator.d.ts +19 -4
- package/validators/is-unique.validator.js +67 -11
- package/validators/skip-empty.validator.d.ts +5 -0
- package/validators/skip-empty.validator.js +5 -0
- package/vault/interfaces/vault-options.interface.d.ts +9 -0
- package/vault/vault-config.loader.d.ts +30 -0
- package/vault/vault-config.loader.js +48 -1
- package/vault/vault-config.service.d.ts +53 -0
- package/vault/vault-config.service.js +57 -0
- package/vault/vault.module.d.ts +4 -0
- package/vault/vault.module.js +4 -0
- package/decorators/examples/validation-decorators.example.d.ts +0 -69
- package/decorators/examples/validation-decorators.example.js +0 -331
|
@@ -1,331 +0,0 @@
|
|
|
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);
|