docs: update to next 15 + eslint 9 (#9839)
* update next * updated react * update eslint * finish updating eslint * fix content lint errors * fix docs test * fix vale action * fix installation errors
This commit is contained in:
@@ -48,7 +48,7 @@ module.exports = defineConfig({
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -195,7 +195,7 @@ export async function POST(request: MedusaRequest, res: MedusaResponse) {
|
||||
```ts
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
// eslint-disable-next-line prettier/prettier
|
||||
|
||||
import { initialize as initializeCustomerModule } from "@medusajs/medusa/customer"
|
||||
|
||||
export async function POST(request: Request) {
|
||||
|
||||
@@ -42,7 +42,7 @@ module.exports = defineConfig({
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ module.exports = defineConfig({
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ Then, create a link between the payment collection and the resource it's storing
|
||||
```ts
|
||||
import {
|
||||
ContainerRegistrationKeys,
|
||||
Modules
|
||||
Modules,
|
||||
} from "@medusajs/framework/utils"
|
||||
|
||||
// ...
|
||||
@@ -56,11 +56,11 @@ const remoteLink = container.resolve(
|
||||
|
||||
remoteLink.create({
|
||||
[Modules.CART]: {
|
||||
cart_id: "cart_123"
|
||||
cart_id: "cart_123",
|
||||
},
|
||||
[Modules.PAYMENT]: {
|
||||
payment_collection_id: paymentCollection.id
|
||||
}
|
||||
payment_collection_id: paymentCollection.id,
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ module.exports = defineConfig({
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -68,13 +68,13 @@ Learn more about module links in [this guide](!docs!/module-links).
|
||||
Create the file `src/links/product-custom.ts` with the following content:
|
||||
|
||||
```ts title="src/links/product-custom.ts"
|
||||
import { defineLink } from "@medusajs/framework/utils";
|
||||
import { defineLink } from "@medusajs/framework/utils"
|
||||
import HelloModule from "../modules/hello"
|
||||
import ProductModule from "@medusajs/medusa/product"
|
||||
|
||||
export default defineLink(
|
||||
ProductModule.linkable.product,
|
||||
HelloModule.linkable.custom,
|
||||
HelloModule.linkable.custom
|
||||
)
|
||||
```
|
||||
|
||||
@@ -234,29 +234,29 @@ export const createCustomFromProductWorkflow = createWorkflow(
|
||||
(input: CreateCustomFromProductWorkflowInput) => {
|
||||
const customName = transform(
|
||||
{
|
||||
input
|
||||
input,
|
||||
},
|
||||
(data) => data.input.additional_data.custom_name || ""
|
||||
)
|
||||
|
||||
const custom = createCustomStep({
|
||||
custom_name: customName
|
||||
custom_name: customName,
|
||||
})
|
||||
|
||||
when(({ custom }), ({ custom }) => custom !== undefined)
|
||||
.then(() => {
|
||||
createRemoteLinkStep([{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: input.product.id
|
||||
product_id: input.product.id,
|
||||
},
|
||||
[HELLO_MODULE]: {
|
||||
custom_id: custom.id
|
||||
}
|
||||
custom_id: custom.id,
|
||||
},
|
||||
}])
|
||||
})
|
||||
|
||||
return new WorkflowResponse({
|
||||
custom
|
||||
custom,
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -282,19 +282,19 @@ To consume the hook, create the file `src/workflow/hooks/product-created.ts` wit
|
||||
import { createProductsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
import {
|
||||
createCustomFromProductWorkflow,
|
||||
CreateCustomFromProductWorkflowInput
|
||||
CreateCustomFromProductWorkflowInput,
|
||||
} from "../create-custom-from-product"
|
||||
|
||||
createProductsWorkflow.hooks.productsCreated(
|
||||
async ({ products, additional_data }, { container }) => {
|
||||
const workflow = createCustomFromProductWorkflow(container)
|
||||
|
||||
for (let product of products) {
|
||||
for (const product of products) {
|
||||
await workflow.run({
|
||||
input: {
|
||||
product,
|
||||
additional_data
|
||||
} as CreateCustomFromProductWorkflowInput
|
||||
additional_data,
|
||||
} as CreateCustomFromProductWorkflowInput,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -556,16 +556,16 @@ const created = when({
|
||||
)
|
||||
.then(() => {
|
||||
const custom = createCustomStep({
|
||||
custom_name: input.additional_data.custom_name
|
||||
custom_name: input.additional_data.custom_name,
|
||||
})
|
||||
|
||||
createRemoteLinkStep([{
|
||||
[Modules.PRODUCT]: {
|
||||
product_id: input.product.id
|
||||
product_id: input.product.id,
|
||||
},
|
||||
[HELLO_MODULE]: {
|
||||
custom_id: custom.id
|
||||
}
|
||||
custom_id: custom.id,
|
||||
},
|
||||
}])
|
||||
|
||||
return custom
|
||||
@@ -628,7 +628,7 @@ const updated = when({
|
||||
return new WorkflowResponse({
|
||||
created,
|
||||
updated,
|
||||
deleted
|
||||
deleted,
|
||||
})
|
||||
```
|
||||
|
||||
@@ -646,19 +646,19 @@ Create the file `src/workflows/hooks/product-updated.ts` with the following cont
|
||||
import { updateProductsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
import {
|
||||
UpdateCustomFromProductStepInput,
|
||||
updateCustomFromProductWorkflow
|
||||
updateCustomFromProductWorkflow,
|
||||
} from "../update-custom-from-product"
|
||||
|
||||
updateProductsWorkflow.hooks.productsUpdated(
|
||||
async ({ products, additional_data }, { container }) => {
|
||||
const workflow = updateCustomFromProductWorkflow(container)
|
||||
|
||||
for (let product of products) {
|
||||
for (const product of products) {
|
||||
await workflow.run({
|
||||
input: {
|
||||
product,
|
||||
additional_data
|
||||
} as UpdateCustomFromProductStepInput
|
||||
additional_data,
|
||||
} as UpdateCustomFromProductStepInput,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,13 +68,13 @@ Learn more about module links in [this guide](!docs!/module-links).
|
||||
Create the file `src/links/promotion-custom.ts` with the following content:
|
||||
|
||||
```ts title="src/links/promotion-custom.ts"
|
||||
import { defineLink } from "@medusajs/framework/utils";
|
||||
import { defineLink } from "@medusajs/framework/utils"
|
||||
import HelloModule from "../modules/hello"
|
||||
import PromotionModule from "@medusajs/medusa/promotion"
|
||||
|
||||
export default defineLink(
|
||||
PromotionModule.linkable.promotion,
|
||||
HelloModule.linkable.custom,
|
||||
HelloModule.linkable.custom
|
||||
)
|
||||
```
|
||||
|
||||
@@ -234,29 +234,29 @@ export const createCustomFromPromotionWorkflow = createWorkflow(
|
||||
(input: CreateCustomFromPromotionWorkflowInput) => {
|
||||
const customName = transform(
|
||||
{
|
||||
input
|
||||
input,
|
||||
},
|
||||
(data) => data.input.additional_data.custom_name || ""
|
||||
)
|
||||
|
||||
const custom = createCustomStep({
|
||||
custom_name: customName
|
||||
custom_name: customName,
|
||||
})
|
||||
|
||||
when(({ custom }), ({ custom }) => custom !== undefined)
|
||||
.then(() => {
|
||||
createRemoteLinkStep([{
|
||||
[Modules.PROMOTION]: {
|
||||
promotion_id: input.promotion.id
|
||||
promotion_id: input.promotion.id,
|
||||
},
|
||||
[HELLO_MODULE]: {
|
||||
custom_id: custom.id
|
||||
}
|
||||
custom_id: custom.id,
|
||||
},
|
||||
}])
|
||||
})
|
||||
|
||||
return new WorkflowResponse({
|
||||
custom
|
||||
custom,
|
||||
})
|
||||
}
|
||||
)
|
||||
@@ -282,19 +282,19 @@ To consume the hook, create the file `src/workflow/hooks/promotion-created.ts` w
|
||||
import { createPromotionsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
import {
|
||||
createCustomFromPromotionWorkflow,
|
||||
CreateCustomFromPromotionWorkflowInput
|
||||
CreateCustomFromPromotionWorkflowInput,
|
||||
} from "../create-custom-from-promotion"
|
||||
|
||||
createPromotionsWorkflow.hooks.promotionsCreated(
|
||||
async ({ promotions, additional_data }, { container }) => {
|
||||
const workflow = createCustomFromPromotionWorkflow(container)
|
||||
|
||||
for (let promotion of promotions) {
|
||||
for (const promotion of promotions) {
|
||||
await workflow.run({
|
||||
input: {
|
||||
promotion,
|
||||
additional_data
|
||||
} as CreateCustomFromPromotionWorkflowInput
|
||||
additional_data,
|
||||
} as CreateCustomFromPromotionWorkflowInput,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -562,16 +562,16 @@ const created = when({
|
||||
)
|
||||
.then(() => {
|
||||
const custom = createCustomStep({
|
||||
custom_name: input.additional_data.custom_name
|
||||
custom_name: input.additional_data.custom_name,
|
||||
})
|
||||
|
||||
createRemoteLinkStep([{
|
||||
[Modules.PROMOTION]: {
|
||||
promotion_id: input.promotion.id
|
||||
promotion_id: input.promotion.id,
|
||||
},
|
||||
[HELLO_MODULE]: {
|
||||
custom_id: custom.id
|
||||
}
|
||||
custom_id: custom.id,
|
||||
},
|
||||
}])
|
||||
|
||||
return custom
|
||||
@@ -634,7 +634,7 @@ const updated = when({
|
||||
return new WorkflowResponse({
|
||||
created,
|
||||
updated,
|
||||
deleted
|
||||
deleted,
|
||||
})
|
||||
```
|
||||
|
||||
@@ -652,19 +652,19 @@ Create the file `src/workflows/hooks/promotion-updated.ts` with the following co
|
||||
import { updatePromotionsWorkflow } from "@medusajs/medusa/core-flows"
|
||||
import {
|
||||
UpdateCustomFromPromotionStepInput,
|
||||
updateCustomFromPromotionWorkflow
|
||||
updateCustomFromPromotionWorkflow,
|
||||
} from "../update-custom-from-promotion"
|
||||
|
||||
updatePromotionsWorkflow.hooks.promotionsUpdated(
|
||||
async ({ promotions, additional_data }, { container }) => {
|
||||
const workflow = updateCustomFromPromotionWorkflow(container)
|
||||
|
||||
for (let promotion of promotions) {
|
||||
for (const promotion of promotions) {
|
||||
await workflow.run({
|
||||
input: {
|
||||
promotion,
|
||||
additional_data
|
||||
} as UpdateCustomFromPromotionStepInput
|
||||
additional_data,
|
||||
} as UpdateCustomFromPromotionStepInput,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ module.exports = defineConfig({
|
||||
],
|
||||
},
|
||||
},
|
||||
]
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports = defineConfig({
|
||||
jwt_secret: process.env.JWT_SECRET,
|
||||
},
|
||||
},
|
||||
]
|
||||
],
|
||||
})
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user