Skip to content

v1.18.0

Compare
Choose a tag to compare
@olivermrbl olivermrbl released this 21 Nov 09:15
· 3150 commits to develop since this release
9c7f95c

Highlights

Subscriber API + Scheduled Jobs API

This release comes with an improved Subscriber API and a new Scheduled Jobs API. These are drastic improvements of the developer experience of setting up event subscribers and cron jobs.

Subscriber API

// src/subscribers/product-update-handler.ts
import type { SubscriberConfig, SubscriberArgs, ProductService } from "@medusajs/medusa"

export default async function productUpdateHandler({ data, eventName, container, pluginOptions }: SubscriberArgs) {
  const productService: ProductService = container.resolve("productService")

  const { id } = data

  const product = await productService.retrieve(id)

  // do something with the product...
}

export const config: SubscriberConfig = {
  event: ProductService.Events.UPDATE
}

Scheduled Jobs API

// src/jobs/once-a-minute.ts
import type { ProductService, ScheduledJobConfig, ScheduledJobArgs }  from "@medusajs/medusa"

export default async function handler({ container, data, pluginOptions }: ScheduledJobArgs) {
  const productService: ProductService = container.resolve("productService")
  
  const count = await productService.count()

  console.log(`You have ${count} products`)
}

export const config: ScheduledJobConfig = {
  name: "every-minute",
  schedule: "* * * * *"
}

Read more about the new APIs in the PR details.

Breaking changes

Changes to feature flags

This version significantly changes the feature flags in our core @medusajs/medusa. We've decided to replace all module-specific feature flags with one that encapsulates all the work around modularizing Medusa further.

The following feature flags no longer exist:

Name Flag Environment variable
Product Module isolate_product_domain  MEDUSA_FF_ISOLATE_PRODUCT_DOMAIN
Pricing Module isolate_pricing_domain  MEDUSA_FF_ISOLATE_PRICING_DOMAIN

These feature flags have been replaced with one capturing all work for Medusa V2, releasing next year:

Name Flag Environment variable
Medusa V2 medusa_v2  MEDUSA_FF_MEDUSA_V2

Creating a NotificationService

The introduction of the new Subscriber API changes the recommended way to define the subscribers of a NotificationService. The recommended approach is to use a loader until our Subscriber API natively supports NotificationServices or we introduce a mechanism dedicated towards it.

Read more here.

Features

  • feat(pricing,types): price list API + price calculations with price lists by @riqwan in #5498
  • feat(workflows,medusa,utils): add medusa v2 feature flag by @riqwan in #5603
  • feat(medusa): Alternative Subscriber API and new ScheduledJobs API by @kasperkristensen in #5624
  • feat(medusa): Add metadata to Product Category by @bqst in #5599

Bugs

Chores

Documentation

New Contributors

Full Changelog: v1.17.4...v1.18.0