feat(medusa,types,core-flows,utils): added delete endpoints for campaigns and promotions (#6152)
what: adds delete endpoints for: - campaigns (RESOLVES CORE-1686) - promotions (RESOLVES CORE-1680)
This commit is contained in:
1 parent
76291823f4
commit
99045848fd
25 files changed
+699
-84
No files matched your search
@@ -3,7 +3,6 @@ import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { createPromotionsStep } from "../../handlers/promotion"
|
||||
|
||||
type WorkflowInput = { promotionsData: CreatePromotionDTO[] }
|
||||
type WorkflowOutput = PromotionDTO[]
|
||||
|
||||
export const createPromotionsWorkflowId = "create-promotions"
|
||||
export const createPromotionsWorkflow = createWorkflow(
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { createWorkflow, WorkflowData } from "@medusajs/workflows-sdk"
|
||||
import { deleteCampaignsStep } from "../../handlers/promotion"
|
||||
|
||||
type WorkflowInput = { ids: string[] }
|
||||
|
||||
export const deleteCampaignsWorkflowId = "delete-campaigns"
|
||||
export const deleteCampaignsWorkflow = createWorkflow(
|
||||
deleteCampaignsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>): WorkflowData<void> => {
|
||||
return deleteCampaignsStep(input.ids)
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,12 @@
|
||||
import { createWorkflow, WorkflowData } from "@medusajs/workflows-sdk"
|
||||
import { deletePromotionsStep } from "../../handlers/promotion"
|
||||
|
||||
type WorkflowInput = { ids: string[] }
|
||||
|
||||
export const deletePromotionsWorkflowId = "delete-promotions"
|
||||
export const deletePromotionsWorkflow = createWorkflow(
|
||||
deletePromotionsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>): WorkflowData<void> => {
|
||||
return deletePromotionsStep(input.ids)
|
||||
}
|
||||
)
|
||||
@@ -1,4 +1,6 @@
|
||||
export * from "./create-campaigns"
|
||||
export * from "./create-promotions"
|
||||
export * from "./delete-campaigns"
|
||||
export * from "./delete-promotions"
|
||||
export * from "./update-campaigns"
|
||||
export * from "./update-promotions"
|
||||
@@ -0,0 +1,28 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IPromotionModuleService } from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteCampaignsStepId = "delete-campaigns"
|
||||
export const deleteCampaignsStep = createStep(
|
||||
deleteCampaignsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
const promotionModule = container.resolve<IPromotionModuleService>(
|
||||
ModuleRegistrationName.PROMOTION
|
||||
)
|
||||
|
||||
await promotionModule.softDeleteCampaigns(ids)
|
||||
|
||||
return new StepResponse(void 0, ids)
|
||||
},
|
||||
async (idsToRestore, { container }) => {
|
||||
if (!idsToRestore?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const promotionModule = container.resolve<IPromotionModuleService>(
|
||||
ModuleRegistrationName.PROMOTION
|
||||
)
|
||||
|
||||
await promotionModule.restoreCampaigns(idsToRestore)
|
||||
}
|
||||
)
|
||||
@@ -0,0 +1,28 @@
|
||||
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
|
||||
import { IPromotionModuleService } from "@medusajs/types"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deletePromotionsStepId = "delete-promotions"
|
||||
export const deletePromotionsStep = createStep(
|
||||
deletePromotionsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
const promotionModule = container.resolve<IPromotionModuleService>(
|
||||
ModuleRegistrationName.PROMOTION
|
||||
)
|
||||
|
||||
await promotionModule.softDelete(ids)
|
||||
|
||||
return new StepResponse(void 0, ids)
|
||||
},
|
||||
async (idsToRestore, { container }) => {
|
||||
if (!idsToRestore?.length) {
|
||||
return
|
||||
}
|
||||
|
||||
const promotionModule = container.resolve<IPromotionModuleService>(
|
||||
ModuleRegistrationName.PROMOTION
|
||||
)
|
||||
|
||||
await promotionModule.restore(idsToRestore)
|
||||
}
|
||||
)
|
||||
@@ -1,4 +1,6 @@
|
||||
export * from "./create-campaigns"
|
||||
export * from "./create-promotions"
|
||||
export * from "./delete-campaigns"
|
||||
export * from "./delete-promotions"
|
||||
export * from "./update-campaigns"
|
||||
export * from "./update-promotions"
|
||||
Reference in new issue
Block a user