v2.0.2-preview

medusajs/medusav2.0.2-previewJul 25, 2024by olivermrbl

AI Summary

Preview release introducing new CLI commands for Migrations and Linking, a new Middlewares API, and tax-inclusive pricing support.

Key Highlights

  • New CLI commands: `medusa migrations generate` and `medusa links sync`.
  • New Middlewares API using `defineMiddlewares` utility function.
  • Re-introduction of tax-inclusive pricing for products and shipping.
  • Admin Returns API and improved order preview features.

Breaking Changes

  • Middleware configuration changed from exporting `MiddlewareConfig` to using `defineMiddlewares`.
  • The `medusa migrations revert` command now requires specific module names.

New Features

  • Workflow to request item return
  • Allocate items in dashboard
  • CLI generate command for migrations
  • Request return on order exchanges and claims
  • Add return shipping
  • Add tax inclusivity management to currencies
  • Admin Returns API
  • Exchange return shipping
  • Returns order previews
  • Ensure async workflow executions have access to shared container
  • Add support for private files to file module
  • Product export endpoint
  • Notification endpoints for admin
  • Update app layout and add user SDK methods
  • Allow filtering returns by `order_id`
  • Link between fulfillment provider and stock location
  • Remove loading middlewares file in favor of routes-config files
  • Implement notifications feed
  • Basic support for importing products

Full Release Notes

