fix lint errors

This commit is contained in:
Shahed Nasser
2024-12-11 11:20:07 +02:00
parent 3522c0f0e0
commit 35a8224497
9 changed files with 51 additions and 51 deletions
@@ -440,7 +440,7 @@ export const validateVariantOutOfStockStep = createStep(
const query = container.resolve("query")
const availability = await getVariantAvailability(query, {
variant_ids: [variant_id],
sales_channel_id
sales_channel_id,
})
if (availability[variant_id].availability > 0) {
@@ -623,10 +623,10 @@ export const createRestockSubscriptionWorkflow = createWorkflow(
({
variant_id,
sales_channel_id,
customer
customer,
}: CreateRestockSubscriptionWorkflowInput) => {
const customerId = transform({
customer
customer,
}, (data) => {
return data.customer.customer_id || ""
})
@@ -643,8 +643,8 @@ export const createRestockSubscriptionWorkflow = createWorkflow(
fields: ["email"],
filters: { id: customerId },
options: {
throwIfKeyNotFound: true
}
throwIfKeyNotFound: true,
},
}).config({ name: "retrieve-customer" })
return data
@@ -652,7 +652,7 @@ export const createRestockSubscriptionWorkflow = createWorkflow(
const email = transform({
retrievedCustomer,
customer
customer,
}, (data) => {
return data.customer?.email ?? data.retrievedCustomer?.[0].email
})
@@ -692,7 +692,7 @@ export const subscriptionWorkflow2Highlights = [
```ts title="src/workflows/create-restock-subscription/index.ts" highlights={subscriptionWorkflow2Highlights}
validateVariantOutOfStockStep({
variant_id,
sales_channel_id
sales_channel_id,
})
// @ts-ignore
@@ -702,8 +702,8 @@ const { data: restockSubscriptions } = useQueryGraphStep({
filters: {
email,
variant_id,
sales_channel_id
}
sales_channel_id,
},
}).config({ name: "retrieve-subscriptions" })
when({ restockSubscriptions }, ({ restockSubscriptions }) => {
@@ -714,7 +714,7 @@ when({ restockSubscriptions }, ({ restockSubscriptions }) => {
variant_id,
sales_channel_id,
email,
customer_id: customer.customer_id
customer_id: customer.customer_id,
})
})
@@ -724,7 +724,7 @@ when({ restockSubscriptions }, ({ restockSubscriptions }) => {
.then(() => {
updateRestockSubscriptionStep({
id: restockSubscriptions[0].id,
customer_id: customer.customer_id
customer_id: customer.customer_id,
})
})
@@ -735,8 +735,8 @@ const { data: restockSubscription } = useQueryGraphStep({
filters: {
email,
variant_id,
sales_channel_id
}
sales_channel_id,
},
}).config({ name: "retrieve-restock-subscription" })
return new WorkflowResponse(
@@ -1120,12 +1120,12 @@ Before adding the step that does this, you'll add a method in the `RestockModule
```ts title="src/modules/restock/service.ts"
// other imports...
import { InjectManager, MedusaContext } from "@medusajs/framework/utils";
import { InjectManager, MedusaContext } from "@medusajs/framework/utils"
import { Context } from "@medusajs/framework/types"
import { EntityManager } from "@mikro-orm/knex";
import { EntityManager } from "@mikro-orm/knex"
class RestockModuleService extends MedusaService({
RestockSubscription
RestockSubscription,
}) {
// ...
@InjectManager()
@@ -1151,9 +1151,9 @@ You'll use this method in the step. To create the step, create the file `src/wor
![Directory structure of the Medusa application after adding the step.](https://res.cloudinary.com/dza7lstvk/image/upload/v1733399774/Medusa%20Resources/restock-dir-overview-22_kzchmm.jpg)
```ts title="src/workflows/send-restock-notifications/steps/get-distinct-subscriptions.ts"
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk";
import RestockModuleService from "../../../modules/restock/service";
import { RESTOCK_MODULE } from "../../../modules/restock";
import { createStep, StepResponse } from "@medusajs/framework/workflows-sdk"
import RestockModuleService from "../../../modules/restock/service"
import { RESTOCK_MODULE } from "../../../modules/restock"
export const getDistinctSubscriptionsStep = createStep(
"get-distinct-subscriptions",
@@ -1198,7 +1198,7 @@ export const getRestockedStep = createStep(
input.map(async (restockSubscription) => {
const variantAvailability = await getVariantAvailability(query, {
variant_ids: [restockSubscription.variant_id],
sales_channel_id: restockSubscription.sales_channel_id
sales_channel_id: restockSubscription.sales_channel_id,
})
if (variantAvailability[restockSubscription.variant_id].availability > 0) {
@@ -1322,12 +1322,12 @@ Create the file `src/workflows/send-restock-notifications/index.ts` with the fol
![The directory structure of the Medusa application after adding the workflow.](https://res.cloudinary.com/dza7lstvk/image/upload/v1733234507/Medusa%20Resources/restock-dir-overview-20_mcqkkx.jpg)
```ts title="src/workflows/send-restock-notifications/index.ts"
import { createWorkflow, transform, WorkflowResponse } from "@medusajs/framework/workflows-sdk";
import { useQueryGraphStep } from "@medusajs/medusa/core-flows";
import { getRestockedStep } from "./steps/get-restocked";
import { sendRestockNotificationStep } from "./steps/send-restock-notification";
import { deleteRestockSubscriptionStep } from "./steps/delete-restock-subscriptions";
import { getDistinctSubscriptionsStep } from "./steps/get-distinct-subscriptions";
import { createWorkflow, transform, WorkflowResponse } from "@medusajs/framework/workflows-sdk"
import { useQueryGraphStep } from "@medusajs/medusa/core-flows"
import { getRestockedStep } from "./steps/get-restocked"
import { sendRestockNotificationStep } from "./steps/send-restock-notification"
import { deleteRestockSubscriptionStep } from "./steps/delete-restock-subscriptions"
import { getDistinctSubscriptionsStep } from "./steps/get-distinct-subscriptions"
export const sendRestockNotificationsWorkflow = createWorkflow(
"send-restock-notifications",
@@ -1338,11 +1338,11 @@ export const sendRestockNotificationsWorkflow = createWorkflow(
const restockedSubscriptions = getRestockedStep(subscriptions)
const { variant_ids, sales_channel_ids } = transform({
restockedSubscriptions
restockedSubscriptions,
}, (data) => {
const filters: Record<string, string[]> = {
variant_ids: [],
sales_channel_ids: []
sales_channel_ids: [],
}
data.restockedSubscriptions.map((subscription) => {
filters.variant_ids.push(subscription.variant_id)
@@ -1358,8 +1358,8 @@ export const sendRestockNotificationsWorkflow = createWorkflow(
fields: ["*", "product_variant.*"],
filters: {
variant_id: variant_ids,
sales_channel_id: sales_channel_ids
}
sales_channel_id: sales_channel_ids,
},
})
// @ts-ignore
@@ -1369,7 +1369,7 @@ export const sendRestockNotificationsWorkflow = createWorkflow(
deleteRestockSubscriptionStep(restockedSubscriptionsWithEmails)
return new WorkflowResponse({
subscriptions: restockedSubscriptionsWithEmails
subscriptions: restockedSubscriptionsWithEmails,
})
}
)