docs: add line highlight validation (#14380)

* docs: add line highlight validation

* add to all projects

* fixes

* fixes

* fix

* fixes
This commit is contained in:
Shahed Nasser
2025-12-22 14:10:39 +02:00
committed by GitHub
parent 6380c1fdf4
commit cb33388202
59 changed files with 514 additions and 243 deletions
@@ -1415,8 +1415,8 @@ To create the workflow, create the file `src/workflows/apply-loyalty-on-cart.ts`
export const applyLoyaltyOnCartWorkflowHighlights = [
["46", "useQueryGraphStep", "Retrieve the cart's details."],
["57", "validateCustomerExistsStep", "Validate that the customer is registered."],
["59", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
["61", "acquireLockStep", "Acquire a lock on the cart to prevent concurrent modifications."],
["61", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
["66", "acquireLockStep", "Acquire a lock on the cart to prevent concurrent modifications."],
["72", "getCartLoyaltyPromoAmountStep", "Get the amount to be discounted based on the loyalty points."],
]
@@ -917,11 +917,11 @@ A Notification Module Provider has a service that contains the sending logic. Th
So, create the file `src/modules/twilio-sms/service.ts` with the following content:
export const twilioSmsServiceHighlights = [
["8", "accountSid", "Twilio account SID."],
["9", "authToken", "Twilio auth token."],
["10", "from", "Twilio phone number to send the SMS from."],
["14", "identifier", "Unique identifier for the module."],
["15", "client", "Twilio client to send the SMS."],
["9", "accountSid", "Twilio account SID."],
["10", "authToken", "Twilio auth token."],
["11", "from", "Twilio phone number to send the SMS from."],
["15", "identifier", "Unique identifier for the module."],
["16", "client", "Twilio client to send the SMS."],
]
```ts title="src/modules/twilio-sms/service.ts" highlights={twilioSmsServiceHighlights}
@@ -538,12 +538,12 @@ If you get a type error on resolving the Preorder Module, run the Medusa applica
</Note>
export const updatePreorderVariantStepHighlights = [
["16", "preorderModuleService", "Resolve the Preorder Module's service from the Medusa container."],
["20", "oldData", "Retrieve existing record to undo updates if an error occurs."],
["24", "preorderVariant", "Update the pre-order variant."],
["28", "preorderVariant", "Return the updated pre-order variant."],
["28", "oldData", "Pass the old data to the compensation function."],
["39", "updatePreorderVariants", "Undo updates if an error occurs during the workflow execution."]
["17", "preorderModuleService", "Resolve the Preorder Module's service from the Medusa container."],
["21", "oldData", "Retrieve existing record to undo updates if an error occurs."],
["25", "preorderVariant", "Update the pre-order variant."],
["29", "preorderVariant", "Return the updated pre-order variant."],
["29", "oldData", "Pass the old data to the compensation function."],
["40", "updatePreorderVariants", "Undo updates if an error occurs during the workflow execution."]
]
```ts title="src/workflows/steps/update-preorder-variant.ts" highlights={updatePreorderVariantStepHighlights}
@@ -623,10 +623,10 @@ The `createPreorderVariantStep` creates a pre-order variant record.
To create the step, create the file `src/workflows/steps/create-preorder-variant.ts` with the following content:
export const createPreorderVariantStepHighlights = [
["15", "preorderVariant", "Create the pre-order variant."],
["19", "preorderVariant", "Return the created pre-order variant."],
["19", "id", "Pass the ID to the compensation function."],
["30", "deletePreorderVariants", "Delete the pre-order variant if an error occurs during the workflow execution."]
["16", "preorderVariant", "Create the pre-order variant."],
["20", "preorderVariant", "Return the created pre-order variant."],
["20", "id", "Pass the ID to the compensation function."],
["31", "deletePreorderVariants", "Delete the pre-order variant if an error occurs during the workflow execution."]
]
```ts title="src/workflows/steps/create-preorder-variant.ts" highlights={createPreorderVariantStepHighlights}
@@ -811,7 +811,7 @@ export const upsertPreorderVariantRouteHighlights = [
["10", "UpsertPreorderVariantSchema", "The schema to validate the request body."],
["18", "POST", "Expose a POST API route."],
["24", "upsertProductVariantPreorderWorkflow", "Execute the workflow to create or update pre-order variant configurations."],
["32", "preorder_variant", "Return the created or updated pre-order variant in the response."],
["33", "preorder_variant", "Return the created or updated pre-order variant in the response."],
]
```ts title="src/api/admin/variants/[id]/preorders/route.ts" highlights={upsertPreorderVariantRouteHighlights}
@@ -944,12 +944,12 @@ The `disablePreorderVariantStep` changes the status of a pre-order variant recor
Create the file `src/workflows/steps/disable-preorder-variant.ts` with the following content:
export const disablePreorderVariantStepHighlights = [
["15", "oldData", "Retrieve existing record to undo updates if an error occurs."],
["17", "preorderVariant", "Update the pre-order variant."],
["19", "DISABLED", "Set the pre-order variant's status to `disabled`."],
["22", "preorderVariant", "Return the updated pre-order variant."],
["22", "oldData", "Pass the old data to the compensation function."],
["31", "updatePreorderVariants", "Undo updates if an error occurs during the workflow execution."]
["16", "oldData", "Retrieve existing record to undo updates if an error occurs."],
["18", "preorderVariant", "Update the pre-order variant."],
["20", "DISABLED", "Set the pre-order variant's status to `disabled`."],
["23", "preorderVariant", "Return the updated pre-order variant."],
["23", "oldData", "Pass the old data to the compensation function."],
["32", "updatePreorderVariants", "Undo updates if an error occurs during the workflow execution."]
]
```ts title="src/workflows/steps/disable-preorder-variant.ts" highlights={disablePreorderVariantStepHighlights}
@@ -1688,9 +1688,9 @@ The `createPreordersStep` creates a `Preorder` record for each pre-order variant
Create the file `src/workflows/steps/create-preorders.ts` with the following content:
export const createPreordersStepHighlights = [
["16", "preorders", "Create pre-orders."],
["23", "preorders", "Return the pre-orders."],
["32", "deletePreorders", "Delete pre-orders if an error occurs during the workflow execution."],
["17", "preorders", "Create pre-orders."],
["24", "preorders", "Return the pre-orders."],
["33", "deletePreorders", "Delete pre-orders if an error occurs during the workflow execution."],
]
```ts title="src/workflows/steps/create-preorders.ts" highlights={createPreordersStepHighlights}
@@ -1927,7 +1927,7 @@ export const validateCartHookHighlights = [
["32", "variantsToAdd", "Retrieve the pre-order variants of the new items being added to the cart."],
["42", "cartHasPreorderVariants", "Check if the cart has pre-order variants."],
["48", "newItemsHavePreorderVariants", "Check if the new items being added have pre-order variants."],
["55", "throw MedusaError", "Throw an error if the cart has mixed pre-order and available items."],
["55", "MedusaError", "Throw an error if the cart has mixed pre-order and available items."],
]
```ts title="src/workflows/hooks/validate-cart.ts" highlights={validateCartHookHighlights}
@@ -2759,12 +2759,12 @@ The `updatePreordersStep` updates the details of pre-order records.
Create the file `src/workflows/steps/update-preorders.ts` with the following content:
export const updatePreordersHighlights = [
["13", "preorders", "The pre-orders to update."],
["16", "oldPreorders", "The pre-orders before the update."],
["20", "updatedPreorders", "Update the pre-orders."],
["24", "updatedPreorders", "Return the updated pre-orders."],
["24", "oldPreorders", "Pass the old pre-orders to the compensation function."],
["33", "updatePreorders", "Revert the pre-order updates if an error occurs during the workflow's execution."]
["14", "preorders", "The pre-orders to update."],
["17", "oldPreorders", "The pre-orders before the update."],
["21", "updatedPreorders", "Update the pre-orders."],
["25", "updatedPreorders", "Return the updated pre-orders."],
["25", "oldPreorders", "Pass the old pre-orders to the compensation function."],
["34", "updatePreorders", "Revert the pre-order updates if an error occurs during the workflow's execution."]
]
```ts title="src/workflows/steps/update-preorders.ts" highlights={updatePreordersHighlights}
@@ -2964,14 +2964,7 @@ export const retrieveItemsToFulfillStep = createStep(
Then, update the workflow to the following:
export const fulfillPreorderWorkflowHighlights2 = [
["22"], ["23"], ["24"], ["25"], ["37"], ["55"], ["56"], ["57"], ["58"],
["59"], ["60"], ["61"], ["62"], ["63"], ["64"], ["65"], ["66"], ["67"],
["68"], ["69"], ["70"], ["71"], ["72"], ["73"], ["74"], ["75"], ["76"],
["77"], ["78"], ["79"], ["80"],
]
```ts title="src/workflows/fulfill-preorder.ts" highlights={fulfillPreorderWorkflowHighlights2}
```ts title="src/workflows/fulfill-preorder.ts"
import { InferTypeOf } from "@medusajs/framework/types"
import { PreorderVariant } from "../modules/preorder/models/preorder-variant"
import { createWorkflow, transform, when, WorkflowResponse } from "@medusajs/framework/workflows-sdk"
@@ -3135,7 +3128,7 @@ export const fulfillPreordersJobHighlights2 = [
["24", "available_date", "Retrieve only the pre-order variants available today."],
["43", "unfulfilledPreorders", "The unfulfilled pre-orders retrieved."],
["44", "preorderMetadata", "The pagination details of the pre-order query."],
["66", "fulfillPreorderWorkflow.run", "Fulfill a pre-order of the variant."],
["66", "fulfillPreorderWorkflow", "Fulfill a pre-order of the variant."],
]
```ts title="src/jobs/fulfill-preorders.ts" highlights={fulfillPreordersJobHighlights2}
@@ -3498,7 +3491,7 @@ export const orderCanceledHighlights = [
["14", "workflowInput", "Prepare the input to pass to the workflow."],
["24", "preorders", "Retrieve the pre-orders of the order."],
["41", "push", "Add the pre-orders to the workflow input."],
["46", "cancelPreordersWorkflow.run", "Execute the cancel pre-orders workflow."],
["46", "cancelPreordersWorkflow", "Execute the cancel pre-orders workflow."],
]
```ts title="src/subscribers/order-canceled.ts" highlights={orderCanceledHighlights}
@@ -3642,10 +3635,7 @@ Create the file `src/workflows/steps/retrieve-preorder-updates.ts` with the foll
export const retrievePreorderUpdatesStepHighlights = [
["20", "preordersToCancel", "The pre-orders to cancel."],
["24", "preordersToCreate", "The pre-orders to create."],
["20", "preorder_variant", "The pre-order variant associated with the item."],
["32", "", "Find the new pre-order items."],
["44", "push", "Add the pre-order variant to the pre-orders to create."],
["50", "", "Find the pre-order items that need to be canceled."],
["55", "push", "Add the pre-order to the pre-orders to cancel."],
]
@@ -5540,8 +5540,6 @@ You also need to update the components that use the `Item` component to pass the
In `src/modules/cart/templates/items.tsx`, replace the `return` statement with the following:
export const itemsTemplateHighlights = [
["13", "className"],
["17", "className"],
["34", "cartItems", "Pass new prop"]
]
@@ -5669,12 +5667,7 @@ You calculate the total items by summing the quantities of the `filteredItems`,
Finally, in the `return` statement, replace all usages of `cartState.items` with `filteredItems`, and remove the children element of the `DeleteButton` for better styling:
export const cartDropdownHighlights = [
["6", "filteredItems"], ["9", "filteredItems"],
["21"], ["22"], ["23"], ["24"], ["25"]
]
```tsx title="src/modules/layout/components/cart-dropdown/index.tsx" badgeLabel="Storefront" badgeColor="blue" highlights={cartDropdownHighlights}
```tsx title="src/modules/layout/components/cart-dropdown/index.tsx" badgeLabel="Storefront" badgeColor="blue" highlights={[["6"], ["9"], ["21"], ["22"], ["23"], ["24"], ["25"]]}
return (
<div
// ...
@@ -5789,7 +5782,7 @@ export const removeProductBuilderFromCartWorkflowHighlights = [
["40", "itemsToRemove", "Identify items to remove."],
["51", "relatedItems", "Identify addon items to remove."],
["68", "deleteLineItemsWorkflow", "Delete line items from cart."],
["75", "updatedCart", "Retrieve updated cart."],
["73", "updatedCart", "Retrieve updated cart."],
["84", "releaseLockStep", "Release lock on cart."],
]
@@ -5992,7 +5985,6 @@ Then, pass an `isBuilderConfigItem` prop to the `DeleteButton` component, and up
export const deleteButtonHighlights = [
["3", "isBuilderConfigItem", "New prop to determine if item belongs to a product with builder configurations."],
["6"],
["12", "removeBuilderLineItem", "Use when the line item belongs to a product with builder configurations."],
]