<!-- 
![image](https://github.com/user-attachments/assets/76904202-ab28-4051-9598-82ec0ba4cb96)

# Medusa Preview Release update #2

CMS_BREAK -->

## Get started with a new project

To get started using the preview release, run the following command:

```bash
npx create-medusa-app@preview
```

This command will create a new Medusa project with our redesigned admin and a 2.0-compatible Next.js storefront. The Medusa application and the Next.js storefront are separate projects in separate folders.

## Update existing project
Ensure your **Medusa** dependencies in `package.json` are using the `preview` tag:

```json
{
  "dependencies": {
    "@medusajs/medusa": "preview",
    "@medusajs/pricing": "preview",
    "@medusajs/product": "preview",
    ...
  }
}
```

To ensure an upgrade to a new version is completed correctly, run the following sequence of commands:

```tsx
rm -rf node_modules
rm yarn.lock // or package-lock.json

yarn // If you are using yarn berry, you need to create the lock-file first
```

## Highlights

### Migrations and Linking CLI
We have introduced new CLI commands for generating migrations and managing links between modules. The latter is used to ensure links are in sync.

To generate migrations in your module, you can run the following command:
```
npx medusa migrations generate <name of module>
```

To sync the links between modules, you can run the following command:
```
npx medusa links sync
```
In case your links are out of sync, you'll be guided through possible actions to take.

Explore our [full CLI reference in our documentation](https://docs.medusajs.com/v2/resources/medusa-cli).

### New Middlewares API
> 🚧 Breaking change

We have introduced a new way of defining middlewares for API Routes. This is a breaking change.

Instead of exporting a config from `middlewares.ts`, you will now need to use a new utility function `defineMiddlewares`. 

To upgrade your project, you should apply the following changes:

```diff
- import { MiddlewareConfig } from '@medusajs/medusa'
+ import { defineMiddlewares } from '@medusajs/medusa'

- export const config: MiddlewareConfig = {
-   routes: []
- }
+ export default defineMiddlewares({
+  routes: []
+ })
```

Read more about the new [Middlewares API in our documentation](https://docs.medusajs.com/v2/advanced-development/api-routes/middlewares).

### Tax-inclusive Pricing
We have re-introduced tax-inclusive pricing. Tax-Inclusive pricing allows you to set the final prices for products and shipping options regardless of the customer's applicable tax rates. When tax-inclusive prices are used, Medusa automatically calculates the tax amount for a given price.

Read more about [tax-inclusive pricing in our documentation](https://docs.medusajs.com/v2/resources/commerce-modules/pricing/tax-inclusive-pricing).

### Coming soon
The following are work-in-progress and will be released soon:
- Returns, Exchanges, and Claims of Orders
- Export and Import of Products
- Bulk Editor improvements
- Digital Products and Subscription Recipes

## Features
* feat(core-flows,types): adds workflow to request item return by @riqwan in https://github.com/medusajs/medusa/pull/8098
* feat(dashboard): allocate items by @fPolic in https://github.com/medusajs/medusa/pull/8021
* feat(migrations): CLI generate command by @adrien2p in https://github.com/medusajs/medusa/pull/8103
* feat(core-flows): request return on order exchanges and claims by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8107
* feat: Add return shipping by @olivermrbl in https://github.com/medusajs/medusa/pull/8106
* feat: Add tax inclusivity management to currenices by @sradevski in https://github.com/medusajs/medusa/pull/8112
* feat: Admin Returns API by @olivermrbl in https://github.com/medusajs/medusa/pull/8117
* feat: Add exchange return shipping by @olivermrbl in https://github.com/medusajs/medusa/pull/8108
* feat: Returns order previews by @olivermrbl in https://github.com/medusajs/medusa/pull/8135
* feat(core-flows,medusa,order): remove return shipping by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8137
* feat(medusa): Order preview endpoint by @olivermrbl in https://github.com/medusajs/medusa/pull/8144
* feat: Ensure async workflow executions have access to shared container by @sradevski in https://github.com/medusajs/medusa/pull/8157
* feat: Add support for private files to file module by @sradevski in https://github.com/medusajs/medusa/pull/8169
* feat(core-flows, medusa): remove request item return by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8146
* feat(pricing): big number support by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8113
* feat(core-flows,order): exchange/claim add item by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8126
* feat: rework how links database migrations are managed by @adrien2p in https://github.com/medusajs/medusa/pull/8162
* feat: Add product export endpoint and a dummy workflow by @sradevski in https://github.com/medusajs/medusa/pull/8178
* feat: Add notification endpoints for admin by @sradevski in https://github.com/medusajs/medusa/pull/8196
* feat(dashboard,js-sdk,types): Update app layout, and add user sdk methods by @kasperkristensen in https://github.com/medusajs/medusa/pull/8182
* feat: Add support for exporting products in backend by @sradevski in https://github.com/medusajs/medusa/pull/8214
* feat(medusa): allow filtering returns by `order_id` by @fPolic in https://github.com/medusajs/medusa/pull/8225
* feat: Add skeleton for supporting product imports in BE by @sradevski in https://github.com/medusajs/medusa/pull/8232
* feat: Extending API routes validators by @thetutlage in https://github.com/medusajs/medusa/pull/8254
* feat: add extend router helper by @thetutlage in https://github.com/medusajs/medusa/pull/8263
* feat(dashboard, order, medusa, types, js-sdk): Request return e2e flow by @fPolic in https://github.com/medusajs/medusa/pull/7848
* feat(utils,link-modules): link between fulfillment provider and stock location by @riqwan in https://github.com/medusajs/medusa/pull/8275
* feat: remove loading middlewares file in favor of routes-config files by @thetutlage in https://github.com/medusajs/medusa/pull/8274
* feat: Implement notifications feed by @sradevski in https://github.com/medusajs/medusa/pull/8224
* feat: Add basic support for importing products by @sradevski in https://github.com/medusajs/medusa/pull/8266

## Bugs
* fix: Migration generator and generated migrations by @adrien2p in https://github.com/medusajs/medusa/pull/8090
* fix: Handle multiple id prop generation by @adrien2p in https://github.com/medusajs/medusa/pull/8097
* fix: product module joiner config by @adrien2p in https://github.com/medusajs/medusa/pull/8170
* fix(dashboard): product create input focus by @fPolic in https://github.com/medusajs/medusa/pull/8095
* fix(utils): error message when isQueryable is possibly not enabled. by @shahednasser in https://github.com/medusajs/medusa/pull/8096
* fix(dashboard): promotions disable conditions by @fPolic in https://github.com/medusajs/medusa/pull/8104
* fix(payment, stripe) stripe payment cannot be captured by @silenaker in https://github.com/medusajs/medusa/pull/8075
* fix(dashboard): reservation and price list fixes by @fPolic in https://github.com/medusajs/medusa/pull/8110
* fix: defineMikroOrmCliConfig helper to provide default db credentials by @thetutlage in https://github.com/medusajs/medusa/pull/8131
* fix: workflow return type inf missing type by @adrien2p in https://github.com/medusajs/medusa/pull/8133
* fix(dashboard): create variant remove inventory quantity by @fPolic in https://github.com/medusajs/medusa/pull/8129
* fix: install modules-sdk for test-utils to work by @adrien2p in https://github.com/medusajs/medusa/pull/8142
* fix(core-flow): request item return reason by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8152
* fix: Log error if a scheduled job handler throws by @sradevski in https://github.com/medusajs/medusa/pull/8164
* fix(medusa): normalize build path by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8166
* fix(dashboard): create SO modal by @fPolic in https://github.com/medusajs/medusa/pull/8167
* fix: Remove the option to pass a container to workflow engine API by @sradevski in https://github.com/medusajs/medusa/pull/8165
* fix: normalize path before consuming it while loading models by @adrien2p in https://github.com/medusajs/medusa/pull/8194
* fix(medusa): rm default created at field by @adrien2p in https://github.com/medusajs/medusa/pull/8213
* fix(utils): Fix inferrence of public method name and service registration name based on configuration by @adrien2p in https://github.com/medusajs/medusa/pull/8237
* fix: Dont restart server if static file is added to the private folder by @sradevski in https://github.com/medusajs/medusa/pull/8181
* fix: workflow 'when' should return T or undefined instead of Partial<T> by @adrien2p in https://github.com/medusajs/medusa/pull/8195
* fix(utils): totals calculation by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8190
* fix(dashboard): fix header in create tax region form by @shahednasser in https://github.com/medusajs/medusa/pull/8197
* fix(create-medusa-app): run links sync during setup by @shahednasser in https://github.com/medusajs/medusa/pull/8215
* fix(admin-shared): Fix autocomplete for InjectionZones by @kasperkristensen in https://github.com/medusajs/medusa/pull/8219
* fix(medusa): GET return/:id by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8226
* fix(core-flows): create return items by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8227
* fix: Event emitter not cleared in export tests by @sradevski in https://github.com/medusajs/medusa/pull/8228
* fix(core-flows): confirm return request by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8242
* fix(order): remove nested entities by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8250
* fix(types,order): fixes to order module's service and data models by @shahednasser in https://github.com/medusajs/medusa/pull/8247
* fix: `isList` on field alias in link configuration by @adrien2p in https://github.com/medusajs/medusa/pull/8244
* fix: Product options were not preserved over updates by @sradevski in https://github.com/medusajs/medusa/pull/8267

## Documentation
* docs: updated marketplace recipe + added example by @shahednasser in https://github.com/medusajs/medusa/pull/8061
* docs: highlight fixes by @shahednasser in https://github.com/medusajs/medusa/pull/8094
* docs: add documentation for migration generate cli tool by @shahednasser in https://github.com/medusajs/medusa/pull/8128
* docs: remove imports from src in medusa-config.js by @shahednasser in https://github.com/medusajs/medusa/pull/8132
* docs-util: add support for RequestWithContext in route-handler detection by @shahednasser in https://github.com/medusajs/medusa/pull/8141
* docs: rename data to event in subscribers across docs by @shahednasser in https://github.com/medusajs/medusa/pull/8149
* docs: remove type arguments passed to createWorkflow by @shahednasser in https://github.com/medusajs/medusa/pull/8161
* docs: fix cross-project links to use base path in production by @shahednasser in https://github.com/medusajs/medusa/pull/8160
* docs: add update dependencies + release note details by @shahednasser in https://github.com/medusajs/medusa/pull/8159
* docs: fix installation version of packages by @shahednasser in https://github.com/medusajs/medusa/pull/8177
* docs: fix module provider definition export by @shahednasser in https://github.com/medusajs/medusa/pull/8180
* docs: fix auth routes in api reference by @shahednasser in https://github.com/medusajs/medusa/pull/8187
* docs: added tax-inclusive conceptual guide and updates to storefront guide by @shahednasser in https://github.com/medusajs/medusa/pull/8186
* Update page.mdx by @akmaksumov in https://github.com/medusajs/medusa/pull/8189
* docs: add chapter on executing a workflow in another / in a step by @shahednasser in https://github.com/medusajs/medusa/pull/8163
* docs: remove the requirement on is queryable by @shahednasser in https://github.com/medusajs/medusa/pull/8199
* docs: add section on delete cascades by @shahednasser in https://github.com/medusajs/medusa/pull/8198
* docs: fix fulfillment provider option name by @shahednasser in https://github.com/medusajs/medusa/pull/8211
* docs: document links sync command by @shahednasser in https://github.com/medusajs/medusa/pull/8212
* docs: updates and fixes to marketplace recipe example by @shahednasser in https://github.com/medusajs/medusa/pull/8150
* docs: fix note about how method names are generated by @shahednasser in https://github.com/medusajs/medusa/pull/8240
* docs: fix information related to link directions by @shahednasser in https://github.com/medusajs/medusa/pull/8236
* docs: fix rewrites in sub-projects to prevent loop on 404 page by @shahednasser in https://github.com/medusajs/medusa/pull/8255
* docs: add 404 page by @shahednasser in https://github.com/medusajs/medusa/pull/8260
* docs: fix package names of event bus modules by @shahednasser in https://github.com/medusajs/medusa/pull/8262
* docs: added a section to introduction on using docs by @shahednasser in https://github.com/medusajs/medusa/pull/8257
* docs: updates to Medusa server deployment guides by @shahednasser in https://github.com/medusajs/medusa/pull/8268


## Chores
* chore: add generated OAS and Typedoc output to automated PRs by @shahednasser in https://github.com/medusajs/medusa/pull/8054
* chore: temporarely disabling link revert by @adrien2p in https://github.com/medusajs/medusa/pull/8105
* chore: fix docs issue template by @shahednasser in https://github.com/medusajs/medusa/pull/8068
* chore: Allow to fetch remote link using the service name or the alias from the use remote link step by @adrien2p in https://github.com/medusajs/medusa/pull/8140
* chore: restructure events payload by @thetutlage in https://github.com/medusajs/medusa/pull/8143
* chore(medusa,core-flows): update request return items and shipping by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8151
* chore(core-flows, medusa): cancel request return by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8153
* chore(ui-preset,icons,toolbox): Update dark mode theme by @kasperkristensen in https://github.com/medusajs/medusa/pull/8168
* chore: default isQueryable module by @adrien2p in https://github.com/medusajs/medusa/pull/8192
* chore(framework): Initial commit by @adrien2p in https://github.com/medusajs/medusa/pull/8221
* chore(framework): update deps by @adrien2p in https://github.com/medusajs/medusa/pull/8261
* chore(medusa,core-flows): begin and cancel receive return by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8171
* chore(medusa, core-flows): receive item return request by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8172
* chore(order): simplify order engine by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8188
* chore(inventory, core-flows): big number support by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8204
* chore: Fix flaky test for scheduled workflows by @sradevski in https://github.com/medusajs/medusa/pull/8216
* chore: Make scheduled job tests reliable by @sradevski in https://github.com/medusajs/medusa/pull/8241
* chore(core-flows): adjust inventory when return is received by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8222
* chore: rm testing path by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8249
* chore: Add `@medusajs/framework` to changeset by @olivermrbl in https://github.com/medusajs/medusa/pull/8256
* chore(types): update workerMode tsdocs by @shahednasser in https://github.com/medusajs/medusa/pull/8269
* chore(core-flows,medusa): order claims by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/8271

## New Contributors
* @silenaker made their first contribution in https://github.com/medusajs/medusa/pull/8075
* @silenaker made their first contribution in https://github.com/medusajs/medusa/pull/8075
* @akmaksumov made their first contribution in https://github.com/medusajs/medusa/pull/8189

**Full Changelog**: https://github.com/medusajs/medusa/compare/v2.0.1-preview...v2.0.2-preview