@mercurjs/core/workflows. They run against the Medusa container, and each step compensates on failure unless noted. None of them emits an event.
createCommissionRatesWorkflow
Creates one or more commission rates. Workflow idcreate-commission-rates.
CreateCommissionRateDTO takes name, type, and value, and optionally code, currency_code, include_tax, include_shipping, is_enabled, and is_default. The module also accepts nested rules and values arrays, which the DTO doesn’t declare. A missing code is generated from name.
- Output: the created rates, in input order
- Steps:
createCommissionRatesStep, compensated by deleting the created rates - Hooks: none
updateCommissionRatesWorkflow
Updates fields on one or more rates. Workflow idupdate-commission-rates.
Each item needs an
id and takes any CreateCommissionRateDTO field as optional.
- Output: the updated rates
- Steps:
updateCommissionRatesStep - Hooks: none
deleteCommissionRatesWorkflow
Soft-deletes rates after checking that none of them is the global rate. Workflow iddelete-commission-rates.
- Output: none
- Steps:
validateCommissionRatesDeletableStep, which throwsNOT_ALLOWEDfor anis_defaultrate, thendeleteCommissionRatesStep, compensated by restoring the rates - Hooks:
commissionRatesDeleted, with{ ids }
batchCommissionRulesWorkflow
Creates, updates, and deletes the rules of one rate. Workflow idbatch-commission-rules.
- Output:
{ created, updated, deleted }, wheredeletedholds the ids - Steps:
createCommissionRulesStep,updateCommissionRulesStep, anddeleteCommissionRulesStep, run in parallel - Hooks: none
create uses commission_rate_id. The ids in update and delete aren’t checked against it.
refreshOrderCommissionLinesWorkflow
Recomputes and replaces the commission lines of one or more orders. Workflow idrefresh-order-commission-lines.
- Output:
CommissionLineDTO[], the lines written for all the orders - Steps:
fetch-orders(useQueryGraphStep),getCommissionLinesStep,upsertCommissionLinesStep - Called by:
completeCartWithSplitOrdersWorkflowand theorder-commission-refresh-handlersubscriber
getCommissionLinesStep nor upsertCommissionLinesStep defines a compensation.
Exported steps
@mercurjs/core/workflows also exports each step, with its id, for use in your own workflows: