@tc-libs/service 3.6.0 → 3.8.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.
Files changed (2) hide show
  1. package/README.md +53 -6
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -1,11 +1,58 @@
1
- # service
1
+ # @tc-libs/service
2
2
 
3
- This library was generated with [Nx](https://nx.dev).
3
+ Base layer per servizi applicativi CRUD costruiti sopra i repository di `@tc-libs/database`.
4
4
 
5
- ## Building
5
+ Il package contiene soprattutto:
6
6
 
7
- Run `nx build service` to build the library.
7
+ - `AbstractService`
8
+ - interfaccia `IService`
8
9
 
9
- ## Running unit tests
10
+ ## Cosa offre `AbstractService`
10
11
 
11
- Run `nx test service` to execute the unit tests via [Jest](https://jestjs.io).
12
+ Fornisce implementazioni riusabili per:
13
+
14
+ - `findById`, `findOne`, `findAll`, `findByIds`
15
+ - `create`, `createMany`, `save`
16
+ - `updateOne`, `updateMany`, `updateById`, `findOneAndUpdate`, `upsertOne`
17
+ - `delete`, `deleteMany`, `deleteManyByIds`, `deleteById`
18
+ - `exists`, `count`, `distinct`
19
+ - `paginate`
20
+ - gestione posizioni (`findMaxPosition`, `fillMissingPosition`, `moveToPosition`)
21
+ - `startTransaction`
22
+
23
+ ## Esempio
24
+
25
+ ```ts
26
+ @Injectable()
27
+ export class PermissionService extends AbstractService<
28
+ PermissionEntity,
29
+ PermissionDoc
30
+ > {
31
+ readonly logger = new Logger(PermissionService.name);
32
+
33
+ constructor(
34
+ protected readonly paging: PaginationService,
35
+ private readonly permissionRepository: PermissionRepository,
36
+ ) {
37
+ super(permissionRepository, paging);
38
+ }
39
+ }
40
+ ```
41
+
42
+ ## Quando usarlo
43
+
44
+ Usa questo package quando vuoi standardizzare i service di dominio su un comportamento comune, evitando di riscrivere sempre il wiring repository + pagination.
45
+
46
+ ## Dipendenze attese
47
+
48
+ `AbstractService` presuppone:
49
+
50
+ - un repository che estende `DatabaseMongoRepositoryAbstract`
51
+ - `PaginationService`
52
+
53
+ ## Sviluppo
54
+
55
+ ```bash
56
+ nx build service
57
+ nx test service
58
+ ```
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@tc-libs/service",
3
- "version": "3.6.0",
3
+ "version": "3.8.0",
4
4
  "dependencies": {
5
- "@tc-libs/database": "3.6.0",
6
- "@tc-libs/pagination": "3.6.0",
5
+ "@tc-libs/database": "3.8.0",
6
+ "@tc-libs/pagination": "3.8.0",
7
7
  "@nestjs/common": "^11.0.12",
8
8
  "mongoose": "^8.13.1",
9
9
  "tslib": "^2.8.1"