v2.0.9-preview
medusajs/medusav2.0.9-previewSep 16, 2024by olivermrbl
AI Summary
This update enforces the use of Publishable API keys for the Store API, deprecates `ModuleRegistrationName`, and fixes issues with many-to-many relation definitions.
Key Highlights
- Enforced Publishable API key requirement for Store API endpoints
- Deprecation of `ModuleRegistrationName` in favor of `Modules`
- Disabled automatic MikroORM casing change
- Fixed issue with many-to-many relations requiring `mappedBy`
Breaking Changes
- Enforced Publishable API Key in Store API
- Disabled automatic MikroORM casing change
- Fixed issue with many-to-many relations (breaking change to model definitions)
- Deprecated `ModuleRegistrationName` (will be removed in a later release)
New Features
- Application types generation from project GQL schema
- Reset password functionality
- Support for refreshing JWT tokens
- Telemetry/Tracing introduction (OpenTelemetry wrapper)
Full Release Notes
<!--

# Medusa Preview Release update #9
CMS_BREAK -->
## 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
### Deprecated `ModuleRegistrationName`
> [!WARNING]
Breaking change
We have deprecated `ModuleRegistrationName` in favor of `Modules`. `ModuleRegistrationName` will be removed in a later preview release.
Modules are registered in the dependency container using [these keys](https://github.com/medusajs/medusa/blob/8829f8940220e4448202e0dd2ad228afa9f8af26/packages/core/utils/src/modules-sdk/definition.ts#L27-L52) and are now resolved as follows:
```ts
import { Modules } from "@medusajs/utils"
const productModule = container.resolve(Modules.PRODUCT)
```
This is a breaking change if you have used strings for module resolution instead of `ModuleRegistrationName`.
For example, if you have resolved the product module using its previous string resolution key, you will need to change it as follows:
```diff
-const productModule = container.resolve("productModuleService")
+const productModule = container.resolve(Modules.PRODUCT)
```
### Enforced Publishable API Key in Store API
> [!WARNING]
Breaking change
In the latest preview release, we require a Publishable API key header to access the Store API, i.e., all endpoints under the `/store` resource. This will ensure your requests are scoped to at least one Sales Channel associated with the Publishable API key. Sales Channels are used to retrieve products, retrieve correct inventory quantities, create carts, and place orders.
The requirement has been introduced to ensure you can perform these operations without experiencing issues.
### Disabled automatic MikroORM casing change
> [!WARNING]
> Breaking change
Refer to https://github.com/medusajs/medusa/pull/9058 for a description of the issue, solution, and the minimal breaking change.
### Fixed issue with many-to-many relations
> [!WARNING]
> Breaking change
In #9075, a bug with our many-to-many relation definition was identified. The solution to the problem lead to a minimal breaking change to the way many-to-many relations are defined when using our `model` tool from `@medusajs/framework`.
We now require the many-to-many relation to be defined on both sides and a `mappedBy` definition on at least one side.
## Features
* feat(create-medusa-app): add publishable API key environment variable to Next.js storefront by @shahednasser in https://github.com/medusajs/medusa/pull/9029
* feat: Application types generation from project GQL schema's by @adrien2p in https://github.com/medusajs/medusa/pull/8995
* feat: Reset password by @olivermrbl in https://github.com/medusajs/medusa/pull/8962
* feat: Add support for refreshing JWT tokens by @sradevski in https://github.com/medusajs/medusa/pull/9013
* feature: introduce types for query.graph method by @thetutlage in https://github.com/medusajs/medusa/pull/9031
* feat: Add support for fetch streaming to js SDK by @sradevski in https://github.com/medusajs/medusa/pull/9065
* fix(utils,medusa,order,cart): fix totals when promotions are included by @riqwan in https://github.com/medusajs/medusa/pull/9014
* feat(payment): Payment providers are upserted upon loading by @riqwan in https://github.com/medusajs/medusa/pull/9090
* feat(dashboard) modal search autofocus by @fPolic in https://github.com/medusajs/medusa/pull/9038
* feat(utils,types,framework,medusa): store endpoints should require publishable key by @riqwan in https://github.com/medusajs/medusa/pull/9068
* feat(core-flows): product type, option and tag events by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/9105
* feat(core-flows,dashboard,types,medusa): delete shipping methods when all inbound/outbound items are deleted by @riqwan in https://github.com/medusajs/medusa/pull/9106
* feat(core-flows,types,medusa): validate deleting location level when quantities exist by @riqwan in https://github.com/medusajs/medusa/pull/9086
* feat: introduce a thin wrapper on top of OpenTelemetry by @thetutlage in https://github.com/medusajs/medusa/pull/9109
* feat(api-key,js-sdk,dashboard): allow deleting api keys only once its revoked by @riqwan in https://github.com/medusajs/medusa/pull/9118
* feature: add telemetry to the HTTP layer by @thetutlage in https://github.com/medusajs/medusa/pull/9116
* feature: add tracing to remote query by @thetutlage in https://github.com/medusajs/medusa/pull/9128
* feat(core-flows,medusa,utils,types): adds delivered_quantity to order by @riqwan in https://github.com/medusajs/medusa/pull/9130
## Bugs
* fix(types): add inventory_quantity to http variant type by @shahednasser in https://github.com/medusajs/medusa/pull/9030
* fix: Check for star actor types when allowing unregistered access by @sradevski in https://github.com/medusajs/medusa/pull/9037
* fix(orchestration): filter out undefined items by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/9046
* fix(types, medusa): request / response types clean-up by @shahednasser in https://github.com/medusajs/medusa/pull/9043
* fix: Allow specifying PORT for tests through environment by @sradevski in https://github.com/medusajs/medusa/pull/9055
* breaking: turn off Mikro-ORM casing change with DML properties by @thetutlage in https://github.com/medusajs/medusa/pull/9058
* fix(dashboard): rq cache and pending flag by @fPolic in https://github.com/medusajs/medusa/pull/9063
* fix: JSON stringify DML json property default value by @thetutlage in https://github.com/medusajs/medusa/pull/9074
* fix(dashboard): refresh order list when fulfilment status changes by @fPolic in https://github.com/medusajs/medusa/pull/9076
* fix(medusa-test-utils): Run with modules without models by @adrien2p in https://github.com/medusajs/medusa/pull/9062
* fix(core-flows): fix emitted event for deleting sales channel by @shahednasser in https://github.com/medusajs/medusa/pull/9081
* fix(promotion): handle promotion buy X get X scenario by @riqwan in https://github.com/medusajs/medusa/pull/9002
* fix(dashboard): campaign fixes by @fPolic in https://github.com/medusajs/medusa/pull/9082
* fix: broken order page due to missing inventory by @riqwan in https://github.com/medusajs/medusa/pull/9083
* fix: Update auth `app_metadata` when deleting users + customers by @olivermrbl in https://github.com/medusajs/medusa/pull/9041
* fix: product options event names by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/9108
* fix(dashboard): product create - ignored variants in datagrid by @fPolic in https://github.com/medusajs/medusa/pull/9087
* fix: wrap ModuleImplementations so that all methods are async by @Alexnortung in https://github.com/medusajs/medusa/pull/9012
* fix: `instanceof MedusaError` does not work by @McTom234 in https://github.com/medusajs/medusa/pull/9094
* fix(dml): Throw when many to many are not configured properly by @adrien2p in https://github.com/medusajs/medusa/pull/9085
* fix: Remove test listeners after the event has happened by @sradevski in https://github.com/medusajs/medusa/pull/9115
* fix(types, medusa): fix http type of exchanges and claims by @shahednasser in https://github.com/medusajs/medusa/pull/9123
* fix(): Query Missing bindings by @adrien2p in https://github.com/medusajs/medusa/pull/9131
* fix(core-flows): item id in reservations by @fPolic in https://github.com/medusajs/medusa/pull/9097
* fix(dashboard): max call error onKeyDown handler by @kasperkristensen in https://github.com/medusajs/medusa/pull/9141
* fix: OrderDTO add first class discount_subtotal var by @420coupe in https://github.com/medusajs/medusa/pull/9112
* fix: Fixed misleading LinkDefinition import from the wrong package by @erickirt in https://github.com/medusajs/medusa/pull/9139
## Documentation
* chore: fix incorrect oas property name by @shahednasser in https://github.com/medusajs/medusa/pull/9009
* docs: update auth docs + add new storefront guides by @shahednasser in https://github.com/medusajs/medusa/pull/9020
* docs: fix admin actor type -> user by @shahednasser in https://github.com/medusajs/medusa/pull/9028
* docs: document star actor types by @shahednasser in https://github.com/medusajs/medusa/pull/9044
* oas: [2/2] improve store OAS by @shahednasser in https://github.com/medusajs/medusa/pull/9035
* oas: [1/n] improve oas schemas by @shahednasser in https://github.com/medusajs/medusa/pull/9039
* oas: [2/n] improve schema oas by @shahednasser in https://github.com/medusajs/medusa/pull/9040
* oas: [1/n] improve store oas by @shahednasser in https://github.com/medusajs/medusa/pull/8993
* oas: [3/n] improve oas schemas by @shahednasser in https://github.com/medusajs/medusa/pull/9042
* docs: fix pricing query params in storefront guide + modules restructure by @shahednasser in https://github.com/medusajs/medusa/pull/9021
* docs: added storefront development guide on retrieving variant inventory details by @shahednasser in https://github.com/medusajs/medusa/pull/9032
* chore(utils): update auth provider TSDocs + fix errors stopping references build by @shahednasser in https://github.com/medusajs/medusa/pull/9023
* chore: fix build errors in OAS by @shahednasser in https://github.com/medusajs/medusa/pull/9059
* docs: add prerequisites link for test guides by @shahednasser in https://github.com/medusajs/medusa/pull/9057
* oas: [4/n] improve oas schemas by @shahednasser in https://github.com/medusajs/medusa/pull/9064
* docs-util: fix generated hooks example by @shahednasser in https://github.com/medusajs/medusa/pull/9060
* oas: [5/n] improve oas schemas by @shahednasser in https://github.com/medusajs/medusa/pull/9066
* docs-util: fix after updating node version by @shahednasser in https://github.com/medusajs/medusa/pull/9072
* docs: fix links to inventory model references by @shahednasser in https://github.com/medusajs/medusa/pull/9073
* docs: document events reference by @shahednasser in https://github.com/medusajs/medusa/pull/9080
* docs: add Query documentation by @shahednasser in https://github.com/medusajs/medusa/pull/9079
* docs: added a services constraint document by @shahednasser in https://github.com/medusajs/medusa/pull/8999
* docs: fixes to long-running workflows + relationship docs by @shahednasser in https://github.com/medusajs/medusa/pull/9101
* docs: added docs for deleting user of actor type by @shahednasser in https://github.com/medusajs/medusa/pull/9104
* docs: add new events to reference by @shahednasser in https://github.com/medusajs/medusa/pull/9121
* oas: [6/n] improve oas schemas by @shahednasser in https://github.com/medusajs/medusa/pull/9122
* docs: fix import of LinkDefinition by @shahednasser in https://github.com/medusajs/medusa/pull/9143
## Chores
* chore: re-add oas tests for generated OAS by @shahednasser in https://github.com/medusajs/medusa/pull/9036
* chore(modules-sdk): Move Query and cleanup by @adrien2p in https://github.com/medusajs/medusa/pull/9054
* chore(types, medusa): clean up to request / response types by @shahednasser in https://github.com/medusajs/medusa/pull/9067
* chore: joiner config entity property by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/9084
* chore: Register Query in container by @adrien2p in https://github.com/medusajs/medusa/pull/9103
* chore(workflows-sdk): Update hook functions type by @adrien2p in https://github.com/medusajs/medusa/pull/9117
* chore: remove container registration name by @carlos-r-l-rodrigues in https://github.com/medusajs/medusa/pull/9137
## New Contributors
* @McTom234 made their first contribution in https://github.com/medusajs/medusa/pull/9094
* @erickirt made their first contribution in https://github.com/medusajs/medusa/pull/9139
**Full Changelog**: https://github.com/medusajs/medusa/compare/v2.0.8-preview...v2.0.9-preview