@flusys/nestjs-localization 7.0.2 → 8.0.0-beta.1
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/config/index.d.ts +3 -3
- package/controllers/index.d.ts +3 -3
- package/controllers/language.controller.d.ts +4 -4
- package/controllers/translation-key.controller.d.ts +3 -3
- package/controllers/translation.controller.d.ts +4 -4
- package/docs/index.d.ts +1 -1
- package/docs/localization-swagger.config.d.ts +1 -1
- package/dtos/index.d.ts +3 -3
- package/dtos/translation.dto.d.ts +2 -2
- package/entities/index.d.ts +6 -6
- package/entities/language.entity.d.ts +1 -1
- package/entities/translation-key.entity.d.ts +1 -1
- package/entities/translation.entity.d.ts +2 -2
- package/fesm/349.js +1179 -0
- package/fesm/692.js +1205 -0
- package/fesm/config/index.js +101 -3
- package/fesm/controllers/index.js +15 -3
- package/fesm/docs/index.js +126 -1
- package/fesm/dtos/index.js +680 -3
- package/fesm/entities/index.js +405 -8
- package/fesm/index.js +257 -7
- package/fesm/interfaces/index.js +18 -4
- package/fesm/modules/index.js +152 -1
- package/fesm/runtime.js +85 -0
- package/fesm/services/index.js +15 -5
- package/index.d.ts +7 -7
- package/interfaces/index.d.ts +4 -4
- package/interfaces/language.interface.d.ts +1 -1
- package/interfaces/localization-module-options.interface.d.ts +3 -3
- package/interfaces/translation-key.interface.d.ts +1 -1
- package/interfaces/translation.interface.d.ts +3 -3
- package/modules/index.d.ts +1 -1
- package/modules/localization.module.d.ts +2 -2
- package/package.json +25 -34
- package/services/index.d.ts +5 -5
- package/services/language.service.d.ts +6 -6
- package/services/localization-config.service.d.ts +3 -3
- package/services/localization-datasource.provider.d.ts +3 -3
- package/services/translation-key.service.d.ts +6 -6
- package/services/translation.service.d.ts +5 -5
- package/cjs/config/event-actions.js +0 -33
- package/cjs/config/index.js +0 -20
- package/cjs/config/localization.constants.js +0 -11
- package/cjs/config/message-keys.js +0 -41
- package/cjs/controllers/index.js +0 -20
- package/cjs/controllers/language.controller.js +0 -188
- package/cjs/controllers/language.controller.spec.js +0 -154
- package/cjs/controllers/translation-key.controller.js +0 -135
- package/cjs/controllers/translation-key.controller.spec.js +0 -70
- package/cjs/controllers/translation.controller.js +0 -195
- package/cjs/controllers/translation.controller.spec.js +0 -169
- package/cjs/docs/index.js +0 -11
- package/cjs/docs/localization-swagger.config.js +0 -111
- package/cjs/docs/localization-swagger.config.spec.js +0 -30
- package/cjs/dtos/index.js +0 -20
- package/cjs/dtos/language.dto.js +0 -213
- package/cjs/dtos/translation-key.dto.js +0 -215
- package/cjs/dtos/translation.dto.js +0 -269
- package/cjs/entities/index.js +0 -42
- package/cjs/entities/index.spec.js +0 -18
- package/cjs/entities/language.entity.js +0 -126
- package/cjs/entities/translation-key.entity.js +0 -126
- package/cjs/entities/translation.entity.js +0 -120
- package/cjs/index.js +0 -24
- package/cjs/interfaces/index.js +0 -21
- package/cjs/interfaces/language.interface.js +0 -4
- package/cjs/interfaces/localization-module-options.interface.js +0 -4
- package/cjs/interfaces/translation-key.interface.js +0 -4
- package/cjs/interfaces/translation.interface.js +0 -4
- package/cjs/modules/index.js +0 -18
- package/cjs/modules/localization.module.js +0 -116
- package/cjs/modules/localization.module.spec.js +0 -132
- package/cjs/services/index.js +0 -22
- package/cjs/services/language.service.js +0 -181
- package/cjs/services/language.service.spec.js +0 -256
- package/cjs/services/localization-config.service.js +0 -66
- package/cjs/services/localization-config.service.spec.js +0 -80
- package/cjs/services/localization-datasource.provider.js +0 -79
- package/cjs/services/localization-datasource.provider.spec.js +0 -85
- package/cjs/services/translation-key.service.js +0 -179
- package/cjs/services/translation-key.service.spec.js +0 -303
- package/cjs/services/translation.service.js +0 -228
- package/cjs/services/translation.service.spec.js +0 -530
- package/fesm/config/event-actions.js +0 -12
- package/fesm/config/localization.constants.js +0 -1
- package/fesm/config/message-keys.js +0 -20
- package/fesm/controllers/language.controller.js +0 -178
- package/fesm/controllers/language.controller.spec.js +0 -150
- package/fesm/controllers/translation-key.controller.js +0 -125
- package/fesm/controllers/translation-key.controller.spec.js +0 -66
- package/fesm/controllers/translation.controller.js +0 -185
- package/fesm/controllers/translation.controller.spec.js +0 -165
- package/fesm/docs/localization-swagger.config.js +0 -101
- package/fesm/docs/localization-swagger.config.spec.js +0 -26
- package/fesm/dtos/language.dto.js +0 -192
- package/fesm/dtos/translation-key.dto.js +0 -194
- package/fesm/dtos/translation.dto.js +0 -239
- package/fesm/entities/index.spec.js +0 -14
- package/fesm/entities/language.entity.js +0 -116
- package/fesm/entities/translation-key.entity.js +0 -116
- package/fesm/entities/translation.entity.js +0 -110
- package/fesm/interfaces/language.interface.js +0 -1
- package/fesm/interfaces/localization-module-options.interface.js +0 -1
- package/fesm/interfaces/translation-key.interface.js +0 -1
- package/fesm/interfaces/translation.interface.js +0 -1
- package/fesm/modules/localization.module.js +0 -106
- package/fesm/modules/localization.module.spec.js +0 -128
- package/fesm/services/language.service.js +0 -171
- package/fesm/services/language.service.spec.js +0 -252
- package/fesm/services/localization-config.service.js +0 -56
- package/fesm/services/localization-config.service.spec.js +0 -76
- package/fesm/services/localization-datasource.provider.js +0 -69
- package/fesm/services/localization-datasource.provider.spec.js +0 -81
- package/fesm/services/translation-key.service.js +0 -169
- package/fesm/services/translation-key.service.spec.js +0 -299
- package/fesm/services/translation.service.js +0 -218
- package/fesm/services/translation.service.spec.js +0 -526
package/fesm/config/index.js
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export const __rspack_esm_id = 565;
|
|
2
|
+
export const __rspack_esm_ids = [565];
|
|
3
|
+
export const __webpack_modules__ = {
|
|
4
|
+
102(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
/**
|
|
6
|
+
* Domain event actions published by the localization module, alongside the CRUD
|
|
7
|
+
* lifecycle actions every ApiService emits.
|
|
8
|
+
*/ const LOCALIZATION_EVENT_ACTIONS = {
|
|
9
|
+
BULK_UPDATED: 'bulk-updated'
|
|
10
|
+
};
|
|
11
|
+
/** Every entity the localization module publishes under */ const LOCALIZATION_EVENT_ENTITIES = {
|
|
12
|
+
LANGUAGE: 'language',
|
|
13
|
+
TRANSLATION_KEY: 'translationKey',
|
|
14
|
+
TRANSLATION: 'translation'
|
|
15
|
+
};
|
|
16
|
+
const LOCALIZATION_EVENT_MODULE = 'localization';
|
|
17
|
+
|
|
18
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
19
|
+
}, {
|
|
20
|
+
JX: LOCALIZATION_EVENT_ENTITIES,
|
|
21
|
+
ec: LOCALIZATION_EVENT_MODULE,
|
|
22
|
+
f_: LOCALIZATION_EVENT_ACTIONS
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
},
|
|
27
|
+
992(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
28
|
+
/* import */ var _event_actions_js__rspack_import_0 = __webpack_require__(102);
|
|
29
|
+
/* import */ var _localization_constants_js__rspack_import_1 = __webpack_require__(88);
|
|
30
|
+
/* import */ var _message_keys_js__rspack_import_2 = __webpack_require__(68);
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
A5: () => (/* reexport safe */ _localization_constants_js__rspack_import_1.A),
|
|
37
|
+
Bc: () => (/* reexport safe */ _message_keys_js__rspack_import_2.Bc),
|
|
38
|
+
JX: () => (/* reexport safe */ _event_actions_js__rspack_import_0.JX),
|
|
39
|
+
Ju: () => (/* reexport safe */ _message_keys_js__rspack_import_2.Ju),
|
|
40
|
+
ec: () => (/* reexport safe */ _event_actions_js__rspack_import_0.ec),
|
|
41
|
+
ew: () => (/* reexport safe */ _message_keys_js__rspack_import_2.ew),
|
|
42
|
+
f_: () => (/* reexport safe */ _event_actions_js__rspack_import_0.f_)
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
},
|
|
47
|
+
88(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
48
|
+
const LOCALIZATION_MODULE_OPTIONS = 'LOCALIZATION_MODULE_OPTIONS';
|
|
49
|
+
|
|
50
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
51
|
+
}, {
|
|
52
|
+
A: LOCALIZATION_MODULE_OPTIONS
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
},
|
|
57
|
+
68(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
58
|
+
// ==================== LOCALIZATION MODULE MESSAGE KEYS ====================
|
|
59
|
+
const LANGUAGE_MESSAGES = {
|
|
60
|
+
ACTIVE_SUCCESS: 'language.active.success',
|
|
61
|
+
SET_DEFAULT_SUCCESS: 'language.set.default.success',
|
|
62
|
+
GET_DEFAULT_SUCCESS: 'language.get.default.success',
|
|
63
|
+
READONLY_UPDATE_FORBIDDEN: 'language.readonly.update.forbidden',
|
|
64
|
+
READONLY_DELETE_FORBIDDEN: 'language.readonly.delete.forbidden',
|
|
65
|
+
DEFAULT_DELETE_FORBIDDEN: 'language.default.delete.forbidden'
|
|
66
|
+
};
|
|
67
|
+
const TRANSLATION_KEY_MESSAGES = {
|
|
68
|
+
MODULES_SUCCESS: 'translation.key.modules.success',
|
|
69
|
+
READONLY_DELETE_FORBIDDEN: 'translation.key.readonly.delete.forbidden',
|
|
70
|
+
READONLY_UPDATE_FORBIDDEN: 'translation.key.readonly.update.forbidden',
|
|
71
|
+
DUPLICATE_KEY_IN_MODULE: 'translation.key.duplicate.key.in.module'
|
|
72
|
+
};
|
|
73
|
+
const TRANSLATION_MESSAGES = {
|
|
74
|
+
GET_ALL_SUCCESS: 'translation.get.all.success',
|
|
75
|
+
UPDATE_MANY_SUCCESS: 'translation.update.many.success',
|
|
76
|
+
BY_LANGUAGE_SUCCESS: 'translation.by.language.success'
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
80
|
+
}, {
|
|
81
|
+
Bc: TRANSLATION_KEY_MESSAGES,
|
|
82
|
+
Ju: TRANSLATION_MESSAGES,
|
|
83
|
+
ew: LANGUAGE_MESSAGES
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
};
|
|
90
|
+
import { __webpack_require__ } from '../runtime.js';
|
|
91
|
+
var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
|
|
92
|
+
import * as __rspack_chunk_1 from './index.js';
|
|
93
|
+
__webpack_require__.C(__rspack_chunk_1);
|
|
94
|
+
var __webpack_exports__ = __webpack_exec__(992);var __webpack_exports__LANGUAGE_MESSAGES = __webpack_exports__.ew;
|
|
95
|
+
var __webpack_exports__LOCALIZATION_EVENT_ACTIONS = __webpack_exports__.f_;
|
|
96
|
+
var __webpack_exports__LOCALIZATION_EVENT_ENTITIES = __webpack_exports__.JX;
|
|
97
|
+
var __webpack_exports__LOCALIZATION_EVENT_MODULE = __webpack_exports__.ec;
|
|
98
|
+
var __webpack_exports__LOCALIZATION_MODULE_OPTIONS = __webpack_exports__.A5;
|
|
99
|
+
var __webpack_exports__TRANSLATION_KEY_MESSAGES = __webpack_exports__.Bc;
|
|
100
|
+
var __webpack_exports__TRANSLATION_MESSAGES = __webpack_exports__.Ju;
|
|
101
|
+
export { __webpack_exports__LANGUAGE_MESSAGES as LANGUAGE_MESSAGES, __webpack_exports__LOCALIZATION_EVENT_ACTIONS as LOCALIZATION_EVENT_ACTIONS, __webpack_exports__LOCALIZATION_EVENT_ENTITIES as LOCALIZATION_EVENT_ENTITIES, __webpack_exports__LOCALIZATION_EVENT_MODULE as LOCALIZATION_EVENT_MODULE, __webpack_exports__LOCALIZATION_MODULE_OPTIONS as LOCALIZATION_MODULE_OPTIONS, __webpack_exports__TRANSLATION_KEY_MESSAGES as TRANSLATION_KEY_MESSAGES, __webpack_exports__TRANSLATION_MESSAGES as TRANSLATION_MESSAGES };
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export const __rspack_esm_id = 24;
|
|
2
|
+
export const __rspack_esm_ids = [24];
|
|
3
|
+
export const __webpack_modules__ = {};
|
|
4
|
+
import { __webpack_require__ } from '../runtime.js';
|
|
5
|
+
var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
|
|
6
|
+
import * as __rspack_chunk_1 from '../692.js';
|
|
7
|
+
__webpack_require__.C(__rspack_chunk_1);
|
|
8
|
+
import * as __rspack_chunk_2 from '../349.js';
|
|
9
|
+
__webpack_require__.C(__rspack_chunk_2);
|
|
10
|
+
import * as __rspack_chunk_3 from './index.js';
|
|
11
|
+
__webpack_require__.C(__rspack_chunk_3);
|
|
12
|
+
var __webpack_exports__ = __webpack_exec__(212);var __webpack_exports__LanguageController = __webpack_exports__.t7;
|
|
13
|
+
var __webpack_exports__TranslationController = __webpack_exports__.Ap;
|
|
14
|
+
var __webpack_exports__TranslationKeyController = __webpack_exports__.$4;
|
|
15
|
+
export { __webpack_exports__LanguageController as LanguageController, __webpack_exports__TranslationController as TranslationController, __webpack_exports__TranslationKeyController as TranslationKeyController };
|
package/fesm/docs/index.js
CHANGED
|
@@ -1 +1,126 @@
|
|
|
1
|
-
export
|
|
1
|
+
export const __rspack_esm_id = 428;
|
|
2
|
+
export const __rspack_esm_ids = [428];
|
|
3
|
+
export const __webpack_modules__ = {
|
|
4
|
+
921(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
|
|
6
|
+
// EXPORTS
|
|
7
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
8
|
+
a: () => (/* reexport */ localizationSwaggerConfig)
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
;// CONCATENATED MODULE: ./projects/nestjs-localization/src/docs/localization-swagger.config.ts
|
|
12
|
+
function localizationSwaggerConfig(bootstrapConfig) {
|
|
13
|
+
const isMultiTenant = bootstrapConfig?.databaseMode === 'multi-tenant';
|
|
14
|
+
const multiTenantNote = isMultiTenant ? `\n> **Multi-Tenant Mode**: Include \`x-tenant-id\` header to target a specific tenant database.\n` : '';
|
|
15
|
+
return {
|
|
16
|
+
title: 'Localization API',
|
|
17
|
+
description: `
|
|
18
|
+
## Localization API
|
|
19
|
+
${multiTenantNote}
|
|
20
|
+
|
|
21
|
+
Database-driven internationalization system. Manage languages, translation keys, and translations — all stored in the database and served via API.
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
### 🌐 Language Management
|
|
26
|
+
- Create and manage languages with LTR/RTL direction support
|
|
27
|
+
- Set a default language
|
|
28
|
+
- Mark languages as readonly to protect seeded entries
|
|
29
|
+
|
|
30
|
+
### 🔑 Translation Keys
|
|
31
|
+
- Organize keys by module for lazy loading (e.g. \`auth\`, \`iam\`, \`common\`)
|
|
32
|
+
- Dot-case naming convention: \`auth.login.title\`, \`common.button.save\`
|
|
33
|
+
- Support for interpolation variables: \`['count', 'name']\`
|
|
34
|
+
- Readonly protection — system keys cannot be deleted or have their key/module changed
|
|
35
|
+
|
|
36
|
+
### 📝 Translations
|
|
37
|
+
- Store translated values per language per key
|
|
38
|
+
- Mark translations as verified
|
|
39
|
+
- Bulk upsert in a single transaction — create or update in one call
|
|
40
|
+
- Detect missing translations for a given language
|
|
41
|
+
- Track translation counts per key
|
|
42
|
+
|
|
43
|
+
### 🚀 Angular Lazy Loading
|
|
44
|
+
- Public endpoints return flat key-value maps: \`{ "auth.login.title": "Sign In" }\`
|
|
45
|
+
- Filter by one or multiple modules to load only what is needed
|
|
46
|
+
- No authentication required for translation retrieval endpoints
|
|
47
|
+
|
|
48
|
+
## Key Naming Convention
|
|
49
|
+
|
|
50
|
+
Translation keys use dot-case and must be unique per module:
|
|
51
|
+
|
|
52
|
+
\`\`\`
|
|
53
|
+
auth.login.title
|
|
54
|
+
auth.login.submit
|
|
55
|
+
auth.register.email.placeholder
|
|
56
|
+
common.button.save
|
|
57
|
+
common.button.cancel
|
|
58
|
+
iam.role.create.success
|
|
59
|
+
\`\`\`
|
|
60
|
+
|
|
61
|
+
## Module-Based Lazy Loading
|
|
62
|
+
|
|
63
|
+
Keys are grouped by \`module\` so the frontend loads translations on demand:
|
|
64
|
+
|
|
65
|
+
| Module | Purpose |
|
|
66
|
+
|--------|---------|
|
|
67
|
+
| auth | Login, register, profile pages |
|
|
68
|
+
| iam | Roles, permissions management |
|
|
69
|
+
| storage | Files and folders |
|
|
70
|
+
| event-manager | Calendar events |
|
|
71
|
+
| form-builder | Dynamic form fields |
|
|
72
|
+
| notification | Notification titles and messages |
|
|
73
|
+
| email | Email template content |
|
|
74
|
+
| common | Shared labels used across modules |
|
|
75
|
+
|
|
76
|
+
## Public vs Authenticated Endpoints
|
|
77
|
+
|
|
78
|
+
**Public** (no auth required — used by Angular to load translations):
|
|
79
|
+
- POST /localization/language/get-active
|
|
80
|
+
- POST /localization/language/get-default
|
|
81
|
+
- POST /localization/translation/get-by-language
|
|
82
|
+
- POST /localization/translation/get-by-module
|
|
83
|
+
|
|
84
|
+
**Authenticated** (require JWT + permission):
|
|
85
|
+
- All create, update, delete operations
|
|
86
|
+
- get-missing, get-counts, update-many-values
|
|
87
|
+
|
|
88
|
+
## Bulk Update
|
|
89
|
+
|
|
90
|
+
POST /localization/translation/update-many-values accepts an array of translation objects. Each item is either an upsert (provide **id** to update, omit to create). The entire batch runs in a single database transaction.
|
|
91
|
+
|
|
92
|
+
## Readonly Protection
|
|
93
|
+
|
|
94
|
+
Languages and translation keys with \`isReadonly: true\` are protected at the service layer:
|
|
95
|
+
- Cannot be deleted
|
|
96
|
+
- Key and module fields cannot be modified
|
|
97
|
+
|
|
98
|
+
Use \`isReadonly\` to protect entries that are seeded at startup and should not be changed by users.
|
|
99
|
+
|
|
100
|
+
## Getting Started
|
|
101
|
+
|
|
102
|
+
1. **Authenticate**: Obtain JWT token from POST /auth/login
|
|
103
|
+
2. **Create languages**: Add languages via POST /localization/language/insert
|
|
104
|
+
3. **Seed translation keys**: Bulk insert keys via POST /localization/translation-key/insert-many
|
|
105
|
+
4. **Add translations**: Use POST /localization/translation/update-many-values for bulk upsert
|
|
106
|
+
5. **Load in Angular**: Call POST /localization/translation/get-by-language with { languageCode: "en", modules: ["auth"] }
|
|
107
|
+
`,
|
|
108
|
+
version: '1.0',
|
|
109
|
+
path: 'api/docs/localization',
|
|
110
|
+
bearerAuth: true
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
;// CONCATENATED MODULE: ./projects/nestjs-localization/src/docs/index.ts
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
};
|
|
121
|
+
import { __webpack_require__ } from '../runtime.js';
|
|
122
|
+
var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId); }
|
|
123
|
+
import * as __rspack_chunk_1 from './index.js';
|
|
124
|
+
__webpack_require__.C(__rspack_chunk_1);
|
|
125
|
+
var __webpack_exports__ = __webpack_exec__(921);var __webpack_exports__localizationSwaggerConfig = __webpack_exports__.a;
|
|
126
|
+
export { __webpack_exports__localizationSwaggerConfig as localizationSwaggerConfig };
|