@mercurjs/docs 2.2.1 → 2.3.0-canary.1
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/content/home.mdx +107 -0
- package/content/learn/architecture.mdx +168 -83
- package/content/learn/introduction.mdx +161 -56
- package/content/learn/migration-to-2-0.mdx +187 -0
- package/content/learn/why-mercur.mdx +91 -0
- package/content/platform/attribute/concepts/attribute-types.mdx +59 -0
- package/content/platform/attribute/concepts/global-vs-inline.mdx +50 -0
- package/content/platform/attribute/concepts/variant-axes.mdx +61 -0
- package/content/platform/attribute/guides/attach-attributes-to-a-product.mdx +69 -0
- package/content/platform/attribute/guides/create-a-variant-axis.mdx +83 -0
- package/content/platform/attribute/guides/create-an-attribute.mdx +81 -0
- package/content/platform/attribute/overview.mdx +87 -0
- package/content/platform/attribute/reference/data-models.mdx +56 -0
- package/content/platform/attribute/reference/events.mdx +41 -0
- package/content/platform/attribute/reference/links.mdx +45 -0
- package/content/platform/attribute/reference/service.mdx +49 -0
- package/content/platform/attribute/reference/workflows.mdx +45 -0
- package/content/platform/catalog/concepts/master-products.mdx +54 -0
- package/content/platform/catalog/concepts/product-seller-allowlist.mdx +48 -0
- package/content/platform/catalog/concepts/status-lifecycle.mdx +58 -0
- package/content/platform/catalog/concepts/variants-categories-collections.mdx +49 -0
- package/content/platform/catalog/guides/allowlist-stores.mdx +59 -0
- package/content/platform/catalog/guides/create-a-master-product.mdx +70 -0
- package/content/platform/catalog/guides/publish-or-reject-a-product.mdx +79 -0
- package/content/platform/catalog/overview.mdx +90 -0
- package/content/platform/catalog/reference/data-models.mdx +66 -0
- package/content/platform/catalog/reference/events.mdx +41 -0
- package/content/platform/catalog/reference/links.mdx +44 -0
- package/content/platform/catalog/reference/service.mdx +52 -0
- package/content/platform/catalog/reference/workflows.mdx +40 -0
- package/content/platform/commission/concepts/order-commission-lines.mdx +65 -0
- package/content/platform/commission/concepts/rule-matching.mdx +86 -0
- package/content/platform/commission/concepts/rules-and-rates.mdx +84 -0
- package/content/platform/commission/guides/batch-update-rules.mdx +58 -0
- package/content/platform/commission/guides/create-a-rate.mdx +72 -0
- package/content/platform/commission/guides/refresh-order-commission-lines.mdx +55 -0
- package/content/platform/commission/overview.mdx +86 -0
- package/content/platform/commission/reference/data-models.mdx +75 -0
- package/content/platform/commission/reference/events.mdx +58 -0
- package/content/platform/commission/reference/links.mdx +45 -0
- package/content/platform/commission/reference/service.mdx +51 -0
- package/content/platform/commission/reference/workflows.mdx +40 -0
- package/content/platform/offer/concepts/pricing-and-inventory.mdx +72 -0
- package/content/platform/offer/concepts/shipping.mdx +48 -0
- package/content/platform/offer/concepts/what-is-an-offer.mdx +65 -0
- package/content/platform/offer/guides/bulk-create-offers.mdx +84 -0
- package/content/platform/offer/guides/create-an-offer.mdx +83 -0
- package/content/platform/offer/guides/manage-offer-inventory.mdx +53 -0
- package/content/platform/offer/overview.mdx +84 -0
- package/content/platform/offer/reference/data-models.mdx +56 -0
- package/content/platform/offer/reference/events.mdx +39 -0
- package/content/platform/offer/reference/links.mdx +60 -0
- package/content/platform/offer/reference/service.mdx +53 -0
- package/content/platform/offer/reference/workflows.mdx +38 -0
- package/content/platform/order-group/concepts/computed-totals.mdx +59 -0
- package/content/platform/order-group/concepts/order-splitting.mdx +61 -0
- package/content/platform/order-group/concepts/the-order-group.mdx +64 -0
- package/content/platform/order-group/guides/list-order-groups.mdx +67 -0
- package/content/platform/order-group/guides/retrieve-an-order-group.mdx +63 -0
- package/content/platform/order-group/guides/split-a-cart.mdx +58 -0
- package/content/platform/order-group/overview.mdx +83 -0
- package/content/platform/order-group/reference/data-models.mdx +40 -0
- package/content/platform/order-group/reference/events.mdx +37 -0
- package/content/platform/order-group/reference/links.mdx +45 -0
- package/content/platform/order-group/reference/service.mdx +50 -0
- package/content/platform/order-group/reference/workflows.mdx +39 -0
- package/content/platform/payout/concepts/account-lifecycle.mdx +75 -0
- package/content/platform/payout/concepts/accounts-and-onboarding.mdx +70 -0
- package/content/platform/payout/concepts/payout-pipeline.mdx +99 -0
- package/content/platform/payout/guides/create-a-payout-account.mdx +59 -0
- package/content/platform/payout/guides/process-a-provider-webhook.mdx +74 -0
- package/content/platform/payout/guides/start-provider-onboarding.mdx +50 -0
- package/content/platform/payout/overview.mdx +86 -0
- package/content/platform/payout/reference/data-models.mdx +61 -0
- package/content/platform/payout/reference/events.mdx +48 -0
- package/content/platform/payout/reference/links.mdx +36 -0
- package/content/platform/payout/reference/service.mdx +53 -0
- package/content/platform/payout/reference/workflows.mdx +32 -0
- package/content/platform/product-edit/concepts/change-actions.mdx +66 -0
- package/content/platform/product-edit/concepts/change-pipeline.mdx +69 -0
- package/content/platform/product-edit/concepts/status-and-auto-confirm.mdx +66 -0
- package/content/platform/product-edit/guides/confirm-or-decline-a-change.mdx +76 -0
- package/content/platform/product-edit/guides/edit-a-product.mdx +74 -0
- package/content/platform/product-edit/guides/request-a-revision.mdx +54 -0
- package/content/platform/product-edit/overview.mdx +85 -0
- package/content/platform/product-edit/reference/data-models.mdx +65 -0
- package/content/platform/product-edit/reference/events.mdx +47 -0
- package/content/platform/product-edit/reference/links.mdx +39 -0
- package/content/platform/product-edit/reference/service.mdx +43 -0
- package/content/platform/product-edit/reference/workflows.mdx +49 -0
- package/content/platform/review/concepts/product-vs-seller-reviews.mdx +63 -0
- package/content/platform/review/concepts/ratings-and-moderation.mdx +64 -0
- package/content/platform/review/concepts/the-review-model.mdx +56 -0
- package/content/platform/review/guides/compute-aggregate-ratings.mdx +57 -0
- package/content/platform/review/guides/create-a-review.mdx +55 -0
- package/content/platform/review/guides/moderate-a-review.mdx +58 -0
- package/content/platform/review/guides/respond-to-a-review.mdx +61 -0
- package/content/platform/review/overview.mdx +87 -0
- package/content/platform/review/reference/data-models.mdx +36 -0
- package/content/platform/review/reference/events.mdx +61 -0
- package/content/platform/review/reference/links.mdx +43 -0
- package/content/platform/review/reference/service.mdx +54 -0
- package/content/platform/review/reference/workflows.mdx +31 -0
- package/content/platform/store/concepts/lifecycle.mdx +62 -0
- package/content/platform/store/concepts/store-entity.mdx +53 -0
- package/content/platform/store/concepts/team.mdx +50 -0
- package/content/platform/store/guides/create-a-store.mdx +55 -0
- package/content/platform/store/guides/manage-the-team.mdx +55 -0
- package/content/platform/store/guides/moderate-a-store.mdx +59 -0
- package/content/platform/store/overview.mdx +86 -0
- package/content/platform/store/reference/data-models.mdx +89 -0
- package/content/platform/store/reference/events.mdx +43 -0
- package/content/platform/store/reference/links.mdx +71 -0
- package/content/platform/store/reference/service.mdx +51 -0
- package/content/platform/store/reference/workflows.mdx +35 -0
- package/content/references/api/admin/commission-rates/create-commission-rate.mdx +1 -1
- package/content/references/api/admin/commission-rates/list-commission-rates.mdx +2 -2
- package/content/references/api/admin/commission-rates/update-commission-rate.mdx +1 -1
- package/content/references/api/admin/offers/batch-create-offers.mdx +3 -3
- package/content/references/api/admin/order-groups/list-order-groups.mdx +1 -1
- package/content/references/api/admin/product-attributes/create-attribute-value.mdx +2 -2
- package/content/references/api/admin/product-attributes/create-product-attribute.mdx +1 -1
- package/content/references/api/admin/product-attributes/update-product-attribute.mdx +1 -1
- package/content/references/api/admin/product-changes/confirm-product-change.mdx +1 -1
- package/content/references/api/admin/products/batch-product-attributes.mdx +1 -1
- package/content/references/api/admin/products/create-product.mdx +1 -1
- package/content/references/api/admin/products/preview-product.mdx +1 -1
- package/content/references/api/admin.mdx +4 -5
- package/content/references/api/conventions.mdx +9 -7
- package/content/references/api/store/carts/add-line-item.mdx +1 -1
- package/content/references/api/store/offers/list-offers.mdx +1 -1
- package/content/references/api/store/order-groups/list-order-groups.mdx +1 -1
- package/content/references/api/store.mdx +4 -13
- package/content/references/api/vendor/members/accept-member-invite.mdx +1 -1
- package/content/references/api/vendor/offers/batch-create-offers.mdx +4 -0
- package/content/references/api/vendor/offers/batch-offer-inventory-items.mdx +2 -0
- package/content/references/api/vendor/offers/create-offer.mdx +13 -1
- package/content/references/api/vendor/offers/list-offers.mdx +4 -0
- package/content/references/api/vendor/offers/retrieve-offer.mdx +4 -0
- package/content/references/api/vendor/offers/update-offer.mdx +12 -0
- package/content/references/api/vendor/payout-accounts/create-onboarding.mdx +1 -1
- package/content/references/api/vendor/products/batch-product-attributes.mdx +1 -1
- package/content/references/api/vendor/products/create-product-variant.mdx +1 -1
- package/content/references/api/vendor/products/create-product.mdx +1 -1
- package/content/references/api/vendor/products/delete-product.mdx +1 -1
- package/content/references/api/vendor/products/update-product.mdx +1 -1
- package/content/references/api/vendor/sellers/create-seller.mdx +2 -2
- package/content/references/api/vendor/sellers/list-sellers.mdx +1 -1
- package/content/references/api/vendor.mdx +6 -5
- package/content/references/configuration.mdx +16 -33
- package/content/references/overview.mdx +34 -52
- package/content/references/panel-extensions/create-page.mdx +194 -0
- package/content/references/panel-extensions/custom-fields.mdx +256 -0
- package/content/references/panel-extensions/overview.mdx +102 -0
- package/content/references/panel-extensions/widgets.mdx +212 -0
- package/content/resources/ai/mcp.mdx +2 -2
- package/content/resources/ai/overview.mdx +21 -16
- package/content/resources/ai/skills.mdx +67 -0
- package/content/resources/best-practices/api-routes.mdx +55 -43
- package/content/resources/best-practices/custom-fields.mdx +116 -92
- package/content/resources/best-practices/frontend.mdx +62 -50
- package/content/resources/best-practices/module-links.mdx +48 -34
- package/content/resources/best-practices/modules.mdx +53 -27
- package/content/resources/best-practices/overview.mdx +45 -17
- package/content/resources/best-practices/subscribers-and-jobs.mdx +37 -24
- package/content/resources/best-practices/types.mdx +38 -23
- package/content/resources/best-practices/workflows.mdx +33 -21
- package/content/resources/customization/custom-fields.mdx +15 -15
- package/content/resources/customization/extend-a-workflow.mdx +7 -4
- package/content/resources/customization/extending-panels.mdx +55 -52
- package/content/resources/deployment/medusa-cloud.mdx +21 -20
- package/content/resources/deployment/self-host.mdx +123 -0
- package/content/resources/integrations/overview.mdx +38 -0
- package/content/resources/integrations/stripe-connect.mdx +39 -38
- package/content/resources/tutorials/add-a-block.mdx +25 -18
- package/content/resources/tutorials/add-a-widget.mdx +32 -23
- package/content/resources/tutorials/add-order-detail-button.mdx +33 -20
- package/content/resources/tutorials/attributes-and-variant-axes.mdx +28 -27
- package/content/resources/tutorials/build-a-block.mdx +26 -15
- package/content/resources/tutorials/custom-api-route.mdx +32 -20
- package/content/resources/tutorials/custom-panel-page.mdx +21 -12
- package/content/resources/tutorials/customize-navigation.mdx +30 -23
- package/content/resources/tutorials/extend-forms-and-tables.mdx +36 -28
- package/content/resources/tutorials/extend-onboarding.mdx +38 -35
- package/content/resources/tutorials/master-products-and-offers.mdx +28 -23
- package/content/telemetry.mdx +3 -3
- package/content/user-guide/admin/attributes/how-tos/create-an-attribute.mdx +64 -0
- package/content/user-guide/admin/attributes/how-tos/manage-possible-values.mdx +40 -0
- package/content/user-guide/admin/attributes/overview.mdx +22 -0
- package/content/user-guide/admin/commissions/how-tos/create-a-commission-rule.mdx +63 -0
- package/content/user-guide/admin/commissions/how-tos/edit-the-global-commission.mdx +48 -0
- package/content/user-guide/admin/commissions/how-tos/manage-a-commission-rule.mdx +45 -0
- package/content/user-guide/admin/commissions/overview.mdx +25 -0
- package/content/user-guide/admin/overview.mdx +20 -12
- package/content/user-guide/admin/product-requests/how-tos/review-a-new-product.mdx +58 -0
- package/content/user-guide/admin/product-requests/how-tos/review-a-product-edit.mdx +48 -0
- package/content/user-guide/admin/product-requests/overview.mdx +25 -0
- package/content/user-guide/vendor/offers/how-tos/create-an-offer.mdx +59 -0
- package/content/user-guide/vendor/offers/how-tos/update-prices-and-stock.mdx +40 -0
- package/content/user-guide/vendor/offers/overview.mdx +22 -0
- package/content/user-guide/vendor/onboarding.mdx +79 -0
- package/content/user-guide/vendor/orders/how-tos/fulfill-an-order.mdx +49 -0
- package/content/user-guide/vendor/orders/how-tos/mark-an-order-as-delivered.mdx +33 -0
- package/content/user-guide/vendor/orders/how-tos/process-a-return.mdx +42 -0
- package/content/user-guide/vendor/orders/how-tos/refund-an-order.mdx +38 -0
- package/content/user-guide/vendor/orders/how-tos/ship-an-order.mdx +40 -0
- package/content/user-guide/vendor/orders/overview.mdx +31 -0
- package/content/user-guide/vendor/overview.mdx +23 -12
- package/content/user-guide/vendor/products/how-tos/edit-a-product.mdx +44 -0
- package/content/user-guide/vendor/products/how-tos/submit-a-product.mdx +63 -0
- package/content/user-guide/vendor/products/overview.mdx +22 -0
- package/llms.txt +176 -142
- package/package.json +1 -1
- package/content/learn/concepts.mdx +0 -84
- package/content/learn/installation.mdx +0 -117
- package/content/learn/mirakl-alternative.mdx +0 -86
- package/content/migration/from-1-x-to-2-0.mdx +0 -152
- package/content/migration/from-2-0-to-2-1.mdx +0 -105
- package/content/migration/overview.mdx +0 -58
- package/content/references/api/store/search/search.mdx +0 -136
- package/content/references/modules/commission.mdx +0 -106
- package/content/references/modules/custom-fields.mdx +0 -45
- package/content/references/modules/media.mdx +0 -55
- package/content/references/modules/offer.mdx +0 -64
- package/content/references/modules/payout.mdx +0 -121
- package/content/references/modules/product-attribute.mdx +0 -111
- package/content/references/modules/product-edit.mdx +0 -80
- package/content/references/modules/search.mdx +0 -112
- package/content/references/modules/seller.mdx +0 -175
- package/content/references/panel-extension-api.mdx +0 -337
- package/content/references/workflows/cart/add-seller-shipping-method-to-cart.mdx +0 -48
- package/content/references/workflows/cart/complete-cart-with-split-orders.mdx +0 -36
- package/content/references/workflows/cart/list-seller-shipping-options-for-cart.mdx +0 -39
- package/content/references/workflows/cart/update-cart-seller-promotions.mdx +0 -42
- package/content/references/workflows/commission/batch-commission-rules.mdx +0 -49
- package/content/references/workflows/commission/create-commission-rates.mdx +0 -41
- package/content/references/workflows/commission/delete-commission-rates.mdx +0 -34
- package/content/references/workflows/commission/refresh-order-commission-lines.mdx +0 -30
- package/content/references/workflows/commission/update-commission-rates.mdx +0 -35
- package/content/references/workflows/media/set-category-images.mdx +0 -41
- package/content/references/workflows/media/set-collection-images.mdx +0 -41
- package/content/references/workflows/member/accept-member-invite.mdx +0 -33
- package/content/references/workflows/member/add-seller-member.mdx +0 -30
- package/content/references/workflows/member/create-member-invites.mdx +0 -34
- package/content/references/workflows/member/delete-member-invite.mdx +0 -24
- package/content/references/workflows/member/remove-seller-member.mdx +0 -28
- package/content/references/workflows/member/resend-member-invite.mdx +0 -28
- package/content/references/workflows/member/update-member-role.mdx +0 -28
- package/content/references/workflows/member/update-member.mdx +0 -35
- package/content/references/workflows/offer/batch-offer-inventory-items.mdx +0 -62
- package/content/references/workflows/offer/create-offers.mdx +0 -65
- package/content/references/workflows/offer/delete-offers.mdx +0 -35
- package/content/references/workflows/offer/update-offers.mdx +0 -53
- package/content/references/workflows/order/cancel-order-fulfillment.mdx +0 -34
- package/content/references/workflows/order/confirm-claim-request.mdx +0 -25
- package/content/references/workflows/order/confirm-exchange-request.mdx +0 -25
- package/content/references/workflows/order/confirm-order-edit-request.mdx +0 -25
- package/content/references/workflows/order/confirm-return-receive.mdx +0 -25
- package/content/references/workflows/order/create-order-fulfillment.mdx +0 -45
- package/content/references/workflows/order-group/get-order-group-detail.mdx +0 -29
- package/content/references/workflows/order-group/get-order-groups-list.mdx +0 -38
- package/content/references/workflows/overview.mdx +0 -72
- package/content/references/workflows/payout/create-onboarding.mdx +0 -36
- package/content/references/workflows/payout/create-payout-account.mdx +0 -33
- package/content/references/workflows/payout/create-payout.mdx +0 -30
- package/content/references/workflows/payout/process-payout-for-webhook.mdx +0 -34
- package/content/references/workflows/product/confirm-products.mdx +0 -48
- package/content/references/workflows/product/create-products.mdx +0 -63
- package/content/references/workflows/product/link-sellers-to-product-category.mdx +0 -40
- package/content/references/workflows/product/link-sellers-to-product.mdx +0 -40
- package/content/references/workflows/product/reject-product.mdx +0 -48
- package/content/references/workflows/product/request-product-change.mdx +0 -48
- package/content/references/workflows/product-attribute/add-product-attributes-to-product.mdx +0 -49
- package/content/references/workflows/product-attribute/create-and-link-product-attributes-to-product.mdx +0 -46
- package/content/references/workflows/product-attribute/create-product-attribute-values.mdx +0 -43
- package/content/references/workflows/product-attribute/create-product-attributes.mdx +0 -56
- package/content/references/workflows/product-attribute/delete-product-attribute-values.mdx +0 -30
- package/content/references/workflows/product-attribute/delete-product-attributes.mdx +0 -30
- package/content/references/workflows/product-attribute/remove-product-attributes-from-product.mdx +0 -29
- package/content/references/workflows/product-attribute/update-product-attribute-values.mdx +0 -44
- package/content/references/workflows/product-attribute/update-product-attributes-on-product.mdx +0 -41
- package/content/references/workflows/product-attribute/update-product-attributes.mdx +0 -48
- package/content/references/workflows/product-attribute/upsert-product-attribute-values.mdx +0 -43
- package/content/references/workflows/product-edit/auto-confirm-product-change.mdx +0 -39
- package/content/references/workflows/product-edit/cancel-product-change.mdx +0 -49
- package/content/references/workflows/product-edit/confirm-product-change.mdx +0 -57
- package/content/references/workflows/product-edit/create-product-change.mdx +0 -72
- package/content/references/workflows/product-edit/reject-product-change.mdx +0 -54
- package/content/references/workflows/product-edit/stage-product-change.mdx +0 -75
- package/content/references/workflows/seller/approve-seller.mdx +0 -36
- package/content/references/workflows/seller/create-seller-account.mdx +0 -59
- package/content/references/workflows/seller/create-seller-defaults.mdx +0 -22
- package/content/references/workflows/seller/create-sellers.mdx +0 -65
- package/content/references/workflows/seller/delete-seller-professional-details.mdx +0 -37
- package/content/references/workflows/seller/delete-sellers.mdx +0 -24
- package/content/references/workflows/seller/invite-seller.mdx +0 -28
- package/content/references/workflows/seller/suspend-seller.mdx +0 -37
- package/content/references/workflows/seller/terminate-seller.mdx +0 -37
- package/content/references/workflows/seller/unsuspend-seller.mdx +0 -36
- package/content/references/workflows/seller/unterminate-seller.mdx +0 -36
- package/content/references/workflows/seller/update-seller-address.mdx +0 -55
- package/content/references/workflows/seller/update-seller-payment-details.mdx +0 -52
- package/content/references/workflows/seller/update-seller-professional-details.mdx +0 -48
- package/content/references/workflows/seller/update-sellers.mdx +0 -57
- package/content/resources/ai/llms.mdx +0 -74
- package/content/resources/integrations/notifications.mdx +0 -39
- package/content/resources/integrations/search.mdx +0 -122
- package/content/resources/tutorials/configure-commissions.mdx +0 -127
- package/content/resources/tutorials/first-marketplace.mdx +0 -45
- package/content/resources/tutorials/handle-product-requests.mdx +0 -80
- package/content/resources/tutorials/import-export-products.mdx +0 -96
- package/content/resources/tutorials/seller-payouts-stripe.mdx +0 -89
- package/content/resources/tutorials/store-setup-checklist.mdx +0 -214
- package/content/tools/api-client.mdx +0 -155
- package/content/tools/cli.mdx +0 -196
- package/content/tools/dashboard-sdk.mdx +0 -35
|
@@ -3,7 +3,9 @@ title: "Configuration"
|
|
|
3
3
|
description: "withMercur() options, environment variables, and provider configuration."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
Mercur is configured through the standard Medusa config file.
|
|
6
|
+
Mercur is configured through the standard Medusa config file.
|
|
7
|
+
|
|
8
|
+
`withMercur()` wraps `defineConfig()` and wires the marketplace layer in. You pass it the same shape you would pass to Medusa, plus one Mercur-specific field.
|
|
7
9
|
|
|
8
10
|
## withMercur()
|
|
9
11
|
|
|
@@ -39,7 +41,7 @@ The option surface is Medusa's `InputConfigWithArrayModules` extended with:
|
|
|
39
41
|
|
|
40
42
|
| Option | Type | Purpose |
|
|
41
43
|
| --- | --- | --- |
|
|
42
|
-
| `projectConfig.http.vendorCors` | `string` | CORS origins for the Vendor API (`/vendor/*`)
|
|
44
|
+
| `projectConfig.http.vendorCors` | `string` | CORS origins for the Vendor API (`/vendor/*`). The only Mercur-specific option |
|
|
43
45
|
|
|
44
46
|
### What withMercur applies
|
|
45
47
|
|
|
@@ -47,10 +49,10 @@ The option surface is Medusa's `InputConfigWithArrayModules` extended with:
|
|
|
47
49
|
| --- | --- |
|
|
48
50
|
| Registers the core plugin | Appends `@mercurjs/core` to `plugins` unless already present |
|
|
49
51
|
| Registers RBAC | Appends the `@medusajs/medusa/rbac` module and forces `featureFlags.rbac = true`, so vendor role scoping works out of the box |
|
|
50
|
-
| Disables the Medusa admin | `admin.disable` defaults to `true
|
|
52
|
+
| Disables the Medusa admin | `admin.disable` defaults to `true`, since Mercur ships its own dashboards |
|
|
51
53
|
| Adjusts core middlewares | Replaces the Medusa middlewares that Mercur overrides (e.g. collections with media) |
|
|
52
54
|
|
|
53
|
-
Everything you pass is
|
|
55
|
+
Everything else you pass is forwarded to `defineConfig()` unchanged, so any valid Medusa configuration stays valid here.
|
|
54
56
|
|
|
55
57
|
## Environment variables
|
|
56
58
|
|
|
@@ -58,16 +60,16 @@ The starter (`apps/api` and projects created with `create-mercur-app`) reads:
|
|
|
58
60
|
|
|
59
61
|
| Variable | Purpose | Default |
|
|
60
62
|
| --- | --- | --- |
|
|
61
|
-
| `DATABASE_URL` | Postgres connection string |
|
|
63
|
+
| `DATABASE_URL` | Postgres connection string | Required |
|
|
62
64
|
| `REDIS_URL` | Redis for cache, event bus, workflow engine, locking | `redis://localhost:6379` |
|
|
63
|
-
| `STORE_CORS` | Storefront CORS origins |
|
|
64
|
-
| `ADMIN_CORS` | Admin panel CORS origins |
|
|
65
|
-
| `VENDOR_CORS` | Vendor panel CORS origins |
|
|
66
|
-
| `AUTH_CORS` | Auth endpoint CORS origins |
|
|
65
|
+
| `STORE_CORS` | Storefront CORS origins | Required |
|
|
66
|
+
| `ADMIN_CORS` | Admin panel CORS origins | Required |
|
|
67
|
+
| `VENDOR_CORS` | Vendor panel CORS origins | Required |
|
|
68
|
+
| `AUTH_CORS` | Auth endpoint CORS origins | Required |
|
|
67
69
|
| `JWT_SECRET` | JWT signing secret | `supersecret` (change in production) |
|
|
68
70
|
| `COOKIE_SECRET` | Cookie signing secret | `supersecret` (change in production) |
|
|
69
71
|
| `FILE_BACKEND_URL` | Public origin baked into uploaded file URLs | `http://localhost:9000/static` |
|
|
70
|
-
| `MERCUR_VENDOR_URL` | Vendor dashboard base URL used in member invite links | `""
|
|
72
|
+
| `MERCUR_VENDOR_URL` | Vendor dashboard base URL used in member invite links | `""`; can also be set via the seller module's `vendor_url` option |
|
|
71
73
|
| `NODE_ENV` | Environment selection | `development` |
|
|
72
74
|
|
|
73
75
|
## Dashboard modules
|
|
@@ -118,38 +120,19 @@ Register `@mercurjs/payout-stripe-connect` as a provider of the payout module:
|
|
|
118
120
|
|
|
119
121
|
| Option | Type | Default | Purpose |
|
|
120
122
|
| --- | --- | --- | --- |
|
|
121
|
-
| `apiKey` | `string` |
|
|
122
|
-
| `webhookSecret` | `string` |
|
|
123
|
+
| `apiKey` | `string` | Required | Stripe secret key |
|
|
124
|
+
| `webhookSecret` | `string` | Required | Verifies incoming Stripe webhook signatures |
|
|
123
125
|
| `accountValidation.detailsSubmitted` | `boolean` | `true` | Require onboarding details submitted before the account is active |
|
|
124
126
|
| `accountValidation.chargesEnabled` | `boolean` | `true` | Require charges enabled |
|
|
125
127
|
| `accountValidation.payoutsEnabled` | `boolean` | `true` | Require payouts enabled |
|
|
126
128
|
| `accountValidation.noOutstandingRequirements` | `boolean` | `true` | Treat pending Stripe requirements as `restricted` |
|
|
127
129
|
| `accountValidation.requiredCapabilities` | `string[]` | `[]` | Stripe capabilities that must be `active` |
|
|
128
130
|
|
|
129
|
-
The payout module itself also accepts scheduling options (`authorizationWindowMs`, `sellerActionWindowMs`, `captureSafetyBufferMs`, `requiredFulfillmentStatus`)
|
|
130
|
-
|
|
131
|
-
## Search provider
|
|
132
|
-
|
|
133
|
-
The search module needs no configuration — when no provider is given, the built-in in-memory Orama provider registers automatically. To use a custom provider:
|
|
134
|
-
|
|
135
|
-
```ts
|
|
136
|
-
{
|
|
137
|
-
resolve: "@mercurjs/core/modules/search",
|
|
138
|
-
options: {
|
|
139
|
-
provider: {
|
|
140
|
-
resolve: "./src/providers/my-search-provider",
|
|
141
|
-
id: "my-search",
|
|
142
|
-
options: { /* provider options */ },
|
|
143
|
-
},
|
|
144
|
-
},
|
|
145
|
-
}
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
The provider must extend `AbstractSearchProvider` — see the [Search module reference](/rc/references/modules/search#provider-contract).
|
|
131
|
+
The payout module itself also accepts scheduling options (`authorizationWindowMs`, `sellerActionWindowMs`, `captureSafetyBufferMs`, `requiredFulfillmentStatus`). See the [Payout module](/platform/payout/overview).
|
|
149
132
|
|
|
150
133
|
## Next steps
|
|
151
134
|
|
|
152
135
|
<CardGroup cols={2}>
|
|
153
|
-
<Card title="Installation" href="/
|
|
136
|
+
<Card title="Installation" href="/learn/introduction" />
|
|
154
137
|
<Card title="Stripe Connect integration" href="/rc/resources/integrations/stripe-connect" />
|
|
155
138
|
</CardGroup>
|
|
@@ -1,80 +1,62 @@
|
|
|
1
1
|
---
|
|
2
|
-
title: "
|
|
3
|
-
|
|
2
|
+
title: "Reference"
|
|
3
|
+
sidebarTitle: "Overview"
|
|
4
|
+
description: "Technical reference for Mercur's HTTP APIs, panel extensions, and configuration."
|
|
4
5
|
---
|
|
5
6
|
|
|
6
|
-
This section is the technical contract of the Mercur core plugin.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
<CardGroup cols={3}>
|
|
13
|
-
<Card title="Seller" href="/rc/references/modules/seller">
|
|
14
|
-
Sellers, members, invites, and order groups.
|
|
15
|
-
</Card>
|
|
16
|
-
<Card title="Commission" href="/rc/references/modules/commission">
|
|
17
|
-
Commission rates, rules, and per-order commission lines.
|
|
18
|
-
</Card>
|
|
19
|
-
<Card title="Payout" href="/rc/references/modules/payout">
|
|
20
|
-
Payout accounts, onboarding, payouts, and the provider interface.
|
|
21
|
-
</Card>
|
|
22
|
-
<Card title="Offer" href="/rc/references/modules/offer">
|
|
23
|
-
Per-seller listings binding a variant to SKU, price, and inventory.
|
|
24
|
-
</Card>
|
|
25
|
-
<Card title="Product Attribute" href="/rc/references/modules/product-attribute">
|
|
26
|
-
Configurable attributes, values, and variant axes on native product options.
|
|
27
|
-
</Card>
|
|
28
|
-
<Card title="Product Edit" href="/rc/references/modules/product-edit">
|
|
29
|
-
Product change requests and the approval queue.
|
|
30
|
-
</Card>
|
|
31
|
-
<Card title="Media" href="/rc/references/modules/media">
|
|
32
|
-
Image galleries, thumbnails, banners, and icons for categories and collections.
|
|
33
|
-
</Card>
|
|
34
|
-
<Card title="Search" href="/rc/references/modules/search">
|
|
35
|
-
Provider-agnostic search with the built-in Orama provider.
|
|
36
|
-
</Card>
|
|
37
|
-
<Card title="Custom Fields" href="/rc/references/modules/custom-fields">
|
|
38
|
-
Extra columns on any entity without a custom module.
|
|
39
|
-
</Card>
|
|
40
|
-
</CardGroup>
|
|
7
|
+
This section is the technical contract of the Mercur core plugin. The
|
|
8
|
+
[Learn](/learn/introduction) tab explains concepts and the
|
|
9
|
+
[Platform](/platform/store/overview) tab documents each domain's data models,
|
|
10
|
+
workflows, service, and events. These pages cover the HTTP APIs, the panel
|
|
11
|
+
extension helpers, and configuration.
|
|
41
12
|
|
|
42
13
|
## HTTP API
|
|
43
14
|
|
|
44
|
-
Mercur extends the Medusa server with three route surfaces. Start with the
|
|
15
|
+
Mercur extends the Medusa server with three route surfaces. Start with the
|
|
16
|
+
conventions page: authentication, seller scoping, and pagination work the same
|
|
17
|
+
way across all of them.
|
|
45
18
|
|
|
46
19
|
<CardGroup cols={2}>
|
|
47
|
-
<Card title="API conventions" href="/
|
|
20
|
+
<Card title="API conventions" href="/references/api/conventions">
|
|
48
21
|
Authentication, seller scoping, pagination, field selection, and webhooks.
|
|
49
22
|
</Card>
|
|
50
|
-
<Card title="Admin API" href="/
|
|
23
|
+
<Card title="Admin API" href="/references/api/admin">
|
|
51
24
|
Operator routes under <code>/admin/*</code>.
|
|
52
25
|
</Card>
|
|
53
|
-
<Card title="Vendor API" href="/
|
|
26
|
+
<Card title="Vendor API" href="/references/api/vendor">
|
|
54
27
|
Seller-scoped routes under <code>/vendor/*</code>.
|
|
55
28
|
</Card>
|
|
56
|
-
<Card title="Store API" href="/
|
|
29
|
+
<Card title="Store API" href="/references/api/store">
|
|
57
30
|
Storefront routes under <code>/store/*</code>.
|
|
58
31
|
</Card>
|
|
59
32
|
</CardGroup>
|
|
60
33
|
|
|
61
|
-
## Panel
|
|
34
|
+
## Panel extensions
|
|
62
35
|
|
|
63
|
-
|
|
36
|
+
File-based helpers for extending the Admin and Vendor panels without forking.
|
|
64
37
|
|
|
65
|
-
<CardGroup cols={
|
|
66
|
-
<Card title="
|
|
67
|
-
|
|
38
|
+
<CardGroup cols={2}>
|
|
39
|
+
<Card title="Overview" href="/references/panel-extensions/overview">
|
|
40
|
+
Typed targets, persistence, and how the helpers fit together.
|
|
41
|
+
</Card>
|
|
42
|
+
<Card title="Widgets" href="/references/panel-extensions/widgets">
|
|
43
|
+
<code>defineWidgetConfig</code>: zones, config, and component props.
|
|
44
|
+
</Card>
|
|
45
|
+
<Card title="Custom Fields" href="/references/panel-extensions/custom-fields">
|
|
46
|
+
<code>defineCustomFieldsConfig</code>: forms, displays, and list columns.
|
|
47
|
+
</Card>
|
|
48
|
+
<Card title="Create a new page" href="/references/panel-extensions/create-page">
|
|
49
|
+
<code>defineNavigationConfig</code> and <code>createFormHelper</code>.
|
|
68
50
|
</Card>
|
|
69
51
|
</CardGroup>
|
|
70
52
|
|
|
71
|
-
##
|
|
53
|
+
## Configuration
|
|
72
54
|
|
|
73
55
|
<CardGroup cols={2}>
|
|
74
|
-
<Card title="
|
|
75
|
-
Every workflow exported by <code>@mercurjs/core</code>, grouped by domain.
|
|
76
|
-
</Card>
|
|
77
|
-
<Card title="Configuration" href="/rc/references/configuration">
|
|
56
|
+
<Card title="Configuration" href="/references/configuration">
|
|
78
57
|
<code>withMercur()</code>, environment variables, and provider options.
|
|
79
58
|
</Card>
|
|
59
|
+
<Card title="Platform modules" href="/platform/store/overview">
|
|
60
|
+
Data models, workflows, service, and events for each domain.
|
|
61
|
+
</Card>
|
|
80
62
|
</CardGroup>
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Create a new page"
|
|
3
|
+
sidebarTitle: "Create new page"
|
|
4
|
+
description: "Add a page to the admin or vendor panel with file-based routing, then register it in the sidebar."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
A page is a React component mounted at a route. Pages are file-based. You drop a
|
|
8
|
+
`page.tsx` under a panel's `src/routes/` folder and the SDK registers it at build
|
|
9
|
+
time, the same way [Next.js](https://nextjs.org) and [Remix](https://remix.run)
|
|
10
|
+
map folders to routes.
|
|
11
|
+
|
|
12
|
+
This guide walks through creating a page, then documents the routing conventions,
|
|
13
|
+
the sidebar config, and the `defineNavigationConfig` and `createFormHelper`
|
|
14
|
+
helpers.
|
|
15
|
+
|
|
16
|
+
## Create a page
|
|
17
|
+
|
|
18
|
+
<Steps>
|
|
19
|
+
<Step title="Add a page file">
|
|
20
|
+
Create `page.tsx` in a new folder under `src/routes/`. The folder path becomes
|
|
21
|
+
the URL, so this file mounts at `/erp-sync`.
|
|
22
|
+
|
|
23
|
+
```tsx apps/vendor/src/routes/erp-sync/page.tsx
|
|
24
|
+
const ErpSyncPage = () => {
|
|
25
|
+
return <div>ERP sync</div>
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default ErpSyncPage
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The default export is the only required part. Only files named `page` register
|
|
32
|
+
as routes, so you can co-locate a `loader.ts` or components in the same folder.
|
|
33
|
+
</Step>
|
|
34
|
+
|
|
35
|
+
<Step title="Add it to the sidebar">
|
|
36
|
+
A page has no sidebar entry until it exports a `config` with a `label`. The
|
|
37
|
+
config is a plain object.
|
|
38
|
+
|
|
39
|
+
```tsx apps/vendor/src/routes/erp-sync/page.tsx
|
|
40
|
+
import { ArrowsPointingOut } from "@medusajs/icons"
|
|
41
|
+
|
|
42
|
+
export const config = {
|
|
43
|
+
label: "ERP sync",
|
|
44
|
+
icon: ArrowsPointingOut,
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
</Step>
|
|
48
|
+
|
|
49
|
+
<Step title="Run the panel">
|
|
50
|
+
Start the panel and open the route. The page renders and its sidebar entry
|
|
51
|
+
appears.
|
|
52
|
+
|
|
53
|
+
```bash Terminal
|
|
54
|
+
bun run dev
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The vendor panel runs on `http://localhost:7001` and the admin panel on
|
|
58
|
+
`http://localhost:7000`.
|
|
59
|
+
</Step>
|
|
60
|
+
</Steps>
|
|
61
|
+
|
|
62
|
+
## Route paths
|
|
63
|
+
|
|
64
|
+
Folder and file names map to path segments. Wrap a segment in brackets or
|
|
65
|
+
parentheses to make it dynamic or optional.
|
|
66
|
+
|
|
67
|
+
| Folder segment | Route path | Description |
|
|
68
|
+
| -------------- | ------------ | ---------------------------------------------------- |
|
|
69
|
+
| `products` | `/products` | Static segment. |
|
|
70
|
+
| `[id]` | `/:id` | Dynamic parameter. |
|
|
71
|
+
| `[[id]]` | `/:id?` | Optional dynamic parameter. |
|
|
72
|
+
| `[*]` | `/*` | Splat. Matches the rest of the path. |
|
|
73
|
+
| `[[*]]` | `/*?` | Optional splat. |
|
|
74
|
+
| `(preview)` | `/preview?` | Optional static segment. |
|
|
75
|
+
| `@modal` | nested route | Parallel segment. Renders inside its parent's route. |
|
|
76
|
+
|
|
77
|
+
Read a dynamic segment with React Router's `useParams()`. A file at
|
|
78
|
+
`src/routes/orders/[id]/page.tsx` mounts at `/orders/:id`.
|
|
79
|
+
|
|
80
|
+
## Where the page mounts
|
|
81
|
+
|
|
82
|
+
The route path and the page's `config.public` flag decide which layout wraps the
|
|
83
|
+
page.
|
|
84
|
+
|
|
85
|
+
| Layout | When | Example route |
|
|
86
|
+
| -------- | ----------------------------------------------- | ------------------------------------------------- |
|
|
87
|
+
| Main | Default. Any protected route. | `src/routes/erp-sync/page.tsx` |
|
|
88
|
+
| Settings | Route path starts with `/settings/`. | `src/routes/settings/erp/page.tsx` |
|
|
89
|
+
| Public | `config.public` is `true`. Renders before auth. | `src/routes/status/page.tsx` with `config.public` |
|
|
90
|
+
|
|
91
|
+
Main and settings routes render inside the authenticated shell. Public routes
|
|
92
|
+
render on their own, so use them for pages a signed-out user must reach.
|
|
93
|
+
|
|
94
|
+
## Sidebar config
|
|
95
|
+
|
|
96
|
+
The `config` object controls the page's sidebar entry.
|
|
97
|
+
|
|
98
|
+
| Field | Type | Description |
|
|
99
|
+
| --------------- | -------------------------- | -------------------------------------------------------------- |
|
|
100
|
+
| `label` | `string` | Sidebar label. A page with no `label` has no sidebar entry. |
|
|
101
|
+
| `icon` | `ComponentType` (optional) | Sidebar icon, from `@medusajs/icons`. |
|
|
102
|
+
| `rank` | `number` (optional) | Order among sibling items. Lower ranks first. |
|
|
103
|
+
| `nested` | `string` (optional) | Parent item id to nest this entry under. |
|
|
104
|
+
| `translationNs` | `string` (optional) | i18n namespace used to resolve `label` as a translation key. |
|
|
105
|
+
| `public` | `boolean` (optional) | Render the route before authentication under the public layout. |
|
|
106
|
+
|
|
107
|
+
<Note>
|
|
108
|
+
A page can exist without a sidebar entry. Omit `label` when the route is reached
|
|
109
|
+
from a link or a widget rather than the sidebar.
|
|
110
|
+
</Note>
|
|
111
|
+
|
|
112
|
+
## Load data for a page
|
|
113
|
+
|
|
114
|
+
Export a `loader` to fetch data before the component renders, and a `handle` to
|
|
115
|
+
attach route metadata such as a breadcrumb. Both are React Router route options,
|
|
116
|
+
picked up as named exports.
|
|
117
|
+
|
|
118
|
+
```tsx apps/vendor/src/routes/erp-sync/page.tsx
|
|
119
|
+
import type { LoaderFunction } from "react-router-dom"
|
|
120
|
+
|
|
121
|
+
export const loader: LoaderFunction = async () => {
|
|
122
|
+
return { syncedAt: new Date().toISOString() }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export const handle = {
|
|
126
|
+
breadcrumb: () => "ERP sync",
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
Read the loader's result with `useLoaderData()` inside the component.
|
|
131
|
+
|
|
132
|
+
## Reshape built-in navigation
|
|
133
|
+
|
|
134
|
+
Use `defineNavigationConfig` to reorder, hide, relabel, or re-parent built-in
|
|
135
|
+
sidebar items. It lives in a single host-owned file, `src/_navigation.ts`. Blocks
|
|
136
|
+
cannot contribute navigation overrides.
|
|
137
|
+
|
|
138
|
+
```ts apps/vendor/src/_navigation.ts
|
|
139
|
+
import { defineNavigationConfig } from "@mercurjs/dashboard-sdk"
|
|
140
|
+
|
|
141
|
+
export default defineNavigationConfig({
|
|
142
|
+
items: [
|
|
143
|
+
{ id: "orders", rank: 0 },
|
|
144
|
+
{ id: "price-lists", hidden: true },
|
|
145
|
+
{ id: "payouts", label: "settlements" },
|
|
146
|
+
{ id: "categories", nested: null, rank: 1 },
|
|
147
|
+
{ id: "campaigns", nested: "orders" },
|
|
148
|
+
],
|
|
149
|
+
})
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Each entry is a `NavItemOverride`.
|
|
153
|
+
|
|
154
|
+
| Field | Type | Description |
|
|
155
|
+
| -------- | -------------------------------- | ------------------------------------------------------------------------------- |
|
|
156
|
+
| `id` | `NavItemId` | Built-in item to override, top-level or nested. Typed against the panel registry. |
|
|
157
|
+
| `rank` | `number` (optional) | Order within the item's parent, or among top-level items. |
|
|
158
|
+
| `hidden` | `boolean` (optional) | Remove from the sidebar. The route may still be reachable directly. |
|
|
159
|
+
| `label` | `string` (optional) | i18n key or literal replacing the item's label. |
|
|
160
|
+
| `icon` | `ComponentType` (optional) | Icon component replacing the item's icon, from `@medusajs/icons`. |
|
|
161
|
+
| `nested` | `NavParentId \| null` (optional) | Re-parent under a built-in parent id. `null` promotes a nested item to top level. |
|
|
162
|
+
|
|
163
|
+
Navigation overrides reshape existing items only. To add a new item, register a
|
|
164
|
+
page with a `config.label` as shown above.
|
|
165
|
+
|
|
166
|
+
## Type a page's forms
|
|
167
|
+
|
|
168
|
+
`createFormHelper<T>()` returns Medusa's Zod surface for describing field
|
|
169
|
+
validation and value types. Import it from `@mercurjs/dashboard-shared`.
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import { createFormHelper } from "@mercurjs/dashboard-shared"
|
|
173
|
+
|
|
174
|
+
const form = createFormHelper<ProductWithMeta>()
|
|
175
|
+
|
|
176
|
+
form.define({ validation, defaultValue, label, description, placeholder, component })
|
|
177
|
+
form.string() / form.number() / form.boolean() / form.date()
|
|
178
|
+
form.array() / form.object() / form.null() / form.nullable() / form.coerce
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
The generated registry types the target: which zone, tab, and field ids exist.
|
|
182
|
+
The Zod `validation` types the value. See [Custom Fields](/references/panel-extensions/custom-fields)
|
|
183
|
+
for where `form.define` fields are attached.
|
|
184
|
+
|
|
185
|
+
## Next steps
|
|
186
|
+
|
|
187
|
+
<CardGroup cols={2}>
|
|
188
|
+
<Card title="Widgets" href="/references/panel-extensions/widgets">
|
|
189
|
+
Render a component in a slot on an existing page.
|
|
190
|
+
</Card>
|
|
191
|
+
<Card title="Custom Fields" href="/references/panel-extensions/custom-fields">
|
|
192
|
+
Add fields, section rows, and list columns to a built-in model.
|
|
193
|
+
</Card>
|
|
194
|
+
</CardGroup>
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Custom Fields"
|
|
3
|
+
sidebarTitle: "Custom Fields"
|
|
4
|
+
description: "Add fields, detail rows, section actions, and list columns to a built-in model."
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
Custom fields extend a built-in model's forms, detail sections, and list table
|
|
8
|
+
without forking the page. You add a field to the create and edit forms, a row to
|
|
9
|
+
the detail view, an action to a section menu, or a column to the list.
|
|
10
|
+
|
|
11
|
+
You write one file per model under `src/custom-fields/` and default-export a
|
|
12
|
+
`defineCustomFieldsConfig`. The config targets a model, optionally fetches linked
|
|
13
|
+
module data alongside it, and describes what to add to each surface.
|
|
14
|
+
|
|
15
|
+
## Add a custom field
|
|
16
|
+
|
|
17
|
+
<Steps>
|
|
18
|
+
<Step title="Create a custom-fields file">
|
|
19
|
+
Create a file under `src/custom-fields/` and default-export
|
|
20
|
+
`defineCustomFieldsConfig` with the model you want to extend. Start with
|
|
21
|
+
`product`.
|
|
22
|
+
|
|
23
|
+
```tsx apps/vendor/src/custom-fields/product.tsx
|
|
24
|
+
import { defineCustomFieldsConfig } from "@mercurjs/dashboard-sdk"
|
|
25
|
+
|
|
26
|
+
export default defineCustomFieldsConfig({
|
|
27
|
+
model: "product",
|
|
28
|
+
})
|
|
29
|
+
```
|
|
30
|
+
</Step>
|
|
31
|
+
|
|
32
|
+
<Step title="Describe the field with `createFormHelper`">
|
|
33
|
+
Import `createFormHelper` from `@mercurjs/dashboard-shared` and turn a Zod
|
|
34
|
+
schema into an input type and validation. The Zod schema drives both the
|
|
35
|
+
default input and the validation.
|
|
36
|
+
|
|
37
|
+
```tsx apps/vendor/src/custom-fields/product.tsx
|
|
38
|
+
import { createFormHelper } from "@mercurjs/dashboard-shared"
|
|
39
|
+
|
|
40
|
+
type ProductWithMeta = { metadata?: Record<string, unknown> }
|
|
41
|
+
const form = createFormHelper<ProductWithMeta>()
|
|
42
|
+
```
|
|
43
|
+
</Step>
|
|
44
|
+
|
|
45
|
+
<Step title="Add the field to a form">
|
|
46
|
+
Add the field to a built-in form zone and tab. This injects an `ERP ID` field
|
|
47
|
+
into the product edit form.
|
|
48
|
+
|
|
49
|
+
```tsx apps/vendor/src/custom-fields/product.tsx
|
|
50
|
+
export default defineCustomFieldsConfig({
|
|
51
|
+
model: "product",
|
|
52
|
+
forms: [
|
|
53
|
+
{
|
|
54
|
+
zone: "edit",
|
|
55
|
+
tab: "general",
|
|
56
|
+
fields: {
|
|
57
|
+
erp_id: form.define({
|
|
58
|
+
validation: form.string().nullish(),
|
|
59
|
+
defaultValue: (data) => (data?.metadata?.erp_id as string) ?? "",
|
|
60
|
+
label: "ERP ID",
|
|
61
|
+
placeholder: "ERP-000",
|
|
62
|
+
}),
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
})
|
|
67
|
+
```
|
|
68
|
+
</Step>
|
|
69
|
+
|
|
70
|
+
<Step title="Run the panel">
|
|
71
|
+
Start the panel and open the product edit form. The field renders in its tab.
|
|
72
|
+
|
|
73
|
+
```bash Terminal
|
|
74
|
+
bun run dev
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For `product`, values submit under `additional_data` and persist onto the
|
|
78
|
+
product's `metadata`. See [Persistence](#persistence) for other models.
|
|
79
|
+
</Step>
|
|
80
|
+
</Steps>
|
|
81
|
+
|
|
82
|
+
## Configuration
|
|
83
|
+
|
|
84
|
+
`defineCustomFieldsConfig` takes one object.
|
|
85
|
+
|
|
86
|
+
| Field | Type | Description |
|
|
87
|
+
| ---------- | ---------------------- | --------------------------------------------------------------------------------------------------- |
|
|
88
|
+
| `model` | `CustomFieldModel` | Target model. Start with `"product"`. Typed against `CustomFieldsRegistry`. |
|
|
89
|
+
| `link` | `string \| string[]` | Module link or links fetched alongside the entity. Their data is available to columns and displays. |
|
|
90
|
+
| `forms` | `CustomFormEntry[]` | Fields injected into built-in create, edit, and onboarding forms. |
|
|
91
|
+
| `displays` | `CustomDisplayEntry[]` | Field replace, remove, or add, plus `ActionMenu` actions on detail sections. |
|
|
92
|
+
| `list` | `CustomListExtension` | Columns, bulk actions, filters, and view defaults on the model's list table. |
|
|
93
|
+
|
|
94
|
+
## Add fields to a form
|
|
95
|
+
|
|
96
|
+
Inject fields into a built-in create, edit, or onboarding form.
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
forms: [
|
|
100
|
+
{
|
|
101
|
+
zone: "edit", // "create" | "edit" | "organize" | "attributes" | "onboarding"
|
|
102
|
+
tab: "general", // TabbedForm tab id, or wizard step id for zone: "onboarding"
|
|
103
|
+
fields: {
|
|
104
|
+
erp_id: form.define({
|
|
105
|
+
validation: form.string().nullish(),
|
|
106
|
+
defaultValue: (data) => (data?.metadata?.erp_id as string) ?? "",
|
|
107
|
+
label: "ERP ID",
|
|
108
|
+
description: "External system identifier",
|
|
109
|
+
placeholder: "ERP-000",
|
|
110
|
+
component: MyErpInput,
|
|
111
|
+
}),
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
]
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Each field is a `CustomFormField`.
|
|
118
|
+
|
|
119
|
+
| Field | Type | Description |
|
|
120
|
+
| -------------- | -------------------------------- | ------------------------------------------------------------- |
|
|
121
|
+
| `validation` | Zod schema | Drives both the default input type and validation. |
|
|
122
|
+
| `defaultValue` | `unknown \| ((data) => unknown)` | Static value or a resolver from the loaded entity. |
|
|
123
|
+
| `label` | `string` (optional) | Field label. |
|
|
124
|
+
| `description` | `string` (optional) | Help text below the input. |
|
|
125
|
+
| `placeholder` | `string` (optional) | Input placeholder. |
|
|
126
|
+
| `component` | `ComponentType` (optional) | Custom render. Falls back to a default input for the Zod type. |
|
|
127
|
+
|
|
128
|
+
<Warning>
|
|
129
|
+
**A form-field `component` receives no props.** It renders as `<Component />`
|
|
130
|
+
inside the field's `additional_data.<field>` React Hook Form context. Read and
|
|
131
|
+
write the value with `useFormContext()` or `useController()`, and render through
|
|
132
|
+
the `Form.Field` and `Form.Item` chain. Do not use a raw `Controller`. Values
|
|
133
|
+
live in form state under `additional_data`. For `product`, custom fields persist
|
|
134
|
+
onto the product's `metadata`.
|
|
135
|
+
</Warning>
|
|
136
|
+
|
|
137
|
+
## Extend detail sections
|
|
138
|
+
|
|
139
|
+
Add, replace, or remove fields on a detail section, and add actions to its
|
|
140
|
+
`ActionMenu`.
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
displays: [
|
|
144
|
+
{
|
|
145
|
+
zone: "general", // an existing detail section id
|
|
146
|
+
fields: [
|
|
147
|
+
{ id: "erp_id", component: ErpRow }, // ADD (unknown id -> new row)
|
|
148
|
+
{ id: "status", component: BrandedStatusBadge }, // REPLACE a built-in field
|
|
149
|
+
{ id: "created_by", component: null }, // REMOVE a built-in field
|
|
150
|
+
],
|
|
151
|
+
actions: [
|
|
152
|
+
{ rank: 0, component: SyncErpAction }, // add to the section's ActionMenu
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
]
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
`fields[]` is `CustomDisplayField`.
|
|
159
|
+
|
|
160
|
+
| Field | Type | Description |
|
|
161
|
+
| ----------- | ---------------------------------- | -------------------------------------------------------------------------------------- |
|
|
162
|
+
| `id` | `displayFieldIds \| (string & {})` | Built-in field id, which autocompletes, to replace or remove. Any other string adds a new row. |
|
|
163
|
+
| `component` | `ComponentType<{ data? }> \| null` | Render component, or `null` to remove a built-in field. |
|
|
164
|
+
|
|
165
|
+
A display `component` receives the loaded detail entity as `data`, including any
|
|
166
|
+
`link`ed module data. If the config declares `link: "brand"`, read it off
|
|
167
|
+
`data.brand`.
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
const BrandRow = ({ data }: { data?: { brand?: { name: string } } }) => (
|
|
171
|
+
<Text>{data?.brand?.name}</Text>
|
|
172
|
+
)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
`actions[]` is `SectionAction`, the same shape as list `bulkActions`.
|
|
176
|
+
|
|
177
|
+
| Field | Type | Description |
|
|
178
|
+
| ----------- | -------------------------- | ------------------------------------------------------- |
|
|
179
|
+
| `rank` | `number` (optional) | Position within the section's `ActionMenu`. |
|
|
180
|
+
| `component` | `ComponentType<{ data? }>` | Owns its own label, icon, group placement, and `onClick`. |
|
|
181
|
+
|
|
182
|
+
## Extend the list table
|
|
183
|
+
|
|
184
|
+
Override or add columns, register bulk actions and filters, and set view defaults
|
|
185
|
+
on the model's list table.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
list: {
|
|
189
|
+
columns: [
|
|
190
|
+
{ id: "title", component: ({ value }) => <strong>{value}</strong> }, // override a cell
|
|
191
|
+
{ id: "brand_name", header: "Brand", component: ({ row }) => row.brand?.name }, // add from link
|
|
192
|
+
],
|
|
193
|
+
bulkActions: [{ rank: 0, component: ArchiveBulkAction }],
|
|
194
|
+
filters: [/* add or remove list filters */],
|
|
195
|
+
viewDefaults: {
|
|
196
|
+
columnVisibility: { created_at: false },
|
|
197
|
+
columnOrder: ["title", "sku", "erp_id"],
|
|
198
|
+
},
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
`columns[]` is `CustomColumn`.
|
|
203
|
+
|
|
204
|
+
| Field | Type | Description |
|
|
205
|
+
| ----------- | -------------------------------------------- | ------------------------------------------------------------------- |
|
|
206
|
+
| `id` | `string` | Column id. Matches a built-in column to override, or adds a new one. |
|
|
207
|
+
| `header` | `string` (optional) | Column header text, for added columns. |
|
|
208
|
+
| `component` | `ComponentType<{ row?, value? }>` (optional) | Cell renderer. Receives the full `row` and the cell `value`. |
|
|
209
|
+
|
|
210
|
+
<Note>
|
|
211
|
+
**Bulk-action rendering is deferred in the MVP.** `bulkActions` are accepted and
|
|
212
|
+
surfaced by the config, but not yet mounted into the list toolbar.
|
|
213
|
+
</Note>
|
|
214
|
+
|
|
215
|
+
<Warning>
|
|
216
|
+
**The vendor product list is field-constrained.** It must use the curated fields
|
|
217
|
+
from `useProductTableQuery`. The SDK merges `link` fetches with the `+` and `-`
|
|
218
|
+
convention, never bare fields, or the list returns a 500. You never hand-write
|
|
219
|
+
the field list. The `link` declaration drives it.
|
|
220
|
+
</Warning>
|
|
221
|
+
|
|
222
|
+
## Fetch linked module data
|
|
223
|
+
|
|
224
|
+
Declare `link` to fetch a module link alongside the entity. Its data rides on the
|
|
225
|
+
`data` passed to displays and on the `row` passed to columns.
|
|
226
|
+
|
|
227
|
+
```tsx
|
|
228
|
+
export default defineCustomFieldsConfig({
|
|
229
|
+
model: "product",
|
|
230
|
+
link: "brand", // string | string[]
|
|
231
|
+
displays: [/* read data.brand here */],
|
|
232
|
+
list: {/* read row.brand here */},
|
|
233
|
+
})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Persistence
|
|
237
|
+
|
|
238
|
+
<Warning>
|
|
239
|
+
**The MVP is a UI surface only.** Custom fields render, validate, and display
|
|
240
|
+
through the built-in forms, sections, and tables. There is no generic core-side
|
|
241
|
+
write path. For `product`, values submit under `additional_data` and persist
|
|
242
|
+
onto `metadata`. To store data for other models, wire your own route or
|
|
243
|
+
workflow, or use the backend
|
|
244
|
+
[Custom Fields module](/rc/resources/customization/custom-fields).
|
|
245
|
+
</Warning>
|
|
246
|
+
|
|
247
|
+
## Next steps
|
|
248
|
+
|
|
249
|
+
<CardGroup cols={2}>
|
|
250
|
+
<Card title="Widgets" href="/references/panel-extensions/widgets">
|
|
251
|
+
Render a component in a slot on an existing page.
|
|
252
|
+
</Card>
|
|
253
|
+
<Card title="Create a new page" href="/references/panel-extensions/create-page">
|
|
254
|
+
Add a route with file-based routing and register it in the sidebar.
|
|
255
|
+
</Card>
|
|
256
|
+
</CardGroup>
|