chore(core-flows): [15] export types and steps, add basic TSDocs (#8525)
This commit is contained in:
@@ -5,11 +5,14 @@ import {
|
||||
import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type CreateProductCategoriesStepInput = {
|
||||
export type CreateProductCategoriesStepInput = {
|
||||
product_categories: CreateProductCategoryDTO[]
|
||||
}
|
||||
|
||||
export const createProductCategoriesStepId = "create-product-categories"
|
||||
/**
|
||||
* This step creates one or more product categories.
|
||||
*/
|
||||
export const createProductCategoriesStep = createStep(
|
||||
createProductCategoriesStepId,
|
||||
async (data: CreateProductCategoriesStepInput, { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteProductCategoriesStepId = "delete-product-categories"
|
||||
/**
|
||||
* This step deletes one or more product categories.
|
||||
*/
|
||||
export const deleteProductCategoriesStep = createStep(
|
||||
deleteProductCategoriesStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -9,12 +9,15 @@ import {
|
||||
} from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
type UpdateProductCategoriesStepInput = {
|
||||
export type UpdateProductCategoriesStepInput = {
|
||||
selector: FilterableProductCategoryProps
|
||||
update: UpdateProductCategoryDTO
|
||||
}
|
||||
|
||||
export const updateProductCategoriesStepId = "update-product-categories"
|
||||
/**
|
||||
* This step updates product categories matching specified filters.
|
||||
*/
|
||||
export const updateProductCategoriesStep = createStep(
|
||||
updateProductCategoriesStepId,
|
||||
async (data: UpdateProductCategoriesStepInput, { container }) => {
|
||||
|
||||
+4
-4
@@ -6,13 +6,13 @@ import {
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { createProductCategoriesStep } from "../steps"
|
||||
|
||||
type WorkflowInputData =
|
||||
ProductCategoryWorkflow.CreateProductCategoriesWorkflowInput
|
||||
|
||||
export const createProductCategoriesWorkflowId = "create-product-categories"
|
||||
/**
|
||||
* This workflow creates one or more product categories.
|
||||
*/
|
||||
export const createProductCategoriesWorkflow = createWorkflow(
|
||||
createProductCategoriesWorkflowId,
|
||||
(input: WorkflowData<WorkflowInputData>) => {
|
||||
(input: WorkflowData<ProductCategoryWorkflow.CreateProductCategoriesWorkflowInput>) => {
|
||||
return new WorkflowResponse(createProductCategoriesStep(input))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -2,6 +2,9 @@ import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { deleteProductCategoriesStep } from "../steps"
|
||||
|
||||
export const deleteProductCategoriesWorkflowId = "delete-product-categories"
|
||||
/**
|
||||
* This workflow deletes one or more product categories.
|
||||
*/
|
||||
export const deleteProductCategoriesWorkflow = createWorkflow(
|
||||
deleteProductCategoriesWorkflowId,
|
||||
(input: WorkflowData<string[]>) => {
|
||||
|
||||
+4
-4
@@ -6,13 +6,13 @@ import {
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { updateProductCategoriesStep } from "../steps"
|
||||
|
||||
type WorkflowInputData =
|
||||
ProductCategoryWorkflow.UpdateProductCategoriesWorkflowInput
|
||||
|
||||
export const updateProductCategoriesWorkflowId = "update-product-categories"
|
||||
/**
|
||||
* This workflow updates product categories matching specified filters.
|
||||
*/
|
||||
export const updateProductCategoriesWorkflow = createWorkflow(
|
||||
updateProductCategoriesWorkflowId,
|
||||
(input: WorkflowData<WorkflowInputData>) => {
|
||||
(input: WorkflowData<ProductCategoryWorkflow.UpdateProductCategoriesWorkflowInput>) => {
|
||||
return new WorkflowResponse(updateProductCategoriesStep(input))
|
||||
}
|
||||
)
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, WorkflowData, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const addCampaignPromotionsStepId = "add-campaign-promotions"
|
||||
/**
|
||||
* This step adds promotions to a campaign.
|
||||
*/
|
||||
export const addCampaignPromotionsStep = createStep(
|
||||
addCampaignPromotionsStepId,
|
||||
async (input: WorkflowData<LinkWorkflowInput>, { container }) => {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { StepResponse, WorkflowData, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const addOrRemoveCampaignPromotionsStepId =
|
||||
"add-or-remove-campaign-promotions"
|
||||
/**
|
||||
* This step adds or removes promotions from a campaign.
|
||||
*/
|
||||
export const addOrRemoveCampaignPromotionsStep = createStep(
|
||||
addOrRemoveCampaignPromotionsStepId,
|
||||
async (input: WorkflowData<LinkWorkflowInput>, { container }) => {
|
||||
|
||||
@@ -6,6 +6,9 @@ import { ModuleRegistrationName, RuleType } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const addRulesToPromotionsStepId = "add-rules-to-promotions"
|
||||
/**
|
||||
* This step adds rules to a promotion.
|
||||
*/
|
||||
export const addRulesToPromotionsStep = createStep(
|
||||
addRulesToPromotionsStepId,
|
||||
async (input: AddPromotionRulesWorkflowDTO, { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createCampaignsStepId = "create-campaigns"
|
||||
/**
|
||||
* This step cancels one or more campaigns.
|
||||
*/
|
||||
export const createCampaignsStep = createStep(
|
||||
createCampaignsStepId,
|
||||
async (data: CreateCampaignDTO[], { container }) => {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { createPromotionRulesWorkflow } from "../workflows/create-promotion-rule
|
||||
|
||||
export const createPromotionRulesWorkflowStepId =
|
||||
"create-promotion-rules-workflow"
|
||||
/**
|
||||
* This step creates promotion rules using the {@link createPromotionRulesWorkflow}.
|
||||
*/
|
||||
export const createPromotionRulesWorkflowStep = createStep(
|
||||
createPromotionRulesWorkflowStepId,
|
||||
async (data: AddPromotionRulesWorkflowDTO, { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const createPromotionsStepId = "create-promotions"
|
||||
/**
|
||||
* This step creates one or more promotions.
|
||||
*/
|
||||
export const createPromotionsStep = createStep(
|
||||
createPromotionsStepId,
|
||||
async (data: CreatePromotionDTO[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deleteCampaignsStepId = "delete-campaigns"
|
||||
/**
|
||||
* This step deletes one or more campaigns.
|
||||
*/
|
||||
export const deleteCampaignsStep = createStep(
|
||||
deleteCampaignsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { deletePromotionRulesWorkflow } from "../workflows/delete-promotion-rule
|
||||
|
||||
export const deletePromotionRulesWorkflowStepId =
|
||||
"delete-promotion-rules-workflow"
|
||||
/**
|
||||
* This step deletes promotion rules using the {@link deletePromotionRulesWorkflow}.
|
||||
*/
|
||||
export const deletePromotionRulesWorkflowStep = createStep(
|
||||
deletePromotionRulesWorkflowStepId,
|
||||
async (data: RemovePromotionRulesWorkflowDTO, { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const deletePromotionsStepId = "delete-promotions"
|
||||
/**
|
||||
* This step deletes one or more promotions.
|
||||
*/
|
||||
export const deletePromotionsStep = createStep(
|
||||
deletePromotionsStepId,
|
||||
async (ids: string[], { container }) => {
|
||||
|
||||
@@ -3,6 +3,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, WorkflowData, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const removeCampaignPromotionsStepId = "remove-campaign-promotions"
|
||||
/**
|
||||
* This step removes promotions from a campaigns.
|
||||
*/
|
||||
export const removeCampaignPromotionsStep = createStep(
|
||||
removeCampaignPromotionsStepId,
|
||||
async (input: WorkflowData<LinkWorkflowInput>, { container }) => {
|
||||
|
||||
@@ -8,6 +8,9 @@ import { ModuleRegistrationName, RuleType } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const removeRulesFromPromotionsStepId = "remove-rules-from-promotions"
|
||||
/**
|
||||
* This step removes rules from a promotion.
|
||||
*/
|
||||
export const removeRulesFromPromotionsStep = createStep(
|
||||
removeRulesFromPromotionsStepId,
|
||||
async (input: RemovePromotionRulesWorkflowDTO, { container }) => {
|
||||
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const updateCampaignsStepId = "update-campaigns"
|
||||
/**
|
||||
* This step updates one or more campaigns.
|
||||
*/
|
||||
export const updateCampaignsStep = createStep(
|
||||
updateCampaignsStepId,
|
||||
async (data: UpdateCampaignDTO[], { container }) => {
|
||||
|
||||
@@ -4,6 +4,9 @@ import { updatePromotionRulesWorkflow } from "../workflows/update-promotion-rule
|
||||
|
||||
export const updatePromotionRulesWorkflowStepId =
|
||||
"update-promotion-rules-workflow"
|
||||
/**
|
||||
* This step updates promotion rules using the {@link updatePromotionRulesWorkflow}.
|
||||
*/
|
||||
export const updatePromotionRulesWorkflowStep = createStep(
|
||||
updatePromotionRulesWorkflowStepId,
|
||||
async (data: UpdatePromotionRulesWorkflowDTO, { container }) => {
|
||||
|
||||
@@ -6,6 +6,9 @@ import { ModuleRegistrationName } from "@medusajs/utils"
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const updatePromotionRulesStepId = "update-promotion-rules"
|
||||
/**
|
||||
* This step updates one or more promotion rules.
|
||||
*/
|
||||
export const updatePromotionRulesStep = createStep(
|
||||
updatePromotionRulesStepId,
|
||||
async (input: UpdatePromotionRulesWorkflowDTO, { container }) => {
|
||||
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
import { StepResponse, createStep } from "@medusajs/workflows-sdk"
|
||||
|
||||
export const updatePromotionsStepId = "update-promotions"
|
||||
/**
|
||||
* This step updates one or more promotions.
|
||||
*/
|
||||
export const updatePromotionsStep = createStep(
|
||||
updatePromotionsStepId,
|
||||
async (data: UpdatePromotionDTO[], { container }) => {
|
||||
|
||||
@@ -11,6 +11,9 @@ import {
|
||||
|
||||
export const addOrRemoveCampaignPromotionsWorkflowId =
|
||||
"add-or-remove-campaign-promotions"
|
||||
/**
|
||||
* This workflow adds or removes promotions from campaigns.
|
||||
*/
|
||||
export const addOrRemoveCampaignPromotionsWorkflow = createWorkflow(
|
||||
addOrRemoveCampaignPromotionsWorkflowId,
|
||||
(input: WorkflowData<LinkWorkflowInput>): WorkflowData<void> => {
|
||||
|
||||
@@ -18,6 +18,9 @@ import { updatePromotionRulesWorkflowStep } from "../steps/update-promotion-rule
|
||||
import { deletePromotionRulesWorkflowStep } from "../steps/delete-promotion-rules-workflow"
|
||||
|
||||
export const batchPromotionRulesWorkflowId = "batch-promotion-rules"
|
||||
/**
|
||||
* This workflow creates, updates, or deletes promotion rules.
|
||||
*/
|
||||
export const batchPromotionRulesWorkflow = createWorkflow(
|
||||
batchPromotionRulesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -7,12 +7,15 @@ import {
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { createCampaignsStep } from "../steps"
|
||||
|
||||
type WorkflowInput = { campaignsData: CreateCampaignDTO[] } & AdditionalData
|
||||
export type CreateCampaignsWorkflowInput = { campaignsData: CreateCampaignDTO[] } & AdditionalData
|
||||
|
||||
export const createCampaignsWorkflowId = "create-campaigns"
|
||||
/**
|
||||
* This workflow creates one or more campaigns.
|
||||
*/
|
||||
export const createCampaignsWorkflow = createWorkflow(
|
||||
createCampaignsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>) => {
|
||||
(input: WorkflowData<CreateCampaignsWorkflowInput>) => {
|
||||
const createdCampaigns = createCampaignsStep(input.campaignsData)
|
||||
const campaignsCreated = createHook("campaignsCreated", {
|
||||
campaigns: createdCampaigns,
|
||||
|
||||
@@ -7,6 +7,9 @@ import {
|
||||
import { addRulesToPromotionsStep } from "../steps"
|
||||
|
||||
export const createPromotionRulesWorkflowId = "create-promotion-rules-workflow"
|
||||
/**
|
||||
* This workflow creates one or more promotion rules.
|
||||
*/
|
||||
export const createPromotionRulesWorkflow = createWorkflow(
|
||||
createPromotionRulesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -7,12 +7,15 @@ import {
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { createPromotionsStep } from "../steps"
|
||||
|
||||
type WorkflowInput = { promotionsData: CreatePromotionDTO[] } & AdditionalData
|
||||
export type CreatePromotionsWorkflowInput = { promotionsData: CreatePromotionDTO[] } & AdditionalData
|
||||
|
||||
export const createPromotionsWorkflowId = "create-promotions"
|
||||
/**
|
||||
* This workflow creates one or more promotions.
|
||||
*/
|
||||
export const createPromotionsWorkflow = createWorkflow(
|
||||
createPromotionsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>) => {
|
||||
(input: WorkflowData<CreatePromotionsWorkflowInput>) => {
|
||||
const createdPromotions = createPromotionsStep(input.promotionsData)
|
||||
const promotionsCreated = createHook("promotionsCreated", {
|
||||
promotions: createdPromotions,
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { createHook, createWorkflow, WorkflowData, WorkflowResponse } from "@medusajs/workflows-sdk"
|
||||
import { deleteCampaignsStep } from "../steps"
|
||||
|
||||
type WorkflowInput = { ids: string[] }
|
||||
export type DeleteCampaignsWorkflowInput = { ids: string[] }
|
||||
|
||||
export const deleteCampaignsWorkflowId = "delete-campaigns"
|
||||
/**
|
||||
* This workflow deletes one or more campaigns.
|
||||
*/
|
||||
export const deleteCampaignsWorkflow = createWorkflow(
|
||||
deleteCampaignsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>) => {
|
||||
(input: WorkflowData<DeleteCampaignsWorkflowInput>) => {
|
||||
const deletedCampaigns = deleteCampaignsStep(input.ids)
|
||||
const campaignsDeleted = createHook("campaignsDeleted", {
|
||||
ids: input.ids
|
||||
|
||||
@@ -3,6 +3,9 @@ import { WorkflowData, createWorkflow } from "@medusajs/workflows-sdk"
|
||||
import { removeRulesFromPromotionsStep } from "../steps"
|
||||
|
||||
export const deletePromotionRulesWorkflowId = "delete-promotion-rules-workflow"
|
||||
/**
|
||||
* This workflow deletes one or more promotion rules.
|
||||
*/
|
||||
export const deletePromotionRulesWorkflow = createWorkflow(
|
||||
deletePromotionRulesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { createHook, createWorkflow, WorkflowData, WorkflowResponse } from "@medusajs/workflows-sdk"
|
||||
import { deletePromotionsStep } from "../steps"
|
||||
|
||||
type WorkflowInput = { ids: string[] }
|
||||
export type DeletePromotionsWorkflowInput = { ids: string[] }
|
||||
|
||||
export const deletePromotionsWorkflowId = "delete-promotions"
|
||||
/**
|
||||
* This workflow deletes one or more promotions.
|
||||
*/
|
||||
export const deletePromotionsWorkflow = createWorkflow(
|
||||
deletePromotionsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>) => {
|
||||
(input: WorkflowData<DeletePromotionsWorkflowInput>) => {
|
||||
const deletedPromotions = deletePromotionsStep(input.ids)
|
||||
const promotionsDeleted = createHook("promotionsDeleted", {
|
||||
ids: input.ids
|
||||
|
||||
@@ -7,12 +7,15 @@ import {
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { updateCampaignsStep } from "../steps"
|
||||
|
||||
type WorkflowInput = { campaignsData: UpdateCampaignDTO[] } & AdditionalData
|
||||
export type UpdateCampaignsWorkflowInput = { campaignsData: UpdateCampaignDTO[] } & AdditionalData
|
||||
|
||||
export const updateCampaignsWorkflowId = "update-campaigns"
|
||||
/**
|
||||
* This workflow updates one or more campaigns.
|
||||
*/
|
||||
export const updateCampaignsWorkflow = createWorkflow(
|
||||
updateCampaignsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>) => {
|
||||
(input: WorkflowData<UpdateCampaignsWorkflowInput>) => {
|
||||
const updatedCampaigns = updateCampaignsStep(input.campaignsData)
|
||||
const campaignsUpdated = createHook("campaignsUpdated", {
|
||||
campaigns: updatedCampaigns,
|
||||
|
||||
@@ -10,6 +10,9 @@ import {
|
||||
import { updatePromotionRulesStep } from "../steps"
|
||||
|
||||
export const updatePromotionRulesWorkflowId = "update-promotion-rules-workflow"
|
||||
/**
|
||||
* This workflow updates one or more promotion rules.
|
||||
*/
|
||||
export const updatePromotionRulesWorkflow = createWorkflow(
|
||||
updatePromotionRulesWorkflowId,
|
||||
(
|
||||
|
||||
@@ -10,12 +10,15 @@ import {
|
||||
} from "@medusajs/workflows-sdk"
|
||||
import { updatePromotionsStep } from "../steps"
|
||||
|
||||
type WorkflowInput = { promotionsData: UpdatePromotionDTO[] } & AdditionalData
|
||||
export type UpdatePromotionsWorkflowInput = { promotionsData: UpdatePromotionDTO[] } & AdditionalData
|
||||
|
||||
export const updatePromotionsWorkflowId = "update-promotions"
|
||||
/**
|
||||
* This workflow updates one or more promotions.
|
||||
*/
|
||||
export const updatePromotionsWorkflow = createWorkflow(
|
||||
updatePromotionsWorkflowId,
|
||||
(input: WorkflowData<WorkflowInput>) => {
|
||||
(input: WorkflowData<UpdatePromotionsWorkflowInput>) => {
|
||||
const updatedPromotions = updatePromotionsStep(input.promotionsData)
|
||||
const promotionsUpdated = createHook("promotionsUpdated", {
|
||||
promotions: updatedPromotions,
|
||||
|
||||
Reference in New Issue
Block a user