v1.20.0

medusajs/medusav1.20.0Jan 9, 2024by olivermrbl

AI Summary

Introduces major architectural changes to the Stripe plugin and cart completion logic, alongside database schema updates and new admin translations.

Key Highlights

  • Improved Stripe plugin architecture + webhook (migrated to API Routes/Event Bus)
  • Changed service checks from an `instance of` to a static property check
  • More robust and reliable cart completion
  • Database schema changes for `publishable_api_key_sales_channel` table
  • `order by` queries on deeply nested relations fixed

Breaking Changes

  • Stripe plugin endpoints and subscribers migrated to API Routes and Event Bus
  • Service type checks changed from `instance of` to static property check
  • Database schema change requires running migrations

New Features

  • Currency to region responses
  • Sales channel links (Product, PubKey, Order, Cart)
  • Soft delete pricing entities
  • Promotions with rules
  • Cart module package
  • Authentication module skeleton
  • Libya admin region

Full Release Notes

<!-- 
![1-20-0](https://github.com/medusajs/medusa/assets/59018053/d797ba05-959b-4bc6-a968-20ddc28971ab)

# Version 1.20.0

This version increases the robustness and reliability of our checkout APIs and squashes numerous bugs across all packages.

CMS_BREAK -->

## Highlights

### Improved Stripe plugin architecture + webhook
> 🚧 **Breaking change in `medusa-plugin-stripe`**

Two important changes have been introduced to the Stripe plugin, one of which is breaking.

The endpoints and subscribers in the plugin have been migrated to use our new API Routes and Subscribers. This significantly lowers the code footprint of the package and makes it easier to maintain.

The webhook event management has changed significantly from in-band processing of the event to now using our Event Bus to process it as a background job. There were several motivations for this change: 1) it is deemed best practice to respond with a 200 immediately upon receiving a webhook request, 2) it allows for our retry mechanism to kick in in case the processing fails, and 3) it gives us more control of how the event is processed. 

One example of the latter, effective from this release, is that we've added a 5s delay on processing events to avoid conflicts stemming from race conditions between the webhook and client requests.

### Changed service checks from an `instance of` to a static property check
> 🚧 **Breaking change**

Several issues have been filed related to failing registrations of different types of services, such as payment providers, fulfillment providers, and similar. The culprit to these issues was found in how we check the type of the service class.

Until now, we've relied on `instance of` to perform the check:
```ts
export function isPaymentProcessor(obj: unknown): boolean {
  return obj instanceof AbstractPaymentProcessor
}
```

However, if you have a version mismatch in your packages, the `instance of` check will fail even though the services are seemingly the expected type. 

With this release, the service class type checks are now performed with static properties to eliminate this issue:
```ts
static isPaymentProcessor(object): boolean {
    return object?.constructor?._isPaymentProcessor
}
```

### More robust and reliable cart completion
> 🚧 **Important change**

Our cart completion API has been updated to increase robustness and reliability - especially under high load. The update includes removing serializable transactions from the API and generally refactoring our transaction management. 

As a positive side effect, the changes have also made for a more performant API.

### Database schema changes

Minor changes to the schema of table `publishable_api_key_sales_channel` have been introduced.

Please, apply the new migration by running the following command in your Medusa project after having updated:
```bash
npx @medusajs/medusa-cli migrations run
```

### `order by` queries on deeply nested relations
An issue with duplicated rows in the result set in `order by` queries on deeply nested relations has been resolved.

