v2.3.0
medusajs/medusav2.3.0Jan 17, 2025by olivermrbl
AI Summary
This release improves inventory UX, introduces data migration scripts, and adds cart validation hooks. It also removes deprecated fields from the Payment Module.
Key Highlights
- Foundation for data migration scripts.
- Cart validation hooks added to all cart workflows.
- Variant Inventory UX upgrade with new bulk editors (Breaking change).
- Payment module data model cleanup (Breaking change).
- Promotion statuses added (active, inactive, draft).
Breaking Changes
- Batch location levels endpoint structure changed from `creates`/`deletes` to `create`/`delete`/`update`.
- Removed fields from Payment Module: `region_id` from Payment Collection, `cart_id`, `order_id`, `customer_id` from Payment entity.
New Features
- Add default retry strategy for redis
- Add plugin develop command
- Add plugin build command
- Enable migration scripts
- Validation hook for cart workflows
- Add support for listing saved payment methods
- Add statuses to promotions
Full Release Notes
<!--

# v2.3.0
This release improves the UX of inventory management in Medusa Admin, introduces data migration scripts, and much more.
CMS_BREAK -->
## 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 https://github.com/medusajs/medusa/pull/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:
```ts
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 https://github.com/medusajs/medusa/pull/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 https://github.com/medusajs/medusa/pull/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 https://github.com/medusajs/medusa/pull/10950 for more.
## Features
* feat: add default retry strategy for redis by @thetutlage in https://github.com/medusajs/medusa/pull/10880
* feat: remove dead code and refactor the logic of resolving plugins by @thetutlage in https://github.com/medusajs/medusa/pull/10874
* feat: Merge plugin modules by @thetutlage in https://github.com/medusajs/medusa/pull/10895
* feat(inventory,dashboard,types,core-flows,js-sdk,medusa): Improve inventory UX by @kasperkristensen in https://github.com/medusajs/medusa/pull/10630
* feat(admin-bundler,admin-vite-plugin,medusa): Add support for loading Admin Extensions from plugins by @kasperkristensen in https://github.com/medusajs/medusa/pull/10869
* Feat/plugin develop by @thetutlage in https://github.com/medusajs/medusa/pull/10926
* feat: add plugin build command by @thetutlage in https://github.com/medusajs/medusa/pull/10935
* feat: Scaffold plugin in create-medusa-app by @adrien2p in https://github.com/medusajs/medusa/pull/10908
* feat(cli): Add plugin:publish and plugin:add commands support by @adrien2p in https://github.com/medusajs/medusa/pull/10938
* feat(medusa,framework,cli,admin-bundler): Integrate admin extensions into medusa build:plugin by @kasperkristensen in https://github.com/medusajs/medusa/pull/10941
* feat(core, medusa, cli): Enable migration scripts by @adrien2p in https://github.com/medusajs/medusa/pull/10960
* feat(core-flows): validate hook by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/10967
* feat: add support for loading admin extensions from the source by @thetutlage in https://github.com/medusajs/medusa/pull/10975
* feat: Improvements to payment module and Stripe provider by @sradevski in https://github.com/medusajs/medusa/pull/10980
* feat: Remove fields from payment models that were leftovers from v1 by @sradevski in https://github.com/medusajs/medusa/pull/10987
* feat: Add support for listing saved payment methods in module and Stripe by @sradevski in https://github.com/medusajs/medusa/pull/10994
* feat(promotion,dashboard,types,utils,medusa): Add statuses to promotions by @riqwan in https://github.com/medusajs/medusa/pull/10950
* Feat(medusa, cli): plugin db generate by @adrien2p in https://github.com/medusajs/medusa/pull/10988
## Bugs
* fix(pricing): PriceLists of type Sale should not override lower prices by @kasperkristensen in https://github.com/medusajs/medusa/pull/10882
* fix: event-bus-redis processor execute event before subscriber are loaded by @pmc12thsuki in https://github.com/medusajs/medusa/pull/10823
* fix(pricing): add null conditions for deleted at during price calculations by @riqwan in https://github.com/medusajs/medusa/pull/10896
* fix(modules): Fix miss leading provider resolution error by @adrien2p in https://github.com/medusajs/medusa/pull/10900
* fix(types): add missing inventory_items to input of createProductsWorkflow by @shahednasser in https://github.com/medusajs/medusa/pull/10892
* fix(orchestration): avoid retry when finished by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/10913
* fix(core-flows): return refunded when all captured payments have been refunded by @riqwan in https://github.com/medusajs/medusa/pull/10923
* fix(dashboard, core-flows): improvements to order page on canceled orders by @riqwan in https://github.com/medusajs/medusa/pull/10888
* fix(core-flows): missing variable of when condition by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/10958
* fix: Include is default billing and shipping fields in the address re… by @sradevski in https://github.com/medusajs/medusa/pull/10970
* chore(dashboard,icons): Update icons and switch icon in CategoryTree by @kasperkristensen in https://github.com/medusajs/medusa/pull/10961
* fix(index): Add type casting to raw order by by @adrien2p in https://github.com/medusajs/medusa/pull/10899
* fix: Put routes loader error inline by @sradevski in https://github.com/medusajs/medusa/pull/10912
* fix(framework): Exclude .d.ts files from the glob search and fix insert query by @adrien2p in https://github.com/medusajs/medusa/pull/10990
* fix(dashboard): delete user messages by @fPolic in https://github.com/medusajs/medusa/pull/11004
* fix(core-flows,medusa): use deleteRefundReasonsWorkflow in delete /admin/refund-reasons/:id by @shahednasser in https://github.com/medusajs/medusa/pull/11012
## Documentation
* docs: fix divider in API reference + clean up layout by @shahednasser in https://github.com/medusajs/medusa/pull/10861
* docs: document create-medusa-app new project name argument by @shahednasser in https://github.com/medusajs/medusa/pull/10834
* docs-util: fixes to OAS generator + generate OAS by @shahednasser in https://github.com/medusajs/medusa/pull/10867
* docs: document dependencies for auth provider by @shahednasser in https://github.com/medusajs/medusa/pull/10865
* docs: update recipes following 2.2 release by @shahednasser in https://github.com/medusajs/medusa/pull/10868
* docs: added Cloudflare R2 guide for Object Storage by @ehtisham-afzal in https://github.com/medusajs/medusa/pull/10497
* docs: fix typo by @gharbi-mohamed-dev in https://github.com/medusajs/medusa/pull/10870
* docs: added llms.txt by @shahednasser in https://github.com/medusajs/medusa/pull/10873
* docs: general fixes and additions by @shahednasser in https://github.com/medusajs/medusa/pull/10876
* docs-util: fix parsing when function if it has three parameters by @shahednasser in https://github.com/medusajs/medusa/pull/10878
* docs-util: add warning on request parameters change by @shahednasser in https://github.com/medusajs/medusa/pull/10881
* docs: add inventory kit conceptual guide by @shahednasser in https://github.com/medusajs/medusa/pull/10891
* docs: fix colon in api key header by @shahednasser in https://github.com/medusajs/medusa/pull/10893
* docs: add workflow and js sdk reference pages for commerce modules by @shahednasser in https://github.com/medusajs/medusa/pull/10898
* docs-util: fix hook input type showing as __type by @shahednasser in https://github.com/medusajs/medusa/pull/10905
* docs: DX improvements to a workflow / step reference page by @shahednasser in https://github.com/medusajs/medusa/pull/10906
* docs: typo fixes in execute workflow section by @shahednasser in https://github.com/medusajs/medusa/pull/10911
* docs-util: add examples generator for workflows and steps by @shahednasser in https://github.com/medusajs/medusa/pull/10914
* docs: update breaking changes for google auth storefront by @ranjithkumar8352 in https://github.com/medusajs/medusa/pull/10924
* docs: fix validation in restaurant-delivery marketplace recipe by @shahednasser in https://github.com/medusajs/medusa/pull/10925
* docs: fixes to workflow reference tooling by @shahednasser in https://github.com/medusajs/medusa/pull/10931
* docs: add a note about promotion types support in Medusa Admin by @shahednasser in https://github.com/medusajs/medusa/pull/10933
* docs: fix authentication callback descriptions to include all query parameters by @shahednasser in https://github.com/medusajs/medusa/pull/10932
* docs: remove redundant body parameter in fetch customer by @ranjithkumar8352 in https://github.com/medusajs/medusa/pull/10934
* chore(docs): generate references following latest workflows reference changes by @shahednasser in https://github.com/medusajs/medusa/pull/10943
* docs-util: remove duplicate union children by @shahednasser in https://github.com/medusajs/medusa/pull/10942
* docs: add additional data description in generated references by @shahednasser in https://github.com/medusajs/medusa/pull/10944
* docs-util: reorder workflow execution examples by @shahednasser in https://github.com/medusajs/medusa/pull/10955
* docs: small typo fix by @shahednasser in https://github.com/medusajs/medusa/pull/10956
* docs: handle step tooltip bug in safari by @shahednasser in https://github.com/medusajs/medusa/pull/10954
* docs-util: add exception for workflow examples modification + show summary instead of comment by @shahednasser in https://github.com/medusajs/medusa/pull/10963
* docs: fixes to database transaction docs by @shahednasser in https://github.com/medusajs/medusa/pull/10978
* chore(js-sdk): update TSDocs of auth callback by @shahednasser in https://github.com/medusajs/medusa/pull/11005
* chore: fix manage customer groups of customer OAS by @shahednasser in https://github.com/medusajs/medusa/pull/11011
* docs: fix select code blocks in UI docs by @shahednasser in https://github.com/medusajs/medusa/pull/11010
### Chores
* chore(medusa): Add handler path to the http tracing to be able to group by by @adrien2p in https://github.com/medusajs/medusa/pull/10835
* chore: move build utilities to Compiler class by @thetutlage in https://github.com/medusajs/medusa/pull/10904
* chore(core-flows,types): add tsdocs for create cart workflow by @shahednasser in https://github.com/medusajs/medusa/pull/10928
* chore(core-flows,types): improve tsdocs of workflows [1] by @shahednasser in https://github.com/medusajs/medusa/pull/10940
* chore: Use local CLI version in CI by @olivermrbl in https://github.com/medusajs/medusa/pull/10982
* chore(core-flows,types): improve TSDocs of product workflows by @shahednasser in https://github.com/medusajs/medusa/pull/10966
* chore(core-flows,types): improve TSDocs of order workflows by @shahednasser in https://github.com/medusajs/medusa/pull/10983
* chore(core-flows,types): improve TSDocs of cart workflows and steps by @shahednasser in https://github.com/medusajs/medusa/pull/10962
* chore(core-flows,types): improve tsdocs of fulfillment by @shahednasser in https://github.com/medusajs/medusa/pull/10995
* chore(core-flows): improve TSDocs of customer and customer groups workflows / steps by @shahednasser in https://github.com/medusajs/medusa/pull/10993
* chore: lazy import admin-bundler and run scripts during publish by @thetutlage in https://github.com/medusajs/medusa/pull/10996
* chore(core-flows): improve TSDocs for payment workflows / steps by @shahednasser in https://github.com/medusajs/medusa/pull/10998
* chore(core-flows,types): improve tsdocs of pricing-related workflows by @shahednasser in https://github.com/medusajs/medusa/pull/11000
* chore(core-flows,types): improve TSDocs of inventory-related workflows by @shahednasser in https://github.com/medusajs/medusa/pull/11013
* chore(core-flows,types): update TSDocs related to promotion workflows by @shahednasser in https://github.com/medusajs/medusa/pull/11014
* chore(core-flows,types): improve TSDocs of user-related workflows by @shahednasser in https://github.com/medusajs/medusa/pull/11017
* chore(core-flows, types): improve TSDocs of tax and region related workflows by @shahednasser in https://github.com/medusajs/medusa/pull/11018
* chore(core-flows,types): improve TSDocs for remaining workflows by @shahednasser in https://github.com/medusajs/medusa/pull/11021
### Other Changes
* docs: fix typo by @gharbi-mohamed-dev in https://github.com/medusajs/medusa/pull/10894
* [Fix] Update Repository Directory Paths for All Packages by @rahul-rocket in https://github.com/medusajs/medusa/pull/10910
## New Contributors
* @ehtisham-afzal made their first contribution in https://github.com/medusajs/medusa/pull/10497
* @gharbi-mohamed-dev made their first contribution in https://github.com/medusajs/medusa/pull/10870
* @pmc12thsuki made their first contribution in https://github.com/medusajs/medusa/pull/10823
* @rahul-rocket made their first contribution in https://github.com/medusajs/medusa/pull/10910
**Full Changelog**: https://github.com/medusajs/medusa/compare/v2.2.0...v2.3.0