createReviewWorkflow that validates the submission, creates the
Review record, and links it to its target, order, and customer in one step. Run
it from any place that has access to the Medusa container.
Run the workflow
src/api/custom/route.ts
reference field selects the target: pass "product" with a product id, or
"seller" with a seller id, in reference_id.
The workflow validates that the
order_id belongs to customer_id and that
the customer hasn’t already reviewed the same target on that order. Either
check failing raises an error and no review is created.Statuses on creation
A new review is created aspending and stays hidden until it’s moderated. See
Moderate a review to publish or
reject it.