@tc-libs/error-interface 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 +86 -6
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,11 +1,91 @@
1
- # error-interface
1
+ # @tc-libs/error-interface
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Definisce i contratti TypeScript condivisi per rappresentare errori applicativi e errori di importazione.
4
4
 
5
- ## Building
5
+ Questo package non contiene eccezioni NestJS, filtri o logica runtime: espone solo tipi e costanti riusabili.
6
6
 
7
- Run `nx build error-interface` to build the library.
7
+ ## Export pubblici
8
8
 
9
- ## Running unit tests
9
+ ```ts
10
+ import {
11
+ ERROR_TYPE,
12
+ IErrors,
13
+ IErrorsImport,
14
+ IValidationErrorImport,
15
+ } from '@tc-libs/error-interface';
16
+ ```
10
17
 
11
- Run `nx test error-interface` to execute the unit tests via [Jest](https://jestjs.io).
18
+ ## Tipi disponibili
19
+
20
+ ### `IErrors`
21
+
22
+ Rappresenta un singolo errore applicativo normalizzato:
23
+
24
+ ```ts
25
+ type IErrors = {
26
+ message: string;
27
+ property: string;
28
+ };
29
+ ```
30
+
31
+ Uso tipico:
32
+
33
+ ```ts
34
+ const errors: IErrors[] = [
35
+ { property: 'email', message: 'email must be valid' },
36
+ ];
37
+ ```
38
+
39
+ ### `IErrorsImport`
40
+
41
+ Rappresenta un errore associato a una riga di import:
42
+
43
+ ```ts
44
+ type IErrorsImport = {
45
+ row: number;
46
+ file?: string;
47
+ errors: IErrors[];
48
+ };
49
+ ```
50
+
51
+ Utile per import massivi da CSV/XLSX dove devi restituire al chiamante il dettaglio per record.
52
+
53
+ ### `IValidationErrorImport`
54
+
55
+ Variante pensata per interoperare con `class-validator`:
56
+
57
+ ```ts
58
+ type IValidationErrorImport = {
59
+ row: number;
60
+ file?: string;
61
+ errors: ValidationError[];
62
+ };
63
+ ```
64
+
65
+ ## Enum disponibili
66
+
67
+ ### `ERROR_TYPE`
68
+
69
+ Classifica il tipo di errore:
70
+
71
+ ```ts
72
+ ERROR_TYPE.DEFAULT;
73
+ ERROR_TYPE.IMPORT;
74
+ ```
75
+
76
+ Tipicamente viene usato nei package superiori per differenziare la serializzazione o il trattamento dell'errore.
77
+
78
+ ## Quando usarlo
79
+
80
+ Usa questo package quando vuoi:
81
+
82
+ - condividere interfacce errore tra librerie
83
+ - tipizzare errori di validazione/import senza introdurre dipendenze runtime aggiuntive
84
+ - evitare duplicazioni di DTO o interfacce negli handler applicativi
85
+
86
+ ## Sviluppo
87
+
88
+ ```bash
89
+ nx build error-interface
90
+ nx test error-interface
91
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tc-libs/error-interface",
3
- "version": "3.5.0",
3
+ "version": "3.6.1",
4
4
  "dependencies": {
5
5
  "class-validator": "^0.14.1",
6
6
  "tslib": "^2.8.1"