@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,265 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Publish a failed delivery attempt
|
|
6
|
+
|
|
7
|
+
The Carrier Tracking API publishes this event when the driver cannot deliver, for example because nobody is home. Acme Inc consumes it to book a redelivery and tell the customer.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `shipmentId` and `orderId` identify the shipment and the order.
|
|
12
|
+
- `reason` is `FAILED_DELIVERY`: the parcel is still with the carrier.
|
|
13
|
+
- `failedAt` is the UTC time of the failed attempt.
|
|
14
|
+
|
|
15
|
+
### Using this example
|
|
16
|
+
|
|
17
|
+
A consumer should start the redelivery flow for this `reason` and must not issue a refund.
|
|
18
|
+
|
|
19
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ShipmentFailed schema. The package names and publish methods are illustrative.
|
|
20
|
+
|
|
21
|
+
</Column>
|
|
22
|
+
|
|
23
|
+
<Column>
|
|
24
|
+
|
|
25
|
+
<CodeGroup dropdown>
|
|
26
|
+
|
|
27
|
+
```typescript publish-shipment-failed.ts
|
|
28
|
+
import { EventsClient } from '@acme/events';
|
|
29
|
+
import type { ShipmentFailed } from './schemas/shipment-failed';
|
|
30
|
+
|
|
31
|
+
const client = new EventsClient({
|
|
32
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const event: ShipmentFailed = {
|
|
36
|
+
shipmentId: '1d7f4a9c-2e8b-4b5d-9a3c-6e0f8b2d4c79',
|
|
37
|
+
orderId: '3f2b8c1e-7a4d-4e9b-9c21-5d8e6f0a1b27',
|
|
38
|
+
reason: 'FAILED_DELIVERY',
|
|
39
|
+
failedAt: '2026-09-15T12:48:19Z',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
await client.publish('ShipmentFailed', event);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```python publish_shipment_failed.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
|
+
"shipmentId": "1d7f4a9c-2e8b-4b5d-9a3c-6e0f8b2d4c79",
|
|
53
|
+
"orderId": "3f2b8c1e-7a4d-4e9b-9c21-5d8e6f0a1b27",
|
|
54
|
+
"reason": "FAILED_DELIVERY",
|
|
55
|
+
"failedAt": "2026-09-15T12:48:19Z",
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
client.publish("ShipmentFailed", event)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```java PublishShipmentFailed.java
|
|
62
|
+
import com.acme.events.EventsClient;
|
|
63
|
+
import java.util.Map;
|
|
64
|
+
|
|
65
|
+
public class PublishShipmentFailed {
|
|
66
|
+
public static void main(String[] args) {
|
|
67
|
+
var client = new EventsClient(
|
|
68
|
+
System.getenv("ACME_API_KEY")
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
var event = Map.of(
|
|
72
|
+
"shipmentId", "1d7f4a9c-2e8b-4b5d-9a3c-6e0f8b2d4c79",
|
|
73
|
+
"orderId", "3f2b8c1e-7a4d-4e9b-9c21-5d8e6f0a1b27",
|
|
74
|
+
"reason", "FAILED_DELIVERY",
|
|
75
|
+
"failedAt", "2026-09-15T12:48:19Z"
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
client.publish("ShipmentFailed", event);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
</CodeGroup>
|
|
84
|
+
|
|
85
|
+
</Column>
|
|
86
|
+
|
|
87
|
+
</Columns>
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
<Columns cols={2}>
|
|
92
|
+
|
|
93
|
+
<Column>
|
|
94
|
+
|
|
95
|
+
## 2. Publish a lost parcel
|
|
96
|
+
|
|
97
|
+
The carrier publishes this event when it cannot find the parcel in its network. Acme Inc consumes it to send a replacement or refund the customer.
|
|
98
|
+
|
|
99
|
+
### Payload details
|
|
100
|
+
|
|
101
|
+
- `reason` is `LOST`: the parcel will not arrive.
|
|
102
|
+
- `failedAt` is the UTC time the carrier declared the parcel lost.
|
|
103
|
+
|
|
104
|
+
### Using this example
|
|
105
|
+
|
|
106
|
+
A consumer should start the replacement or refund flow for this `reason` instead of booking a redelivery.
|
|
107
|
+
|
|
108
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ShipmentFailed schema. The package names and publish methods are illustrative.
|
|
109
|
+
|
|
110
|
+
</Column>
|
|
111
|
+
|
|
112
|
+
<Column>
|
|
113
|
+
|
|
114
|
+
<CodeGroup dropdown>
|
|
115
|
+
|
|
116
|
+
```typescript publish-shipment-failed.ts
|
|
117
|
+
import { EventsClient } from '@acme/events';
|
|
118
|
+
import type { ShipmentFailed } from './schemas/shipment-failed';
|
|
119
|
+
|
|
120
|
+
const client = new EventsClient({
|
|
121
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const event: ShipmentFailed = {
|
|
125
|
+
shipmentId: '9a2c6e8f-4b1d-4d7a-8e5c-3f9b0a6d2e14',
|
|
126
|
+
orderId: 'c7e41d92-5b3a-4f86-a1d4-8e2f9b6c0d53',
|
|
127
|
+
reason: 'LOST',
|
|
128
|
+
failedAt: '2026-09-19T16:02:37Z',
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
await client.publish('ShipmentFailed', event);
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```python publish_shipment_failed.py
|
|
135
|
+
import os
|
|
136
|
+
from acme_events import EventsClient
|
|
137
|
+
|
|
138
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
139
|
+
|
|
140
|
+
event = {
|
|
141
|
+
"shipmentId": "9a2c6e8f-4b1d-4d7a-8e5c-3f9b0a6d2e14",
|
|
142
|
+
"orderId": "c7e41d92-5b3a-4f86-a1d4-8e2f9b6c0d53",
|
|
143
|
+
"reason": "LOST",
|
|
144
|
+
"failedAt": "2026-09-19T16:02:37Z",
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
client.publish("ShipmentFailed", event)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
```java PublishShipmentFailed.java
|
|
151
|
+
import com.acme.events.EventsClient;
|
|
152
|
+
import java.util.Map;
|
|
153
|
+
|
|
154
|
+
public class PublishShipmentFailed {
|
|
155
|
+
public static void main(String[] args) {
|
|
156
|
+
var client = new EventsClient(
|
|
157
|
+
System.getenv("ACME_API_KEY")
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
var event = Map.of(
|
|
161
|
+
"shipmentId", "9a2c6e8f-4b1d-4d7a-8e5c-3f9b0a6d2e14",
|
|
162
|
+
"orderId", "c7e41d92-5b3a-4f86-a1d4-8e2f9b6c0d53",
|
|
163
|
+
"reason", "LOST",
|
|
164
|
+
"failedAt", "2026-09-19T16:02:37Z"
|
|
165
|
+
);
|
|
166
|
+
|
|
167
|
+
client.publish("ShipmentFailed", event);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
</CodeGroup>
|
|
173
|
+
|
|
174
|
+
</Column>
|
|
175
|
+
|
|
176
|
+
</Columns>
|
|
177
|
+
|
|
178
|
+
---
|
|
179
|
+
|
|
180
|
+
<Columns cols={2}>
|
|
181
|
+
|
|
182
|
+
<Column>
|
|
183
|
+
|
|
184
|
+
## 3. Publish a parcel returned to sender
|
|
185
|
+
|
|
186
|
+
The carrier publishes this event when it sends the parcel back to the warehouse, for example after several failed attempts. Acme Inc consumes it to contact the customer and restock the items when they arrive.
|
|
187
|
+
|
|
188
|
+
### Payload details
|
|
189
|
+
|
|
190
|
+
- `reason` is `RETURNED_TO_SENDER`: the parcel is on its way back to the warehouse.
|
|
191
|
+
- `failedAt` is the UTC time the carrier started the return.
|
|
192
|
+
|
|
193
|
+
### Using this example
|
|
194
|
+
|
|
195
|
+
A consumer should expect the goods back at the warehouse for this `reason` and contact the customer about a new delivery or a refund.
|
|
196
|
+
|
|
197
|
+
The examples use a **fictional Acme Events SDK** to publish a payload matching the ShipmentFailed schema. The package names and publish methods are illustrative.
|
|
198
|
+
|
|
199
|
+
</Column>
|
|
200
|
+
|
|
201
|
+
<Column>
|
|
202
|
+
|
|
203
|
+
<CodeGroup dropdown>
|
|
204
|
+
|
|
205
|
+
```typescript publish-shipment-failed.ts
|
|
206
|
+
import { EventsClient } from '@acme/events';
|
|
207
|
+
import type { ShipmentFailed } from './schemas/shipment-failed';
|
|
208
|
+
|
|
209
|
+
const client = new EventsClient({
|
|
210
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
const event: ShipmentFailed = {
|
|
214
|
+
shipmentId: '1d7f4a9c-2e8b-4b5d-9a3c-6e0f8b2d4c79',
|
|
215
|
+
orderId: '3f2b8c1e-7a4d-4e9b-9c21-5d8e6f0a1b27',
|
|
216
|
+
reason: 'RETURNED_TO_SENDER',
|
|
217
|
+
failedAt: '2026-09-18T08:30:00Z',
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
await client.publish('ShipmentFailed', event);
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
```python publish_shipment_failed.py
|
|
224
|
+
import os
|
|
225
|
+
from acme_events import EventsClient
|
|
226
|
+
|
|
227
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
228
|
+
|
|
229
|
+
event = {
|
|
230
|
+
"shipmentId": "1d7f4a9c-2e8b-4b5d-9a3c-6e0f8b2d4c79",
|
|
231
|
+
"orderId": "3f2b8c1e-7a4d-4e9b-9c21-5d8e6f0a1b27",
|
|
232
|
+
"reason": "RETURNED_TO_SENDER",
|
|
233
|
+
"failedAt": "2026-09-18T08:30:00Z",
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
client.publish("ShipmentFailed", event)
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```java PublishShipmentFailed.java
|
|
240
|
+
import com.acme.events.EventsClient;
|
|
241
|
+
import java.util.Map;
|
|
242
|
+
|
|
243
|
+
public class PublishShipmentFailed {
|
|
244
|
+
public static void main(String[] args) {
|
|
245
|
+
var client = new EventsClient(
|
|
246
|
+
System.getenv("ACME_API_KEY")
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
var event = Map.of(
|
|
250
|
+
"shipmentId", "1d7f4a9c-2e8b-4b5d-9a3c-6e0f8b2d4c79",
|
|
251
|
+
"orderId", "3f2b8c1e-7a4d-4e9b-9c21-5d8e6f0a1b27",
|
|
252
|
+
"reason", "RETURNED_TO_SENDER",
|
|
253
|
+
"failedAt", "2026-09-18T08:30:00Z"
|
|
254
|
+
);
|
|
255
|
+
|
|
256
|
+
client.publish("ShipmentFailed", event);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
</CodeGroup>
|
|
262
|
+
|
|
263
|
+
</Column>
|
|
264
|
+
|
|
265
|
+
</Columns>
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
<Columns cols={2}>
|
|
2
|
+
|
|
3
|
+
<Column>
|
|
4
|
+
|
|
5
|
+
## 1. Release stock after a failed checkout
|
|
6
|
+
|
|
7
|
+
The checkout saga sends this command when payment fails after stock was reserved. The Inventory Service puts the reserved units back on sale.
|
|
8
|
+
|
|
9
|
+
### Payload details
|
|
10
|
+
|
|
11
|
+
- `reservationId` is the reservation from the earlier `InventoryReserved` event.
|
|
12
|
+
- `reason` is `CHECKOUT_FAILED`.
|
|
13
|
+
|
|
14
|
+
### Using this example
|
|
15
|
+
|
|
16
|
+
The handler should return the reserved units to `available` stock and record `CHECKOUT_FAILED` as the reason.
|
|
17
|
+
|
|
18
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the ReleaseInventory schema. The package names and send methods are illustrative.
|
|
19
|
+
|
|
20
|
+
</Column>
|
|
21
|
+
|
|
22
|
+
<Column>
|
|
23
|
+
|
|
24
|
+
<CodeGroup dropdown>
|
|
25
|
+
|
|
26
|
+
```typescript send-release-inventory.ts
|
|
27
|
+
import { EventsClient } from '@acme/events';
|
|
28
|
+
import type { ReleaseInventory } from './schemas/release-inventory';
|
|
29
|
+
|
|
30
|
+
const client = new EventsClient({
|
|
31
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
const command: ReleaseInventory = {
|
|
35
|
+
reservationId: '4e9a1c7d-6b2f-4d8e-9c3a-7f5b0d1e2a86',
|
|
36
|
+
reason: 'CHECKOUT_FAILED',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
await client.send('ReleaseInventory', command);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
```python send_release_inventory.py
|
|
43
|
+
import os
|
|
44
|
+
from acme_events import EventsClient
|
|
45
|
+
|
|
46
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
47
|
+
|
|
48
|
+
command = {
|
|
49
|
+
"reservationId": "4e9a1c7d-6b2f-4d8e-9c3a-7f5b0d1e2a86",
|
|
50
|
+
"reason": "CHECKOUT_FAILED",
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
client.send("ReleaseInventory", command)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
```java SendReleaseInventory.java
|
|
57
|
+
import com.acme.events.EventsClient;
|
|
58
|
+
import java.util.Map;
|
|
59
|
+
|
|
60
|
+
public class SendReleaseInventory {
|
|
61
|
+
public static void main(String[] args) {
|
|
62
|
+
var client = new EventsClient(
|
|
63
|
+
System.getenv("ACME_API_KEY")
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
var command = Map.of(
|
|
67
|
+
"reservationId", "4e9a1c7d-6b2f-4d8e-9c3a-7f5b0d1e2a86",
|
|
68
|
+
"reason", "CHECKOUT_FAILED"
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
client.send("ReleaseInventory", command);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
</CodeGroup>
|
|
77
|
+
|
|
78
|
+
</Column>
|
|
79
|
+
|
|
80
|
+
</Columns>
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
<Columns cols={2}>
|
|
85
|
+
|
|
86
|
+
<Column>
|
|
87
|
+
|
|
88
|
+
## 2. Release stock for a cancelled order
|
|
89
|
+
|
|
90
|
+
The Ordering domain sends this command when a customer cancels an order before it is picked. The reserved hoodie goes back on sale.
|
|
91
|
+
|
|
92
|
+
### Payload details
|
|
93
|
+
|
|
94
|
+
- `reservationId` is the reservation held for the order.
|
|
95
|
+
- `reason` is `ORDER_CANCELLED`.
|
|
96
|
+
|
|
97
|
+
### Using this example
|
|
98
|
+
|
|
99
|
+
The handler should release the reservation and must not start a picking job for the cancelled order.
|
|
100
|
+
|
|
101
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the ReleaseInventory schema. The package names and send methods are illustrative.
|
|
102
|
+
|
|
103
|
+
</Column>
|
|
104
|
+
|
|
105
|
+
<Column>
|
|
106
|
+
|
|
107
|
+
<CodeGroup dropdown>
|
|
108
|
+
|
|
109
|
+
```typescript send-release-inventory.ts
|
|
110
|
+
import { EventsClient } from '@acme/events';
|
|
111
|
+
import type { ReleaseInventory } from './schemas/release-inventory';
|
|
112
|
+
|
|
113
|
+
const client = new EventsClient({
|
|
114
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const command: ReleaseInventory = {
|
|
118
|
+
reservationId: '8f3d6b2a-1e9c-4a7f-b5d8-2c0e4a9f6b13',
|
|
119
|
+
reason: 'ORDER_CANCELLED',
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
await client.send('ReleaseInventory', command);
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```python send_release_inventory.py
|
|
126
|
+
import os
|
|
127
|
+
from acme_events import EventsClient
|
|
128
|
+
|
|
129
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
130
|
+
|
|
131
|
+
command = {
|
|
132
|
+
"reservationId": "8f3d6b2a-1e9c-4a7f-b5d8-2c0e4a9f6b13",
|
|
133
|
+
"reason": "ORDER_CANCELLED",
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
client.send("ReleaseInventory", command)
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
```java SendReleaseInventory.java
|
|
140
|
+
import com.acme.events.EventsClient;
|
|
141
|
+
import java.util.Map;
|
|
142
|
+
|
|
143
|
+
public class SendReleaseInventory {
|
|
144
|
+
public static void main(String[] args) {
|
|
145
|
+
var client = new EventsClient(
|
|
146
|
+
System.getenv("ACME_API_KEY")
|
|
147
|
+
);
|
|
148
|
+
|
|
149
|
+
var command = Map.of(
|
|
150
|
+
"reservationId", "8f3d6b2a-1e9c-4a7f-b5d8-2c0e4a9f6b13",
|
|
151
|
+
"reason", "ORDER_CANCELLED"
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
client.send("ReleaseInventory", command);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
</CodeGroup>
|
|
160
|
+
|
|
161
|
+
</Column>
|
|
162
|
+
|
|
163
|
+
</Columns>
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
<Columns cols={2}>
|
|
168
|
+
|
|
169
|
+
<Column>
|
|
170
|
+
|
|
171
|
+
## 3. Release an expired reservation
|
|
172
|
+
|
|
173
|
+
A clean-up job sends this command when a reservation was held too long without an order, for example when a customer leaves the checkout page open.
|
|
174
|
+
|
|
175
|
+
### Payload details
|
|
176
|
+
|
|
177
|
+
- `reservationId` is the stale reservation.
|
|
178
|
+
- `reason` is `EXPIRED`.
|
|
179
|
+
|
|
180
|
+
### Using this example
|
|
181
|
+
|
|
182
|
+
The handler should release the reservation and should be idempotent, because the clean-up job may send the same command again.
|
|
183
|
+
|
|
184
|
+
The examples use a **fictional Acme Events SDK** to send a payload matching the ReleaseInventory schema. The package names and send methods are illustrative.
|
|
185
|
+
|
|
186
|
+
</Column>
|
|
187
|
+
|
|
188
|
+
<Column>
|
|
189
|
+
|
|
190
|
+
<CodeGroup dropdown>
|
|
191
|
+
|
|
192
|
+
```typescript send-release-inventory.ts
|
|
193
|
+
import { EventsClient } from '@acme/events';
|
|
194
|
+
import type { ReleaseInventory } from './schemas/release-inventory';
|
|
195
|
+
|
|
196
|
+
const client = new EventsClient({
|
|
197
|
+
apiKey: process.env.ACME_API_KEY!,
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
const command: ReleaseInventory = {
|
|
201
|
+
reservationId: '4e9a1c7d-6b2f-4d8e-9c3a-7f5b0d1e2a86',
|
|
202
|
+
reason: 'EXPIRED',
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
await client.send('ReleaseInventory', command);
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
```python send_release_inventory.py
|
|
209
|
+
import os
|
|
210
|
+
from acme_events import EventsClient
|
|
211
|
+
|
|
212
|
+
client = EventsClient(api_key=os.environ["ACME_API_KEY"])
|
|
213
|
+
|
|
214
|
+
command = {
|
|
215
|
+
"reservationId": "4e9a1c7d-6b2f-4d8e-9c3a-7f5b0d1e2a86",
|
|
216
|
+
"reason": "EXPIRED",
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
client.send("ReleaseInventory", command)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
```java SendReleaseInventory.java
|
|
223
|
+
import com.acme.events.EventsClient;
|
|
224
|
+
import java.util.Map;
|
|
225
|
+
|
|
226
|
+
public class SendReleaseInventory {
|
|
227
|
+
public static void main(String[] args) {
|
|
228
|
+
var client = new EventsClient(
|
|
229
|
+
System.getenv("ACME_API_KEY")
|
|
230
|
+
);
|
|
231
|
+
|
|
232
|
+
var command = Map.of(
|
|
233
|
+
"reservationId", "4e9a1c7d-6b2f-4d8e-9c3a-7f5b0d1e2a86",
|
|
234
|
+
"reason", "EXPIRED"
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
client.send("ReleaseInventory", command);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
</CodeGroup>
|
|
243
|
+
|
|
244
|
+
</Column>
|
|
245
|
+
|
|
246
|
+
</Columns>
|