v1.20.4

medusajs/medusav1.20.4Mar 26, 2024by olivermrbl

AI Summary

Introduces Worker Mode, allowing Medusa instances to run background jobs in a separate process from the main application.

Key Highlights

  • Introduces Worker Mode with three runtime options: `server`, `worker`, and `shared`.
  • Separates background job processing from the main application using the Redis Event Bus.

New Features

  • Update variant and options signatures
  • Fulfillment Events management
  • Init v2 implementation in admin
  • Add Update inventory item endpoint in api-v2
  • Autogenerate create and update methods when dto is provided
  • Align product module HTTP API
  • Pricing models are made soft deletable
  • Additional properties to workflow context
  • Shard modules and API integration tests
  • v2 worker mode
  • Invite expiration fix
  • List products middleware
  • Dismiss inventory links
  • Workflow cancel
  • Admin 3.0 return creation
  • Add Update location level endpoint for api-v2
  • Add `successRedirectUrl` to auth options
  • Price List configurations section
  • Product image modals
  • Create stock location endpoint for api-v2
  • Added --v2 option
  • Rename psma to prices
  • Draft orders create
  • Migrate medusa unit tests to swc jest
  • Create user account

Full Release Notes

<!-- 
![image](https://github.com/medusajs/medusa/assets/59018053/dfc0eefb-87ab-4fbc-904a-aa4e635c7690)

# Version 1.20.4

This version introduces Worker Mode to start Medusa instances for background job execution separate from the main application process.

CMS_BREAK -->

## Highlights

### Introducing Worker Mode

This release ships Worker Mode, a new runtime mode for Medusa instances.

Worker Mode allows you to start a Medusa instance in a process separate from the main application process. An instance running in Worker Mode is useful for executing long-running or resource-heavy tasks in the background. Those tasks are offloaded to a separate process and will not affect the performance of the main application. Examples of tasks are importing data or updating a search index. While Worker Mode is especially good for resource-intensive tasks, we recommend always starting an instance in this mode if possible. 

Worker Mode introduces three new runtime modes for your Medusa instance:
- `server`: API Routes are registered, and no workers are started.
- `worker`: API Routes are not registered, and workers are started.
- `shared`: API routes are registered, and workers are started (the regular runtime mode + default).

The worker mode is configured in `medusa-config.js`:
```ts
// medusa-config.js
const projectConfig = {
  ...,
  database_url: "...",
  worker_mode: "worker",
};
```

In this release, the Redis Event Bus has been updated to leverage the worker architecture. Instantiating a Medusa instance with `worker_mode: "server"` and a different one with `worker_mode: "worker"` will separate background job processing from the public-facing main application, given that the Redis Event Bus module is installed.

## Features
* feat: Update the signatures for variants and options to follow convention by @sradevski in https://github.com/medusajs/medusa/pull/6748
* feat(fulfillment): Events management by @adrien2p in https://github.com/medusajs/medusa/pull/6730
* feat: Init. v2 implementation in admin by @olivermrbl in https://github.com/medusajs/medusa/pull/6715
* feat(medusa, core-flows): add Update inventory item endpoint in api-v2 by @pKorsholm in https://github.com/medusajs/medusa/pull/6735
* feat(utils): autogenerates create and update methods when dto is provided by @riqwan in https://github.com/medusajs/medusa/pull/6751
* feat: Align the product module HTTP API to follow our conventions by @sradevski in https://github.com/medusajs/medusa/pull/6759
* feat(pricing): pricing models are made soft deletable by @riqwan in https://github.com/medusajs/medusa/pull/6732
* Feat(workflows-sdk): additional properties to context by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/6760
* feat: shard modules and API integration tests by @riqwan in https://github.com/medusajs/medusa/pull/6775
* feat: v2 - add worker mode by @srindom in https://github.com/medusajs/medusa/pull/6739
* Feat(user): Invite expiration fix by @pKorsholm in https://github.com/medusajs/medusa/pull/6758
* feat: List products middleware by @olivermrbl in https://github.com/medusajs/medusa/pull/6769
* feat(core-flows): Use remote link methods to dismiss all links related to inventory item by @pKorsholm in https://github.com/medusajs/medusa/pull/6737
* Feat(orchestration,workflows-sdk,core-flows): workflow cancel by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/6778
* feat(dashboard) admin 3.0 return creation by @fPolic in https://github.com/medusajs/medusa/pull/6713
* feat(core-flows, types, medusa): Add Update location level endpoint for api-v2 by @pKorsholm in https://github.com/medusajs/medusa/pull/6743
* feat: Add `successRedirectUrl` to auth options by @olivermrbl in https://github.com/medusajs/medusa/pull/6792
* update prefix for inventory-next reservation item by @pKorsholm in https://github.com/medusajs/medusa/pull/6816
* feat(dashboard): Price List configurations section by @kasperkristensen in https://github.com/medusajs/medusa/pull/6663
* feat(dashboard, ui): Product image modals by @kasperkristensen in https://github.com/medusajs/medusa/pull/6779
* feat(core-flows, medusa): add create stock location endpoint for api-v2 by @pKorsholm in https://github.com/medusajs/medusa/pull/6787
* feat(create-medusa-app): Added --v2 option by @shahednasser in https://github.com/medusajs/medusa/pull/6729
* feat(core-flows,medusa,types,utils): rename psma to prices by @riqwan in https://github.com/medusajs/medusa/pull/6796
* feat(medusa-payment-paypal,medusa-payment-stripe): speed up unit tests in CI by @riqwan in https://github.com/medusajs/medusa/pull/6806
* feat(dashboard): Order timeline by @kasperkristensen in https://github.com/medusajs/medusa/pull/6815
* feat(types, medusa, core-flows): add delete-stock-location endpoint to api-v2 by @pKorsholm in https://github.com/medusajs/medusa/pull/6801
* feat(medusa, core-flows): add retrieve stock location endpoint to api-v2 by @pKorsholm in https://github.com/medusajs/medusa/pull/6791
* feat(dashboard): Draft orders create by @kasperkristensen in https://github.com/medusajs/medusa/pull/6680
* feat(medusa): migrate medusa unit tests / plugins integration tests to swc jest by @riqwan in https://github.com/medusajs/medusa/pull/6820
* feat: Create user account by @olivermrbl in https://github.com/medusajs/medusa/pull/6819
* chore(dashboard): render main layout as home page for v2 by @riqwan in https://github.com/medusajs/medusa/pull/6823

## Bugs
* fix(orchestration): Properly handle select all by @adrien2p in https://github.com/medusajs/medusa/pull/6742
* fix(link-modules): recreate dismissed link by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/6764
* fix: revert no server start by @srindom in https://github.com/medusajs/medusa/pull/6790
* fix: make module test runner configurable by @srindom in https://github.com/medusajs/medusa/pull/6803
* fix(medusa-oas-cli): fix tool not working in Medusa backends by @shahednasser in https://github.com/medusajs/medusa/pull/6812
* Fix/pricing create price lists by @adrien2p in https://github.com/medusajs/medusa/pull/6818
* fix(medusa): migrate with feature flag by @srindom in https://github.com/medusajs/medusa/pull/6771

## Chores
* chore: Deprecate extra in favor of driver options by @adrien2p in https://github.com/medusajs/medusa/pull/6772
* chore: merge money amounts and price set money amounts by @riqwan in https://github.com/medusajs/medusa/pull/6768
* chore: pricing models uses standardized relationships attributes by @riqwan in https://github.com/medusajs/medusa/pull/6767
* chore: update naming in abstract service to dto specifics by @riqwan in https://github.com/medusajs/medusa/pull/6763
* chore: add TSDocs to the API Key Module by @shahednasser in https://github.com/medusajs/medusa/pull/6785
* chore(docs): Updated UI Reference by @github-actions in https://github.com/medusajs/medusa/pull/6754

## Documentation
* docs: Update example-logged-in-user.mdx by @Deveosys in https://github.com/medusajs/medusa/pull/6780

## New Contributors
* @Deveosys made their first contribution in https://github.com/medusajs/medusa/pull/6780

**Full Changelog**: https://github.com/medusajs/medusa/compare/v1.20.3...v1.20.4