@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.
Files changed (58) hide show
  1. package/dist/index.js +1 -1
  2. package/package.json +1 -1
  3. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/CreateProduct/examples/index.mdx +194 -0
  4. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/DeleteProduct/examples/index.mdx +161 -0
  5. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/UpdateProduct/examples/index.mdx +182 -0
  6. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductCreated/examples/index.mdx +227 -0
  7. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductDeleted/examples/index.mdx +175 -0
  8. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductUpdated/examples/index.mdx +205 -0
  9. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/queries/GetProduct/examples/index.mdx +205 -0
  10. package/templates/default/domains/Catalog/systems/search-system/services/SearchAPI/queries/SearchProducts/examples/index.mdx +369 -0
  11. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/RegisterCustomer/examples/index.mdx +168 -0
  12. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/UpdateCustomer/examples/index.mdx +168 -0
  13. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerRegistered/examples/index.mdx +201 -0
  14. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerUpdated/examples/index.mdx +194 -0
  15. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/queries/GetCustomer/examples/index.mdx +194 -0
  16. package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/commands/AuthenticateCustomer/examples/index.mdx +198 -0
  17. package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/events/CustomerAuthenticated/examples/index.mdx +276 -0
  18. package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentCreated/examples/index.mdx +184 -0
  19. package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentDelivered/examples/index.mdx +173 -0
  20. package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentFailed/examples/index.mdx +265 -0
  21. package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/commands/ReleaseInventory/examples/index.mdx +246 -0
  22. package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryReserved/examples/index.mdx +227 -0
  23. package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryUnavailable/examples/index.mdx +229 -0
  24. package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/queries/GetStockLevel/examples/index.mdx +186 -0
  25. package/templates/default/domains/Fulfilment/systems/shipping-system/services/CarrierAdapter/commands/CreateShipment/examples/index.mdx +206 -0
  26. package/templates/default/domains/Fulfilment/systems/warehouse-system/services/PickingWorker/events/OrderPacked/examples/index.mdx +172 -0
  27. package/templates/default/domains/Fulfilment/systems/warehouse-system/services/WarehouseService/events/OrderReadyForShipping/examples/index.mdx +208 -0
  28. package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/AuthorizePayment/examples/index.mdx +179 -0
  29. package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/ReserveInventory/examples/index.mdx +215 -0
  30. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CancelOrder/examples/index.mdx +163 -0
  31. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CreateOrder/examples/index.mdx +246 -0
  32. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCancelled/examples/index.mdx +267 -0
  33. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCompleted/examples/index.mdx +171 -0
  34. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCreated/examples/index.mdx +190 -0
  35. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/queries/GetOrder/examples/index.mdx +343 -0
  36. package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckFailed/examples/index.mdx +271 -0
  37. package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckPassed/examples/index.mdx +173 -0
  38. package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/PaymentRequested/examples/index.mdx +191 -0
  39. package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/RefundRequested/examples/index.mdx +194 -0
  40. package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentFailed/examples/index.mdx +265 -0
  41. package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentSucceeded/examples/index.mdx +190 -0
  42. package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/RefundProcessed/examples/index.mdx +186 -0
  43. package/templates/default/domains/Reviews/services/RatingAggregator/events/rating-updated/examples/index.mdx +183 -0
  44. package/templates/default/domains/Reviews/services/ReviewAPI/commands/flag-review/examples/index.mdx +183 -0
  45. package/templates/default/domains/Reviews/services/ReviewAPI/commands/submit-review/examples/index.mdx +195 -0
  46. package/templates/default/domains/Reviews/services/ReviewAPI/commands/vote-review-helpful/examples/index.mdx +178 -0
  47. package/templates/default/domains/Reviews/services/ReviewAPI/events/review-flagged/examples/index.mdx +186 -0
  48. package/templates/default/domains/Reviews/services/ReviewAPI/events/review-helpful-voted/examples/index.mdx +177 -0
  49. package/templates/default/domains/Reviews/services/ReviewAPI/events/review-submitted/examples/index.mdx +194 -0
  50. package/templates/default/domains/Reviews/services/ReviewAPI/queries/get-product-reviews/examples/index.mdx +259 -0
  51. package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-published/examples/index.mdx +183 -0
  52. package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-rejected/examples/index.mdx +178 -0
  53. package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/AddItemToCart/examples/index.mdx +171 -0
  54. package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/CheckoutCart/examples/index.mdx +168 -0
  55. package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/RemoveItemFromCart/examples/index.mdx +170 -0
  56. package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/events/CartCheckedOut/examples/index.mdx +275 -0
  57. package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/commands/CalculateDiscount/examples/index.mdx +207 -0
  58. package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/events/DiscountCalculated/examples/index.mdx +190 -0
