docs-util: fix parsing when function if it has three parameters (#10878)
* docs-util: fix parsing when step when it has three parameters * fix condition
This commit is contained in:
1 parent
a0e944a7a8
commit
46f987e351
6 files changed
+106960
-106544
No files matched your search
@@ -251,7 +251,7 @@ export const generatedEditDates = {
|
||||
"references/auth/IAuthModuleService/methods/auth.IAuthModuleService.listAuthIdentities/page.mdx": "2024-12-09T13:21:36.253Z",
|
||||
"references/auth/interfaces/auth.FilterableAuthIdentityProps/page.mdx": "2024-12-23T13:57:04.094Z",
|
||||
"references/auth/interfaces/auth.IAuthModuleService/page.mdx": "2024-11-25T17:49:28.823Z",
|
||||
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.completeCartWorkflow/page.mdx": "2024-12-25T08:43:13.426Z",
|
||||
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.completeCartWorkflow/page.mdx": "2025-01-08T14:15:11.676Z",
|
||||
"references/core_flows/Cart/core_flows.Cart.Workflows_Cart/page.mdx": "2024-12-23T12:30:23.632Z",
|
||||
"references/core_flows/Common/Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx": "2025-01-07T12:54:14.097Z",
|
||||
"references/core_flows/Common/Steps_Common/functions/core_flows.Common.Steps_Common.dismissRemoteLinkStep/page.mdx": "2025-01-07T12:54:14.100Z",
|
||||
@@ -658,7 +658,7 @@ export const generatedEditDates = {
|
||||
"references/types/types/types.UpdatePromotionRulesWorkflowDTO/page.mdx": "2024-12-09T13:21:35.497Z",
|
||||
"references/core_flows/Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.setTaxLinesForItemsStep/page.mdx": "2024-12-25T08:43:13.394Z",
|
||||
"references/core_flows/Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx": "2024-12-25T08:43:13.401Z",
|
||||
"references/core_flows/Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartPaymentsStep/page.mdx": "2024-12-10T14:54:58.011Z",
|
||||
"references/core_flows/Cart/Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartPaymentsStep/page.mdx": "2025-01-08T14:15:11.661Z",
|
||||
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.addToCartWorkflow/page.mdx": "2024-12-25T08:43:13.424Z",
|
||||
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.confirmVariantInventoryWorkflow/page.mdx": "2024-12-25T08:43:13.429Z",
|
||||
"references/core_flows/Cart/Workflows_Cart/functions/core_flows.Cart.Workflows_Cart.createCartWorkflow/page.mdx": "2025-01-07T12:54:14.019Z",
|
||||
|
||||
+2
@@ -1,6 +1,8 @@
|
||||
---
|
||||
slug: /references/medusa-workflows/steps/validateCartPaymentsStep
|
||||
sidebar_label: validateCartPaymentsStep
|
||||
tags:
|
||||
- step
|
||||
---
|
||||
|
||||
import { TypeList, WorkflowDiagram } from "docs-ui"
|
||||
|
||||
+10
-1
@@ -3,6 +3,15 @@ slug: /references/medusa-workflows/completeCartWorkflow
|
||||
sidebar_label: completeCartWorkflow
|
||||
tags:
|
||||
- query
|
||||
- remote query
|
||||
- logger
|
||||
- payment
|
||||
- order
|
||||
- link
|
||||
- cart
|
||||
- inventory
|
||||
- locking
|
||||
- event bus
|
||||
- workflow
|
||||
---
|
||||
|
||||
@@ -16,7 +25,7 @@ This workflow completes a cart.
|
||||
|
||||
## Steps
|
||||
|
||||
<WorkflowDiagram workflow={{"name":"completeCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1}]}} />
|
||||
<WorkflowDiagram workflow={{"name":"completeCartWorkflow","steps":[{"type":"step","name":"useQueryGraphStep","description":"This step fetches data across modules using the Query.\n\nLearn more in the [Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx","depth":1},{"type":"when","condition":"{\n return !orderId\n }","depth":"2","steps":[{"type":"step","name":"useRemoteQueryStep","description":"This step fetches data across modules using the remote query.\n\nLearn more in the [Remote Query documentation](https://docs.medusajs.com/learn/fundamentals/module-links/query).\n\n:::note\n\nThis step is deprecated. Use [useQueryGraphStep](../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useQueryGraphStep/page.mdx) instead.\n\n:::\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.useRemoteQueryStep/page.mdx","depth":2},{"type":"step","name":"validateCartPaymentsStep","description":"This step validates a cart's payment sessions. Their status must\nbe `pending` or `requires_more`.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.validateCartPaymentsStep/page.mdx","depth":2},{"type":"step","name":"authorizePaymentSessionStep","description":"This step authorizes a payment session.\n\n","link":"../../../../Payment/Steps_Payment/functions/core_flows.Payment.Steps_Payment.authorizePaymentSessionStep/page.mdx","depth":2},{"type":"step","name":"createOrdersStep","description":"This step creates one or more orders.\n\n","link":"../../../../Order/Steps_Order/functions/core_flows.Order.Steps_Order.createOrdersStep/page.mdx","depth":2},{"type":"step","name":"createRemoteLinkStep","description":"This step creates remote links between two records of linked data models.\n\nLearn more in the [Remote Link documentation.](https://docs.medusajs.com/learn/fundamentals/module-links/remote-link#create-link).\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.createRemoteLinkStep/page.mdx","depth":2},{"type":"step","name":"updateCartsStep","description":"This step updates a cart.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.updateCartsStep/page.mdx","depth":2},{"type":"step","name":"reserveInventoryStep","description":"This step reserves the quantity of line items from the associated\nvariant's inventory.\n\n","link":"../../../Steps_Cart/functions/core_flows.Cart.Steps_Cart.reserveInventoryStep/page.mdx","depth":2},{"type":"step","name":"emitEventStep","description":"Emit an event.\n\n","link":"../../../../Common/Steps_Common/functions/core_flows.Common.Steps_Common.emitEventStep/page.mdx","depth":2}]}]}} />
|
||||
|
||||
## Input
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { Text } from "@medusajs/ui"
|
||||
import clsx from "clsx"
|
||||
import Link from "next/link"
|
||||
import React from "react"
|
||||
import React, { useMemo } from "react"
|
||||
import { WorkflowStepUi } from "types"
|
||||
import { InlineCode, MarkdownContent, Tooltip } from "../../.."
|
||||
import { Bolt, InformationCircle } from "@medusajs/icons"
|
||||
@@ -15,6 +15,10 @@ export type WorkflowDiagramNodeProps = {
|
||||
export const WorkflowDiagramStepNode = ({ step }: WorkflowDiagramNodeProps) => {
|
||||
const stepId = step.name.split(".").pop()
|
||||
|
||||
const description = useMemo(() => {
|
||||
return step.description?.replaceAll(/:::[a-z]*/g, "") || ""
|
||||
}, [step.description])
|
||||
|
||||
return (
|
||||
<Tooltip
|
||||
tooltipClassName="!text-left max-w-[300px] text-pretty overflow-scroll"
|
||||
@@ -27,12 +31,12 @@ export const WorkflowDiagramStepNode = ({ step }: WorkflowDiagramNodeProps) => {
|
||||
satisfied.
|
||||
</span>
|
||||
)}
|
||||
{step.description && (
|
||||
{description && (
|
||||
<MarkdownContent
|
||||
allowedElements={["a", "strong", "code"]}
|
||||
unwrapDisallowed={true}
|
||||
>
|
||||
{step.description}
|
||||
{description}
|
||||
</MarkdownContent>
|
||||
)}
|
||||
</>
|
||||
|
||||
+106927
-106534
File diff suppressed because it is too large.
Load diff
@@ -227,6 +227,7 @@ class WorkflowsPlugin {
|
||||
...resources,
|
||||
"workflow",
|
||||
])
|
||||
|
||||
this.updateWorkflowsTagsMap(workflowId, uniqueResources)
|
||||
}
|
||||
|
||||
@@ -379,10 +380,16 @@ class WorkflowsPlugin {
|
||||
.expression as ts.CallExpression
|
||||
const thenInitializer = initializer
|
||||
|
||||
const validArgumentsLength =
|
||||
whenInitializer.arguments.length === 2 ||
|
||||
whenInitializer.arguments.length === 3
|
||||
|
||||
const conditionIndex = whenInitializer.arguments.length - 1
|
||||
|
||||
if (
|
||||
whenInitializer.arguments.length < 2 ||
|
||||
(!ts.isFunctionExpression(whenInitializer.arguments[1]) &&
|
||||
!ts.isArrowFunction(whenInitializer.arguments[1])) ||
|
||||
!validArgumentsLength ||
|
||||
(!ts.isFunctionExpression(whenInitializer.arguments[conditionIndex]) &&
|
||||
!ts.isArrowFunction(whenInitializer.arguments[conditionIndex])) ||
|
||||
thenInitializer.arguments.length < 1 ||
|
||||
(!ts.isFunctionExpression(thenInitializer.arguments[0]) &&
|
||||
!ts.isArrowFunction(thenInitializer.arguments[0]))
|
||||
@@ -392,7 +399,8 @@ class WorkflowsPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
const whenCondition = whenInitializer.arguments[1].body.getText()
|
||||
const whenCondition =
|
||||
whenInitializer.arguments[conditionIndex].body.getText()
|
||||
|
||||
const thenStatements = (thenInitializer.arguments[0].body as ts.Block)
|
||||
.statements
|
||||
|
||||
Reference in new issue
Block a user