Harminder Virk 93b38bf47b fix: do not pass additional_data to service (#9532)
Fixes: FRMW-2743

This PR extracts and removes the `additional_data` from the workflow input before calling the steps and hence the `additional_data` is not passed down to the service layer.

However, this bug has made me discover one inconsistency in the input structure of certain workflows.

 **Following is the input structure of the `updateProductsWorkflow`**. Here, we accept the `products` and the `additional_data` as two separate top-level properties.

```ts
// Shape
export type UpdateProductsWorkflowInputSelector = {
  selector: ProductTypes.FilterableProductProps
  update: Omit<ProductTypes.UpdateProductDTO, "variants"> & {
    sales_channels?: { id: string }[]
    variants?: UpdateProductVariantWorkflowInputDTO[]
  }
} & AdditionalData

// Calling the workflow
const { result } = await updateProductsWorkflow(req.scope).run({
  input: {
    selector: { id: req.params.id },
    update,
    additional_data,
  },
})
```

 **Following in the input structure of the `updateCartWorflow`**. In this case, we are accepting the cart properties at the top-level, hence the `additional_data` is merged within those properties, increasing the chance of passing it down to the service layer by mistake.

```ts
// Shape
WorkflowData<UpdateCartWorkflowInputDTO & AdditionalData>

// Calling the workflow
await workflow.run({
  input: {
    ...req.validatedBody // Additional data is part of the validatedBody,
    id: req.params.id,
  },
})
```

Ideally, the input of `updateCartWorkflow` should look as follows.

```ts
WorkflowData<{ cart: UpdateCartWorkflowInputDTO } & AdditionalData>
```
2024-10-11 23:43:13 +00:00
2024-08-23 07:16:04 -03:00
2023-11-02 10:31:45 +00:00
2024-03-27 17:46:32 +01:00

Medusa logo

Medusa

Documentation | Website

Building blocks for digital commerce

Medusa is released under the MIT license. PRs welcome!

Follow @medusajs Discord Chat

Getting Started

Visit the Quickstart Guide to set up a server.

Visit the Docs to learn more about our system requirements.

What is Medusa

Medusa is a set of commerce modules and tools that allow you to build rich, reliable, and performant commerce applications without reinventing core commerce logic. The modules can be customized and used to build advanced ecommerce stores, marketplaces, or any product that needs foundational commerce primitives. All modules are open-source and freely available on npm.

Learn more about Medusas architecture and commerce modules in the Docs.

Roadmap, Upgrades & Plugins

You can view the planned, started and completed features in the Roadmap discussion.

Follow the Upgrade Guides to keep your Medusa project up-to-date.

Check out all available Medusa plugins.

Community & Contributions

The community and core team are available in GitHub Discussions, where you can ask for support, discuss roadmap, and share ideas.

Our Contribution Guide describes how to contribute to the codebase and Docs.

Join our Discord server to meet other community members.

Other channels

License

Licensed under the MIT License.

Description
No description provided
Readme 539 MiB
Languages
TypeScript 84.9%
JavaScript 14.8%
Shell 0.2%