@nest-omni/core 1.0.6 → 1.0.7

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.
Files changed (175) hide show
  1. package/dist/boilerplate.polyfill.d.ts +39 -0
  2. package/dist/boilerplate.polyfill.js +77 -0
  3. package/dist/common/abstract-client.service.d.ts +16 -0
  4. package/dist/common/abstract-client.service.js +35 -0
  5. package/dist/common/abstract.entity.d.ts +17 -0
  6. package/dist/common/abstract.entity.js +64 -0
  7. package/dist/common/dto/abstract.dto.d.ts +13 -0
  8. package/dist/common/dto/abstract.dto.js +59 -0
  9. package/dist/common/dto/bulk-id.dto.d.ts +3 -0
  10. package/dist/common/dto/bulk-id.dto.js +27 -0
  11. package/dist/common/dto/create-translation.dto.d.ts +5 -0
  12. package/dist/common/dto/create-translation.dto.js +25 -0
  13. package/dist/common/dto/page-meta.dto.d.ts +15 -0
  14. package/dist/common/dto/page-meta.dto.js +48 -0
  15. package/dist/common/dto/page-options.dto.d.ts +8 -0
  16. package/dist/common/dto/page-options.dto.js +52 -0
  17. package/dist/common/dto/page.dto.d.ts +11 -0
  18. package/dist/common/dto/page.dto.js +53 -0
  19. package/dist/common/utils.d.ts +3 -0
  20. package/dist/common/utils.js +25 -0
  21. package/dist/constants/index.d.ts +4 -0
  22. package/dist/constants/index.js +20 -0
  23. package/dist/constants/language-code.d.ts +5 -0
  24. package/dist/constants/language-code.js +9 -0
  25. package/dist/constants/order.d.ts +4 -0
  26. package/dist/constants/order.js +8 -0
  27. package/dist/constants/role-type.d.ts +4 -0
  28. package/dist/constants/role-type.js +8 -0
  29. package/dist/constants/token-type.d.ts +4 -0
  30. package/dist/constants/token-type.js +8 -0
  31. package/dist/decorators/api-page-ok-response.decorator.d.ts +5 -0
  32. package/dist/decorators/api-page-ok-response.decorator.js +25 -0
  33. package/dist/decorators/auth-user.decorator.d.ts +1 -0
  34. package/dist/decorators/auth-user.decorator.js +15 -0
  35. package/dist/decorators/controller.decorator.d.ts +1 -0
  36. package/dist/decorators/controller.decorator.js +11 -0
  37. package/dist/decorators/field.decorators.d.ts +71 -0
  38. package/dist/decorators/field.decorators.js +449 -0
  39. package/dist/decorators/http.decorators.d.ts +3 -0
  40. package/dist/decorators/http.decorators.js +8 -0
  41. package/dist/decorators/index.d.ts +12 -0
  42. package/dist/decorators/index.js +28 -0
  43. package/dist/decorators/omni-auth.decorator.d.ts +8 -0
  44. package/dist/decorators/omni-auth.decorator.js +35 -0
  45. package/dist/decorators/operation.decorator.d.ts +1 -0
  46. package/dist/decorators/operation.decorator.js +6 -0
  47. package/dist/decorators/property.decorators.d.ts +15 -0
  48. package/dist/decorators/property.decorators.js +32 -0
  49. package/dist/decorators/public-route.decorator.d.ts +3 -0
  50. package/dist/decorators/public-route.decorator.js +7 -0
  51. package/dist/decorators/swagger.schema.d.ts +5 -0
  52. package/dist/decorators/swagger.schema.js +79 -0
  53. package/dist/decorators/timestamp-column.decorator.d.ts +1 -0
  54. package/dist/decorators/timestamp-column.decorator.js +28 -0
  55. package/dist/decorators/transform.decorators.d.ts +8 -0
  56. package/dist/decorators/transform.decorators.js +95 -0
  57. package/dist/decorators/translate.decorator.d.ts +5 -0
  58. package/dist/decorators/translate.decorator.js +17 -0
  59. package/dist/decorators/use-dto.decorator.d.ts +4 -0
  60. package/dist/decorators/use-dto.decorator.js +9 -0
  61. package/dist/decorators/user-check.decorator.d.ts +6 -0
  62. package/dist/decorators/user-check.decorator.js +21 -0
  63. package/dist/decorators/user.decorator.d.ts +8 -0
  64. package/dist/decorators/user.decorator.js +38 -0
  65. package/dist/decorators/user_auth.decorator.d.ts +1 -0
  66. package/dist/decorators/user_auth.decorator.js +16 -0
  67. package/dist/decorators/validator.decorators.d.ts +10 -0
  68. package/dist/decorators/validator.decorators.js +59 -0
  69. package/dist/exceptions/file-not-image.exception.d.ts +4 -0
  70. package/dist/exceptions/file-not-image.exception.js +10 -0
  71. package/dist/exceptions/index.d.ts +2 -0
  72. package/dist/exceptions/index.js +18 -0
  73. package/dist/exceptions/page-type.exception.d.ts +4 -0
  74. package/dist/exceptions/page-type.exception.js +10 -0
  75. package/dist/exceptions/user-not-found.exception.d.ts +4 -0
  76. package/dist/exceptions/user-not-found.exception.js +10 -0
  77. package/dist/filters/bad-request.filter.d.ts +5 -0
  78. package/dist/filters/bad-request.filter.js +60 -0
  79. package/dist/filters/constraint-errors.d.ts +1 -0
  80. package/dist/filters/constraint-errors.js +6 -0
  81. package/dist/filters/index.d.ts +3 -0
  82. package/dist/filters/index.js +19 -0
  83. package/dist/filters/query-failed.filter.d.ts +10 -0
  84. package/dist/filters/query-failed.filter.js +42 -0
  85. package/dist/health-checker/health-checker.controller.d.ts +15 -0
  86. package/dist/health-checker/health-checker.controller.js +72 -0
  87. package/dist/health-checker/health-checker.module.d.ts +2 -0
  88. package/dist/health-checker/health-checker.module.js +25 -0
  89. package/dist/health-checker/health-indicators/service.indicator.d.ts +8 -0
  90. package/dist/health-checker/health-indicators/service.indicator.js +66 -0
  91. package/dist/helpers/common.helper.d.ts +3 -0
  92. package/dist/helpers/common.helper.js +36 -0
  93. package/dist/helpers/date.helper.d.ts +10 -0
  94. package/dist/helpers/date.helper.js +58 -0
  95. package/dist/helpers/index.d.ts +3 -0
  96. package/dist/helpers/index.js +19 -0
  97. package/dist/i18n/en_US/validation.json +38 -0
  98. package/dist/i18n/zh_CN/validation.json +38 -0
  99. package/dist/index.d.ts +11 -0
  100. package/dist/index.js +27 -0
  101. package/dist/interceptors/auth-user.interceptor.d.ts +4 -0
  102. package/dist/interceptors/auth-user.interceptor.js +24 -0
  103. package/dist/interceptors/index.d.ts +2 -0
  104. package/dist/interceptors/index.js +18 -0
  105. package/dist/interceptors/language-interceptor.service.d.ts +6 -0
  106. package/dist/interceptors/language-interceptor.service.js +30 -0
  107. package/dist/interceptors/translation-interceptor.service.d.ts +5 -0
  108. package/dist/interceptors/translation-interceptor.service.js +34 -0
  109. package/dist/interfaces/IApiFile.d.ts +4 -0
  110. package/dist/interfaces/IApiFile.js +2 -0
  111. package/dist/interfaces/IFile.d.ts +9 -0
  112. package/dist/interfaces/IFile.js +2 -0
  113. package/dist/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
  114. package/dist/interfaces/ITranslationDecoratorInterface.js +2 -0
  115. package/dist/interfaces/index.d.ts +3 -0
  116. package/dist/interfaces/index.js +19 -0
  117. package/dist/interfaces/response.d.ts +25 -0
  118. package/dist/interfaces/response.js +2 -0
  119. package/dist/middlewares/index.d.ts +3 -0
  120. package/dist/middlewares/index.js +19 -0
  121. package/dist/middlewares/omni-auth.middleware.d.ts +1 -0
  122. package/dist/middlewares/omni-auth.middleware.js +13 -0
  123. package/dist/middlewares/powerby.middleware.d.ts +1 -0
  124. package/dist/middlewares/powerby.middleware.js +10 -0
  125. package/dist/middlewares/request-id.middleware.d.ts +7 -0
  126. package/dist/middlewares/request-id.middleware.js +22 -0
  127. package/dist/providers/context.provider.d.ts +32 -0
  128. package/dist/providers/context.provider.js +71 -0
  129. package/dist/providers/generator.provider.d.ts +9 -0
  130. package/dist/providers/generator.provider.js +50 -0
  131. package/dist/providers/index.d.ts +2 -0
  132. package/dist/providers/index.js +18 -0
  133. package/dist/setup/bootstrap.setup.d.ts +5 -0
  134. package/dist/setup/bootstrap.setup.js +112 -0
  135. package/dist/setup/index.d.ts +1 -0
  136. package/dist/setup/index.js +17 -0
  137. package/dist/setup-swagger.d.ts +2 -0
  138. package/dist/setup-swagger.js +62 -0
  139. package/dist/shared/index.d.ts +2 -0
  140. package/dist/shared/index.js +18 -0
  141. package/dist/shared/serviceRegistryModule.d.ts +2 -0
  142. package/dist/shared/serviceRegistryModule.js +110 -0
  143. package/dist/shared/services/api-config.service.d.ts +70 -0
  144. package/dist/shared/services/api-config.service.js +290 -0
  145. package/dist/shared/services/aws-s3.service.d.ts +10 -0
  146. package/dist/shared/services/aws-s3.service.js +56 -0
  147. package/dist/shared/services/generator.service.d.ts +4 -0
  148. package/dist/shared/services/generator.service.js +23 -0
  149. package/dist/shared/services/index.d.ts +5 -0
  150. package/dist/shared/services/index.js +21 -0
  151. package/dist/shared/services/translation.service.d.ts +9 -0
  152. package/dist/shared/services/translation.service.js +70 -0
  153. package/dist/shared/services/validator.service.d.ts +3 -0
  154. package/dist/shared/services/validator.service.js +20 -0
  155. package/dist/snake-naming.strategy.d.ts +11 -0
  156. package/dist/snake-naming.strategy.js +37 -0
  157. package/dist/tsconfig.tsbuildinfo +1 -0
  158. package/dist/types.d.ts +9 -0
  159. package/dist/types.js +2 -0
  160. package/dist/validators/file-mimetype.validator.d.ts +13 -0
  161. package/dist/validators/file-mimetype.validator.js +21 -0
  162. package/dist/validators/index.d.ts +3 -0
  163. package/dist/validators/index.js +19 -0
  164. package/dist/validators/is-exists.validator.d.ts +18 -0
  165. package/dist/validators/is-exists.validator.js +61 -0
  166. package/dist/validators/is-unique.validator.d.ts +17 -0
  167. package/dist/validators/is-unique.validator.js +92 -0
  168. package/dist/validators/phone-country-code.validator.d.ts +2 -0
  169. package/dist/validators/phone-country-code.validator.js +30 -0
  170. package/dist/validators/same-as.validator.d.ts +2 -0
  171. package/dist/validators/same-as.validator.js +25 -0
  172. package/dist/validators/skip-empty.validator.d.ts +1 -0
  173. package/dist/validators/skip-empty.validator.js +18 -0
  174. package/package.json +1 -1
  175. package/tsconfig.json +6 -2
