@eventcatalog/create-eventcatalog 4.3.12 → 4.3.14-beta.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.
- package/LICENSE +0 -10
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/templates/amazon-api-gateway/README-template.md +4 -0
- package/templates/asyncapi/README-template.md +4 -0
- package/templates/asyncapi/env +0 -5
- package/templates/confluent/README-template.md +4 -0
- package/templates/default/README-template.md +4 -0
- 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
- package/templates/default/env +0 -5
- package/templates/empty/README-template.md +4 -0
- package/templates/empty/env +0 -5
- package/templates/eventbridge/README-template.md +4 -0
- package/templates/graphql/README-template.md +4 -0
- package/templates/graphql/env +0 -5
- package/templates/openapi/README-template.md +4 -0
- package/templates/openapi/env +0 -5
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Publish a newly created draft product
|
|
6
|
+
|
|
7
|
+
The Product API has just stored the Embroidered Logo Cap as a draft, so ProductCreated is published with only the required product fields. The Search System consumes it to index the new product.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `eventId` is unique to this event; consumers can use it to ignore duplicate deliveries.
|
|
12
|
+
- `occurredAt` is the ISO-8601 UTC time the product was created.
|
|
13
|
+
- `product.status` is `DRAFT`, so the product is not yet on sale.
|
|
14
|
+
- `product.price` is `1499` in minor units, with `product.currency` set to `GBP`.
|
|
15
|
+
- `product.description` and `product.category` are optional and omitted.
|
|
16
|
+
|
|
17
|
+
The price is **1,499 pence (£14.99)**.
|
|
18
|
+
|
|
19
|
+
### Using this example
|
|
20
|
+
|
|
21
|
+
Use this to check how the search consumer handles `DRAFT` products and products without a category, for example indexing them without showing them to shoppers.
|
|
22
|
+
|
|
23
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ProductCreated schema. The package names and publish methods are illustrative.
|
|
24
|
+
|
|
25
|
+
</Column>
|
|
26
|
+
|
|
27
|
+
<Column>
|
|
28
|
+
|
|
29
|
+
<CodeGroup dropdown>
|
|
30
|
+
|
|
31
|
+
```typescript publish-product-created.ts
|
|
32
|
+
import { EventsClient } from '@acme/events';
|
|
33
|
+
import type { ProductCreated } from './schemas/product-created';
|
|
34
|
+
|
|
35
|
+
const client = new EventsClient({
|
|
36
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
const event: ProductCreated = {
|
|
40
|
+
eventId: 'b2d4f6a8-0c1e-4a3b-9d5f-7e9a1c3b5d6e',
|
|
41
|
+
occurredAt: '2026-09-11T08:12:45Z',
|
|
42
|
+
product: {
|
|
43
|
+
productId: 'a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71',
|
|
44
|
+
sku: 'CAP-LOGO-NVY',
|
|
45
|
+
name: 'Embroidered Logo Cap',
|
|
46
|
+
price: 1499,
|
|
47
|
+
currency: 'GBP',
|
|
48
|
+
status: 'DRAFT',
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
await client.publish('ProductCreated', event);
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```python publish_product_created.py
|
|
56
|
+
import os
|
|
57
|
+
from acme_events import EventsClient
|
|
58
|
+
|
|
59
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
60
|
+
|
|
61
|
+
event = {
|
|
62
|
+
"eventId": "b2d4f6a8-0c1e-4a3b-9d5f-7e9a1c3b5d6e",
|
|
63
|
+
"occurredAt": "2026-09-11T08:12:45Z",
|
|
64
|
+
"product": {
|
|
65
|
+
"productId": "a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71",
|
|
66
|
+
"sku": "CAP-LOGO-NVY",
|
|
67
|
+
"name": "Embroidered Logo Cap",
|
|
68
|
+
"price": 1499,
|
|
69
|
+
"currency": "GBP",
|
|
70
|
+
"status": "DRAFT",
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
client.publish("ProductCreated", event)
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
```java PublishProductCreated.java
|
|
78
|
+
import com.acme.events.EventsClient;
|
|
79
|
+
import java.util.Map;
|
|
80
|
+
|
|
81
|
+
public class PublishProductCreated {
|
|
82
|
+
public static void main(String[] args) {
|
|
83
|
+
var client = new EventsClient(
|
|
84
|
+
System.getenv("ACME_API_KEY")
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
var event = Map.of(
|
|
88
|
+
"eventId", "b2d4f6a8-0c1e-4a3b-9d5f-7e9a1c3b5d6e",
|
|
89
|
+
"occurredAt", "2026-09-11T08:12:45Z",
|
|
90
|
+
"product", Map.of(
|
|
91
|
+
"productId", "a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71",
|
|
92
|
+
"sku", "CAP-LOGO-NVY",
|
|
93
|
+
"name", "Embroidered Logo Cap",
|
|
94
|
+
"price", 1499,
|
|
95
|
+
"currency", "GBP",
|
|
96
|
+
"status", "DRAFT"
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
client.publish("ProductCreated", event);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
</CodeGroup>
|
|
106
|
+
|
|
107
|
+
</Column>
|
|
108
|
+
|
|
109
|
+
</Columns>
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
<Columns cols={2}>
|
|
114
|
+
|
|
115
|
+
<Column>
|
|
116
|
+
|
|
117
|
+
## 2. Publish an active product with full details
|
|
118
|
+
|
|
119
|
+
The Heavyweight Zip Hoodie was created as `ACTIVE` with every field filled in. The Search System indexes it straight away so shoppers can find it.
|
|
120
|
+
|
|
121
|
+
### Payload details
|
|
122
|
+
|
|
123
|
+
- `eventId` and `occurredAt` identify this event and when the product was created.
|
|
124
|
+
- `product.productId` is the identifier the Product API assigned to the hoodie.
|
|
125
|
+
- `product.sku` is `HOODIE-ZIP-GRY-L`.
|
|
126
|
+
- `product.description` and `product.category` (`hoodies`) are both present, so the search document can be fully populated.
|
|
127
|
+
- `product.status` is `ACTIVE`, so the product is on sale.
|
|
128
|
+
|
|
129
|
+
The price is **4,999 pence (£49.99)**.
|
|
130
|
+
|
|
131
|
+
### Using this example
|
|
132
|
+
|
|
133
|
+
A search consumer should index every field, including `category` for filtering, and the product should appear in results for a search such as "hoodie".
|
|
134
|
+
|
|
135
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ProductCreated schema. The package names and publish methods are illustrative.
|
|
136
|
+
|
|
137
|
+
</Column>
|
|
138
|
+
|
|
139
|
+
<Column>
|
|
140
|
+
|
|
141
|
+
<CodeGroup dropdown>
|
|
142
|
+
|
|
143
|
+
```typescript publish-product-created.ts
|
|
144
|
+
import { EventsClient } from '@acme/events';
|
|
145
|
+
import type { ProductCreated } from './schemas/product-created';
|
|
146
|
+
|
|
147
|
+
const client = new EventsClient({
|
|
148
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const event: ProductCreated = {
|
|
152
|
+
eventId: 'd8f0a2c4-6e8b-4d1f-b3a5-9c7e1f2a4b68',
|
|
153
|
+
occurredAt: '2026-09-12T10:30:00Z',
|
|
154
|
+
product: {
|
|
155
|
+
productId: 'c9e1f3a5-6b2d-4f7e-a8c0-1d3e5f7a9b24',
|
|
156
|
+
sku: 'HOODIE-ZIP-GRY-L',
|
|
157
|
+
name: 'Heavyweight Zip Hoodie',
|
|
158
|
+
description: 'Brushed-back cotton hoodie with a full-length zip.',
|
|
159
|
+
price: 4999,
|
|
160
|
+
currency: 'GBP',
|
|
161
|
+
category: 'hoodies',
|
|
162
|
+
status: 'ACTIVE',
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
await client.publish('ProductCreated', event);
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
```python publish_product_created.py
|
|
170
|
+
import os
|
|
171
|
+
from acme_events import EventsClient
|
|
172
|
+
|
|
173
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
174
|
+
|
|
175
|
+
event = {
|
|
176
|
+
"eventId": "d8f0a2c4-6e8b-4d1f-b3a5-9c7e1f2a4b68",
|
|
177
|
+
"occurredAt": "2026-09-12T10:30:00Z",
|
|
178
|
+
"product": {
|
|
179
|
+
"productId": "c9e1f3a5-6b2d-4f7e-a8c0-1d3e5f7a9b24",
|
|
180
|
+
"sku": "HOODIE-ZIP-GRY-L",
|
|
181
|
+
"name": "Heavyweight Zip Hoodie",
|
|
182
|
+
"description": "Brushed-back cotton hoodie with a full-length zip.",
|
|
183
|
+
"price": 4999,
|
|
184
|
+
"currency": "GBP",
|
|
185
|
+
"category": "hoodies",
|
|
186
|
+
"status": "ACTIVE",
|
|
187
|
+
},
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
client.publish("ProductCreated", event)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
```java PublishProductCreated.java
|
|
194
|
+
import com.acme.events.EventsClient;
|
|
195
|
+
import java.util.Map;
|
|
196
|
+
|
|
197
|
+
public class PublishProductCreated {
|
|
198
|
+
public static void main(String[] args) {
|
|
199
|
+
var client = new EventsClient(
|
|
200
|
+
System.getenv("ACME_API_KEY")
|
|
201
|
+
);
|
|
202
|
+
|
|
203
|
+
var event = Map.of(
|
|
204
|
+
"eventId", "d8f0a2c4-6e8b-4d1f-b3a5-9c7e1f2a4b68",
|
|
205
|
+
"occurredAt", "2026-09-12T10:30:00Z",
|
|
206
|
+
"product", Map.of(
|
|
207
|
+
"productId", "c9e1f3a5-6b2d-4f7e-a8c0-1d3e5f7a9b24",
|
|
208
|
+
"sku", "HOODIE-ZIP-GRY-L",
|
|
209
|
+
"name", "Heavyweight Zip Hoodie",
|
|
210
|
+
"description", "Brushed-back cotton hoodie with a full-length zip.",
|
|
211
|
+
"price", 4999,
|
|
212
|
+
"currency", "GBP",
|
|
213
|
+
"category", "hoodies",
|
|
214
|
+
"status", "ACTIVE"
|
|
215
|
+
)
|
|
216
|
+
);
|
|
217
|
+
|
|
218
|
+
client.publish("ProductCreated", event);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
</CodeGroup>
|
|
224
|
+
|
|
225
|
+
</Column>
|
|
226
|
+
|
|
227
|
+
</Columns>
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Publish a deletion without a reason
|
|
6
|
+
|
|
7
|
+
A bucket hat listing added by mistake has been removed through the Product API. No reason was given, so the event carries only the required fields. The Search System removes the product from its index.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `eventId` is unique to this event and can be used to ignore duplicate deliveries.
|
|
12
|
+
- `occurredAt` is the ISO-8601 UTC time the product was deleted.
|
|
13
|
+
- `productId` identifies the product to remove.
|
|
14
|
+
- `reason` is optional and omitted.
|
|
15
|
+
|
|
16
|
+
### Using this example
|
|
17
|
+
|
|
18
|
+
A consumer should remove the product by `productId` and must not fail when `reason` is missing.
|
|
19
|
+
|
|
20
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ProductDeleted schema. The package names and publish methods are illustrative.
|
|
21
|
+
|
|
22
|
+
</Column>
|
|
23
|
+
|
|
24
|
+
<Column>
|
|
25
|
+
|
|
26
|
+
<CodeGroup dropdown>
|
|
27
|
+
|
|
28
|
+
```typescript publish-product-deleted.ts
|
|
29
|
+
import { EventsClient } from '@acme/events';
|
|
30
|
+
import type { ProductDeleted } from './schemas/product-deleted';
|
|
31
|
+
|
|
32
|
+
const client = new EventsClient({
|
|
33
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const event: ProductDeleted = {
|
|
37
|
+
eventId: '6a8c0e2f-4b6d-4e8a-9c1f-3d5b7a9e1c46',
|
|
38
|
+
occurredAt: '2026-09-19T16:45:03Z',
|
|
39
|
+
productId: 'e4f6a8b0-2c4d-4e6f-8a0b-1c3d5e7f9a12',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
await client.publish('ProductDeleted', event);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```python publish_product_deleted.py
|
|
46
|
+
import os
|
|
47
|
+
from acme_events import EventsClient
|
|
48
|
+
|
|
49
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
50
|
+
|
|
51
|
+
event = {
|
|
52
|
+
"eventId": "6a8c0e2f-4b6d-4e8a-9c1f-3d5b7a9e1c46",
|
|
53
|
+
"occurredAt": "2026-09-19T16:45:03Z",
|
|
54
|
+
"productId": "e4f6a8b0-2c4d-4e6f-8a0b-1c3d5e7f9a12",
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
client.publish("ProductDeleted", event)
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
```java PublishProductDeleted.java
|
|
61
|
+
import com.acme.events.EventsClient;
|
|
62
|
+
import java.util.Map;
|
|
63
|
+
|
|
64
|
+
public class PublishProductDeleted {
|
|
65
|
+
public static void main(String[] args) {
|
|
66
|
+
var client = new EventsClient(
|
|
67
|
+
System.getenv("ACME_API_KEY")
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
var event = Map.of(
|
|
71
|
+
"eventId", "6a8c0e2f-4b6d-4e8a-9c1f-3d5b7a9e1c46",
|
|
72
|
+
"occurredAt", "2026-09-19T16:45:03Z",
|
|
73
|
+
"productId", "e4f6a8b0-2c4d-4e6f-8a0b-1c3d5e7f9a12"
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
client.publish("ProductDeleted", event);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
</CodeGroup>
|
|
82
|
+
|
|
83
|
+
</Column>
|
|
84
|
+
|
|
85
|
+
</Columns>
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
<Columns cols={2}>
|
|
90
|
+
|
|
91
|
+
<Column>
|
|
92
|
+
|
|
93
|
+
## 2. Publish a discontinued product
|
|
94
|
+
|
|
95
|
+
The Tie-Dye T-Shirt has been retired because it will not be restocked. The event includes the reason so downstream systems can report on why products leave the catalog.
|
|
96
|
+
|
|
97
|
+
### Payload details
|
|
98
|
+
|
|
99
|
+
- `productId` identifies the Tie-Dye T-Shirt.
|
|
100
|
+
- `reason` is `DISCONTINUED`, copied from the DeleteProduct command.
|
|
101
|
+
- `occurredAt` records when the product was removed.
|
|
102
|
+
|
|
103
|
+
### Using this example
|
|
104
|
+
|
|
105
|
+
Check that the product is removed from the search index and that `reason` is recorded, so a discontinued line can be told apart from a `DUPLICATE` or `MERCHANT_REQUEST` removal.
|
|
106
|
+
|
|
107
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ProductDeleted schema. The package names and publish methods are illustrative.
|
|
108
|
+
|
|
109
|
+
</Column>
|
|
110
|
+
|
|
111
|
+
<Column>
|
|
112
|
+
|
|
113
|
+
<CodeGroup dropdown>
|
|
114
|
+
|
|
115
|
+
```typescript publish-product-deleted.ts
|
|
116
|
+
import { EventsClient } from '@acme/events';
|
|
117
|
+
import type { ProductDeleted } from './schemas/product-deleted';
|
|
118
|
+
|
|
119
|
+
const client = new EventsClient({
|
|
120
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
const event: ProductDeleted = {
|
|
124
|
+
eventId: '7b9d1f3a-5c7e-4a9b-b0d2-4e6f8a0c2e57',
|
|
125
|
+
occurredAt: '2026-09-20T11:20:30Z',
|
|
126
|
+
productId: '5c7e9a1b-3d5f-4a7c-9e1b-2d4f6a8c0e35',
|
|
127
|
+
reason: 'DISCONTINUED',
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
await client.publish('ProductDeleted', event);
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
```python publish_product_deleted.py
|
|
134
|
+
import os
|
|
135
|
+
from acme_events import EventsClient
|
|
136
|
+
|
|
137
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
138
|
+
|
|
139
|
+
event = {
|
|
140
|
+
"eventId": "7b9d1f3a-5c7e-4a9b-b0d2-4e6f8a0c2e57",
|
|
141
|
+
"occurredAt": "2026-09-20T11:20:30Z",
|
|
142
|
+
"productId": "5c7e9a1b-3d5f-4a7c-9e1b-2d4f6a8c0e35",
|
|
143
|
+
"reason": "DISCONTINUED",
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
client.publish("ProductDeleted", event)
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
```java PublishProductDeleted.java
|
|
150
|
+
import com.acme.events.EventsClient;
|
|
151
|
+
import java.util.Map;
|
|
152
|
+
|
|
153
|
+
public class PublishProductDeleted {
|
|
154
|
+
public static void main(String[] args) {
|
|
155
|
+
var client = new EventsClient(
|
|
156
|
+
System.getenv("ACME_API_KEY")
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
var event = Map.of(
|
|
160
|
+
"eventId", "7b9d1f3a-5c7e-4a9b-b0d2-4e6f8a0c2e57",
|
|
161
|
+
"occurredAt", "2026-09-20T11:20:30Z",
|
|
162
|
+
"productId", "5c7e9a1b-3d5f-4a7c-9e1b-2d4f6a8c0e35",
|
|
163
|
+
"reason", "DISCONTINUED"
|
|
164
|
+
);
|
|
165
|
+
|
|
166
|
+
client.publish("ProductDeleted", event);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
</CodeGroup>
|
|
172
|
+
|
|
173
|
+
</Column>
|
|
174
|
+
|
|
175
|
+
</Columns>
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Publish a price change
|
|
6
|
+
|
|
7
|
+
The Classic Crew Neck T-Shirt has been marked down, so ProductUpdated is published with only the fields that changed. The Search System re-indexes the product so results show the new price.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `productId` identifies the T-shirt that changed.
|
|
12
|
+
- `changes` holds only the changed fields: `price` and `currency`.
|
|
13
|
+
- `changes.price` is `1499` in minor units, down from `1999`.
|
|
14
|
+
- `occurredAt` is the ISO-8601 UTC time the update was applied.
|
|
15
|
+
|
|
16
|
+
The new price is **1,499 pence (£14.99)**, **500 pence (£5.00)** less than before.
|
|
17
|
+
|
|
18
|
+
### Using this example
|
|
19
|
+
|
|
20
|
+
A consumer should update only the fields in `changes` and leave the rest of its copy of the product untouched.
|
|
21
|
+
|
|
22
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ProductUpdated schema. The package names and publish methods are illustrative.
|
|
23
|
+
|
|
24
|
+
</Column>
|
|
25
|
+
|
|
26
|
+
<Column>
|
|
27
|
+
|
|
28
|
+
<CodeGroup dropdown>
|
|
29
|
+
|
|
30
|
+
```typescript publish-product-updated.ts
|
|
31
|
+
import { EventsClient } from '@acme/events';
|
|
32
|
+
import type { ProductUpdated } from './schemas/product-updated';
|
|
33
|
+
|
|
34
|
+
const client = new EventsClient({
|
|
35
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
const event: ProductUpdated = {
|
|
39
|
+
eventId: 'f1a3c5e7-9b2d-4f6a-8c0e-3b5d7f9a1c24',
|
|
40
|
+
occurredAt: '2026-09-18T09:00:00Z',
|
|
41
|
+
productId: '4c8e2a6f-1d3b-4f5a-9e7c-0b2d4f6a8c13',
|
|
42
|
+
changes: {
|
|
43
|
+
price: 1499,
|
|
44
|
+
currency: 'GBP',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
await client.publish('ProductUpdated', event);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```python publish_product_updated.py
|
|
52
|
+
import os
|
|
53
|
+
from acme_events import EventsClient
|
|
54
|
+
|
|
55
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
56
|
+
|
|
57
|
+
event = {
|
|
58
|
+
"eventId": "f1a3c5e7-9b2d-4f6a-8c0e-3b5d7f9a1c24",
|
|
59
|
+
"occurredAt": "2026-09-18T09:00:00Z",
|
|
60
|
+
"productId": "4c8e2a6f-1d3b-4f5a-9e7c-0b2d4f6a8c13",
|
|
61
|
+
"changes": {
|
|
62
|
+
"price": 1499,
|
|
63
|
+
"currency": "GBP",
|
|
64
|
+
},
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
client.publish("ProductUpdated", event)
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```java PublishProductUpdated.java
|
|
71
|
+
import com.acme.events.EventsClient;
|
|
72
|
+
import java.util.Map;
|
|
73
|
+
|
|
74
|
+
public class PublishProductUpdated {
|
|
75
|
+
public static void main(String[] args) {
|
|
76
|
+
var client = new EventsClient(
|
|
77
|
+
System.getenv("ACME_API_KEY")
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
var event = Map.of(
|
|
81
|
+
"eventId", "f1a3c5e7-9b2d-4f6a-8c0e-3b5d7f9a1c24",
|
|
82
|
+
"occurredAt", "2026-09-18T09:00:00Z",
|
|
83
|
+
"productId", "4c8e2a6f-1d3b-4f5a-9e7c-0b2d4f6a8c13",
|
|
84
|
+
"changes", Map.of(
|
|
85
|
+
"price", 1499,
|
|
86
|
+
"currency", "GBP"
|
|
87
|
+
)
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
client.publish("ProductUpdated", event);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
</CodeGroup>
|
|
96
|
+
|
|
97
|
+
</Column>
|
|
98
|
+
|
|
99
|
+
</Columns>
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
<Columns cols={2}>
|
|
104
|
+
|
|
105
|
+
<Column>
|
|
106
|
+
|
|
107
|
+
## 2. Publish a product launch with several changes
|
|
108
|
+
|
|
109
|
+
The Embroidered Logo Cap has moved from draft to live with its final name, description and category. All four changes come from one UpdateProduct command, so they arrive in a single event.
|
|
110
|
+
|
|
111
|
+
### Payload details
|
|
112
|
+
|
|
113
|
+
- `changes.name` and `changes.description` replace the text shown to shoppers.
|
|
114
|
+
- `changes.category` is `caps`, so the product can now be found with a category filter.
|
|
115
|
+
- `changes.status` is `ACTIVE`, moving the cap out of `DRAFT`.
|
|
116
|
+
- Price is not in `changes`, so it is unchanged.
|
|
117
|
+
|
|
118
|
+
### Using this example
|
|
119
|
+
|
|
120
|
+
Check that a consumer applies every field in `changes` together, and that a search for "cap" now returns the product.
|
|
121
|
+
|
|
122
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ProductUpdated schema. The package names and publish methods are illustrative.
|
|
123
|
+
|
|
124
|
+
</Column>
|
|
125
|
+
|
|
126
|
+
<Column>
|
|
127
|
+
|
|
128
|
+
<CodeGroup dropdown>
|
|
129
|
+
|
|
130
|
+
```typescript publish-product-updated.ts
|
|
131
|
+
import { EventsClient } from '@acme/events';
|
|
132
|
+
import type { ProductUpdated } from './schemas/product-updated';
|
|
133
|
+
|
|
134
|
+
const client = new EventsClient({
|
|
135
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const event: ProductUpdated = {
|
|
139
|
+
eventId: '0e2c4a6f-8d1b-4b3e-a5c7-9f1d3b5e7a80',
|
|
140
|
+
occurredAt: '2026-09-15T14:05:12Z',
|
|
141
|
+
productId: 'a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71',
|
|
142
|
+
changes: {
|
|
143
|
+
name: 'Embroidered Logo Cap - Navy',
|
|
144
|
+
description: 'Six-panel cotton twill cap with an adjustable strap.',
|
|
145
|
+
category: 'caps',
|
|
146
|
+
status: 'ACTIVE',
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
await client.publish('ProductUpdated', event);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
```python publish_product_updated.py
|
|
154
|
+
import os
|
|
155
|
+
from acme_events import EventsClient
|
|
156
|
+
|
|
157
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
158
|
+
|
|
159
|
+
event = {
|
|
160
|
+
"eventId": "0e2c4a6f-8d1b-4b3e-a5c7-9f1d3b5e7a80",
|
|
161
|
+
"occurredAt": "2026-09-15T14:05:12Z",
|
|
162
|
+
"productId": "a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71",
|
|
163
|
+
"changes": {
|
|
164
|
+
"name": "Embroidered Logo Cap - Navy",
|
|
165
|
+
"description": "Six-panel cotton twill cap with an adjustable strap.",
|
|
166
|
+
"category": "caps",
|
|
167
|
+
"status": "ACTIVE",
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
client.publish("ProductUpdated", event)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
```java PublishProductUpdated.java
|
|
175
|
+
import com.acme.events.EventsClient;
|
|
176
|
+
import java.util.Map;
|
|
177
|
+
|
|
178
|
+
public class PublishProductUpdated {
|
|
179
|
+
public static void main(String[] args) {
|
|
180
|
+
var client = new EventsClient(
|
|
181
|
+
System.getenv("ACME_API_KEY")
|
|
182
|
+
);
|
|
183
|
+
|
|
184
|
+
var event = Map.of(
|
|
185
|
+
"eventId", "0e2c4a6f-8d1b-4b3e-a5c7-9f1d3b5e7a80",
|
|
186
|
+
"occurredAt", "2026-09-15T14:05:12Z",
|
|
187
|
+
"productId", "a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71",
|
|
188
|
+
"changes", Map.of(
|
|
189
|
+
"name", "Embroidered Logo Cap - Navy",
|
|
190
|
+
"description", "Six-panel cotton twill cap with an adjustable strap.",
|
|
191
|
+
"category", "caps",
|
|
192
|
+
"status", "ACTIVE"
|
|
193
|
+
)
|
|
194
|
+
);
|
|
195
|
+
|
|
196
|
+
client.publish("ProductUpdated", event);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
</CodeGroup>
|
|
202
|
+
|
|
203
|
+
</Column>
|
|
204
|
+
|
|
205
|
+
</Columns>
|