docs: general fixes and improvements (#7918)

* docs improvements and changes

* updated module definition

* modules + dml changes

* fix build

* fix vale error

* fix lint errors

* fixes to stripe docs

* fix condition

* fix condition

* fix module defintion

* fix checkout

* disable UI action

* change oas preview action

* flatten provider module options

* fix lint errors

* add module link docs

* pr comments fixes

* fix vale error

* change node engine version

* links -> linkable

* add note about database name

* small fixes

* link fixes

* fix response code in api reference

* added migrations step
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-07-04 17:26:03 +03:00
1 parent 32982e708a
commit 964927b597
149 files changed
+1676 -3008

No files matched your search

@@ -23,9 +23,10 @@ Start by creating the file `src/workflows/update-product-erp/index.ts` that will
In the file, add the type of the expected workflow input:
```ts title="src/workflows/update-product-erp/index.ts"
import { UpdateProductDTO } from "@medusajs/types"
import { UpsertProductDTO } from "@medusajs/types"
export type UpdateProductAndErpWorkflowInput = UpsertProductDTO
export type UpdateProductAndErpWorkflowInput = UpdateProductDTO
```
The expected input is the data to update in the product along with the product’s ID.
@@ -40,17 +41,9 @@ Create the file `src/workflows/update-product-erp/steps/update-product.ts` with
export const updateProductHighlights = [
["13", "resolve", "Resolve the `ProductService` from the Medusa container."],
[
"16",
"previousProductData",
"Retrieve the `previousProductData` to pass it to the compensation function.",
],
["19", "", "Update the product."],
[
"39",
"",
"Revert the product’s data using the `previousProductData` passed from the step to the compensation function.",
],
["16", "previousProductData", "Retrieve the `previousProductData` to pass it to the compensation function."],
["19", "updateProducts", "Update the product."],
["39", "updateProducts", "Revert the product’s data using the `previousProductData` passed from the step to the compensation function."]
]
```ts title="src/workflows/update-product-erp/steps/update-product.ts" highlights={updateProductHighlights} collapsibleLines="1-9" expandButtonLabel="Show Imports"
@@ -66,9 +59,10 @@ const updateProduct = createStep(
context.container.resolve(ModuleRegistrationName.PRODUCT)
const { id } = input
const previousProductData = await productModuleService.retrieve(id)
const previousProductData =
await productModuleService.retrieveProduct(id)
const product = await productModuleService.update(id, input)
const product = await productModuleService.updateProducts(id, input)
return new StepResponse(product, {
// pass to compensation function
@@ -82,10 +76,12 @@ const updateProduct = createStep(
const { id, type, options, variants, ...previousData } = previousProductData
await productModuleService.update(id, {
...previousData,
variants: variants.map((variant) => {
const variantOptions = {}
await productModuleService.updateProducts(
id,
{
...previousData,
variants: variants.map((variant) => {
const variantOptions = {}
variant.options.forEach((option) => {
variantOptions[option.option.title] = option.value
@@ -110,7 +106,7 @@ export default updateProduct
In the step:
- You resolve the `ProductService` from the Medusa container.
- You resolve the Product Module's main service from the Medusa container.
- You retrieve the `previousProductData` to pass it to the compensation function.
- You update and return the product.
@@ -211,11 +207,11 @@ Change the content of `src/workflows/update-product-erp/index.ts` to the followi
```ts title="src/workflows/update-product-erp/index.ts" collapsibleLines="1-6" expandButtonLabel="Show Imports"
import { createWorkflow } from "@medusajs/workflows-sdk"
import { UpdateProductDTO, ProductDTO } from "@medusajs/types"
import { UpsertProductDTO, ProductDTO } from "@medusajs/types"
import updateProduct from "./steps/update-product"
import updateErp from "./steps/update-erp"
export type UpdateProductAndErpWorkflowInput = UpdateProductDTO
export type UpdateProductAndErpWorkflowInput = UpsertProductDTO
type WorkflowOutput = {
product: ProductDTO