denwa-nest-shared 1.2.4 → 1.2.6

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 (53) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +124 -0
  3. package/cjs/decorators.d.ts +4 -2
  4. package/cjs/decorators.js +59 -30
  5. package/cjs/decorators.js.map +1 -1
  6. package/cjs/dto.js +10 -3
  7. package/cjs/dto.js.map +1 -1
  8. package/cjs/interceptors/fields-roles.interceptor.js +9 -3
  9. package/cjs/interceptors/fields-roles.interceptor.js.map +1 -1
  10. package/cjs/lib.js +79 -35
  11. package/cjs/lib.js.map +1 -1
  12. package/cjs/openapi-axios/interpolate-params.js +1 -12
  13. package/cjs/openapi-axios/interpolate-params.js.map +1 -1
  14. package/cjs/openapi-axios/types/serializer.d.ts +1 -0
  15. package/cjs/openapi-axios/types/serializer.js +1 -0
  16. package/cjs/openapi-axios/types/serializer.js.map +1 -1
  17. package/cjs/opensearch-core.js +1 -1
  18. package/cjs/opensearch-core.js.map +1 -1
  19. package/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  20. package/cjs/validation/validation.exception.d.ts +2 -2
  21. package/cjs/validation/validation.exception.js +1 -1
  22. package/cjs/validation/validation.exception.js.map +1 -1
  23. package/cjs/validation/validation.pipe.d.ts +2 -0
  24. package/cjs/validation/validation.pipe.js +27 -11
  25. package/cjs/validation/validation.pipe.js.map +1 -1
  26. package/dist/decorators.d.ts +4 -2
  27. package/dist/decorators.js +60 -31
  28. package/dist/decorators.js.map +1 -1
  29. package/dist/dto.js +11 -4
  30. package/dist/dto.js.map +1 -1
  31. package/dist/interceptors/fields-roles.interceptor.js +9 -3
  32. package/dist/interceptors/fields-roles.interceptor.js.map +1 -1
  33. package/dist/lib.js +79 -35
  34. package/dist/lib.js.map +1 -1
  35. package/dist/openapi-axios/interpolate-params.js +1 -12
  36. package/dist/openapi-axios/interpolate-params.js.map +1 -1
  37. package/dist/openapi-axios/types/serializer.d.ts +1 -0
  38. package/dist/openapi-axios/types/serializer.js +1 -0
  39. package/dist/openapi-axios/types/serializer.js.map +1 -1
  40. package/dist/opensearch-core.js +1 -1
  41. package/dist/opensearch-core.js.map +1 -1
  42. package/dist/tsconfig.build.tsbuildinfo +1 -1
  43. package/dist/validation/validation.exception.d.ts +2 -2
  44. package/dist/validation/validation.exception.js +1 -1
  45. package/dist/validation/validation.exception.js.map +1 -1
  46. package/dist/validation/validation.pipe.d.ts +2 -0
  47. package/dist/validation/validation.pipe.js +27 -11
  48. package/dist/validation/validation.pipe.js.map +1 -1
  49. package/package.json +16 -6
  50. package/skills/auth-security/SKILL.md +3 -3
  51. package/skills/data-access-typeorm/SKILL.md +22 -4
  52. package/skills/file-management/SKILL.md +27 -21
  53. package/skills/schema-definition/SKILL.md +83 -16
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.2.6](https://github.com/Denwa799/nest-shared/compare/v1.2.5...v1.2.6) (2026-09-13)
6
+
7
+ ### [1.2.5](https://github.com/Denwa799/nest-shared/compare/v1.2.4...v1.2.5) (2026-09-03)
8
+
5
9
  ### [1.2.4](https://github.com/Denwa799/nest-shared/compare/v1.2.3...v1.2.4) (2026-07-14)
6
10
 
7
11
  ### [1.2.3](https://github.com/Denwa799/nest-shared/compare/v1.2.2...v1.2.3) (2026-07-14)
package/README.md ADDED
@@ -0,0 +1,124 @@
1
+ # denwa-nest-shared
2
+
3
+ Общая shared-библиотека для микросервисов и приложений монорепозитория на базе NestJS, GraphQL, OpenAPI (Swagger) и TypeORM.
4
+
5
+ ## Возможности
6
+
7
+ - **Единая валидация схем (`ApiValidationProperty`):** один декоратор объединяет Swagger (`@ApiProperty`), GraphQL (`@Field`) и валидацию `class-validator` (`@IsString`, `@Min`, `@IsOptional` и др.).
8
+ - **Контроль доступа к полям (`MutableBy`, `sanitizeDto`):** ограничение редактирования отдельных полей DTO на основе ролей пользователя.
9
+ - **Генератор запросов TypeORM (`createQueryData`):** построение параметров выборки с пагинацией, мультипоиском (`ILike`), фильтрацией и диапазонами (`fromToFields`).
10
+ - **Гарды и перехватчики ролей (`FieldsRolesInterceptor`, `@CheckFieldsRoles`, `@Roles`, `@Public`):** управление доступом на уровне резолверов и полей GraphQL.
11
+ - **OpenAPI Axios клиент (`OpenApiAxios`):** типобезопасный HTTP-клиент на базе схемы OpenAPI.
12
+ - **Утилиты:** транслитерация (`translit`, `checkTranslit`), форматирование телефонов (`formatPhone`), валидационный пайп (`ValidationPipe`), интеграция с OpenSearch (`OpenSearchCore`).
13
+
14
+ ## Установка
15
+
16
+ ```bash
17
+ npm install denwa-nest-shared
18
+ ```
19
+
20
+ ### Peer Dependencies
21
+
22
+ Убедитесь, что в вашем сервисе установлены необходимые peer-зависимости:
23
+
24
+ ```bash
25
+ npm install @nestjs/common @nestjs/graphql @nestjs/swagger class-validator class-transformer graphql typeorm rxjs
26
+ ```
27
+
28
+ ## Быстрый старт
29
+
30
+ ### 1. Определение DTO
31
+
32
+ ```typescript
33
+ import { InputType } from '@nestjs/graphql';
34
+ import { ApiValidationProperty, MutableBy } from 'denwa-nest-shared';
35
+
36
+ @InputType()
37
+ export class CreateProductDto {
38
+ @ApiValidationProperty({
39
+ type: 'string',
40
+ description: 'Название товара',
41
+ min: 2,
42
+ max: 255,
43
+ })
44
+ nameRU: string;
45
+
46
+ @ApiValidationProperty({
47
+ type: 'int',
48
+ min: 0,
49
+ isOptional: true,
50
+ })
51
+ @MutableBy(['super_admin', 'admin'])
52
+ priority?: number;
53
+ }
54
+ ```
55
+
56
+ ### 2. Вложенные DTO
57
+
58
+ Для вложенных объектов передавайте класс DTO через `objectType` (или `swaggerType` — для обратной
59
+ совместимости, включая `[SomeDto]`). Тогда `@Field`, `@ValidateNested` и `@Type` проставляются
60
+ автоматически, а ошибочный `IsString` не эмитится.
61
+
62
+ ```typescript
63
+ import { InputType } from '@nestjs/graphql';
64
+ import { ApiValidationProperty } from 'denwa-nest-shared';
65
+
66
+ @InputType()
67
+ class ImageDto {
68
+ @ApiValidationProperty({ type: 'string', max: 256 })
69
+ tempName: string;
70
+ }
71
+
72
+ @InputType()
73
+ export class UpdateProductDto {
74
+ @ApiValidationProperty({
75
+ type: 'object',
76
+ objectType: ImageDto,
77
+ isArray: true,
78
+ isOptional: true,
79
+ })
80
+ images?: ImageDto[];
81
+ }
82
+ ```
83
+
84
+ ### 3. Фильтрация и поиск с TypeORM
85
+
86
+ ```typescript
87
+ import { createQueryData } from 'denwa-nest-shared';
88
+ import { Repository } from 'typeorm';
89
+
90
+ async function getUsers(userRepository: Repository<User>, query: any) {
91
+ const queryData = createQueryData({
92
+ page: query.page ?? 1,
93
+ limit: query.limit ?? 20,
94
+ sortField: 'createdAt',
95
+ sortOrder: 'desc',
96
+ filterType: 'and',
97
+ filter: query.filter,
98
+ search: query.search,
99
+ searchFields: ['name', 'email'],
100
+ });
101
+
102
+ return await userRepository.findAndCount(queryData);
103
+ }
104
+ ```
105
+
106
+ ## Сборка и тестирование
107
+
108
+ ```bash
109
+ # Линтинг
110
+ npm run lint
111
+
112
+ # Форматирование
113
+ npm run format
114
+
115
+ # Тесты
116
+ npm test
117
+
118
+ # Сборка (ESM и CJS)
119
+ npm run build
120
+ ```
121
+
122
+ ## Лицензия
123
+
124
+ ISC
@@ -1,8 +1,10 @@
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, isDateString, }: {
3
- type: "string" | "int" | "float" | "date" | "boolean";
2
+ export type ClassRef = new (...args: never[]) => unknown;
3
+ export declare const ApiValidationProperty: ({ type, enumObject, swaggerType, objectType, 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, }: {
4
+ type: "string" | "int" | "float" | "date" | "boolean" | "object";
4
5
  enumObject?: object;
5
6
  swaggerType?: any;
7
+ objectType?: ClassRef;
6
8
  min?: number;
7
9
  max?: number;
8
10
  arrayMinSize?: number;
package/cjs/decorators.js CHANGED
@@ -9,14 +9,22 @@ const class_validator_1 = require("class-validator");
9
9
  const class_transformer_1 = require("class-transformer");
10
10
  const const_1 = require("./const");
11
11
  const lib_1 = require("./lib");
12
- 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, }) => {
12
+ const BUILT_IN_TYPES = new Set([String, Number, Boolean, Object, Date, Array, Function]);
13
+ const isClassRef = (value) => typeof value === 'function' && !BUILT_IN_TYPES.has(value);
14
+ const resolveObjectType = (objectType, swaggerType) => {
15
+ const raw = objectType ?? swaggerType;
16
+ const candidate = Array.isArray(raw) ? raw[0] : raw;
17
+ return isClassRef(candidate) ? candidate : null;
18
+ };
19
+ const ApiValidationProperty = ({ type, enumObject, swaggerType, objectType, 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, }) => {
13
20
  const decorators = [];
21
+ const schemaType = swaggerType ?? (objectType ? (isArray ? [objectType] : objectType) : undefined);
14
22
  const swaggerData = {
15
23
  example,
16
24
  description,
17
25
  enum: enumObject,
18
26
  isArray: isSwaggerArray,
19
- type: swaggerType,
27
+ type: schemaType,
20
28
  };
21
29
  if (!enumObject) {
22
30
  delete swaggerData.enum;
@@ -24,7 +32,7 @@ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayM
24
32
  if (!isSwaggerArray) {
25
33
  delete swaggerData.isArray;
26
34
  }
27
- if (!swaggerType) {
35
+ if (!schemaType) {
28
36
  delete swaggerData.type;
29
37
  }
30
38
  if (isOptional) {
@@ -33,6 +41,29 @@ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayM
33
41
  else {
34
42
  decorators.push((0, swagger_1.ApiProperty)(swaggerData));
35
43
  }
44
+ const nestedType = resolveObjectType(objectType, swaggerType);
45
+ if (nestedType) {
46
+ decorators.push((0, graphql_1.Field)(() => (isArray ? [nestedType] : nestedType), { nullable: isOptional }));
47
+ if (isOptional)
48
+ decorators.push((0, class_validator_1.IsOptional)());
49
+ if (isArray) {
50
+ decorators.push((0, class_validator_1.IsArray)());
51
+ if (isArrayNotEmpty)
52
+ decorators.push((0, class_validator_1.ArrayNotEmpty)());
53
+ if (isArrayUnique)
54
+ decorators.push((0, class_validator_1.ArrayUnique)());
55
+ if (arrayMinSize !== undefined)
56
+ decorators.push((0, class_validator_1.ArrayMinSize)(arrayMinSize));
57
+ if (arrayMaxSize !== undefined)
58
+ decorators.push((0, class_validator_1.ArrayMaxSize)(arrayMaxSize));
59
+ }
60
+ decorators.push((0, class_validator_1.ValidateNested)({ each: isArray }));
61
+ decorators.push((0, class_transformer_1.Type)(() => nestedType));
62
+ return (0, common_1.applyDecorators)(...decorators);
63
+ }
64
+ if (type === 'object') {
65
+ throw new Error('ApiValidationProperty: `type: "object"` requires a nested DTO class in `objectType` or `swaggerType`');
66
+ }
36
67
  switch (type) {
37
68
  case 'int':
38
69
  decorators.push((0, graphql_1.Field)(() => (isArray ? [graphql_1.Int] : graphql_1.Int), { nullable: isOptional }));
@@ -44,20 +75,18 @@ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayM
44
75
  decorators.push((0, class_validator_1.ArrayNotEmpty)());
45
76
  if (isArrayUnique)
46
77
  decorators.push((0, class_validator_1.ArrayUnique)());
47
- if (arrayMinSize)
78
+ if (arrayMinSize !== undefined)
48
79
  decorators.push((0, class_validator_1.ArrayMinSize)(arrayMinSize));
49
- if (arrayMaxSize)
80
+ if (arrayMaxSize !== undefined)
50
81
  decorators.push((0, class_validator_1.ArrayMaxSize)(arrayMaxSize));
51
- if (divisibleBy)
52
- decorators.push((0, class_validator_1.IsDivisibleBy)(divisibleBy));
53
82
  }
54
- decorators.push((0, class_validator_1.IsNumber)());
55
- decorators.push((0, class_validator_1.IsInt)());
56
- if (min)
83
+ decorators.push((0, class_validator_1.IsNumber)({}, { each: isArray }));
84
+ decorators.push((0, class_validator_1.IsInt)({ each: isArray }));
85
+ if (min !== undefined)
57
86
  decorators.push((0, class_validator_1.Min)(min, { each: isArray }));
58
- if (max)
87
+ if (max !== undefined)
59
88
  decorators.push((0, class_validator_1.Max)(max, { each: isArray }));
60
- if (divisibleBy)
89
+ if (divisibleBy !== undefined)
61
90
  decorators.push((0, class_validator_1.IsDivisibleBy)(divisibleBy, { each: isArray }));
62
91
  break;
63
92
  case 'float':
@@ -70,17 +99,17 @@ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayM
70
99
  decorators.push((0, class_validator_1.ArrayNotEmpty)());
71
100
  if (isArrayUnique)
72
101
  decorators.push((0, class_validator_1.ArrayUnique)());
73
- if (arrayMinSize)
102
+ if (arrayMinSize !== undefined)
74
103
  decorators.push((0, class_validator_1.ArrayMinSize)(arrayMinSize));
75
- if (arrayMaxSize)
104
+ if (arrayMaxSize !== undefined)
76
105
  decorators.push((0, class_validator_1.ArrayMaxSize)(arrayMaxSize));
77
106
  }
78
- decorators.push((0, class_validator_1.IsNumber)());
79
- if (min)
107
+ decorators.push((0, class_validator_1.IsNumber)({}, { each: isArray }));
108
+ if (min !== undefined)
80
109
  decorators.push((0, class_validator_1.Min)(min, { each: isArray }));
81
- if (max)
110
+ if (max !== undefined)
82
111
  decorators.push((0, class_validator_1.Max)(max, { each: isArray }));
83
- if (divisibleBy)
112
+ if (divisibleBy !== undefined)
84
113
  decorators.push((0, class_validator_1.IsDivisibleBy)(divisibleBy, { each: isArray }));
85
114
  break;
86
115
  case 'date':
@@ -93,9 +122,9 @@ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayM
93
122
  decorators.push((0, class_validator_1.ArrayNotEmpty)());
94
123
  if (isArrayUnique)
95
124
  decorators.push((0, class_validator_1.ArrayUnique)());
96
- if (arrayMinSize)
125
+ if (arrayMinSize !== undefined)
97
126
  decorators.push((0, class_validator_1.ArrayMinSize)(arrayMinSize));
98
- if (arrayMaxSize)
127
+ if (arrayMaxSize !== undefined)
99
128
  decorators.push((0, class_validator_1.ArrayMaxSize)(arrayMaxSize));
100
129
  }
101
130
  decorators.push((0, class_validator_1.IsDate)({ each: isArray }));
@@ -123,9 +152,9 @@ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayM
123
152
  decorators.push((0, class_validator_1.ArrayNotEmpty)());
124
153
  if (isArrayUnique)
125
154
  decorators.push((0, class_validator_1.ArrayUnique)());
126
- if (arrayMinSize)
155
+ if (arrayMinSize !== undefined)
127
156
  decorators.push((0, class_validator_1.ArrayMinSize)(arrayMinSize));
128
- if (arrayMaxSize)
157
+ if (arrayMaxSize !== undefined)
129
158
  decorators.push((0, class_validator_1.ArrayMaxSize)(arrayMaxSize));
130
159
  }
131
160
  decorators.push((0, class_validator_1.IsString)({ each: isArray }));
@@ -141,9 +170,9 @@ const ApiValidationProperty = ({ type, enumObject, swaggerType, min, max, arrayM
141
170
  decorators.push((0, class_validator_1.IsPositive)({ each: isArray }));
142
171
  if (isNegative)
143
172
  decorators.push((0, class_validator_1.IsNegative)({ each: isArray }));
144
- if (min)
173
+ if (min !== undefined)
145
174
  decorators.push((0, class_validator_1.MinLength)(min, { each: isArray }));
146
- if (max)
175
+ if (max !== undefined)
147
176
  decorators.push((0, class_validator_1.MaxLength)(max, { each: isArray }));
148
177
  if (enumObject)
149
178
  decorators.push((0, class_validator_1.IsEnum)(enumObject, { each: isArray }));
@@ -169,11 +198,11 @@ const Roles = (roles) => (0, common_1.SetMetadata)(const_1.ROLES_KEY, roles);
169
198
  exports.Roles = Roles;
170
199
  exports.GetCurrentUserId = (0, common_1.createParamDecorator)((_data, context) => {
171
200
  const request = (0, lib_1.prepareRequestContext)(context);
172
- return request.user['id'];
201
+ return request?.user?.['id'];
173
202
  });
174
203
  exports.GetCurrentRoles = (0, common_1.createParamDecorator)((_data, context) => {
175
204
  const request = (0, lib_1.prepareRequestContext)(context);
176
- return (request.user['roles']?.map((item) => {
205
+ return (request?.user?.['roles']?.map((item) => {
177
206
  if (typeof item === 'string')
178
207
  return item;
179
208
  return item.value;
@@ -182,8 +211,8 @@ exports.GetCurrentRoles = (0, common_1.createParamDecorator)((_data, context) =>
182
211
  exports.GetCurrentUser = (0, common_1.createParamDecorator)((data, context) => {
183
212
  const request = (0, lib_1.prepareRequestContext)(context);
184
213
  if (!data)
185
- return request.user;
186
- return request.user[data];
214
+ return request?.user;
215
+ return request?.user?.[data];
187
216
  });
188
217
  const Public = () => (0, common_1.SetMetadata)('isPublic', true);
189
218
  exports.Public = Public;
@@ -195,8 +224,8 @@ function MutableBy(roles) {
195
224
  return (target, propertyKey) => {
196
225
  const proto = (target.constructor?.prototype ?? target);
197
226
  const existing = Reflect.getMetadata(exports.MUTABLE_BY_KEY, proto) ?? {};
198
- existing[String(propertyKey)] = roles;
199
- Reflect.defineMetadata(exports.MUTABLE_BY_KEY, existing, proto);
227
+ const updated = { ...existing, [String(propertyKey)]: roles };
228
+ Reflect.defineMetadata(exports.MUTABLE_BY_KEY, updated, proto);
200
229
  };
201
230
  }
202
231
  //# sourceMappingURL=decorators.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAoTA,8BAQC;AA5TD,2CAMwB;AACxB,6CAAoD;AACpD,6CAAyF;AACzF,qDA+ByB;AACzB,yDAAyC;AACzC,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,EACrB,YAAY,GAAG,KAAK,GAgCrB,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;KAClB,CAAC;IAEF,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,WAAW,CAAC,IAAI,CAAC;IAC1B,CAAC;IAED,IAAI,CAAC,cAAc,EAAE,CAAC;QACpB,OAAO,WAAW,CAAC,OAAO,CAAC;IAC7B,CAAC;IAED,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,WAAW,CAAC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IAAA,oBAAW,EAAC,8BAAsB,EAAE,cAAc,CAAC,CAAC;AAFtE,QAAA,gBAAgB,oBAEsD;AAMtE,QAAA,cAAc,GAAG,WAAW,CAAC;AAkB1C,SAAgB,SAAS,CAAC,KAAe;IACvC,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,EAAE;QACtD,MAAM,KAAK,GAAW,CAAC,MAAM,CAAC,WAAW,EAAE,SAAS,IAAI,MAAM,CAAW,CAAC;QAC1E,MAAM,QAAQ,GACX,OAAO,CAAC,WAAW,CAAC,sBAAc,EAAE,KAAK,CAA0C,IAAI,EAAE,CAAC;QAC7F,QAAQ,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,GAAG,KAAK,CAAC;QACtC,OAAO,CAAC,cAAc,CAAC,sBAAc,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC,CAAC;AACJ,CAAC","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 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\n/**\n * Metadata key for `@MutableBy()` — marks a DTO field as editable only by specific roles.\n * Fields without this decorator are editable by anyone.\n */\nexport const MUTABLE_BY_KEY = 'mutableBy';\n\n/**\n * Property decorator that marks an input DTO field as restricted to specific roles.\n * The `sanitizeDto()` utility reads this metadata and strips the field if the\n * current user lacks the required role.\n *\n * @example\n * ```ts\n * class CreateProductDto {\n * \\@MutableBy([ROLES.super_admin, ROLES.admin])\n * priority?: number;\n *\n * nameRU: string; // no decorator — anyone can set\n * }\n * ```\n */\n\nexport function MutableBy(roles: string[]): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const proto: object = (target.constructor?.prototype ?? target) as object;\n const existing: Record<string, string[]> =\n (Reflect.getMetadata(MUTABLE_BY_KEY, proto) as Record<string, string[]> | undefined) ?? {};\n existing[String(propertyKey)] = roles;\n Reflect.defineMetadata(MUTABLE_BY_KEY, existing, proto);\n };\n}\n"]}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAkXA,8BAQC;AA1XD,2CAMwB;AACxB,6CAAoD;AACpD,6CAAyF;AACzF,qDAgCyB;AACzB,yDAAy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AG,EAAE,GAAG,QAAQ,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC;QAC9D,OAAO,CAAC,cAAc,CAAC,sBAAc,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACzD,CAAC,CAAC;AACJ,CAAC","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 IsDateString,\n ValidateNested,\n} from 'class-validator';\nimport { Type } from 'class-transformer';\nimport { ROLES_KEY } from './const';\nimport { prepareRequestContext } from './lib';\n\n/** Конструктор класса вложенного DTO. */\nexport type ClassRef = new (...args: never[]) => unknown;\n\n/** Встроенные конструкторы, которые не считаются вложенным DTO. */\nconst BUILT_IN_TYPES = new Set<unknown>([String, Number, Boolean, Object, Date, Array, Function]);\n\nconst isClassRef = (value: unknown): value is ClassRef =>\n typeof value === 'function' && !BUILT_IN_TYPES.has(value);\n\n/**\n * Достаёт класс вложенного DTO из `objectType` или `swaggerType`.\n * Поддерживает как одиночный класс (`SomeDto`), так и массив из одного класса (`[SomeDto]`).\n */\nconst resolveObjectType = (\n objectType: ClassRef | undefined,\n swaggerType: unknown,\n): ClassRef | null => {\n const raw: unknown = objectType ?? swaggerType;\n const candidate = Array.isArray(raw) ? raw[0] : raw;\n\n return isClassRef(candidate) ? candidate : null;\n};\n\n/**\n * Единый декоратор для GraphQL, Swagger и class-validator.\n *\n * Для вложенных DTO передавайте класс в `objectType` (предпочтительно) или в `swaggerType`\n * (обратная совместимость, в т.ч. массив `[SomeDto]`). Тогда вместо `IsString` эмитятся\n * `@Field(() => SomeDto)`, `@ValidateNested()` и `@Type(() => SomeDto)`.\n */\nexport const ApiValidationProperty = ({\n type,\n enumObject,\n swaggerType,\n objectType,\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' | 'object';\n enumObject?: object;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n swaggerType?: any;\n objectType?: ClassRef;\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 schemaType =\n swaggerType ?? (objectType ? (isArray ? [objectType] : objectType) : undefined);\n\n const swaggerData = {\n example,\n description,\n enum: enumObject,\n isArray: isSwaggerArray,\n type: schemaType,\n };\n\n if (!enumObject) {\n delete swaggerData.enum;\n }\n\n if (!isSwaggerArray) {\n delete swaggerData.isArray;\n }\n\n if (!schemaType) {\n delete swaggerData.type;\n }\n\n if (isOptional) {\n decorators.push(ApiPropertyOptional(swaggerData));\n } else {\n decorators.push(SwaggerApiProperty(swaggerData));\n }\n\n const nestedType = resolveObjectType(objectType, swaggerType);\n\n if (nestedType) {\n decorators.push(Field(() => (isArray ? [nestedType] : nestedType), { 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 !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(ValidateNested({ each: isArray }));\n decorators.push(Type(() => nestedType));\n\n return applyDecorators(...decorators);\n }\n\n if (type === 'object') {\n throw new Error(\n 'ApiValidationProperty: `type: \"object\"` requires a nested DTO class in `objectType` or `swaggerType`',\n );\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 !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsNumber({}, { each: isArray }));\n decorators.push(IsInt({ each: isArray }));\n\n if (min !== undefined) decorators.push(Min(min, { each: isArray }));\n if (max !== undefined) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy !== undefined) 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 !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) decorators.push(ArrayMaxSize(arrayMaxSize));\n }\n\n decorators.push(IsNumber({}, { each: isArray }));\n\n if (min !== undefined) decorators.push(Min(min, { each: isArray }));\n if (max !== undefined) decorators.push(Max(max, { each: isArray }));\n if (divisibleBy !== undefined) 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 !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) 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 !== undefined) decorators.push(ArrayMinSize(arrayMinSize));\n if (arrayMaxSize !== undefined) 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 !== undefined) decorators.push(MinLength(min, { each: isArray }));\n if (max !== undefined) 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 | undefined => {\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\n/**\n * Metadata key for `@MutableBy()` — marks a DTO field as editable only by specific roles.\n * Fields without this decorator are editable by anyone.\n */\nexport const MUTABLE_BY_KEY = 'mutableBy';\n\n/**\n * Property decorator that marks an input DTO field as restricted to specific roles.\n * The `sanitizeDto()` utility reads this metadata and strips the field if the\n * current user lacks the required role.\n *\n * @example\n * ```ts\n * class CreateProductDto {\n * \\@MutableBy([ROLES.super_admin, ROLES.admin])\n * priority?: number;\n *\n * nameRU: string; // no decorator — anyone can set\n * }\n * ```\n */\n\nexport function MutableBy(roles: string[]): PropertyDecorator {\n return (target: object, propertyKey: string | symbol) => {\n const proto: object = (target.constructor?.prototype ?? target) as object;\n const existing: Record<string, string[]> =\n (Reflect.getMetadata(MUTABLE_BY_KEY, proto) as Record<string, string[]> | undefined) ?? {};\n const updated = { ...existing, [String(propertyKey)]: roles };\n Reflect.defineMetadata(MUTABLE_BY_KEY, updated, proto);\n };\n}\n"]}
package/cjs/dto.js CHANGED
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.SortFieldDto = exports.UpdateFilesResponse = exports.UpdateFilesRequest = exports.UpdateImagesResponse = exports.UpdateImagesRequest = exports.IdsDto = exports.InputPreparedFileDto = exports.InputPreparedImageDto = exports.PreparedFileDto = exports.PreparedImageDto = exports.AllImagesDto = exports.AllFilesDto = exports.AddTempImagesDto = exports.TempImagesDto = exports.TempFilesDto = exports.BadGatewayDto = exports.InternalErrorDto = exports.MethodNotAllowedDto = exports.NotFoundDto = exports.ForbiddenDto = exports.UnauthorizedDto = exports.BadRequestDto = exports.CreatedRequestDto = exports.OkRequestDto = exports.FileDto = exports.ImageFileDto = exports.DeleteDto = exports.Paginate = void 0;
13
13
  const graphql_1 = require("@nestjs/graphql");
14
14
  const swagger_1 = require("@nestjs/swagger");
15
+ const class_transformer_1 = require("class-transformer");
15
16
  const class_validator_1 = require("class-validator");
16
17
  const decorators_1 = require("./decorators");
17
18
  let Paginate = class Paginate {
@@ -442,7 +443,7 @@ __decorate([
442
443
  (0, swagger_1.ApiProperty)({ example: 'jpg', description: 'Расширение оригинального файла' }),
443
444
  (0, graphql_1.Field)(),
444
445
  (0, class_validator_1.IsString)(),
445
- (0, class_validator_1.Length)(4, 5),
446
+ (0, class_validator_1.Length)(1, 10),
446
447
  __metadata("design:type", String)
447
448
  ], PreparedImageDto.prototype, "originalFileExtension", void 0);
448
449
  __decorate([
@@ -579,7 +580,7 @@ __decorate([
579
580
  (0, swagger_1.ApiProperty)({ example: 'jpg', description: 'Расширение оригинального файла' }),
580
581
  (0, graphql_1.Field)(),
581
582
  (0, class_validator_1.IsString)(),
582
- (0, class_validator_1.Length)(4, 5),
583
+ (0, class_validator_1.Length)(1, 10),
583
584
  __metadata("design:type", String)
584
585
  ], InputPreparedImageDto.prototype, "originalFileExtension", void 0);
585
586
  __decorate([
@@ -746,6 +747,9 @@ __decorate([
746
747
  __decorate([
747
748
  (0, swagger_1.ApiProperty)({ description: 'Информация о фотографиях' }),
748
749
  (0, class_validator_1.IsOptional)(),
750
+ (0, class_validator_1.IsArray)(),
751
+ (0, class_validator_1.ValidateNested)({ each: true }),
752
+ (0, class_transformer_1.Type)(() => AllImagesData),
749
753
  __metadata("design:type", Array)
750
754
  ], UpdateImagesRequest.prototype, "allImages", void 0);
751
755
  __decorate([
@@ -798,6 +802,9 @@ __decorate([
798
802
  __decorate([
799
803
  (0, swagger_1.ApiProperty)({ description: 'Информация о файлах' }),
800
804
  (0, class_validator_1.IsOptional)(),
805
+ (0, class_validator_1.IsArray)(),
806
+ (0, class_validator_1.ValidateNested)({ each: true }),
807
+ (0, class_transformer_1.Type)(() => AllFilesData),
801
808
  __metadata("design:type", Array)
802
809
  ], UpdateFilesRequest.prototype, "allFiles", void 0);
803
810
  __decorate([
@@ -816,7 +823,7 @@ __decorate([
816
823
  __metadata("design:type", Number)
817
824
  ], UpdateFilesResponse.prototype, "statusCode", void 0);
818
825
  __decorate([
819
- (0, swagger_1.ApiProperty)({ example: 'Фото обновлены', description: 'Сообщение' }),
826
+ (0, swagger_1.ApiProperty)({ example: 'Файлы обновлены', description: 'Сообщение' }),
820
827
  __metadata("design:type", String)
821
828
  ], UpdateFilesResponse.prototype, "message", void 0);
822
829
  let SortFieldDto = class SortFieldDto {