Skip to content

Commit

Permalink
Merge branch 'develop' into fix/promotion-index
Browse files Browse the repository at this point in the history
  • Loading branch information
olivermrbl authored Feb 26, 2025
2 parents 53cff55 + 65eb3aa commit d9513e2
Show file tree
Hide file tree
Showing 82 changed files with 782 additions and 808 deletions.
7 changes: 7 additions & 0 deletions .changeset/clean-poets-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@medusajs/medusa": patch
"@medusajs/core-flows": patch
"@medusajs/types": patch
---

fix: add additionl data to product categories hook
14 changes: 12 additions & 2 deletions packages/core/core-flows/src/cart/workflows/refresh-cart-items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,22 @@ export const refreshCartItemsWorkflow = createWorkflow(
list: false,
}).config({ name: "refetch–cart" })

const refreshCartInput = transform(
{ refetchedCart, input },
({ refetchedCart, input }) => {
return {
cart: !input.force_refresh ? refetchedCart : undefined,
cart_id: !!input.force_refresh ? input.cart_id : undefined,
}
}
)

refreshCartShippingMethodsWorkflow.runAsStep({
input: { cart: refetchedCart },
input: refreshCartInput,
})

updateTaxLinesWorkflow.runAsStep({
input: { cart: refetchedCart },
input: refreshCartInput,
})

