github medusajs/medusa v2.2.0

one day ago

Highlights

Passing custom callback to Oauth providers

Warning

Breaking changes

The callback URL for Oauth providers can now be passed in the payload of the authentication request to support use cases like different login pages based on the actor.

For example, you might have a user/github/callback page and a customer/github/callback page, and where you redirect to would depend on which actor is doing the authentication.

The request would look as follows:

POST http://localhost:9000/customer/auth/github

{ callback_url: "<some url>" }

This change also adds the state parameter as defined in the Oauth protocol.

Required actions

If you have overridden the auth module definition in medusa-config.ts, you will need to pass Modules.CACHE as a dependency, as the state is stored temporarily in cache when carrying out the authentication flow:

module.exports = defineConfig({
 ...
  modules: [
    {
      resolve: "@medusajs/medusa/auth",
      dependencies: [Modules.CACHE, ContainerRegistrationKeys.LOGGER],
      options: {
        providers: [ ... ],
      },
    },
  ],
})

Custom module types

Container mappings types are generated for modules by inspecting the registered modules. The types are generated and written to your local project in .medusa/types/module-bindings.d.ts. To generate the types, the module needs be functionally correct, registered in medusa-config.ts, and the server needs to be started in development mode.

Once the types are generated, your IDEs intellisense should pick them up, e.g. when creating an API Route:

import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http"

export const GET = (req: MedusaRequest, res: MedusaResponse) => {

  const brandModule = req.scope.resolve("brand")

  await brandModule. // <-------------- Autocompletion should appear

  ...
}

If you experience issues with generating types for custom modules, please submit an issue, so we can look into it.

Deprecated APIs

Some APIs have been deprecated and/or renamed as part of a housekeeping task in order to be more consistent with naming across tools and modules.

These are:

  • remoteLink -> link (deprecated and renamed)
  • remoteQueryConfig -> queryConfig (deprecated and renamed)
  • remote-query-entry-points.d.ts -> query-entry-points.d.ts (renaming)

There are no breaking changes in this release, but the deprecated APIs will be removed in a later release, so we recommend updating your code to use the new APIs as soon as possible.

Order cancelation

Canceling an order will also cancel its payments. If the payments are captured, we will attempt to refund an amount equal to the captured amount. If the payments are not captured, they will be canceled immediately.

Other changes

The relationship between stock location and stock location address has been changed to a one-to-one. This change involves a migration, so please apply the latest migrations when upgrading.

Required actions

Run migrations to ensure your server functions as expected after upgrading:

npx medusa db:migrate

Features

  • feat(medusa): Add health endpoint for all running modes of medusa by @sradevski in #10737
  • feat(create-medusa-app): allow passing project name on command line by @shahednasser in #10755
  • feat: deprecate remote link by @thetutlage in #10768
  • feat: deprecate remoteQueryConfig in favor of queryConfig by @thetutlage in #10773
  • feat: generate modules mappings at runtime by @thetutlage in #10791
  • feat(create-medusa-app): improve by adding depth to clone commands by @shahednasser in #10812
  • feat(auth-google,auth-github): Allow passing a custom callbackUrl to … by @sradevski in #10829
  • feat(dashboard,core-flows,types,utils,medusa): Order cancelations will refund payments by @riqwan in #10667

Bugs

  • fix(fulfillment): export schema types by @shahednasser in #10700
  • fix: pluralization of words ending in y, where y follows a vowel by @thetutlage in #10697
  • fix(medusa,types,js-sdk): fix request query parameter types for store product routes by @shahednasser in #10707
  • fix(core-flows): export updateTaxRegionsStep by @shahednasser in #10732
  • fix(pricing): pricing context calculations only takes into account existing rule attributes by @riqwan in #10771
  • Fix/product variants filter by @thetutlage in #10808
  • fix(): Workflow cancellation + gracefully handle non serializable state by @adrien2p in #10674
  • fix(core-flow): invalid update quantity in update line item in cart workflow by @daykrm in #10405
  • fix(promotion): don't evaluate rule condition if conditions to evaluate is empty by @riqwan in #10795
  • fix(stock-location,core-flows,types): updates existing address when updating stock location by @riqwan in #10832
  • feat(core-flows,fulfillment, fulfillment-manual, types): make fulfillment typings more specific by @fPolic in #10677
  • fix(create-medusa-app): add default storefront url to auth CORS by @shahednasser in #10853
  • fix(dashboard): cancel order notifications by @fPolic in #10858

Documentation

Chores

Other Changes

New Contributors

Full Changelog: v2.1.3...v2.2.0

Don't miss a new medusa release

NewReleases is sending notifications on new releases.