Skip to content

Commit

Permalink
chore: move input type to types package
Browse files Browse the repository at this point in the history
  • Loading branch information
riqwan committed Mar 13, 2024
1 parent 04c36a3 commit b0f1e6c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 21 deletions.
13 changes: 2 additions & 11 deletions packages/core-flows/src/promotion/steps/add-rules-to-promotions.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,15 @@
import { ModuleRegistrationName } from "@medusajs/modules-sdk"
import {
CreatePromotionRuleDTO,
AddPromotionRulesWorkflowDTO,
IPromotionModuleService,
PromotionRuleTypes,
} from "@medusajs/types"
import { RuleType } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

type WorkflowStepInput = {
rule_type: PromotionRuleTypes
data: {
id: string
rules: CreatePromotionRuleDTO[]
}
}

export const addRulesToPromotionsStepId = "add-rules-to-promotions"
export const addRulesToPromotionsStep = createStep(
addRulesToPromotionsStepId,
async (input: WorkflowStepInput, { container }) => {
async (input: AddPromotionRulesWorkflowDTO, { container }) => {
const { data, rule_type: ruleType } = input

const promotionModule = container.resolve<IPromotionModuleService>(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,11 @@
import { CreatePromotionRuleDTO, PromotionRuleTypes } from "@medusajs/types"
import { AddPromotionRulesWorkflowDTO } from "@medusajs/types"
import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
import { addRulesToPromotionsStep } from "../steps"

type WorkflowInput = {
rule_type: PromotionRuleTypes
data: {
id: string
rules: CreatePromotionRuleDTO[]
}
}

export const addRulesToPromotionsWorkflowId = "add-rules-to-promotions-workflow"
export const addRulesToPromotionsWorkflow = createWorkflow(
addRulesToPromotionsWorkflowId,
(input: WorkflowData<WorkflowInput>): WorkflowData<void> => {
(input: WorkflowData<AddPromotionRulesWorkflowDTO>): WorkflowData<void> => {
addRulesToPromotionsStep(input)
}
)
1 change: 1 addition & 0 deletions packages/types/src/promotion/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from "./common"
export * from "./mutations"
export * from "./service"
export * from "./workflows"
9 changes: 9 additions & 0 deletions packages/types/src/promotion/workflows.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { CreatePromotionRuleDTO, PromotionRuleTypes } from "./common"

export type AddPromotionRulesWorkflowDTO = {
rule_type: PromotionRuleTypes
data: {
id: string
rules: CreatePromotionRuleDTO[]
}
}

0 comments on commit b0f1e6c

Please sign in to comment.