Skip to content

Commit b46bbfa

Browse files
authored
docs: fix input type of some hooks in workflow reference (medusajs#12995)
1 parent 9c94580 commit b46bbfa

File tree

6 files changed

+21
-9
lines changed
  • www
    • apps/resources
      • generated
      • references/core_flows/Cart/Workflows_Cart/functions
        • core_flows.Cart.Workflows_Cart.addToCartWorkflow
        • core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow
        • core_flows.Cart.Workflows_Cart.updateLineItemInCartWorkflow
    • utils/packages

6 files changed

+21
-9
lines changed

www/apps/resources/generated/edit-dates.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -628,13 +628,13 @@ export const generatedEditDates = {
628628
"references/core_flows/Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.setTaxLinesForItemsStep/page.mdx": "2025-01-17T16:43:22.421Z",
629629
"references/core_flows/Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx": "2025-06-25T10:11:28.124Z",
630630
"references/core_flows/Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartPaymentsStep/page.mdx": "2025-06-25T10:11:28.183Z",
631-
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx": "2025-07-14T09:31:27.068Z",
631+
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx": "2025-07-18T14:23:49.522Z",
632632
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.confirmVariantInventoryWorkflow/page.mdx": "2025-07-14T09:31:27.089Z",
633633
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.createCartWorkflow/page.mdx": "2025-07-14T09:31:27.142Z",
634634
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.createPaymentCollectionForCartWorkflow/page.mdx": "2025-07-14T09:31:27.161Z",
635635
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.listShippingOptionsForCartWorkflow/page.mdx": "2025-07-14T09:31:27.186Z",
636636
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.updateCartWorkflow/page.mdx": "2025-07-14T09:31:27.242Z",
637-
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.updateLineItemInCartWorkflow/page.mdx": "2025-07-14T09:31:27.257Z",
637+
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.updateLineItemInCartWorkflow/page.mdx": "2025-07-18T14:23:49.605Z",
638638
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.updateTaxLinesWorkflow/page.mdx": "2025-07-14T09:31:27.272Z",
639639
"references/core_flows/Cart/core_flows.Cart.Steps_Cart/page.mdx": "2025-02-11T11:36:38.987Z",
640640
"references/core_flows/Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx": "2025-01-13T17:30:23.158Z",
@@ -5820,7 +5820,7 @@ export const generatedEditDates = {
58205820
"references/utils/PromotionUtils/enums/utils.PromotionUtils.PromotionStatus/page.mdx": "2025-01-17T16:43:30.762Z",
58215821
"references/core_flows/Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateAndReturnShippingMethodsDataStep/page.mdx": "2025-03-04T13:33:40.459Z",
58225822
"references/core_flows/Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartStep/page.mdx": "2025-05-20T07:51:40.753Z",
5823-
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx": "2025-07-14T09:31:27.196Z",
5823+
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx": "2025-07-18T14:23:49.576Z",
58245824
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.refreshCartShippingMethodsWorkflow/page.mdx": "2025-07-14T09:31:27.204Z",
58255825
"references/core_flows/Order/Workflows_Order/functions/core_flows.Order.Workflows_Order.createOrUpdateOrderPaymentCollectionWorkflow/page.mdx": "2025-07-14T09:31:28.994Z",
58265826
"references/core_flows/Payment_Collection/Workflows_Payment_Collection/functions/core_flows.Payment_Collection.Workflows_Payment_Collection.deleteRefundReasonsWorkflow/page.mdx": "2025-07-14T09:31:30.133Z",

www/apps/resources/references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ addToCartWorkflow.hooks.validate(
210210

211211
Handlers consuming this hook accept the following input.
212212

213-
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-1)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
213+
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-1)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AddToCartWorkflowInputDTO](../../../../../types/interfaces/types.AddToCartWorkflowInputDTO/page.mdx) & [AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart to add items to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"[CreateCartCreateLineItemDTO](../../../../../types/interfaces/types.CreateCartCreateLineItemDTO/page.mdx)[]","description":"The items to add to the cart.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
214214

215215
### setPricingContext
216216

www/apps/resources/references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.refreshCartItemsWorkflow/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,4 @@ refreshCartItemsWorkflow.hooks.beforeRefreshingPaymentCollection(
226226

227227
Handlers consuming this hook accept the following input.
228228

229-
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-11)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="beforeRefreshingPaymentCollection"/>
229+
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-11)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[RefreshCartItemsWorkflowInput](../../../../types/core_flows.RefreshCartItemsWorkflowInput/page.mdx) & [AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The cart's ID.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"promo_codes","type":"`string`[]","description":"The promotion codes applied on the cart.\nThese promotion codes will replace previously applied codes.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"force_refresh","type":"`boolean`","description":"Force refresh the cart items","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"`any`[]","description":"The items to refresh.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"shipping_methods","type":"`any`[]","description":"The shipping methods to refresh.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"force_tax_calculation","type":"`boolean`","description":"Whether to force re-calculating tax amounts, which\nmay include sending requests to a third-part tax provider, depending\non the configurations of the cart's tax region.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="beforeRefreshingPaymentCollection"/>

www/apps/resources/references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.updateLineItemInCartWorkflow/page.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ updateLineItemInCartWorkflow.hooks.validate(
185185

186186
Handlers consuming this hook accept the following input.
187187

188-
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-19)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
188+
<TypeList types={[{"name":"input","type":"[input](../../../core_flows.Cart.Workflows_Cart/page.mdx#__type-19)","description":"The input data for the hook.","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"input","type":"[UpdateLineItemInCartWorkflowInputDTO](../../../../../types/interfaces/types.UpdateLineItemInCartWorkflowInputDTO/page.mdx) & [AdditionalData](../../../../../types/HttpTypes/types/types.HttpTypes.AdditionalData/page.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[{"name":"cart_id","type":"`string`","description":"The ID of the cart that the line item belongs to.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"item_id","type":"`string`","description":"The ID of the line item to update.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"update","type":"Partial&#60;[UpdateLineItemDTO](../../../../../cart/interfaces/cart.UpdateLineItemDTO/page.mdx)&#62;","description":"The details to update in the line item.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"additional_data","type":"`Record<string, unknown>`","description":"Additional data that can be passed through the `additional_data` property in HTTP requests.\n\nLearn more in [this documentation](https://docs.medusajs.com/learn/fundamentals/api-routes/additional-data).","optional":true,"defaultValue":"","expandable":false,"children":[]}]},{"name":"cart","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]}]} expandUrl="https://docs.medusajs.com/learn/fundamentals/data-models/manage-relationships#retrieve-records-of-relation" openedLevel={1} sectionTitle="validate"/>
189189

190190
### setPricingContext
191191

www/utils/packages/typedoc-plugin-markdown-medusa/src/resources/helpers/workflow-hooks.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ export default function (theme: MarkdownTheme) {
115115
str += `Handlers consuming this hook accept the following input.\n\n`
116116

117117
str += Handlebars.helpers.parameterComponent.call(
118-
cleanUpHookInput(signatures[0].parameters),
118+
cleanUpHookInput(
119+
signatures[0].parameters,
120+
this.name === "addToCartWorkflow" && hook.name === "validate"
121+
),
119122
{
120123
hash: {
121124
sectionTitle: hook.name,

www/utils/packages/utils/src/hooks-util.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,15 @@ export function getHookChildren(
4141
}
4242

4343
export function cleanUpHookInput(
44-
parameters: ParameterReflection[]
44+
parameters: ParameterReflection[],
45+
debug = false
4546
): (ParameterReflection | DeclarationReflection)[] {
4647
const hasInvokeParameter = parameters.some(
4748
(parameter) => parameter.name === "invoke"
4849
)
50+
if (debug) {
51+
console.log(parameters, hasInvokeParameter)
52+
}
4953
if (hasInvokeParameter) {
5054
return getHookInputFromInvoke(parameters)
5155
}
@@ -98,7 +102,12 @@ function cleanUpReflectionType(reflection: Reflection): Reflection {
98102
reflection.type?.type === "intersection" &&
99103
reflection.type.types.length >= 2
100104
) {
101-
reflection.type = reflection.type.types[1]
105+
const allReferences = reflection.type.types.every(
106+
(type) => type.type === "reference"
107+
)
108+
if (!allReferences) {
109+
reflection.type = reflection.type.types[1]
110+
}
102111
}
103112

104113
if (reflection instanceof DeclarationReflection && reflection.children) {

0 commit comments

Comments
 (0)