denwa-nest-shared 1.0.56 → 1.0.58

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/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.58](https://github.com/Denwa799/nest-shared/compare/v1.0.57...v1.0.58) (2025-07-23)
6
+
7
+ ### [1.0.57](https://github.com/Denwa799/nest-shared/compare/v1.0.56...v1.0.57) (2025-07-22)
8
+
5
9
  ### [1.0.56](https://github.com/Denwa799/nest-shared/compare/v1.0.55...v1.0.56) (2025-07-11)
6
10
 
7
11
  ### [1.0.55](https://github.com/Denwa799/nest-shared/compare/v1.0.54...v1.0.55) (2025-07-09)
@@ -1,5 +1,5 @@
1
1
  import { CustomDecorator } from '@nestjs/common';
2
- export declare const ApiValidationProperty: ({ type, enumObject, swaggerType, min, max, arrayMinSize, arrayMaxSize, divisibleBy, example, description, isSwaggerArray, isOptional, isUUID, isArray, isJson, isJWT, isUrl, isPositive, isNegative, isEmail, isMobilePhone, isPhoneNumber, isLatitude, isLongitude, isStrongPassword, isArrayNotEmpty, isArrayUnique, }: {
2
+ export declare const ApiValidationProperty: ({ type, enumObject, swaggerType, min, max, arrayMinSize, arrayMaxSize, divisibleBy, example, description, isSwaggerArray, isOptional, isUUID, isArray, isJson, isJWT, isUrl, isPositive, isNegative, isEmail, isMobilePhone, isPhoneNumber, isLatitude, isLongitude, isStrongPassword, isArrayNotEmpty, isArrayUnique, isDateString, }: {
3
3
  type: "string" | "int" | "float" | "date" | "boolean";
4
4
  enumObject?: object;
5
5
  swaggerType?: any;
@@ -27,6 +27,7 @@ export declare const ApiValidationProperty: ({ type, enumObject, swaggerType, mi
27
27
  isStrongPassword?: boolean;
28
28
  isArrayNotEmpty?: boolean;
29
29
  isArrayUnique?: boolean;
30
+ isDateString?: boolean;
30
31
  }) => (<TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void);
31
32
  export declare const Roles: (roles: string[]) => CustomDecorator<string[]>;
32
33
  export declare const GetCurrentUserId: (...dataOrPipes: (import("@nestjs/common").PipeTransform<any, any> | import("@nestjs/common").Type<import("@nestjs/common").PipeTransform<any, any>> | undefined)[]) => ParameterDecorator;
package/cjs/decorators.js CHANGED
@@ -5,9 +5,10 @@ const common_1 = require("@nestjs/common");
5
5
  const graphql_1 = require("@nestjs/graphql");
6
6
  const swagger_1 = require("@nestjs/swagger");
7
7
  const class_validator_1 = require("class-validator");
8
+ const class_transformer_1 = require("class-transformer");
8
9
  const const_1 = require("./const");
9
10
  const lib_1 = require("./lib");
10
- const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayMinSize, arrayMaxSize, divisibleBy, example, description, isSwaggerArray, isOptional = false, isUUID = false, isArray = false, isJson = false, isJWT = false, isUrl = false, isPositive = false, isNegative = false, isEmail = false, isMobilePhone = false, isPhoneNumber = false, isLatitude = false, isLongitude = false, isStrongPassword = false, isArrayNotEmpty = false, isArrayUnique = false, }) => {
11
+ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayMinSize, arrayMaxSize, divisibleBy, example, description, isSwaggerArray, isOptional = false, isUUID = false, isArray = false, isJson = false, isJWT = false, isUrl = false, isPositive = false, isNegative = false, isEmail = false, isMobilePhone = false, isPhoneNumber = false, isLatitude = false, isLongitude = false, isStrongPassword = false, isArrayNotEmpty = false, isArrayUnique = false, isDateString = false, }) => {
11
12
  const decorators = [];
12
13
  const swaggerData = {
13
14
  example,
@@ -97,6 +98,7 @@ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayM
97
98
  decorators.push((0, class_validator_1.ArrayMaxSize)(arrayMaxSize));
98
99
  }
99
100
  decorators.push((0, class_validator_1.IsDate)({ each: isArray }));
101
+ decorators.push((0, class_transformer_1.Type)(() => Date));
100
102
  break;
101
103
  case 'boolean':
102
104
  decorators.push((0, graphql_1.Field)({ nullable: isOptional }));
@@ -156,6 +158,8 @@ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayM
156
158
  decorators.push((0, class_validator_1.IsLongitude)({ each: isArray }));
157
159
  if (isStrongPassword)
158
160
  decorators.push((0, class_validator_1.IsStrongPassword)(undefined, { each: isArray }));
161
+ if (isDateString)
162
+ decorators.push((0, class_validator_1.IsDateString)(undefined, { each: isArray }));
159
163
  }
160
164
  return (0, common_1.applyDecorators)(...decorators);
161
165
  };
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAA,2CAMwB;AACxB,6CAAoD;AACpD,6CAAyF;AACzF,qDA8ByB;AACzB,mCAAoC;AACpC,+BAA8C;AAEvC,MAAM,qBAAqB,GAAG,CAAC,EACpC,IAAI,EACJ,UAAU,EACV,WAAW,EACX,GAAG,EACH,GAAG,EACH,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,OAAO,EACP,WAAW,EACX,cAAc,EACd,UAAU,GAAG,KAAK,EAClB,MAAM,GAAG,KAAK,EACd,OAAO,GAAG,KAAK,EACf,MAAM,GAAG,KAAK,EACd,KAAK,GAAG,KAAK,EACb,KAAK,GAAG,KAAK,EACb,UAAU,GAAG,KAAK,EAClB,UAAU,GAAG,KAAK,EAClB,OAAO,GAAG,KAAK,EACf,aAAa,GAAG,KAAK,EACrB,aAAa,GAAG,KAAK,EACrB,UAAU,GAAG,KAAK,EAClB,WAAW,GAAG,KAAK,EACnB,gBAAgB,GAAG,KAAK,EACxB,eAAe,GAAG,KAAK,EACvB,aAAa,GAAG,KAAK,GA+BtB,EAIU,EAAE;IACX,MAAM,UAAU,GAAG,EAAE,CAAC;IAEtB,MAAM,WAAW,GAAG;QAClB,OAAO;QACP,WAAW;QACX,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,cAAc;QACvB,IAAI,EAAE,WAAW;KACl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A2B,EAAE,CAAC,IAAA,oBAAW,EAAC,8BAAsB,EAAE,cAAc,CAAC,CAAC;AAFtE,QAAA,gBAAgB,oBAEsD","sourcesContent":["import {\n applyDecorators,\n createParamDecorator,\n CustomDecorator,\n ExecutionContext,\n SetMetadata,\n} from '@nestjs/common';\nimport { Field, Float, Int } from '@nestjs/graphql';\nimport { ApiProperty as SwaggerApiProperty, ApiPropertyOptional } from '@nestjs/swagger';\nimport {\n ArrayMaxSize,\n ArrayMinSize,\n ArrayNotEmpty,\n ArrayUnique,\n IsArray,\n IsBoolean,\n IsDate,\n IsEmail,\n IsEnum,\n IsInt,\n IsJSON,\n IsJWT,\n IsLatitude,\n IsLongitude,\n IsMobilePhone,\n IsNegative,\n IsNumber,\n IsOptional,\n IsPhoneNumber,\n IsPositive,\n IsString,\n IsStrongPassword,\n IsUrl,\n IsUUID,\n Max,\n MaxLength,\n Min,\n MinLength,\n IsDivisibleBy,\n} from 'class-validator';\nimport { ROLES_KEY } from './const';\nimport { prepareRequestContext } from './lib';\n\nexport const ApiValidationProperty = ({\n type,\n enumObject,\n swaggerType,\n min,\n max,\n arrayMinSize,\n arrayMaxSize,\n divisibleBy,\n example,\n description,\n isSwaggerArray,\n isOptional = false,\n isUUID = false,\n isArray = false,\n isJson = false,\n isJWT = false,\n isUrl = false,\n isPositive = false,\n isNegative = false,\n isEmail = false,\n isMobilePhone = false,\n isPhoneNumber = false,\n isLatitude = false,\n isLongitude = false,\n isStrongPassword = false,\n isArrayNotEmpty = false,\n isArrayUnique = false,\n}: {\n type: 'string' | 'int' | 'float' | 'date' | 'boolean';\n enumObject?: object;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n swaggerType?: any;\n min?: number;\n max?: number;\n arrayMinSize?: number;\n arrayMaxSize?: number;\n divisibleBy?: number;\n example?: string;\n description?: string;\n isOptional?: boolean;\n isUUID?: boolean;\n isArray?: boolean;\n isSwaggerArray?: boolean;\n isJson?: boolean;\n isJWT?: boolean;\n isUrl?: boolean;\n isPositive?: boolean;\n isNegative?: boolean;\n isEmail?: boolean;\n isMobilePhone?: boolean;\n isPhoneNumber?: boolean;\n isLatitude?: boolean;\n isLongitude?: boolean;\n isStrongPassword?: boolean;\n isArrayNotEmpty?: boolean;\n isArrayUnique?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n}): (<TFunction extends Function, Y>(\n target: TFunction | object,\n propertyKey?: string | symbol,\n descriptor?: TypedPropertyDescriptor<Y>,\n) => void) => {\n const decorators = [];\n\n const swaggerData = {\n example,\n description,\n enum: enumObject,\n isArray: isSwaggerArray,\n type: swaggerType,\n };\n\n if (!enumObject) {\n delete swaggerData.enum;\n }\n\n if (!isSwaggerArray) {\n delete swaggerData.isArray;\n }\n\n if (!swaggerType) {\n delete swaggerData.type;\n }\n\n if (isOptional) {\n decorators.push(ApiPropertyOptional(swaggerData));\n } else {\n decorators.push(SwaggerApiProperty(swaggerData));\n }\n\n switch (type) {\n case 'int':\n decorators.push(Field(() => (isArray ? [Int] : Int), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize) decorators.push(ArrayMaxSize(arrayMaxSize));\n if (divisibleBy) decorators.push(IsDivisibleBy(divisibleBy));\n }\n\n decorators.push(IsNumber());\n decorators.push(IsInt());\n\n if (min) decorators.push(Min(min, { each: isArray }));\n if (max) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy) decorators.push(IsDivisibleBy(divisibleBy, { each: isArray }));\n\n break;\n case 'float':\n decorators.push(Field(() => (isArray ? [Float] : Float), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsNumber());\n\n if (min) decorators.push(Min(min, { each: isArray }));\n if (max) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy) decorators.push(IsDivisibleBy(divisibleBy, { each: isArray }));\n\n break;\n case 'date':\n decorators.push(Field(() => (isArray ? [Date] : Date), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsDate({ each: isArray }));\n break;\n case 'boolean':\n decorators.push(Field({ nullable: isOptional }));\n if (isOptional) decorators.push(IsOptional());\n decorators.push(IsBoolean());\n break;\n case 'string':\n default:\n if (enumObject) {\n decorators.push(\n Field(() => (isArray ? [enumObject] : enumObject), { nullable: isOptional }),\n );\n } else {\n decorators.push(Field(() => (isArray ? [String] : String), { nullable: isOptional }));\n }\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsString({ each: isArray }));\n\n if (isUUID) decorators.push(IsUUID(undefined, { each: isArray }));\n if (isEmail) decorators.push(IsEmail(undefined, { each: isArray }));\n if (isMobilePhone) decorators.push(IsMobilePhone(undefined, undefined, { each: isArray }));\n if (isPhoneNumber) decorators.push(IsPhoneNumber(undefined, { each: isArray }));\n if (isPositive) decorators.push(IsPositive({ each: isArray }));\n if (isNegative) decorators.push(IsNegative({ each: isArray }));\n if (min) decorators.push(MinLength(min, { each: isArray }));\n if (max) decorators.push(MaxLength(max, { each: isArray }));\n if (enumObject) decorators.push(IsEnum(enumObject, { each: isArray }));\n if (isJson) decorators.push(IsJSON({ each: isArray }));\n if (isJWT) decorators.push(IsJWT({ each: isArray }));\n if (isUrl) decorators.push(IsUrl(undefined, { each: isArray }));\n if (isLatitude) decorators.push(IsLatitude({ each: isArray }));\n if (isLongitude) decorators.push(IsLongitude({ each: isArray }));\n if (isStrongPassword) decorators.push(IsStrongPassword(undefined, { each: isArray }));\n }\n\n return applyDecorators(...decorators);\n};\n\nexport const Roles = (roles: string[]): CustomDecorator<string[]> => SetMetadata(ROLES_KEY, roles);\n\nexport const GetCurrentUserId = createParamDecorator(\n (_data: undefined, context: ExecutionContext): string => {\n const request = prepareRequestContext(context);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return request.user['id'];\n },\n);\n\nexport const GetCurrentRoles = createParamDecorator(\n (_data: undefined, context: ExecutionContext): string => {\n const request = prepareRequestContext(context);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (\n request.user['roles']?.map((item: { value: string } | string) => {\n if (typeof item === 'string') return item;\n return item.value;\n }) ?? []\n );\n },\n);\n\nexport const GetCurrentUser = createParamDecorator(\n (data: string | undefined, context: ExecutionContext) => {\n const request = prepareRequestContext(context);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n if (!data) return request.user;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return request.user[data];\n },\n);\n\nexport const Public = (): CustomDecorator<string> => SetMetadata('isPublic', true);\n\nexport const CHECK_FIELDS_ROLES_KEY = 'checkFieldsRoles';\nexport const CheckFieldsRoles = (fieldsRolesMap: {\n [field: string]: string[];\n}): CustomDecorator<string> => SetMetadata(CHECK_FIELDS_ROLES_KEY, fieldsRolesMap);\n"]}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],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Metadata,\n} from '@nestjs/common';\nimport { Field, Float, Int } from '@nestjs/graphql';\nimport { ApiProperty as SwaggerApiProperty, ApiPropertyOptional } from '@nestjs/swagger';\nimport {\n ArrayMaxSize,\n ArrayMinSize,\n ArrayNotEmpty,\n ArrayUnique,\n IsArray,\n IsBoolean,\n IsDate,\n IsEmail,\n IsEnum,\n IsInt,\n IsJSON,\n IsJWT,\n IsLatitude,\n IsLongitude,\n IsMobilePhone,\n IsNegative,\n IsNumber,\n IsOptional,\n IsPhoneNumber,\n IsPositive,\n IsString,\n IsStrongPassword,\n IsUrl,\n IsUUID,\n Max,\n MaxLength,\n Min,\n MinLength,\n IsDivisibleBy,\n IsDateString,\n} from 'class-validator';\nimport { Type } from 'class-transformer';\nimport { ROLES_KEY } from './const';\nimport { prepareRequestContext } from './lib';\n\nexport const ApiValidationProperty = ({\n type,\n enumObject,\n swaggerType,\n min,\n max,\n arrayMinSize,\n arrayMaxSize,\n divisibleBy,\n example,\n description,\n isSwaggerArray,\n isOptional = false,\n isUUID = false,\n isArray = false,\n isJson = false,\n isJWT = false,\n isUrl = false,\n isPositive = false,\n isNegative = false,\n isEmail = false,\n isMobilePhone = false,\n isPhoneNumber = false,\n isLatitude = false,\n isLongitude = false,\n isStrongPassword = false,\n isArrayNotEmpty = false,\n isArrayUnique = false,\n isDateString = false,\n}: {\n type: 'string' | 'int' | 'float' | 'date' | 'boolean';\n enumObject?: object;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n swaggerType?: any;\n min?: number;\n max?: number;\n arrayMinSize?: number;\n arrayMaxSize?: number;\n divisibleBy?: number;\n example?: string;\n description?: string;\n isOptional?: boolean;\n isUUID?: boolean;\n isArray?: boolean;\n isSwaggerArray?: boolean;\n isJson?: boolean;\n isJWT?: boolean;\n isUrl?: boolean;\n isPositive?: boolean;\n isNegative?: boolean;\n isEmail?: boolean;\n isMobilePhone?: boolean;\n isPhoneNumber?: boolean;\n isLatitude?: boolean;\n isLongitude?: boolean;\n isStrongPassword?: boolean;\n isArrayNotEmpty?: boolean;\n isArrayUnique?: boolean;\n isDateString?: boolean;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n}): (<TFunction extends Function, Y>(\n target: TFunction | object,\n propertyKey?: string | symbol,\n descriptor?: TypedPropertyDescriptor<Y>,\n) => void) => {\n const decorators = [];\n\n const swaggerData = {\n example,\n description,\n enum: enumObject,\n isArray: isSwaggerArray,\n type: swaggerType,\n };\n\n if (!enumObject) {\n delete swaggerData.enum;\n }\n\n if (!isSwaggerArray) {\n delete swaggerData.isArray;\n }\n\n if (!swaggerType) {\n delete swaggerData.type;\n }\n\n if (isOptional) {\n decorators.push(ApiPropertyOptional(swaggerData));\n } else {\n decorators.push(SwaggerApiProperty(swaggerData));\n }\n\n switch (type) {\n case 'int':\n decorators.push(Field(() => (isArray ? [Int] : Int), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize) decorators.push(ArrayMaxSize(arrayMaxSize));\n if (divisibleBy) decorators.push(IsDivisibleBy(divisibleBy));\n }\n\n decorators.push(IsNumber());\n decorators.push(IsInt());\n\n if (min) decorators.push(Min(min, { each: isArray }));\n if (max) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy) decorators.push(IsDivisibleBy(divisibleBy, { each: isArray }));\n\n break;\n case 'float':\n decorators.push(Field(() => (isArray ? [Float] : Float), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsNumber());\n\n if (min) decorators.push(Min(min, { each: isArray }));\n if (max) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy) decorators.push(IsDivisibleBy(divisibleBy, { each: isArray }));\n\n break;\n case 'date':\n decorators.push(Field(() => (isArray ? [Date] : Date), { nullable: isOptional }));\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsDate({ each: isArray }));\n decorators.push(Type(() => Date));\n break;\n case 'boolean':\n decorators.push(Field({ nullable: isOptional }));\n if (isOptional) decorators.push(IsOptional());\n decorators.push(IsBoolean());\n break;\n case 'string':\n default:\n if (enumObject) {\n decorators.push(\n Field(() => (isArray ? [enumObject] : enumObject), { nullable: isOptional }),\n );\n } else {\n decorators.push(Field(() => (isArray ? [String] : String), { nullable: isOptional }));\n }\n\n if (isOptional) decorators.push(IsOptional());\n\n if (isArray) {\n decorators.push(IsArray());\n if (isArrayNotEmpty) decorators.push(ArrayNotEmpty());\n if (isArrayUnique) decorators.push(ArrayUnique());\n if (arrayMinSize) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsString({ each: isArray }));\n\n if (isUUID) decorators.push(IsUUID(undefined, { each: isArray }));\n if (isEmail) decorators.push(IsEmail(undefined, { each: isArray }));\n if (isMobilePhone) decorators.push(IsMobilePhone(undefined, undefined, { each: isArray }));\n if (isPhoneNumber) decorators.push(IsPhoneNumber(undefined, { each: isArray }));\n if (isPositive) decorators.push(IsPositive({ each: isArray }));\n if (isNegative) decorators.push(IsNegative({ each: isArray }));\n if (min) decorators.push(MinLength(min, { each: isArray }));\n if (max) decorators.push(MaxLength(max, { each: isArray }));\n if (enumObject) decorators.push(IsEnum(enumObject, { each: isArray }));\n if (isJson) decorators.push(IsJSON({ each: isArray }));\n if (isJWT) decorators.push(IsJWT({ each: isArray }));\n if (isUrl) decorators.push(IsUrl(undefined, { each: isArray }));\n if (isLatitude) decorators.push(IsLatitude({ each: isArray }));\n if (isLongitude) decorators.push(IsLongitude({ each: isArray }));\n if (isStrongPassword) decorators.push(IsStrongPassword(undefined, { each: isArray }));\n if (isDateString) decorators.push(IsDateString(undefined, { each: isArray }));\n }\n\n return applyDecorators(...decorators);\n};\n\nexport const Roles = (roles: string[]): CustomDecorator<string[]> => SetMetadata(ROLES_KEY, roles);\n\nexport const GetCurrentUserId = createParamDecorator(\n (_data: undefined, context: ExecutionContext): string => {\n const request = prepareRequestContext(context);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return request.user['id'];\n },\n);\n\nexport const GetCurrentRoles = createParamDecorator(\n (_data: undefined, context: ExecutionContext): string => {\n const request = prepareRequestContext(context);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return (\n request.user['roles']?.map((item: { value: string } | string) => {\n if (typeof item === 'string') return item;\n return item.value;\n }) ?? []\n );\n },\n);\n\nexport const GetCurrentUser = createParamDecorator(\n (data: string | undefined, context: ExecutionContext) => {\n const request = prepareRequestContext(context);\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n if (!data) return request.user;\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return request.user[data];\n },\n);\n\nexport const Public = (): CustomDecorator<string> => SetMetadata('isPublic', true);\n\nexport const CHECK_FIELDS_ROLES_KEY = 'checkFieldsRoles';\nexport const CheckFieldsRoles = (fieldsRolesMap: {\n [field: string]: string[];\n}): CustomDecorator<string> => SetMetadata(CHECK_FIELDS_ROLES_KEY, fieldsRolesMap);\n"]}