@eventcatalog/create-eventcatalog 4.3.12-beta.1 → 4.3.13
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/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/CreateProduct/examples/index.mdx +194 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/DeleteProduct/examples/index.mdx +161 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/UpdateProduct/examples/index.mdx +182 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductCreated/examples/index.mdx +227 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductDeleted/examples/index.mdx +175 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductUpdated/examples/index.mdx +205 -0
- package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/queries/GetProduct/examples/index.mdx +205 -0
- package/templates/default/domains/Catalog/systems/search-system/services/SearchAPI/queries/SearchProducts/examples/index.mdx +369 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/RegisterCustomer/examples/index.mdx +168 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/UpdateCustomer/examples/index.mdx +168 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerRegistered/examples/index.mdx +201 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerUpdated/examples/index.mdx +194 -0
- package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/queries/GetCustomer/examples/index.mdx +194 -0
- package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/commands/AuthenticateCustomer/examples/index.mdx +198 -0
- package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/events/CustomerAuthenticated/examples/index.mdx +276 -0
- package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentCreated/examples/index.mdx +184 -0
- package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentDelivered/examples/index.mdx +173 -0
- package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentFailed/examples/index.mdx +265 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/commands/ReleaseInventory/examples/index.mdx +246 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryReserved/examples/index.mdx +227 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryUnavailable/examples/index.mdx +229 -0
- package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/queries/GetStockLevel/examples/index.mdx +186 -0
- package/templates/default/domains/Fulfilment/systems/shipping-system/services/CarrierAdapter/commands/CreateShipment/examples/index.mdx +206 -0
- package/templates/default/domains/Fulfilment/systems/warehouse-system/services/PickingWorker/events/OrderPacked/examples/index.mdx +172 -0
- package/templates/default/domains/Fulfilment/systems/warehouse-system/services/WarehouseService/events/OrderReadyForShipping/examples/index.mdx +208 -0
- package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/AuthorizePayment/examples/index.mdx +179 -0
- package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/ReserveInventory/examples/index.mdx +215 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CancelOrder/examples/index.mdx +163 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CreateOrder/examples/index.mdx +246 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCancelled/examples/index.mdx +267 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCompleted/examples/index.mdx +171 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCreated/examples/index.mdx +190 -0
- package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/queries/GetOrder/examples/index.mdx +343 -0
- package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckFailed/examples/index.mdx +271 -0
- package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckPassed/examples/index.mdx +173 -0
- package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/PaymentRequested/examples/index.mdx +191 -0
- package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/RefundRequested/examples/index.mdx +194 -0
- package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentFailed/examples/index.mdx +265 -0
- package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentSucceeded/examples/index.mdx +190 -0
- package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/RefundProcessed/examples/index.mdx +186 -0
- package/templates/default/domains/Reviews/services/RatingAggregator/events/rating-updated/examples/index.mdx +183 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/commands/flag-review/examples/index.mdx +183 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/commands/submit-review/examples/index.mdx +195 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/commands/vote-review-helpful/examples/index.mdx +178 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/events/review-flagged/examples/index.mdx +186 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/events/review-helpful-voted/examples/index.mdx +177 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/events/review-submitted/examples/index.mdx +194 -0
- package/templates/default/domains/Reviews/services/ReviewAPI/queries/get-product-reviews/examples/index.mdx +259 -0
- package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-published/examples/index.mdx +183 -0
- package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-rejected/examples/index.mdx +178 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/AddItemToCart/examples/index.mdx +171 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/CheckoutCart/examples/index.mdx +168 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/RemoveItemFromCart/examples/index.mdx +170 -0
- package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/events/CartCheckedOut/examples/index.mdx +275 -0
- package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/commands/CalculateDiscount/examples/index.mdx +207 -0
- package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/events/DiscountCalculated/examples/index.mdx +190 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Submit a five-star review with a title
|
|
6
|
+
|
|
7
|
+
A customer who bought the classic white T-shirt leaves a full review from their order history page. The storefront sends this command to the Review API, which stores the review and publishes `ReviewSubmitted`.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `reviewId` is generated by the client, so a retried request does not create a duplicate review.
|
|
12
|
+
- `productId` is `prod_tshirt_classic_white` and `customerId` is `cust_4821`.
|
|
13
|
+
- `rating` is `5`, the top of the 1 to 5 star range.
|
|
14
|
+
- `title` (optional, max 120 characters) and `body` (max 5,000 characters) are both set.
|
|
15
|
+
- `submittedAt` is the UTC time the customer pressed submit.
|
|
16
|
+
|
|
17
|
+
### Using this example
|
|
18
|
+
|
|
19
|
+
Check that the Review API accepts the command, stores the review as pending moderation and publishes `ReviewSubmitted` with the same `reviewId`.
|
|
20
|
+
|
|
21
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the SubmitReview schema. The package names and send methods are illustrative.
|
|
22
|
+
|
|
23
|
+
</Column>
|
|
24
|
+
|
|
25
|
+
<Column>
|
|
26
|
+
|
|
27
|
+
<CodeGroup dropdown>
|
|
28
|
+
|
|
29
|
+
```typescript send-submit-review.ts
|
|
30
|
+
import { EventsClient } from '@acme/events';
|
|
31
|
+
import type { SubmitReview } from './schemas/submit-review';
|
|
32
|
+
|
|
33
|
+
const client = new EventsClient({
|
|
34
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const command: SubmitReview = {
|
|
38
|
+
reviewId: '3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90',
|
|
39
|
+
productId: 'prod_tshirt_classic_white',
|
|
40
|
+
customerId: 'cust_4821',
|
|
41
|
+
rating: 5,
|
|
42
|
+
title: 'Perfect everyday tee',
|
|
43
|
+
body: 'Soft, thick cotton and it kept its shape after washing.',
|
|
44
|
+
submittedAt: '2026-09-14T18:22:10Z',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
await client.send('SubmitReview', command);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
```python send_submit_review.py
|
|
51
|
+
import os
|
|
52
|
+
from acme_events import EventsClient
|
|
53
|
+
|
|
54
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
55
|
+
|
|
56
|
+
command = {
|
|
57
|
+
"reviewId": "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
|
|
58
|
+
"productId": "prod_tshirt_classic_white",
|
|
59
|
+
"customerId": "cust_4821",
|
|
60
|
+
"rating": 5,
|
|
61
|
+
"title": "Perfect everyday tee",
|
|
62
|
+
"body": "Soft, thick cotton and it kept its shape after washing.",
|
|
63
|
+
"submittedAt": "2026-09-14T18:22:10Z",
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
client.send("SubmitReview", command)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
```java SendSubmitReview.java
|
|
70
|
+
import com.acme.events.EventsClient;
|
|
71
|
+
import java.util.Map;
|
|
72
|
+
|
|
73
|
+
public class SendSubmitReview {
|
|
74
|
+
public static void main(String[] args) {
|
|
75
|
+
var client = new EventsClient(
|
|
76
|
+
System.getenv("ACME_API_KEY")
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
var command = Map.of(
|
|
80
|
+
"reviewId", "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
|
|
81
|
+
"productId", "prod_tshirt_classic_white",
|
|
82
|
+
"customerId", "cust_4821",
|
|
83
|
+
"rating", 5,
|
|
84
|
+
"title", "Perfect everyday tee",
|
|
85
|
+
"body", "Soft, thick cotton and it kept its shape after washing.",
|
|
86
|
+
"submittedAt", "2026-09-14T18:22:10Z"
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
client.send("SubmitReview", command);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
</CodeGroup>
|
|
95
|
+
|
|
96
|
+
</Column>
|
|
97
|
+
|
|
98
|
+
</Columns>
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
<Columns cols={2}>
|
|
103
|
+
|
|
104
|
+
<Column>
|
|
105
|
+
|
|
106
|
+
## 2. Submit a low rating without a title
|
|
107
|
+
|
|
108
|
+
A customer returns an oversized hoodie and leaves a short two-star review from the mobile app, skipping the optional title.
|
|
109
|
+
|
|
110
|
+
### Payload details
|
|
111
|
+
|
|
112
|
+
- Only the required fields are sent; `title` is omitted.
|
|
113
|
+
- `productId` is `prod_hoodie_oversized_grey` and `customerId` is `cust_1057`.
|
|
114
|
+
- `rating` is `2`, so this review will pull the product's average rating down once it is published.
|
|
115
|
+
- `body` explains the sizing problem in the customer's own words.
|
|
116
|
+
|
|
117
|
+
### Using this example
|
|
118
|
+
|
|
119
|
+
Use this payload to test that a review without a `title` is accepted and that low ratings go through the same moderation path as high ones.
|
|
120
|
+
|
|
121
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the SubmitReview schema. The package names and send methods are illustrative.
|
|
122
|
+
|
|
123
|
+
</Column>
|
|
124
|
+
|
|
125
|
+
<Column>
|
|
126
|
+
|
|
127
|
+
<CodeGroup dropdown>
|
|
128
|
+
|
|
129
|
+
```typescript send-submit-review.ts
|
|
130
|
+
import { EventsClient } from '@acme/events';
|
|
131
|
+
import type { SubmitReview } from './schemas/submit-review';
|
|
132
|
+
|
|
133
|
+
const client = new EventsClient({
|
|
134
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const command: SubmitReview = {
|
|
138
|
+
reviewId: 'a7c4e2d9-1b3f-4c8a-b6e5-9d0f2a1c3e47',
|
|
139
|
+
productId: 'prod_hoodie_oversized_grey',
|
|
140
|
+
customerId: 'cust_1057',
|
|
141
|
+
rating: 2,
|
|
142
|
+
body: 'Nice fabric but the sleeves are too long for a size M.',
|
|
143
|
+
submittedAt: '2026-09-15T09:04:33Z',
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
await client.send('SubmitReview', command);
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```python send_submit_review.py
|
|
150
|
+
import os
|
|
151
|
+
from acme_events import EventsClient
|
|
152
|
+
|
|
153
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
154
|
+
|
|
155
|
+
command = {
|
|
156
|
+
"reviewId": "a7c4e2d9-1b3f-4c8a-b6e5-9d0f2a1c3e47",
|
|
157
|
+
"productId": "prod_hoodie_oversized_grey",
|
|
158
|
+
"customerId": "cust_1057",
|
|
159
|
+
"rating": 2,
|
|
160
|
+
"body": "Nice fabric but the sleeves are too long for a size M.",
|
|
161
|
+
"submittedAt": "2026-09-15T09:04:33Z",
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
client.send("SubmitReview", command)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
```java SendSubmitReview.java
|
|
168
|
+
import com.acme.events.EventsClient;
|
|
169
|
+
import java.util.Map;
|
|
170
|
+
|
|
171
|
+
public class SendSubmitReview {
|
|
172
|
+
public static void main(String[] args) {
|
|
173
|
+
var client = new EventsClient(
|
|
174
|
+
System.getenv("ACME_API_KEY")
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
var command = Map.of(
|
|
178
|
+
"reviewId", "a7c4e2d9-1b3f-4c8a-b6e5-9d0f2a1c3e47",
|
|
179
|
+
"productId", "prod_hoodie_oversized_grey",
|
|
180
|
+
"customerId", "cust_1057",
|
|
181
|
+
"rating", 2,
|
|
182
|
+
"body", "Nice fabric but the sleeves are too long for a size M.",
|
|
183
|
+
"submittedAt", "2026-09-15T09:04:33Z"
|
|
184
|
+
);
|
|
185
|
+
|
|
186
|
+
client.send("SubmitReview", command);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
</CodeGroup>
|
|
192
|
+
|
|
193
|
+
</Column>
|
|
194
|
+
|
|
195
|
+
</Columns>
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Mark a review as helpful
|
|
6
|
+
|
|
7
|
+
A shopper finds the five-star review of the classic white T-shirt useful and taps "Helpful". The storefront sends this command to the Review API, which updates the count and publishes `ReviewHelpfulVoted`.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `reviewId` is the review being voted on.
|
|
12
|
+
- `customerId` is `cust_3314`; each customer can hold one helpful vote per review.
|
|
13
|
+
- `vote` is `helpful`, which adds a vote.
|
|
14
|
+
- `votedAt` is when the customer tapped the button.
|
|
15
|
+
|
|
16
|
+
### Using this example
|
|
17
|
+
|
|
18
|
+
Check that the review's helpful count goes up by one and that sending the same vote again does not count twice.
|
|
19
|
+
|
|
20
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the VoteReviewHelpful schema. The package names and send methods are illustrative.
|
|
21
|
+
|
|
22
|
+
</Column>
|
|
23
|
+
|
|
24
|
+
<Column>
|
|
25
|
+
|
|
26
|
+
<CodeGroup dropdown>
|
|
27
|
+
|
|
28
|
+
```typescript send-vote-review-helpful.ts
|
|
29
|
+
import { EventsClient } from '@acme/events';
|
|
30
|
+
import type { VoteReviewHelpful } from './schemas/vote-review-helpful';
|
|
31
|
+
|
|
32
|
+
const client = new EventsClient({
|
|
33
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const command: VoteReviewHelpful = {
|
|
37
|
+
reviewId: '3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90',
|
|
38
|
+
customerId: 'cust_3314',
|
|
39
|
+
vote: 'helpful',
|
|
40
|
+
votedAt: '2026-09-18T10:02:11Z',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
await client.send('VoteReviewHelpful', command);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```python send_vote_review_helpful.py
|
|
47
|
+
import os
|
|
48
|
+
from acme_events import EventsClient
|
|
49
|
+
|
|
50
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
51
|
+
|
|
52
|
+
command = {
|
|
53
|
+
"reviewId": "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
|
|
54
|
+
"customerId": "cust_3314",
|
|
55
|
+
"vote": "helpful",
|
|
56
|
+
"votedAt": "2026-09-18T10:02:11Z",
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
client.send("VoteReviewHelpful", command)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```java SendVoteReviewHelpful.java
|
|
63
|
+
import com.acme.events.EventsClient;
|
|
64
|
+
import java.util.Map;
|
|
65
|
+
|
|
66
|
+
public class SendVoteReviewHelpful {
|
|
67
|
+
public static void main(String[] args) {
|
|
68
|
+
var client = new EventsClient(
|
|
69
|
+
System.getenv("ACME_API_KEY")
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
var command = Map.of(
|
|
73
|
+
"reviewId", "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
|
|
74
|
+
"customerId", "cust_3314",
|
|
75
|
+
"vote", "helpful",
|
|
76
|
+
"votedAt", "2026-09-18T10:02:11Z"
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
client.send("VoteReviewHelpful", command);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
</CodeGroup>
|
|
85
|
+
|
|
86
|
+
</Column>
|
|
87
|
+
|
|
88
|
+
</Columns>
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
<Columns cols={2}>
|
|
93
|
+
|
|
94
|
+
<Column>
|
|
95
|
+
|
|
96
|
+
## 2. Remove a helpful vote
|
|
97
|
+
|
|
98
|
+
The same shopper changes their mind a few seconds later and taps "Helpful" again to undo the vote.
|
|
99
|
+
|
|
100
|
+
### Payload details
|
|
101
|
+
|
|
102
|
+
- `reviewId` and `customerId` match the earlier vote.
|
|
103
|
+
- `vote` is `remove`, which takes away the customer's existing vote.
|
|
104
|
+
- `votedAt` is later than the original vote.
|
|
105
|
+
|
|
106
|
+
### Using this example
|
|
107
|
+
|
|
108
|
+
Use this payload to test that removing a vote lowers the helpful count by one, and that removing a vote that does not exist leaves the count unchanged.
|
|
109
|
+
|
|
110
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the VoteReviewHelpful schema. The package names and send methods are illustrative.
|
|
111
|
+
|
|
112
|
+
</Column>
|
|
113
|
+
|
|
114
|
+
<Column>
|
|
115
|
+
|
|
116
|
+
<CodeGroup dropdown>
|
|
117
|
+
|
|
118
|
+
```typescript send-vote-review-helpful.ts
|
|
119
|
+
import { EventsClient } from '@acme/events';
|
|
120
|
+
import type { VoteReviewHelpful } from './schemas/vote-review-helpful';
|
|
121
|
+
|
|
122
|
+
const client = new EventsClient({
|
|
123
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const command: VoteReviewHelpful = {
|
|
127
|
+
reviewId: '3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90',
|
|
128
|
+
customerId: 'cust_3314',
|
|
129
|
+
vote: 'remove',
|
|
130
|
+
votedAt: '2026-09-18T10:02:47Z',
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
await client.send('VoteReviewHelpful', command);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```python send_vote_review_helpful.py
|
|
137
|
+
import os
|
|
138
|
+
from acme_events import EventsClient
|
|
139
|
+
|
|
140
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
141
|
+
|
|
142
|
+
command = {
|
|
143
|
+
"reviewId": "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
|
|
144
|
+
"customerId": "cust_3314",
|
|
145
|
+
"vote": "remove",
|
|
146
|
+
"votedAt": "2026-09-18T10:02:47Z",
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
client.send("VoteReviewHelpful", command)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
```java SendVoteReviewHelpful.java
|
|
153
|
+
import com.acme.events.EventsClient;
|
|
154
|
+
import java.util.Map;
|
|
155
|
+
|
|
156
|
+
public class SendVoteReviewHelpful {
|
|
157
|
+
public static void main(String[] args) {
|
|
158
|
+
var client = new EventsClient(
|
|
159
|
+
System.getenv("ACME_API_KEY")
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
var command = Map.of(
|
|
163
|
+
"reviewId", "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
|
|
164
|
+
"customerId", "cust_3314",
|
|
165
|
+
"vote", "remove",
|
|
166
|
+
"votedAt", "2026-09-18T10:02:47Z"
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
client.send("VoteReviewHelpful", command);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
</CodeGroup>
|
|
175
|
+
|
|
176
|
+
</Column>
|
|
177
|
+
|
|
178
|
+
</Columns>
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Publish the first flag on a review
|
|
6
|
+
|
|
7
|
+
The Review API has recorded a customer's off-topic report against a navy baseball cap review. It publishes this event so the Review Moderation Worker can screen the review again.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `reviewId` is the flagged review.
|
|
12
|
+
- `productId` is `prod_cap_baseball_navy`, added so consumers do not need to look up the review.
|
|
13
|
+
- `reason` is `off_topic`, copied from the `FlagReview` command.
|
|
14
|
+
- `flagCount` is `1`, meaning this is the first flag the review has received.
|
|
15
|
+
- `flaggedAt` matches the time the flag was raised.
|
|
16
|
+
|
|
17
|
+
### Using this example
|
|
18
|
+
|
|
19
|
+
A moderation consumer should queue the review for another screening and decide whether to leave it live or publish `ReviewRejected`.
|
|
20
|
+
|
|
21
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewFlagged schema. The package names and publish methods are illustrative.
|
|
22
|
+
|
|
23
|
+
</Column>
|
|
24
|
+
|
|
25
|
+
<Column>
|
|
26
|
+
|
|
27
|
+
<CodeGroup dropdown>
|
|
28
|
+
|
|
29
|
+
```typescript publish-review-flagged.ts
|
|
30
|
+
import { EventsClient } from '@acme/events';
|
|
31
|
+
import type { ReviewFlagged } from './schemas/review-flagged';
|
|
32
|
+
|
|
33
|
+
const client = new EventsClient({
|
|
34
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const event: ReviewFlagged = {
|
|
38
|
+
reviewId: 'b2d6f8a1-4c3e-4a9b-9f7d-5e1c3a8b0d24',
|
|
39
|
+
productId: 'prod_cap_baseball_navy',
|
|
40
|
+
reason: 'off_topic',
|
|
41
|
+
flagCount: 1,
|
|
42
|
+
flaggedAt: '2026-09-16T12:40:18Z',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
await client.publish('ReviewFlagged', event);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```python publish_review_flagged.py
|
|
49
|
+
import os
|
|
50
|
+
from acme_events import EventsClient
|
|
51
|
+
|
|
52
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
53
|
+
|
|
54
|
+
event = {
|
|
55
|
+
"reviewId": "b2d6f8a1-4c3e-4a9b-9f7d-5e1c3a8b0d24",
|
|
56
|
+
"productId": "prod_cap_baseball_navy",
|
|
57
|
+
"reason": "off_topic",
|
|
58
|
+
"flagCount": 1,
|
|
59
|
+
"flaggedAt": "2026-09-16T12:40:18Z",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
client.publish("ReviewFlagged", event)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```java PublishReviewFlagged.java
|
|
66
|
+
import com.acme.events.EventsClient;
|
|
67
|
+
import java.util.Map;
|
|
68
|
+
|
|
69
|
+
public class PublishReviewFlagged {
|
|
70
|
+
public static void main(String[] args) {
|
|
71
|
+
var client = new EventsClient(
|
|
72
|
+
System.getenv("ACME_API_KEY")
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
var event = Map.of(
|
|
76
|
+
"reviewId", "b2d6f8a1-4c3e-4a9b-9f7d-5e1c3a8b0d24",
|
|
77
|
+
"productId", "prod_cap_baseball_navy",
|
|
78
|
+
"reason", "off_topic",
|
|
79
|
+
"flagCount", 1,
|
|
80
|
+
"flaggedAt", "2026-09-16T12:40:18Z"
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
client.publish("ReviewFlagged", event);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
</CodeGroup>
|
|
89
|
+
|
|
90
|
+
</Column>
|
|
91
|
+
|
|
92
|
+
</Columns>
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
<Columns cols={2}>
|
|
97
|
+
|
|
98
|
+
<Column>
|
|
99
|
+
|
|
100
|
+
## 2. Publish a repeat abuse flag
|
|
101
|
+
|
|
102
|
+
A moderator flags a sunset graphic T-shirt review for abuse after two customers have already reported it. The rising `flagCount` tells the moderation worker this review needs urgent attention.
|
|
103
|
+
|
|
104
|
+
### Payload details
|
|
105
|
+
|
|
106
|
+
- `productId` is `prod_tshirt_graphic_sunset`.
|
|
107
|
+
- `reason` is `abuse`, the reason on the latest flag.
|
|
108
|
+
- `flagCount` is `3`: the total number of flags on this review, including this one.
|
|
109
|
+
- `flaggedAt` is the time of the latest flag.
|
|
110
|
+
|
|
111
|
+
### Using this example
|
|
112
|
+
|
|
113
|
+
Use this payload to test any priority rules, for example that reviews with an `abuse` flag or a high `flagCount` are screened first.
|
|
114
|
+
|
|
115
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewFlagged schema. The package names and publish methods are illustrative.
|
|
116
|
+
|
|
117
|
+
</Column>
|
|
118
|
+
|
|
119
|
+
<Column>
|
|
120
|
+
|
|
121
|
+
<CodeGroup dropdown>
|
|
122
|
+
|
|
123
|
+
```typescript publish-review-flagged.ts
|
|
124
|
+
import { EventsClient } from '@acme/events';
|
|
125
|
+
import type { ReviewFlagged } from './schemas/review-flagged';
|
|
126
|
+
|
|
127
|
+
const client = new EventsClient({
|
|
128
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const event: ReviewFlagged = {
|
|
132
|
+
reviewId: 'd8a3c5e7-2f1b-4e9d-b4a6-7c0e3f5a1b82',
|
|
133
|
+
productId: 'prod_tshirt_graphic_sunset',
|
|
134
|
+
reason: 'abuse',
|
|
135
|
+
flagCount: 3,
|
|
136
|
+
flaggedAt: '2026-09-17T08:15:00Z',
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
await client.publish('ReviewFlagged', event);
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```python publish_review_flagged.py
|
|
143
|
+
import os
|
|
144
|
+
from acme_events import EventsClient
|
|
145
|
+
|
|
146
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
147
|
+
|
|
148
|
+
event = {
|
|
149
|
+
"reviewId": "d8a3c5e7-2f1b-4e9d-b4a6-7c0e3f5a1b82",
|
|
150
|
+
"productId": "prod_tshirt_graphic_sunset",
|
|
151
|
+
"reason": "abuse",
|
|
152
|
+
"flagCount": 3,
|
|
153
|
+
"flaggedAt": "2026-09-17T08:15:00Z",
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
client.publish("ReviewFlagged", event)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
```java PublishReviewFlagged.java
|
|
160
|
+
import com.acme.events.EventsClient;
|
|
161
|
+
import java.util.Map;
|
|
162
|
+
|
|
163
|
+
public class PublishReviewFlagged {
|
|
164
|
+
public static void main(String[] args) {
|
|
165
|
+
var client = new EventsClient(
|
|
166
|
+
System.getenv("ACME_API_KEY")
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
var event = Map.of(
|
|
170
|
+
"reviewId", "d8a3c5e7-2f1b-4e9d-b4a6-7c0e3f5a1b82",
|
|
171
|
+
"productId", "prod_tshirt_graphic_sunset",
|
|
172
|
+
"reason", "abuse",
|
|
173
|
+
"flagCount", 3,
|
|
174
|
+
"flaggedAt", "2026-09-17T08:15:00Z"
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
client.publish("ReviewFlagged", event);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
</CodeGroup>
|
|
183
|
+
|
|
184
|
+
</Column>
|
|
185
|
+
|
|
186
|
+
</Columns>
|