@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.
Files changed (72) hide show
  1. package/LICENSE +0 -10
  2. package/dist/index.js +1 -1
  3. package/package.json +1 -1
  4. package/templates/amazon-api-gateway/README-template.md +4 -0
  5. package/templates/asyncapi/README-template.md +4 -0
  6. package/templates/asyncapi/env +0 -5
  7. package/templates/confluent/README-template.md +4 -0
  8. package/templates/default/README-template.md +4 -0
  9. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/CreateProduct/examples/index.mdx +194 -0
  10. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/DeleteProduct/examples/index.mdx +161 -0
  11. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/commands/UpdateProduct/examples/index.mdx +182 -0
  12. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductCreated/examples/index.mdx +227 -0
  13. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductDeleted/examples/index.mdx +175 -0
  14. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/events/ProductUpdated/examples/index.mdx +205 -0
  15. package/templates/default/domains/Catalog/systems/product-catalog-system/services/ProductAPI/queries/GetProduct/examples/index.mdx +205 -0
  16. package/templates/default/domains/Catalog/systems/search-system/services/SearchAPI/queries/SearchProducts/examples/index.mdx +369 -0
  17. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/RegisterCustomer/examples/index.mdx +168 -0
  18. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/commands/UpdateCustomer/examples/index.mdx +168 -0
  19. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerRegistered/examples/index.mdx +201 -0
  20. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/events/CustomerUpdated/examples/index.mdx +194 -0
  21. package/templates/default/domains/Customer/systems/customer-management-system/services/CustomerAPI/queries/GetCustomer/examples/index.mdx +194 -0
  22. package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/commands/AuthenticateCustomer/examples/index.mdx +198 -0
  23. package/templates/default/domains/Customer/systems/identity-provider/services/OAuthAPI/events/CustomerAuthenticated/examples/index.mdx +276 -0
  24. package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentCreated/examples/index.mdx +184 -0
  25. package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentDelivered/examples/index.mdx +173 -0
  26. package/templates/default/domains/Fulfilment/systems/carrier/services/CarrierTrackingAPI/events/ShipmentFailed/examples/index.mdx +265 -0
  27. package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/commands/ReleaseInventory/examples/index.mdx +246 -0
  28. package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryReserved/examples/index.mdx +227 -0
  29. package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/events/InventoryUnavailable/examples/index.mdx +229 -0
  30. package/templates/default/domains/Fulfilment/systems/inventory-system/services/InventoryService/queries/GetStockLevel/examples/index.mdx +186 -0
  31. package/templates/default/domains/Fulfilment/systems/shipping-system/services/CarrierAdapter/commands/CreateShipment/examples/index.mdx +206 -0
  32. package/templates/default/domains/Fulfilment/systems/warehouse-system/services/PickingWorker/events/OrderPacked/examples/index.mdx +172 -0
  33. package/templates/default/domains/Fulfilment/systems/warehouse-system/services/WarehouseService/events/OrderReadyForShipping/examples/index.mdx +208 -0
  34. package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/AuthorizePayment/examples/index.mdx +179 -0
  35. package/templates/default/domains/Ordering/systems/checkout-system/services/CheckoutOrchestrator/commands/ReserveInventory/examples/index.mdx +215 -0
  36. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CancelOrder/examples/index.mdx +163 -0
  37. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/commands/CreateOrder/examples/index.mdx +246 -0
  38. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCancelled/examples/index.mdx +267 -0
  39. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCompleted/examples/index.mdx +171 -0
  40. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/events/OrderCreated/examples/index.mdx +190 -0
  41. package/templates/default/domains/Ordering/systems/order-management-system/services/OrderService/queries/GetOrder/examples/index.mdx +343 -0
  42. package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckFailed/examples/index.mdx +271 -0
  43. package/templates/default/domains/Payments/systems/fraud-detection/services/FraudAPI/events/FraudCheckPassed/examples/index.mdx +173 -0
  44. package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/PaymentRequested/examples/index.mdx +191 -0
  45. package/templates/default/domains/Payments/systems/payment-processing-system/services/PaymentWorker/events/RefundRequested/examples/index.mdx +194 -0
  46. package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentFailed/examples/index.mdx +265 -0
  47. package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/PaymentSucceeded/examples/index.mdx +190 -0
  48. package/templates/default/domains/Payments/systems/stripe/services/StripeWebhookEndpoint/events/RefundProcessed/examples/index.mdx +186 -0
  49. package/templates/default/domains/Reviews/services/RatingAggregator/events/rating-updated/examples/index.mdx +183 -0
  50. package/templates/default/domains/Reviews/services/ReviewAPI/commands/flag-review/examples/index.mdx +183 -0
  51. package/templates/default/domains/Reviews/services/ReviewAPI/commands/submit-review/examples/index.mdx +195 -0
  52. package/templates/default/domains/Reviews/services/ReviewAPI/commands/vote-review-helpful/examples/index.mdx +178 -0
  53. package/templates/default/domains/Reviews/services/ReviewAPI/events/review-flagged/examples/index.mdx +186 -0
  54. package/templates/default/domains/Reviews/services/ReviewAPI/events/review-helpful-voted/examples/index.mdx +177 -0
  55. package/templates/default/domains/Reviews/services/ReviewAPI/events/review-submitted/examples/index.mdx +194 -0
  56. package/templates/default/domains/Reviews/services/ReviewAPI/queries/get-product-reviews/examples/index.mdx +259 -0
  57. package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-published/examples/index.mdx +183 -0
  58. package/templates/default/domains/Reviews/services/ReviewModerationWorker/events/review-rejected/examples/index.mdx +178 -0
  59. package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/AddItemToCart/examples/index.mdx +171 -0
  60. package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/CheckoutCart/examples/index.mdx +168 -0
  61. package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/commands/RemoveItemFromCart/examples/index.mdx +170 -0
  62. package/templates/default/domains/Shopping/systems/cart-system/services/CartAPI/events/CartCheckedOut/examples/index.mdx +275 -0
  63. package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/commands/CalculateDiscount/examples/index.mdx +207 -0
  64. package/templates/default/domains/Shopping/systems/promotion-system/services/PromotionService/events/DiscountCalculated/examples/index.mdx +190 -0
  65. package/templates/default/env +0 -5
  66. package/templates/empty/README-template.md +4 -0
  67. package/templates/empty/env +0 -5
  68. package/templates/eventbridge/README-template.md +4 -0
  69. package/templates/graphql/README-template.md +4 -0
  70. package/templates/graphql/env +0 -5
  71. package/templates/openapi/README-template.md +4 -0
  72. package/templates/openapi/env +0 -5
