feat: Add skeleton for supporting product imports in BE (#8232)
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
WorkflowData,
|
||||
createWorkflow,
|
||||
transform,
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { WorkflowTypes } from "@medusajs/types"
|
||||
import { sendNotificationsStep } from "../../notification"
|
||||
|
||||
export const importProductsWorkflowId = "import-products"
|
||||
export const importProductsWorkflow = createWorkflow(
|
||||
importProductsWorkflowId,
|
||||
(
|
||||
input: WorkflowData<WorkflowTypes.ProductWorkflow.ImportProductsDTO>
|
||||
): WorkflowData<void> => {
|
||||
// validateImportCsvStep(input.fileContent)
|
||||
|
||||
const notifications = transform({ input }, (data) => {
|
||||
return [
|
||||
{
|
||||
// We don't need the recipient here for now, but if we want to push feed notifications to a specific user we could add it.
|
||||
to: "",
|
||||
channel: "feed",
|
||||
template: "admin-ui",
|
||||
data: {
|
||||
title: "Product import",
|
||||
description: `Product import of file ${data.input.filename} completed successfully!`,
|
||||
},
|
||||
},
|
||||
]
|
||||
})
|
||||
|
||||
sendNotificationsStep(notifications)
|
||||
}
|
||||
)
|
||||
@@ -21,3 +21,4 @@ export * from "./update-product-tags"
|
||||
export * from "./update-product-variants"
|
||||
export * from "./update-products"
|
||||
export * from "./export-products"
|
||||
export * from "./import-products"
|
||||
|
||||
@@ -2,6 +2,7 @@ import { BatchMethodRequest } from "../../../common"
|
||||
import { ProductStatus } from "../common"
|
||||
|
||||
export interface AdminExportProductRequest {}
|
||||
export interface AdminImportProductRequest {}
|
||||
export interface AdminBatchProductRequest
|
||||
extends BatchMethodRequest<AdminCreateProduct, AdminUpdateProduct> {}
|
||||
|
||||
|
||||
@@ -35,6 +35,10 @@ export interface AdminExportProductResponse {
|
||||
workflow_id: string
|
||||
}
|
||||
|
||||
export interface AdminImportProductResponse {
|
||||
workflow_id: string
|
||||
}
|
||||
|
||||
export interface AdminBatchProductVariantResponse
|
||||
extends BatchMethodResponse<AdminProductVariant> {}
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
export interface ImportProductsDTO {
|
||||
fileContent: string
|
||||
filename: string
|
||||
}
|
||||
@@ -3,3 +3,4 @@ export * from "./create-products"
|
||||
export * from "./update-product-variants"
|
||||
export * from "./update-products"
|
||||
export * from "./export-products"
|
||||
export * from "./import-products"
|
||||
|
||||
Reference in New Issue
Block a user