@@ -0,0 +1,227 @@
1
+ <Columns cols={2}>
2
+
3
+ <Column>
4
+
5
+ ## 1. Publish a reservation for a multi-item order
6
+
7
+ The Inventory Service publishes this event when it holds stock for every item in an order. The checkout saga in the Ordering domain consumes it and continues placing the order.
8
+
9
+ ### Payload details
10
+
11
+ - `reservationId` is the ID to use later in `ReleaseInventory`.
12
+ - `orderId` and `cartId` link the reservation to the order and the cart it came from.
13
+ - `items` holds 2 T-shirts and 1 cap, each by `productId` and `quantity`.
14
+ - `reservedAt` is the UTC time the stock was held.
15
+
16
+ In total, **3 units** are reserved across 2 products.
17
+
18
+ ### Using this example
19
+
20
+ The checkout saga should move on to payment for this order. Tests can check that both line items are reserved in full.
21
+
22
+ The examples use a **fictional Acme Events SDK** to publish a payload matching the InventoryReserved schema. The package names and publish methods are illustrative.
23
+
24
+ </Column>
25
+
26
+ <Column>
27
+
28
+ <CodeGroup dropdown>
29
+
30
+ ```typescript publish-inventory-reserved.ts
31
+ import { EventsClient } from '@acme/events';
32
+ import type { InventoryReserved } from './schemas/inventory-reserved';
33
+
34
+ const client = new EventsClient({
35
+ apiKey: process.env.ACME_API_KEY!,
36
+ });
37
+
38
+ const event: InventoryReserved = {
39
+ reservationId: '4e9a1c7d-6b2f-4d8e-9c3a-7f5b0d1e2a86',
40
+ orderId: '3f2b8c1e-7a4d-4e9b-9c21-5d8e6f0a1b27',
41
+ cartId: '7a1e5c9b-3f8d-4b2e-a6c4-9d0f1b7e3a58',
42
+ items: [
43
+ {
44
+ productId: '0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95',
45
+ quantity: 2,
46
+ },
47
+ {
48
+ productId: '6c1f9a4e-3d7b-4a2c-8f5e-9b0d2c7a1e38',
49
+ quantity: 1,
50
+ },
51
+ ],
52
+ reservedAt: '2026-09-14T08:12:45Z',
53
+ };
54
+
55
+ await client.publish('InventoryReserved', event);
56
+ ```
57
+
58
+ ```python publish_inventory_reserved.py
59
+ import os
60
+ from acme_events import EventsClient
61
+
62
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
63
+
64
+ event = {
65
+ "reservationId": "4e9a1c7d-6b2f-4d8e-9c3a-7f5b0d1e2a86",
66
+ "orderId": "3f2b8c1e-7a4d-4e9b-9c21-5d8e6f0a1b27",
67
+ "cartId": "7a1e5c9b-3f8d-4b2e-a6c4-9d0f1b7e3a58",
68
+ "items": [
69
+ {
70
+ "productId": "0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95",
71
+ "quantity": 2,
72
+ },
73
+ {
74
+ "productId": "6c1f9a4e-3d7b-4a2c-8f5e-9b0d2c7a1e38",
75
+ "quantity": 1,
76
+ },
77
+ ],
78
+ "reservedAt": "2026-09-14T08:12:45Z",
79
+ }
80
+
81
+ client.publish("InventoryReserved", event)
82
+ ```
83
+
84
+ ```java PublishInventoryReserved.java
85
+ import com.acme.events.EventsClient;
86
+ import java.util.List;
87
+ import java.util.Map;
88
+
89
+ public class PublishInventoryReserved {
90
+ public static void main(String[] args) {
91
+ var client = new EventsClient(
92
+ System.getenv("ACME_API_KEY")
93
+ );
94
+
95
+ var event = Map.of(
96
+ "reservationId", "4e9a1c7d-6b2f-4d8e-9c3a-7f5b0d1e2a86",
97
+ "orderId", "3f2b8c1e-7a4d-4e9b-9c21-5d8e6f0a1b27",
98
+ "cartId", "7a1e5c9b-3f8d-4b2e-a6c4-9d0f1b7e3a58",
99
+ "items", List.of(
100
+ Map.of(
101
+ "productId", "0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95",
102
+ "quantity", 2
103
+ ),
104
+ Map.of(
105
+ "productId", "6c1f9a4e-3d7b-4a2c-8f5e-9b0d2c7a1e38",
106
+ "quantity", 1
107
+ )
108
+ ),
109
+ "reservedAt", "2026-09-14T08:12:45Z"
110
+ );
111
+
112
+ client.publish("InventoryReserved", event);
113
+ }
114
+ }
115
+ ```
116
+
117
+ </CodeGroup>
118
+
119
+ </Column>
120
+
121
+ </Columns>
122
+
123
+ ---
124
+
125
+ <Columns cols={2}>
126
+
127
+ <Column>
128
+
129
+ ## 2. Publish a reservation for a cart
130
+
131
+ Stock can be held for a cart before the order exists. The event then links to the cart only and holds a single hoodie.
132
+
133
+ ### Payload details
134
+
135
+ - `cartId` is set and `orderId` is omitted because no order has been created yet.
136
+ - `items` holds 1 hoodie.
137
+ - `reservationId`, `items` and `reservedAt` are the required fields.
138
+
139
+ ### Using this example
140
+
141
+ Use this payload to check that consumers match a reservation by `cartId` when `orderId` is missing.
142
+
143
+ The examples use a **fictional Acme Events SDK** to publish a payload matching the InventoryReserved schema. The package names and publish methods are illustrative.
144
+
145
+ </Column>
146
+
147
+ <Column>
148
+
149
+ <CodeGroup dropdown>
150
+
151
+ ```typescript publish-inventory-reserved.ts
152
+ import { EventsClient } from '@acme/events';
153
+ import type { InventoryReserved } from './schemas/inventory-reserved';
154
+
155
+ const client = new EventsClient({
156
+ apiKey: process.env.ACME_API_KEY!,
157
+ });
158
+
159
+ const event: InventoryReserved = {
160
+ reservationId: '8f3d6b2a-1e9c-4a7f-b5d8-2c0e4a9f6b13',
161
+ cartId: '2c8f0b6d-5a3e-4c9f-8d1b-6e4a7c0f2b91',
162
+ items: [
163
+ {
164
+ productId: 'd2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72',
165
+ quantity: 1,
166
+ },
167
+ ],
168
+ reservedAt: '2026-09-14T10:58:21Z',
169
+ };
170
+
171
+ await client.publish('InventoryReserved', event);
172
+ ```
173
+
174
+ ```python publish_inventory_reserved.py
175
+ import os
176
+ from acme_events import EventsClient
177
+
178
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
179
+
180
+ event = {
181
+ "reservationId": "8f3d6b2a-1e9c-4a7f-b5d8-2c0e4a9f6b13",
182
+ "cartId": "2c8f0b6d-5a3e-4c9f-8d1b-6e4a7c0f2b91",
183
+ "items": [
184
+ {
185
+ "productId": "d2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72",
186
+ "quantity": 1,
187
+ },
188
+ ],
189
+ "reservedAt": "2026-09-14T10:58:21Z",
190
+ }
191
+
192
+ client.publish("InventoryReserved", event)
193
+ ```
194
+
195
+ ```java PublishInventoryReserved.java
196
+ import com.acme.events.EventsClient;
197
+ import java.util.List;
198
+ import java.util.Map;
199
+
200
+ public class PublishInventoryReserved {
201
+ public static void main(String[] args) {
202
+ var client = new EventsClient(
203
+ System.getenv("ACME_API_KEY")
204
+ );
205
+
206
+ var event = Map.of(
207
+ "reservationId", "8f3d6b2a-1e9c-4a7f-b5d8-2c0e4a9f6b13",
208
+ "cartId", "2c8f0b6d-5a3e-4c9f-8d1b-6e4a7c0f2b91",
209
+ "items", List.of(
210
+ Map.of(
211
+ "productId", "d2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72",
212
+ "quantity", 1
213
+ )
214
+ ),
215
+ "reservedAt", "2026-09-14T10:58:21Z"
216
+ );
217
+
218
+ client.publish("InventoryReserved", event);
219
+ }
220
+ }
221
+ ```
222
+
223
+ </CodeGroup>
224
+
225
+ </Column>
226
+
227
+ </Columns>
@@ -0,0 +1,229 @@
1
+ <Columns cols={2}>
2
+
3
+ <Column>
4
+
5
+ ## 1. Publish a sold-out item for an order
6
+
7
+ The Inventory Service publishes this event when it cannot reserve stock for an order. The checkout saga consumes it, fails checkout and cancels the order.
8
+
9
+ ### Payload details
10
+
11
+ - `orderId` and `cartId` identify the order and the cart that was checked out.
12
+ - `unavailableItems` lists the hoodie: `requested` is `1` and `available` is `0`.
13
+ - `checkedAt` is the UTC time of the stock check.
14
+
15
+ ### Using this example
16
+
17
+ The checkout saga should cancel the order and tell the customer the hoodie is sold out.
18
+
19
+ The examples use a **fictional Acme Events SDK** to publish a payload matching the InventoryUnavailable schema. The package names and publish methods are illustrative.
20
+
21
+ </Column>
22
+
23
+ <Column>
24
+
25
+ <CodeGroup dropdown>
26
+
27
+ ```typescript publish-inventory-unavailable.ts
28
+ import { EventsClient } from '@acme/events';
29
+ import type { InventoryUnavailable } from './schemas/inventory-unavailable';
30
+
31
+ const client = new EventsClient({
32
+ apiKey: process.env.ACME_API_KEY!,
33
+ });
34
+
35
+ const event: InventoryUnavailable = {
36
+ orderId: 'c7e41d92-5b3a-4f86-a1d4-8e2f9b6c0d53',
37
+ cartId: '2c8f0b6d-5a3e-4c9f-8d1b-6e4a7c0f2b91',
38
+ unavailableItems: [
39
+ {
40
+ productId: 'd2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72',
41
+ requested: 1,
42
+ available: 0,
43
+ },
44
+ ],
45
+ checkedAt: '2026-09-20T17:03:44Z',
46
+ };
47
+
48
+ await client.publish('InventoryUnavailable', event);
49
+ ```
50
+
51
+ ```python publish_inventory_unavailable.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
+ "orderId": "c7e41d92-5b3a-4f86-a1d4-8e2f9b6c0d53",
59
+ "cartId": "2c8f0b6d-5a3e-4c9f-8d1b-6e4a7c0f2b91",
60
+ "unavailableItems": [
61
+ {
62
+ "productId": "d2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72",
63
+ "requested": 1,
64
+ "available": 0,
65
+ },
66
+ ],
67
+ "checkedAt": "2026-09-20T17:03:44Z",
68
+ }
69
+
70
+ client.publish("InventoryUnavailable", event)
71
+ ```
72
+
73
+ ```java PublishInventoryUnavailable.java
74
+ import com.acme.events.EventsClient;
75
+ import java.util.List;
76
+ import java.util.Map;
77
+
78
+ public class PublishInventoryUnavailable {
79
+ public static void main(String[] args) {
80
+ var client = new EventsClient(
81
+ System.getenv("ACME_API_KEY")
82
+ );
83
+
84
+ var event = Map.of(
85
+ "orderId", "c7e41d92-5b3a-4f86-a1d4-8e2f9b6c0d53",
86
+ "cartId", "2c8f0b6d-5a3e-4c9f-8d1b-6e4a7c0f2b91",
87
+ "unavailableItems", List.of(
88
+ Map.of(
89
+ "productId", "d2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72",
90
+ "requested", 1,
91
+ "available", 0
92
+ )
93
+ ),
94
+ "checkedAt", "2026-09-20T17:03:44Z"
95
+ );
96
+
97
+ client.publish("InventoryUnavailable", event);
98
+ }
99
+ }
100
+ ```
101
+
102
+ </CodeGroup>
103
+
104
+ </Column>
105
+
106
+ </Columns>
107
+
108
+ ---
109
+
110
+ <Columns cols={2}>
111
+
112
+ <Column>
113
+
114
+ ## 2. Publish a partial shortage for a cart
115
+
116
+ A cart asks for more T-shirts and caps than are left. The event lists every short item and links to the cart only, because no order exists yet.
117
+
118
+ ### Payload details
119
+
120
+ - `unavailableItems` has two entries: 3 T-shirts requested with 1 available, and 2 caps requested with 0 available.
121
+ - `cartId` is set; `orderId` is omitted.
122
+ - `unavailableItems` and `checkedAt` are the only required fields.
123
+
124
+ The cart is short by **4 units**: 2 T-shirts and 2 caps.
125
+
126
+ ### Using this example
127
+
128
+ Consumers should show the customer the `available` count for each item so they can reduce the quantity and try again.
129
+
130
+ The examples use a **fictional Acme Events SDK** to publish a payload matching the InventoryUnavailable schema. The package names and publish methods are illustrative.
131
+
132
+ </Column>
133
+
134
+ <Column>
135
+
136
+ <CodeGroup dropdown>
137
+
138
+ ```typescript publish-inventory-unavailable.ts
139
+ import { EventsClient } from '@acme/events';
140
+ import type { InventoryUnavailable } from './schemas/inventory-unavailable';
141
+
142
+ const client = new EventsClient({
143
+ apiKey: process.env.ACME_API_KEY!,
144
+ });
145
+
146
+ const event: InventoryUnavailable = {
147
+ cartId: 'f5d3a8e2-0c7b-4e1f-9a6d-3b8c5e2f0a47',
148
+ unavailableItems: [
149
+ {
150
+ productId: '0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95',
151
+ requested: 3,
152
+ available: 1,
153
+ },
154
+ {
155
+ productId: '6c1f9a4e-3d7b-4a2c-8f5e-9b0d2c7a1e38',
156
+ requested: 2,
157
+ available: 0,
158
+ },
159
+ ],
160
+ checkedAt: '2026-09-14T08:10:02Z',
161
+ };
162
+
163
+ await client.publish('InventoryUnavailable', event);
164
+ ```
165
+
166
+ ```python publish_inventory_unavailable.py
167
+ import os
168
+ from acme_events import EventsClient
169
+
170
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
171
+
172
+ event = {
173
+ "cartId": "f5d3a8e2-0c7b-4e1f-9a6d-3b8c5e2f0a47",
174
+ "unavailableItems": [
175
+ {
176
+ "productId": "0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95",
177
+ "requested": 3,
178
+ "available": 1,
179
+ },
180
+ {
181
+ "productId": "6c1f9a4e-3d7b-4a2c-8f5e-9b0d2c7a1e38",
182
+ "requested": 2,
183
+ "available": 0,
184
+ },
185
+ ],
186
+ "checkedAt": "2026-09-14T08:10:02Z",
187
+ }
188
+
189
+ client.publish("InventoryUnavailable", event)
190
+ ```
191
+
192
+ ```java PublishInventoryUnavailable.java
193
+ import com.acme.events.EventsClient;
194
+ import java.util.List;
195
+ import java.util.Map;
196
+
197
+ public class PublishInventoryUnavailable {
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
+ "cartId", "f5d3a8e2-0c7b-4e1f-9a6d-3b8c5e2f0a47",
205
+ "unavailableItems", List.of(
206
+ Map.of(
207
+ "productId", "0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95",
208
+ "requested", 3,
209
+ "available", 1
210
+ ),
211
+ Map.of(
212
+ "productId", "6c1f9a4e-3d7b-4a2c-8f5e-9b0d2c7a1e38",
213
+ "requested", 2,
214
+ "available", 0
215
+ )
216
+ ),
217
+ "checkedAt", "2026-09-14T08:10:02Z"
218
+ );
219
+
220
+ client.publish("InventoryUnavailable", event);
221
+ }
222
+ }
223
+ ```
224
+
225
+ </CodeGroup>
226
+
227
+ </Column>
228
+
229
+ </Columns>
@@ -0,0 +1,186 @@
1
+ <Columns cols={2}>
2
+
3
+ <Column>
4
+
5
+ ## 1. Get the stock level of a product in stock
6
+
7
+ A product page or the checkout asks the Inventory Service how many of a T-shirt it can still sell. The response comes straight from the inventory database.
8
+
9
+ ### Payload details
10
+
11
+ - The request has one field, `productId`, for the T-shirt.
12
+ - `available` is `42`: units that can still be sold.
13
+ - `reserved` is `6`: units held for checkouts in progress.
14
+
15
+ ### Example response
16
+
17
+ ```json
18
+ {
19
+ "productId": "0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95",
20
+ "available": 42,
21
+ "reserved": 6
22
+ }
23
+ ```
24
+
25
+ ### Using this example
26
+
27
+ A caller should show the product as in stock because `available` is above zero. Use this pair to test stock badges and quantity limits.
28
+
29
+ The examples use a **fictional Acme Events SDK** to query a payload matching the GetStockLevel schema. The package names and query methods are illustrative.
30
+
31
+ </Column>
32
+
33
+ <Column>
34
+
35
+ <CodeGroup dropdown>
36
+
37
+ ```typescript query-get-stock-level.ts
38
+ import { EventsClient } from '@acme/events';
39
+ import type { GetStockLevelRequest, GetStockLevelResponse } from './schemas/get-stock-level';
40
+
41
+ const client = new EventsClient({
42
+ apiKey: process.env.ACME_API_KEY!,
43
+ });
44
+
45
+ const request: GetStockLevelRequest = {
46
+ productId: '0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95',
47
+ };
48
+
49
+ const stock: GetStockLevelResponse = await client.query('GetStockLevel', request);
50
+
51
+ console.log(stock.available, stock.reserved);
52
+ ```
53
+
54
+ ```python query_get_stock_level.py
55
+ import os
56
+ from acme_events import EventsClient
57
+
58
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
59
+
60
+ request = {
61
+ "productId": "0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95",
62
+ }
63
+
64
+ stock = client.query("GetStockLevel", request)
65
+ print(stock["available"], stock["reserved"])
66
+ ```
67
+
68
+ ```java QueryGetStockLevel.java
69
+ import com.acme.events.EventsClient;
70
+ import java.util.Map;
71
+
72
+ public class QueryGetStockLevel {
73
+ public static void main(String[] args) {
74
+ var client = new EventsClient(
75
+ System.getenv("ACME_API_KEY")
76
+ );
77
+
78
+ var request = Map.of(
79
+ "productId", "0b8e3d5f-9c2a-4f1e-b7d6-4a2c8e0f3b95"
80
+ );
81
+
82
+ var stock = client.query("GetStockLevel", request);
83
+ System.out.println(stock.get("available") + " " + stock.get("reserved"));
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. Get the stock level of a sold-out product
101
+
102
+ The same query for a hoodie that has sold out. No units are held for checkouts, so the Inventory Service leaves out `reserved`.
103
+
104
+ ### Payload details
105
+
106
+ - The request asks for the hoodie's `productId`.
107
+ - `available` is `0`: the hoodie cannot be sold.
108
+ - `reserved` is omitted, not set to null.
109
+
110
+ ### Example response
111
+
112
+ ```json
113
+ {
114
+ "productId": "d2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72",
115
+ "available": 0
116
+ }
117
+ ```
118
+
119
+ ### Using this example
120
+
121
+ A caller should show the hoodie as out of stock and must not treat the missing `reserved` field as an error.
122
+
123
+ The examples use a **fictional Acme Events SDK** to query a payload matching the GetStockLevel schema. The package names and query methods are illustrative.
124
+
125
+ </Column>
126
+
127
+ <Column>
128
+
129
+ <CodeGroup dropdown>
130
+
131
+ ```typescript query-get-stock-level.ts
132
+ import { EventsClient } from '@acme/events';
133
+ import type { GetStockLevelRequest, GetStockLevelResponse } from './schemas/get-stock-level';
134
+
135
+ const client = new EventsClient({
136
+ apiKey: process.env.ACME_API_KEY!,
137
+ });
138
+
139
+ const request: GetStockLevelRequest = {
140
+ productId: 'd2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72',
141
+ };
142
+
143
+ const stock: GetStockLevelResponse = await client.query('GetStockLevel', request);
144
+
145
+ console.log(stock.productId, stock.available);
146
+ ```
147
+
148
+ ```python query_get_stock_level.py
149
+ import os
150
+ from acme_events import EventsClient
151
+
152
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
153
+
154
+ request = {
155
+ "productId": "d2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72",
156
+ }
157
+
158
+ stock = client.query("GetStockLevel", request)
159
+ print(stock["productId"], stock["available"])
160
+ ```
161
+
162
+ ```java QueryGetStockLevel.java
163
+ import com.acme.events.EventsClient;
164
+ import java.util.Map;
165
+
166
+ public class QueryGetStockLevel {
167
+ public static void main(String[] args) {
168
+ var client = new EventsClient(
169
+ System.getenv("ACME_API_KEY")
170
+ );
171
+
172
+ var request = Map.of(
173
+ "productId", "d2a5e8c1-7f4b-4e9d-a3c6-1b8f0e5d9a72"
174
+ );
175
+
176
+ var stock = client.query("GetStockLevel", request);
177
+ System.out.println(stock.get("productId") + " " + stock.get("available"));
178
+ }
179
+ }
180
+ ```
181
+
182
+ </CodeGroup>
183
+
184
+ </Column>
185
+
186
+ </Columns>