docs: general updates after 2.5.0 update (#11402)

This commit is contained in:
Shahed Nasser
2025-02-11 18:26:21 +02:00
committed by GitHub
parent ca486aa7ed
commit 5cb44d364d
17 changed files with 11576 additions and 11565 deletions
@@ -288,7 +288,7 @@ const columns = [
}),
columnHelper.accessor("name", {
header: "Name",
})
}),
]
```
@@ -337,10 +337,10 @@ medusaIntegrationTestRunner({
{
type: "publishable",
title: "Test Key",
created_by: ""
}
]
}
created_by: "",
},
],
},
})).result[0]
})
describe("GET /custom", () => {
@@ -349,8 +349,8 @@ medusaIntegrationTestRunner({
`/store/custom`,
{
headers: {
"x-publishable-api-key": pak.token
}
"x-publishable-api-key": pak.token,
},
}
)
@@ -421,13 +421,13 @@ medusaIntegrationTestRunner({
provider: "emailpass",
entity_id: "admin@medusa.js",
provider_metadata: {
password: "supersecret"
}
}
password: "supersecret",
},
},
],
app_metadata: {
user_id: user.id
}
user_id: user.id,
},
})
const token = jwt.sign(
@@ -503,13 +503,13 @@ medusaIntegrationTestRunner({
provider: "emailpass",
entity_id: "customer@medusa.js",
provider_metadata: {
password: "supersecret"
}
}
password: "supersecret",
},
},
],
app_metadata: {
user_id: customer.id
}
user_id: customer.id,
},
})
const token = jwt.sign(
@@ -533,10 +533,10 @@ medusaIntegrationTestRunner({
{
type: "publishable",
title: "Test Key",
created_by: ""
}
]
}
created_by: "",
},
],
},
})).result[0]
headers["x-publishable-api-key"] = pak.token
@@ -126,7 +126,7 @@ medusaIntegrationTestRunner({
it("returns message", async () => {
const { errors } = await helloWorldWorkflow(getContainer())
.run({
throwOnError: false
throwOnError: false,
})
expect(errors.length).toBeGreaterThan(0)
@@ -10,59 +10,59 @@ In this chapter, you'll learn how to manage relationships between data models wh
### BelongsTo Side of One-to-One
When you create a record of a data model that belongs to another through a one-to-one relation, pass the ID of the other data model's record in the relation property.
When you create a record of a data model that belongs to another through a one-to-one relation, pass the ID of the other data model's record in the `{relation}_id` property, where `{relation}` is the name of the relation property.
For example, assuming you have the [User and Email data models from the previous chapter](../relationships/page.mdx#one-to-one-relationship), set an email's user ID as follows:
export const belongsHighlights = [
["4", "user", "The ID of the user the email belongs to."],
["11", "user", "The ID of the user the email belongs to."]
["4", "user_id", "The ID of the user the email belongs to."],
["11", "user_id", "The ID of the user the email belongs to."]
]
```ts highlights={belongsHighlights}
// when creating an email
const email = await helloModuleService.createEmails({
// other properties...
user: "123",
user_id: "123",
})
// when updating an email
const email = await helloModuleService.updateEmails({
id: "321",
// other properties...
user: "123",
user_id: "123",
})
```
In the example above, you pass the `user` property when creating or updating an email to specify the user it belongs to.
In the example above, you pass the `user_id` property when creating or updating an email to specify the user it belongs to.
### HasOne Side
When you create a record of a data model that has one of another, pass the ID of the other data model's record in the relation property.
When you create a record of a data model that has one of another, pass the ID of the other data model's record in the `{relation}_id` property, where `{relation}` is the name of the relation property.
For example, assuming you have the [User and Email data models from the previous chapter](../relationships/page.mdx#one-to-one-relationship), set a user's email ID as follows:
export const hasOneHighlights = [
["4", "email", "The ID of the email that the user has."],
["11", "email", "The ID of the email that the user has."]
["4", "email_id", "The ID of the email that the user has."],
["11", "email_id", "The ID of the email that the user has."]
]
```ts highlights={hasOneHighlights}
// when creating a user
const user = await helloModuleService.createUsers({
// other properties...
email: "123",
email_id: "123",
})
// when updating a user
const user = await helloModuleService.updateUsers({
id: "321",
// other properties...
email: "123",
email_id: "123",
})
```
In the example above, you pass the `email` property when creating or updating a user to specify the email it has.
In the example above, you pass the `email_id` property when creating or updating a user to specify the email it has.
---
@@ -33,7 +33,7 @@ const { data } = await query.graph({
fields: ["*"],
context: QueryContext({
lang: "es",
})
}),
})
```
@@ -58,7 +58,7 @@ import Author from "./models/author"
class BlogModuleService extends MedusaService({
Post,
Author
Author,
}){
// @ts-ignore
async listPosts(
@@ -125,8 +125,8 @@ const { data } = await query.graph({
lang: "es",
author: QueryContext({
lang: "es",
})
})
}),
}),
})
```
@@ -144,7 +144,7 @@ import Author from "./models/author"
class BlogModuleService extends MedusaService({
Post,
Author
Author,
}){
// @ts-ignore
async listPosts(
@@ -168,7 +168,7 @@ class BlogModuleService extends MedusaService({
author: {
...post.author,
name: isAuthorLangEs ? post.author.name + " en español" : post.author.name,
}
},
}
})
}
@@ -201,8 +201,8 @@ const { data } = await query.graph({
context: {
post: QueryContext({
lang: "es",
})
}
}),
},
})
```
@@ -50,7 +50,7 @@ import { createStep, createWorkflow } from "@medusajs/framework/workflows-sdk"
const step1 = createStep(
{
name: "step-1"
name: "step-1",
},
async () => {
console.log("Hello from step 1")
@@ -61,7 +61,7 @@ export const helloWorkflow = createWorkflow(
{
name: "hello-workflow",
retentionTime: 99999,
store: true
store: true,
},
() => {
step1()
@@ -98,8 +98,8 @@ export const retrieveHighlights = [
]
```ts title="src/workflows/[id]/route.ts" highlights={retrieveHighlights}
import { MedusaRequest, MedusaResponse } from "@medusajs/framework";
import { Modules } from "@medusajs/framework/utils";
import { MedusaRequest, MedusaResponse } from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"
export async function GET(
req: MedusaRequest,
@@ -112,11 +112,11 @@ export async function GET(
)
const [workflowExecution] = await workflowEngineService.listWorkflowExecutions({
transaction_id: transaction_id
transaction_id: transaction_id,
})
res.json({
workflowExecution
workflowExecution,
})
}
```
@@ -165,7 +165,7 @@ To check if a stored workflow execution failed, you can check its `state` proper
```ts
if (workflowExecution.state === "failed") {
return res.status(500).json({
error: "Workflow failed"
error: "Workflow failed",
})
}
```