chore(core-flows): [12] export types and types, add basic TSDocs (#8522)

This commit is contained in:
Shahed Nasser
2024-08-08 20:02:42 +03:00
committed by GitHub
parent 4c2d605599
commit 288ed2747b
21 changed files with 71 additions and 16 deletions
@@ -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 }) => {
@@ -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 }) => {
@@ -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 }) => {
@@ -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 }) => {
@@ -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 }) => {
@@ -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 }) => {
@@ -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 }) => {
@@ -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 }) => {
@@ -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 }) => {
@@ -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 }) => {
@@ -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 }) => {
@@ -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 (
@@ -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
)
@@ -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 }) => {
@@ -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 }) => {
@@ -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
)
@@ -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
)
@@ -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
@@ -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 }) => {
@@ -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))
}
)
@@ -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[]>) => {
@@ -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))
}
)