feat: Add skeleton for supporting product imports in BE (#8232)

This commit is contained in:
Stevche Radevski
2024-07-23 11:16:14 +02:00
committed by GitHub
parent 55b55b6a92
commit 4b09be3a88
17 changed files with 204 additions and 1178 deletions
@@ -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"