@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,183 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Publish an approved five-star review
|
|
6
|
+
|
|
7
|
+
The Review Moderation Worker has screened the T-shirt review and found no problems, so the review is now visible on the storefront. The Rating Aggregator consumes this event to recalculate the product's rating.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `reviewId` is the review that passed moderation.
|
|
12
|
+
- `productId` is `prod_tshirt_classic_white`, the product whose rating needs updating.
|
|
13
|
+
- `customerId` is included (`cust_4821`) so consumers can link the review to its author.
|
|
14
|
+
- `rating` is `5`, which the aggregator adds to the product's totals.
|
|
15
|
+
- `publishedAt` is when the review went live, shortly after it was submitted.
|
|
16
|
+
|
|
17
|
+
### Using this example
|
|
18
|
+
|
|
19
|
+
The Rating Aggregator should add this `rating` to the product's totals and publish `RatingUpdated` for the same `productId`.
|
|
20
|
+
|
|
21
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewPublished schema. The package names and publish methods are illustrative.
|
|
22
|
+
|
|
23
|
+
</Column>
|
|
24
|
+
|
|
25
|
+
<Column>
|
|
26
|
+
|
|
27
|
+
<CodeGroup dropdown>
|
|
28
|
+
|
|
29
|
+
```typescript publish-review-published.ts
|
|
30
|
+
import { EventsClient } from '@acme/events';
|
|
31
|
+
import type { ReviewPublished } from './schemas/review-published';
|
|
32
|
+
|
|
33
|
+
const client = new EventsClient({
|
|
34
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const event: ReviewPublished = {
|
|
38
|
+
reviewId: '3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90',
|
|
39
|
+
productId: 'prod_tshirt_classic_white',
|
|
40
|
+
customerId: 'cust_4821',
|
|
41
|
+
rating: 5,
|
|
42
|
+
publishedAt: '2026-09-14T18:23:02Z',
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
await client.publish('ReviewPublished', event);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```python publish_review_published.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": "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
|
|
56
|
+
"productId": "prod_tshirt_classic_white",
|
|
57
|
+
"customerId": "cust_4821",
|
|
58
|
+
"rating": 5,
|
|
59
|
+
"publishedAt": "2026-09-14T18:23:02Z",
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
client.publish("ReviewPublished", event)
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
```java PublishReviewPublished.java
|
|
66
|
+
import com.acme.events.EventsClient;
|
|
67
|
+
import java.util.Map;
|
|
68
|
+
|
|
69
|
+
public class PublishReviewPublished {
|
|
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", "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
|
|
77
|
+
"productId", "prod_tshirt_classic_white",
|
|
78
|
+
"customerId", "cust_4821",
|
|
79
|
+
"rating", 5,
|
|
80
|
+
"publishedAt", "2026-09-14T18:23:02Z"
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
client.publish("ReviewPublished", 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 an approved review with only required fields
|
|
101
|
+
|
|
102
|
+
The two-star hoodie review passes moderation. This event carries only the fields the Rating Aggregator needs.
|
|
103
|
+
|
|
104
|
+
### Payload details
|
|
105
|
+
|
|
106
|
+
- `customerId` is optional and left out; the aggregator only needs the product and the rating.
|
|
107
|
+
- `productId` is `prod_hoodie_oversized_grey`.
|
|
108
|
+
- `rating` is `2`, so the product's average rating will drop.
|
|
109
|
+
- `publishedAt` is when the review became visible.
|
|
110
|
+
|
|
111
|
+
### Using this example
|
|
112
|
+
|
|
113
|
+
Use this payload to check that consumers do not depend on `customerId` and that low ratings update the average correctly.
|
|
114
|
+
|
|
115
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewPublished schema. The package names and publish methods are illustrative.
|
|
116
|
+
|
|
117
|
+
</Column>
|
|
118
|
+
|
|
119
|
+
<Column>
|
|
120
|
+
|
|
121
|
+
<CodeGroup dropdown>
|
|
122
|
+
|
|
123
|
+
```typescript publish-review-published.ts
|
|
124
|
+
import { EventsClient } from '@acme/events';
|
|
125
|
+
import type { ReviewPublished } from './schemas/review-published';
|
|
126
|
+
|
|
127
|
+
const client = new EventsClient({
|
|
128
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
const event: ReviewPublished = {
|
|
132
|
+
reviewId: 'a7c4e2d9-1b3f-4c8a-b6e5-9d0f2a1c3e47',
|
|
133
|
+
productId: 'prod_hoodie_oversized_grey',
|
|
134
|
+
rating: 2,
|
|
135
|
+
publishedAt: '2026-09-15T09:05:38Z',
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
await client.publish('ReviewPublished', event);
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
```python publish_review_published.py
|
|
142
|
+
import os
|
|
143
|
+
from acme_events import EventsClient
|
|
144
|
+
|
|
145
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
146
|
+
|
|
147
|
+
event = {
|
|
148
|
+
"reviewId": "a7c4e2d9-1b3f-4c8a-b6e5-9d0f2a1c3e47",
|
|
149
|
+
"productId": "prod_hoodie_oversized_grey",
|
|
150
|
+
"rating": 2,
|
|
151
|
+
"publishedAt": "2026-09-15T09:05:38Z",
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
client.publish("ReviewPublished", event)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```java PublishReviewPublished.java
|
|
158
|
+
import com.acme.events.EventsClient;
|
|
159
|
+
import java.util.Map;
|
|
160
|
+
|
|
161
|
+
public class PublishReviewPublished {
|
|
162
|
+
public static void main(String[] args) {
|
|
163
|
+
var client = new EventsClient(
|
|
164
|
+
System.getenv("ACME_API_KEY")
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
var event = Map.of(
|
|
168
|
+
"reviewId", "a7c4e2d9-1b3f-4c8a-b6e5-9d0f2a1c3e47",
|
|
169
|
+
"productId", "prod_hoodie_oversized_grey",
|
|
170
|
+
"rating", 2,
|
|
171
|
+
"publishedAt", "2026-09-15T09:05:38Z"
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
client.publish("ReviewPublished", event);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
</CodeGroup>
|
|
180
|
+
|
|
181
|
+
</Column>
|
|
182
|
+
|
|
183
|
+
</Columns>
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Reject a spam review
|
|
6
|
+
|
|
7
|
+
A review on the navy baseball cap contains a promotional link for a discount site. The Review Moderation Worker rejects it as spam, so it is kept for audit but never shown on the storefront.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `reviewId` identifies the rejected review.
|
|
12
|
+
- `productId` is `prod_cap_baseball_navy`.
|
|
13
|
+
- `reason` is `spam`, one of `spam`, `abuse`, `off_topic` or `policy_violation`.
|
|
14
|
+
- `rejectedAt` is when the moderation decision was made.
|
|
15
|
+
|
|
16
|
+
### Using this example
|
|
17
|
+
|
|
18
|
+
Check that the review stays hidden, the product's rating is not changed, and the `reason` is recorded against the review for audit.
|
|
19
|
+
|
|
20
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewRejected schema. The package names and publish methods are illustrative.
|
|
21
|
+
|
|
22
|
+
</Column>
|
|
23
|
+
|
|
24
|
+
<Column>
|
|
25
|
+
|
|
26
|
+
<CodeGroup dropdown>
|
|
27
|
+
|
|
28
|
+
```typescript publish-review-rejected.ts
|
|
29
|
+
import { EventsClient } from '@acme/events';
|
|
30
|
+
import type { ReviewRejected } from './schemas/review-rejected';
|
|
31
|
+
|
|
32
|
+
const client = new EventsClient({
|
|
33
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const event: ReviewRejected = {
|
|
37
|
+
reviewId: 'c9e1f4a2-7b6d-4d3c-8e2f-1a5b9c7d0e63',
|
|
38
|
+
productId: 'prod_cap_baseball_navy',
|
|
39
|
+
reason: 'spam',
|
|
40
|
+
rejectedAt: '2026-09-16T07:41:19Z',
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
await client.publish('ReviewRejected', event);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```python publish_review_rejected.py
|
|
47
|
+
import os
|
|
48
|
+
from acme_events import EventsClient
|
|
49
|
+
|
|
50
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
51
|
+
|
|
52
|
+
event = {
|
|
53
|
+
"reviewId": "c9e1f4a2-7b6d-4d3c-8e2f-1a5b9c7d0e63",
|
|
54
|
+
"productId": "prod_cap_baseball_navy",
|
|
55
|
+
"reason": "spam",
|
|
56
|
+
"rejectedAt": "2026-09-16T07:41:19Z",
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
client.publish("ReviewRejected", event)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
```java PublishReviewRejected.java
|
|
63
|
+
import com.acme.events.EventsClient;
|
|
64
|
+
import java.util.Map;
|
|
65
|
+
|
|
66
|
+
public class PublishReviewRejected {
|
|
67
|
+
public static void main(String[] args) {
|
|
68
|
+
var client = new EventsClient(
|
|
69
|
+
System.getenv("ACME_API_KEY")
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
var event = Map.of(
|
|
73
|
+
"reviewId", "c9e1f4a2-7b6d-4d3c-8e2f-1a5b9c7d0e63",
|
|
74
|
+
"productId", "prod_cap_baseball_navy",
|
|
75
|
+
"reason", "spam",
|
|
76
|
+
"rejectedAt", "2026-09-16T07:41:19Z"
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
client.publish("ReviewRejected", event);
|
|
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. Reject a review that breaks the content policy
|
|
97
|
+
|
|
98
|
+
A review on the black zip hoodie includes a delivery driver's full name and phone number. Sharing personal details breaks the review policy, so the worker rejects it.
|
|
99
|
+
|
|
100
|
+
### Payload details
|
|
101
|
+
|
|
102
|
+
- `productId` is `prod_hoodie_zip_black`.
|
|
103
|
+
- `reason` is `policy_violation`, used when a review is on topic but breaks a content rule.
|
|
104
|
+
- `rejectedAt` is the UTC time of the decision.
|
|
105
|
+
|
|
106
|
+
### Using this example
|
|
107
|
+
|
|
108
|
+
Use this payload to test that each `reason` value maps to the right message shown to the customer who wrote the review.
|
|
109
|
+
|
|
110
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewRejected schema. The package names and publish methods are illustrative.
|
|
111
|
+
|
|
112
|
+
</Column>
|
|
113
|
+
|
|
114
|
+
<Column>
|
|
115
|
+
|
|
116
|
+
<CodeGroup dropdown>
|
|
117
|
+
|
|
118
|
+
```typescript publish-review-rejected.ts
|
|
119
|
+
import { EventsClient } from '@acme/events';
|
|
120
|
+
import type { ReviewRejected } from './schemas/review-rejected';
|
|
121
|
+
|
|
122
|
+
const client = new EventsClient({
|
|
123
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const event: ReviewRejected = {
|
|
127
|
+
reviewId: 'e4b7d1c3-9a2f-4b6e-a8d5-2c7f0e9b1a36',
|
|
128
|
+
productId: 'prod_hoodie_zip_black',
|
|
129
|
+
reason: 'policy_violation',
|
|
130
|
+
rejectedAt: '2026-09-16T14:02:55Z',
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
await client.publish('ReviewRejected', event);
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
```python publish_review_rejected.py
|
|
137
|
+
import os
|
|
138
|
+
from acme_events import EventsClient
|
|
139
|
+
|
|
140
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
141
|
+
|
|
142
|
+
event = {
|
|
143
|
+
"reviewId": "e4b7d1c3-9a2f-4b6e-a8d5-2c7f0e9b1a36",
|
|
144
|
+
"productId": "prod_hoodie_zip_black",
|
|
145
|
+
"reason": "policy_violation",
|
|
146
|
+
"rejectedAt": "2026-09-16T14:02:55Z",
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
client.publish("ReviewRejected", event)
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
```java PublishReviewRejected.java
|
|
153
|
+
import com.acme.events.EventsClient;
|
|
154
|
+
import java.util.Map;
|
|
155
|
+
|
|
156
|
+
public class PublishReviewRejected {
|
|
157
|
+
public static void main(String[] args) {
|
|
158
|
+
var client = new EventsClient(
|
|
159
|
+
System.getenv("ACME_API_KEY")
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
var event = Map.of(
|
|
163
|
+
"reviewId", "e4b7d1c3-9a2f-4b6e-a8d5-2c7f0e9b1a36",
|
|
164
|
+
"productId", "prod_hoodie_zip_black",
|
|
165
|
+
"reason", "policy_violation",
|
|
166
|
+
"rejectedAt", "2026-09-16T14:02:55Z"
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
client.publish("ReviewRejected", event);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
</CodeGroup>
|
|
175
|
+
|
|
176
|
+
</Column>
|
|
177
|
+
|
|
178
|
+
</Columns>
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Add a single T-shirt to a cart
|
|
6
|
+
|
|
7
|
+
A shopper taps **Add to basket** on a T-shirt product page. The storefront sends `AddItemToCart` to the Cart API, which adds the line to the cart and saves it to the cart database.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `cartId` identifies the shopper's open cart.
|
|
12
|
+
- `productId` is the catalogue ID of the T-shirt.
|
|
13
|
+
- `quantity` is `1`, the storefront default for a single click.
|
|
14
|
+
|
|
15
|
+
### Using this example
|
|
16
|
+
|
|
17
|
+
Check that the cart now holds one T-shirt line with a quantity of 1, and that a second identical command increases the quantity to 2 rather than adding a new line.
|
|
18
|
+
|
|
19
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the AddItemToCart schema. The package names and send methods are illustrative.
|
|
20
|
+
|
|
21
|
+
</Column>
|
|
22
|
+
|
|
23
|
+
<Column>
|
|
24
|
+
|
|
25
|
+
<CodeGroup dropdown>
|
|
26
|
+
|
|
27
|
+
```typescript send-add-item-to-cart.ts
|
|
28
|
+
import { EventsClient } from '@acme/events';
|
|
29
|
+
import type { AddItemToCart } from './schemas/add-item-to-cart';
|
|
30
|
+
|
|
31
|
+
const client = new EventsClient({
|
|
32
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const command: AddItemToCart = {
|
|
36
|
+
cartId: 'a7c3e9f1-2b4d-4e6a-8f1c-3d5b7e9a1c24',
|
|
37
|
+
productId: '0e8f4b2a-7c1d-4f3e-9a5b-6d2c8e1f7a93',
|
|
38
|
+
quantity: 1,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
await client.send('AddItemToCart', command);
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```python send_add_item_to_cart.py
|
|
45
|
+
import os
|
|
46
|
+
from acme_events import EventsClient
|
|
47
|
+
|
|
48
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
49
|
+
|
|
50
|
+
command = {
|
|
51
|
+
"cartId": "a7c3e9f1-2b4d-4e6a-8f1c-3d5b7e9a1c24",
|
|
52
|
+
"productId": "0e8f4b2a-7c1d-4f3e-9a5b-6d2c8e1f7a93",
|
|
53
|
+
"quantity": 1,
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
client.send("AddItemToCart", command)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
```java SendAddItemToCart.java
|
|
60
|
+
import com.acme.events.EventsClient;
|
|
61
|
+
import java.util.Map;
|
|
62
|
+
|
|
63
|
+
public class SendAddItemToCart {
|
|
64
|
+
public static void main(String[] args) {
|
|
65
|
+
var client = new EventsClient(
|
|
66
|
+
System.getenv("ACME_API_KEY")
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
var command = Map.of(
|
|
70
|
+
"cartId", "a7c3e9f1-2b4d-4e6a-8f1c-3d5b7e9a1c24",
|
|
71
|
+
"productId", "0e8f4b2a-7c1d-4f3e-9a5b-6d2c8e1f7a93",
|
|
72
|
+
"quantity", 1
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
client.send("AddItemToCart", command);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
</CodeGroup>
|
|
81
|
+
|
|
82
|
+
</Column>
|
|
83
|
+
|
|
84
|
+
</Columns>
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
<Columns cols={2}>
|
|
89
|
+
|
|
90
|
+
<Column>
|
|
91
|
+
|
|
92
|
+
## 2. Add several caps in one go
|
|
93
|
+
|
|
94
|
+
A shopper picks a quantity of 3 in the quantity selector before adding a cap to the same cart. The Cart API adds all three units in one command.
|
|
95
|
+
|
|
96
|
+
### Payload details
|
|
97
|
+
|
|
98
|
+
- `cartId` is the same cart as in the first example.
|
|
99
|
+
- `productId` is the catalogue ID of the cap.
|
|
100
|
+
- `quantity` is `3`; it must be at least 1.
|
|
101
|
+
|
|
102
|
+
### Using this example
|
|
103
|
+
|
|
104
|
+
Check that the cap line has a quantity of 3, and that a `quantity` of 0 is rejected with a `400` response.
|
|
105
|
+
|
|
106
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the AddItemToCart schema. The package names and send methods are illustrative.
|
|
107
|
+
|
|
108
|
+
</Column>
|
|
109
|
+
|
|
110
|
+
<Column>
|
|
111
|
+
|
|
112
|
+
<CodeGroup dropdown>
|
|
113
|
+
|
|
114
|
+
```typescript send-add-item-to-cart.ts
|
|
115
|
+
import { EventsClient } from '@acme/events';
|
|
116
|
+
import type { AddItemToCart } from './schemas/add-item-to-cart';
|
|
117
|
+
|
|
118
|
+
const client = new EventsClient({
|
|
119
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
const command: AddItemToCart = {
|
|
123
|
+
cartId: 'a7c3e9f1-2b4d-4e6a-8f1c-3d5b7e9a1c24',
|
|
124
|
+
productId: '8d4f6a2c-3e5b-4c7d-9f1a-5b7d9e3c1a46',
|
|
125
|
+
quantity: 3,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
await client.send('AddItemToCart', command);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
```python send_add_item_to_cart.py
|
|
132
|
+
import os
|
|
133
|
+
from acme_events import EventsClient
|
|
134
|
+
|
|
135
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
136
|
+
|
|
137
|
+
command = {
|
|
138
|
+
"cartId": "a7c3e9f1-2b4d-4e6a-8f1c-3d5b7e9a1c24",
|
|
139
|
+
"productId": "8d4f6a2c-3e5b-4c7d-9f1a-5b7d9e3c1a46",
|
|
140
|
+
"quantity": 3,
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
client.send("AddItemToCart", command)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```java SendAddItemToCart.java
|
|
147
|
+
import com.acme.events.EventsClient;
|
|
148
|
+
import java.util.Map;
|
|
149
|
+
|
|
150
|
+
public class SendAddItemToCart {
|
|
151
|
+
public static void main(String[] args) {
|
|
152
|
+
var client = new EventsClient(
|
|
153
|
+
System.getenv("ACME_API_KEY")
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
var command = Map.of(
|
|
157
|
+
"cartId", "a7c3e9f1-2b4d-4e6a-8f1c-3d5b7e9a1c24",
|
|
158
|
+
"productId", "8d4f6a2c-3e5b-4c7d-9f1a-5b7d9e3c1a46",
|
|
159
|
+
"quantity", 3
|
|
160
|
+
);
|
|
161
|
+
|
|
162
|
+
client.send("AddItemToCart", command);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
</CodeGroup>
|
|
168
|
+
|
|
169
|
+
</Column>
|
|
170
|
+
|
|
171
|
+
</Columns>
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Check out without a promotion code
|
|
6
|
+
|
|
7
|
+
A returning customer clicks **Checkout** with a basket of T-shirts and no voucher. The Cart API prices the cart and, on success, publishes `CartCheckedOut`.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `cartId` is the cart being checked out.
|
|
12
|
+
- `customerId` is the signed-in customer.
|
|
13
|
+
- `promotionCode` is omitted, so only automatic promotions can apply.
|
|
14
|
+
|
|
15
|
+
### Using this example
|
|
16
|
+
|
|
17
|
+
Check that the cart is locked and a `CartCheckedOut` event is published for the same `cartId` and `customerId`. A second checkout of the same cart should return `409`.
|
|
18
|
+
|
|
19
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the CheckoutCart schema. The package names and send methods are illustrative.
|
|
20
|
+
|
|
21
|
+
</Column>
|
|
22
|
+
|
|
23
|
+
<Column>
|
|
24
|
+
|
|
25
|
+
<CodeGroup dropdown>
|
|
26
|
+
|
|
27
|
+
```typescript send-checkout-cart.ts
|
|
28
|
+
import { EventsClient } from '@acme/events';
|
|
29
|
+
import type { CheckoutCart } from './schemas/checkout-cart';
|
|
30
|
+
|
|
31
|
+
const client = new EventsClient({
|
|
32
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const command: CheckoutCart = {
|
|
36
|
+
cartId: 'c1d2e3f4-5a6b-4c7d-8e9f-0a1b2c3d4e5f',
|
|
37
|
+
customerId: '7a1e5c9d-8b3f-4f2a-a6d4-2e9c0b7f3d51',
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
await client.send('CheckoutCart', command);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```python send_checkout_cart.py
|
|
44
|
+
import os
|
|
45
|
+
from acme_events import EventsClient
|
|
46
|
+
|
|
47
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
48
|
+
|
|
49
|
+
command = {
|
|
50
|
+
"cartId": "c1d2e3f4-5a6b-4c7d-8e9f-0a1b2c3d4e5f",
|
|
51
|
+
"customerId": "7a1e5c9d-8b3f-4f2a-a6d4-2e9c0b7f3d51",
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
client.send("CheckoutCart", command)
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
```java SendCheckoutCart.java
|
|
58
|
+
import com.acme.events.EventsClient;
|
|
59
|
+
import java.util.Map;
|
|
60
|
+
|
|
61
|
+
public class SendCheckoutCart {
|
|
62
|
+
public static void main(String[] args) {
|
|
63
|
+
var client = new EventsClient(
|
|
64
|
+
System.getenv("ACME_API_KEY")
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
var command = Map.of(
|
|
68
|
+
"cartId", "c1d2e3f4-5a6b-4c7d-8e9f-0a1b2c3d4e5f",
|
|
69
|
+
"customerId", "7a1e5c9d-8b3f-4f2a-a6d4-2e9c0b7f3d51"
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
client.send("CheckoutCart", command);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
</CodeGroup>
|
|
78
|
+
|
|
79
|
+
</Column>
|
|
80
|
+
|
|
81
|
+
</Columns>
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
<Columns cols={2}>
|
|
86
|
+
|
|
87
|
+
<Column>
|
|
88
|
+
|
|
89
|
+
## 2. Check out with an autumn voucher
|
|
90
|
+
|
|
91
|
+
A customer enters the voucher code `AUTUMN10` at checkout. The Cart API asks the Promotion Service to calculate the discount before it completes the checkout.
|
|
92
|
+
|
|
93
|
+
### Payload details
|
|
94
|
+
|
|
95
|
+
- `cartId` is the cart holding T-shirts, a hoodie and a cap.
|
|
96
|
+
- `customerId` is the customer who owns the cart.
|
|
97
|
+
- `promotionCode` is `AUTUMN10`, a 10% off voucher.
|
|
98
|
+
|
|
99
|
+
### Using this example
|
|
100
|
+
|
|
101
|
+
Check that a `CalculateDiscount` command is sent with the promotion code, and that the resulting `CartCheckedOut` event includes the discount.
|
|
102
|
+
|
|
103
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the CheckoutCart schema. The package names and send methods are illustrative.
|
|
104
|
+
|
|
105
|
+
</Column>
|
|
106
|
+
|
|
107
|
+
<Column>
|
|
108
|
+
|
|
109
|
+
<CodeGroup dropdown>
|
|
110
|
+
|
|
111
|
+
```typescript send-checkout-cart.ts
|
|
112
|
+
import { EventsClient } from '@acme/events';
|
|
113
|
+
import type { CheckoutCart } from './schemas/checkout-cart';
|
|
114
|
+
|
|
115
|
+
const client = new EventsClient({
|
|
116
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
const command: CheckoutCart = {
|
|
120
|
+
cartId: 'a7c3e9f1-2b4d-4e6a-8f1c-3d5b7e9a1c24',
|
|
121
|
+
customerId: '3f2c8a91-6b4e-4d7a-9c1f-8e5b2a7d4c60',
|
|
122
|
+
promotionCode: 'AUTUMN10',
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
await client.send('CheckoutCart', command);
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
```python send_checkout_cart.py
|
|
129
|
+
import os
|
|
130
|
+
from acme_events import EventsClient
|
|
131
|
+
|
|
132
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
133
|
+
|
|
134
|
+
command = {
|
|
135
|
+
"cartId": "a7c3e9f1-2b4d-4e6a-8f1c-3d5b7e9a1c24",
|
|
136
|
+
"customerId": "3f2c8a91-6b4e-4d7a-9c1f-8e5b2a7d4c60",
|
|
137
|
+
"promotionCode": "AUTUMN10",
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
client.send("CheckoutCart", command)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
```java SendCheckoutCart.java
|
|
144
|
+
import com.acme.events.EventsClient;
|
|
145
|
+
import java.util.Map;
|
|
146
|
+
|
|
147
|
+
public class SendCheckoutCart {
|
|
148
|
+
public static void main(String[] args) {
|
|
149
|
+
var client = new EventsClient(
|
|
150
|
+
System.getenv("ACME_API_KEY")
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
var command = Map.of(
|
|
154
|
+
"cartId", "a7c3e9f1-2b4d-4e6a-8f1c-3d5b7e9a1c24",
|
|
155
|
+
"customerId", "3f2c8a91-6b4e-4d7a-9c1f-8e5b2a7d4c60",
|
|
156
|
+
"promotionCode", "AUTUMN10"
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
client.send("CheckoutCart", command);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
</CodeGroup>
|
|
165
|
+
|
|
166
|
+
</Column>
|
|
167
|
+
|
|
168
|
+
</Columns>
|