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
CreateConfigurationRuleDTO
required
The configuration rule to create. rule_type
ConfigurationRuleType
required
The type of the configuration rule. Available types:
global_product_catalog - Controls global product catalog access
require_product_approval - Requires admin approval for new products
product_request_enabled - Enables sellers to submit product requests
product_import_enabled - Enables product import functionality
Whether the configuration rule is enabled.
Output
The created configuration rule. The ID of the configuration rule.
The type of the configuration rule.
Whether the rule is enabled.
The date the rule was created.
The date the rule was last updated.
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
UpdateConfigurationRuleDTO
required
The configuration rule updates. The ID of the configuration rule to update.
Whether the configuration rule should be enabled.
Output
The updated configuration rule. The ID of the configuration rule.
The type of the configuration rule.
Whether the rule is enabled.
The date the rule was created.
The date the rule was last updated.
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
CreateConfigurationRuleDTO
required
The configuration rule to create.
Output
The created configuration rule.
updateConfigurationRuleStep
Updates an existing configuration rule.
Source code
input
UpdateConfigurationRuleDTO
required
The configuration rule updates.
Output
The updated configuration rule.