@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,177 @@
1
+ <Columns cols={2}>
2
+
3
+ <Column>
4
+
5
+ ## 1. Publish a higher helpful count
6
+
7
+ A customer has marked the classic white T-shirt review as helpful. The Review API publishes the new total so the storefront can keep its "most helpful" ordering up to date.
8
+
9
+ ### Payload details
10
+
11
+ - `reviewId` is the review whose count changed.
12
+ - `productId` is `prod_tshirt_classic_white`, so consumers can refresh that product's review list.
13
+ - `helpfulCount` is `13`, the new total after the vote (it was 12).
14
+ - `updatedAt` is when the count changed.
15
+
16
+ ### Using this example
17
+
18
+ Consumers should store `helpfulCount` as the latest total and use `updatedAt` to ignore older, out-of-order events.
19
+
20
+ The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewHelpfulVoted schema. The package names and publish methods are illustrative.
21
+
22
+ </Column>
23
+
24
+ <Column>
25
+
26
+ <CodeGroup dropdown>
27
+
28
+ ```typescript publish-review-helpful-voted.ts
29
+ import { EventsClient } from '@acme/events';
30
+ import type { ReviewHelpfulVoted } from './schemas/review-helpful-voted';
31
+
32
+ const client = new EventsClient({
33
+ apiKey: process.env.ACME_API_KEY!,
34
+ });
35
+
36
+ const event: ReviewHelpfulVoted = {
37
+ reviewId: '3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90',
38
+ productId: 'prod_tshirt_classic_white',
39
+ helpfulCount: 13,
40
+ updatedAt: '2026-09-18T10:02:12Z',
41
+ };
42
+
43
+ await client.publish('ReviewHelpfulVoted', event);
44
+ ```
45
+
46
+ ```python publish_review_helpful_voted.py
47
+ import os
48
+ from acme_events import EventsClient
49
+
50
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
51
+
52
+ event = {
53
+ "reviewId": "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
54
+ "productId": "prod_tshirt_classic_white",
55
+ "helpfulCount": 13,
56
+ "updatedAt": "2026-09-18T10:02:12Z",
57
+ }
58
+
59
+ client.publish("ReviewHelpfulVoted", event)
60
+ ```
61
+
62
+ ```java PublishReviewHelpfulVoted.java
63
+ import com.acme.events.EventsClient;
64
+ import java.util.Map;
65
+
66
+ public class PublishReviewHelpfulVoted {
67
+ public static void main(String[] args) {
68
+ var client = new EventsClient(
69
+ System.getenv("ACME_API_KEY")
70
+ );
71
+
72
+ var event = Map.of(
73
+ "reviewId", "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
74
+ "productId", "prod_tshirt_classic_white",
75
+ "helpfulCount", 13,
76
+ "updatedAt", "2026-09-18T10:02:12Z"
77
+ );
78
+
79
+ client.publish("ReviewHelpfulVoted", event);
80
+ }
81
+ }
82
+ ```
83
+
84
+ </CodeGroup>
85
+
86
+ </Column>
87
+
88
+ </Columns>
89
+
90
+ ---
91
+
92
+ <Columns cols={2}>
93
+
94
+ <Column>
95
+
96
+ ## 2. Publish a lower helpful count after a vote is removed
97
+
98
+ The customer removes their vote, so the Review API publishes the reduced total for the same review.
99
+
100
+ ### Payload details
101
+
102
+ - `helpfulCount` is `12`, back to the total before the earlier vote.
103
+ - `updatedAt` is later than the previous event for this review.
104
+
105
+ ### Using this example
106
+
107
+ Use this payload with the first example to test that consumers keep the latest `helpfulCount` when events arrive out of order.
108
+
109
+ The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewHelpfulVoted schema. The package names and publish methods are illustrative.
110
+
111
+ </Column>
112
+
113
+ <Column>
114
+
115
+ <CodeGroup dropdown>
116
+
117
+ ```typescript publish-review-helpful-voted.ts
118
+ import { EventsClient } from '@acme/events';
119
+ import type { ReviewHelpfulVoted } from './schemas/review-helpful-voted';
120
+
121
+ const client = new EventsClient({
122
+ apiKey: process.env.ACME_API_KEY!,
123
+ });
124
+
125
+ const event: ReviewHelpfulVoted = {
126
+ reviewId: '3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90',
127
+ productId: 'prod_tshirt_classic_white',
128
+ helpfulCount: 12,
129
+ updatedAt: '2026-09-18T10:02:48Z',
130
+ };
131
+
132
+ await client.publish('ReviewHelpfulVoted', event);
133
+ ```
134
+
135
+ ```python publish_review_helpful_voted.py
136
+ import os
137
+ from acme_events import EventsClient
138
+
139
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
140
+
141
+ event = {
142
+ "reviewId": "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
143
+ "productId": "prod_tshirt_classic_white",
144
+ "helpfulCount": 12,
145
+ "updatedAt": "2026-09-18T10:02:48Z",
146
+ }
147
+
148
+ client.publish("ReviewHelpfulVoted", event)
149
+ ```
150
+
151
+ ```java PublishReviewHelpfulVoted.java
152
+ import com.acme.events.EventsClient;
153
+ import java.util.Map;
154
+
155
+ public class PublishReviewHelpfulVoted {
156
+ public static void main(String[] args) {
157
+ var client = new EventsClient(
158
+ System.getenv("ACME_API_KEY")
159
+ );
160
+
161
+ var event = Map.of(
162
+ "reviewId", "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
163
+ "productId", "prod_tshirt_classic_white",
164
+ "helpfulCount", 12,
165
+ "updatedAt", "2026-09-18T10:02:48Z"
166
+ );
167
+
168
+ client.publish("ReviewHelpfulVoted", event);
169
+ }
170
+ }
171
+ ```
172
+
173
+ </CodeGroup>
174
+
175
+ </Column>
176
+
177
+ </Columns>
@@ -0,0 +1,194 @@
1
+ <Columns cols={2}>
2
+
3
+ <Column>
4
+
5
+ ## 1. Publish a stored five-star review
6
+
7
+ The Review API has accepted a `SubmitReview` command for the classic white T-shirt and stored the review. It publishes this event so the Review Moderation Worker can screen the review before it goes live.
8
+
9
+ ### Payload details
10
+
11
+ - `reviewId` matches the id sent in the original `SubmitReview` command.
12
+ - `productId` is `prod_tshirt_classic_white` and `customerId` is `cust_4821`.
13
+ - `rating` is `5`; `title` and `body` carry the text the moderation worker screens.
14
+ - `submittedAt` is when the customer submitted the review, not when moderation happens.
15
+
16
+ ### Using this example
17
+
18
+ A moderation consumer should pick up this event, screen the `title` and `body`, and then publish either `ReviewPublished` or `ReviewRejected` for the same `reviewId`.
19
+
20
+ The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewSubmitted schema. The package names and publish methods are illustrative.
21
+
22
+ </Column>
23
+
24
+ <Column>
25
+
26
+ <CodeGroup dropdown>
27
+
28
+ ```typescript publish-review-submitted.ts
29
+ import { EventsClient } from '@acme/events';
30
+ import type { ReviewSubmitted } from './schemas/review-submitted';
31
+
32
+ const client = new EventsClient({
33
+ apiKey: process.env.ACME_API_KEY!,
34
+ });
35
+
36
+ const event: ReviewSubmitted = {
37
+ reviewId: '3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90',
38
+ productId: 'prod_tshirt_classic_white',
39
+ customerId: 'cust_4821',
40
+ rating: 5,
41
+ title: 'Perfect everyday tee',
42
+ body: 'Soft, thick cotton and it kept its shape after washing.',
43
+ submittedAt: '2026-09-14T18:22:10Z',
44
+ };
45
+
46
+ await client.publish('ReviewSubmitted', event);
47
+ ```
48
+
49
+ ```python publish_review_submitted.py
50
+ import os
51
+ from acme_events import EventsClient
52
+
53
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
54
+
55
+ event = {
56
+ "reviewId": "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
57
+ "productId": "prod_tshirt_classic_white",
58
+ "customerId": "cust_4821",
59
+ "rating": 5,
60
+ "title": "Perfect everyday tee",
61
+ "body": "Soft, thick cotton and it kept its shape after washing.",
62
+ "submittedAt": "2026-09-14T18:22:10Z",
63
+ }
64
+
65
+ client.publish("ReviewSubmitted", event)
66
+ ```
67
+
68
+ ```java PublishReviewSubmitted.java
69
+ import com.acme.events.EventsClient;
70
+ import java.util.Map;
71
+
72
+ public class PublishReviewSubmitted {
73
+ public static void main(String[] args) {
74
+ var client = new EventsClient(
75
+ System.getenv("ACME_API_KEY")
76
+ );
77
+
78
+ var event = Map.of(
79
+ "reviewId", "3f2b8c1e-5d4a-4e7b-9a1c-6b2d8e4f7a90",
80
+ "productId", "prod_tshirt_classic_white",
81
+ "customerId", "cust_4821",
82
+ "rating", 5,
83
+ "title", "Perfect everyday tee",
84
+ "body", "Soft, thick cotton and it kept its shape after washing.",
85
+ "submittedAt", "2026-09-14T18:22:10Z"
86
+ );
87
+
88
+ client.publish("ReviewSubmitted", event);
89
+ }
90
+ }
91
+ ```
92
+
93
+ </CodeGroup>
94
+
95
+ </Column>
96
+
97
+ </Columns>
98
+
99
+ ---
100
+
101
+ <Columns cols={2}>
102
+
103
+ <Column>
104
+
105
+ ## 2. Publish a review that has no title
106
+
107
+ A customer left a two-star review for the oversized grey hoodie without a title. The event still goes to the moderation worker, with the optional `title` left out.
108
+
109
+ ### Payload details
110
+
111
+ - `title` is omitted because the customer did not provide one.
112
+ - `productId` is `prod_hoodie_oversized_grey` and `customerId` is `cust_1057`.
113
+ - `rating` is `2`.
114
+ - `body` holds the short review text for moderation.
115
+
116
+ ### Using this example
117
+
118
+ Check that consumers handle a missing `title` and do not treat a low `rating` as a reason to reject the review.
119
+
120
+ The examples use a **fictional Acme Events SDK** to publish a payload matching the ReviewSubmitted schema. The package names and publish methods are illustrative.
121
+
122
+ </Column>
123
+
124
+ <Column>
125
+
126
+ <CodeGroup dropdown>
127
+
128
+ ```typescript publish-review-submitted.ts
129
+ import { EventsClient } from '@acme/events';
130
+ import type { ReviewSubmitted } from './schemas/review-submitted';
131
+
132
+ const client = new EventsClient({
133
+ apiKey: process.env.ACME_API_KEY!,
134
+ });
135
+
136
+ const event: ReviewSubmitted = {
137
+ reviewId: 'a7c4e2d9-1b3f-4c8a-b6e5-9d0f2a1c3e47',
138
+ productId: 'prod_hoodie_oversized_grey',
139
+ customerId: 'cust_1057',
140
+ rating: 2,
141
+ body: 'Nice fabric but the sleeves are too long for a size M.',
142
+ submittedAt: '2026-09-15T09:04:33Z',
143
+ };
144
+
145
+ await client.publish('ReviewSubmitted', event);
146
+ ```
147
+
148
+ ```python publish_review_submitted.py
149
+ import os
150
+ from acme_events import EventsClient
151
+
152
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
153
+
154
+ event = {
155
+ "reviewId": "a7c4e2d9-1b3f-4c8a-b6e5-9d0f2a1c3e47",
156
+ "productId": "prod_hoodie_oversized_grey",
157
+ "customerId": "cust_1057",
158
+ "rating": 2,
159
+ "body": "Nice fabric but the sleeves are too long for a size M.",
160
+ "submittedAt": "2026-09-15T09:04:33Z",
161
+ }
162
+
163
+ client.publish("ReviewSubmitted", event)
164
+ ```
165
+
166
+ ```java PublishReviewSubmitted.java
167
+ import com.acme.events.EventsClient;
168
+ import java.util.Map;
169
+
170
+ public class PublishReviewSubmitted {
171
+ public static void main(String[] args) {
172
+ var client = new EventsClient(
173
+ System.getenv("ACME_API_KEY")
174
+ );
175
+
176
+ var event = Map.of(
177
+ "reviewId", "a7c4e2d9-1b3f-4c8a-b6e5-9d0f2a1c3e47",
178
+ "productId", "prod_hoodie_oversized_grey",
179
+ "customerId", "cust_1057",
180
+ "rating", 2,
181
+ "body", "Nice fabric but the sleeves are too long for a size M.",
182
+ "submittedAt", "2026-09-15T09:04:33Z"
183
+ );
184
+
185
+ client.publish("ReviewSubmitted", event);
186
+ }
187
+ }
188
+ ```
189
+
190
+ </CodeGroup>
191
+
192
+ </Column>
193
+
194
+ </Columns>
@@ -0,0 +1,259 @@
1
+ <Columns cols={2}>
2
+
3
+ <Column>
4
+
5
+ ## 1. Get the latest reviews with default paging
6
+
7
+ The product page for the navy baseball cap loads its reviews. Only `productId` is sent, so the Review API uses its defaults.
8
+
9
+ ### Payload details
10
+
11
+ - `productId` is `prod_cap_baseball_navy`.
12
+ - `page`, `pageSize` and `sort` are omitted, so the defaults apply: page `1`, `20` reviews per page, sorted `newest` first.
13
+ - The response contains the aggregate rating and both published reviews for the cap, newest first.
14
+
15
+ The two reviews have 5 + 4 = **9 stars**, so `averageRating` is 9 / 2 = **4.5**.
16
+
17
+ ### Example response
18
+
19
+ ```json
20
+ {
21
+ "productId": "prod_cap_baseball_navy",
22
+ "averageRating": 4.5,
23
+ "reviewCount": 2,
24
+ "page": 1,
25
+ "pageSize": 20,
26
+ "reviews": [
27
+ {
28
+ "reviewId": "f1c7a9e3-6d2b-4f8a-8c4e-0b9d7a3f2e15",
29
+ "customerId": "cust_5502",
30
+ "rating": 5,
31
+ "title": "Great fit, adjustable strap",
32
+ "body": "Fits well and the colour has not faded in the sun.",
33
+ "helpfulCount": 3,
34
+ "publishedAt": "2026-09-12T15:31:07Z"
35
+ },
36
+ {
37
+ "reviewId": "b2d6f8a1-4c3e-4a9b-9f7d-5e1c3a8b0d24",
38
+ "customerId": "cust_6178",
39
+ "rating": 4,
40
+ "title": "Arrived a day late",
41
+ "body": "Took a day longer than expected, but the cap is solid.",
42
+ "helpfulCount": 0,
43
+ "publishedAt": "2026-09-10T11:08:52Z"
44
+ }
45
+ ]
46
+ }
47
+ ```
48
+
49
+ ### Using this example
50
+
51
+ Check that the defaults are applied when paging and sort fields are left out, and that only published reviews are returned.
52
+
53
+ The examples use a **fictional Acme Events SDK** to query a payload matching the GetProductReviews schema. The package names and query methods are illustrative.
54
+
55
+ </Column>
56
+
57
+ <Column>
58
+
59
+ <CodeGroup dropdown>
60
+
61
+ ```typescript query-get-product-reviews.ts
62
+ import { EventsClient } from '@acme/events';
63
+ import type { GetProductReviewsRequest, GetProductReviewsResponse } from './schemas/get-product-reviews';
64
+
65
+ const client = new EventsClient({
66
+ apiKey: process.env.ACME_API_KEY!,
67
+ });
68
+
69
+ const request: GetProductReviewsRequest = {
70
+ productId: 'prod_cap_baseball_navy',
71
+ };
72
+
73
+ const reviews: GetProductReviewsResponse = await client.query('GetProductReviews', request);
74
+
75
+ console.log(reviews.averageRating, reviews.reviewCount);
76
+ ```
77
+
78
+ ```python query_get_product_reviews.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
+ "productId": "prod_cap_baseball_navy",
86
+ }
87
+
88
+ reviews = client.query("GetProductReviews", request)
89
+
90
+ print(reviews["averageRating"], reviews["reviewCount"])
91
+ ```
92
+
93
+ ```java QueryGetProductReviews.java
94
+ import com.acme.events.EventsClient;
95
+ import java.util.Map;
96
+
97
+ public class QueryGetProductReviews {
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
+ "productId", "prod_cap_baseball_navy"
105
+ );
106
+
107
+ var reviews = client.query(
108
+ "GetProductReviews",
109
+ request
110
+ );
111
+
112
+ System.out.println(
113
+ reviews.get("averageRating") + " "
114
+ + reviews.get("reviewCount")
115
+ );
116
+ }
117
+ }
118
+ ```
119
+
120
+ </CodeGroup>
121
+
122
+ </Column>
123
+
124
+ </Columns>
125
+
126
+ ---
127
+
128
+ <Columns cols={2}>
129
+
130
+ <Column>
131
+
132
+ ## 2. Get a page of the most helpful reviews
133
+
134
+ A compact "Most helpful reviews" widget on the classic white T-shirt page shows two reviews at a time. The shopper moves to the second page.
135
+
136
+ ### Payload details
137
+
138
+ - `productId` is `prod_tshirt_classic_white`.
139
+ - `page` is `2` and `pageSize` is `2` (the schema allows 1 to 100).
140
+ - `sort` is `most_helpful`, one of `newest`, `highest`, `lowest` or `most_helpful`.
141
+ - The response is ordered by `helpfulCount`, highest first; the top two reviews were on page 1.
142
+
143
+ ### Example response
144
+
145
+ ```json
146
+ {
147
+ "productId": "prod_tshirt_classic_white",
148
+ "averageRating": 4.6,
149
+ "reviewCount": 128,
150
+ "page": 2,
151
+ "pageSize": 2,
152
+ "reviews": [
153
+ {
154
+ "reviewId": "0e5a3b7c-8d1f-4a2e-9b6c-3f8d1e7a5c49",
155
+ "customerId": "cust_2764",
156
+ "rating": 4,
157
+ "title": "Soft but runs slightly large",
158
+ "body": "Really soft cotton. Size down for a closer fit.",
159
+ "helpfulCount": 9,
160
+ "publishedAt": "2026-08-02T19:45:13Z"
161
+ },
162
+ {
163
+ "reviewId": "6a9d2e4f-1c8b-4d7a-a3e5-8b0c6f2d9e71",
164
+ "customerId": "cust_8841",
165
+ "rating": 5,
166
+ "title": "Survived 30 washes",
167
+ "body": "Still white and still in shape after months of washing.",
168
+ "helpfulCount": 7,
169
+ "publishedAt": "2026-07-21T08:17:36Z"
170
+ }
171
+ ]
172
+ }
173
+ ```
174
+
175
+ ### Using this example
176
+
177
+ Use this payload to test paging and sorting together: `reviewCount` stays the product total while `reviews` holds only the requested page.
178
+
179
+ The examples use a **fictional Acme Events SDK** to query a payload matching the GetProductReviews schema. The package names and query methods are illustrative.
180
+
181
+ </Column>
182
+
183
+ <Column>
184
+
185
+ <CodeGroup dropdown>
186
+
187
+ ```typescript query-get-product-reviews.ts
188
+ import { EventsClient } from '@acme/events';
189
+ import type { GetProductReviewsRequest, GetProductReviewsResponse } from './schemas/get-product-reviews';
190
+
191
+ const client = new EventsClient({
192
+ apiKey: process.env.ACME_API_KEY!,
193
+ });
194
+
195
+ const request: GetProductReviewsRequest = {
196
+ productId: 'prod_tshirt_classic_white',
197
+ page: 2,
198
+ pageSize: 2,
199
+ sort: 'most_helpful',
200
+ };
201
+
202
+ const reviews: GetProductReviewsResponse = await client.query('GetProductReviews', request);
203
+
204
+ console.log(reviews.averageRating, reviews.reviewCount);
205
+ ```
206
+
207
+ ```python query_get_product_reviews.py
208
+ import os
209
+ from acme_events import EventsClient
210
+
211
+ client = EventsClient(api_key=os.environ["ACME_API_KEY"])
212
+
213
+ request = {
214
+ "productId": "prod_tshirt_classic_white",
215
+ "page": 2,
216
+ "pageSize": 2,
217
+ "sort": "most_helpful",
218
+ }
219
+
220
+ reviews = client.query("GetProductReviews", request)
221
+
222
+ print(reviews["averageRating"], reviews["reviewCount"])
223
+ ```
224
+
225
+ ```java QueryGetProductReviews.java
226
+ import com.acme.events.EventsClient;
227
+ import java.util.Map;
228
+
229
+ public class QueryGetProductReviews {
230
+ public static void main(String[] args) {
231
+ var client = new EventsClient(
232
+ System.getenv("ACME_API_KEY")
233
+ );
234
+
235
+ var request = Map.of(
236
+ "productId", "prod_tshirt_classic_white",
237
+ "page", 2,
238
+ "pageSize", 2,
239
+ "sort", "most_helpful"
240
+ );
241
+
242
+ var reviews = client.query(
243
+ "GetProductReviews",
244
+ request
245
+ );
246
+
247
+ System.out.println(
248
+ reviews.get("averageRating") + " "
249
+ + reviews.get("reviewCount")
250
+ );
251
+ }
252
+ }
253
+ ```
254
+
255
+ </CodeGroup>
256
+
257
+ </Column>
258
+
259
+ </Columns>