feat(medusa, types, utils, workflow): Migrate medusa workflow to the workflow package (#4682)
This commit is contained in:
1 parent
433914ae01
commit
dc46927bc6
68 files changed
+1224
-1064
No files matched your search
@@ -36,13 +36,13 @@ import { DistributedTransaction } from "@medusajs/orchestration"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
||||
import { FlagRouter } from "../../../../utils/flag-router"
|
||||
import { IInventoryService } from "@medusajs/types"
|
||||
import { IInventoryService, WorkflowTypes } from "@medusajs/types"
|
||||
import { Logger } from "../../../../types/global"
|
||||
import { ProductStatus } from "../../../../models"
|
||||
import SalesChannelFeatureFlag from "../../../../loaders/feature-flags/sales-channels"
|
||||
import { Type } from "class-transformer"
|
||||
import { createProductsWorkflow } from "../../../../workflows/admin/create-products"
|
||||
import { validator } from "../../../../utils/validator"
|
||||
import { validator } from "../../../../utils"
|
||||
import { createProducts } from "@medusajs/workflows"
|
||||
|
||||
/**
|
||||
* @oas [post] /admin/products
|
||||
@@ -133,13 +133,26 @@ export default async (req, res) => {
|
||||
const productModuleService = req.scope.resolve("productModuleService")
|
||||
|
||||
if (productModuleService) {
|
||||
const products = await createProductsWorkflow(
|
||||
{
|
||||
container: req.scope,
|
||||
const createProductWorkflow = createProducts(req.scope)
|
||||
|
||||
const input = {
|
||||
products: [
|
||||
validated,
|
||||
] as WorkflowTypes.ProductWorkflow.CreateProductInputDTO[],
|
||||
config: {
|
||||
listConfig: {
|
||||
select: defaultAdminProductFields,
|
||||
relations: defaultAdminProductRelations,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
const { result: products } = await createProductWorkflow.run({
|
||||
input,
|
||||
context: {
|
||||
manager: entityManager,
|
||||
},
|
||||
[validated]
|
||||
)
|
||||
})
|
||||
|
||||
return res.json({ product: products[0] })
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user