@volontariapp/domain-social 0.9.5 → 0.9.6

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 (3) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +88 -0
  3. package/package.json +7 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.9.6
4
+
5
+ ### Patch Changes
6
+
7
+ - README bump
8
+
9
+ - Updated dependencies []:
10
+ - @volontariapp/bridge-nest@0.3.16
11
+ - @volontariapp/contracts@4.3.2
12
+ - @volontariapp/errors@0.6.1
13
+ - @volontariapp/errors-nest@0.13.1
14
+ - @volontariapp/logger@0.2.6
15
+
3
16
  ## 0.9.5
4
17
 
5
18
  ### Patch Changes
package/README.md ADDED
@@ -0,0 +1,88 @@
1
+ # @volontariapp/domain-social
2
+
3
+ ## Overview & Domain Driven Design (DDD)
4
+
5
+ Le package `domain-social` isole la **logique métier absolue** relative au **Graphe Social** (demandes d'amis, abonnements, relations).
6
+ Cette logique est complexe (validation croisée des états des deux utilisateurs) et requiert une isolation parfaite vis-à-vis des bases de données orientées graphes (ex: Neo4j) utilisées par l'infrastructure.
7
+
8
+ Ce domaine métier (DRY) est partagé entre :
9
+ - `ms-social` (API HTTP/gRPC)
10
+ - Les Workers asynchrones de synchronisation relationnelle
11
+ - Les Post-Processors (Notifications de demandes d'amis)
12
+
13
+ ## Architecture du Domaine
14
+
15
+ ```mermaid
16
+ classDiagram
17
+ direction TB
18
+
19
+ namespace DomainLayer {
20
+ class RelationService {
21
+ <<Domain Service>>
22
+ +requestFriendship(userA, userB)
23
+ +acceptFriendship(relationId)
24
+ }
25
+ class FriendshipRelation {
26
+ <<Entity>>
27
+ +id: Uuid
28
+ +requesterId: Uuid
29
+ +addresseeId: Uuid
30
+ +status: RelationStatus
31
+ +accept()
32
+ +reject()
33
+ }
34
+ class RelationStatus {
35
+ <<Value Object>>
36
+ -status: enum
37
+ +isPending()
38
+ +isAccepted()
39
+ }
40
+ class IRelationRepository {
41
+ <<Interface>>
42
+ +save(FriendshipRelation)
43
+ +findByUsers(userA, userB)
44
+ }
45
+ }
46
+
47
+ RelationService --> FriendshipRelation : Manipule
48
+ FriendshipRelation *-- RelationStatus : Possède
49
+ RelationService --> IRelationRepository : Injection de dépendance
50
+ ```
51
+
52
+ ## Structure des Dossiers
53
+
54
+ ```text
55
+ src/
56
+ ├── entities/ # Entités du graphe social (FriendshipRelation, FollowRelation)
57
+ ├── value-objects/ # Status, Type de relation
58
+ ├── services/ # Logique métier orchestrant plusieurs noeuds (RelationService)
59
+ ├── repositories/ # Contrats d'accès aux données (IRelationRepository)
60
+ └── test/ # Spies et Mocks pour tester le domaine isolé
61
+ ```
62
+
63
+ ## Exemples d'Implémentation
64
+
65
+ ### Règle Métier dans l'Entité
66
+
67
+ ```typescript
68
+ // entities/friendship-relation.entity.ts
69
+ export class FriendshipRelation {
70
+ constructor(
71
+ public readonly id: string,
72
+ public readonly requesterId: string,
73
+ public readonly addresseeId: string,
74
+ public status: RelationStatus // Value Object
75
+ ) {
76
+ if (requesterId === addresseeId) {
77
+ throw new DomainError('INVALID_RELATION', 'User cannot befriend themselves');
78
+ }
79
+ }
80
+
81
+ public accept(): void {
82
+ if (!this.status.isPending()) {
83
+ throw new DomainError('INVALID_TRANSITION', 'Only pending requests can be accepted');
84
+ }
85
+ this.status = RelationStatus.ACCEPTED();
86
+ }
87
+ }
88
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volontariapp/domain-social",
3
- "version": "0.9.5",
3
+ "version": "0.9.6",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -39,11 +39,11 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@nestjs/common": "^11.0.1",
42
- "@volontariapp/bridge-nest": "0.3.15",
43
- "@volontariapp/contracts": "4.3.1",
44
- "@volontariapp/errors": "0.6.0",
45
- "@volontariapp/errors-nest": "0.13.0",
46
- "@volontariapp/logger": "0.2.5",
42
+ "@volontariapp/bridge-nest": "0.3.16",
43
+ "@volontariapp/contracts": "4.3.2",
44
+ "@volontariapp/errors": "0.6.1",
45
+ "@volontariapp/errors-nest": "0.13.1",
46
+ "@volontariapp/logger": "0.2.6",
47
47
  "neo4j-driver": "^6.0.1",
48
48
  "reflect-metadata": "^0.2.2"
49
49
  },
@@ -51,7 +51,7 @@
51
51
  "@jest/globals": "^30.3.0",
52
52
  "@types/jest": "^30.0.0",
53
53
  "@types/node": "^22.10.7",
54
- "@volontariapp/testing": "1.0.1",
54
+ "@volontariapp/testing": "1.0.2",
55
55
  "jest": "^30.3.0",
56
56
  "ts-jest": "^29.4.6",
57
57
  "typescript": "5.7.3"