docs: remove usages of ts-ignore in examples (#12839)
This commit is contained in:
@@ -558,11 +558,9 @@ const {
|
||||
updated_at: {
|
||||
$lt: oneDayAgo,
|
||||
},
|
||||
// @ts-ignore
|
||||
email: {
|
||||
$ne: null,
|
||||
},
|
||||
// @ts-ignore
|
||||
completed_at: null,
|
||||
},
|
||||
pagination: {
|
||||
|
||||
+6
-10
@@ -202,12 +202,12 @@ To create the workflow, create the file `src/workflows/apply-first-purchase-prom
|
||||
|
||||
export const workflowHighlights = [
|
||||
["7", "cart_id", "Receive cart ID as input."],
|
||||
["14", "carts", "Retrieve the cart's details."],
|
||||
["23", "promotions", "Retrieve the first-purchase promotion's details."],
|
||||
["32", "when", "Check if the first-purchase promotion can be applied."],
|
||||
["42", "updateCartPromotionsStep", "Add the first-purchase promotion to the cart."],
|
||||
["51", "updatedCarts", "Retrieve the updated cart's details."],
|
||||
["59", "WorkflowResponse", "Return the updated cart's details."]
|
||||
["13", "carts", "Retrieve the cart's details."],
|
||||
["21", "promotions", "Retrieve the first-purchase promotion's details."],
|
||||
["29", "when", "Check if the first-purchase promotion can be applied."],
|
||||
["39", "updateCartPromotionsStep", "Add the first-purchase promotion to the cart."],
|
||||
["47", "updatedCarts", "Retrieve the updated cart's details."],
|
||||
["55", "WorkflowResponse", "Return the updated cart's details."]
|
||||
]
|
||||
|
||||
```ts title="src/workflows/apply-first-purchase-promo.ts" highlights={workflowHighlights}
|
||||
@@ -223,7 +223,6 @@ type WorkflowInput = {
|
||||
export const applyFirstPurchasePromoWorkflow = createWorkflow(
|
||||
"apply-first-purchase-promo",
|
||||
(input: WorkflowInput) => {
|
||||
// @ts-ignore
|
||||
const { data: carts } = useQueryGraphStep({
|
||||
entity: "cart",
|
||||
fields: ["promotions.*", "customer.*", "customer.orders.*"],
|
||||
@@ -232,12 +231,10 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
|
||||
}
|
||||
})
|
||||
|
||||
// @ts-ignore
|
||||
const { data: promotions } = useQueryGraphStep({
|
||||
entity: "promotion",
|
||||
fields: ["code"],
|
||||
filters: {
|
||||
// @ts-ignore
|
||||
code: FIRST_PURCHASE_PROMOTION_CODE
|
||||
}
|
||||
}).config({ name: "retrieve-promotions" })
|
||||
@@ -260,7 +257,6 @@ export const applyFirstPurchasePromoWorkflow = createWorkflow(
|
||||
})
|
||||
|
||||
// retrieve updated cart
|
||||
// @ts-ignore
|
||||
const { data: updatedCarts } = useQueryGraphStep({
|
||||
entity: "cart",
|
||||
fields: ["*", "promotions.*"],
|
||||
|
||||
@@ -835,14 +835,14 @@ Now that you have all the steps, you can create the workflow that uses them.
|
||||
To create the workflow, create the file `src/workflows/handle-order-points.ts` with the following content:
|
||||
|
||||
export const handleOrderPointsHighlights = [
|
||||
["18", "useQueryGraphStep", "Retrieve the order's details."],
|
||||
["38", "validateCustomerExistsStep", "Validate that the customer is registered."],
|
||||
["42", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
|
||||
["46", "when", "Check whether the order's cart has a loyalty promotion."],
|
||||
["51", "deductPurchasePointsStep", "Deduct points from the customer's loyalty points."],
|
||||
["56", "updatePromotionsStep", "Deactivate the cart's loyalty promotion."],
|
||||
["65", "when", "Check whether the order's cart doesn't have a loyalty promotion."],
|
||||
["70", "addPurchaseAsPointsStep", "Add points to the customer's loyalty points."],
|
||||
["17", "useQueryGraphStep", "Retrieve the order's details."],
|
||||
["37", "validateCustomerExistsStep", "Validate that the customer is registered."],
|
||||
["41", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
|
||||
["45", "when", "Check whether the order's cart has a loyalty promotion."],
|
||||
["50", "deductPurchasePointsStep", "Deduct points from the customer's loyalty points."],
|
||||
["55", "updatePromotionsStep", "Deactivate the cart's loyalty promotion."],
|
||||
["64", "when", "Check whether the order's cart doesn't have a loyalty promotion."],
|
||||
["69", "addPurchaseAsPointsStep", "Add points to the customer's loyalty points."],
|
||||
]
|
||||
|
||||
```ts title="src/workflows/handle-order-points.ts" highlights={handleOrderPointsHighlights} collapsibleLines="1-9" expandButtonLabel="Show Imports"
|
||||
@@ -862,7 +862,6 @@ type WorkflowInput = {
|
||||
export const handleOrderPointsWorkflow = createWorkflow(
|
||||
"handle-order-points",
|
||||
({ order_id }: WorkflowInput) => {
|
||||
// @ts-ignore
|
||||
const { data: orders } = useQueryGraphStep({
|
||||
entity: "order",
|
||||
fields: [
|
||||
@@ -1394,10 +1393,10 @@ You can now create the workflow that applies a loyalty promotion to the cart.
|
||||
To create the workflow, create the file `src/workflows/apply-loyalty-on-cart.ts` with the following content:
|
||||
|
||||
export const applyLoyaltyOnCartWorkflowHighlights = [
|
||||
["45", "useQueryGraphStep", "Retrieve the cart's details."],
|
||||
["56", "validateCustomerExistsStep", "Validate that the customer is registered."],
|
||||
["60", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
|
||||
["65", "getCartLoyaltyPromoAmountStep", "Get the amount to be discounted based on the loyalty points."],
|
||||
["44", "useQueryGraphStep", "Retrieve the cart's details."],
|
||||
["55", "validateCustomerExistsStep", "Validate that the customer is registered."],
|
||||
["59", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
|
||||
["64", "getCartLoyaltyPromoAmountStep", "Get the amount to be discounted based on the loyalty points."],
|
||||
]
|
||||
|
||||
```ts title="src/workflows/apply-loyalty-on-cart.ts" highlights={applyLoyaltyOnCartWorkflowHighlights} collapsibleLines="1-24" expandButtonLabel="Show Imports"
|
||||
@@ -1444,7 +1443,6 @@ const fields = [
|
||||
export const applyLoyaltyOnCartWorkflow = createWorkflow(
|
||||
"apply-loyalty-on-cart",
|
||||
(input: WorkflowInput) => {
|
||||
// @ts-ignore
|
||||
const { data: carts } = useQueryGraphStep({
|
||||
entity: "cart",
|
||||
fields,
|
||||
@@ -1559,7 +1557,7 @@ export const createLoyaltyPromoStepHighlights = [
|
||||
["5", "transform", "Prepare the data to update the cart's promotions."],
|
||||
["25", "updateCartPromotionsWorkflow", "Update the cart's promotions with the new loyalty promotion."],
|
||||
["29", "updateCartsStep", "Update the cart to store the ID of the loyalty promotion in the metadata."],
|
||||
["38", "useQueryGraphStep", "Retrieve the cart's details again."],
|
||||
["37", "useQueryGraphStep", "Retrieve the cart's details again."],
|
||||
]
|
||||
|
||||
```ts title="src/workflows/apply-loyalty-on-cart.ts" highlights={createLoyaltyPromoStepHighlights}
|
||||
@@ -1599,7 +1597,6 @@ updateCartsStep([
|
||||
])
|
||||
|
||||
// retrieve cart with updated promotions
|
||||
// @ts-ignore
|
||||
const { data: updatedCarts } = useQueryGraphStep({
|
||||
entity: "cart",
|
||||
fields,
|
||||
@@ -1800,13 +1797,13 @@ Since you already have all the steps, you can create the workflow.
|
||||
To create the workflow, create the file `src/workflows/remove-loyalty-from-cart.ts` with the following content:
|
||||
|
||||
export const removeLoyaltyFromCartWorkflowHighlights = [
|
||||
["36", "useQueryGraphStep", "Retrieve the cart's details."],
|
||||
["44", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
|
||||
["49", "updateCartPromotionsWorkflow", "Update the cart's promotions to remove the loyalty promotion."],
|
||||
["57", "transform", "Prepare the new metadata to remove the loyalty promotion ID."],
|
||||
["68", "updateCartsStep", "Update the cart to remove the loyalty promotion ID from the metadata."],
|
||||
["75", "updatePromotionsStep", "Deactivate the loyalty promotion."],
|
||||
["84", "useQueryGraphStep", "Retrieve the cart's details again."],
|
||||
["35", "useQueryGraphStep", "Retrieve the cart's details."],
|
||||
["43", "getCartLoyaltyPromoStep", "Retrieve the cart's loyalty promotion."],
|
||||
["48", "updateCartPromotionsWorkflow", "Update the cart's promotions to remove the loyalty promotion."],
|
||||
["56", "transform", "Prepare the new metadata to remove the loyalty promotion ID."],
|
||||
["67", "updateCartsStep", "Update the cart to remove the loyalty promotion ID from the metadata."],
|
||||
["74", "updatePromotionsStep", "Deactivate the loyalty promotion."],
|
||||
["82", "useQueryGraphStep", "Retrieve the cart's details again."],
|
||||
]
|
||||
|
||||
```ts title="src/workflows/remove-loyalty-from-cart.ts" collapsibleLines="1-15" expandButtonLabel="Show Imports" highlights={removeLoyaltyFromCartWorkflowHighlights}
|
||||
@@ -1844,7 +1841,6 @@ const fields = [
|
||||
export const removeLoyaltyFromCartWorkflow = createWorkflow(
|
||||
"remove-loyalty-from-cart",
|
||||
(input: WorkflowInput) => {
|
||||
// @ts-ignore
|
||||
const { data: carts } = useQueryGraphStep({
|
||||
entity: "cart",
|
||||
fields,
|
||||
@@ -1892,7 +1888,6 @@ export const removeLoyaltyFromCartWorkflow = createWorkflow(
|
||||
])
|
||||
|
||||
// retrieve cart with updated promotions
|
||||
// @ts-ignore
|
||||
const { data: updatedCarts } = useQueryGraphStep({
|
||||
entity: "cart",
|
||||
fields,
|
||||
|
||||
@@ -505,7 +505,6 @@ export const createReviewWorkflow = createWorkflow(
|
||||
"create-review",
|
||||
(input: CreateReviewInput) => {
|
||||
// Check product exists
|
||||
// @ts-ignore
|
||||
useQueryGraphStep({
|
||||
entity: "product",
|
||||
fields: ["id"],
|
||||
@@ -520,7 +519,6 @@ export const createReviewWorkflow = createWorkflow(
|
||||
// Create the review
|
||||
const review = createReviewStep(input)
|
||||
|
||||
// @ts-ignore
|
||||
return new WorkflowResponse({
|
||||
review,
|
||||
})
|
||||
@@ -1522,8 +1520,8 @@ export const GetStoreReviewsHighlights = [
|
||||
["10", "GetStoreReviewsSchema", "Define the query parameters schema."],
|
||||
["12", "GET", "Expose a GET API route."],
|
||||
["26", "query.graph", "Retrieve reviews with pagination."],
|
||||
["31", "status", "Only retrieve approved reviews."],
|
||||
["41", "average_rating", "Retrieve the average rating of the product."],
|
||||
["30", "status", "Only retrieve approved reviews."],
|
||||
["40", "average_rating", "Retrieve the average rating of the product."],
|
||||
]
|
||||
|
||||
```ts title="src/api/store/products/[id]/reviews/route.ts" highlights={GetStoreReviewsHighlights} collapsibleLines="1-9" expandButtonLabel="Show Imports"
|
||||
@@ -1556,7 +1554,6 @@ export const GET = async (
|
||||
entity: "review",
|
||||
filters: {
|
||||
product_id: id,
|
||||
// @ts-ignore
|
||||
status: "approved",
|
||||
},
|
||||
...req.queryConfig,
|
||||
|
||||
@@ -179,7 +179,7 @@ This workflow uses steps from Medusa's `@medusajs/medusa/core-flows` package. So
|
||||
To create the workflow, create the file `src/workflows/reorder.ts` with the following content:
|
||||
|
||||
export const workflowHighlights1 = [
|
||||
["20", "useQueryGraphStep", "Retrieve the order's details."],
|
||||
["19", "useQueryGraphStep", "Retrieve the order's details."],
|
||||
]
|
||||
|
||||
```ts title="src/workflows/reorder.ts" highlights={workflowHighlights1}
|
||||
@@ -201,7 +201,6 @@ type ReorderWorkflowInput = {
|
||||
export const reorderWorkflow = createWorkflow(
|
||||
"reorder",
|
||||
({ order_id }: ReorderWorkflowInput) => {
|
||||
// @ts-ignore
|
||||
const { data: orders } = useQueryGraphStep({
|
||||
entity: "order",
|
||||
fields: [
|
||||
@@ -359,12 +358,11 @@ Finally, you need to retrieve the cart's details and return them as the workflow
|
||||
Replace the `TODO` in the workflow with the following:
|
||||
|
||||
export const workflowHighlights4 = [
|
||||
["2", "useQueryGraphStep", "Retrieve the cart's details."],
|
||||
["28", "WorkflowResponse", "Return the cart's details."],
|
||||
["1", "useQueryGraphStep", "Retrieve the cart's details."],
|
||||
["27", "WorkflowResponse", "Return the cart's details."],
|
||||
]
|
||||
|
||||
```ts title="src/workflows/reorder.ts" highlights={workflowHighlights4}
|
||||
// @ts-ignore
|
||||
const { data: carts } = useQueryGraphStep({
|
||||
entity: "cart",
|
||||
fields: [
|
||||
|
||||
Reference in New Issue
Block a user