Skip to main content
Creates one or more ProductChange records — the staging entity for vendor edits on shared master products. Validates that none of the referenced products already has a pending change before inserting. Emits product-change.created with one { id } entry per change. Actions are attached separately (see stageProductChangeWorkflow for the combined flow).

Usage

import { createProductChangeWorkflow } from "@mercurjs/core/workflows"

const { result } = await createProductChangeWorkflow(container).run({
  input: {
    changes: [
      { product_id: "prod_01H...", created_by: "sel_01H..." },
    ],
  },
})

Input

changes
CreateProductChangeDTO[]
required
Changes to create.
additional_data
object
Arbitrary data forwarded to the productChangeCreated hook.

Result

result
ProductChangeDTO[]
The created change records with ids, statuses, and timestamps.

Hooks

validate
hook
Runs first with { input } — use it to reject invalid payloads before creation.
productChangeCreated
hook
Runs after creation with { changes, additional_data }.