v2.0.7

medusajs/medusav2.0.7Nov 27, 2024by olivermrbl

AI Summary

This release introduces order transfers between customers and migrates the Product module to the Data Model API, adding support for multiple new languages.

Key Highlights

  • Order transfers between customers are now supported via UI and API.
  • The Product module has been migrated to DML, requiring explicit owner configuration for `manyToMany` relations.
  • Pivot table naming conventions have been updated.
  • New languages added: Brazilian Portuguese, French, Thai, and Spanish.

Breaking Changes

  • Product module migration to DML changes `manyToMany` relation ownership logic.
  • Pivot table naming for `manyToMany` relations has changed.

New Features

  • Allow setting a tooltip for disabled action items.
  • Customer page transfer order + cancel request in timeline.
  • Convert MikroORM entities to DML entities.
  • Add ptBR (Brazilian Portuguese) in translations.
  • Add Thai language support.

Full Release Notes

<!-- 
![order-transfer](https://github.com/user-attachments/assets/e5c6b044-d100-4f30-b781-7dbde4216bbe)

# v2.0.7

This version introduces order transfers and new languages to Medusa Admin.

CMS_BREAK -->

## Highlights

### Order transfers

You can now transfer order ownership between customers. We've added UI support in three places:
- Order details page in Medusa Admin
- Customer details page (Order list) in Medusa Admin
- Self-serve in our Next.js and B2B starters

The high-level flow is as follows:

1. Initiate transfer
```
POST /admin/orders/:id/transfer  { customer_id: string }
```

Send a request to generate a transfer token and emit an event with the order ID.

2. Event subscriber

A subscriber picks up the event and emails the order’s current customer with the token.

4. Accept Transfer

Customer accepts the order transfer.

```
POST /store/orders/:id/transfer/accept { token: string }
```

### Product Module DML migration

> [!WARNING]  
Breaking changes (avoidable)

The Product module now uses our DML for data model definitions instead of MikroORM. This migration introduces improvements and fixes but results in breaking changes to some relationship APIs. These can be avoided through explicit configurations.

**Required actions**

- Relation ownership on `manyToMany` relation

Previously, the `manyToMany` API inferred the owning side of relations based on the order of loading models. If the first-loaded model used `mappedBy`, it became the owner. Now, ownership is determined by examining both sides of the relation, before defaulting to the old behavior. This change might lead to unexpected behavior, and we therefore recommend explicitly defining the owner. 

Explicitly define the owner using `joinColumn`, `inverseJoinColumn`, or `pivotTable`:
```ts
const ProductVariant = model
  .define("ProductVariant", {
    id: model.id({ prefix: "variant" }).primaryKey(),
    ...
    options: model.manyToMany(() => ProductOptionValue, {
      pivotTable: "product_variant_option",
      mappedBy: "variants",
      joinColumn: "variant_id",
      inverseJoinColumn: "option_value_id",
    }),
  })
```

- Pivot table naming

Aside from the relation ownership, we have also updated how pivot table names are generated. 

**Before**

We used the model names in alphabetical order and pluralized the last one of them.

**Now**

We use the model's table names in alphabetical order and pluralize the last one of them.

To avoid issues with your project, explicitly set `pivotTable` in `manyToMany` relations to match your existing table names:

For example:
```ts
const user = model.define('User', () => {
  addresses: model.manyToMany(() => Address, { pivotTable: 'address_users' })
})
```

### New languages

Our admin dashboard has been translated into Brazilian Portuguese, French, Thai, and Spanish.

## Features
* feat(dashboard): Allow setting a tooltip for disabled action items by @kasperkristensen in https://github.com/medusajs/medusa/pull/10234
* feat(dashboard, js-sdk): customer page transfer order + cancel request in timeline by @fPolic in https://github.com/medusajs/medusa/pull/10250
* feat: convert MikroORM entities to DML entities by @thetutlage in https://github.com/medusajs/medusa/pull/10043
* feat: add ptBR (Brazilian Portuguese) in translations by @DanSilva41 in https://github.com/medusajs/medusa/pull/10188
* feat: add Thai language support by @oDestroyeRo in https://github.com/medusajs/medusa/pull/10249
* feat: French translation V2 by @triplecasquette in #10301

## Bugs
* fix: Fix product module creation example by @sradevski in https://github.com/medusajs/medusa/pull/10228
* fix: Inventory module schema by @olivermrbl in https://github.com/medusajs/medusa/pull/10262
* fix(dashboard): Add Metadata form to variant page by @kasperkristensen in https://github.com/medusajs/medusa/pull/10285
* fix(dashboard): Truncate long product organization tags by @kasperkristensen in https://github.com/medusajs/medusa/pull/10261
* fix(core-flows): aggregate payment status by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/10278
* fix(dashboard): Align casing of fields in reset password event by @kasperkristensen in https://github.com/medusajs/medusa/pull/10313
* fix(dashboard): adjust transfer SVG for theme by @fPolic in https://github.com/medusajs/medusa/pull/10307
* fix(dashboard): Prevent product metadata form from throwing error by @kasperkristensen in #10312
* fix(utils): read dir recursive by @carlos-r-l-rodrigues in #10318
* fix(dashboard): Correct Spain provinces in country-states.ts by @anthid in #10264

## Documentation
* docs: update injection zones for v2.0.5 by @shahednasser in https://github.com/medusajs/medusa/pull/10225
* docs: add details on updating a cart's customer by @shahednasser in https://github.com/medusajs/medusa/pull/10226
* docs: added section on medusa cloud by @shahednasser in https://github.com/medusajs/medusa/pull/10265
* docs-util: fix references generator by @shahednasser in https://github.com/medusajs/medusa/pull/10271
* docs-util: fix build errors by @shahednasser in https://github.com/medusajs/medusa/pull/10275
* docs: fixes to Medusa Cloud sections by @shahednasser in https://github.com/medusajs/medusa/pull/10270
* docs: changes for CLI tools by @shahednasser in https://github.com/medusajs/medusa/pull/10284
* docs: fix link to payment session by @shahednasser in https://github.com/medusajs/medusa/pull/10286
* docs: fix links in API reference workflows section by @shahednasser in https://github.com/medusajs/medusa/pull/10269
* docs: revise scheduled jobs by @shahednasser in https://github.com/medusajs/medusa/pull/10291
* docs: fix links in examples guide by @shahednasser in https://github.com/medusajs/medusa/pull/10296
* docs: revise workflows docs by @shahednasser in https://github.com/medusajs/medusa/pull/10294
* docs: fix link to medusa container by @shahednasser in https://github.com/medusajs/medusa/pull/10298
* docs: revise admin customization pages by @shahednasser in https://github.com/medusajs/medusa/pull/10297
* docs: clarify medusa_url in Stripe docs by @shahednasser in https://github.com/medusajs/medusa/pull/10305
* docs: update list of events by @shahednasser in https://github.com/medusajs/medusa/pull/10308
* docs: add resend integration guide by @shahednasser in https://github.com/medusajs/medusa/pull/10268
* docs: fix database URL in railway guide by @shahednasser in https://github.com/medusajs/medusa/pull/10311
* docs: fix updateProvider edit user's password example by @xqSimone in https://github.com/medusajs/medusa/pull/10253
* docs: Update Redis connection string instructions for Railway by @qbitdoge in https://github.com/medusajs/medusa/pull/10246

## Chores
* chore: fix CI branch in test by @shahednasser in https://github.com/medusajs/medusa/pull/10274
* chore(dashboard): Add missing keys to i18n translation files by @kasperkristensen #10260

## New Contributors
* @DanSilva41 made their first contribution in https://github.com/medusajs/medusa/pull/10188
* @xqSimone made their first contribution in https://github.com/medusajs/medusa/pull/10253
* @qbitdoge made their first contribution in https://github.com/medusajs/medusa/pull/10246
* @anthid made their first contribution in https://github.com/medusajs/medusa/pull/10301

**Full Changelog**: https://github.com/medusajs/medusa/compare/v2.0.6...v2.0.7