@mercurjs/docs 2.2.0-canary.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/content/blocks.mdx +209 -0
- package/content/learn/architecture.mdx +215 -0
- package/content/learn/attributes.mdx +89 -0
- package/content/learn/blocks.mdx +99 -0
- package/content/learn/commissions.mdx +175 -0
- package/content/learn/concepts.mdx +84 -0
- package/content/learn/installation.mdx +117 -0
- package/content/learn/introduction.mdx +71 -0
- package/content/learn/offers.mdx +78 -0
- package/content/learn/order-groups.mdx +114 -0
- package/content/learn/payouts.mdx +175 -0
- package/content/learn/product-requests.mdx +82 -0
- package/content/learn/products.mdx +79 -0
- package/content/learn/registry.mdx +155 -0
- package/content/learn/seller-members.mdx +62 -0
- package/content/learn/sellers.mdx +118 -0
- package/content/migration/from-1-x-to-2-0.mdx +152 -0
- package/content/migration/from-2-0-to-2-1.mdx +105 -0
- package/content/migration/overview.mdx +58 -0
- package/content/references/api/admin/commission-rates/batch-commission-rules.mdx +70 -0
- package/content/references/api/admin/commission-rates/create-commission-rate.mdx +95 -0
- package/content/references/api/admin/commission-rates/delete-commission-rate.mdx +40 -0
- package/content/references/api/admin/commission-rates/list-commission-rates.mdx +92 -0
- package/content/references/api/admin/commission-rates/retrieve-commission-rate.mdx +70 -0
- package/content/references/api/admin/commission-rates/update-commission-rate.mdx +84 -0
- package/content/references/api/admin/members/list-members.mdx +61 -0
- package/content/references/api/admin/offers/batch-create-offers.mdx +130 -0
- package/content/references/api/admin/offers/delete-offer.mdx +40 -0
- package/content/references/api/admin/offers/list-offers.mdx +106 -0
- package/content/references/api/admin/offers/retrieve-offer.mdx +82 -0
- package/content/references/api/admin/order-groups/list-order-groups.mdx +77 -0
- package/content/references/api/admin/order-groups/retrieve-order-group.mdx +56 -0
- package/content/references/api/admin/orders/get-order-commission-lines.mdx +65 -0
- package/content/references/api/admin/orders/get-order-order-group.mdx +56 -0
- package/content/references/api/admin/orders/list-orders.mdx +79 -0
- package/content/references/api/admin/payouts/list-payouts.mdx +75 -0
- package/content/references/api/admin/payouts/retrieve-payout.mdx +62 -0
- package/content/references/api/admin/product-attributes/create-attribute-value.mdx +76 -0
- package/content/references/api/admin/product-attributes/create-product-attribute.mdx +99 -0
- package/content/references/api/admin/product-attributes/delete-attribute-value.mdx +52 -0
- package/content/references/api/admin/product-attributes/delete-product-attribute.mdx +40 -0
- package/content/references/api/admin/product-attributes/list-product-attributes.mdx +91 -0
- package/content/references/api/admin/product-attributes/retrieve-product-attribute.mdx +81 -0
- package/content/references/api/admin/product-attributes/update-attribute-value.mdx +66 -0
- package/content/references/api/admin/product-attributes/update-product-attribute.mdx +76 -0
- package/content/references/api/admin/product-changes/cancel-product-change.mdx +68 -0
- package/content/references/api/admin/product-changes/confirm-product-change.mdx +47 -0
- package/content/references/api/admin/products/batch-product-attributes.mdx +96 -0
- package/content/references/api/admin/products/confirm-product.mdx +59 -0
- package/content/references/api/admin/products/create-product-variant.mdx +78 -0
- package/content/references/api/admin/products/create-product.mdx +169 -0
- package/content/references/api/admin/products/delete-product-variant.mdx +48 -0
- package/content/references/api/admin/products/delete-product.mdx +40 -0
- package/content/references/api/admin/products/list-product-variants.mdx +91 -0
- package/content/references/api/admin/products/list-products.mdx +109 -0
- package/content/references/api/admin/products/preview-product.mdx +78 -0
- package/content/references/api/admin/products/reject-product.mdx +59 -0
- package/content/references/api/admin/products/request-product-changes.mdx +59 -0
- package/content/references/api/admin/products/retrieve-product-variant.mdx +73 -0
- package/content/references/api/admin/products/retrieve-product.mdx +96 -0
- package/content/references/api/admin/products/set-product-sellers.mdx +47 -0
- package/content/references/api/admin/products/update-product-variant.mdx +89 -0
- package/content/references/api/admin/products/update-product.mdx +133 -0
- package/content/references/api/admin/sellers/add-seller-member.mdx +63 -0
- package/content/references/api/admin/sellers/approve-seller.mdx +54 -0
- package/content/references/api/admin/sellers/create-seller.mdx +100 -0
- package/content/references/api/admin/sellers/delete-member-invite.mdx +42 -0
- package/content/references/api/admin/sellers/delete-professional-details.mdx +52 -0
- package/content/references/api/admin/sellers/invite-seller-member.mdx +63 -0
- package/content/references/api/admin/sellers/list-member-invites.mdx +71 -0
- package/content/references/api/admin/sellers/list-seller-members.mdx +71 -0
- package/content/references/api/admin/sellers/list-seller-products.mdx +85 -0
- package/content/references/api/admin/sellers/list-sellers.mdx +96 -0
- package/content/references/api/admin/sellers/remove-seller-member.mdx +42 -0
- package/content/references/api/admin/sellers/resend-member-invite.mdx +55 -0
- package/content/references/api/admin/sellers/retrieve-seller.mdx +81 -0
- package/content/references/api/admin/sellers/suspend-seller.mdx +60 -0
- package/content/references/api/admin/sellers/terminate-seller.mdx +60 -0
- package/content/references/api/admin/sellers/unsuspend-seller.mdx +52 -0
- package/content/references/api/admin/sellers/unterminate-seller.mdx +52 -0
- package/content/references/api/admin/sellers/update-seller.mdx +83 -0
- package/content/references/api/admin/sellers/upsert-payment-details.mdx +88 -0
- package/content/references/api/admin/sellers/upsert-professional-details.mdx +78 -0
- package/content/references/api/admin/sellers/upsert-seller-address.mdx +91 -0
- package/content/references/api/admin.mdx +134 -0
- package/content/references/api/conventions.mdx +109 -0
- package/content/references/api/store/carts/add-line-item.mdx +115 -0
- package/content/references/api/store/carts/add-shipping-methods.mdx +84 -0
- package/content/references/api/store/carts/apply-promotions.mdx +83 -0
- package/content/references/api/store/carts/complete-cart.mdx +98 -0
- package/content/references/api/store/offers/list-offers.mdx +161 -0
- package/content/references/api/store/offers/retrieve-offer.mdx +112 -0
- package/content/references/api/store/order-groups/list-order-groups.mdx +105 -0
- package/content/references/api/store/order-groups/retrieve-order-group.mdx +78 -0
- package/content/references/api/store/product-attributes/list-product-attributes.mdx +134 -0
- package/content/references/api/store/product-attributes/retrieve-product-attribute.mdx +78 -0
- package/content/references/api/store/product-categories/list-product-categories.mdx +126 -0
- package/content/references/api/store/product-categories/retrieve-product-category.mdx +79 -0
- package/content/references/api/store/products/list-products.mdx +184 -0
- package/content/references/api/store/products/retrieve-product.mdx +107 -0
- package/content/references/api/store/search/search.mdx +136 -0
- package/content/references/api/store/sellers/list-sellers.mdx +105 -0
- package/content/references/api/store/sellers/retrieve-seller.mdx +62 -0
- package/content/references/api/store/shipping-options/list-shipping-options.mdx +74 -0
- package/content/references/api/store.mdx +67 -0
- package/content/references/api/vendor/members/accept-member-invite.mdx +65 -0
- package/content/references/api/vendor/members/retrieve-current-member.mdx +51 -0
- package/content/references/api/vendor/members/update-current-member.mdx +70 -0
- package/content/references/api/vendor/offers/batch-create-offers.mdx +123 -0
- package/content/references/api/vendor/offers/batch-offer-inventory-items.mdx +103 -0
- package/content/references/api/vendor/offers/create-offer.mdx +141 -0
- package/content/references/api/vendor/offers/delete-offer.mdx +51 -0
- package/content/references/api/vendor/offers/list-offers.mdx +125 -0
- package/content/references/api/vendor/offers/retrieve-offer.mdx +74 -0
- package/content/references/api/vendor/offers/update-offer.mdx +82 -0
- package/content/references/api/vendor/orders/cancel-fulfillment.mdx +63 -0
- package/content/references/api/vendor/orders/cancel-order.mdx +56 -0
- package/content/references/api/vendor/orders/complete-order.mdx +55 -0
- package/content/references/api/vendor/orders/create-fulfillment.mdx +76 -0
- package/content/references/api/vendor/orders/create-shipment.mdx +99 -0
- package/content/references/api/vendor/orders/get-order-commission-lines.mdx +66 -0
- package/content/references/api/vendor/orders/list-order-changes.mdx +75 -0
- package/content/references/api/vendor/orders/list-orders.mdx +103 -0
- package/content/references/api/vendor/orders/mark-fulfillment-delivered.mdx +62 -0
- package/content/references/api/vendor/orders/preview-order.mdx +65 -0
- package/content/references/api/vendor/orders/retrieve-order.mdx +84 -0
- package/content/references/api/vendor/payout-accounts/create-onboarding.mdx +68 -0
- package/content/references/api/vendor/payout-accounts/create-payout-account.mdx +59 -0
- package/content/references/api/vendor/payout-accounts/retrieve-payout-account-by-id.mdx +60 -0
- package/content/references/api/vendor/payout-accounts/retrieve-payout-account.mdx +77 -0
- package/content/references/api/vendor/payouts/list-payouts.mdx +90 -0
- package/content/references/api/vendor/payouts/retrieve-payout.mdx +63 -0
- package/content/references/api/vendor/product-attributes/list-product-attributes.mdx +135 -0
- package/content/references/api/vendor/product-attributes/retrieve-product-attribute.mdx +71 -0
- package/content/references/api/vendor/product-variants/list-variants.mdx +136 -0
- package/content/references/api/vendor/products/batch-product-attributes.mdx +104 -0
- package/content/references/api/vendor/products/cancel-product-change.mdx +62 -0
- package/content/references/api/vendor/products/create-product-variant.mdx +92 -0
- package/content/references/api/vendor/products/create-product.mdx +197 -0
- package/content/references/api/vendor/products/delete-product-variant.mdx +68 -0
- package/content/references/api/vendor/products/delete-product.mdx +62 -0
- package/content/references/api/vendor/products/list-product-variants.mdx +114 -0
- package/content/references/api/vendor/products/list-products.mdx +163 -0
- package/content/references/api/vendor/products/preview-product.mdx +61 -0
- package/content/references/api/vendor/products/retrieve-product-variant.mdx +76 -0
- package/content/references/api/vendor/products/retrieve-product.mdx +69 -0
- package/content/references/api/vendor/products/update-product-variant.mdx +104 -0
- package/content/references/api/vendor/products/update-product.mdx +148 -0
- package/content/references/api/vendor/sellers/create-seller.mdx +150 -0
- package/content/references/api/vendor/sellers/delete-professional-details.mdx +54 -0
- package/content/references/api/vendor/sellers/invite-seller-member.mdx +67 -0
- package/content/references/api/vendor/sellers/list-member-invites.mdx +82 -0
- package/content/references/api/vendor/sellers/list-seller-members.mdx +80 -0
- package/content/references/api/vendor/sellers/list-sellers.mdx +71 -0
- package/content/references/api/vendor/sellers/remove-seller-member.mdx +48 -0
- package/content/references/api/vendor/sellers/retrieve-current-seller-member.mdx +59 -0
- package/content/references/api/vendor/sellers/retrieve-current-seller.mdx +69 -0
- package/content/references/api/vendor/sellers/select-seller.mdx +44 -0
- package/content/references/api/vendor/sellers/update-current-seller.mdx +108 -0
- package/content/references/api/vendor/sellers/update-member-role.mdx +51 -0
- package/content/references/api/vendor/sellers/upsert-payment-details.mdx +74 -0
- package/content/references/api/vendor/sellers/upsert-professional-details.mdx +70 -0
- package/content/references/api/vendor/sellers/upsert-seller-address.mdx +81 -0
- package/content/references/api/vendor.mdx +150 -0
- package/content/references/configuration.mdx +155 -0
- package/content/references/modules/commission.mdx +106 -0
- package/content/references/modules/custom-fields.mdx +45 -0
- package/content/references/modules/media.mdx +55 -0
- package/content/references/modules/offer.mdx +64 -0
- package/content/references/modules/payout.mdx +121 -0
- package/content/references/modules/product-attribute.mdx +111 -0
- package/content/references/modules/product-edit.mdx +80 -0
- package/content/references/modules/search.mdx +112 -0
- package/content/references/modules/seller.mdx +175 -0
- package/content/references/overview.mdx +70 -0
- package/content/references/workflows/cart/add-seller-shipping-method-to-cart.mdx +44 -0
- package/content/references/workflows/cart/complete-cart-with-split-orders.mdx +36 -0
- package/content/references/workflows/cart/list-seller-shipping-options-for-cart.mdx +39 -0
- package/content/references/workflows/cart/update-cart-seller-promotions.mdx +42 -0
- package/content/references/workflows/commission/batch-commission-rules.mdx +45 -0
- package/content/references/workflows/commission/create-commission-rates.mdx +41 -0
- package/content/references/workflows/commission/delete-commission-rates.mdx +34 -0
- package/content/references/workflows/commission/refresh-order-commission-lines.mdx +30 -0
- package/content/references/workflows/commission/update-commission-rates.mdx +35 -0
- package/content/references/workflows/media/set-category-images.mdx +41 -0
- package/content/references/workflows/media/set-collection-images.mdx +41 -0
- package/content/references/workflows/member/accept-member-invite.mdx +33 -0
- package/content/references/workflows/member/add-seller-member.mdx +30 -0
- package/content/references/workflows/member/create-member-invites.mdx +34 -0
- package/content/references/workflows/member/delete-member-invite.mdx +24 -0
- package/content/references/workflows/member/remove-seller-member.mdx +28 -0
- package/content/references/workflows/member/resend-member-invite.mdx +28 -0
- package/content/references/workflows/member/update-member-role.mdx +28 -0
- package/content/references/workflows/member/update-member.mdx +35 -0
- package/content/references/workflows/offer/batch-offer-inventory-items.mdx +58 -0
- package/content/references/workflows/offer/create-offers.mdx +63 -0
- package/content/references/workflows/offer/delete-offers.mdx +35 -0
- package/content/references/workflows/offer/update-offers.mdx +51 -0
- package/content/references/workflows/order/cancel-order-fulfillment.mdx +34 -0
- package/content/references/workflows/order/confirm-claim-request.mdx +25 -0
- package/content/references/workflows/order/confirm-exchange-request.mdx +25 -0
- package/content/references/workflows/order/confirm-order-edit-request.mdx +25 -0
- package/content/references/workflows/order/confirm-return-receive.mdx +25 -0
- package/content/references/workflows/order/create-order-fulfillment.mdx +45 -0
- package/content/references/workflows/order-group/get-order-group-detail.mdx +29 -0
- package/content/references/workflows/order-group/get-order-groups-list.mdx +36 -0
- package/content/references/workflows/overview.mdx +72 -0
- package/content/references/workflows/payout/create-onboarding.mdx +36 -0
- package/content/references/workflows/payout/create-payout-account.mdx +33 -0
- package/content/references/workflows/payout/create-payout.mdx +30 -0
- package/content/references/workflows/payout/process-payout-for-webhook.mdx +32 -0
- package/content/references/workflows/product/confirm-products.mdx +46 -0
- package/content/references/workflows/product/create-products.mdx +63 -0
- package/content/references/workflows/product/link-sellers-to-product-category.mdx +40 -0
- package/content/references/workflows/product/link-sellers-to-product.mdx +40 -0
- package/content/references/workflows/product/reject-product.mdx +46 -0
- package/content/references/workflows/product/request-product-change.mdx +46 -0
- package/content/references/workflows/product-attribute/add-product-attributes-to-product.mdx +49 -0
- package/content/references/workflows/product-attribute/create-and-link-product-attributes-to-product.mdx +46 -0
- package/content/references/workflows/product-attribute/create-product-attribute-values.mdx +43 -0
- package/content/references/workflows/product-attribute/create-product-attributes.mdx +56 -0
- package/content/references/workflows/product-attribute/delete-product-attribute-values.mdx +30 -0
- package/content/references/workflows/product-attribute/delete-product-attributes.mdx +30 -0
- package/content/references/workflows/product-attribute/remove-product-attributes-from-product.mdx +29 -0
- package/content/references/workflows/product-attribute/update-product-attribute-values.mdx +44 -0
- package/content/references/workflows/product-attribute/update-product-attributes-on-product.mdx +41 -0
- package/content/references/workflows/product-attribute/update-product-attributes.mdx +48 -0
- package/content/references/workflows/product-attribute/upsert-product-attribute-values.mdx +43 -0
- package/content/references/workflows/product-edit/auto-confirm-product-change.mdx +39 -0
- package/content/references/workflows/product-edit/cancel-product-change.mdx +49 -0
- package/content/references/workflows/product-edit/confirm-product-change.mdx +57 -0
- package/content/references/workflows/product-edit/create-product-change.mdx +72 -0
- package/content/references/workflows/product-edit/reject-product-change.mdx +54 -0
- package/content/references/workflows/product-edit/stage-product-change.mdx +75 -0
- package/content/references/workflows/seller/approve-seller.mdx +34 -0
- package/content/references/workflows/seller/create-seller-account.mdx +59 -0
- package/content/references/workflows/seller/create-seller-defaults.mdx +22 -0
- package/content/references/workflows/seller/create-sellers.mdx +65 -0
- package/content/references/workflows/seller/delete-seller-professional-details.mdx +37 -0
- package/content/references/workflows/seller/delete-sellers.mdx +24 -0
- package/content/references/workflows/seller/invite-seller.mdx +28 -0
- package/content/references/workflows/seller/suspend-seller.mdx +35 -0
- package/content/references/workflows/seller/terminate-seller.mdx +35 -0
- package/content/references/workflows/seller/unsuspend-seller.mdx +34 -0
- package/content/references/workflows/seller/unterminate-seller.mdx +34 -0
- package/content/references/workflows/seller/update-seller-address.mdx +55 -0
- package/content/references/workflows/seller/update-seller-payment-details.mdx +52 -0
- package/content/references/workflows/seller/update-seller-professional-details.mdx +48 -0
- package/content/references/workflows/seller/update-sellers.mdx +57 -0
- package/content/resources/ai/llms.mdx +74 -0
- package/content/resources/ai/mcp.mdx +152 -0
- package/content/resources/ai/overview.mdx +97 -0
- package/content/resources/customization/custom-fields.mdx +182 -0
- package/content/resources/customization/extend-a-workflow.mdx +39 -0
- package/content/resources/customization/extending-panels.mdx +309 -0
- package/content/resources/deployment/medusa-cloud.mdx +167 -0
- package/content/resources/integrations/notifications.mdx +39 -0
- package/content/resources/integrations/search.mdx +122 -0
- package/content/resources/integrations/stripe-connect.mdx +395 -0
- package/content/resources/tutorials/add-a-block.mdx +74 -0
- package/content/resources/tutorials/attributes-and-variant-axes.mdx +111 -0
- package/content/resources/tutorials/build-a-block.mdx +134 -0
- package/content/resources/tutorials/configure-commissions.mdx +127 -0
- package/content/resources/tutorials/custom-api-route.mdx +142 -0
- package/content/resources/tutorials/custom-panel-page.mdx +78 -0
- package/content/resources/tutorials/first-marketplace.mdx +45 -0
- package/content/resources/tutorials/handle-product-requests.mdx +80 -0
- package/content/resources/tutorials/import-export-products.mdx +96 -0
- package/content/resources/tutorials/master-products-and-offers.mdx +89 -0
- package/content/resources/tutorials/recompose-a-page.mdx +129 -0
- package/content/resources/tutorials/replace-panel-components.mdx +116 -0
- package/content/resources/tutorials/seller-payouts-stripe.mdx +89 -0
- package/content/telemetry.mdx +67 -0
- package/content/tools/api-client.mdx +155 -0
- package/content/tools/cli.mdx +196 -0
- package/content/tools/dashboard-sdk.mdx +35 -0
- package/content/user-guide/admin/overview.mdx +23 -0
- package/content/user-guide/admin/stores.mdx +193 -0
- package/content/user-guide/vendor/overview.mdx +23 -0
- package/content/user-guide/vendor/stores.mdx +209 -0
- package/llms.txt +307 -0
- package/package.json +33 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "createAndLinkProductAttributesToProductWorkflow"
|
|
3
|
+
description: "Batch attach, detach, and update attribute selections on a product."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The batch orchestrator behind `POST /admin/products/:id/attributes/batch` and `POST /vendor/products/:id/attributes/batch`. Delegates to `removeProductAttributesFromProductWorkflow`, `addProductAttributesToProductWorkflow`, and `updateProductAttributesOnProductWorkflow`, applied in the order **remove → add → update** so removing and re-adding the same attribute in one call resolves correctly.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { createAndLinkProductAttributesToProductWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
await createAndLinkProductAttributesToProductWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
product_id: "prod_123",
|
|
16
|
+
add: [{ id: "pattr_color", value_ids: ["pattrval_red"] }],
|
|
17
|
+
remove: ["pattr_old"],
|
|
18
|
+
update: [{ id: "pattr_size", add: ["pattrval_xl"] }],
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Input
|
|
24
|
+
|
|
25
|
+
<ParamField body="product_id" type="string" required>The product whose attributes are being managed.</ParamField>
|
|
26
|
+
<ParamField body="add" type="ProductAttributeBatchAdd[]">Attributes to attach — existing (`{ id, value_ids | value }`) or inline (`{ title, type?, value | values, is_variant_axis? }`).</ParamField>
|
|
27
|
+
<ParamField body="remove" type="string[]">Ids of attributes to detach; product-scoped attributes are deleted, shared ones are unlinked.</ParamField>
|
|
28
|
+
<ParamField body="update" type="ProductAttributeBatchUpdate[]">Per-attribute selection changes (`{ id, title?, add?, remove?, value? }`).</ParamField>
|
|
29
|
+
<ParamField body="additional_data" type="object">Custom data passed through to the workflow hooks.</ParamField>
|
|
30
|
+
|
|
31
|
+
## Result
|
|
32
|
+
|
|
33
|
+
<ResponseField name="result" type="void">No return value.</ResponseField>
|
|
34
|
+
|
|
35
|
+
## Hooks
|
|
36
|
+
|
|
37
|
+
- `validate` — runs before any mutation with `{ input }`; throw to reject the batch.
|
|
38
|
+
- `productAttributesLinked` — runs after all sub-workflows with `{ product_id }`.
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
createAndLinkProductAttributesToProductWorkflow.hooks.productAttributesLinked(
|
|
42
|
+
async ({ product_id }) => {
|
|
43
|
+
// re-index the product
|
|
44
|
+
},
|
|
45
|
+
)
|
|
46
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "createProductAttributeValuesWorkflow"
|
|
3
|
+
description: "Add values to an attribute, mirroring them onto its product option."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Creates values on an existing attribute. If the attribute is a variant-axis `multi_select` with a mirror `ProductOption`, the option's value list is extended first and each new attribute value is bound to its option value via `product_option_value_id`. Triggered by `POST /admin/product-attributes/:id/values`. Emits `product-attribute-value.created`.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { createProductAttributeValuesWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
const { result } = await createProductAttributeValuesWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
attribute_id: "pattr_color",
|
|
16
|
+
values: [{ name: "Green" }, { name: "Yellow", rank: 5 }],
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Input
|
|
22
|
+
|
|
23
|
+
<ParamField body="attribute_id" type="string" required>The attribute to add the values to.</ParamField>
|
|
24
|
+
<ParamField body="values" type="CreateProductAttributeValueDTO[]" required>
|
|
25
|
+
Values to create.
|
|
26
|
+
<Expandable title="properties">
|
|
27
|
+
<ParamField body="name" type="string" required>Display name of the value.</ParamField>
|
|
28
|
+
<ParamField body="handle" type="string">URL-safe handle; auto-generated when omitted.</ParamField>
|
|
29
|
+
<ParamField body="rank" type="number">Sort rank.</ParamField>
|
|
30
|
+
<ParamField body="is_active" type="boolean">Whether the value is active.</ParamField>
|
|
31
|
+
<ParamField body="metadata" type="object | null">Custom key-value data.</ParamField>
|
|
32
|
+
</Expandable>
|
|
33
|
+
</ParamField>
|
|
34
|
+
<ParamField body="additional_data" type="object">Custom data passed through to the hooks.</ParamField>
|
|
35
|
+
|
|
36
|
+
## Result
|
|
37
|
+
|
|
38
|
+
<ResponseField name="result" type="ProductAttributeValueDTO[]">The created values.</ResponseField>
|
|
39
|
+
|
|
40
|
+
## Hooks
|
|
41
|
+
|
|
42
|
+
- `validate` — runs before creation with `{ input }`.
|
|
43
|
+
- `productAttributeValuesCreated` — runs after creation with `{ values, additional_data }`.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "createProductAttributesWorkflow"
|
|
3
|
+
description: "Create catalog attributes with values, mirror options, and category links."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Creates product attributes and their values. Variant-axis `multi_select` attributes also get a shared mirror `ProductOption` created, with each value bound to its option value. Optional `category_ids` create category links per attribute. Triggered by `POST /admin/product-attributes`. Emits `product-attribute.created`.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { createProductAttributesWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
const { result } = await createProductAttributesWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
attributes: [
|
|
16
|
+
{
|
|
17
|
+
name: "Color",
|
|
18
|
+
type: "multi_select",
|
|
19
|
+
is_variant_axis: true,
|
|
20
|
+
values: [{ name: "Red" }, { name: "Blue" }],
|
|
21
|
+
category_ids: ["pcat_apparel"],
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Input
|
|
29
|
+
|
|
30
|
+
<ParamField body="attributes" type="(CreateProductAttributeDTO & { category_ids?: string[] })[]" required>
|
|
31
|
+
Attributes to create.
|
|
32
|
+
<Expandable title="properties">
|
|
33
|
+
<ParamField body="name" type="string" required>Display name of the attribute.</ParamField>
|
|
34
|
+
<ParamField body="type" type="AttributeType" required>One of `single_select`, `multi_select`, `unit`, `toggle`, `text`.</ParamField>
|
|
35
|
+
<ParamField body="handle" type="string">URL-safe handle; auto-generated when omitted.</ParamField>
|
|
36
|
+
<ParamField body="description" type="string | null">Description of the attribute.</ParamField>
|
|
37
|
+
<ParamField body="is_required" type="boolean">Whether products must carry this attribute.</ParamField>
|
|
38
|
+
<ParamField body="is_filterable" type="boolean">Whether the attribute is exposed as a storefront filter.</ParamField>
|
|
39
|
+
<ParamField body="is_variant_axis" type="boolean">Mirror the attribute as a shared `ProductOption` (with `type: multi_select`).</ParamField>
|
|
40
|
+
<ParamField body="rank" type="number">Sort rank.</ParamField>
|
|
41
|
+
<ParamField body="is_active" type="boolean">Whether the attribute is active.</ParamField>
|
|
42
|
+
<ParamField body="values" type="CreateProductAttributeValueDTO[]">Values to create (`{ name, handle?, rank?, is_active?, metadata? }`).</ParamField>
|
|
43
|
+
<ParamField body="category_ids" type="string[]">Category ids to link the attribute to.</ParamField>
|
|
44
|
+
<ParamField body="metadata" type="object | null">Custom key-value data.</ParamField>
|
|
45
|
+
</Expandable>
|
|
46
|
+
</ParamField>
|
|
47
|
+
<ParamField body="additional_data" type="object">Custom data passed through to the hooks.</ParamField>
|
|
48
|
+
|
|
49
|
+
## Result
|
|
50
|
+
|
|
51
|
+
<ResponseField name="result" type="ProductAttributeDTO[]">The created attributes.</ResponseField>
|
|
52
|
+
|
|
53
|
+
## Hooks
|
|
54
|
+
|
|
55
|
+
- `validate` — runs before creation with `{ input }`.
|
|
56
|
+
- `productAttributesCreated` — runs after creation with `{ attributes, additional_data }`.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "deleteProductAttributeValuesWorkflow"
|
|
3
|
+
description: "Delete attribute values and shrink the mirror option accordingly."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Deletes attribute values by id. When the deleted values belong to a single variant-axis `multi_select` attribute with a mirror `ProductOption`, the option's value list is rewritten to the attribute's remaining value names. Triggered by `DELETE /admin/product-attributes/:id/values/:value_id`; also run internally by the batch update engine. Emits `product-attribute-value.deleted`.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { deleteProductAttributeValuesWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
await deleteProductAttributeValuesWorkflow(container).run({
|
|
14
|
+
input: { ids: ["pattrval_123", "pattrval_456"] },
|
|
15
|
+
})
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Input
|
|
19
|
+
|
|
20
|
+
<ParamField body="ids" type="string[]" required>Ids of the attribute values to delete.</ParamField>
|
|
21
|
+
<ParamField body="additional_data" type="object">Custom data passed through to the hooks.</ParamField>
|
|
22
|
+
|
|
23
|
+
## Result
|
|
24
|
+
|
|
25
|
+
<ResponseField name="result" type="void">No return value.</ResponseField>
|
|
26
|
+
|
|
27
|
+
## Hooks
|
|
28
|
+
|
|
29
|
+
- `validate` — runs before deletion with `{ input }`.
|
|
30
|
+
- `productAttributeValuesDeleted` — runs after deletion with `{ ids, additional_data }`.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "deleteProductAttributesWorkflow"
|
|
3
|
+
description: "Delete attributes and their mirror product options."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Deletes product attributes after validating none of them is still linked to a product or category. Mirror `ProductOption`s of axis attributes are deleted alongside. Triggered by `DELETE /admin/product-attributes/:id`; also run internally when detaching product-scoped attributes. Emits `product-attribute.deleted`.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { deleteProductAttributesWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
await deleteProductAttributesWorkflow(container).run({
|
|
14
|
+
input: { ids: ["pattr_123"] },
|
|
15
|
+
})
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Input
|
|
19
|
+
|
|
20
|
+
<ParamField body="ids" type="string[]" required>Ids of the attributes to delete; the workflow throws if an attribute is still linked.</ParamField>
|
|
21
|
+
<ParamField body="additional_data" type="object">Custom data passed through to the hooks.</ParamField>
|
|
22
|
+
|
|
23
|
+
## Result
|
|
24
|
+
|
|
25
|
+
<ResponseField name="result" type="void">No return value.</ResponseField>
|
|
26
|
+
|
|
27
|
+
## Hooks
|
|
28
|
+
|
|
29
|
+
- `validate` — runs before deletion with `{ input }`.
|
|
30
|
+
- `productAttributesDeleted` — runs after deletion with `{ ids, additional_data }`.
|
package/content/references/workflows/product-attribute/remove-product-attributes-from-product.mdx
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "removeProductAttributesFromProductWorkflow"
|
|
3
|
+
description: "Detach attributes from a product, deleting product-scoped ones."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Handles the `remove` portion of the attribute batch engine (`createAndLinkProductAttributesToProductWorkflow`). Rejects required attributes, dismisses the product's value links for every listed attribute, detaches the mirror `ProductOption` for shared axis attributes, and runs `deleteProductAttributesWorkflow` for product-scoped (inline) attributes so their exclusive options are deleted too.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { removeProductAttributesFromProductWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
await removeProductAttributesFromProductWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
product_id: "prod_123",
|
|
16
|
+
remove: ["pattr_color", "pattr_custom_size"],
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Input
|
|
22
|
+
|
|
23
|
+
<ParamField body="product_id" type="string" required>The product to detach the attributes from.</ParamField>
|
|
24
|
+
<ParamField body="remove" type="string[]" required>Ids of the attributes to detach; attributes with `is_required: true` cause the workflow to throw.</ParamField>
|
|
25
|
+
<ParamField body="additional_data" type="object">Custom data passed through.</ParamField>
|
|
26
|
+
|
|
27
|
+
## Result
|
|
28
|
+
|
|
29
|
+
<ResponseField name="result" type="void">No return value.</ResponseField>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "updateProductAttributeValuesWorkflow"
|
|
3
|
+
description: "Update attribute values matching a selector and re-sync the mirror option."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Updates attribute values by selector. When the touched values belong to a single variant-axis `multi_select` attribute with a mirror `ProductOption`, the option's value list is rewritten from the attribute's current value names. Triggered by `POST /admin/product-attributes/:id/values/:value_id`. Emits `product-attribute-value.updated`.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { updateProductAttributeValuesWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
const { result } = await updateProductAttributeValuesWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
selector: { id: "pattrval_123" },
|
|
16
|
+
update: { name: "Dark Green" },
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Input
|
|
22
|
+
|
|
23
|
+
<ParamField body="selector" type="object" required>Filter for the values to update, e.g. `{ id: "pattrval_123" }`.</ParamField>
|
|
24
|
+
<ParamField body="update" type="UpdateProductAttributeValueDTO" required>
|
|
25
|
+
Fields to set on every matched value.
|
|
26
|
+
<Expandable title="properties">
|
|
27
|
+
<ParamField body="name" type="string">New display name.</ParamField>
|
|
28
|
+
<ParamField body="handle" type="string">New handle.</ParamField>
|
|
29
|
+
<ParamField body="rank" type="number">Sort rank.</ParamField>
|
|
30
|
+
<ParamField body="is_active" type="boolean">Whether the value is active.</ParamField>
|
|
31
|
+
<ParamField body="product_option_value_id" type="string | null">Bound mirror option value.</ParamField>
|
|
32
|
+
<ParamField body="metadata" type="object | null">Custom key-value data.</ParamField>
|
|
33
|
+
</Expandable>
|
|
34
|
+
</ParamField>
|
|
35
|
+
<ParamField body="additional_data" type="object">Custom data passed through to the hooks.</ParamField>
|
|
36
|
+
|
|
37
|
+
## Result
|
|
38
|
+
|
|
39
|
+
<ResponseField name="result" type="ProductAttributeValueDTO[]">The updated values.</ResponseField>
|
|
40
|
+
|
|
41
|
+
## Hooks
|
|
42
|
+
|
|
43
|
+
- `validate` — runs before the update with `{ input }`.
|
|
44
|
+
- `productAttributeValuesUpdated` — runs after the update with `{ values, additional_data }`.
|
package/content/references/workflows/product-attribute/update-product-attributes-on-product.mdx
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "updateProductAttributesOnProductWorkflow"
|
|
3
|
+
description: "Mutate a product's per-attribute value selections."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Handles the `update` portion of the attribute batch engine (`createAndLinkProductAttributesToProductWorkflow`). For shared axis attributes it adjusts the per-product value subset of the mirror option and keeps the value-link pivot in sync; for exclusive (product-scoped) axis attributes it creates or deletes values on the exclusive option; for `text`/`unit` it swaps the linked value's name (or creates one); for `toggle` it re-links the matching `true`/`false` value. A `title` on a product-scoped attribute renames it via `updateProductAttributesWorkflow`.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { updateProductAttributesOnProductWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
await updateProductAttributesOnProductWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
product_id: "prod_123",
|
|
16
|
+
update: [
|
|
17
|
+
{ id: "pattr_size", add: ["pattrval_xl"], remove: ["pattrval_s"] },
|
|
18
|
+
{ id: "pattr_material", value: "Linen" },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Input
|
|
25
|
+
|
|
26
|
+
<ParamField body="product_id" type="string" required>The product whose attribute selections are updated.</ParamField>
|
|
27
|
+
<ParamField body="update" type="ProductAttributeBatchUpdate[]" required>
|
|
28
|
+
Per-attribute updates.
|
|
29
|
+
<Expandable title="properties">
|
|
30
|
+
<ParamField body="id" type="string" required>Id of the existing attribute to update.</ParamField>
|
|
31
|
+
<ParamField body="title" type="string">New name; only honoured for product-scoped attributes and propagated to the mirror option title.</ParamField>
|
|
32
|
+
<ParamField body="add" type="(string | { value: string })[]">Value ids to add (shared axis subset) or new value objects to create (exclusive axis).</ParamField>
|
|
33
|
+
<ParamField body="remove" type="string[]">Value ids to remove from the selection (exclusive-axis values are deleted).</ParamField>
|
|
34
|
+
<ParamField body="value" type="string | number | boolean">New scalar for `text` / `unit` / `toggle` attributes.</ParamField>
|
|
35
|
+
</Expandable>
|
|
36
|
+
</ParamField>
|
|
37
|
+
<ParamField body="additional_data" type="object">Custom data passed through.</ParamField>
|
|
38
|
+
|
|
39
|
+
## Result
|
|
40
|
+
|
|
41
|
+
<ResponseField name="result" type="void">No return value.</ResponseField>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "updateProductAttributesWorkflow"
|
|
3
|
+
description: "Update attributes matching a selector and sync mirror option titles."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Updates product attributes by selector. When `name` changes, the mirror `ProductOption` title of any affected axis attribute is updated to match. Triggered by `POST /admin/product-attributes/:id`. Emits `product-attribute.updated`.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { updateProductAttributesWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
const { result } = await updateProductAttributesWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
selector: { id: "pattr_123" },
|
|
16
|
+
update: { name: "Colour", is_filterable: true },
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Input
|
|
22
|
+
|
|
23
|
+
<ParamField body="selector" type="object" required>Filter for the attributes to update, e.g. `{ id: "pattr_123" }`.</ParamField>
|
|
24
|
+
<ParamField body="update" type="UpdateProductAttributeDTO" required>
|
|
25
|
+
Fields to set on every matched attribute.
|
|
26
|
+
<Expandable title="properties">
|
|
27
|
+
<ParamField body="name" type="string">New display name; propagated to mirror option titles.</ParamField>
|
|
28
|
+
<ParamField body="handle" type="string">New handle.</ParamField>
|
|
29
|
+
<ParamField body="description" type="string | null">New description.</ParamField>
|
|
30
|
+
<ParamField body="type" type="AttributeType">One of `single_select`, `multi_select`, `unit`, `toggle`, `text`.</ParamField>
|
|
31
|
+
<ParamField body="is_required" type="boolean">Whether products must carry this attribute.</ParamField>
|
|
32
|
+
<ParamField body="is_filterable" type="boolean">Whether the attribute is a storefront filter.</ParamField>
|
|
33
|
+
<ParamField body="is_variant_axis" type="boolean">Whether the attribute is a variant axis.</ParamField>
|
|
34
|
+
<ParamField body="rank" type="number">Sort rank.</ParamField>
|
|
35
|
+
<ParamField body="is_active" type="boolean">Whether the attribute is active.</ParamField>
|
|
36
|
+
<ParamField body="metadata" type="object | null">Custom key-value data.</ParamField>
|
|
37
|
+
</Expandable>
|
|
38
|
+
</ParamField>
|
|
39
|
+
<ParamField body="additional_data" type="object">Custom data passed through to the hooks.</ParamField>
|
|
40
|
+
|
|
41
|
+
## Result
|
|
42
|
+
|
|
43
|
+
<ResponseField name="result" type="ProductAttributeDTO[]">The updated attributes.</ResponseField>
|
|
44
|
+
|
|
45
|
+
## Hooks
|
|
46
|
+
|
|
47
|
+
- `validate` — runs before the update with `{ input }`.
|
|
48
|
+
- `productAttributesUpdated` — runs after the update with `{ attributes, additional_data }`.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "upsertProductAttributeValuesWorkflow"
|
|
3
|
+
description: "Create or update attribute values in one call, keyed by id presence."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Splits the given values by `id`: entries without an id are created on the attribute, entries with an id are updated in place. Unlike the create/update value workflows it does not touch the mirror `ProductOption` (renaming a value in place does not re-sync the mirrored option) and it emits no events.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { upsertProductAttributeValuesWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
const { result } = await upsertProductAttributeValuesWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
attribute_id: "pattr_color",
|
|
16
|
+
values: [
|
|
17
|
+
{ name: "Teal" },
|
|
18
|
+
{ id: "pattrval_123", name: "Navy Blue" },
|
|
19
|
+
],
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Input
|
|
25
|
+
|
|
26
|
+
<ParamField body="attribute_id" type="string" required>The attribute the values belong to.</ParamField>
|
|
27
|
+
<ParamField body="values" type="UpsertProductAttributeValueDTO[]" required>
|
|
28
|
+
Values to create (no `id`) or update (with `id`).
|
|
29
|
+
<Expandable title="properties">
|
|
30
|
+
<ParamField body="id" type="string">Existing value id; omit to create a new value.</ParamField>
|
|
31
|
+
<ParamField body="name" type="string">Display name of the value.</ParamField>
|
|
32
|
+
<ParamField body="handle" type="string">URL-safe handle.</ParamField>
|
|
33
|
+
<ParamField body="rank" type="number">Sort rank.</ParamField>
|
|
34
|
+
<ParamField body="is_active" type="boolean">Whether the value is active.</ParamField>
|
|
35
|
+
<ParamField body="product_option_value_id" type="string | null">Bound mirror option value.</ParamField>
|
|
36
|
+
<ParamField body="metadata" type="object | null">Custom key-value data.</ParamField>
|
|
37
|
+
</Expandable>
|
|
38
|
+
</ParamField>
|
|
39
|
+
<ParamField body="additional_data" type="object">Custom data passed through.</ParamField>
|
|
40
|
+
|
|
41
|
+
## Result
|
|
42
|
+
|
|
43
|
+
<ResponseField name="result" type="ProductAttributeValueDTO[]">The created values followed by the updated values.</ResponseField>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "autoConfirmProductChangeWorkflow"
|
|
3
|
+
description: "Conditionally confirm a ProductChange based on the product_request feature flag."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Decides whether a freshly staged `ProductChange` should be confirmed immediately: it runs `confirmProductChangeWorkflow` for the change when `force` is `true` or the `product_request` feature flag is disabled, and does nothing otherwise (leaving the change `pending` for operator review). Run as a step by `stageProductChangeWorkflow`. Any events (`product-change.confirmed`) come from the nested confirm workflow.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { autoConfirmProductChangeWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
await autoConfirmProductChangeWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
change_id: "prch_01H...",
|
|
16
|
+
confirmed_by: "sel_01H...",
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Input
|
|
22
|
+
|
|
23
|
+
<ParamField body="change_id" type="string" required>
|
|
24
|
+
Id of the product change to (conditionally) confirm.
|
|
25
|
+
</ParamField>
|
|
26
|
+
|
|
27
|
+
<ParamField body="confirmed_by" type="string">
|
|
28
|
+
Actor id forwarded as `confirmed_by` to the confirm workflow.
|
|
29
|
+
</ParamField>
|
|
30
|
+
|
|
31
|
+
<ParamField body="force" type="boolean">
|
|
32
|
+
Confirm regardless of the `product_request` feature flag.
|
|
33
|
+
</ParamField>
|
|
34
|
+
|
|
35
|
+
## Result
|
|
36
|
+
|
|
37
|
+
<ResponseField name="result" type="void">
|
|
38
|
+
Returns nothing; the change is either confirmed (and its actions applied) or left `pending`.
|
|
39
|
+
</ResponseField>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "cancelProductChangeWorkflow"
|
|
3
|
+
description: "Cancel a pending ProductChange so its staged actions are never applied."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Cancels a pending `ProductChange`: validates the change exists and is still `pending`, then sets it to `canceled` with `canceled_by` and `canceled_at` — the staged actions are never applied to the master product. Triggered by `POST /admin/product-changes/:id/cancel` (operator) and `POST /vendor/products/:id/cancel` (vendor withdrawing their own edit). Emits `product-change.canceled` with `{ id }`.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { cancelProductChangeWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
await cancelProductChangeWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
id: "prch_01H...",
|
|
16
|
+
canceled_by: "sel_01H...",
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Input
|
|
22
|
+
|
|
23
|
+
<ParamField body="id" type="string" required>
|
|
24
|
+
Id of the product change to cancel. Must exist and be in `pending` status.
|
|
25
|
+
</ParamField>
|
|
26
|
+
|
|
27
|
+
<ParamField body="canceled_by" type="string">
|
|
28
|
+
Actor id recorded as the canceler on the change.
|
|
29
|
+
</ParamField>
|
|
30
|
+
|
|
31
|
+
<ParamField body="additional_data" type="object">
|
|
32
|
+
Arbitrary data forwarded to the `productChangeCanceled` hook.
|
|
33
|
+
</ParamField>
|
|
34
|
+
|
|
35
|
+
## Result
|
|
36
|
+
|
|
37
|
+
<ResponseField name="result" type="void">
|
|
38
|
+
Returns nothing; the change status is updated in place.
|
|
39
|
+
</ResponseField>
|
|
40
|
+
|
|
41
|
+
## Hooks
|
|
42
|
+
|
|
43
|
+
<ResponseField name="validate" type="hook">
|
|
44
|
+
Runs first with `{ input }` — use it to block cancellation.
|
|
45
|
+
</ResponseField>
|
|
46
|
+
|
|
47
|
+
<ResponseField name="productChangeCanceled" type="hook">
|
|
48
|
+
Runs after cancellation with `{ id, additional_data }`.
|
|
49
|
+
</ResponseField>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "confirmProductChangeWorkflow"
|
|
3
|
+
description: "Confirm pending ProductChanges and apply their staged actions to the master product."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Confirms one or more pending `ProductChange` records: validates each change exists and is confirmable, marks them `confirmed` with `confirmed_by`, then runs the internal apply engine (`applyProductChangeActionsWorkflow`) to write the staged actions onto the master product. Triggered by `POST /admin/product-changes/:id/confirm`, and internally by `autoConfirmProductChangeWorkflow`. Emits `product-change.confirmed` with one `{ id }` per change.
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { confirmProductChangeWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
await confirmProductChangeWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
ids: ["prch_01H..."],
|
|
16
|
+
confirmed_by: "user_01H...",
|
|
17
|
+
},
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Input
|
|
22
|
+
|
|
23
|
+
<ParamField body="ids" type="string[]" required>
|
|
24
|
+
Ids of the product changes to confirm. Each must exist and be in a confirmable (`pending`) state.
|
|
25
|
+
</ParamField>
|
|
26
|
+
|
|
27
|
+
<ParamField body="confirmed_by" type="string">
|
|
28
|
+
Actor id recorded as the confirmer on each change.
|
|
29
|
+
</ParamField>
|
|
30
|
+
|
|
31
|
+
<ParamField body="internal_note" type="string">
|
|
32
|
+
Operator-only note stored on each confirmed change.
|
|
33
|
+
</ParamField>
|
|
34
|
+
|
|
35
|
+
<ParamField body="external_note" type="string">
|
|
36
|
+
Vendor-facing note stored on each confirmed change.
|
|
37
|
+
</ParamField>
|
|
38
|
+
|
|
39
|
+
<ParamField body="additional_data" type="object">
|
|
40
|
+
Arbitrary data forwarded to the `productChangeConfirmed` hook.
|
|
41
|
+
</ParamField>
|
|
42
|
+
|
|
43
|
+
## Result
|
|
44
|
+
|
|
45
|
+
<ResponseField name="result" type="void">
|
|
46
|
+
Returns nothing; the changes are confirmed and their actions applied in place.
|
|
47
|
+
</ResponseField>
|
|
48
|
+
|
|
49
|
+
## Hooks
|
|
50
|
+
|
|
51
|
+
<ResponseField name="validate" type="hook">
|
|
52
|
+
Runs first with `{ input }` — use it to block confirmation of specific changes.
|
|
53
|
+
</ResponseField>
|
|
54
|
+
|
|
55
|
+
<ResponseField name="productChangeConfirmed" type="hook">
|
|
56
|
+
Runs after actions are applied with `{ ids, additional_data }`.
|
|
57
|
+
</ResponseField>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "createProductChangeWorkflow"
|
|
3
|
+
description: "Create ProductChange records after validating no pending change exists per product."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
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).
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { createProductChangeWorkflow } from "@mercurjs/core/workflows"
|
|
12
|
+
|
|
13
|
+
const { result } = await createProductChangeWorkflow(container).run({
|
|
14
|
+
input: {
|
|
15
|
+
changes: [
|
|
16
|
+
{ product_id: "prod_01H...", created_by: "sel_01H..." },
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Input
|
|
23
|
+
|
|
24
|
+
<ParamField body="changes" type="CreateProductChangeDTO[]" required>
|
|
25
|
+
Changes to create.
|
|
26
|
+
<Expandable title="properties">
|
|
27
|
+
<ParamField body="product_id" type="string" required>
|
|
28
|
+
Id of the product the change targets. Must not already have a pending change.
|
|
29
|
+
</ParamField>
|
|
30
|
+
<ParamField body="status" type="ProductChangeStatus">
|
|
31
|
+
One of `pending`, `confirmed`, `declined`, `canceled`; audit-trail rows are created already `confirmed`.
|
|
32
|
+
</ParamField>
|
|
33
|
+
<ParamField body="created_by" type="string">
|
|
34
|
+
Actor id who authored the change.
|
|
35
|
+
</ParamField>
|
|
36
|
+
<ParamField body="internal_note" type="string">
|
|
37
|
+
Operator-only note.
|
|
38
|
+
</ParamField>
|
|
39
|
+
<ParamField body="external_note" type="string">
|
|
40
|
+
Vendor-facing note.
|
|
41
|
+
</ParamField>
|
|
42
|
+
<ParamField body="confirmed_by" type="string">
|
|
43
|
+
Confirming actor id, for pre-confirmed rows.
|
|
44
|
+
</ParamField>
|
|
45
|
+
<ParamField body="confirmed_at" type="Date">
|
|
46
|
+
Confirmation timestamp, for pre-confirmed rows.
|
|
47
|
+
</ParamField>
|
|
48
|
+
<ParamField body="metadata" type="object">
|
|
49
|
+
Arbitrary key-value data stored on the change.
|
|
50
|
+
</ParamField>
|
|
51
|
+
</Expandable>
|
|
52
|
+
</ParamField>
|
|
53
|
+
|
|
54
|
+
<ParamField body="additional_data" type="object">
|
|
55
|
+
Arbitrary data forwarded to the `productChangeCreated` hook.
|
|
56
|
+
</ParamField>
|
|
57
|
+
|
|
58
|
+
## Result
|
|
59
|
+
|
|
60
|
+
<ResponseField name="result" type="ProductChangeDTO[]">
|
|
61
|
+
The created change records with ids, statuses, and timestamps.
|
|
62
|
+
</ResponseField>
|
|
63
|
+
|
|
64
|
+
## Hooks
|
|
65
|
+
|
|
66
|
+
<ResponseField name="validate" type="hook">
|
|
67
|
+
Runs first with `{ input }` — use it to reject invalid payloads before creation.
|
|
68
|
+
</ResponseField>
|
|
69
|
+
|
|
70
|
+
<ResponseField name="productChangeCreated" type="hook">
|
|
71
|
+
Runs after creation with `{ changes, additional_data }`.
|
|
72
|
+
</ResponseField>
|