@tc-libs/message 3.5.0 → 3.6.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.
Files changed (2) hide show
  1. package/README.md +66 -6
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,11 +1,71 @@
1
- # message
1
+ # @tc-libs/message
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Servizio di messaggistica applicativa e normalizzazione errori validazione.
4
4
 
5
- ## Building
5
+ Il package non contiene ancora un motore i18n attivo: `setMessage()` al momento ritorna `null`, ma l'API e gia pronta e viene usata dagli altri package per costruire risposte multilingua o fallback.
6
6
 
7
- Run `nx build message` to build the library.
7
+ ## Registrazione
8
8
 
9
- ## Running unit tests
9
+ ```ts
10
+ MessageModule.register(
11
+ {
12
+ appDefaultLanguage: 'it',
13
+ availableLanguages: ['it', 'en'],
14
+ i18nEnabled: false,
15
+ },
16
+ true,
17
+ );
18
+ ```
10
19
 
11
- Run `nx test message` to execute the unit tests via [Jest](https://jestjs.io).
20
+ Il modulo applica anche il middleware `MessageCustomLanguageMiddleware` per leggere la lingua custom dalla request.
21
+
22
+ ## Servizio
23
+
24
+ `MessageService` espone:
25
+
26
+ - `getAvailableLanguages()`
27
+ - `get(key, options?)`
28
+ - `getRequestErrorsMessage(validationErrors, customLanguages?)`
29
+ - `getImportErrorsMessage(importErrors, customLanguages?)`
30
+
31
+ Esempio:
32
+
33
+ ```ts
34
+ const msg = await this.messageService.get('user.created', {
35
+ customLanguages: ['it'],
36
+ properties: { name: 'Mario' },
37
+ });
38
+ ```
39
+
40
+ ## Uso con validation errors
41
+
42
+ ```ts
43
+ const errors = await this.messageService.getRequestErrorsMessage(
44
+ validationErrors,
45
+ ['it'],
46
+ );
47
+ ```
48
+
49
+ Questo e il punto di integrazione usato da `@tc-libs/error-handler`.
50
+
51
+ ## Export pubblici
52
+
53
+ ```ts
54
+ import {
55
+ IMessage,
56
+ IMessageOptions,
57
+ MessageModule,
58
+ MessageService,
59
+ } from '@tc-libs/message';
60
+ ```
61
+
62
+ ## Nota importante
63
+
64
+ Lo strato di API e pronto, ma la traduzione vera e propria e da completare. Nei package che lo usano, trattalo come message resolver/pluggable facade piu che come i18n engine finito.
65
+
66
+ ## Sviluppo
67
+
68
+ ```bash
69
+ nx build message
70
+ nx test message
71
+ ```
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tc-libs/message",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "dependencies": {
5
- "@tc-libs/error-interface": "3.5.0",
6
- "@tc-libs/request": "3.5.0",
5
+ "@tc-libs/error-interface": "3.6.1",
6
+ "@tc-libs/request": "3.6.1",
7
7
  "@nestjs/swagger": "^11.1.0",
8
8
  "@nestjs/common": "^11.0.12",
9
9
  "express": "5.0.1",