Highlights
Data migrations script
Some features might require data migrations to ensure new functionality works as expected after an upgrade. Typically, these migrations can be dealt with by database migrations within a module. However, this is not the case when the changes affect the data models in several modules. In those scenarios, the data in multiple modules need to be brought to the desired state.
To support this, we've introduced data migration scripts. They are very similar to regular scripts in the sense, that you have access to the dependency container, i.e. all modules. However, instead of running manually, data migration scripts are run automatically as part of running medusa db:migrate
.
How it works
We scour Medusa projects, plugins, and the core for files in the src/migration-scripts
and execute them. The files should export a default function. These scripts are only run once, provided they succeed.
The flow is as follows:
- Find files
- Ensure the
script_migrations
table exists–if not, create it - Identify pending migration scripts (scripts that have not been ran previously)
- Acquire a lock on the table
- Begin loop, for each script
- Insert migration script in the database
- Execute script
- Mark script as finished
- Release lock
This release focuses on putting the foundation in place for data migrations and does not introduce any scripts.
See #10960 for more.
Cart validation hooks
All Cart workflows have been updated to include a hook to perform validation before executing the operation.
For example, in the completeCartWorkflow
you can register a hook like so:
import { completeCartWorkflow } from "@medusajs/medusa/core-flows"
completeCartWorkflow.hooks.validate({ cart } => {
if (!cart.metadata.approved_at) {
throw new Error("Cannot complete unapproved cart")
}
})
Variant Inventory UX upgrade
Warning
Breaking changes
New bulk editors have been added to improve inventory management. One on the product details page, and another on the inventory item list page.
To enable these improvements, we have had to introduce breaking changes to the endpoint updating location levels in batches.
Before
POST /admin/inventory-items/:id/location-levels/batch
{ creates: [ ... ], deletes: [ ... ] }
After
POST /admin/inventory-items/:id/location-levels/batch
{ create: [ ... ], delete: [ ... ], update: [...] }
This brings the endpoint in line with all other batch endpoints.
See #10630 for more.
Payment module changes
Warning
Breaking changes
Data models in the Payment Module have been cleaned up, removing unused fields. This is a breaking change.
The removed fields are region_id
from the Payment Collection entity and cart_id
, order_id
, and customer_id
from the payment entity.
See #10987 for more.
Promotion statuses
The process of creating a promotion is sometimes a lengthy one that requires a campaign to be designed, promotion rules to be drafted, approvals to go through, and time to test it out.
This release introduces statuses on promotions to enable these workflows.
Promotions can now be either active
, inactive
, or draft
. All existing promotions will be set to active
whileas new promotion will start in a draft
state, unless specified otherwise.
See #10950 for more.
Features
- feat: add default retry strategy for redis by @thetutlage in #10880
- feat: remove dead code and refactor the logic of resolving plugins by @thetutlage in #10874
- feat: Merge plugin modules by @thetutlage in #10895
- feat(inventory,dashboard,types,core-flows,js-sdk,medusa): Improve inventory UX by @kasperkristensen in #10630
- feat(admin-bundler,admin-vite-plugin,medusa): Add support for loading Admin Extensions from plugins by @kasperkristensen in #10869
- Feat/plugin develop by @thetutlage in #10926
- feat: add plugin build command by @thetutlage in #10935
- feat: Scaffold plugin in create-medusa-app by @adrien2p in #10908
- feat(cli): Add plugin:publish and plugin:add commands support by @adrien2p in #10938
- feat(medusa,framework,cli,admin-bundler): Integrate admin extensions into medusa build:plugin by @kasperkristensen in #10941
- feat(core, medusa, cli): Enable migration scripts by @adrien2p in #10960
- feat(core-flows): validate hook by @carlos-r-l-rodrigues in #10967
- feat: add support for loading admin extensions from the source by @thetutlage in #10975
- feat: Improvements to payment module and Stripe provider by @sradevski in #10980
- feat: Remove fields from payment models that were leftovers from v1 by @sradevski in #10987
- feat: Add support for listing saved payment methods in module and Stripe by @sradevski in #10994
- feat(promotion,dashboard,types,utils,medusa): Add statuses to promotions by @riqwan in #10950
- Feat(medusa, cli): plugin db generate by @adrien2p in #10988
Bugs
- fix(pricing): PriceLists of type Sale should not override lower prices by @kasperkristensen in #10882
- fix: event-bus-redis processor execute event before subscriber are loaded by @pmc12thsuki in #10823
- fix(pricing): add null conditions for deleted at during price calculations by @riqwan in #10896
- fix(modules): Fix miss leading provider resolution error by @adrien2p in #10900
- fix(types): add missing inventory_items to input of createProductsWorkflow by @shahednasser in #10892
- fix(orchestration): avoid retry when finished by @carlos-r-l-rodrigues in #10913
- fix(core-flows): return refunded when all captured payments have been refunded by @riqwan in #10923
- fix(dashboard, core-flows): improvements to order page on canceled orders by @riqwan in #10888
- fix(core-flows): missing variable of when condition by @carlos-r-l-rodrigues in #10958
- fix: Include is default billing and shipping fields in the address re… by @sradevski in #10970
- chore(dashboard,icons): Update icons and switch icon in CategoryTree by @kasperkristensen in #10961
- fix(index): Add type casting to raw order by by @adrien2p in #10899
- fix: Put routes loader error inline by @sradevski in #10912
- fix(framework): Exclude .d.ts files from the glob search and fix insert query by @adrien2p in #10990
- fix(dashboard): delete user messages by @fPolic in #11004
- fix(core-flows,medusa): use deleteRefundReasonsWorkflow in delete /admin/refund-reasons/:id by @shahednasser in #11012
Documentation
- docs: fix divider in API reference + clean up layout by @shahednasser in #10861
- docs: document create-medusa-app new project name argument by @shahednasser in #10834
- docs-util: fixes to OAS generator + generate OAS by @shahednasser in #10867
- docs: document dependencies for auth provider by @shahednasser in #10865
- docs: update recipes following 2.2 release by @shahednasser in #10868
- docs: added Cloudflare R2 guide for Object Storage by @ehtisham-afzal in #10497
- docs: fix typo by @gharbi-mohamed-dev in #10870
- docs: added llms.txt by @shahednasser in #10873
- docs: general fixes and additions by @shahednasser in #10876
- docs-util: fix parsing when function if it has three parameters by @shahednasser in #10878
- docs-util: add warning on request parameters change by @shahednasser in #10881
- docs: add inventory kit conceptual guide by @shahednasser in #10891
- docs: fix colon in api key header by @shahednasser in #10893
- docs: add workflow and js sdk reference pages for commerce modules by @shahednasser in #10898
- docs-util: fix hook input type showing as __type by @shahednasser in #10905
- docs: DX improvements to a workflow / step reference page by @shahednasser in #10906
- docs: typo fixes in execute workflow section by @shahednasser in #10911
- docs-util: add examples generator for workflows and steps by @shahednasser in #10914
- docs: update breaking changes for google auth storefront by @ranjithkumar8352 in #10924
- docs: fix validation in restaurant-delivery marketplace recipe by @shahednasser in #10925
- docs: fixes to workflow reference tooling by @shahednasser in #10931
- docs: add a note about promotion types support in Medusa Admin by @shahednasser in #10933
- docs: fix authentication callback descriptions to include all query parameters by @shahednasser in #10932
- docs: remove redundant body parameter in fetch customer by @ranjithkumar8352 in #10934
- chore(docs): generate references following latest workflows reference changes by @shahednasser in #10943
- docs-util: remove duplicate union children by @shahednasser in #10942
- docs: add additional data description in generated references by @shahednasser in #10944
- docs-util: reorder workflow execution examples by @shahednasser in #10955
- docs: small typo fix by @shahednasser in #10956
- docs: handle step tooltip bug in safari by @shahednasser in #10954
- docs-util: add exception for workflow examples modification + show summary instead of comment by @shahednasser in #10963
- docs: fixes to database transaction docs by @shahednasser in #10978
- chore(js-sdk): update TSDocs of auth callback by @shahednasser in #11005
- chore: fix manage customer groups of customer OAS by @shahednasser in #11011
- docs: fix select code blocks in UI docs by @shahednasser in #11010
Chores
- chore(medusa): Add handler path to the http tracing to be able to group by by @adrien2p in #10835
- chore: move build utilities to Compiler class by @thetutlage in #10904
- chore(core-flows,types): add tsdocs for create cart workflow by @shahednasser in #10928
- chore(core-flows,types): improve tsdocs of workflows [1] by @shahednasser in #10940
- chore: Use local CLI version in CI by @olivermrbl in #10982
- chore(core-flows,types): improve TSDocs of product workflows by @shahednasser in #10966
- chore(core-flows,types): improve TSDocs of order workflows by @shahednasser in #10983
- chore(core-flows,types): improve TSDocs of cart workflows and steps by @shahednasser in #10962
- chore(core-flows,types): improve tsdocs of fulfillment by @shahednasser in #10995
- chore(core-flows): improve TSDocs of customer and customer groups workflows / steps by @shahednasser in #10993
- chore: lazy import admin-bundler and run scripts during publish by @thetutlage in #10996
- chore(core-flows): improve TSDocs for payment workflows / steps by @shahednasser in #10998
- chore(core-flows,types): improve tsdocs of pricing-related workflows by @shahednasser in #11000
- chore(core-flows,types): improve TSDocs of inventory-related workflows by @shahednasser in #11013
- chore(core-flows,types): update TSDocs related to promotion workflows by @shahednasser in #11014
- chore(core-flows,types): improve TSDocs of user-related workflows by @shahednasser in #11017
- chore(core-flows, types): improve TSDocs of tax and region related workflows by @shahednasser in #11018
- chore(core-flows,types): improve TSDocs for remaining workflows by @shahednasser in #11021
Other Changes
- docs: fix typo by @gharbi-mohamed-dev in #10894
- [Fix] Update Repository Directory Paths for All Packages by @rahul-rocket in #10910
New Contributors
- @ehtisham-afzal made their first contribution in #10497
- @gharbi-mohamed-dev made their first contribution in #10870
- @pmc12thsuki made their first contribution in #10823
- @rahul-rocket made their first contribution in #10910
Full Changelog: v2.2.0...v2.3.0