@volontariapp/domain-post 3.6.11 → 3.6.12
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/CHANGELOG.md +15 -0
- package/README.md +75 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.6.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- README bump
|
|
8
|
+
|
|
9
|
+
- Updated dependencies []:
|
|
10
|
+
- @volontariapp/contracts@4.3.2
|
|
11
|
+
- @volontariapp/database@3.4.4
|
|
12
|
+
- @volontariapp/errors@0.6.1
|
|
13
|
+
- @volontariapp/errors-nest@0.13.1
|
|
14
|
+
- @volontariapp/logger@0.2.6
|
|
15
|
+
- @volontariapp/messaging@2.10.1
|
|
16
|
+
- @volontariapp/outbox@0.9.41
|
|
17
|
+
|
|
3
18
|
## 3.6.11
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
package/README.md
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# @volontariapp/domain-post
|
|
2
|
+
|
|
3
|
+
## Overview & Domain Driven Design (DDD)
|
|
4
|
+
|
|
5
|
+
Le package `domain-post` contient la **logique métier absolue** relative aux **Actualités (Posts)**.
|
|
6
|
+
Tout comme les autres packages de domaine, il est construit autour des principes de la **Clean Architecture**. Il garantit une isolation parfaite entre les règles de gestion d'un Post et la tuyauterie de l'infrastructure (serveur HTTP, bases de données, Kafka/Redis).
|
|
7
|
+
|
|
8
|
+
Ce package est partagé entre :
|
|
9
|
+
- `ms-post` (API)
|
|
10
|
+
- Les Workers asynchrones de traitement d'images/posts
|
|
11
|
+
- Les Post-Processors (Notifications, Flux)
|
|
12
|
+
|
|
13
|
+
## Architecture du Domaine
|
|
14
|
+
|
|
15
|
+
```mermaid
|
|
16
|
+
graph TD
|
|
17
|
+
subgraph "Domain Layer (Pure TypeScript)"
|
|
18
|
+
PS[PostService]
|
|
19
|
+
PE[PostEntity]
|
|
20
|
+
VO[ContentValueObject]
|
|
21
|
+
IR[IPostRepository]
|
|
22
|
+
|
|
23
|
+
PS -->|Manipule| PE
|
|
24
|
+
PE -->|Contient| VO
|
|
25
|
+
PS -->|Persiste via| IR
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
subgraph "Infrastructure Layer"
|
|
29
|
+
PGR[PostgresPostRepository]
|
|
30
|
+
API[NestJS PostController]
|
|
31
|
+
|
|
32
|
+
PGR -.->|Implémente| IR
|
|
33
|
+
API -->|Invoque| PS
|
|
34
|
+
end
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Structure des Dossiers
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
src/
|
|
41
|
+
├── entities/ # PostEntity, CommentEntity, LikeEntity
|
|
42
|
+
├── value-objects/ # PostContent (validation de longueur, profanité)
|
|
43
|
+
├── services/ # FeedGenerationService, PostModerationService
|
|
44
|
+
├── repositories/ # Interfaces (IPostRepository) et Implémentations SQL
|
|
45
|
+
└── test/ # Stubs et Factories
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Exemples d'Implémentation
|
|
49
|
+
|
|
50
|
+
### L'Entité Post et l'encapsulation
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
// entities/post.entity.ts
|
|
54
|
+
export class PostEntity {
|
|
55
|
+
private constructor(
|
|
56
|
+
public readonly id: string,
|
|
57
|
+
public readonly authorId: string,
|
|
58
|
+
public content: PostContent, // Value Object
|
|
59
|
+
public isPublished: boolean
|
|
60
|
+
) {}
|
|
61
|
+
|
|
62
|
+
// Constructeur statique pour forcer la validation à la création
|
|
63
|
+
public static create(authorId: string, contentText: string): PostEntity {
|
|
64
|
+
const content = new PostContent(contentText);
|
|
65
|
+
return new PostEntity(uuidv4(), authorId, content, false);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public publish(): void {
|
|
69
|
+
if (this.content.isEmpty()) {
|
|
70
|
+
throw new DomainError('POST_EMPTY', 'Cannot publish an empty post');
|
|
71
|
+
}
|
|
72
|
+
this.isPublished = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@volontariapp/domain-post",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.12",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@nestjs/typeorm": "^11.0.1",
|
|
44
44
|
"@types/jest": "^30.0.0",
|
|
45
45
|
"@types/node": "^22.10.7",
|
|
46
|
-
"@volontariapp/testing": "1.0.
|
|
46
|
+
"@volontariapp/testing": "1.0.2",
|
|
47
47
|
"jest": "^30.3.0",
|
|
48
48
|
"pg": "^8.20.0",
|
|
49
49
|
"reflect-metadata": "^0.2.2",
|
|
@@ -54,13 +54,13 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
56
|
"@nestjs/common": "^11.0.1",
|
|
57
|
-
"@volontariapp/contracts": "4.3.
|
|
58
|
-
"@volontariapp/database": "3.4.
|
|
59
|
-
"@volontariapp/errors": "0.6.
|
|
60
|
-
"@volontariapp/errors-nest": "0.13.
|
|
61
|
-
"@volontariapp/logger": "0.2.
|
|
62
|
-
"@volontariapp/messaging": "2.10.
|
|
63
|
-
"@volontariapp/outbox": "0.9.
|
|
57
|
+
"@volontariapp/contracts": "4.3.2",
|
|
58
|
+
"@volontariapp/database": "3.4.4",
|
|
59
|
+
"@volontariapp/errors": "0.6.1",
|
|
60
|
+
"@volontariapp/errors-nest": "0.13.1",
|
|
61
|
+
"@volontariapp/logger": "0.2.6",
|
|
62
|
+
"@volontariapp/messaging": "2.10.1",
|
|
63
|
+
"@volontariapp/outbox": "0.9.41",
|
|
64
64
|
"class-transformer": "^0.5.1"
|
|
65
65
|
}
|
|
66
66
|
}
|