Read more about the change in the [PR description](https://github.com/medusajs/medusa/pull/5990).

### API reference for `medusa-react`
An API reference and examples for our `medusa-react` library have been introduced to our documentation.

### Admin translations
With this release, the following languages are supported in Medusa Admin: Simplified Chinese, Bulgarian, Slovenian, Czech, and Japanese.

## Features

* feat(medusa): add currency to region responses by @riqwan in https://github.com/medusajs/medusa/pull/5857
* feat(medusa): Update shipping option price type by @pKorsholm in https://github.com/medusajs/medusa/pull/5895
* feat(medusa, link-modules): sales channel <> product module link by @fPolic in https://github.com/medusajs/medusa/pull/5450
* feat(admin): Added Simplified Chinese support by @chrislaai in https://github.com/medusajs/medusa/pull/5798
* feat(admin): Bulgarian language support by @edisaso in https://github.com/medusajs/medusa/pull/5786
* feat(medusa): Slovenian(sl) translation by @glomon in https://github.com/medusajs/medusa/pull/5828
* feat(workflows-sdk): Configurable retries upon step creation by @adrien2p in https://github.com/medusajs/medusa/pull/5728
* feat(medusa): Prevent cart completion conflict by @adrien2p in https://github.com/medusajs/medusa/pull/5814
* feat(admin): Add Czech language support by @hexrw in https://github.com/medusajs/medusa/pull/5822
* feat(admin): Add Japanese language support by @hmmhmmhm in https://github.com/medusajs/medusa/pull/5795
* feat(medusa-payment-stripe): Add delay to Stripe webhook by @olivermrbl in https://github.com/medusajs/medusa/pull/5838
* feat(orchestration, workflows-sdk): Add events management and implementation to manage async workflows by @adrien2p in https://github.com/medusajs/medusa/pull/5951
* feat(medusa, link-modules): sales channel <> pubkey link by @fPolic in https://github.com/medusajs/medusa/pull/5820
* feat(pricing, types, utils): Soft delete pricing entities by @pKorsholm in https://github.com/medusajs/medusa/pull/5858
* feat(medusa, link-modules): sales channel <> order link by @fPolic in https://github.com/medusajs/medusa/pull/5810
* feat(types,utils): added promotion create with rules and application target rules by @riqwan in https://github.com/medusajs/medusa/pull/5957
* feat(cart): Add cart module package by @olivermrbl in https://github.com/medusajs/medusa/pull/5982
* Feat(medusa-test-utils, utils, pricing, product, link-modules): upgrade mikro orm version to latest by @pKorsholm in https://github.com/medusajs/medusa/pull/5985
* feat(medusa, link-modules): sales channel <> cart  link by @fPolic in https://github.com/medusajs/medusa/pull/5459
* feat(workflows-sdk): Allow primitive values to be passed as well as WorkflowDataProperties by @adrien2p in https://github.com/medusajs/medusa/pull/5953
* feat(types,utils): add promotions create with application method by @riqwan in https://github.com/medusajs/medusa/pull/5945
* feat(workflows-sdk): Allow a step to not define an expected input by @adrien2p in https://github.com/medusajs/medusa/pull/5775
* feat(types,modules-sdk): basic module setup for promotions by @riqwan in https://github.com/medusajs/medusa/pull/5920
* feat(types,module-sdk): setup authentication module skeleton by @pKorsholm in https://github.com/medusajs/medusa/pull/5943
* feat(types): promotion delete / update / retrieve / add/remove-rules by @riqwan in https://github.com/medusajs/medusa/pull/5988
* feat(cart): Data models by @olivermrbl in https://github.com/medusajs/medusa/pull/5986
* feat(admin): Add Libya admin region and set Libya to formal name by @abusaidm in https://github.com/medusajs/medusa/pull/6001
* feat(authentication): Load auth providers by @pKorsholm in #6023

## Bugs
* fix: redis_options for job scheduler by @kstoklosa in https://github.com/medusajs/medusa/pull/5894
* fix(medusa): Passport loader resolving to early by @adrien2p in https://github.com/medusajs/medusa/pull/5901
* fix: Typo in documentation by @aldo-roman in https://github.com/medusajs/medusa/pull/5933
* fix(medusa, medusa-js): publishable api key bugs by @olivermrbl in https://github.com/medusajs/medusa/pull/5926
* fix(medusa, pricing, types): pass dates as Date-objects rather than strings to the pricing module by @pKorsholm in https://github.com/medusajs/medusa/pull/5768
* fix(utils): More resilient object from string path by @adrien2p in https://github.com/medusajs/medusa/pull/5929
* fix(medusa-js): remove unnecessary `query` field in `AdminInventoryItemsResource.deleteLocationLevel` method by @shahednasser in https://github.com/medusajs/medusa/pull/5941
* fix(medusa): add payments default relation to getTotalsRelations by @cyf0e in https://github.com/medusajs/medusa/pull/5875
* fix(medusa): Resolve babel executable with `npx` by @olivermrbl in https://github.com/medusajs/medusa/pull/5952
* fix(medusa): Update cart sales channel should not remove all line items by @adrien2p in https://github.com/medusajs/medusa/pull/5980
* fix(medusa-payment-stripe): fix error handling by @adrien2p in https://github.com/medusajs/medusa/pull/5991
* fix(medusa): cart completion payment sessions by @adrien2p in https://github.com/medusajs/medusa/pull/5995
* fix(medusa): Ordering management using joins and pagination by @adrien2p in https://github.com/medusajs/medusa/pull/5990
* fix(medusa): Fix typo in discounts error message by @Sajarin-M in https://github.com/medusajs/medusa/pull/5853
* fix(medusa-payment-stripe): change webhook environment variables to plugin options by@shahednasser in #6034

## Chores
* chore(medusa, interfaces): Uniformise class checks by @adrien2p in https://github.com/medusajs/medusa/pull/5869
* chore: refactored docs-util by @shahednasser in https://github.com/medusajs/medusa/pull/5876
* chore(workflows): Use Node 16.14 in CLI workflow by @olivermrbl in https://github.com/medusajs/medusa/pull/5993
* chore: move next admin packages to core repo by @kasperkristensen in #5983
* chore: add vercel config by @kasperkristensen in #6018
* chore(medusa, orchestration, utils, workflows-sdk): add transaction options support and cleanup by @adrien2p in #6020
* chore(docs-util): update typedoc to v0.25.7 by @shahednasser in #6032

## Documentation
* docs: updates for v1.19 by @shahednasser in https://github.com/medusajs/medusa/pull/5868
* docs: update docs changes for rules_count from number_rules by @riqwan in https://github.com/medusajs/medusa/pull/5855
* docs: Add discount created event by @Arsenalist in https://github.com/medusajs/medusa/pull/5850
* docs: fix upgrade guide release notes link by @shahednasser in https://github.com/medusajs/medusa/pull/5879
* docs: update documentation websites by @shahednasser in https://github.com/medusajs/medusa/pull/5882 
* docs: added missing service method in digital products recipe by @shahednasser in https://github.com/medusajs/medusa/pull/5899
* docs: updated digital ocean spaces guide by @shahednasser in https://github.com/medusajs/medusa/pull/5900
* docs: update Railway pricing info in deploy guide by @dinesh-58 in https://github.com/medusajs/medusa/pull/5908
* docs: fix wishlist route by @shahednasser in https://github.com/medusajs/medusa/pull/5914
* docs: add TSDoc for payment processor + generate docs by @shahednasser in https://github.com/medusajs/medusa/pull/5917
* docs: set rejectUnauthorized based on condition by @dinesh-58 in https://github.com/medusajs/medusa/pull/5907
* docs: fix medusa-react guide + specify react-query version by @shahednasser in https://github.com/medusajs/medusa/pull/5918
* docs: Update minimum node version requirement by @olivermrbl in https://github.com/medusajs/medusa/pull/5994
* docs: generate medusa-react reference by @shahednasser in https://github.com/medusajs/medusa/pull/6004
* docs: rename `EVENT_REDIS_URL` by @dinesh-58 in https://github.com/medusajs/medusa/pull/5948
* docs: fix file name for scheduled jobs by @shahednasser in https://github.com/medusajs/medusa/pull/5972
* docs: Update create.md by @minhtungo in https://github.com/medusajs/medusa/pull/5978
* docs: fixes to digital products recipe by @shahednasser in https://github.com/medusajs/medusa/pull/5897
* docs; Update meilisearch.md by @pepiyu in #6026

## New Contributors
* @dinesh-58 made their first contribution in https://github.com/medusajs/medusa/pull/5908
* @IdekDude made their first contribution in https://github.com/medusajs/medusa/pull/5823
* @edisaso made their first contribution in https://github.com/medusajs/medusa/pull/5786
* @glomon made their first contribution in https://github.com/medusajs/medusa/pull/5828
* @kstoklosa made their first contribution in https://github.com/medusajs/medusa/pull/5894
* @hexrw made their first contribution in https://github.com/medusajs/medusa/pull/5822
* @hmmhmmhm made their first contribution in https://github.com/medusajs/medusa/pull/5795
* @aldo-roman made their first contribution in https://github.com/medusajs/medusa/pull/5933
* @cyf0e made their first contribution in https://github.com/medusajs/medusa/pull/5875
* @abusaidm made their first contribution in https://github.com/medusajs/medusa/pull/6001

**Full Changelog**: https://github.com/medusajs/medusa/compare/v1.19.0...v1.20.0