@flusys/nestjs-localization 4.0.0-rc

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 (89) hide show
  1. package/README.md +870 -0
  2. package/cjs/config/index.js +19 -0
  3. package/cjs/config/localization.constants.js +20 -0
  4. package/cjs/config/message-keys.js +77 -0
  5. package/cjs/controllers/index.js +20 -0
  6. package/cjs/controllers/language.controller.js +188 -0
  7. package/cjs/controllers/translation-key.controller.js +174 -0
  8. package/cjs/controllers/translation.controller.js +254 -0
  9. package/cjs/dtos/index.js +20 -0
  10. package/cjs/dtos/language.dto.js +205 -0
  11. package/cjs/dtos/translation-key.dto.js +233 -0
  12. package/cjs/dtos/translation.dto.js +298 -0
  13. package/cjs/entities/index.js +42 -0
  14. package/cjs/entities/language.entity.js +126 -0
  15. package/cjs/entities/translation-key.entity.js +125 -0
  16. package/cjs/entities/translation.entity.js +120 -0
  17. package/cjs/index.js +24 -0
  18. package/cjs/interfaces/index.js +21 -0
  19. package/cjs/interfaces/language.interface.js +4 -0
  20. package/cjs/interfaces/localization-module-options.interface.js +4 -0
  21. package/cjs/interfaces/translation-key.interface.js +4 -0
  22. package/cjs/interfaces/translation.interface.js +4 -0
  23. package/cjs/modules/index.js +18 -0
  24. package/cjs/modules/localization.module.js +115 -0
  25. package/cjs/services/index.js +22 -0
  26. package/cjs/services/language.service.js +108 -0
  27. package/cjs/services/localization-config.service.js +66 -0
  28. package/cjs/services/localization-datasource.provider.js +122 -0
  29. package/cjs/services/translation-key.service.js +184 -0
  30. package/cjs/services/translation.service.js +222 -0
  31. package/config/index.d.ts +2 -0
  32. package/config/localization.constants.d.ts +2 -0
  33. package/config/message-keys.d.ts +96 -0
  34. package/controllers/index.d.ts +3 -0
  35. package/controllers/language.controller.d.ts +25 -0
  36. package/controllers/translation-key.controller.d.ts +22 -0
  37. package/controllers/translation.controller.d.ts +25 -0
  38. package/dtos/index.d.ts +3 -0
  39. package/dtos/language.dto.d.ts +24 -0
  40. package/dtos/translation-key.dto.d.ts +29 -0
  41. package/dtos/translation.dto.d.ts +42 -0
  42. package/entities/index.d.ts +8 -0
  43. package/entities/language.entity.d.ts +13 -0
  44. package/entities/translation-key.entity.d.ts +13 -0
  45. package/entities/translation.entity.d.ts +12 -0
  46. package/fesm/config/index.js +2 -0
  47. package/fesm/config/localization.constants.js +2 -0
  48. package/fesm/config/message-keys.js +54 -0
  49. package/fesm/controllers/index.js +3 -0
  50. package/fesm/controllers/language.controller.js +178 -0
  51. package/fesm/controllers/translation-key.controller.js +164 -0
  52. package/fesm/controllers/translation.controller.js +244 -0
  53. package/fesm/dtos/index.js +3 -0
  54. package/fesm/dtos/language.dto.js +184 -0
  55. package/fesm/dtos/translation-key.dto.js +209 -0
  56. package/fesm/dtos/translation.dto.js +265 -0
  57. package/fesm/entities/index.js +14 -0
  58. package/fesm/entities/language.entity.js +116 -0
  59. package/fesm/entities/translation-key.entity.js +115 -0
  60. package/fesm/entities/translation.entity.js +110 -0
  61. package/fesm/index.js +7 -0
  62. package/fesm/interfaces/index.js +4 -0
  63. package/fesm/interfaces/language.interface.js +1 -0
  64. package/fesm/interfaces/localization-module-options.interface.js +1 -0
  65. package/fesm/interfaces/translation-key.interface.js +1 -0
  66. package/fesm/interfaces/translation.interface.js +1 -0
  67. package/fesm/modules/index.js +1 -0
  68. package/fesm/modules/localization.module.js +105 -0
  69. package/fesm/services/index.js +5 -0
  70. package/fesm/services/language.service.js +98 -0
  71. package/fesm/services/localization-config.service.js +56 -0
  72. package/fesm/services/localization-datasource.provider.js +112 -0
  73. package/fesm/services/translation-key.service.js +174 -0
  74. package/fesm/services/translation.service.js +212 -0
  75. package/index.d.ts +7 -0
  76. package/interfaces/index.d.ts +4 -0
  77. package/interfaces/language.interface.d.ts +10 -0
  78. package/interfaces/localization-module-options.interface.d.ts +21 -0
  79. package/interfaces/translation-key.interface.d.ts +11 -0
  80. package/interfaces/translation.interface.d.ts +13 -0
  81. package/modules/index.d.ts +1 -0
  82. package/modules/localization.module.d.ts +8 -0
  83. package/package.json +80 -0
  84. package/services/index.d.ts +5 -0
  85. package/services/language.service.d.ts +18 -0
  86. package/services/localization-config.service.d.ts +11 -0
  87. package/services/localization-datasource.provider.d.ts +16 -0
  88. package/services/translation-key.service.d.ts +23 -0
  89. package/services/translation.service.d.ts +30 -0
