v2.0.3-preview
Get started with a new project
To get started using the preview release, run the following command:
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.
Highlights
Workflow Hooks
π§ Breaking change
We have added a new helper, createHook
, to the workflows-sdk
. The createHook
helper exposes a hook from a workflow. Later (after the workflow has been composed), the workflow consumers can bind a handler to the hook to run custom logic.
Note
As of now, you can only register one hook handler, and the workflow orchestrator ignores the return value.
Exposing hook via createHook
import {
createStep,
createHook,
createWorkflow,
WorkflowResponse
} from '@medusajs/workflows-sdk'
const createProductStep = createStep('createProduct', function () {
// business logic for "createProduct"
})
const workflow = createWorkflow('name', function (input) {
createProductStep(input)
const productCreatedHook = createHook('productCreated', { productId: input.id })
return new WorkflowResponse(input, {
hooks: [productCreatedHook]
})
})
Points to note
- Unlike the
createStep
function, thecreateHook
method is called within the workflow composition callback. - You must return the created hooks from the composition callback. Returning of hooks is needed for the TypeScript engine to provide intellisense when registering a handler for the hook.
- Hooks are executed in the same position as they are defined within the composition callback
Registering the hook handler
The workflow user must register a hook handler to run custom logic within a workflow. They can do that as follows.
workflow.hooks.productCreated(() => {
// run custom business logic
})
Points to note
- The hook handler behaves similarly to a workflow step. It can run async code, will be retried, and can also have compensation behavior (defined as the 2nd parameter)
- There can only be one handler for a hook. If you need multiple handlers, you should create another workflow and register that as the hook handler (not supported yet).
- The return value of the hook handler is ignored in this first iteration.
Introducing the WorkflowResponse
class and breaking changes
The introduction of hooks has changed the return value of the createWorkflow
composition callback. Now, we must return both the workflow results and the configured hooks.
Instead of manually composing the return value, you can use the WorkflowResponse
class to construct the current response. The WorkflowResponse
class accepts the following parameters.
- The first parameter is the result of the workflow.
- The second parameter (optional) is a config object with configured hooks.
Product Import and Export
We have re-introduced Product Import and Export and simultaneously redesigned the notifications drawer in the dashboard.
Right now, we are polling for new notifications every third second, but we intend to introduce SSE (or a similar tech.) to enable real-time notifications.
Product Tag management UI
We have added Product Tag management in the dashboard. Find it in "Settings > Product Tags".
New Recipes: Subscriptions and Digital Products
We have added two new recipes covering how to add support for Subscriptions and Digital Product respectively. They both come with an example repository.
Check out the Subscription recipe here.
Check out the Digital Products recipe here.
Features
- feat(medusa): add stock_location_id filter to providers api by @riqwan in #8319
- Chore/order claims 2 by @carlos-r-l-rodrigues in #8312
- feat:Allow updating prices through product update workflow by @sradevski in #8316
- feat(orchestration,workflows-sdk): Skip step by @carlos-r-l-rodrigues in #8334
- feat: Add support for product export in UI by @sradevski in #8281
- feat(dashboard,icons,types,js-sdk): add providers to location UI by @riqwan in #8328
- feat: Add support for product imports by @sradevski in #8298
- breaking: implement workflow hooks (first iteration) by @thetutlage in #8346
- feat: Make product import v1 compatible by @sradevski in #8362
- feat(dashboard, types, js-sdk): Claims client, hooks and types by @fPolic in #8370
- feat: Cart API should also return billing_address.province by default by @josetr in #8293
- feat(core-flows, fulfillment): validate shipping options to stock locations by @riqwan in #8291
- feat(core-flows,medusa): add endpoint to add/remove fulfillment providers to location by @riqwan in #8299
- feat: update return request by @olivermrbl in #8302
- feat(dashboard,medusa,types): Add Product Tag management by @kasperkristensen in #8349
- feat(dashboard,js-sdk,types): add ability to capture payment from order page by @riqwan in #8368
- chore(core-flows): Order Exchange - initial workflows by @carlos-r-l-rodrigues in #8374
- feat: Add support for sorting export headers by @sradevski in #8386
- feat: Add
requested_at
+open
status to return by @olivermrbl in #8391 - feat: Show notice on new notifications by @sradevski in #8390
- feat: add hooks to product module's workflows by @thetutlage in #8389
- feat(dashboard,types,js-sdk,payment): ability to refund payment in order page by @riqwan in #8385
- feat(dashboard, js-sdk, types): receive return e2e by @fPolic in #8305
- feat: Use tag ids instead of values wherever possible by @sradevski in #8394
- feat: Add support for categories in product import and export by @sradevski in #8375
Bugs
- fix: Store private files in the static directory by default by @sradevski in #8325
- fix(core-flows,order): update action by @carlos-r-l-rodrigues in #8333
- fix(dashboard,types,js-sdk): Cleanup
settings/store
by @kasperkristensen in #8336 - fix(core-flows): delete receive return action by @carlos-r-l-rodrigues in #8350
- fix: Added more tests and fixed a couple of issues with product import by @sradevski in #8341
- fix(dashboard): Fix spacing, media, and missing tip in product create form by @kasperkristensen in #8338
- fix: Use region name in product pricing exports by @sradevski in #8373
- fix(framework): prepublish script by @adrien2p in #8377
- fix(framework): telemetry package version by @adrien2p in #8378
- fix: Correctly associate options to variants when variants for multiple products are created by @sradevski in #8285
- fix(core-flows): update receive returned item by @carlos-r-l-rodrigues in #8295
- fix(dashboard): Fix CountrySelect by @kasperkristensen in #8301
- fix(dashboard): Cell behaviour in DataGrid by @kasperkristensen in #8183
- fix: Updating product prices removed existing prices by @sradevski in #8388
- fix: Pass updatedCollections to the hook and not the step by @thetutlage in #8402
- fix(core-flows,utils,medusa): fix bug where payment collection across orders were getting updated by @riqwan in #8401
- fix: Check for existence of modules when seeding default data by @sradevski in #8406
- fix(framework/config): Properly resolve env variables by @adrien2p in #8411
- fix: Don't remove pricing if no variant is passed to update by @sradevski in #8416
Documentation
- docs: added guide on how to get product variant prices by @shahednasser in #8282
- docs: remove js client and medusa react references by @shahednasser in #8270
- docs: update deployment guides for storefront and admin by @shahednasser in #8279
- docs: added a service factory reference by @shahednasser in #8292
- docs-util: add docblock generator for models built with DML by @shahednasser in #8296
- docs-util: update knowledge base of docblock-generator by @shahednasser in #8323
- docs: added typedoc plugin to parse DML json files by @shahednasser in #8300
- docs-util: rename docblock-generator to docs-generator by @shahednasser in #8331
- docs-util: fix knowledge base for functions by @shahednasser in #8337
- docs: added storefront guide on prices with taxes by @shahednasser in #8326
- docs: fix local link to infer slug from front matter by @shahednasser in #8353
- docs-util: fix how data model name is inferred by @shahednasser in #8351
- docs-util: support generating helper steps by @shahednasser in #8354
- Update page.mdx by @JayabharathiPalanisamy in #8366
- docs: added workflow hooks docs + changed workflow response by @shahednasser in #8364
- docs: add sidebar item for helper steps reference + examples fix by @shahednasser in #8365
- docs: add a documentation on calculating prices with taxes by @shahednasser in #8330
- docs-util: mark type parameters as optional by @shahednasser in #8320
- docs: added subscription recipe example by @shahednasser in #8148
- docs: added digital product recipe example by @shahednasser in #8223
- docs: fix recipes sidebar + homepage cards by @shahednasser in #8415
Chores
- chore: Publish framework package by @olivermrbl in #8322
- chore(types): add a note about adding
ssl_mode
option to database URLs by @shahednasser in #8324 - chore(framework): Continue to move loaders to framework by @adrien2p in #8258
- chore(core-flows): cancel claims by @carlos-r-l-rodrigues in #8342
- chore(framework): Move feature flags related resources and cleanup by @adrien2p in #8297
- chore(framework): Move and improve subscriber loader by @adrien2p in #8347
- chore(core-flows,modules-sdk): add TSDocs to helper steps by @shahednasser in #8355
- Chore/framework 6/n by @adrien2p in #8356
- chore(framework): Move and improve links loader by @adrien2p in #8367
- chore(framework): Move and improve workflows loader by @adrien2p in #8363
- chore(core-flows): return fulfillment link by @carlos-r-l-rodrigues in #8304
- chore(framework): Move and improve routes loader by @adrien2p in #8392
- chore(core-flows): use create order step on complete cart by @carlos-r-l-rodrigues in #8397
- chore(framework): medusa app loaders by @adrien2p in #8393
- chore(workflows-sdk): add TSDocs related to createHook by @shahednasser in #8380
- chore: Update labeler to add type labels automatically by @olivermrbl in #8410
- chore(framework): Allow multiple source dir for subcribers loader by @adrien2p in #8407
New Contributors
- @JayabharathiPalanisamy made their first contribution in #8366
Full Changelog: v2.0.2-preview...v2.0.3-preview