@@ -0,0 +1,9 @@
1
+ export type Constructor<T, Arguments extends unknown[] = undefined[]> = new (...arguments_: Arguments) => T;
2
+ export type Plain<T> = T;
3
+ export type PathImpl<T, Key extends keyof T> = Key extends string ? T[Key] extends Record<string, any> ? `${Key}.${PathImpl<T[Key], Exclude<keyof T[Key], keyof any[]>> & string}` | `${Key}.${Exclude<keyof T[Key], keyof any[]> & string}` : never : never;
4
+ export type PathImpl2<T> = PathImpl<T, keyof T> | keyof T;
5
+ export type Path<T> = keyof T extends string ? PathImpl2<T> extends string | keyof T ? PathImpl2<T> : keyof T : never;
6
+ export type PathValue<T, P extends Path<T>> = P extends `${infer Key}.${infer Rest}` ? Key extends keyof T ? Rest extends Path<T[Key]> ? PathValue<T[Key], Rest> : never : never : P extends keyof T ? T[P] : never;
7
+ export type KeyOfType<Entity, U> = {
8
+ [P in keyof Required<Entity>]: Required<Entity>[P] extends U ? P : Required<Entity>[P] extends U[] ? P : never;
9
+ }[keyof Entity];
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import { FileValidator } from '@nestjs/common/pipes/file/file-validator.interface';
2
+ import { IFile } from '@nestjs/common/pipes/file/interfaces';
3
+ export type FileMimetypeValidatorOptions = {
4
+ allowedMimetypes: string[];
5
+ message?: string;
6
+ };
7
+ export declare class FileMimetypeValidator extends FileValidator<FileMimetypeValidatorOptions, IFile> {
8
+ private allowedMimetypes;
9
+ private message;
10
+ constructor(options: FileMimetypeValidatorOptions);
11
+ buildErrorMessage(): string;
12
+ isValid(file?: IFile): boolean;
13
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FileMimetypeValidator = void 0;
4
+ const file_validator_interface_1 = require("@nestjs/common/pipes/file/file-validator.interface");
5
+ class FileMimetypeValidator extends file_validator_interface_1.FileValidator {
6
+ constructor(options) {
7
+ super(options);
8
+ this.allowedMimetypes = options.allowedMimetypes;
9
+ this.message = options.message;
10
+ }
11
+ buildErrorMessage() {
12
+ if (this.message) {
13
+ return this.message;
14
+ }
15
+ return `Invalid file type. Only ${this.allowedMimetypes.join(', ')} are allowed.`;
16
+ }
17
+ isValid(file) {
18
+ return this.allowedMimetypes.includes(file.mimetype);
19
+ }
20
+ }
21
+ exports.FileMimetypeValidator = FileMimetypeValidator;
@@ -0,0 +1,3 @@
1
+ export * from './phone-country-code.validator';
2
+ export * from './skip-empty.validator';
3
+ export * from './file-mimetype.validator';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./phone-country-code.validator"), exports);
18
+ __exportStar(require("./skip-empty.validator"), exports);
19
+ __exportStar(require("./file-mimetype.validator"), exports);
@@ -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,2 @@
1
+ import { ValidationOptions } from 'class-validator';
2
+ export declare function IsPhoneNumberWithCountryCode(validationOptions?: ValidationOptions): (object: NonNullable<unknown>, propertyName: string) => void;
@@ -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,2 @@
1
+ import type { ValidationOptions } from 'class-validator';
2
+ export declare function SameAs(property: string, validationOptions?: ValidationOptions): PropertyDecorator;
@@ -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.6",
3
+ "version": "1.0.7",
4
4
  "description": "framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/tsconfig.json CHANGED
@@ -9,7 +9,6 @@
9
9
  "target": "es6",
10
10
  "sourceMap": false,
11
11
  "outDir": "./dist",
12
- "rootDir": "./src",
13
12
  "incremental": true,
14
13
  "skipLibCheck": true,
15
14
  "strictNullChecks": false,
@@ -17,10 +16,15 @@
17
16
  "strictBindCallApply": false,
18
17
  "forceConsistentCasingInFileNames": false,
19
18
  "noFallthroughCasesInSwitch": false,
20
- "resolveJsonModule": true,
19
+ "resolveJsonModule": true
21
20
  },
22
21
  "include": [
23
22
  "./src/**/*.ts",
24
23
  "./src/i18n/**/*.json"
24
+ ],
25
+ "exclude": [
26
+ "node_modules",
27
+ "**/*.spec.ts",
28
+ "tests"
25
29
  ]
26
30
  }