From 9c43c8c5abf6312e62406c868df793f51a6247be Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 8 Aug 2024 18:39:36 +0300 Subject: [PATCH] chore(core-flows): [12] export types and types, add basic TSDocs --- .../price-list/steps/create-price-list-prices-workflow.ts | 3 +++ .../src/price-list/steps/create-price-list-prices.ts | 3 +++ .../core-flows/src/price-list/steps/create-price-lists.ts | 3 +++ .../core-flows/src/price-list/steps/delete-price-lists.ts | 5 ++++- .../price-list/steps/get-existing-price-lists-price-ids.ts | 3 +++ .../price-list/steps/remove-price-list-prices-workflow.ts | 3 +++ .../src/price-list/steps/remove-price-list-prices.ts | 3 +++ .../price-list/steps/update-price-list-prices-workflow.ts | 3 +++ .../src/price-list/steps/update-price-list-prices.ts | 3 +++ .../core-flows/src/price-list/steps/update-price-lists.ts | 3 +++ .../src/price-list/steps/validate-price-lists.ts | 3 +++ .../src/price-list/steps/validate-variant-price-links.ts | 3 +++ .../src/pricing/steps/create-price-preferences.ts | 7 ++++--- .../core/core-flows/src/pricing/steps/create-price-sets.ts | 3 +++ .../src/pricing/steps/delete-price-preferences.ts | 3 +++ .../src/pricing/steps/update-price-preferences-as-array.ts | 7 +++++-- .../src/pricing/steps/update-price-preferences.ts | 7 ++++--- .../core/core-flows/src/pricing/steps/update-price-sets.ts | 5 ++++- .../src/pricing/workflows/create-price-preferences.ts | 7 ++++--- .../src/pricing/workflows/delete-price-preferences.ts | 3 +++ .../src/pricing/workflows/update-price-preferences.ts | 7 ++++--- 21 files changed, 71 insertions(+), 16 deletions(-) diff --git a/packages/core/core-flows/src/price-list/steps/create-price-list-prices-workflow.ts b/packages/core/core-flows/src/price-list/steps/create-price-list-prices-workflow.ts index 7d9142b541e57..cba216211381f 100644 --- a/packages/core/core-flows/src/price-list/steps/create-price-list-prices-workflow.ts +++ b/packages/core/core-flows/src/price-list/steps/create-price-list-prices-workflow.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/create-price-list-prices.ts b/packages/core/core-flows/src/price-list/steps/create-price-list-prices.ts index c3f3bf5fd42fe..9796208e0650c 100644 --- a/packages/core/core-flows/src/price-list/steps/create-price-list-prices.ts +++ b/packages/core/core-flows/src/price-list/steps/create-price-list-prices.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/create-price-lists.ts b/packages/core/core-flows/src/price-list/steps/create-price-lists.ts index fd6f03f5d173a..462017faaf4ce 100644 --- a/packages/core/core-flows/src/price-list/steps/create-price-lists.ts +++ b/packages/core/core-flows/src/price-list/steps/create-price-lists.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/delete-price-lists.ts b/packages/core/core-flows/src/price-list/steps/delete-price-lists.ts index d7ba2138f736a..50ff54cda9fa8 100644 --- a/packages/core/core-flows/src/price-list/steps/delete-price-lists.ts +++ b/packages/core/core-flows/src/price-list/steps/delete-price-lists.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/get-existing-price-lists-price-ids.ts b/packages/core/core-flows/src/price-list/steps/get-existing-price-lists-price-ids.ts index 98913cbee71fd..b9ac8a9088946 100644 --- a/packages/core/core-flows/src/price-list/steps/get-existing-price-lists-price-ids.ts +++ b/packages/core/core-flows/src/price-list/steps/get-existing-price-lists-price-ids.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/remove-price-list-prices-workflow.ts b/packages/core/core-flows/src/price-list/steps/remove-price-list-prices-workflow.ts index e6c2e275c8bd5..af8618862f8d3 100644 --- a/packages/core/core-flows/src/price-list/steps/remove-price-list-prices-workflow.ts +++ b/packages/core/core-flows/src/price-list/steps/remove-price-list-prices-workflow.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/remove-price-list-prices.ts b/packages/core/core-flows/src/price-list/steps/remove-price-list-prices.ts index 5f80cdf7a2660..2eb36880f4c68 100644 --- a/packages/core/core-flows/src/price-list/steps/remove-price-list-prices.ts +++ b/packages/core/core-flows/src/price-list/steps/remove-price-list-prices.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/update-price-list-prices-workflow.ts b/packages/core/core-flows/src/price-list/steps/update-price-list-prices-workflow.ts index ef76d654a7335..f87beb172b764 100644 --- a/packages/core/core-flows/src/price-list/steps/update-price-list-prices-workflow.ts +++ b/packages/core/core-flows/src/price-list/steps/update-price-list-prices-workflow.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/update-price-list-prices.ts b/packages/core/core-flows/src/price-list/steps/update-price-list-prices.ts index 92999ab80fee0..c75b19b7d73d2 100644 --- a/packages/core/core-flows/src/price-list/steps/update-price-list-prices.ts +++ b/packages/core/core-flows/src/price-list/steps/update-price-list-prices.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/update-price-lists.ts b/packages/core/core-flows/src/price-list/steps/update-price-lists.ts index 192f23cbe6841..94c3b0cb1de7c 100644 --- a/packages/core/core-flows/src/price-list/steps/update-price-lists.ts +++ b/packages/core/core-flows/src/price-list/steps/update-price-lists.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/price-list/steps/validate-price-lists.ts b/packages/core/core-flows/src/price-list/steps/validate-price-lists.ts index b38c02b2aad08..e13a3cf93ab52 100644 --- a/packages/core/core-flows/src/price-list/steps/validate-price-lists.ts +++ b/packages/core/core-flows/src/price-list/steps/validate-price-lists.ts @@ -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[], { container }) => { diff --git a/packages/core/core-flows/src/price-list/steps/validate-variant-price-links.ts b/packages/core/core-flows/src/price-list/steps/validate-variant-price-links.ts index 4e585ff40211f..7e2bf99e1ed55 100644 --- a/packages/core/core-flows/src/price-list/steps/validate-variant-price-links.ts +++ b/packages/core/core-flows/src/price-list/steps/validate-variant-price-links.ts @@ -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 ( diff --git a/packages/core/core-flows/src/pricing/steps/create-price-preferences.ts b/packages/core/core-flows/src/pricing/steps/create-price-preferences.ts index 4c3ed46082f68..806d32e61fb23 100644 --- a/packages/core/core-flows/src/pricing/steps/create-price-preferences.ts +++ b/packages/core/core-flows/src/pricing/steps/create-price-preferences.ts @@ -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( ModuleRegistrationName.PRICING ) diff --git a/packages/core/core-flows/src/pricing/steps/create-price-sets.ts b/packages/core/core-flows/src/pricing/steps/create-price-sets.ts index ac46ff99defda..0e134b8cdf38c 100644 --- a/packages/core/core-flows/src/pricing/steps/create-price-sets.ts +++ b/packages/core/core-flows/src/pricing/steps/create-price-sets.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/pricing/steps/delete-price-preferences.ts b/packages/core/core-flows/src/pricing/steps/delete-price-preferences.ts index b625ea95f25af..2b1d20e04d283 100644 --- a/packages/core/core-flows/src/pricing/steps/delete-price-preferences.ts +++ b/packages/core/core-flows/src/pricing/steps/delete-price-preferences.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/pricing/steps/update-price-preferences-as-array.ts b/packages/core/core-flows/src/pricing/steps/update-price-preferences-as-array.ts index 154a758dc0c06..0b73e026a5a4f 100644 --- a/packages/core/core-flows/src/pricing/steps/update-price-preferences-as-array.ts +++ b/packages/core/core-flows/src/pricing/steps/update-price-preferences-as-array.ts @@ -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( ModuleRegistrationName.PRICING ) diff --git a/packages/core/core-flows/src/pricing/steps/update-price-preferences.ts b/packages/core/core-flows/src/pricing/steps/update-price-preferences.ts index f7427d81eb681..a8369c8316610 100644 --- a/packages/core/core-flows/src/pricing/steps/update-price-preferences.ts +++ b/packages/core/core-flows/src/pricing/steps/update-price-preferences.ts @@ -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( ModuleRegistrationName.PRICING ) diff --git a/packages/core/core-flows/src/pricing/steps/update-price-sets.ts b/packages/core/core-flows/src/pricing/steps/update-price-sets.ts index 47f272919e436..86b9ed57f1a29 100644 --- a/packages/core/core-flows/src/pricing/steps/update-price-sets.ts +++ b/packages/core/core-flows/src/pricing/steps/update-price-sets.ts @@ -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 }) => { diff --git a/packages/core/core-flows/src/pricing/workflows/create-price-preferences.ts b/packages/core/core-flows/src/pricing/workflows/create-price-preferences.ts index c19d51102f965..95e0057314c2c 100644 --- a/packages/core/core-flows/src/pricing/workflows/create-price-preferences.ts +++ b/packages/core/core-flows/src/pricing/workflows/create-price-preferences.ts @@ -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) => { + (input: WorkflowData) => { return new WorkflowResponse(createPricePreferencesStep(input)) } ) diff --git a/packages/core/core-flows/src/pricing/workflows/delete-price-preferences.ts b/packages/core/core-flows/src/pricing/workflows/delete-price-preferences.ts index fcdb54661a212..f0d13a1b94865 100644 --- a/packages/core/core-flows/src/pricing/workflows/delete-price-preferences.ts +++ b/packages/core/core-flows/src/pricing/workflows/delete-price-preferences.ts @@ -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) => { diff --git a/packages/core/core-flows/src/pricing/workflows/update-price-preferences.ts b/packages/core/core-flows/src/pricing/workflows/update-price-preferences.ts index dbb2f1d9c0f28..86be0b58939f6 100644 --- a/packages/core/core-flows/src/pricing/workflows/update-price-preferences.ts +++ b/packages/core/core-flows/src/pricing/workflows/update-price-preferences.ts @@ -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) => { + (input: WorkflowData) => { return new WorkflowResponse(updatePricePreferencesStep(input)) } )