const cartPromoCodes = transform(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const createProductCategoriesWorkflow = createWorkflow(

const categoriesCreated = createHook("categoriesCreated", {
categories: createdCategories,
additional_data: input.additional_data,
})

return new WorkflowResponse(createdCategories, {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { ProductCategoryDTO, ProductCategoryWorkflow } from "@medusajs/framework/types"
import {
ProductCategoryDTO,
ProductCategoryWorkflow,
} from "@medusajs/framework/types"
import { ProductCategoryWorkflowEvents } from "@medusajs/framework/utils"
import {
WorkflowData,
Expand All @@ -19,10 +22,10 @@ export const updateProductCategoriesWorkflowId = "update-product-categories"
/**
* This workflow updates product categories matching specified filters. It's used by the
* [Update Product Category Admin API Route](https://docs.medusajs.com/api/admin#product-categories_postproductcategoriesid).
*
*
* You can use this workflow within your customizations or your own custom workflows, allowing you to
* update product categories within your custom flows.
*
*
* @example
* const { result } = await updateProductCategoriesWorkflow(container)
* .run({
Expand All @@ -35,16 +38,16 @@ export const updateProductCategoriesWorkflowId = "update-product-categories"
* }
* }
* })
*
*
* @summary
*
*
* Update product categories.
*/
export const updateProductCategoriesWorkflow = createWorkflow(
updateProductCategoriesWorkflowId,
(
input: WorkflowData<ProductCategoryWorkflow.UpdateProductCategoriesWorkflowInput>
) => {
) => {
const updatedCategories = updateProductCategoriesStep(input)

const productCategoryIdEvents = transform(
Expand All @@ -66,11 +69,12 @@ export const updateProductCategoriesWorkflow = createWorkflow(
})

const categoriesUpdated = createHook("categoriesUpdated", {
categories: updatedCategories
categories: updatedCategories,
additional_data: input.additional_data,
})

return new WorkflowResponse(updatedCategories, {
hooks: [categoriesUpdated]
hooks: [categoriesUpdated],
})
}
)
9 changes: 5 additions & 4 deletions packages/core/types/src/workflow/product-category/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LinkWorkflowInput } from "../../common"
import { AdditionalData } from "../../http"
import {
CreateProductCategoryDTO,
FilterableProductCategoryProps,
Expand All @@ -8,16 +9,16 @@ import {
/**
* The data to create product categories.
*/
export interface CreateProductCategoriesWorkflowInput {
export type CreateProductCategoriesWorkflowInput = {
/**
* The product categories to create.
*/
product_categories: CreateProductCategoryDTO[]
}
} & AdditionalData
/**
* The data to update product categories.
*/
export interface UpdateProductCategoriesWorkflowInput {
export type UpdateProductCategoriesWorkflowInput = {
/**
* The filters to select the product categories to update.
*/
Expand All @@ -26,7 +27,7 @@ export interface UpdateProductCategoriesWorkflowInput {
* The data to update in the product categories.
*/
update: UpdateProductCategoryDTO
}
} & AdditionalData

/**
* The products to manage of a category.
Expand Down
17 changes: 13 additions & 4 deletions packages/medusa/src/api/admin/product-categories/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
createFindParams,
createOperatorMap,
createSelectParams,
WithAdditionalData,
} from "../../utils/validators"

export type AdminProductCategoryParamsType = z.infer<
Expand Down Expand Up @@ -44,7 +45,7 @@ export const AdminProductCategoriesParams = createFindParams({
.merge(AdminProductCategoriesParamsFields)
.merge(applyAndAndOrOperators(AdminProductCategoriesParamsFields))

export const AdminCreateProductCategory = z
export const CreateProductCategory = z
.object({
name: z.string(),
description: z.string().optional(),
Expand All @@ -57,11 +58,15 @@ export const AdminCreateProductCategory = z
})
.strict()

export const AdminCreateProductCategory = WithAdditionalData(
CreateProductCategory
)

export type AdminCreateProductCategoryType = z.infer<
typeof AdminCreateProductCategory
typeof CreateProductCategory
>

export const AdminUpdateProductCategory = z
export const UpdateProductCategory = z
.object({
name: z.string().optional(),
description: z.string().optional(),
Expand All @@ -74,6 +79,10 @@ export const AdminUpdateProductCategory = z
})
.strict()

export const AdminUpdateProductCategory = WithAdditionalData(
UpdateProductCategory
)

export type AdminUpdateProductCategoryType = z.infer<
typeof AdminUpdateProductCategory
typeof UpdateProductCategory
>
2 changes: 1 addition & 1 deletion www/apps/api-reference/markdown/admin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Use a user's secret API Token to send authenticated requests.

#### How to Create an API Token for a User

Create the API key token either from the Medusa Admin or using the [Create API Key API Route](#api-keys_postapikeys).
Create the API key token either from the [Medusa Admin](!user-guide!/settings/developer/secret-api-keys) or using the [Create API Key API Route](#api-keys_postapikeys).

<Note>

Expand Down
1 change: 1 addition & 0 deletions www/apps/book/app/learn/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ This documentation is split into the following sections:
1. The main documentation, which is the one you're currently reading. It's recommended to follow the chapters in this documentation to understand the core concepts of Medusa and how to use them.
2. The [Development Resources documentation](!resources!) provides guides and resources useful during your development, such as tools, API references, recipes, step-by-step guides and examples, and more.
3. The [Store](!api!/store) and [Admin](!api!/admin) API references provide a reference to the Medusa application's endpoints and instructions related to authentication, parameter types in requests, and more.
4. The [User Guide](!user-guide!) introduces you to the Medusa Admin dashboard and helps merchants and store managers understand how to use the dashboard to manage their store.

To get started, check out the [Installation chapter](./installation/page.mdx).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,4 @@ Then, start the Medusa application:
npm run dev
```

{/* TODO add links */}

And create a product either using the [API route](!api!/admin#products_postproducts) or the Medusa Admin. This runs the subscriber and sends an email using SendGrid.
And create a product either using the [API route](!api!/admin#products_postproducts) or the [Medusa Admin](!user-guide!/products/create). This runs the subscriber and sends an email using SendGrid.
6 changes: 6 additions & 0 deletions www/apps/resources/app/commerce-modules/api-key/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this section of the documentation, you will find resources to learn more about the API Key Module and how to use it in your application.

<Note title="Looking for no-code docs?">

Refer to the [Medusa Admin User Guide](!user-guide!/settings/developer) to learn how to manage publishable and secret API keys using the dashboard.

</Note>

Medusa has API-key related features available out-of-the-box through the API Key Module. A [module](!docs!/learn/fundamentals/modules) is a standalone package that provides features for a single domain. Each of Medusa's commerce features are placed in commerce modules, such as this API Key Module.

<Note>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this guide, you'll learn how to handle the `auth.password_reset` event, which is emitted when a request is sent to the [Generate Reset Password Token API route](../authentication-route/page.mdx#generate-reset-password-token-route).

<Note title="Looking for no-code docs?">

Refer to this [Medusa Admin User Guide](!user-guide!/reset-password) to learn how to reset your user admin password using the dashboard.

</Note>

You'll create a subscriber that listens to the event. When the event is emitted, the subscriber sends an email notification to the user.

<Prerequisites
Expand Down
6 changes: 6 additions & 0 deletions www/apps/resources/app/commerce-modules/currency/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this section of the documentation, you will find resources to learn more about the Currency Module and how to use it in your application.

<Note title="Looking for no-code docs?">

Refer to the [Medusa Admin User Guide](!user-guide!/settings/store) to learn how to manage your store's currencies using the dashboard.

</Note>

Medusa has currency related features available out-of-the-box through the Currency Module. A [module](!docs!/learn/fundamentals/modules) is a standalone package that provides features for a single domain. Each of Medusa's commerce features are placed in commerce modules, such as this Currency Module.

<Note>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export const metadata = {

In this document, you’ll learn how registered and unregistered accounts are distinguished in the Medusa application.

<Note title="Looking for no-code docs?">

Refer to this [Medusa Admin User Guide](!user-guide!/customers) to learn how to manage customers using the dashboard.

</Note>

## `has_account` Property

The [Customer data model](/references/customer/models/Customer) has a `has_account` property, which is a boolean that indicates whether a customer is registered.
Expand Down
6 changes: 6 additions & 0 deletions www/apps/resources/app/commerce-modules/customer/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this section of the documentation, you will find resources to learn more about the Customer Module and how to use it in your application.

<Note title="Looking for no-code docs?">

Refer to the [Medusa Admin User Guide](!user-guide!/customers) to learn how to manage customers and groups using the dashboard.

</Note>

Medusa has customer related features available out-of-the-box through the Customer Module. A [module](!docs!/learn/fundamentals/modules) is a standalone package that provides features for a single domain. Each of Medusa's commerce features are placed in commerce modules, such as this Customer Module.

<Note>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export const metadata = {

In this document, you’ll learn what a fulfillment module provider is.

<Note title="Looking for no-code docs?">

Refer to this [Medusa Admin User Guide](!user-guide!/settings/locations-and-shipping/locations#manage-fulfillment-providers) to learn how to add a fulfillment provider to a location using the dashboard.

</Note>

## What’s a Fulfillment Module Provider?

A fulfillment module provider handles fulfilling items, typically using a third-party integration.
Expand Down
9 changes: 9 additions & 0 deletions www/apps/resources/app/commerce-modules/fulfillment/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ export const metadata = {

In this section of the documentation, you will find resources to learn more about the Fulfillment Module and how to use it in your application.

<Note title="Looking for no-code docs?">

Refer to the Medusa Admin User Guide to learn how to use the dashboard to:

- [Manage order fulfillments](!user-guide!/orders/fulfillments).
- [Manage shipping options and profiles](!user-guide!/settings/locations-and-shipping).

</Note>

Medusa has fulfillment related features available out-of-the-box through the Fulfillment Module. A [module](!docs!/learn/fundamentals/modules) is a standalone package that provides features for a single domain. Each of Medusa's commerce features are placed in commerce modules, such as this Fulfillment Module.

<Note>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ export const metadata = {

In this guide, you'll learn how inventory kits can be used in the Medusa application to support use cases like multi-part products, bundled products, and shared inventory across products.

<Note title="Looking for no-code docs?">

Refer to the following user guides to learn how to use the Medusa Admin dashboard to:

- [Create Multi-Part Products](!user-guide!/products/create/multi-part).
- [Create Bundled Products](!user-guide!/products/create/bundle).

</Note>

## What is an Inventory Kit?

An inventory kit is a collection of inventory items that are linked to a single product variant. These inventory items can be used to represent different parts of a product, or to represent a bundle of products.
Expand Down Expand Up @@ -42,7 +51,7 @@ Then, whenever a customer purchases a bicycle, the inventory of each part is upd

### Create Multi-Part Product

Using the Medusa Admin, you can create a multi-part product by creating its inventory items first, then assigning these inventory items to the product's variant(s).
Using the [Medusa Admin](!user-guide!/products/create/multi-part), you can create a multi-part product by creating its inventory items first, then assigning these inventory items to the product's variant(s).

Using [workflows](!docs!/learn/fundamentals/workflows), you can implement this by first creating the inventory items:

Expand Down Expand Up @@ -205,7 +214,7 @@ Then, when the bundled product's variant is purchased, the inventory quantity of

### Create Bundled Product

You can create a bundled product in the Medusa Admin by creating the products part of the bundle first, each having its own inventory items. Then, you create the bundled product whose variant(s) have inventory kits composed of inventory items from each of the products part of the bundle.
You can create a bundled product in the [Medusa Admin](!user-guide!/products/create/bundle) by creating the products part of the bundle first, each having its own inventory items. Then, you create the bundled product whose variant(s) have inventory kits composed of inventory items from each of the products part of the bundle.

Using [workflows](!docs!/learn/fundamentals/workflows), you can implement this by first creating the products part of the bundle:

Expand Down
6 changes: 6 additions & 0 deletions www/apps/resources/app/commerce-modules/inventory/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this section of the documentation, you will find resources to learn more about the Inventory Module and how to use it in your application.

<Note title="Looking for no-code docs?">

Refer to the [Medusa Admin User Guide](!user-guide!/inventory) to learn how to manage inventory and related features using the dashboard.

</Note>

Medusa has inventory related features available out-of-the-box through the Inventory Module. A [module](!docs!/learn/fundamentals/modules) is a standalone package that provides features for a single domain. Each of Medusa's commerce features are placed in commerce modules, such as this Inventory Module.

<Note>
Expand Down
6 changes: 6 additions & 0 deletions www/apps/resources/app/commerce-modules/order/claim/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export const metadata = {

In this document, you’ll learn about order claims.

<Note title="Looking for no-code docs?">

Refer to this [Medusa Admin User Guide](!user-guide!/orders/claims) to learn how to manage an order's claims using the dashboard.

</Note>

## What is a Claim?

When a customer receives a defective or incorrect item, the merchant can create a claim to refund or replace the item.
Expand Down
6 changes: 6 additions & 0 deletions www/apps/resources/app/commerce-modules/order/edit/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export const metadata = {

In this document, you'll learn about order edits.

<Note title="Looking for no-code docs?">

Refer to this [Medusa Admin User Guide](!user-guide!/orders/edit) to learn how to edit an order's items using the dashboard.

</Note>

## What is an Order Edit?

A merchant can edit an order to add new items or change the quantity of existing items in the order.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this document, you’ll learn about order exchanges.

<Note title="Looking for no-code docs?">

Refer to this [Medusa Admin User Guide](!user-guide!/orders/exchanges) to learn how to manage an order's exchanges using the dashboard.

</Note>

## What is an Exchange?

An exchange is the replacement of an item that the customer ordered with another.
Expand Down
6 changes: 6 additions & 0 deletions www/apps/resources/app/commerce-modules/order/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ export const metadata = {

In this section of the documentation, you will find resources to learn more about the Order Module and how to use it in your application.

<Note title="Looking for no-code docs?">

Refer to the [Medusa Admin User Guide](!user-guide!/orders) to learn how to manage orders using the dashboard.

</Note>

Medusa has order related features available out-of-the-box through the Order Module. A [module](!docs!/learn/fundamentals/modules) is a standalone package that provides features for a single domain. Each of Medusa's commerce features are placed in commerce modules, such as this Order Module.

<Note>
Expand Down
Loading

0 comments on commit d9513e2

Please sign in to comment.