@@ -0,0 +1,205 @@
1
+ <Columns cols={2}>
2
+
3
+ <Column>
4
+
5
+ ## 1. Fetch an active product
6
+
7
+ The storefront product page asks the Product API for the Classic Crew Neck T-Shirt. The Product API reads it from the product database and returns every field.
8
+
9
+ ### Payload details
10
+
11
+ - `request.productId` is the UUID of the product to fetch, taken from the page URL.
12
+ - The response includes the optional `description` and `category` as well as the required fields.
13
+ - `status` is `ACTIVE`, so the product can be shown and sold.
14
+ - `price` is `1999` in minor units, with `currency` set to `GBP`.
15
+
16
+ The price is **1,999 pence (£19.99)**.
17
+
18
+ ### Example response
19
+
20
+ ```json
21
+ {
22
+ "productId": "4c8e2a6f-1d3b-4f5a-9e7c-0b2d4f6a8c13",
23
+ "sku": "TSHIRT-CREW-BLK-M",
24
+ "name": "Classic Crew Neck T-Shirt",
25
+ "description": "Midweight organic cotton T-shirt with a ribbed collar.",
26
+ "price": 1999,
27
+ "currency": "GBP",
28
+ "category": "t-shirts",
29
+ "status": "ACTIVE"
30
+ }
31
+ ```
32
+
33
+ ### Using this example
34
+
35
+ Use this to check that the product page renders the name, description and formatted price, and that the returned `productId` matches the one requested.
36
+
37
+ The examples use a **fictional Acme Events SDK** to query a payload matching the GetProduct schema. The package names and query methods are illustrative.
38
+
39
+ </Column>
40
+
41
+ <Column>
42
+
43
+ <CodeGroup dropdown>
44
+
45
+ ```typescript query-get-product.ts
46
+ import { EventsClient } from '@acme/events';
47
+ import type { GetProductRequest, GetProductResponse } from './schemas/get-product';
48
+
49
+ const client = new EventsClient({
50
+ apiKey: process.env.ACME_API_KEY!,
51
+ });
52
+
53
+ const request: GetProductRequest = {
54
+ productId: '4c8e2a6f-1d3b-4f5a-9e7c-0b2d4f6a8c13',
55
+ };
56
+
57
+ const product: GetProductResponse = await client.query('GetProduct', request);
58
+
59
+ console.log(product.status, product.price);
60
+ ```
61
+
62
+ ```python query_get_product.py
63
+ import os
64
+ from acme_events import EventsClient
65
+
66
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
67
+
68
+ request = {
69
+ "productId": "4c8e2a6f-1d3b-4f5a-9e7c-0b2d4f6a8c13",
70
+ }
71
+
72
+ product = client.query("GetProduct", request)
73
+
74
+ print(product["status"], product["price"])
75
+ ```
76
+
77
+ ```java QueryGetProduct.java
78
+ import com.acme.events.EventsClient;
79
+ import java.util.Map;
80
+
81
+ public class QueryGetProduct {
82
+ public static void main(String[] args) {
83
+ var client = new EventsClient(
84
+ System.getenv("ACME_API_KEY")
85
+ );
86
+
87
+ var request = Map.of(
88
+ "productId", "4c8e2a6f-1d3b-4f5a-9e7c-0b2d4f6a8c13"
89
+ );
90
+
91
+ var product = client.query("GetProduct", request);
92
+
93
+ System.out.println(product.get("status") + " " + product.get("price"));
94
+ }
95
+ }
96
+ ```
97
+
98
+ </CodeGroup>
99
+
100
+ </Column>
101
+
102
+ </Columns>
103
+
104
+ ---
105
+
106
+ <Columns cols={2}>
107
+
108
+ <Column>
109
+
110
+ ## 2. Fetch a draft product with required fields only
111
+
112
+ A merchandiser opens the Embroidered Logo Cap in the back office before launch. It is still a draft, so the response has only the required fields.
113
+
114
+ ### Payload details
115
+
116
+ - `request.productId` is the UUID of the draft cap.
117
+ - `status` is `DRAFT`, so the product must not be shown to shoppers.
118
+ - `description` and `category` are absent because they have not been set yet.
119
+ - `price` is `1499` in minor units, with `currency` set to `GBP`.
120
+
121
+ The price is **1,499 pence (£14.99)**.
122
+
123
+ ### Example response
124
+
125
+ ```json
126
+ {
127
+ "productId": "a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71",
128
+ "sku": "CAP-LOGO-NVY",
129
+ "name": "Embroidered Logo Cap",
130
+ "price": 1499,
131
+ "currency": "GBP",
132
+ "status": "DRAFT"
133
+ }
134
+ ```
135
+
136
+ ### Using this example
137
+
138
+ Check that callers cope with a missing `description` and `category`, and that storefront code hides products whose `status` is `DRAFT`.
139
+
140
+ The examples use a **fictional Acme Events SDK** to query a payload matching the GetProduct schema. The package names and query methods are illustrative.
141
+
142
+ </Column>
143
+
144
+ <Column>
145
+
146
+ <CodeGroup dropdown>
147
+
148
+ ```typescript query-get-product.ts
149
+ import { EventsClient } from '@acme/events';
150
+ import type { GetProductRequest, GetProductResponse } from './schemas/get-product';
151
+
152
+ const client = new EventsClient({
153
+ apiKey: process.env.ACME_API_KEY!,
154
+ });
155
+
156
+ const request: GetProductRequest = {
157
+ productId: 'a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71',
158
+ };
159
+
160
+ const product: GetProductResponse = await client.query('GetProduct', request);
161
+
162
+ console.log(product.status, product.price);
163
+ ```
164
+
165
+ ```python query_get_product.py
166
+ import os
167
+ from acme_events import EventsClient
168
+
169
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
170
+
171
+ request = {
172
+ "productId": "a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71",
173
+ }
174
+
175
+ product = client.query("GetProduct", request)
176
+
177
+ print(product["status"], product["price"])
178
+ ```
179
+
180
+ ```java QueryGetProduct.java
181
+ import com.acme.events.EventsClient;
182
+ import java.util.Map;
183
+
184
+ public class QueryGetProduct {
185
+ public static void main(String[] args) {
186
+ var client = new EventsClient(
187
+ System.getenv("ACME_API_KEY")
188
+ );
189
+
190
+ var request = Map.of(
191
+ "productId", "a7c4e2d9-1b3f-4c8a-8e5d-2f6b9a0c3d71"
192
+ );
193
+
194
+ var product = client.query("GetProduct", request);
195
+
196
+ System.out.println(product.get("status") + " " + product.get("price"));
197
+ }
198
+ }
199
+ ```
200
+
201
+ </CodeGroup>
202
+
203
+ </Column>
204
+
205
+ </Columns>
@@ -0,0 +1,369 @@
1
+ <Columns cols={2}>
2
+
3
+ <Column>
4
+
5
+ ## 1. Search by keyword with default paging
6
+
7
+ A shopper types "hoodie" into the storefront search box. Only the search term is sent, so the Search API applies its default paging and returns the matches ranked by relevance.
8
+
9
+ ### Payload details
10
+
11
+ - `request.query` is the free-text term `hoodie`.
12
+ - `filters`, `page` and `pageSize` are omitted, so the defaults of page `1` and `20` results per page apply.
13
+ - `total` is `2`, so every match fits on the first page.
14
+ - Each result has a `score`; higher scores are more relevant and come first.
15
+ - `price` values are in minor units: `4999` and `4499`.
16
+
17
+ The two hoodies cost **4,999 pence (£49.99)** and **4,499 pence (£44.99)**.
18
+
19
+ ### Example response
20
+
21
+ ```json
22
+ {
23
+ "total": 2,
24
+ "page": 1,
25
+ "pageSize": 20,
26
+ "results": [
27
+ {
28
+ "productId": "c9e1f3a5-6b2d-4f7e-a8c0-1d3e5f7a9b24",
29
+ "sku": "HOODIE-ZIP-GRY-L",
30
+ "name": "Heavyweight Zip Hoodie",
31
+ "category": "hoodies",
32
+ "price": 4999,
33
+ "currency": "GBP",
34
+ "score": 12.84
35
+ },
36
+ {
37
+ "productId": "8d0f2b4e-6a8c-4e1a-b3d5-7f9b1d3e5a60",
38
+ "sku": "HOODIE-OTH-BLK-M",
39
+ "name": "Oversized Pullover Hoodie",
40
+ "category": "hoodies",
41
+ "price": 4499,
42
+ "currency": "GBP",
43
+ "score": 9.37
44
+ }
45
+ ]
46
+ }
47
+ ```
48
+
49
+ ### Using this example
50
+
51
+ Use this to check that the results page lists both hoodies in `score` order and shows no pagination controls.
52
+
53
+ The examples use a **fictional Acme Events SDK** to query a payload matching the SearchProducts schema. The package names and query methods are illustrative.
54
+
55
+ </Column>
56
+
57
+ <Column>
58
+
59
+ <CodeGroup dropdown>
60
+
61
+ ```typescript query-search-products.ts
62
+ import { EventsClient } from '@acme/events';
63
+ import type { SearchProductsRequest, SearchProductsResponse } from './schemas/search-products';
64
+
65
+ const client = new EventsClient({
66
+ apiKey: process.env.ACME_API_KEY!,
67
+ });
68
+
69
+ const request: SearchProductsRequest = {
70
+ query: 'hoodie',
71
+ };
72
+
73
+ const result: SearchProductsResponse = await client.query('SearchProducts', request);
74
+
75
+ console.log(result.total, result.page);
76
+ ```
77
+
78
+ ```python query_search_products.py
79
+ import os
80
+ from acme_events import EventsClient
81
+
82
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
83
+
84
+ request = {
85
+ "query": "hoodie",
86
+ }
87
+
88
+ result = client.query("SearchProducts", request)
89
+
90
+ print(result["total"], result["page"])
91
+ ```
92
+
93
+ ```java QuerySearchProducts.java
94
+ import com.acme.events.EventsClient;
95
+ import java.util.Map;
96
+
97
+ public class QuerySearchProducts {
98
+ public static void main(String[] args) {
99
+ var client = new EventsClient(
100
+ System.getenv("ACME_API_KEY")
101
+ );
102
+
103
+ var request = Map.of(
104
+ "query", "hoodie"
105
+ );
106
+
107
+ var result = client.query("SearchProducts", request);
108
+
109
+ System.out.println(result.get("total") + " " + result.get("page"));
110
+ }
111
+ }
112
+ ```
113
+
114
+ </CodeGroup>
115
+
116
+ </Column>
117
+
118
+ </Columns>
119
+
120
+ ---
121
+
122
+ <Columns cols={2}>
123
+
124
+ <Column>
125
+
126
+ ## 2. Filter and page through T-shirt results
127
+
128
+ A shopper searches for "t-shirt", narrows the results to active T-shirts between £10 and £25, and moves to the second page of a two-per-page listing.
129
+
130
+ ### Payload details
131
+
132
+ - `filters.category` is `t-shirts` and `filters.status` is `ACTIVE`.
133
+ - `filters.minPrice` is `1000` and `filters.maxPrice` is `2500`, both in minor units.
134
+ - `page` is `2` and `pageSize` is `2`, so this response holds the 3rd and 4th matches.
135
+ - `total` is `5`, so there are three pages in all.
136
+
137
+ The price range is **1,000 to 2,500 pence (£10.00 to £25.00)**; the results cost **2,200 pence (£22.00)** and **1,999 pence (£19.99)**.
138
+
139
+ ### Example response
140
+
141
+ ```json
142
+ {
143
+ "total": 5,
144
+ "page": 2,
145
+ "pageSize": 2,
146
+ "results": [
147
+ {
148
+ "productId": "9e1a3c5f-7b9d-4f2a-8c4e-6a8b0d2f4c71",
149
+ "sku": "TSHIRT-POCKET-WHT-L",
150
+ "name": "Pocket T-Shirt",
151
+ "category": "t-shirts",
152
+ "price": 2200,
153
+ "currency": "GBP",
154
+ "score": 7.91
155
+ },
156
+ {
157
+ "productId": "4c8e2a6f-1d3b-4f5a-9e7c-0b2d4f6a8c13",
158
+ "sku": "TSHIRT-CREW-BLK-M",
159
+ "name": "Classic Crew Neck T-Shirt",
160
+ "category": "t-shirts",
161
+ "price": 1999,
162
+ "currency": "GBP",
163
+ "score": 7.45
164
+ }
165
+ ]
166
+ }
167
+ ```
168
+
169
+ ### Using this example
170
+
171
+ Check that every result falls inside the price range and category, and that the UI shows page 2 of 3 with links to the previous and next pages.
172
+
173
+ The examples use a **fictional Acme Events SDK** to query a payload matching the SearchProducts schema. The package names and query methods are illustrative.
174
+
175
+ </Column>
176
+
177
+ <Column>
178
+
179
+ <CodeGroup dropdown>
180
+
181
+ ```typescript query-search-products.ts
182
+ import { EventsClient } from '@acme/events';
183
+ import type { SearchProductsRequest, SearchProductsResponse } from './schemas/search-products';
184
+
185
+ const client = new EventsClient({
186
+ apiKey: process.env.ACME_API_KEY!,
187
+ });
188
+
189
+ const request: SearchProductsRequest = {
190
+ query: 't-shirt',
191
+ filters: {
192
+ category: 't-shirts',
193
+ status: 'ACTIVE',
194
+ minPrice: 1000,
195
+ maxPrice: 2500,
196
+ },
197
+ page: 2,
198
+ pageSize: 2,
199
+ };
200
+
201
+ const result: SearchProductsResponse = await client.query('SearchProducts', request);
202
+
203
+ console.log(result.total, result.page);
204
+ ```
205
+
206
+ ```python query_search_products.py
207
+ import os
208
+ from acme_events import EventsClient
209
+
210
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
211
+
212
+ request = {
213
+ "query": "t-shirt",
214
+ "filters": {
215
+ "category": "t-shirts",
216
+ "status": "ACTIVE",
217
+ "minPrice": 1000,
218
+ "maxPrice": 2500,
219
+ },
220
+ "page": 2,
221
+ "pageSize": 2,
222
+ }
223
+
224
+ result = client.query("SearchProducts", request)
225
+
226
+ print(result["total"], result["page"])
227
+ ```
228
+
229
+ ```java QuerySearchProducts.java
230
+ import com.acme.events.EventsClient;
231
+ import java.util.Map;
232
+
233
+ public class QuerySearchProducts {
234
+ public static void main(String[] args) {
235
+ var client = new EventsClient(
236
+ System.getenv("ACME_API_KEY")
237
+ );
238
+
239
+ var request = Map.of(
240
+ "query", "t-shirt",
241
+ "filters", Map.of(
242
+ "category", "t-shirts",
243
+ "status", "ACTIVE",
244
+ "minPrice", 1000,
245
+ "maxPrice", 2500
246
+ ),
247
+ "page", 2,
248
+ "pageSize", 2
249
+ );
250
+
251
+ var result = client.query("SearchProducts", request);
252
+
253
+ System.out.println(result.get("total") + " " + result.get("page"));
254
+ }
255
+ }
256
+ ```
257
+
258
+ </CodeGroup>
259
+
260
+ </Column>
261
+
262
+ </Columns>
263
+
264
+ ---
265
+
266
+ <Columns cols={2}>
267
+
268
+ <Column>
269
+
270
+ ## 3. Handle a search with no matches
271
+
272
+ A shopper searches for "scarf" within the `accessories` category, but the shop does not sell scarves. The Search API still returns a valid response, with no results.
273
+
274
+ ### Payload details
275
+
276
+ - `request.query` is `scarf` and `filters.category` is `accessories`.
277
+ - `total` is `0` and `results` is an empty array.
278
+ - `page` and `pageSize` still show the defaults that were applied.
279
+
280
+ ### Example response
281
+
282
+ ```json
283
+ {
284
+ "total": 0,
285
+ "page": 1,
286
+ "pageSize": 20,
287
+ "results": []
288
+ }
289
+ ```
290
+
291
+ ### Using this example
292
+
293
+ Use this to check that the storefront shows a friendly "no results" message instead of an error when `results` is empty.
294
+
295
+ The examples use a **fictional Acme Events SDK** to query a payload matching the SearchProducts schema. The package names and query methods are illustrative.
296
+
297
+ </Column>
298
+
299
+ <Column>
300
+
301
+ <CodeGroup dropdown>
302
+
303
+ ```typescript query-search-products.ts
304
+ import { EventsClient } from '@acme/events';
305
+ import type { SearchProductsRequest, SearchProductsResponse } from './schemas/search-products';
306
+
307
+ const client = new EventsClient({
308
+ apiKey: process.env.ACME_API_KEY!,
309
+ });
310
+
311
+ const request: SearchProductsRequest = {
312
+ query: 'scarf',
313
+ filters: {
314
+ category: 'accessories',
315
+ },
316
+ };
317
+
318
+ const result: SearchProductsResponse = await client.query('SearchProducts', request);
319
+
320
+ console.log(result.total, result.page);
321
+ ```
322
+
323
+ ```python query_search_products.py
324
+ import os
325
+ from acme_events import EventsClient
326
+
327
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
328
+
329
+ request = {
330
+ "query": "scarf",
331
+ "filters": {
332
+ "category": "accessories",
333
+ },
334
+ }
335
+
336
+ result = client.query("SearchProducts", request)
337
+
338
+ print(result["total"], result["page"])
339
+ ```
340
+
341
+ ```java QuerySearchProducts.java
342
+ import com.acme.events.EventsClient;
343
+ import java.util.Map;
344
+
345
+ public class QuerySearchProducts {
346
+ public static void main(String[] args) {
347
+ var client = new EventsClient(
348
+ System.getenv("ACME_API_KEY")
349
+ );
350
+
351
+ var request = Map.of(
352
+ "query", "scarf",
353
+ "filters", Map.of(
354
+ "category", "accessories"
355
+ )
356
+ );
357
+
358
+ var result = client.query("SearchProducts", request);
359
+
360
+ System.out.println(result.get("total") + " " + result.get("page"));
361
+ }
362
+ }
363
+ ```
364
+
365
+ </CodeGroup>
366
+
367
+ </Column>
368
+
369
+ </Columns>