@@ -0,0 +1,244 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ function _ts_metadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+ function _ts_param(paramIndex, decorator) {
24
+ return function(target, key) {
25
+ decorator(target, key, paramIndex);
26
+ };
27
+ }
28
+ import { createApiController, TRANSLATION_PERMISSIONS } from '@flusys/nestjs-shared/classes';
29
+ import { CurrentUser, RequirePermission } from '@flusys/nestjs-shared/decorators';
30
+ import { TRANSLATION_MESSAGES } from '../config';
31
+ import { JwtAuthGuard } from '@flusys/nestjs-shared/guards';
32
+ import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
33
+ import { Body, Controller, Inject, Post, UseGuards } from '@nestjs/common';
34
+ import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
35
+ import { BulkUpdateTranslationsDto, CreateTranslationDto, GetTranslationsByLanguageDto, GetTranslationsByModuleDto, TranslationResponseDto, UpdateTranslationDto } from '../dtos';
36
+ import { TranslationService } from '../services';
37
+ export class TranslationController extends createApiController(CreateTranslationDto, UpdateTranslationDto, TranslationResponseDto, {
38
+ entityName: 'translation',
39
+ security: {
40
+ insert: {
41
+ level: 'permission',
42
+ permissions: [
43
+ TRANSLATION_PERMISSIONS.CREATE
44
+ ]
45
+ },
46
+ insertMany: {
47
+ level: 'permission',
48
+ permissions: [
49
+ TRANSLATION_PERMISSIONS.CREATE
50
+ ]
51
+ },
52
+ getById: {
53
+ level: 'permission',
54
+ permissions: [
55
+ TRANSLATION_PERMISSIONS.READ
56
+ ]
57
+ },
58
+ getAll: {
59
+ level: 'permission',
60
+ permissions: [
61
+ TRANSLATION_PERMISSIONS.READ
62
+ ]
63
+ },
64
+ update: {
65
+ level: 'permission',
66
+ permissions: [
67
+ TRANSLATION_PERMISSIONS.UPDATE
68
+ ]
69
+ },
70
+ updateMany: {
71
+ level: 'permission',
72
+ permissions: [
73
+ TRANSLATION_PERMISSIONS.UPDATE
74
+ ]
75
+ },
76
+ delete: {
77
+ level: 'permission',
78
+ permissions: [
79
+ TRANSLATION_PERMISSIONS.DELETE
80
+ ]
81
+ }
82
+ }
83
+ }) {
84
+ async getByLanguage(body) {
85
+ const data = await this.service.getByLanguageCode(body.languageCode, body.modules);
86
+ return {
87
+ success: true,
88
+ message: 'Translations retrieved successfully',
89
+ messageKey: TRANSLATION_MESSAGES.BY_LANGUAGE_SUCCESS,
90
+ data
91
+ };
92
+ }
93
+ async getByModule(body) {
94
+ const data = await this.service.getByModuleAndLanguage(body.module, body.languageCode);
95
+ return {
96
+ success: true,
97
+ message: 'Translations by module retrieved successfully',
98
+ messageKey: TRANSLATION_MESSAGES.BY_MODULE_SUCCESS,
99
+ data
100
+ };
101
+ }
102
+ async updateManyValues(body, _user) {
103
+ const data = await this.service.bulkUpdate(body.translations);
104
+ return {
105
+ success: true,
106
+ message: `${data.length} translations updated`,
107
+ messageKey: TRANSLATION_MESSAGES.UPDATE_MANY_SUCCESS,
108
+ messageVariables: {
109
+ count: data.length
110
+ },
111
+ data,
112
+ meta: {
113
+ count: data.length
114
+ }
115
+ };
116
+ }
117
+ async getMissing(body, _user) {
118
+ const data = await this.service.getMissingTranslations(body.languageCode);
119
+ return {
120
+ success: true,
121
+ message: 'Missing translations retrieved successfully',
122
+ messageKey: TRANSLATION_MESSAGES.MISSING_SUCCESS,
123
+ data,
124
+ meta: {
125
+ total: data.length,
126
+ page: 0,
127
+ pageSize: data.length,
128
+ count: data.length
129
+ }
130
+ };
131
+ }
132
+ async getCounts(_user) {
133
+ const data = await this.service.getTranslationCounts();
134
+ return {
135
+ success: true,
136
+ message: 'Translation counts retrieved successfully',
137
+ messageKey: TRANSLATION_MESSAGES.GET_ALL_SUCCESS,
138
+ data
139
+ };
140
+ }
141
+ constructor(service){
142
+ super(service), _define_property(this, "service", void 0), this.service = service;
143
+ }
144
+ }
145
+ _ts_decorate([
146
+ Post('get-by-language'),
147
+ ApiOperation({
148
+ summary: 'Get translations for a language (optionally filtered by modules)'
149
+ }),
150
+ ApiResponse({
151
+ status: 200
152
+ }),
153
+ _ts_param(0, Body()),
154
+ _ts_metadata("design:type", Function),
155
+ _ts_metadata("design:paramtypes", [
156
+ typeof GetTranslationsByLanguageDto === "undefined" ? Object : GetTranslationsByLanguageDto
157
+ ]),
158
+ _ts_metadata("design:returntype", Promise)
159
+ ], TranslationController.prototype, "getByLanguage", null);
160
+ _ts_decorate([
161
+ Post('get-by-module'),
162
+ ApiOperation({
163
+ summary: 'Get translations by module and language'
164
+ }),
165
+ ApiResponse({
166
+ status: 200
167
+ }),
168
+ _ts_param(0, Body()),
169
+ _ts_metadata("design:type", Function),
170
+ _ts_metadata("design:paramtypes", [
171
+ typeof GetTranslationsByModuleDto === "undefined" ? Object : GetTranslationsByModuleDto
172
+ ]),
173
+ _ts_metadata("design:returntype", Promise)
174
+ ], TranslationController.prototype, "getByModule", null);
175
+ _ts_decorate([
176
+ Post('update-many-values'),
177
+ UseGuards(JwtAuthGuard),
178
+ ApiBearerAuth(),
179
+ RequirePermission(TRANSLATION_PERMISSIONS.UPDATE),
180
+ ApiOperation({
181
+ summary: 'Bulk update translation values'
182
+ }),
183
+ ApiResponse({
184
+ status: 200,
185
+ type: [
186
+ TranslationResponseDto
187
+ ]
188
+ }),
189
+ _ts_param(0, Body()),
190
+ _ts_param(1, CurrentUser()),
191
+ _ts_metadata("design:type", Function),
192
+ _ts_metadata("design:paramtypes", [
193
+ typeof BulkUpdateTranslationsDto === "undefined" ? Object : BulkUpdateTranslationsDto,
194
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
195
+ ]),
196
+ _ts_metadata("design:returntype", Promise)
197
+ ], TranslationController.prototype, "updateManyValues", null);
198
+ _ts_decorate([
199
+ Post('get-missing'),
200
+ UseGuards(JwtAuthGuard),
201
+ ApiBearerAuth(),
202
+ RequirePermission(TRANSLATION_PERMISSIONS.READ),
203
+ ApiOperation({
204
+ summary: 'Get translation keys missing translations for a language'
205
+ }),
206
+ ApiResponse({
207
+ status: 200
208
+ }),
209
+ _ts_param(0, Body()),
210
+ _ts_param(1, CurrentUser()),
211
+ _ts_metadata("design:type", Function),
212
+ _ts_metadata("design:paramtypes", [
213
+ typeof GetTranslationsByLanguageDto === "undefined" ? Object : GetTranslationsByLanguageDto,
214
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
215
+ ]),
216
+ _ts_metadata("design:returntype", Promise)
217
+ ], TranslationController.prototype, "getMissing", null);
218
+ _ts_decorate([
219
+ Post('get-counts'),
220
+ UseGuards(JwtAuthGuard),
221
+ ApiBearerAuth(),
222
+ RequirePermission(TRANSLATION_PERMISSIONS.READ),
223
+ ApiOperation({
224
+ summary: 'Get translation counts per translation key'
225
+ }),
226
+ ApiResponse({
227
+ status: 200
228
+ }),
229
+ _ts_param(0, CurrentUser()),
230
+ _ts_metadata("design:type", Function),
231
+ _ts_metadata("design:paramtypes", [
232
+ typeof ILoggedUserInfo === "undefined" ? Object : ILoggedUserInfo
233
+ ]),
234
+ _ts_metadata("design:returntype", Promise)
235
+ ], TranslationController.prototype, "getCounts", null);
236
+ TranslationController = _ts_decorate([
237
+ ApiTags('Localization - Translation'),
238
+ Controller('localization/translation'),
239
+ _ts_param(0, Inject(TranslationService)),
240
+ _ts_metadata("design:type", Function),
241
+ _ts_metadata("design:paramtypes", [
242
+ typeof TranslationService === "undefined" ? Object : TranslationService
243
+ ])
244
+ ], TranslationController);
@@ -0,0 +1,3 @@
1
+ export * from './language.dto';
2
+ export * from './translation-key.dto';
3
+ export * from './translation.dto';
@@ -0,0 +1,184 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ function _ts_metadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+ import { IdentityResponseDto } from '@flusys/nestjs-shared/dtos';
24
+ import { ApiProperty, ApiPropertyOptional, PartialType } from '@nestjs/swagger';
25
+ import { Exclude, Expose, Transform } from 'class-transformer';
26
+ import { IsBoolean, IsIn, IsNumber, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
27
+ export class CreateLanguageDto {
28
+ constructor(){
29
+ _define_property(this, "code", void 0);
30
+ _define_property(this, "name", void 0);
31
+ _define_property(this, "nativeName", void 0);
32
+ _define_property(this, "direction", void 0);
33
+ _define_property(this, "isActive", void 0);
34
+ _define_property(this, "isDefault", void 0);
35
+ _define_property(this, "serial", void 0);
36
+ }
37
+ }
38
+ _ts_decorate([
39
+ IsString(),
40
+ MaxLength(10),
41
+ Transform(({ value })=>value?.trim()?.toLowerCase()),
42
+ ApiProperty({
43
+ example: 'en',
44
+ description: 'Language code (ISO 639-1)'
45
+ }),
46
+ _ts_metadata("design:type", String)
47
+ ], CreateLanguageDto.prototype, "code", void 0);
48
+ _ts_decorate([
49
+ IsString(),
50
+ MaxLength(100),
51
+ Transform(({ value })=>value?.trim()),
52
+ ApiProperty({
53
+ example: 'English',
54
+ description: 'Language name'
55
+ }),
56
+ _ts_metadata("design:type", String)
57
+ ], CreateLanguageDto.prototype, "name", void 0);
58
+ _ts_decorate([
59
+ IsOptional(),
60
+ IsString(),
61
+ MaxLength(100),
62
+ Transform(({ value })=>value?.trim()),
63
+ ApiPropertyOptional({
64
+ example: 'English',
65
+ description: 'Native name of the language'
66
+ }),
67
+ _ts_metadata("design:type", String)
68
+ ], CreateLanguageDto.prototype, "nativeName", void 0);
69
+ _ts_decorate([
70
+ IsOptional(),
71
+ IsIn([
72
+ 'ltr',
73
+ 'rtl'
74
+ ]),
75
+ ApiPropertyOptional({
76
+ example: 'ltr',
77
+ enum: [
78
+ 'ltr',
79
+ 'rtl'
80
+ ],
81
+ description: 'Text direction'
82
+ }),
83
+ _ts_metadata("design:type", String)
84
+ ], CreateLanguageDto.prototype, "direction", void 0);
85
+ _ts_decorate([
86
+ IsOptional(),
87
+ IsBoolean(),
88
+ ApiPropertyOptional({
89
+ example: true,
90
+ description: 'Whether the language is active'
91
+ }),
92
+ _ts_metadata("design:type", Boolean)
93
+ ], CreateLanguageDto.prototype, "isActive", void 0);
94
+ _ts_decorate([
95
+ IsOptional(),
96
+ IsBoolean(),
97
+ ApiPropertyOptional({
98
+ example: false,
99
+ description: 'Whether this is the default language'
100
+ }),
101
+ _ts_metadata("design:type", Boolean)
102
+ ], CreateLanguageDto.prototype, "isDefault", void 0);
103
+ _ts_decorate([
104
+ IsOptional(),
105
+ IsNumber(),
106
+ ApiPropertyOptional({
107
+ example: 1,
108
+ description: 'Display order'
109
+ }),
110
+ _ts_metadata("design:type", Number)
111
+ ], CreateLanguageDto.prototype, "serial", void 0);
112
+ export class UpdateLanguageDto extends PartialType(CreateLanguageDto) {
113
+ constructor(...args){
114
+ super(...args), _define_property(this, "id", void 0);
115
+ }
116
+ }
117
+ _ts_decorate([
118
+ IsUUID(),
119
+ ApiProperty({
120
+ description: 'Language ID'
121
+ }),
122
+ _ts_metadata("design:type", String)
123
+ ], UpdateLanguageDto.prototype, "id", void 0);
124
+ export class LanguageResponseDto extends IdentityResponseDto {
125
+ constructor(...args){
126
+ super(...args), _define_property(this, "code", void 0), _define_property(this, "name", void 0), _define_property(this, "nativeName", void 0), _define_property(this, "direction", void 0), _define_property(this, "isActive", void 0), _define_property(this, "isDefault", void 0), _define_property(this, "serial", void 0);
127
+ }
128
+ }
129
+ _ts_decorate([
130
+ ApiProperty({
131
+ example: 'en'
132
+ }),
133
+ Expose(),
134
+ _ts_metadata("design:type", String)
135
+ ], LanguageResponseDto.prototype, "code", void 0);
136
+ _ts_decorate([
137
+ ApiProperty({
138
+ example: 'English'
139
+ }),
140
+ Expose(),
141
+ _ts_metadata("design:type", String)
142
+ ], LanguageResponseDto.prototype, "name", void 0);
143
+ _ts_decorate([
144
+ ApiPropertyOptional({
145
+ example: 'English'
146
+ }),
147
+ Expose(),
148
+ _ts_metadata("design:type", Object)
149
+ ], LanguageResponseDto.prototype, "nativeName", void 0);
150
+ _ts_decorate([
151
+ ApiPropertyOptional({
152
+ example: 'ltr',
153
+ enum: [
154
+ 'ltr',
155
+ 'rtl'
156
+ ]
157
+ }),
158
+ Expose(),
159
+ _ts_metadata("design:type", Object)
160
+ ], LanguageResponseDto.prototype, "direction", void 0);
161
+ _ts_decorate([
162
+ ApiProperty({
163
+ example: true
164
+ }),
165
+ Expose(),
166
+ _ts_metadata("design:type", Boolean)
167
+ ], LanguageResponseDto.prototype, "isActive", void 0);
168
+ _ts_decorate([
169
+ ApiProperty({
170
+ example: false
171
+ }),
172
+ Expose(),
173
+ _ts_metadata("design:type", Boolean)
174
+ ], LanguageResponseDto.prototype, "isDefault", void 0);
175
+ _ts_decorate([
176
+ ApiPropertyOptional({
177
+ example: 1
178
+ }),
179
+ Expose(),
180
+ _ts_metadata("design:type", Object)
181
+ ], LanguageResponseDto.prototype, "serial", void 0);
182
+ LanguageResponseDto = _ts_decorate([
183
+ Exclude()
184
+ ], LanguageResponseDto);
@@ -0,0 +1,209 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
14
+ function _ts_decorate(decorators, target, key, desc) {
15
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
16
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
17
+ 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;
18
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
19
+ }
20
+ function _ts_metadata(k, v) {
21
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
22
+ }
23
+ import { IdentityResponseDto } from '@flusys/nestjs-shared/dtos';
24
+ import { ApiProperty, ApiPropertyOptional, OmitType, PartialType } from '@nestjs/swagger';
25
+ import { Exclude, Expose, Transform } from 'class-transformer';
26
+ import { IsArray, IsBoolean, IsNumber, IsOptional, IsString, IsUUID, MaxLength } from 'class-validator';
27
+ export class CreateTranslationKeyDto {
28
+ constructor(){
29
+ _define_property(this, "module", void 0);
30
+ _define_property(this, "key", void 0);
31
+ _define_property(this, "defaultMessage", void 0);
32
+ _define_property(this, "description", void 0);
33
+ _define_property(this, "variables", void 0);
34
+ _define_property(this, "isActive", void 0);
35
+ _define_property(this, "isReadonly", void 0);
36
+ _define_property(this, "serial", void 0);
37
+ }
38
+ }
39
+ _ts_decorate([
40
+ IsString(),
41
+ MaxLength(100),
42
+ Transform(({ value })=>value?.trim()?.toLowerCase()),
43
+ ApiProperty({
44
+ example: 'auth',
45
+ description: 'Module name'
46
+ }),
47
+ _ts_metadata("design:type", String)
48
+ ], CreateTranslationKeyDto.prototype, "module", void 0);
49
+ _ts_decorate([
50
+ IsString(),
51
+ MaxLength(255),
52
+ Transform(({ value })=>value?.trim()),
53
+ ApiProperty({
54
+ example: 'auth.login.success',
55
+ description: 'Translation key'
56
+ }),
57
+ _ts_metadata("design:type", String)
58
+ ], CreateTranslationKeyDto.prototype, "key", void 0);
59
+ _ts_decorate([
60
+ IsString(),
61
+ MaxLength(500),
62
+ Transform(({ value })=>value?.trim()),
63
+ ApiProperty({
64
+ example: 'Login successful',
65
+ description: 'Default English message'
66
+ }),
67
+ _ts_metadata("design:type", String)
68
+ ], CreateTranslationKeyDto.prototype, "defaultMessage", void 0);
69
+ _ts_decorate([
70
+ IsOptional(),
71
+ IsString(),
72
+ Transform(({ value })=>value?.trim()),
73
+ ApiPropertyOptional({
74
+ description: 'Developer notes'
75
+ }),
76
+ _ts_metadata("design:type", String)
77
+ ], CreateTranslationKeyDto.prototype, "description", void 0);
78
+ _ts_decorate([
79
+ IsOptional(),
80
+ IsArray(),
81
+ IsString({
82
+ each: true
83
+ }),
84
+ ApiPropertyOptional({
85
+ example: [
86
+ 'name'
87
+ ],
88
+ description: 'Variable names used in the message'
89
+ }),
90
+ _ts_metadata("design:type", Array)
91
+ ], CreateTranslationKeyDto.prototype, "variables", void 0);
92
+ _ts_decorate([
93
+ IsOptional(),
94
+ IsBoolean(),
95
+ ApiPropertyOptional({
96
+ example: true
97
+ }),
98
+ _ts_metadata("design:type", Boolean)
99
+ ], CreateTranslationKeyDto.prototype, "isActive", void 0);
100
+ _ts_decorate([
101
+ IsOptional(),
102
+ IsBoolean(),
103
+ ApiPropertyOptional({
104
+ example: false,
105
+ description: 'Readonly keys cannot be deleted by users'
106
+ }),
107
+ _ts_metadata("design:type", Boolean)
108
+ ], CreateTranslationKeyDto.prototype, "isReadonly", void 0);
109
+ _ts_decorate([
110
+ IsOptional(),
111
+ IsNumber(),
112
+ ApiPropertyOptional({
113
+ example: 1
114
+ }),
115
+ _ts_metadata("design:type", Number)
116
+ ], CreateTranslationKeyDto.prototype, "serial", void 0);
117
+ export class UpdateTranslationKeyDto extends PartialType(OmitType(CreateTranslationKeyDto, [
118
+ 'isReadonly'
119
+ ])) {
120
+ constructor(...args){
121
+ super(...args), _define_property(this, "id", void 0);
122
+ }
123
+ }
124
+ _ts_decorate([
125
+ IsUUID(),
126
+ ApiProperty({
127
+ description: 'Translation key ID'
128
+ }),
129
+ _ts_metadata("design:type", String)
130
+ ], UpdateTranslationKeyDto.prototype, "id", void 0);
131
+ export class TranslationKeyResponseDto extends IdentityResponseDto {
132
+ constructor(...args){
133
+ super(...args), _define_property(this, "module", void 0), _define_property(this, "key", void 0), _define_property(this, "defaultMessage", void 0), _define_property(this, "description", void 0), _define_property(this, "variables", void 0), _define_property(this, "isActive", void 0), _define_property(this, "isReadonly", void 0), _define_property(this, "serial", void 0);
134
+ }
135
+ }
136
+ _ts_decorate([
137
+ ApiProperty({
138
+ example: 'auth'
139
+ }),
140
+ Expose(),
141
+ _ts_metadata("design:type", String)
142
+ ], TranslationKeyResponseDto.prototype, "module", void 0);
143
+ _ts_decorate([
144
+ ApiProperty({
145
+ example: 'auth.login.success'
146
+ }),
147
+ Expose(),
148
+ _ts_metadata("design:type", String)
149
+ ], TranslationKeyResponseDto.prototype, "key", void 0);
150
+ _ts_decorate([
151
+ ApiProperty({
152
+ example: 'Login successful'
153
+ }),
154
+ Expose(),
155
+ _ts_metadata("design:type", String)
156
+ ], TranslationKeyResponseDto.prototype, "defaultMessage", void 0);
157
+ _ts_decorate([
158
+ ApiPropertyOptional(),
159
+ Expose(),
160
+ _ts_metadata("design:type", Object)
161
+ ], TranslationKeyResponseDto.prototype, "description", void 0);
162
+ _ts_decorate([
163
+ ApiPropertyOptional({
164
+ example: [
165
+ 'name'
166
+ ]
167
+ }),
168
+ Expose(),
169
+ _ts_metadata("design:type", Object)
170
+ ], TranslationKeyResponseDto.prototype, "variables", void 0);
171
+ _ts_decorate([
172
+ ApiProperty({
173
+ example: true
174
+ }),
175
+ Expose(),
176
+ _ts_metadata("design:type", Boolean)
177
+ ], TranslationKeyResponseDto.prototype, "isActive", void 0);
178
+ _ts_decorate([
179
+ ApiProperty({
180
+ example: false
181
+ }),
182
+ Expose(),
183
+ _ts_metadata("design:type", Boolean)
184
+ ], TranslationKeyResponseDto.prototype, "isReadonly", void 0);
185
+ _ts_decorate([
186
+ ApiPropertyOptional({
187
+ example: 1
188
+ }),
189
+ Expose(),
190
+ _ts_metadata("design:type", Object)
191
+ ], TranslationKeyResponseDto.prototype, "serial", void 0);
192
+ TranslationKeyResponseDto = _ts_decorate([
193
+ Exclude()
194
+ ], TranslationKeyResponseDto);
195
+ export class GetByModuleDto {
196
+ constructor(){
197
+ _define_property(this, "module", void 0);
198
+ }
199
+ }
200
+ _ts_decorate([
201
+ IsString(),
202
+ MaxLength(100),
203
+ Transform(({ value })=>value?.trim()?.toLowerCase()),
204
+ ApiProperty({
205
+ example: 'auth',
206
+ description: 'Module name'
207
+ }),
208
+ _ts_metadata("design:type", String)
209
+ ], GetByModuleDto.prototype, "module", void 0);