v2.1.1
medusajs/medusav2.1.1Dec 10, 2024by olivermrbl
AI Summary
This version introduces shipping option rules based on cart totals and migrates the Cart, Sales Channel, API Key, and Store modules to the Data Model API.
Key Highlights
- New shipping option rules allow pricing based on cart item total (e.g., free shipping above 100 EUR).
- Cart, Sales Channel, API Key, Store, Workflow Engine, and Locking modules have been migrated to DML.
- Support for `hasOne` with FK has been added to DML.
- The admin dashboard has been translated into Japanese.
New Features
- Add support for defining hasOne with FK.
- Migrate cart module to DML.
- Migrate sales-channel to DML.
- Migrate api key module to DML.
- Make credentials configurable in JS SDK.
- Migrate store module to DML.
- Update shipping methods upon cart operations.
Full Release Notes
<!--

# v2.1.1
This version introduces shipping option rules with support for cart total ranges.
CMS_BREAK -->
## Highlights
### Shipping option rules
We've introduced support for pricing rules on shipping options. Initially, the feature allows you to define prices based on the cart item total. For example, you could have a free shipping option that is only available when the item total is above 100 EUR.
Every time the cart is updated, e.g. with new items, we refresh the shipping methods to ensure the correct price is applied at all times.
You'll find the new setting in the admin dashboard under "Settings > Locations & Shipping > View details > Edit prices (on shipping option)".
### New languages
Our admin dashboard has been translated into Japanese.
### DML Migrations
> [!WARNING]
Schema changes
We've migrated our Cart, Sales Channel, API Key, Store, Workflow Engine, and Locking modules to use our Data Model API. These migrations include minor changes to the database schema, primarily around renaming indexes to respect our autogenerated naming conventions.
Read more about each of the schema changes in the PRs below.
**Changes to `hasOne`**
As part of our DML work, the behavior of `hasOne` has been updated in use cases where it is only defined on one side of the relation. In these cases, the `mappedBy` configuration of the `hasOne` definition needs to be set to `undefined` as it is not present on the other model.
For example:
```ts
const email = model.define("email", {
email: model.text(),
isVerified: model.boolean(),
})
const user = model.define("user", {
id: model.number(),
username: model.text(),
email: model.hasOne(() => email, { mappedBy: undefined }), // <------------ Required config
})
```
**Required actions**
Run migrations to ensure your server functions as expected after upgrading to v2.1.0:
```
npx medusa db:migrate
```
## Features
* feat: add support for defining hasOne with FK by @thetutlage in https://github.com/medusajs/medusa/pull/10441
* refactor: migrate cart module to DML by @thetutlage in https://github.com/medusajs/medusa/pull/10385
* refactor: migrate sales-channel to DML by @thetutlage in https://github.com/medusajs/medusa/pull/10452
* refactor: migrate api key module to DML by @thetutlage in https://github.com/medusajs/medusa/pull/10450
* feat(js-sdk): Make credentials configurable in SDK by @sradevski in https://github.com/medusajs/medusa/pull/10464
* refactor: migrate store module to DML by @thetutlage in https://github.com/medusajs/medusa/pull/10467
* feat(core-flows, types): update shipping methods upon cart ops by @riqwan in https://github.com/medusajs/medusa/pull/10382
* feat(dashboard): SO cart item total rules UI by @kasperkristensen in https://github.com/medusajs/medusa/pull/10386
## Bugs
* fix(dashboard,types): Add missing Metadata form for Region domain and fix payload types by @kasperkristensen in https://github.com/medusajs/medusa/pull/10449
* fix(core/js-sdk) Add the credentials field in the fetch() only if supported by @sgirones in https://github.com/medusajs/medusa/pull/10446
* fix(dashboard): Cleanup unsafe accesses to possibly undefined values in order timeline by @kasperkristensen in https://github.com/medusajs/medusa/pull/10454
* fix(): Deleted default sales channel should be prevented by @adrien2p in https://github.com/medusajs/medusa/pull/10193
* fix(utils): DML one to one definition by @adrien2p in https://github.com/medusajs/medusa/pull/10415
* fix(workflows-sdk): name for when/then step by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/10459
* fix(framework): add missing query type argument in request types by @shahednasser in https://github.com/medusajs/medusa/pull/10456
* fix(dashboard): Prevent sending off empty string as handle for product category by @kasperkristensen in https://github.com/medusajs/medusa/pull/10473
* fix(utils): avoid optional properties on graphql generated file by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/10476
* fix(dashboard,types): Fix TS errors by @kasperkristensen in https://github.com/medusajs/medusa/pull/10457
* fix(promotion, core-flows): updating cart with removed promotion removes adjustments by @riqwan in https://github.com/medusajs/medusa/pull/10489
* fix(medusa): add query type argument to RequestWithContext by @shahednasser in https://github.com/medusajs/medusa/pull/10469
* fix(medusa): calculate sales channel availability correctly for variants by @srindom in https://github.com/medusajs/medusa/pull/10448
## Documentation
* docs: add documentation for check constraints by @shahednasser in https://github.com/medusajs/medusa/pull/10425
* docs: add note about default owner table in many-to-many by @shahednasser in https://github.com/medusajs/medusa/pull/10426
* docs: generate references manually by @shahednasser in https://github.com/medusajs/medusa/pull/10438
* docs: revise extend create product by @shahednasser in https://github.com/medusajs/medusa/pull/10444
* docs: revise query linked records by @shahednasser in https://github.com/medusajs/medusa/pull/10447
* docs: fix links in extend product guide by @shahednasser in https://github.com/medusajs/medusa/pull/10472
* docs-util: support new query type argument by @shahednasser in https://github.com/medusajs/medusa/pull/10468
* docs: revise admin customization pages by @shahednasser in https://github.com/medusajs/medusa/pull/10466
* docs: revise last chapters of customizations by @shahednasser in https://github.com/medusajs/medusa/pull/10480
* docs: support detecting broken link cross-projects by @shahednasser in https://github.com/medusajs/medusa/pull/10483
* docs: fix self hosting deployments not showing by @shahednasser in https://github.com/medusajs/medusa/pull/10486
* docs: revise main docs outline by @shahednasser in https://github.com/medusajs/medusa/pull/10502
* docs: fix links to steps in workflow references by @shahednasser in https://github.com/medusajs/medusa/pull/10503
* docs-util: normalize RelationNullableModifier in model references by @shahednasser in https://github.com/medusajs/medusa/pull/10505
## Chores
* chore(utils): DML#hasOne allow mappedBy to not be defined by @adrien2p in https://github.com/medusajs/medusa/pull/10442
* chore: locking-postgres provider dml by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/10478
* chore(workflow-engine): Migrate to DML by @adrien2p in https://github.com/medusajs/medusa/pull/10477
## Other Changes
* feat: added Japanese translation by @hirotaka in https://github.com/medusajs/medusa/pull/10379
## New Contributors
* @sgirones made their first contribution in https://github.com/medusajs/medusa/pull/10446
* @hirotaka made their first contribution in https://github.com/medusajs/medusa/pull/10379
**Full Changelog**: https://github.com/medusajs/medusa/compare/v2.1.0...v2.1.1