@flusys/nestjs-localization 5.1.2 → 5.2.0
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/cjs/services/language.service.js +5 -11
- package/cjs/services/localization-datasource.provider.js +2 -45
- package/cjs/services/translation-key.service.js +7 -13
- package/cjs/services/translation.service.js +5 -11
- package/controllers/language.controller.d.ts +9 -9
- package/controllers/translation-key.controller.d.ts +9 -9
- package/controllers/translation.controller.d.ts +6 -6
- package/fesm/services/language.service.js +6 -12
- package/fesm/services/localization-datasource.provider.js +3 -46
- package/fesm/services/translation-key.service.js +8 -14
- package/fesm/services/translation.service.js +6 -12
- package/package.json +12 -12
- package/services/language.service.d.ts +2 -6
- package/services/localization-datasource.provider.d.ts +2 -2
- package/services/translation-key.service.d.ts +3 -6
- package/services/translation.service.d.ts +3 -5
|
@@ -41,15 +41,9 @@ function _ts_param(paramIndex, decorator) {
|
|
|
41
41
|
decorator(target, key, paramIndex);
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
let LanguageService = class LanguageService extends _classes.
|
|
45
|
-
resolveEntity() {
|
|
46
|
-
return _entities.Language;
|
|
47
|
-
}
|
|
48
|
-
getDataSourceProvider() {
|
|
49
|
-
return this.dataSourceProvider;
|
|
50
|
-
}
|
|
44
|
+
let LanguageService = class LanguageService extends _classes.ApiService {
|
|
51
45
|
async getDefaultLanguage() {
|
|
52
|
-
await this.
|
|
46
|
+
await this.ensureDataSourceRepository();
|
|
53
47
|
return this.repository.findOne({
|
|
54
48
|
where: {
|
|
55
49
|
isDefault: true,
|
|
@@ -58,7 +52,7 @@ let LanguageService = class LanguageService extends _classes.RequestScopedApiSer
|
|
|
58
52
|
});
|
|
59
53
|
}
|
|
60
54
|
async getActiveLanguages() {
|
|
61
|
-
await this.
|
|
55
|
+
await this.ensureDataSourceRepository();
|
|
62
56
|
return this.repository.find({
|
|
63
57
|
where: {
|
|
64
58
|
isActive: true,
|
|
@@ -71,7 +65,7 @@ let LanguageService = class LanguageService extends _classes.RequestScopedApiSer
|
|
|
71
65
|
});
|
|
72
66
|
}
|
|
73
67
|
async setAsDefault(id) {
|
|
74
|
-
await this.
|
|
68
|
+
await this.ensureDataSourceRepository();
|
|
75
69
|
await this.repository.update({
|
|
76
70
|
isDefault: true
|
|
77
71
|
}, {
|
|
@@ -89,7 +83,7 @@ let LanguageService = class LanguageService extends _classes.RequestScopedApiSer
|
|
|
89
83
|
});
|
|
90
84
|
}
|
|
91
85
|
constructor(cacheManager, utilsService, dataSourceProvider){
|
|
92
|
-
super('language',
|
|
86
|
+
super('language', cacheManager, utilsService, LanguageService.name, true, 'localization', _entities.Language, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService;
|
|
93
87
|
}
|
|
94
88
|
};
|
|
95
89
|
LanguageService = _ts_decorate([
|
|
@@ -9,7 +9,6 @@ Object.defineProperty(exports, "LocalizationDataSourceProvider", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
const _modules = require("@flusys/nestjs-shared/modules");
|
|
12
|
-
const _constants = require("@flusys/nestjs-shared/constants");
|
|
13
12
|
const _common = require("@nestjs/common");
|
|
14
13
|
const _core = require("@nestjs/core");
|
|
15
14
|
const _express = require("express");
|
|
@@ -55,56 +54,14 @@ let LocalizationDataSourceProvider = class LocalizationDataSourceProvider extend
|
|
|
55
54
|
const entities = (0, _entities.getLocalizationEntities)();
|
|
56
55
|
return super.createDataSourceFromConfig(config, entities);
|
|
57
56
|
}
|
|
58
|
-
async getSingleDataSource() {
|
|
59
|
-
if (LocalizationDataSourceProvider.singleDataSource?.isInitialized) {
|
|
60
|
-
return LocalizationDataSourceProvider.singleDataSource;
|
|
61
|
-
}
|
|
62
|
-
if (LocalizationDataSourceProvider.singleConnectionLock) {
|
|
63
|
-
return LocalizationDataSourceProvider.singleConnectionLock;
|
|
64
|
-
}
|
|
65
|
-
const config = this.getDefaultDatabaseConfig();
|
|
66
|
-
if (!config) {
|
|
67
|
-
throw new _common.InternalServerErrorException({
|
|
68
|
-
message: 'No database config available. Provide defaultDatabaseConfig or tenantDefaultDatabaseConfig.',
|
|
69
|
-
messageKey: _constants.SYSTEM_MESSAGES.DATABASE_CONFIG_NOT_AVAILABLE
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
const connectionPromise = this.createDataSourceFromConfig(config);
|
|
73
|
-
LocalizationDataSourceProvider.singleConnectionLock = connectionPromise;
|
|
74
|
-
try {
|
|
75
|
-
const dataSource = await connectionPromise;
|
|
76
|
-
LocalizationDataSourceProvider.singleDataSource = dataSource;
|
|
77
|
-
return dataSource;
|
|
78
|
-
} finally{
|
|
79
|
-
LocalizationDataSourceProvider.singleConnectionLock = null;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
async getOrCreateTenantConnection(tenant) {
|
|
83
|
-
const existing = LocalizationDataSourceProvider.tenantConnections.get(tenant.id);
|
|
84
|
-
if (existing?.isInitialized) {
|
|
85
|
-
return existing;
|
|
86
|
-
}
|
|
87
|
-
const pendingConnection = LocalizationDataSourceProvider.connectionLocks.get(tenant.id);
|
|
88
|
-
if (pendingConnection) {
|
|
89
|
-
return pendingConnection;
|
|
90
|
-
}
|
|
91
|
-
const config = this.buildTenantDatabaseConfig(tenant);
|
|
92
|
-
const connectionPromise = this.createDataSourceFromConfig(config);
|
|
93
|
-
LocalizationDataSourceProvider.connectionLocks.set(tenant.id, connectionPromise);
|
|
94
|
-
try {
|
|
95
|
-
const dataSource = await connectionPromise;
|
|
96
|
-
LocalizationDataSourceProvider.tenantConnections.set(tenant.id, dataSource);
|
|
97
|
-
return dataSource;
|
|
98
|
-
} finally{
|
|
99
|
-
LocalizationDataSourceProvider.connectionLocks.delete(tenant.id);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
57
|
constructor(configService, request){
|
|
103
58
|
super(LocalizationDataSourceProvider.buildParentOptions(configService.getOptions()), request);
|
|
104
59
|
}
|
|
105
60
|
};
|
|
106
61
|
_define_property(LocalizationDataSourceProvider, "tenantConnections", new Map());
|
|
107
62
|
_define_property(LocalizationDataSourceProvider, "singleDataSource", null);
|
|
63
|
+
_define_property(LocalizationDataSourceProvider, "tenantsRegistry", new Map());
|
|
64
|
+
_define_property(LocalizationDataSourceProvider, "initialized", false);
|
|
108
65
|
_define_property(LocalizationDataSourceProvider, "connectionLocks", new Map());
|
|
109
66
|
_define_property(LocalizationDataSourceProvider, "singleConnectionLock", null);
|
|
110
67
|
LocalizationDataSourceProvider = _ts_decorate([
|
|
@@ -42,13 +42,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
42
42
|
decorator(target, key, paramIndex);
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
|
-
let TranslationKeyService = class TranslationKeyService extends _classes.
|
|
46
|
-
resolveEntity() {
|
|
47
|
-
return _entities.TranslationKey;
|
|
48
|
-
}
|
|
49
|
-
getDataSourceProvider() {
|
|
50
|
-
return this.dataSourceProvider;
|
|
51
|
-
}
|
|
45
|
+
let TranslationKeyService = class TranslationKeyService extends _classes.ApiService {
|
|
52
46
|
async beforeInsertOperation(dto, _user, _queryRunner) {
|
|
53
47
|
const dtos = Array.isArray(dto) ? dto : [
|
|
54
48
|
dto
|
|
@@ -63,7 +57,7 @@ let TranslationKeyService = class TranslationKeyService extends _classes.Request
|
|
|
63
57
|
dto
|
|
64
58
|
];
|
|
65
59
|
const ids = dtos.map((d)=>d.id);
|
|
66
|
-
await this.
|
|
60
|
+
await this.ensureDataSourceRepository();
|
|
67
61
|
const existingKeys = await this.repository.find({
|
|
68
62
|
where: {
|
|
69
63
|
id: (0, _typeorm.In)(ids),
|
|
@@ -100,7 +94,7 @@ let TranslationKeyService = class TranslationKeyService extends _classes.Request
|
|
|
100
94
|
const ids = Array.isArray(option.id) ? option.id : [
|
|
101
95
|
option.id
|
|
102
96
|
];
|
|
103
|
-
await this.
|
|
97
|
+
await this.ensureDataSourceRepository();
|
|
104
98
|
const readonlyKeys = await this.repository.find({
|
|
105
99
|
where: {
|
|
106
100
|
id: (0, _typeorm.In)(ids),
|
|
@@ -120,7 +114,7 @@ let TranslationKeyService = class TranslationKeyService extends _classes.Request
|
|
|
120
114
|
}
|
|
121
115
|
}
|
|
122
116
|
async findByModule(module) {
|
|
123
|
-
await this.
|
|
117
|
+
await this.ensureDataSourceRepository();
|
|
124
118
|
return this.repository.find({
|
|
125
119
|
where: {
|
|
126
120
|
module,
|
|
@@ -134,12 +128,12 @@ let TranslationKeyService = class TranslationKeyService extends _classes.Request
|
|
|
134
128
|
});
|
|
135
129
|
}
|
|
136
130
|
async getModules() {
|
|
137
|
-
await this.
|
|
131
|
+
await this.ensureDataSourceRepository();
|
|
138
132
|
const result = await this.repository.createQueryBuilder('tk').select('DISTINCT tk.module', 'module').where('tk.deleted_at IS NULL').getRawMany();
|
|
139
133
|
return result.map((r)=>r.module);
|
|
140
134
|
}
|
|
141
135
|
async validateNoDuplicateKeys(keys) {
|
|
142
|
-
await this.
|
|
136
|
+
await this.ensureDataSourceRepository();
|
|
143
137
|
for (const { module, key, excludeId } of keys){
|
|
144
138
|
const query = this.repository.createQueryBuilder('tk').where('tk.module = :module', {
|
|
145
139
|
module
|
|
@@ -165,7 +159,7 @@ let TranslationKeyService = class TranslationKeyService extends _classes.Request
|
|
|
165
159
|
}
|
|
166
160
|
}
|
|
167
161
|
constructor(cacheManager, utilsService, dataSourceProvider){
|
|
168
|
-
super('translationKey',
|
|
162
|
+
super('translationKey', cacheManager, utilsService, TranslationKeyService.name, true, 'localization', _entities.TranslationKey, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService;
|
|
169
163
|
}
|
|
170
164
|
};
|
|
171
165
|
TranslationKeyService = _ts_decorate([
|
|
@@ -41,13 +41,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
41
41
|
decorator(target, key, paramIndex);
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
|
-
let TranslationService = class TranslationService extends _classes.
|
|
45
|
-
resolveEntity() {
|
|
46
|
-
return _entities.Translation;
|
|
47
|
-
}
|
|
48
|
-
getDataSourceProvider() {
|
|
49
|
-
return this.dataSourceProvider;
|
|
50
|
-
}
|
|
44
|
+
let TranslationService = class TranslationService extends _classes.ApiService {
|
|
51
45
|
async getFilterQuery(query, filter, _user) {
|
|
52
46
|
// Handle module filter by joining to translation_key table
|
|
53
47
|
if (filter.module) {
|
|
@@ -73,7 +67,7 @@ let TranslationService = class TranslationService extends _classes.RequestScoped
|
|
|
73
67
|
};
|
|
74
68
|
}
|
|
75
69
|
async ensureAllReposInitialized() {
|
|
76
|
-
await this.
|
|
70
|
+
await this.ensureDataSourceRepository();
|
|
77
71
|
if (!this.languageRepo) {
|
|
78
72
|
const ds = await this.dataSourceProvider.getDataSource();
|
|
79
73
|
this.languageRepo = ds.getRepository(_entities.Language);
|
|
@@ -106,7 +100,7 @@ let TranslationService = class TranslationService extends _classes.RequestScoped
|
|
|
106
100
|
return this.toTranslationsMap(translations);
|
|
107
101
|
}
|
|
108
102
|
async bulkUpdate(updates) {
|
|
109
|
-
await this.
|
|
103
|
+
await this.ensureDataSourceRepository();
|
|
110
104
|
if (updates.length === 0) return [];
|
|
111
105
|
const ds = await this.dataSourceProvider.getDataSource();
|
|
112
106
|
const queryRunner = ds.createQueryRunner();
|
|
@@ -175,7 +169,7 @@ let TranslationService = class TranslationService extends _classes.RequestScoped
|
|
|
175
169
|
return allKeys.filter((k)=>!existingKeyIds.has(k.id));
|
|
176
170
|
}
|
|
177
171
|
async getTranslationCounts() {
|
|
178
|
-
await this.
|
|
172
|
+
await this.ensureDataSourceRepository();
|
|
179
173
|
const counts = await this.repository.createQueryBuilder('t').select('t.translation_key_id', 'keyId').addSelect('COUNT(t.id)', 'count').where('t.is_active = true').andWhere('t.deleted_at IS NULL').groupBy('t.translation_key_id').getRawMany();
|
|
180
174
|
const result = {};
|
|
181
175
|
for (const row of counts){
|
|
@@ -203,7 +197,7 @@ let TranslationService = class TranslationService extends _classes.RequestScoped
|
|
|
203
197
|
return result;
|
|
204
198
|
}
|
|
205
199
|
constructor(cacheManager, utilsService, dataSourceProvider){
|
|
206
|
-
super('translation',
|
|
200
|
+
super('translation', cacheManager, utilsService, TranslationService.name, true, 'localization', _entities.Translation, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "dataSourceProvider", void 0), _define_property(this, "languageRepo", void 0), _define_property(this, "translationKeyRepo", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.dataSourceProvider = dataSourceProvider, this.languageRepo = null, this.translationKeyRepo = null;
|
|
207
201
|
}
|
|
208
202
|
};
|
|
209
203
|
TranslationService = _ts_decorate([
|
|
@@ -4,19 +4,19 @@ import { CreateLanguageDto, LanguageResponseDto, UpdateLanguageDto } from '../dt
|
|
|
4
4
|
import { ILanguage } from '../interfaces';
|
|
5
5
|
import { LanguageService } from '../services';
|
|
6
6
|
declare const LanguageController_base: abstract new (service: LanguageService) => {
|
|
7
|
-
readonly enabledEndpoints: import("@flusys/nestjs-shared
|
|
7
|
+
readonly enabledEndpoints: import("@flusys/nestjs-shared").ApiEndpoint[] | "all";
|
|
8
8
|
service: LanguageService;
|
|
9
|
-
isEnabled(endpoint: import("@flusys/nestjs-shared
|
|
9
|
+
isEnabled(endpoint: import("@flusys/nestjs-shared").ApiEndpoint): boolean;
|
|
10
10
|
insert(addDto: CreateLanguageDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<LanguageResponseDto>>;
|
|
11
|
-
insertMany(addDto: CreateLanguageDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared
|
|
12
|
-
getById(id: string, body: import("@flusys/nestjs-shared
|
|
13
|
-
getByIds(body: import("@flusys/nestjs-shared
|
|
11
|
+
insertMany(addDto: CreateLanguageDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<LanguageResponseDto>>;
|
|
12
|
+
getById(id: string, body: import("@flusys/nestjs-shared").GetByIdBodyDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<LanguageResponseDto>>;
|
|
13
|
+
getByIds(body: import("@flusys/nestjs-shared").GetByIdsDto, user: ILoggedUserInfo | null): Promise<ListResponseDto<LanguageResponseDto>>;
|
|
14
14
|
update(updateDto: UpdateLanguageDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<LanguageResponseDto>>;
|
|
15
|
-
updateMany(updateDtos: UpdateLanguageDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared
|
|
16
|
-
bulkUpsert(dtos: (CreateLanguageDto | UpdateLanguageDto)[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared
|
|
15
|
+
updateMany(updateDtos: UpdateLanguageDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<LanguageResponseDto>>;
|
|
16
|
+
bulkUpsert(dtos: (CreateLanguageDto | UpdateLanguageDto)[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<LanguageResponseDto>>;
|
|
17
17
|
getByFilter(filter: Record<string, any>, user: ILoggedUserInfo | null): Promise<SingleResponseDto<LanguageResponseDto>>;
|
|
18
|
-
getAll(filterAndPaginationDto: import("@flusys/nestjs-shared
|
|
19
|
-
delete(deleteDto: import("@flusys/nestjs-shared
|
|
18
|
+
getAll(filterAndPaginationDto: import("@flusys/nestjs-shared").FilterAndPaginationDto, user: ILoggedUserInfo | null, search?: string): Promise<ListResponseDto<LanguageResponseDto>>;
|
|
19
|
+
delete(deleteDto: import("@flusys/nestjs-shared").DeleteDto, user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").MessageResponseDto>;
|
|
20
20
|
};
|
|
21
21
|
export declare class LanguageController extends LanguageController_base {
|
|
22
22
|
service: LanguageService;
|
|
@@ -3,19 +3,19 @@ import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
|
3
3
|
import { CreateTranslationKeyDto, TranslationKeyResponseDto, UpdateTranslationKeyDto } from '../dtos';
|
|
4
4
|
import { TranslationKeyService } from '../services';
|
|
5
5
|
declare const TranslationKeyController_base: abstract new (service: TranslationKeyService) => {
|
|
6
|
-
readonly enabledEndpoints: import("@flusys/nestjs-shared
|
|
6
|
+
readonly enabledEndpoints: import("@flusys/nestjs-shared").ApiEndpoint[] | "all";
|
|
7
7
|
service: TranslationKeyService;
|
|
8
|
-
isEnabled(endpoint: import("@flusys/nestjs-shared
|
|
8
|
+
isEnabled(endpoint: import("@flusys/nestjs-shared").ApiEndpoint): boolean;
|
|
9
9
|
insert(addDto: CreateTranslationKeyDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<TranslationKeyResponseDto>>;
|
|
10
|
-
insertMany(addDto: CreateTranslationKeyDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared
|
|
11
|
-
getById(id: string, body: import("@flusys/nestjs-shared
|
|
12
|
-
getByIds(body: import("@flusys/nestjs-shared
|
|
10
|
+
insertMany(addDto: CreateTranslationKeyDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<TranslationKeyResponseDto>>;
|
|
11
|
+
getById(id: string, body: import("@flusys/nestjs-shared").GetByIdBodyDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<TranslationKeyResponseDto>>;
|
|
12
|
+
getByIds(body: import("@flusys/nestjs-shared").GetByIdsDto, user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").ListResponseDto<TranslationKeyResponseDto>>;
|
|
13
13
|
update(updateDto: UpdateTranslationKeyDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<TranslationKeyResponseDto>>;
|
|
14
|
-
updateMany(updateDtos: UpdateTranslationKeyDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared
|
|
15
|
-
bulkUpsert(dtos: (CreateTranslationKeyDto | UpdateTranslationKeyDto)[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared
|
|
14
|
+
updateMany(updateDtos: UpdateTranslationKeyDto[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<TranslationKeyResponseDto>>;
|
|
15
|
+
bulkUpsert(dtos: (CreateTranslationKeyDto | UpdateTranslationKeyDto)[], user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").BulkResponseDto<TranslationKeyResponseDto>>;
|
|
16
16
|
getByFilter(filter: Record<string, any>, user: ILoggedUserInfo | null): Promise<SingleResponseDto<TranslationKeyResponseDto>>;
|
|
17
|
-
getAll(filterAndPaginationDto: import("@flusys/nestjs-shared
|
|
18
|
-
delete(deleteDto: import("@flusys/nestjs-shared
|
|
17
|
+
getAll(filterAndPaginationDto: import("@flusys/nestjs-shared").FilterAndPaginationDto, user: ILoggedUserInfo | null, search?: string): Promise<import("@flusys/nestjs-shared").ListResponseDto<TranslationKeyResponseDto>>;
|
|
18
|
+
delete(deleteDto: import("@flusys/nestjs-shared").DeleteDto, user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").MessageResponseDto>;
|
|
19
19
|
};
|
|
20
20
|
export declare class TranslationKeyController extends TranslationKeyController_base {
|
|
21
21
|
service: TranslationKeyService;
|
|
@@ -4,19 +4,19 @@ import { BulkUpdateTranslationsDto, CreateTranslationDto, GetTranslationsByLangu
|
|
|
4
4
|
import { ITranslation, ITranslationsMap } from '../interfaces';
|
|
5
5
|
import { TranslationService } from '../services';
|
|
6
6
|
declare const TranslationController_base: abstract new (service: TranslationService) => {
|
|
7
|
-
readonly enabledEndpoints: import("@flusys/nestjs-shared
|
|
7
|
+
readonly enabledEndpoints: import("@flusys/nestjs-shared").ApiEndpoint[] | "all";
|
|
8
8
|
service: TranslationService;
|
|
9
|
-
isEnabled(endpoint: import("@flusys/nestjs-shared
|
|
9
|
+
isEnabled(endpoint: import("@flusys/nestjs-shared").ApiEndpoint): boolean;
|
|
10
10
|
insert(addDto: CreateTranslationDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<TranslationResponseDto>>;
|
|
11
11
|
insertMany(addDto: CreateTranslationDto[], user: ILoggedUserInfo | null): Promise<BulkResponseDto<TranslationResponseDto>>;
|
|
12
|
-
getById(id: string, body: import("@flusys/nestjs-shared
|
|
13
|
-
getByIds(body: import("@flusys/nestjs-shared
|
|
12
|
+
getById(id: string, body: import("@flusys/nestjs-shared").GetByIdBodyDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<TranslationResponseDto>>;
|
|
13
|
+
getByIds(body: import("@flusys/nestjs-shared").GetByIdsDto, user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").ListResponseDto<TranslationResponseDto>>;
|
|
14
14
|
update(updateDto: UpdateTranslationDto, user: ILoggedUserInfo | null): Promise<SingleResponseDto<TranslationResponseDto>>;
|
|
15
15
|
updateMany(updateDtos: UpdateTranslationDto[], user: ILoggedUserInfo | null): Promise<BulkResponseDto<TranslationResponseDto>>;
|
|
16
16
|
bulkUpsert(dtos: (CreateTranslationDto | UpdateTranslationDto)[], user: ILoggedUserInfo | null): Promise<BulkResponseDto<TranslationResponseDto>>;
|
|
17
17
|
getByFilter(filter: Record<string, any>, user: ILoggedUserInfo | null): Promise<SingleResponseDto<TranslationResponseDto>>;
|
|
18
|
-
getAll(filterAndPaginationDto: import("@flusys/nestjs-shared
|
|
19
|
-
delete(deleteDto: import("@flusys/nestjs-shared
|
|
18
|
+
getAll(filterAndPaginationDto: import("@flusys/nestjs-shared").FilterAndPaginationDto, user: ILoggedUserInfo | null, search?: string): Promise<import("@flusys/nestjs-shared").ListResponseDto<TranslationResponseDto>>;
|
|
19
|
+
delete(deleteDto: import("@flusys/nestjs-shared").DeleteDto, user: ILoggedUserInfo | null): Promise<import("@flusys/nestjs-shared").MessageResponseDto>;
|
|
20
20
|
};
|
|
21
21
|
export declare class TranslationController extends TranslationController_base {
|
|
22
22
|
service: TranslationService;
|
|
@@ -25,21 +25,15 @@ function _ts_param(paramIndex, decorator) {
|
|
|
25
25
|
decorator(target, key, paramIndex);
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
import { HybridCache,
|
|
28
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
29
29
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
30
30
|
import { Inject, Injectable, Scope } from '@nestjs/common';
|
|
31
31
|
import { IsNull } from 'typeorm';
|
|
32
32
|
import { Language } from '../entities';
|
|
33
33
|
import { LocalizationDataSourceProvider } from './localization-datasource.provider';
|
|
34
|
-
export class LanguageService extends
|
|
35
|
-
resolveEntity() {
|
|
36
|
-
return Language;
|
|
37
|
-
}
|
|
38
|
-
getDataSourceProvider() {
|
|
39
|
-
return this.dataSourceProvider;
|
|
40
|
-
}
|
|
34
|
+
export class LanguageService extends ApiService {
|
|
41
35
|
async getDefaultLanguage() {
|
|
42
|
-
await this.
|
|
36
|
+
await this.ensureDataSourceRepository();
|
|
43
37
|
return this.repository.findOne({
|
|
44
38
|
where: {
|
|
45
39
|
isDefault: true,
|
|
@@ -48,7 +42,7 @@ export class LanguageService extends RequestScopedApiService {
|
|
|
48
42
|
});
|
|
49
43
|
}
|
|
50
44
|
async getActiveLanguages() {
|
|
51
|
-
await this.
|
|
45
|
+
await this.ensureDataSourceRepository();
|
|
52
46
|
return this.repository.find({
|
|
53
47
|
where: {
|
|
54
48
|
isActive: true,
|
|
@@ -61,7 +55,7 @@ export class LanguageService extends RequestScopedApiService {
|
|
|
61
55
|
});
|
|
62
56
|
}
|
|
63
57
|
async setAsDefault(id) {
|
|
64
|
-
await this.
|
|
58
|
+
await this.ensureDataSourceRepository();
|
|
65
59
|
await this.repository.update({
|
|
66
60
|
isDefault: true
|
|
67
61
|
}, {
|
|
@@ -79,7 +73,7 @@ export class LanguageService extends RequestScopedApiService {
|
|
|
79
73
|
});
|
|
80
74
|
}
|
|
81
75
|
constructor(cacheManager, utilsService, dataSourceProvider){
|
|
82
|
-
super('language',
|
|
76
|
+
super('language', cacheManager, utilsService, LanguageService.name, true, 'localization', Language, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService;
|
|
83
77
|
}
|
|
84
78
|
}
|
|
85
79
|
LanguageService = _ts_decorate([
|
|
@@ -26,8 +26,7 @@ function _ts_param(paramIndex, decorator) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
import { MultiTenantDataSourceService } from '@flusys/nestjs-shared/modules';
|
|
29
|
-
import {
|
|
30
|
-
import { Inject, Injectable, InternalServerErrorException, Optional, Scope } from '@nestjs/common';
|
|
29
|
+
import { Inject, Injectable, Optional, Scope } from '@nestjs/common';
|
|
31
30
|
import { REQUEST } from '@nestjs/core';
|
|
32
31
|
import { Request } from 'express';
|
|
33
32
|
import { getLocalizationEntities } from '../entities';
|
|
@@ -45,56 +44,14 @@ export class LocalizationDataSourceProvider extends MultiTenantDataSourceService
|
|
|
45
44
|
const entities = getLocalizationEntities();
|
|
46
45
|
return super.createDataSourceFromConfig(config, entities);
|
|
47
46
|
}
|
|
48
|
-
async getSingleDataSource() {
|
|
49
|
-
if (LocalizationDataSourceProvider.singleDataSource?.isInitialized) {
|
|
50
|
-
return LocalizationDataSourceProvider.singleDataSource;
|
|
51
|
-
}
|
|
52
|
-
if (LocalizationDataSourceProvider.singleConnectionLock) {
|
|
53
|
-
return LocalizationDataSourceProvider.singleConnectionLock;
|
|
54
|
-
}
|
|
55
|
-
const config = this.getDefaultDatabaseConfig();
|
|
56
|
-
if (!config) {
|
|
57
|
-
throw new InternalServerErrorException({
|
|
58
|
-
message: 'No database config available. Provide defaultDatabaseConfig or tenantDefaultDatabaseConfig.',
|
|
59
|
-
messageKey: SYSTEM_MESSAGES.DATABASE_CONFIG_NOT_AVAILABLE
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
const connectionPromise = this.createDataSourceFromConfig(config);
|
|
63
|
-
LocalizationDataSourceProvider.singleConnectionLock = connectionPromise;
|
|
64
|
-
try {
|
|
65
|
-
const dataSource = await connectionPromise;
|
|
66
|
-
LocalizationDataSourceProvider.singleDataSource = dataSource;
|
|
67
|
-
return dataSource;
|
|
68
|
-
} finally{
|
|
69
|
-
LocalizationDataSourceProvider.singleConnectionLock = null;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
async getOrCreateTenantConnection(tenant) {
|
|
73
|
-
const existing = LocalizationDataSourceProvider.tenantConnections.get(tenant.id);
|
|
74
|
-
if (existing?.isInitialized) {
|
|
75
|
-
return existing;
|
|
76
|
-
}
|
|
77
|
-
const pendingConnection = LocalizationDataSourceProvider.connectionLocks.get(tenant.id);
|
|
78
|
-
if (pendingConnection) {
|
|
79
|
-
return pendingConnection;
|
|
80
|
-
}
|
|
81
|
-
const config = this.buildTenantDatabaseConfig(tenant);
|
|
82
|
-
const connectionPromise = this.createDataSourceFromConfig(config);
|
|
83
|
-
LocalizationDataSourceProvider.connectionLocks.set(tenant.id, connectionPromise);
|
|
84
|
-
try {
|
|
85
|
-
const dataSource = await connectionPromise;
|
|
86
|
-
LocalizationDataSourceProvider.tenantConnections.set(tenant.id, dataSource);
|
|
87
|
-
return dataSource;
|
|
88
|
-
} finally{
|
|
89
|
-
LocalizationDataSourceProvider.connectionLocks.delete(tenant.id);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
47
|
constructor(configService, request){
|
|
93
48
|
super(LocalizationDataSourceProvider.buildParentOptions(configService.getOptions()), request);
|
|
94
49
|
}
|
|
95
50
|
}
|
|
96
51
|
_define_property(LocalizationDataSourceProvider, "tenantConnections", new Map());
|
|
97
52
|
_define_property(LocalizationDataSourceProvider, "singleDataSource", null);
|
|
53
|
+
_define_property(LocalizationDataSourceProvider, "tenantsRegistry", new Map());
|
|
54
|
+
_define_property(LocalizationDataSourceProvider, "initialized", false);
|
|
98
55
|
_define_property(LocalizationDataSourceProvider, "connectionLocks", new Map());
|
|
99
56
|
_define_property(LocalizationDataSourceProvider, "singleConnectionLock", null);
|
|
100
57
|
LocalizationDataSourceProvider = _ts_decorate([
|
|
@@ -25,20 +25,14 @@ function _ts_param(paramIndex, decorator) {
|
|
|
25
25
|
decorator(target, key, paramIndex);
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
import { HybridCache,
|
|
28
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
29
29
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
30
30
|
import { BadRequestException, ForbiddenException, Inject, Injectable, Scope } from '@nestjs/common';
|
|
31
31
|
import { In, IsNull } from 'typeorm';
|
|
32
32
|
import { TRANSLATION_KEY_MESSAGES } from '../config';
|
|
33
33
|
import { TranslationKey } from '../entities';
|
|
34
34
|
import { LocalizationDataSourceProvider } from './localization-datasource.provider';
|
|
35
|
-
export class TranslationKeyService extends
|
|
36
|
-
resolveEntity() {
|
|
37
|
-
return TranslationKey;
|
|
38
|
-
}
|
|
39
|
-
getDataSourceProvider() {
|
|
40
|
-
return this.dataSourceProvider;
|
|
41
|
-
}
|
|
35
|
+
export class TranslationKeyService extends ApiService {
|
|
42
36
|
async beforeInsertOperation(dto, _user, _queryRunner) {
|
|
43
37
|
const dtos = Array.isArray(dto) ? dto : [
|
|
44
38
|
dto
|
|
@@ -53,7 +47,7 @@ export class TranslationKeyService extends RequestScopedApiService {
|
|
|
53
47
|
dto
|
|
54
48
|
];
|
|
55
49
|
const ids = dtos.map((d)=>d.id);
|
|
56
|
-
await this.
|
|
50
|
+
await this.ensureDataSourceRepository();
|
|
57
51
|
const existingKeys = await this.repository.find({
|
|
58
52
|
where: {
|
|
59
53
|
id: In(ids),
|
|
@@ -90,7 +84,7 @@ export class TranslationKeyService extends RequestScopedApiService {
|
|
|
90
84
|
const ids = Array.isArray(option.id) ? option.id : [
|
|
91
85
|
option.id
|
|
92
86
|
];
|
|
93
|
-
await this.
|
|
87
|
+
await this.ensureDataSourceRepository();
|
|
94
88
|
const readonlyKeys = await this.repository.find({
|
|
95
89
|
where: {
|
|
96
90
|
id: In(ids),
|
|
@@ -110,7 +104,7 @@ export class TranslationKeyService extends RequestScopedApiService {
|
|
|
110
104
|
}
|
|
111
105
|
}
|
|
112
106
|
async findByModule(module) {
|
|
113
|
-
await this.
|
|
107
|
+
await this.ensureDataSourceRepository();
|
|
114
108
|
return this.repository.find({
|
|
115
109
|
where: {
|
|
116
110
|
module,
|
|
@@ -124,12 +118,12 @@ export class TranslationKeyService extends RequestScopedApiService {
|
|
|
124
118
|
});
|
|
125
119
|
}
|
|
126
120
|
async getModules() {
|
|
127
|
-
await this.
|
|
121
|
+
await this.ensureDataSourceRepository();
|
|
128
122
|
const result = await this.repository.createQueryBuilder('tk').select('DISTINCT tk.module', 'module').where('tk.deleted_at IS NULL').getRawMany();
|
|
129
123
|
return result.map((r)=>r.module);
|
|
130
124
|
}
|
|
131
125
|
async validateNoDuplicateKeys(keys) {
|
|
132
|
-
await this.
|
|
126
|
+
await this.ensureDataSourceRepository();
|
|
133
127
|
for (const { module, key, excludeId } of keys){
|
|
134
128
|
const query = this.repository.createQueryBuilder('tk').where('tk.module = :module', {
|
|
135
129
|
module
|
|
@@ -155,7 +149,7 @@ export class TranslationKeyService extends RequestScopedApiService {
|
|
|
155
149
|
}
|
|
156
150
|
}
|
|
157
151
|
constructor(cacheManager, utilsService, dataSourceProvider){
|
|
158
|
-
super('translationKey',
|
|
152
|
+
super('translationKey', cacheManager, utilsService, TranslationKeyService.name, true, 'localization', TranslationKey, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService;
|
|
159
153
|
}
|
|
160
154
|
}
|
|
161
155
|
TranslationKeyService = _ts_decorate([
|
|
@@ -25,19 +25,13 @@ function _ts_param(paramIndex, decorator) {
|
|
|
25
25
|
decorator(target, key, paramIndex);
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
-
import { HybridCache,
|
|
28
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
29
29
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
30
30
|
import { Inject, Injectable, Scope } from '@nestjs/common';
|
|
31
31
|
import { In, IsNull } from 'typeorm';
|
|
32
32
|
import { Language, Translation, TranslationKey } from '../entities';
|
|
33
33
|
import { LocalizationDataSourceProvider } from './localization-datasource.provider';
|
|
34
|
-
export class TranslationService extends
|
|
35
|
-
resolveEntity() {
|
|
36
|
-
return Translation;
|
|
37
|
-
}
|
|
38
|
-
getDataSourceProvider() {
|
|
39
|
-
return this.dataSourceProvider;
|
|
40
|
-
}
|
|
34
|
+
export class TranslationService extends ApiService {
|
|
41
35
|
async getFilterQuery(query, filter, _user) {
|
|
42
36
|
// Handle module filter by joining to translation_key table
|
|
43
37
|
if (filter.module) {
|
|
@@ -63,7 +57,7 @@ export class TranslationService extends RequestScopedApiService {
|
|
|
63
57
|
};
|
|
64
58
|
}
|
|
65
59
|
async ensureAllReposInitialized() {
|
|
66
|
-
await this.
|
|
60
|
+
await this.ensureDataSourceRepository();
|
|
67
61
|
if (!this.languageRepo) {
|
|
68
62
|
const ds = await this.dataSourceProvider.getDataSource();
|
|
69
63
|
this.languageRepo = ds.getRepository(Language);
|
|
@@ -96,7 +90,7 @@ export class TranslationService extends RequestScopedApiService {
|
|
|
96
90
|
return this.toTranslationsMap(translations);
|
|
97
91
|
}
|
|
98
92
|
async bulkUpdate(updates) {
|
|
99
|
-
await this.
|
|
93
|
+
await this.ensureDataSourceRepository();
|
|
100
94
|
if (updates.length === 0) return [];
|
|
101
95
|
const ds = await this.dataSourceProvider.getDataSource();
|
|
102
96
|
const queryRunner = ds.createQueryRunner();
|
|
@@ -165,7 +159,7 @@ export class TranslationService extends RequestScopedApiService {
|
|
|
165
159
|
return allKeys.filter((k)=>!existingKeyIds.has(k.id));
|
|
166
160
|
}
|
|
167
161
|
async getTranslationCounts() {
|
|
168
|
-
await this.
|
|
162
|
+
await this.ensureDataSourceRepository();
|
|
169
163
|
const counts = await this.repository.createQueryBuilder('t').select('t.translation_key_id', 'keyId').addSelect('COUNT(t.id)', 'count').where('t.is_active = true').andWhere('t.deleted_at IS NULL').groupBy('t.translation_key_id').getRawMany();
|
|
170
164
|
const result = {};
|
|
171
165
|
for (const row of counts){
|
|
@@ -193,7 +187,7 @@ export class TranslationService extends RequestScopedApiService {
|
|
|
193
187
|
return result;
|
|
194
188
|
}
|
|
195
189
|
constructor(cacheManager, utilsService, dataSourceProvider){
|
|
196
|
-
super('translation',
|
|
190
|
+
super('translation', cacheManager, utilsService, TranslationService.name, true, 'localization', Translation, dataSourceProvider), _define_property(this, "cacheManager", void 0), _define_property(this, "utilsService", void 0), _define_property(this, "dataSourceProvider", void 0), _define_property(this, "languageRepo", void 0), _define_property(this, "translationKeyRepo", void 0), this.cacheManager = cacheManager, this.utilsService = utilsService, this.dataSourceProvider = dataSourceProvider, this.languageRepo = null, this.translationKeyRepo = null;
|
|
197
191
|
}
|
|
198
192
|
}
|
|
199
193
|
TranslationService = _ts_decorate([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flusys/nestjs-localization",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.2.0",
|
|
4
4
|
"description": "Localization module for multi-language support",
|
|
5
5
|
"main": "cjs/index.js",
|
|
6
6
|
"module": "fesm/index.js",
|
|
@@ -68,19 +68,19 @@
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@nestjs/common": "^
|
|
72
|
-
"@nestjs/config": "^
|
|
73
|
-
"@nestjs/core": "^
|
|
74
|
-
"@nestjs/platform-express": "^
|
|
75
|
-
"@nestjs/swagger": "^
|
|
76
|
-
"@nestjs/typeorm": "^
|
|
77
|
-
"class-transformer": "^0.5.
|
|
78
|
-
"class-validator": "^0.14.0",
|
|
71
|
+
"@nestjs/common": "^11.0.0",
|
|
72
|
+
"@nestjs/config": "^4.0.0",
|
|
73
|
+
"@nestjs/core": "^11.0.0",
|
|
74
|
+
"@nestjs/platform-express": "^11.0.0",
|
|
75
|
+
"@nestjs/swagger": "^11.0.0",
|
|
76
|
+
"@nestjs/typeorm": "^11.0.0",
|
|
77
|
+
"class-transformer": "^0.5.1",
|
|
78
|
+
"class-validator": "^0.14.0 || ^0.15.0",
|
|
79
79
|
"typeorm": "^0.3.0",
|
|
80
|
-
"express": "^4.18.0"
|
|
80
|
+
"express": "^4.18.0 || ^5.0.0"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@flusys/nestjs-core": "5.
|
|
84
|
-
"@flusys/nestjs-shared": "5.
|
|
83
|
+
"@flusys/nestjs-core": "5.2.0",
|
|
84
|
+
"@flusys/nestjs-shared": "5.2.0"
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import { HybridCache,
|
|
1
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
3
|
-
import { EntityTarget } from 'typeorm';
|
|
4
3
|
import { CreateLanguageDto, UpdateLanguageDto } from '../dtos';
|
|
5
4
|
import { Language } from '../entities';
|
|
6
5
|
import { ILanguage } from '../interfaces';
|
|
7
6
|
import { LocalizationDataSourceProvider } from './localization-datasource.provider';
|
|
8
|
-
export declare class LanguageService extends
|
|
7
|
+
export declare class LanguageService extends ApiService<CreateLanguageDto, UpdateLanguageDto, ILanguage, Language> {
|
|
9
8
|
protected cacheManager: HybridCache;
|
|
10
9
|
protected utilsService: UtilsService;
|
|
11
|
-
private readonly dataSourceProvider;
|
|
12
10
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: LocalizationDataSourceProvider);
|
|
13
|
-
protected resolveEntity(): EntityTarget<Language>;
|
|
14
|
-
protected getDataSourceProvider(): LocalizationDataSourceProvider;
|
|
15
11
|
getDefaultLanguage(): Promise<Language | null>;
|
|
16
12
|
getActiveLanguages(): Promise<Language[]>;
|
|
17
13
|
setAsDefault(id: string): Promise<Language | null>;
|
|
@@ -6,11 +6,11 @@ import { LocalizationConfigService } from './localization-config.service';
|
|
|
6
6
|
export declare class LocalizationDataSourceProvider extends MultiTenantDataSourceService {
|
|
7
7
|
protected static readonly tenantConnections: Map<string, DataSource>;
|
|
8
8
|
protected static singleDataSource: DataSource | null;
|
|
9
|
+
protected static readonly tenantsRegistry: Map<string, ITenantDatabaseConfig>;
|
|
10
|
+
protected static initialized: boolean;
|
|
9
11
|
protected static readonly connectionLocks: Map<string, Promise<DataSource>>;
|
|
10
12
|
protected static singleConnectionLock: Promise<DataSource> | null;
|
|
11
13
|
constructor(configService: LocalizationConfigService, request?: Request);
|
|
12
14
|
private static buildParentOptions;
|
|
13
15
|
protected createDataSourceFromConfig(config: IDatabaseConfig): Promise<DataSource>;
|
|
14
|
-
protected getSingleDataSource(): Promise<DataSource>;
|
|
15
|
-
protected getOrCreateTenantConnection(tenant: ITenantDatabaseConfig): Promise<DataSource>;
|
|
16
16
|
}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { HybridCache,
|
|
1
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { DeleteDto } from '@flusys/nestjs-shared/dtos';
|
|
3
3
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
4
4
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
5
|
-
import {
|
|
5
|
+
import { QueryRunner } from 'typeorm';
|
|
6
6
|
import { CreateTranslationKeyDto, UpdateTranslationKeyDto } from '../dtos';
|
|
7
7
|
import { TranslationKey } from '../entities';
|
|
8
8
|
import { ITranslationKey } from '../interfaces';
|
|
9
9
|
import { LocalizationDataSourceProvider } from './localization-datasource.provider';
|
|
10
|
-
export declare class TranslationKeyService extends
|
|
10
|
+
export declare class TranslationKeyService extends ApiService<CreateTranslationKeyDto, UpdateTranslationKeyDto, ITranslationKey, TranslationKey> {
|
|
11
11
|
protected cacheManager: HybridCache;
|
|
12
12
|
protected utilsService: UtilsService;
|
|
13
|
-
private readonly dataSourceProvider;
|
|
14
13
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: LocalizationDataSourceProvider);
|
|
15
|
-
protected resolveEntity(): EntityTarget<TranslationKey>;
|
|
16
|
-
protected getDataSourceProvider(): LocalizationDataSourceProvider;
|
|
17
14
|
protected beforeInsertOperation(dto: CreateTranslationKeyDto | CreateTranslationKeyDto[], _user: ILoggedUserInfo | null, _queryRunner: QueryRunner): Promise<void>;
|
|
18
15
|
protected beforeUpdateOperation(dto: UpdateTranslationKeyDto | UpdateTranslationKeyDto[], _user: ILoggedUserInfo | null, _queryRunner: QueryRunner): Promise<void>;
|
|
19
16
|
protected beforeDeleteOperation(option: DeleteDto, _user: ILoggedUserInfo | null, _queryRunner: QueryRunner): Promise<void>;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
import { HybridCache,
|
|
1
|
+
import { HybridCache, ApiService } from '@flusys/nestjs-shared/classes';
|
|
2
2
|
import { ILoggedUserInfo } from '@flusys/nestjs-shared/interfaces';
|
|
3
3
|
import { UtilsService } from '@flusys/nestjs-shared/modules';
|
|
4
|
-
import {
|
|
4
|
+
import { SelectQueryBuilder } from 'typeorm';
|
|
5
5
|
import { BulkUpdateTranslationDto, CreateTranslationDto, UpdateTranslationDto } from '../dtos';
|
|
6
6
|
import { Translation, TranslationKey } from '../entities';
|
|
7
7
|
import { ITranslation, ITranslationsMap } from '../interfaces';
|
|
8
8
|
import { LocalizationDataSourceProvider } from './localization-datasource.provider';
|
|
9
|
-
export declare class TranslationService extends
|
|
9
|
+
export declare class TranslationService extends ApiService<CreateTranslationDto, UpdateTranslationDto, ITranslation, Translation> {
|
|
10
10
|
protected cacheManager: HybridCache;
|
|
11
11
|
protected utilsService: UtilsService;
|
|
12
12
|
private readonly dataSourceProvider;
|
|
13
13
|
private languageRepo;
|
|
14
14
|
private translationKeyRepo;
|
|
15
15
|
constructor(cacheManager: HybridCache, utilsService: UtilsService, dataSourceProvider: LocalizationDataSourceProvider);
|
|
16
|
-
protected resolveEntity(): EntityTarget<Translation>;
|
|
17
|
-
protected getDataSourceProvider(): LocalizationDataSourceProvider;
|
|
18
16
|
protected getFilterQuery(query: SelectQueryBuilder<Translation>, filter: Record<string, unknown>, _user: ILoggedUserInfo | null): Promise<{
|
|
19
17
|
query: SelectQueryBuilder<Translation>;
|
|
20
18
|
isRaw: boolean;
|