packages/core/src/workflows/review/. Import them from @mercurjs/core/workflows and run them with the Medusa container. None of them exposes a workflow hook, and none emits an event of its own: the events come from the module service, as listed in the Events reference.
createReviewWorkflow
Validates a submission, creates apending review, and writes its customer, order, and target links. Workflow id create-review. Input type CreateReviewDTO, returns the created review.
The workflow runs three steps:
validate-review: fails withINVALID_DATA“Order not found!” when no order matchesorder_idandcustomer_id, and with “Review already exists” when the order has a review with the samereferenceand target idcreate-review: creates the review and links it to the customer and the order; on rollback, deletes the reviewcreate-remote-links: Medusa’screateRemoteLinkStep, which links the review to the product or the seller
updateReviewWorkflow
Updates any of a review’s editable fields, includingstatus. Workflow id update-review. Input type UpdateReviewDTO, returns the updated review.
Its single step,
update-review, reads the review before writing. On rollback it restores the previous rating, customer_note, seller_note, and status.
respondReviewWorkflow
Writes a store’s answer toseller_note, once. Workflow id respond-review. Input type RespondReviewDTO, returns the updated review.
Its single step,
respond-review, fails with NOT_FOUND “Review not found” for an unknown id and with NOT_ALLOWED “This review already has a response” when seller_note is set. On rollback it sets seller_note back to null. The workflow doesn’t check which store owns the review: the Vendor API checks the seller link before running it.
deleteReviewWorkflow
Soft deletes a review. Workflow iddelete-review. The input is the review id as a plain string, and the workflow returns that id.
delete-review, calls softDeleteReviews and leaves the review’s links in place. On rollback it calls restoreReviews.
Steps
@mercurjs/core/workflows also exports each step, so you can compose them into your own workflows: