Fix/add additionl data to product categories hook (#11226)
* fix: add additional_data to categoriesCreated hooks * fix: restore yarn.lock * fix: add additional_data param in the http validators * fix: add additional_data to updateProductCategoriesWorkflow * Update yarn.lock * fix: fix merge * fix: refert yarn.lock * fix: revert tarn.lock * Create clean-poets-promise.md --------- Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com> Co-authored-by: Riqwan Thamir <rmthamir@gmail.com>
This commit is contained in:
5 files changed
+33
-11
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
"@medusajs/medusa": patch
|
||||||
|
"@medusajs/core-flows": patch
|
||||||
|
"@medusajs/types": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: add additionl data to product categories hook
|
||||||
@@ -65,6 +65,7 @@ export const createProductCategoriesWorkflow = createWorkflow(
|
|||||||
|
|
||||||
const categoriesCreated = createHook("categoriesCreated", {
|
const categoriesCreated = createHook("categoriesCreated", {
|
||||||
categories: createdCategories,
|
categories: createdCategories,
|
||||||
|
additional_data: input.additional_data,
|
||||||
})
|
})
|
||||||
|
|
||||||
return new WorkflowResponse(createdCategories, {
|
return new WorkflowResponse(createdCategories, {
|
||||||
|
|||||||
+7
-3
@@ -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 { ProductCategoryWorkflowEvents } from "@medusajs/framework/utils"
|
||||||
import {
|
import {
|
||||||
WorkflowData,
|
WorkflowData,
|
||||||
@@ -66,11 +69,12 @@ export const updateProductCategoriesWorkflow = createWorkflow(
|
|||||||
})
|
})
|
||||||
|
|
||||||
const categoriesUpdated = createHook("categoriesUpdated", {
|
const categoriesUpdated = createHook("categoriesUpdated", {
|
||||||
categories: updatedCategories
|
categories: updatedCategories,
|
||||||
|
additional_data: input.additional_data,
|
||||||
})
|
})
|
||||||
|
|
||||||
return new WorkflowResponse(updatedCategories, {
|
return new WorkflowResponse(updatedCategories, {
|
||||||
hooks: [categoriesUpdated]
|
hooks: [categoriesUpdated],
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { LinkWorkflowInput } from "../../common"
|
import { LinkWorkflowInput } from "../../common"
|
||||||
|
import { AdditionalData } from "../../http"
|
||||||
import {
|
import {
|
||||||
CreateProductCategoryDTO,
|
CreateProductCategoryDTO,
|
||||||
FilterableProductCategoryProps,
|
FilterableProductCategoryProps,
|
||||||
@@ -8,16 +9,16 @@ import {
|
|||||||
/**
|
/**
|
||||||
* The data to create product categories.
|
* The data to create product categories.
|
||||||
*/
|
*/
|
||||||
export interface CreateProductCategoriesWorkflowInput {
|
export type CreateProductCategoriesWorkflowInput = {
|
||||||
/**
|
/**
|
||||||
* The product categories to create.
|
* The product categories to create.
|
||||||
*/
|
*/
|
||||||
product_categories: CreateProductCategoryDTO[]
|
product_categories: CreateProductCategoryDTO[]
|
||||||
}
|
} & AdditionalData
|
||||||
/**
|
/**
|
||||||
* The data to update product categories.
|
* The data to update product categories.
|
||||||
*/
|
*/
|
||||||
export interface UpdateProductCategoriesWorkflowInput {
|
export type UpdateProductCategoriesWorkflowInput = {
|
||||||
/**
|
/**
|
||||||
* The filters to select the product categories to update.
|
* The filters to select the product categories to update.
|
||||||
*/
|
*/
|
||||||
@@ -26,7 +27,7 @@ export interface UpdateProductCategoriesWorkflowInput {
|
|||||||
* The data to update in the product categories.
|
* The data to update in the product categories.
|
||||||
*/
|
*/
|
||||||
update: UpdateProductCategoryDTO
|
update: UpdateProductCategoryDTO
|
||||||
}
|
} & AdditionalData
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The products to manage of a category.
|
* The products to manage of a category.
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
createFindParams,
|
createFindParams,
|
||||||
createOperatorMap,
|
createOperatorMap,
|
||||||
createSelectParams,
|
createSelectParams,
|
||||||
|
WithAdditionalData,
|
||||||
} from "../../utils/validators"
|
} from "../../utils/validators"
|
||||||
|
|
||||||
export type AdminProductCategoryParamsType = z.infer<
|
export type AdminProductCategoryParamsType = z.infer<
|
||||||
@@ -44,7 +45,7 @@ export const AdminProductCategoriesParams = createFindParams({
|
|||||||
.merge(AdminProductCategoriesParamsFields)
|
.merge(AdminProductCategoriesParamsFields)
|
||||||
.merge(applyAndAndOrOperators(AdminProductCategoriesParamsFields))
|
.merge(applyAndAndOrOperators(AdminProductCategoriesParamsFields))
|
||||||
|
|
||||||
export const AdminCreateProductCategory = z
|
export const CreateProductCategory = z
|
||||||
.object({
|
.object({
|
||||||
name: z.string(),
|
name: z.string(),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
@@ -57,11 +58,15 @@ export const AdminCreateProductCategory = z
|
|||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
|
|
||||||
|
export const AdminCreateProductCategory = WithAdditionalData(
|
||||||
|
CreateProductCategory
|
||||||
|
)
|
||||||
|
|
||||||
export type AdminCreateProductCategoryType = z.infer<
|
export type AdminCreateProductCategoryType = z.infer<
|
||||||
typeof AdminCreateProductCategory
|
typeof CreateProductCategory
|
||||||
>
|
>
|
||||||
|
|
||||||
export const AdminUpdateProductCategory = z
|
export const UpdateProductCategory = z
|
||||||
.object({
|
.object({
|
||||||
name: z.string().optional(),
|
name: z.string().optional(),
|
||||||
description: z.string().optional(),
|
description: z.string().optional(),
|
||||||
@@ -74,6 +79,10 @@ export const AdminUpdateProductCategory = z
|
|||||||
})
|
})
|
||||||
.strict()
|
.strict()
|
||||||
|
|
||||||
|
export const AdminUpdateProductCategory = WithAdditionalData(
|
||||||
|
UpdateProductCategory
|
||||||
|
)
|
||||||
|
|
||||||
export type AdminUpdateProductCategoryType = z.infer<
|
export type AdminUpdateProductCategoryType = z.infer<
|
||||||
typeof AdminUpdateProductCategory
|
typeof UpdateProductCategory
|
||||||
>
|
>
|
||||||
Reference in new issue
Block a user