Skip to content

Commit

Permalink
chore(core-flows): [12] export types and types, add basic TSDocs
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Aug 8, 2024
1 parent 90120d6 commit 9c43c8c
Show file tree
Hide file tree
Showing 21 changed files with 71 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { createPriceListPricesWorkflow } from "../workflows/create-price-list-pr

export const createPriceListPricesWorkflowStepId =
"create-price-list-prices-workflow-step"
/**
* This step creates prices for price lists.
*/
export const createPriceListPricesWorkflowStep = createStep(
createPriceListPricesWorkflowStepId,
async (data: CreatePriceListPricesWorkflowDTO[], { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const createPriceListPricesStepId = "create-price-list-prices"
/**
* This step creates prices for a price list.
*/
export const createPriceListPricesStep = createStep(
createPriceListPricesStepId,
async (stepInput: CreatePriceListPricesWorkflowStepDTO, { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const createPriceListsStepId = "create-price-lists"
/**
* This step creates a price list.
*/
export const createPriceListsStep = createStep(
createPriceListsStepId,
async (stepInput: CreatePriceListsWorkflowStepDTO, { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { IPricingModuleService } from "@medusajs/types"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const deletePriceListsStepId = "delete-campaigns"
export const deletePriceListsStepId = "delete-price-lists"
/**
* This step deletes one or more price lists.
*/
export const deletePriceListsStep = createStep(
deletePriceListsStepId,
async (ids: string[], { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const getExistingPriceListsPriceIdsStepId =
"get-existing-price-lists-prices"
/**
* This step retrieves prices of price lists.
*/
export const getExistingPriceListsPriceIdsStep = createStep(
getExistingPriceListsPriceIdsStepId,
async (data: { price_list_ids: string[] }, { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { removePriceListPricesWorkflow } from "../workflows/remove-price-list-pr

export const removePriceListPricesWorkflowStepId =
"remove-price-list-prices-workflow"
/**
* This step removes prices from price lists.
*/
export const removePriceListPricesWorkflowStep = createStep(
removePriceListPricesWorkflowStepId,
async (ids: string[], { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const removePriceListPricesStepId = "remove-price-list-prices"
/**
* This step removes prices from a price list.
*/
export const removePriceListPricesStep = createStep(
removePriceListPricesStepId,
async (ids: string[], { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { updatePriceListPricesWorkflow } from "../workflows/update-price-list-pr

export const updatePriceListPricesWorkflowStepId =
"update-price-list-prices-workflow"
/**
* This step updates price lists' prices.
*/
export const updatePriceListPricesWorkflowStep = createStep(
updatePriceListPricesWorkflowStepId,
async (data: UpdatePriceListPricesWorkflowDTO[], { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import {
import { createStep, StepResponse } from "@medusajs/workflows-sdk"

export const updatePriceListPricesStepId = "update-price-list-prices"
/**
* This step updates a price list's prices.
*/
export const updatePriceListPricesStep = createStep(
updatePriceListPricesStepId,
async (stepInput: UpdatePriceListPriceWorkflowStepDTO, { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import {
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const updatePriceListsStepId = "update-price-lists"
/**
* This step updates one or more price lists.
*/
export const updatePriceListsStep = createStep(
updatePriceListsStepId,
async (data: UpdatePriceListDTO[], { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import {
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const validatePriceListsStepId = "validate-price-lists"
/**
* This step validates that the specified price lists exist.
*/
export const validatePriceListsStep = createStep(
validatePriceListsStepId,
async (data: Pick<UpdatePriceListDTO, "id">[], { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ import {
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const validateVariantPriceLinksStepId = "validate-variant-price-links"
/**
* This step validates that the specified variants have prices.
*/
export const validateVariantPriceLinksStep = createStep(
validateVariantPriceLinksStepId,
async (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { PricingWorkflow } from "@medusajs/types/dist/workflow"
import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

type StepInput = PricingWorkflow.CreatePricePreferencesWorkflowInput[]

export const createPricePreferencesStepId = "create-price-preferences"
/**
* This step creates one or more price preferences.
*/
export const createPricePreferencesStep = createStep(
createPricePreferencesStepId,
async (data: StepInput, { container }) => {
async (data: PricingWorkflow.CreatePricePreferencesWorkflowInput[], { container }) => {
const pricingModule = container.resolve<IPricingModuleService>(
ModuleRegistrationName.PRICING
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const createPriceSetsStepId = "create-price-sets"
/**
* This step creates one or more price sets.
*/
export const createPriceSetsStep = createStep(
createPriceSetsStepId,
async (data: CreatePriceSetDTO[], { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

export const deletePricePreferencesStepId = "delete-price-preferences"
/**
* This step deletes one or more price preferences.
*/
export const deletePricePreferencesStep = createStep(
deletePricePreferencesStepId,
async (ids: string[], { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import {
} from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

type StepInput = PricingWorkflow.UpdatePricePreferencesWorkflowInput["update"][]
export type UpdatePricePreferencesAsArrayStepInput = PricingWorkflow.UpdatePricePreferencesWorkflowInput["update"][]

export const updatePricePreferencesAsArrayStepId =
"update-price-preferences-as-array"
/**
* This step updates price preferences.
*/
export const updatePricePreferencesAsArrayStep = createStep(
updatePricePreferencesAsArrayStepId,
async (input: StepInput, { container }) => {
async (input: UpdatePricePreferencesAsArrayStepInput, { container }) => {
const service = container.resolve<IPricingModuleService>(
ModuleRegistrationName.PRICING
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ import {
} from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

type StepInput = PricingWorkflow.UpdatePricePreferencesWorkflowInput

export const updatePricePreferencesStepId = "update-price-preferences"
/**
* This step updates price preferences matching the specified filters.
*/
export const updatePricePreferencesStep = createStep(
updatePricePreferencesStepId,
async (input: StepInput, { container }) => {
async (input: PricingWorkflow.UpdatePricePreferencesWorkflowInput, { container }) => {
const service = container.resolve<IPricingModuleService>(
ModuleRegistrationName.PRICING
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@medusajs/utils"
import { StepResponse, createStep } from "@medusajs/workflows-sdk"

type UpdatePriceSetsStepInput =
export type UpdatePriceSetsStepInput =
| {
selector?: PricingTypes.FilterablePriceSetProps
update?: PricingTypes.UpdatePriceSetDTO
Expand All @@ -16,6 +16,9 @@ type UpdatePriceSetsStepInput =
}

export const updatePriceSetsStepId = "update-price-sets"
/**
* This step updates price sets.
*/
export const updatePriceSetsStep = createStep(
updatePriceSetsStepId,
async (data: UpdatePriceSetsStepInput, { container }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
} from "@medusajs/workflows-sdk"
import { createPricePreferencesStep } from "../steps"

type WorkflowInputData = PricingWorkflow.CreatePricePreferencesWorkflowInput[]

export const createPricePreferencesWorkflowId = "create-price-preferences"
/**
* This workflow creates one or more price preferences.
*/
export const createPricePreferencesWorkflow = createWorkflow(
createPricePreferencesWorkflowId,
(input: WorkflowData<WorkflowInputData>) => {
(input: WorkflowData<PricingWorkflow.CreatePricePreferencesWorkflowInput[]>) => {
return new WorkflowResponse(createPricePreferencesStep(input))
}
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
import { deletePricePreferencesStep } from "../steps"

export const deletePricePreferencesWorkflowId = "delete-price-preferences"
/**
* This workflow deletes one or more price preferences.
*/
export const deletePricePreferencesWorkflow = createWorkflow(
deletePricePreferencesWorkflowId,
(input: WorkflowData<string[]>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
} from "@medusajs/workflows-sdk"
import { updatePricePreferencesStep } from "../steps"

type WorkflowInputData = PricingWorkflow.UpdatePricePreferencesWorkflowInput

export const updatePricePreferencesWorkflowId = "update-price-preferences"
/**
* This workflow updates one or more price preferences.
*/
export const updatePricePreferencesWorkflow = createWorkflow(
updatePricePreferencesWorkflowId,
(input: WorkflowData<WorkflowInputData>) => {
(input: WorkflowData<PricingWorkflow.UpdatePricePreferencesWorkflowInput>) => {
return new WorkflowResponse(updatePricePreferencesStep(input))
}
)

0 comments on commit 9c43c8c

Please sign in to comment.