Skip to main content

Workflows

createConfigurationRuleWorkflow

This documentation provides a reference to the createConfigurationRuleWorkflow. It belongs to the @mercurjs/b2c-core package. This workflow creates a configuration rule that controls marketplace settings such as product approval requirements, product request enablement, and product import functionality. Source code

Examples

packages/modules/b2c-core/src/api/admin/configuration/route.ts
import { MedusaRequest, MedusaResponse } from '@medusajs/framework'
import { createConfigurationRuleWorkflow } from '../../../workflows/configuration/workflows'
import { AdminCreateRuleType } from './validators'

export const POST = async (
  req: MedusaRequest<AdminCreateRuleType>,
  res: MedusaResponse
) => {
  const { result: configuration_rule } =
    await createConfigurationRuleWorkflow.run({
      container: req.scope,
      input: req.validatedBody
    })

  res.status(201).json({ configuration_rule })
}

Steps

Input

input
CreateConfigurationRuleDTO
required
The configuration rule to create.

Output

ConfigurationRuleDTO
ConfigurationRuleDTO
The created configuration rule.

updateConfigurationRuleWorkflow

This documentation provides a reference to the updateConfigurationRuleWorkflow. It belongs to the @mercurjs/b2c-core package. This workflow updates an existing configuration rule, allowing administrators to enable or disable marketplace features. Source code

Examples

packages/modules/b2c-core/src/api/admin/configuration/[id]/route.ts
import { MedusaRequest, MedusaResponse } from '@medusajs/framework'
import { updateConfigurationRuleWorkflow } from '../../../../workflows/configuration/workflows'
import { AdminUpdateRuleType } from '../validators'

export const POST = async (
  req: MedusaRequest<AdminUpdateRuleType>,
  res: MedusaResponse
) => {
  const { result: configuration_rule } =
    await updateConfigurationRuleWorkflow.run({
      container: req.scope,
      input: { ...req.validatedBody, id: req.params.id }
    })

  res.json({ configuration_rule })
}

Steps

Input

input
UpdateConfigurationRuleDTO
required
The configuration rule updates.

Output

ConfigurationRuleDTO
ConfigurationRuleDTO
The updated configuration rule.

Steps

createConfigurationRuleStep

Creates a configuration rule. If an error occurs after creation, the step’s compensation function automatically deletes the created rule. Source code

Input

input
CreateConfigurationRuleDTO
required
The configuration rule to create.

Output

ConfigurationRuleDTO
ConfigurationRuleDTO
The created configuration rule.

updateConfigurationRuleStep

Updates an existing configuration rule. Source code

Input

input
UpdateConfigurationRuleDTO
required
The configuration rule updates.

Output

ConfigurationRuleDTO
ConfigurationRuleDTO
The updated configuration rule.