[]
+ pageSize: number
+ count: number
+ currentPage: number
+ setCurrentPage: (value: number) => void
+}
+
+export const Table = ({
+ columns,
+ data,
+ pageSize,
+ count,
+ currentPage,
+ setCurrentPage,
+}: TableProps) => {
+ const pageCount = useMemo(() => {
+ return Math.ceil(count / pageSize)
+ }, [data, pageSize])
+
+ const canNextPage = useMemo(() => {
+ return currentPage < pageCount - 1
+ }, [currentPage, pageCount])
+ const canPreviousPage = useMemo(() => {
+ return currentPage - 1 >= 0
+ }, [currentPage])
+
+ const nextPage = () => {
+ if (canNextPage) {
+ setCurrentPage(currentPage + 1)
+ }
+ }
+
+ const previousPage = () => {
+ if (canPreviousPage) {
+ setCurrentPage(currentPage - 1)
+ }
+ }
-export const Container = (props: ContainerProps) => {
return (
-
+
+
+
+
+ {columns.map((column, index) => (
+
+ {column.label || column.key}
+
+ ))}
+
+
+
+ {data.map((item, index) => {
+ const rowIndex = "id" in item ? item.id as string : index
+ return (
+
+ {columns.map((column, index) => (
+
+ <>
+ {column.render && column.render(item[column.key])}
+ {!column.render && (
+ <>{item[column.key] as string}>
+ )}
+ >
+
+ ))}
+
+ )
+ })}
+
+
+
+
)
}
```
-The `Container` component re-uses the component from the [Medusa UI package](https://docs.medusajs.com/ui/components/container/index.html.md) and applies to it classes to match the Medusa Admin's design conventions.
+The `Table` component uses the component from the [UI package](https://docs.medusajs.com/ui/components/table/index.html.md), with additional styling and rendering of data.
+
+It accepts the following props:
+
+- columns: (\`object\[]\`) The table's columns.
+
+ - key: (\`string\`) The column's key in the passed \`data\`
+
+ - label: (\`string\`) The column's label shown in the table. If not provided, the \`key\` is used.
+
+ - render: (\`(value: unknown) => React.ReactNode\`) By default, the data is shown as-is in the table. You can use this function to change how the value is rendered. The function receives the value is a parameter and returns a React node.
+- data: (\`Record\\[]\`) The data to show in the table for the current page. The keys of each object should be in the \`columns\` array.
+- pageSize: (\`number\`) The number of items to show per page.
+- count: (\`number\`) The total number of items.
+- currentPage: (\`number\`) A zero-based index indicating the current page's number.
+- setCurrentPage: (\`(value: number) => void\`) A function used to change the current page.
***
## Example
-Use that `Container` component in any widget or UI route.
+Use the `Table` component in any widget or UI route.
For example, create the widget `src/admin/widgets/product-widget.tsx` with the following content:
```tsx title="src/admin/widgets/product-widget.tsx"
import { defineWidgetConfig } from "@medusajs/admin-sdk"
+import { StatusBadge } from "@medusajs/ui"
+import { Table } from "../components/table"
+import { useState } from "react"
import { Container } from "../components/container"
-import { Header } from "../components/header"
const ProductWidget = () => {
+ const [currentPage, setCurrentPage] = useState(0)
+
return (
-
+ {
+ const isEnabled = value as boolean
+
+ return (
+
+ {isEnabled ? "Enabled" : "Disabled"}
+
+ )
+ },
+ },
+ ]}
+ data={[
+ {
+ name: "John",
+ is_enabled: true,
+ },
+ {
+ name: "Jane",
+ is_enabled: false,
+ },
+ ]}
+ pageSize={2}
+ count={2}
+ currentPage={currentPage}
+ setCurrentPage={setCurrentPage}
+ />
)
}
@@ -48788,7 +48976,108 @@ export const config = defineWidgetConfig({
export default ProductWidget
```
-This widget also uses a [Header](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/admin-components/components/header/index.html.md) custom component.
+This widget also uses the [Container](../container.mdx) custom component.
+
+***
+
+## Example With Data Fetching
+
+This section shows you how to use the `Table` component when fetching data from the Medusa application's API routes.
+
+Assuming you've set up the JS SDK as explained in [this guide](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/js-sdk/index.html.md), create the UI route `src/admin/routes/custom/page.tsx` with the following content:
+
+```tsx title="src/admin/routes/custom/page.tsx" collapsibleLines="1-10" expandButtonLabel="Show Imports" highlights={tableExampleHighlights}
+import { defineRouteConfig } from "@medusajs/admin-sdk"
+import { ChatBubbleLeftRight } from "@medusajs/icons"
+import { useQuery } from "@tanstack/react-query"
+import { SingleColumnLayout } from "../../layouts/single-column"
+import { Table } from "../../components/table"
+import { sdk } from "../../lib/config"
+import { useMemo, useState } from "react"
+import { Container } from "../../components/container"
+import { Header } from "../../components/header"
+
+const CustomPage = () => {
+ const [currentPage, setCurrentPage] = useState(0)
+ const limit = 15
+ const offset = useMemo(() => {
+ return currentPage * limit
+ }, [currentPage])
+
+ const { data } = useQuery({
+ queryFn: () => sdk.admin.product.list({
+ limit,
+ offset,
+ }),
+ queryKey: [["products", limit, offset]],
+ })
+
+ // TODO display table
+}
+
+export const config = defineRouteConfig({
+ label: "Custom",
+ icon: ChatBubbleLeftRight,
+})
+
+export default CustomPage
+```
+
+In the `CustomPage` component, you define:
+
+- A state variable `currentPage` that stores the current page of the table.
+- A `limit` variable, indicating how many items to retrieve per page
+- An `offset` memoized variable indicating how many items to skip before the retrieved items. It's calculated as a multiplication of `currentPage` and `limit`.
+
+Then, you use `useQuery` from [Tanstack Query](https://tanstack.com/query/latest) to retrieve products using the JS SDK. You pass `limit` and `offset` as query parameters, and you set the `queryKey`, which is used for caching and revalidation, to be based on the key `products`, along with the current limit and offset. So, whenever the `offset` variable changes, the request is sent again to retrieve the products of the current page.
+
+You can change the query to send a request to a custom API route as explained in [this guide](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/js-sdk#send-requests-to-custom-routes/index.html.md).
+
+Do not install Tanstack Query as that will cause unexpected errors in your development. If you prefer installing it for better auto-completion in your code editor, make sure to install `v5.64.2` as a development dependency.
+
+`useQuery` returns an object containing `data`, which holds the response fields including the products and pagination fields.
+
+Then, to display the table, replace the `TODO` with the following:
+
+```tsx
+return (
+
+
+
+ {data && (
+
+ )}
+
+
+)
+```
+
+Aside from the `Table` component, this UI route also uses the [SingleColumnLayout](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/admin-components/layouts/single-column/index.html.md), [Container](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/admin-components/components/container/index.html.md), and [Header](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/admin-components/components/header/index.html.md) custom component.
+
+If `data` isn't `undefined`, you display the `Table` component passing it the following props:
+
+- `columns`: The columns to show. You only show the product's ID and title.
+- `data`: The rows of the table. You pass it the `products` property of `data`.
+- `pageSize`: The maximum number of items per page. You pass it the `count` property of `data`.
+- `currentPage` and `setCurrentPage`: The current page and the function to change it.
+
+To test it out, log into the Medusa Admin and open `http://localhost:9000/app/custom`. You'll find a table of products with pagination.
# Section Row - Admin Components
@@ -49111,296 +49400,6 @@ export default ProductWidget
This shows the JSON section at the top of the product page, passing it the object `{ name: "John" }`.
-# Table - Admin Components
-
-If you're using [Medusa v2.4.0+](https://github.com/medusajs/medusa/releases/tag/v2.4.0), it's recommended to use the [Data Table](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/admin-components/components/data-table/index.html.md) component instead as it provides features for sorting, filtering, pagination, and more with a simpler API.
-
-You can use the `Table` component from Medusa UI to display data in a table. It's mostly recommended for simpler tables.
-
-To create a component that shows a table with pagination, create the file `src/admin/components/table.tsx` with the following content:
-
-```tsx title="src/admin/components/table.tsx"
-import { useMemo } from "react"
-import { Table as UiTable } from "@medusajs/ui"
-
-export type TableProps = {
- columns: {
- key: string
- label?: string
- render?: (value: unknown) => React.ReactNode
- }[]
- data: Record[]
- pageSize: number
- count: number
- currentPage: number
- setCurrentPage: (value: number) => void
-}
-
-export const Table = ({
- columns,
- data,
- pageSize,
- count,
- currentPage,
- setCurrentPage,
-}: TableProps) => {
- const pageCount = useMemo(() => {
- return Math.ceil(count / pageSize)
- }, [data, pageSize])
-
- const canNextPage = useMemo(() => {
- return currentPage < pageCount - 1
- }, [currentPage, pageCount])
- const canPreviousPage = useMemo(() => {
- return currentPage - 1 >= 0
- }, [currentPage])
-
- const nextPage = () => {
- if (canNextPage) {
- setCurrentPage(currentPage + 1)
- }
- }
-
- const previousPage = () => {
- if (canPreviousPage) {
- setCurrentPage(currentPage - 1)
- }
- }
-
- return (
-
-
-
-
- {columns.map((column, index) => (
-
- {column.label || column.key}
-
- ))}
-
-
-
- {data.map((item, index) => {
- const rowIndex = "id" in item ? item.id as string : index
- return (
-
- {columns.map((column, index) => (
-
- <>
- {column.render && column.render(item[column.key])}
- {!column.render && (
- <>{item[column.key] as string}>
- )}
- >
-
- ))}
-
- )
- })}
-
-
-
-
- )
-}
-```
-
-The `Table` component uses the component from the [UI package](https://docs.medusajs.com/ui/components/table/index.html.md), with additional styling and rendering of data.
-
-It accepts the following props:
-
-- columns: (\`object\[]\`) The table's columns.
-
- - key: (\`string\`) The column's key in the passed \`data\`
-
- - label: (\`string\`) The column's label shown in the table. If not provided, the \`key\` is used.
-
- - render: (\`(value: unknown) => React.ReactNode\`) By default, the data is shown as-is in the table. You can use this function to change how the value is rendered. The function receives the value is a parameter and returns a React node.
-- data: (\`Record\\[]\`) The data to show in the table for the current page. The keys of each object should be in the \`columns\` array.
-- pageSize: (\`number\`) The number of items to show per page.
-- count: (\`number\`) The total number of items.
-- currentPage: (\`number\`) A zero-based index indicating the current page's number.
-- setCurrentPage: (\`(value: number) => void\`) A function used to change the current page.
-
-***
-
-## Example
-
-Use the `Table` component in any widget or UI route.
-
-For example, create the widget `src/admin/widgets/product-widget.tsx` with the following content:
-
-```tsx title="src/admin/widgets/product-widget.tsx"
-import { defineWidgetConfig } from "@medusajs/admin-sdk"
-import { StatusBadge } from "@medusajs/ui"
-import { Table } from "../components/table"
-import { useState } from "react"
-import { Container } from "../components/container"
-
-const ProductWidget = () => {
- const [currentPage, setCurrentPage] = useState(0)
-
- return (
-
- {
- const isEnabled = value as boolean
-
- return (
-
- {isEnabled ? "Enabled" : "Disabled"}
-
- )
- },
- },
- ]}
- data={[
- {
- name: "John",
- is_enabled: true,
- },
- {
- name: "Jane",
- is_enabled: false,
- },
- ]}
- pageSize={2}
- count={2}
- currentPage={currentPage}
- setCurrentPage={setCurrentPage}
- />
-
- )
-}
-
-export const config = defineWidgetConfig({
- zone: "product.details.before",
-})
-
-export default ProductWidget
-```
-
-This widget also uses the [Container](../container.mdx) custom component.
-
-***
-
-## Example With Data Fetching
-
-This section shows you how to use the `Table` component when fetching data from the Medusa application's API routes.
-
-Assuming you've set up the JS SDK as explained in [this guide](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/js-sdk/index.html.md), create the UI route `src/admin/routes/custom/page.tsx` with the following content:
-
-```tsx title="src/admin/routes/custom/page.tsx" collapsibleLines="1-10" expandButtonLabel="Show Imports" highlights={tableExampleHighlights}
-import { defineRouteConfig } from "@medusajs/admin-sdk"
-import { ChatBubbleLeftRight } from "@medusajs/icons"
-import { useQuery } from "@tanstack/react-query"
-import { SingleColumnLayout } from "../../layouts/single-column"
-import { Table } from "../../components/table"
-import { sdk } from "../../lib/config"
-import { useMemo, useState } from "react"
-import { Container } from "../../components/container"
-import { Header } from "../../components/header"
-
-const CustomPage = () => {
- const [currentPage, setCurrentPage] = useState(0)
- const limit = 15
- const offset = useMemo(() => {
- return currentPage * limit
- }, [currentPage])
-
- const { data } = useQuery({
- queryFn: () => sdk.admin.product.list({
- limit,
- offset,
- }),
- queryKey: [["products", limit, offset]],
- })
-
- // TODO display table
-}
-
-export const config = defineRouteConfig({
- label: "Custom",
- icon: ChatBubbleLeftRight,
-})
-
-export default CustomPage
-```
-
-In the `CustomPage` component, you define:
-
-- A state variable `currentPage` that stores the current page of the table.
-- A `limit` variable, indicating how many items to retrieve per page
-- An `offset` memoized variable indicating how many items to skip before the retrieved items. It's calculated as a multiplication of `currentPage` and `limit`.
-
-Then, you use `useQuery` from [Tanstack Query](https://tanstack.com/query/latest) to retrieve products using the JS SDK. You pass `limit` and `offset` as query parameters, and you set the `queryKey`, which is used for caching and revalidation, to be based on the key `products`, along with the current limit and offset. So, whenever the `offset` variable changes, the request is sent again to retrieve the products of the current page.
-
-You can change the query to send a request to a custom API route as explained in [this guide](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/js-sdk#send-requests-to-custom-routes/index.html.md).
-
-Do not install Tanstack Query as that will cause unexpected errors in your development. If you prefer installing it for better auto-completion in your code editor, make sure to install `v5.64.2` as a development dependency.
-
-`useQuery` returns an object containing `data`, which holds the response fields including the products and pagination fields.
-
-Then, to display the table, replace the `TODO` with the following:
-
-```tsx
-return (
-
-
-
- {data && (
-
- )}
-
-
-)
-```
-
-Aside from the `Table` component, this UI route also uses the [SingleColumnLayout](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/admin-components/layouts/single-column/index.html.md), [Container](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/admin-components/components/container/index.html.md), and [Header](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/admin-components/components/header/index.html.md) custom component.
-
-If `data` isn't `undefined`, you display the `Table` component passing it the following props:
-
-- `columns`: The columns to show. You only show the product's ID and title.
-- `data`: The rows of the table. You pass it the `products` property of `data`.
-- `pageSize`: The maximum number of items per page. You pass it the `count` property of `data`.
-- `currentPage` and `setCurrentPage`: The current page and the function to change it.
-
-To test it out, log into the Medusa Admin and open `http://localhost:9000/app/custom`. You'll find a table of products with pagination.
-
-
# Service Factory Reference
This section of the documentation provides a reference of the methods generated for services extending the service factory (`MedusaService`), and how to use them.
@@ -49466,6 +49465,531 @@ const posts = await postModuleService.createPosts([
If an array is passed of the method, an array of the created records is also returned.
+# delete Method - Service Factory Reference
+
+This method deletes one or more records.
+
+## Delete One Record
+
+```ts
+await postModuleService.deletePosts("123")
+```
+
+To delete one record, pass its ID as a parameter of the method.
+
+***
+
+## Delete Multiple Records
+
+```ts
+await postModuleService.deletePosts([
+ "123",
+ "321",
+])
+```
+
+To delete multiple records, pass an array of IDs as a parameter of the method.
+
+***
+
+## Delete Records Matching Filters
+
+```ts
+await postModuleService.deletePosts({
+ name: "My Post",
+})
+```
+
+To delete records matching a set of filters, pass an object of filters as a parameter.
+
+Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
+
+
+# list Method - Service Factory Reference
+
+This method retrieves a list of records.
+
+## Retrieve List of Records
+
+```ts
+const posts = await postModuleService.listPosts()
+```
+
+If no parameters are passed, the method returns an array of the first `15` records.
+
+***
+
+## Filter Records
+
+```ts
+const posts = await postModuleService.listPosts({
+ id: ["123", "321"],
+})
+```
+
+### Parameters
+
+To retrieve records matching a set of filters, pass an object of the filters as a first parameter.
+
+Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
+
+### Returns
+
+The method returns an array of the first `15` records matching the filters.
+
+***
+
+## Retrieve Relations
+
+This applies to relations between data models of the same module. To retrieve linked records of different modules, use [Query](https://docs.medusajs.com/docs/learn/fundamentals/module-links/query/index.html.md).
+
+```ts
+const posts = await postModuleService.listPosts({}, {
+ relations: ["author"],
+})
+```
+
+### Parameters
+
+To retrieve records with their relations, pass as a second parameter an object having a `relations` property. `relations`'s value is an array of relation names.
+
+### Returns
+
+The method returns an array of the first `15` records matching the filters.
+
+***
+
+## Select Properties
+
+```ts
+const posts = await postModuleService.listPosts({}, {
+ select: ["id", "name"],
+})
+```
+
+### Parameters
+
+By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property.
+
+`select`'s value is an array of property names to retrieve.
+
+### Returns
+
+The method returns an array of the first `15` records matching the filters.
+
+***
+
+## Paginate Relations
+
+```ts
+const posts = await postModuleService.listPosts({}, {
+ take: 20,
+ skip: 10,
+})
+```
+
+### Parameters
+
+To paginate the returned records, the second object parameter accepts the following properties:
+
+- `take`: a number indicating how many records to retrieve. By default, it's `15`.
+- `skip`: a number indicating how many records to skip before the retrieved records. By default, it's `0`.
+
+### Returns
+
+The method returns an array of records. The number of records is less than or equal to `take`'s value.
+
+***
+
+## Sort Records
+
+```ts
+const posts = await postModuleService.listPosts({}, {
+ order: {
+ name: "ASC",
+ },
+})
+```
+
+### Parameters
+
+To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be:
+
+- `ASC` to sort by this property in the ascending order.
+- `DESC` to sort by this property in the descending order.
+
+### Returns
+
+The method returns an array of the first `15` records matching the filters.
+
+
+# listAndCount Method - Service Factory Reference
+
+This method retrieves a list of records with the total count.
+
+## Retrieve List of Records
+
+```ts
+const [posts, count] = await postModuleService.listAndCountPosts()
+```
+
+If no parameters are passed, the method returns an array with two items:
+
+1. The first is an array of the first `15` records retrieved.
+2. The second is the total count of records.
+
+***
+
+## Filter Records
+
+```ts
+const [posts, count] = await postModuleService.listAndCountPosts({
+ id: ["123", "321"],
+})
+```
+
+### Parameters
+
+To retrieve records matching a set of filters, pass an object of the filters as a first parameter.
+
+Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
+
+### Returns
+
+The method returns an array with two items:
+
+1. The first is an array of the first `15` records retrieved matching the specified filters.
+2. The second is the total count of records matching the specified filters.
+
+***
+
+## Retrieve Relations
+
+This applies to relations between data models of the same module. To retrieve linked records of different modules, use [Query](https://docs.medusajs.com/docs/learn/fundamentals/module-links/query/index.html.md).
+
+```ts
+const [posts, count] = await postModuleService.listAndCountPosts({}, {
+ relations: ["author"],
+})
+```
+
+### Parameters
+
+To retrieve records with their relations, pass as a second parameter an object having a `relations` property. Its value is an array of relation names.
+
+### Returns
+
+The method returns an array with two items:
+
+1. The first is an array of the first `15` records retrieved.
+2. The second is the total count of records.
+
+***
+
+## Select Properties
+
+```ts
+const [posts, count] = await postModuleService.listAndCountPosts({}, {
+ select: ["id", "name"],
+})
+```
+
+### Parameters
+
+By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property.
+
+`select`'s value is an array of property names to retrieve.
+
+### Returns
+
+The method returns an array with two items:
+
+1. The first is an array of the first `15` records retrieved.
+2. The second is the total count of records.
+
+***
+
+## Paginate Relations
+
+```ts
+const [posts, count] = await postModuleService.listAndCountPosts({}, {
+ take: 20,
+ skip: 10,
+})
+```
+
+### Parameters
+
+To paginate the returned records, the second object parameter accepts the following properties:
+
+- `take`: a number indicating how many records to retrieve. By default, it's `15`.
+- `skip`: a number indicating how many records to skip before the retrieved records. By default, it's `0`.
+
+### Returns
+
+The method returns an array with two items:
+
+1. The first is an array of the records retrieved. The number of records is less than or equal to `take`'s value.
+2. The second is the total count of records.
+
+***
+
+## Sort Records
+
+```ts
+const [posts, count] = await postModuleService.listAndCountPosts({}, {
+ order: {
+ name: "ASC",
+ },
+})
+```
+
+### Parameters
+
+To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be:
+
+- `ASC` to sort by this property in the ascending order.
+- `DESC` to sort by this property in the descending order.
+
+### Returns
+
+The method returns an array with two items:
+
+1. The first is an array of the first `15` records retrieved.
+2. The second is the total count of records.
+
+
+# retrieve Method - Service Factory Reference
+
+This method retrieves one record of the data model by its ID.
+
+## Retrieve a Record
+
+```ts
+const post = await postModuleService.retrievePost("123")
+```
+
+### Parameters
+
+Pass the ID of the record to retrieve.
+
+### Returns
+
+The method returns the record as an object.
+
+***
+
+## Retrieve a Record's Relations
+
+This applies to relations between data models of the same module. To retrieve linked records of different modules, use [Query](https://docs.medusajs.com/docs/learn/fundamentals/module-links/query/index.html.md).
+
+```ts
+const post = await postModuleService.retrievePost("123", {
+ relations: ["author"],
+})
+```
+
+### Parameters
+
+To retrieve the data model with relations, pass as a second parameter of the method an object with the property `relations`. `relations`'s value is an array of relation names.
+
+### Returns
+
+The method returns the record as an object.
+
+***
+
+## Select Properties to Retrieve
+
+```ts
+const post = await postModuleService.retrievePost("123", {
+ select: ["id", "name"],
+})
+```
+
+### Parameters
+
+By default, all of the record's properties are retrieved. To select specific ones, pass in the second object parameter a `select` property. Its value is an array of property names.
+
+### Returns
+
+The method returns the record as an object.
+
+
+# restore Method - Service Factory Reference
+
+This method restores one or more records of the data model that were [soft-deleted](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/methods/soft-delete/index.html.md).
+
+## Restore One Record
+
+```ts
+const restoredPosts = await postModuleService.restorePosts("123")
+```
+
+### Parameters
+
+To restore one record, pass its ID as a parameter of the method.
+
+### Returns
+
+The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of restored records' IDs.
+
+For example, the returned object of the above example is:
+
+```ts
+restoredPosts = {
+ post_id: ["123"],
+}
+```
+
+***
+
+## Restore Multiple Records
+
+```ts
+const restoredPosts = await postModuleService.restorePosts([
+ "123",
+ "321",
+])
+```
+
+### Parameters
+
+To restore multiple records, pass an array of IDs as a parameter of the method.
+
+### Returns
+
+The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of restored records' IDs.
+
+For example, the returned object of the above example is:
+
+```ts
+restoredPosts = {
+ post_id: [
+ "123",
+ "321",
+ ],
+}
+```
+
+***
+
+## Restore Records Matching Filters
+
+```ts
+const restoredPosts = await postModuleService.restorePosts({
+ name: "My Post",
+})
+```
+
+### Parameters
+
+To restore records matching a set of filters, pass an object of fitlers as a parameter of the method.
+
+Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
+
+### Returns
+
+The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of restored records' IDs.
+
+For example, the returned object of the above example is:
+
+```ts
+restoredPosts = {
+ post_id: [
+ "123",
+ ],
+}
+```
+
+
+# softDelete Method - Service Factory Reference
+
+This method soft deletes one or more records of the data model.
+
+## Soft Delete One Record
+
+```ts
+const deletedPosts = await postModuleService.softDeletePosts(
+ "123"
+)
+```
+
+### Parameters
+
+To soft delete a record, pass its ID as a parameter of the method.
+
+### Returns
+
+The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of soft-deleted records' IDs.
+
+For example, the returned object of the above example is:
+
+```ts
+deletedPosts = {
+ post_id: ["123"],
+}
+```
+
+***
+
+## Soft Delete Multiple Records
+
+```ts
+const deletedPosts = await postModuleService.softDeletePosts([
+ "123",
+ "321",
+])
+```
+
+### Parameters
+
+To soft delete multiple records, pass an array of IDs as a parameter of the method.
+
+### Returns
+
+The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of soft-deleted records' IDs.
+
+For example, the returned object of the above example is:
+
+```ts
+deletedPosts = {
+ post_id: [
+ "123",
+ "321",
+ ],
+}
+```
+
+***
+
+## Soft Delete Records Matching Filters
+
+```ts
+const deletedPosts = await postModuleService.softDeletePosts({
+ name: "My Post",
+})
+```
+
+### Parameters
+
+To soft delete records matching a set of filters, pass an object of filters as a parameter.
+
+Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
+
+### Returns
+
+The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of soft-deleted records' IDs.
+
+For example, the returned object of the above example is:
+
+```ts
+deletedPosts = {
+ post_id: ["123"],
+}
+```
+
+
# Filter Records - Service Factory Reference
Many of the service factory's generated methods allow passing filters to perform an operation, such as to update or delete records matching the filters.
@@ -49724,531 +50248,6 @@ In the example above, posts are retrieved if they meet either of the following c
By combining `and` and `or` conditions, you can create complex filters to retrieve records that meet specific criteria.
-# list Method - Service Factory Reference
-
-This method retrieves a list of records.
-
-## Retrieve List of Records
-
-```ts
-const posts = await postModuleService.listPosts()
-```
-
-If no parameters are passed, the method returns an array of the first `15` records.
-
-***
-
-## Filter Records
-
-```ts
-const posts = await postModuleService.listPosts({
- id: ["123", "321"],
-})
-```
-
-### Parameters
-
-To retrieve records matching a set of filters, pass an object of the filters as a first parameter.
-
-Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
-
-### Returns
-
-The method returns an array of the first `15` records matching the filters.
-
-***
-
-## Retrieve Relations
-
-This applies to relations between data models of the same module. To retrieve linked records of different modules, use [Query](https://docs.medusajs.com/docs/learn/fundamentals/module-links/query/index.html.md).
-
-```ts
-const posts = await postModuleService.listPosts({}, {
- relations: ["author"],
-})
-```
-
-### Parameters
-
-To retrieve records with their relations, pass as a second parameter an object having a `relations` property. `relations`'s value is an array of relation names.
-
-### Returns
-
-The method returns an array of the first `15` records matching the filters.
-
-***
-
-## Select Properties
-
-```ts
-const posts = await postModuleService.listPosts({}, {
- select: ["id", "name"],
-})
-```
-
-### Parameters
-
-By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property.
-
-`select`'s value is an array of property names to retrieve.
-
-### Returns
-
-The method returns an array of the first `15` records matching the filters.
-
-***
-
-## Paginate Relations
-
-```ts
-const posts = await postModuleService.listPosts({}, {
- take: 20,
- skip: 10,
-})
-```
-
-### Parameters
-
-To paginate the returned records, the second object parameter accepts the following properties:
-
-- `take`: a number indicating how many records to retrieve. By default, it's `15`.
-- `skip`: a number indicating how many records to skip before the retrieved records. By default, it's `0`.
-
-### Returns
-
-The method returns an array of records. The number of records is less than or equal to `take`'s value.
-
-***
-
-## Sort Records
-
-```ts
-const posts = await postModuleService.listPosts({}, {
- order: {
- name: "ASC",
- },
-})
-```
-
-### Parameters
-
-To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be:
-
-- `ASC` to sort by this property in the ascending order.
-- `DESC` to sort by this property in the descending order.
-
-### Returns
-
-The method returns an array of the first `15` records matching the filters.
-
-
-# restore Method - Service Factory Reference
-
-This method restores one or more records of the data model that were [soft-deleted](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/methods/soft-delete/index.html.md).
-
-## Restore One Record
-
-```ts
-const restoredPosts = await postModuleService.restorePosts("123")
-```
-
-### Parameters
-
-To restore one record, pass its ID as a parameter of the method.
-
-### Returns
-
-The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of restored records' IDs.
-
-For example, the returned object of the above example is:
-
-```ts
-restoredPosts = {
- post_id: ["123"],
-}
-```
-
-***
-
-## Restore Multiple Records
-
-```ts
-const restoredPosts = await postModuleService.restorePosts([
- "123",
- "321",
-])
-```
-
-### Parameters
-
-To restore multiple records, pass an array of IDs as a parameter of the method.
-
-### Returns
-
-The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of restored records' IDs.
-
-For example, the returned object of the above example is:
-
-```ts
-restoredPosts = {
- post_id: [
- "123",
- "321",
- ],
-}
-```
-
-***
-
-## Restore Records Matching Filters
-
-```ts
-const restoredPosts = await postModuleService.restorePosts({
- name: "My Post",
-})
-```
-
-### Parameters
-
-To restore records matching a set of filters, pass an object of fitlers as a parameter of the method.
-
-Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
-
-### Returns
-
-The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of restored records' IDs.
-
-For example, the returned object of the above example is:
-
-```ts
-restoredPosts = {
- post_id: [
- "123",
- ],
-}
-```
-
-
-# listAndCount Method - Service Factory Reference
-
-This method retrieves a list of records with the total count.
-
-## Retrieve List of Records
-
-```ts
-const [posts, count] = await postModuleService.listAndCountPosts()
-```
-
-If no parameters are passed, the method returns an array with two items:
-
-1. The first is an array of the first `15` records retrieved.
-2. The second is the total count of records.
-
-***
-
-## Filter Records
-
-```ts
-const [posts, count] = await postModuleService.listAndCountPosts({
- id: ["123", "321"],
-})
-```
-
-### Parameters
-
-To retrieve records matching a set of filters, pass an object of the filters as a first parameter.
-
-Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
-
-### Returns
-
-The method returns an array with two items:
-
-1. The first is an array of the first `15` records retrieved matching the specified filters.
-2. The second is the total count of records matching the specified filters.
-
-***
-
-## Retrieve Relations
-
-This applies to relations between data models of the same module. To retrieve linked records of different modules, use [Query](https://docs.medusajs.com/docs/learn/fundamentals/module-links/query/index.html.md).
-
-```ts
-const [posts, count] = await postModuleService.listAndCountPosts({}, {
- relations: ["author"],
-})
-```
-
-### Parameters
-
-To retrieve records with their relations, pass as a second parameter an object having a `relations` property. Its value is an array of relation names.
-
-### Returns
-
-The method returns an array with two items:
-
-1. The first is an array of the first `15` records retrieved.
-2. The second is the total count of records.
-
-***
-
-## Select Properties
-
-```ts
-const [posts, count] = await postModuleService.listAndCountPosts({}, {
- select: ["id", "name"],
-})
-```
-
-### Parameters
-
-By default, retrieved records have all their properties. To select specific properties to retrieve, pass in the second object parameter a `select` property.
-
-`select`'s value is an array of property names to retrieve.
-
-### Returns
-
-The method returns an array with two items:
-
-1. The first is an array of the first `15` records retrieved.
-2. The second is the total count of records.
-
-***
-
-## Paginate Relations
-
-```ts
-const [posts, count] = await postModuleService.listAndCountPosts({}, {
- take: 20,
- skip: 10,
-})
-```
-
-### Parameters
-
-To paginate the returned records, the second object parameter accepts the following properties:
-
-- `take`: a number indicating how many records to retrieve. By default, it's `15`.
-- `skip`: a number indicating how many records to skip before the retrieved records. By default, it's `0`.
-
-### Returns
-
-The method returns an array with two items:
-
-1. The first is an array of the records retrieved. The number of records is less than or equal to `take`'s value.
-2. The second is the total count of records.
-
-***
-
-## Sort Records
-
-```ts
-const [posts, count] = await postModuleService.listAndCountPosts({}, {
- order: {
- name: "ASC",
- },
-})
-```
-
-### Parameters
-
-To sort records by one or more properties, pass to the second object parameter the `order` property. Its value is an object whose keys are the property names, and values can either be:
-
-- `ASC` to sort by this property in the ascending order.
-- `DESC` to sort by this property in the descending order.
-
-### Returns
-
-The method returns an array with two items:
-
-1. The first is an array of the first `15` records retrieved.
-2. The second is the total count of records.
-
-
-# delete Method - Service Factory Reference
-
-This method deletes one or more records.
-
-## Delete One Record
-
-```ts
-await postModuleService.deletePosts("123")
-```
-
-To delete one record, pass its ID as a parameter of the method.
-
-***
-
-## Delete Multiple Records
-
-```ts
-await postModuleService.deletePosts([
- "123",
- "321",
-])
-```
-
-To delete multiple records, pass an array of IDs as a parameter of the method.
-
-***
-
-## Delete Records Matching Filters
-
-```ts
-await postModuleService.deletePosts({
- name: "My Post",
-})
-```
-
-To delete records matching a set of filters, pass an object of filters as a parameter.
-
-Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
-
-
-# retrieve Method - Service Factory Reference
-
-This method retrieves one record of the data model by its ID.
-
-## Retrieve a Record
-
-```ts
-const post = await postModuleService.retrievePost("123")
-```
-
-### Parameters
-
-Pass the ID of the record to retrieve.
-
-### Returns
-
-The method returns the record as an object.
-
-***
-
-## Retrieve a Record's Relations
-
-This applies to relations between data models of the same module. To retrieve linked records of different modules, use [Query](https://docs.medusajs.com/docs/learn/fundamentals/module-links/query/index.html.md).
-
-```ts
-const post = await postModuleService.retrievePost("123", {
- relations: ["author"],
-})
-```
-
-### Parameters
-
-To retrieve the data model with relations, pass as a second parameter of the method an object with the property `relations`. `relations`'s value is an array of relation names.
-
-### Returns
-
-The method returns the record as an object.
-
-***
-
-## Select Properties to Retrieve
-
-```ts
-const post = await postModuleService.retrievePost("123", {
- select: ["id", "name"],
-})
-```
-
-### Parameters
-
-By default, all of the record's properties are retrieved. To select specific ones, pass in the second object parameter a `select` property. Its value is an array of property names.
-
-### Returns
-
-The method returns the record as an object.
-
-
-# softDelete Method - Service Factory Reference
-
-This method soft deletes one or more records of the data model.
-
-## Soft Delete One Record
-
-```ts
-const deletedPosts = await postModuleService.softDeletePosts(
- "123"
-)
-```
-
-### Parameters
-
-To soft delete a record, pass its ID as a parameter of the method.
-
-### Returns
-
-The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of soft-deleted records' IDs.
-
-For example, the returned object of the above example is:
-
-```ts
-deletedPosts = {
- post_id: ["123"],
-}
-```
-
-***
-
-## Soft Delete Multiple Records
-
-```ts
-const deletedPosts = await postModuleService.softDeletePosts([
- "123",
- "321",
-])
-```
-
-### Parameters
-
-To soft delete multiple records, pass an array of IDs as a parameter of the method.
-
-### Returns
-
-The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of soft-deleted records' IDs.
-
-For example, the returned object of the above example is:
-
-```ts
-deletedPosts = {
- post_id: [
- "123",
- "321",
- ],
-}
-```
-
-***
-
-## Soft Delete Records Matching Filters
-
-```ts
-const deletedPosts = await postModuleService.softDeletePosts({
- name: "My Post",
-})
-```
-
-### Parameters
-
-To soft delete records matching a set of filters, pass an object of filters as a parameter.
-
-Learn more about accepted filters in [this documentation](https://docs.medusajs.com/Users/shahednasser/medusa/www/apps/resources/app/service-factory-reference/tips/filtering/index.html.md).
-
-### Returns
-
-The method returns an object, whose keys are of the format `{camel_case_data_model_name}_id`, and their values are arrays of soft-deleted records' IDs.
-
-For example, the returned object of the above example is:
-
-```ts
-deletedPosts = {
- post_id: ["123"],
-}
-```
-
-
# update Method - Service Factory Reference
This method updates one or more records of the data model.
@@ -51522,19 +51521,14 @@ import { CodeBlock, Label } from "@medusajs/ui"
const snippets = [
{
label: "cURL",
- language: "markdown",
- code: `curl -H 'x-publishable-key: YOUR_API_KEY' 'http://localhost:9000/store/products/PRODUCT_ID'`,
+ language: "bash",
+ code: `curl 'http://localhost:9000/store/products/PRODUCT_ID'\n -H 'x-publishable-key: YOUR_API_KEY'`,
hideLineNumbers: true,
},
{
- label: "Medusa JS Client",
+ label: "Medusa JS SDK",
language: "jsx",
- code: `// Install the JS Client in your storefront project: @medusajs/medusa-js\n\nimport Medusa from "@medusajs/medusa-js"\n\nconst medusa = new Medusa({ publishableApiKey: "YOUR_API_KEY"})\nconst product = await medusa.products.retrieve("PRODUCT_ID")\nconsole.log(product.id)`,
- },
- {
- label: "Medusa React",
- language: "tsx",
- code: `// Install the React SDK and required dependencies in your storefront project:\n// medusa-react @tanstack/react-query @medusajs/medusa\n\nimport { useProduct } from "medusa-react"\n\nconst { product } = useProduct("PRODUCT_ID")\nconsole.log(product.id)`,
+ code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
},
]
@@ -51642,9 +51636,9 @@ import { CodeBlock, Label } from "@medusajs/ui"
const snippets = [
{
- label: "Medusa React",
- language: "tsx",
- code: `import { useProduct } from "medusa-react"\n\nconst { product } = useProduct("PRODUCT_ID")\nconsole.log(product.id)`,
+ label: "Medusa JS SDK",
+ language: "jsx",
+ code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
},
]
@@ -51674,9 +51668,9 @@ import { CodeBlock } from "@medusajs/ui"
const snippets = [
{
- label: "Medusa React",
- language: "tsx",
- code: `import { useProduct } from "medusa-react"\n\nconst { product } = useProduct("PRODUCT_ID")\nconsole.log(product.id)`,
+ label: "Medusa JS SDK",
+ language: "jsx",
+ code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
},
]
@@ -51699,10 +51693,9 @@ import { CodeBlock, Label } from "@medusajs/ui"
const snippets = [
{
- label: "Medusa React",
- language: "tsx",
- code: `import { useProduct } from "medusa-react"\n\nconst { product } = useProduct("PRODUCT_ID")\nconsole.log(product.id)`,
- hideLineNumbers: true,
+ label: "Medusa JS SDK",
+ language: "jsx",
+ code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
},
]
diff --git a/www/apps/book/sidebar.mjs b/www/apps/book/sidebar.mjs
index 834e7b90ed..dee991f3ad 100644
--- a/www/apps/book/sidebar.mjs
+++ b/www/apps/book/sidebar.mjs
@@ -527,7 +527,7 @@ export const sidebars = [
{
type: "link",
title: "Type Aliases",
- path: "/learn/conventions/ts-aliases",
+ path: "/learn/configurations/ts-aliases",
},
],
},
@@ -640,7 +640,7 @@ export const sidebars = [
},
{
type: "link",
- path: "/learn/resources//contribution-guidelines/admin-translations",
+ path: "/learn/resources/contribution-guidelines/admin-translations",
title: "Admin Translations",
},
],
diff --git a/www/apps/resources/app/architectural-modules/notification/sendgrid/page.mdx b/www/apps/resources/app/architectural-modules/notification/sendgrid/page.mdx
index 7489d8bc9a..7ce775419c 100644
--- a/www/apps/resources/app/architectural-modules/notification/sendgrid/page.mdx
+++ b/www/apps/resources/app/architectural-modules/notification/sendgrid/page.mdx
@@ -116,15 +116,15 @@ Refer to [this SendGrid documentation guide](https://docs.sendgrid.com/ui/sendin
To test the module out, create a simple subscriber at `src/subscribers/product-created.ts` with the following content:
export const highlights = [
- ["12", "notificationModuleService", "Resolve the Notification Module."],
- ["15", "create", "Create the notification to be sent."],
+ ["11", "notificationModuleService", "Resolve the Notification Module."],
+ ["13", "createNotifications", "Create the notification to be sent."],
[
- "17",
+ "15",
'"email"',
"By specifying the `email` channel, SendGrid will be used to send the notification.",
],
- ["18", '"product-created"', "The ID of the template defined in SendGrid."],
- ["19", "data", "The data to pass to the template defined in SendGrid."],
+ ["16", '"product-created"', "The ID of the template defined in SendGrid."],
+ ["17", "data", "The data to pass to the template defined in SendGrid."],
]
```ts title="src/subscribers/product-created.ts" highlights={highlights} collapsibleLines="1-7" expandButtonLabel="Show Imports"
@@ -133,30 +133,24 @@ import type {
SubscriberConfig,
} from "@medusajs/framework"
import { Modules } from "@medusajs/framework/utils"
-import { INotificationModuleService } from "@medusajs/framework/types"
export default async function productCreateHandler({
event: { data },
container,
}: SubscriberArgs<{ id: string }>) {
- const notificationModuleService: INotificationModuleService =
- container.resolve(Modules.NOTIFICATION)
+ const notificationModuleService = container.resolve(Modules.NOTIFICATION)
+ const productModuleService = container.resolve(Modules.PRODUCT)
+
+ const product = await productModuleService.retrieveProduct(data.id)
await notificationModuleService.createNotifications({
to: "test@gmail.com",
- from: "test@medusajs.com", // Optional var, verified sender required
channel: "email",
template: "product-created",
- data,
- attachments: [ // optional var
- {
- content: base64,
- content_type: "image/png", // mime type
- filename: filename.ext,
- disposition: "attachment or inline attachment",
- id: "id", // only needed for inline attachment
- },
- ],
+ data: {
+ product_title: product.title,
+ product_image: product.images[0]?.url,
+ },
})
}
@@ -165,15 +159,13 @@ export const config: SubscriberConfig = {
}
```
-In this subscriber:
+In this subscriber, you:
-- Resolve the Notification Module's main service.
-- Use the `create` method of the main service to create a notification to be sent to the specified email.
-- By specifying the `email` channel, the SendGrid Notification Module Provider is used to send the notification.
-- The `template` property of the `create` method's parameter specifies the ID of the template defined in SendGrid.
-- The `data` property allows you to pass data to the template in SendGrid.
-- The `attachments` optional property allows you to pass attachments to the template in SendGrid.
-- The `from` optional property allows you to pass a single sender-verified email. If not provided, the value of the `from` configuration of the module is used.
+- Resolve the Notification and Product Modules' main services from the [Medusa container](!docs!/learn/fundamentals/medusa-container).
+- Retrieve the product's details to pass them to the template in SendGrid.
+- Use the `createNotifications` method of the Notification Module's main service to create a notification to be sent to the specified email. By specifying the `email` channel, the SendGrid Notification Module Provider is used to send the notification.
+- The `template` property of the `createNotifications` method's parameter specifies the ID of the template defined in SendGrid.
+- The `data` property allows you to pass data to the template in SendGrid. For example, the product's title and image.
Then, start the Medusa application:
diff --git a/www/apps/resources/generated/edit-dates.mjs b/www/apps/resources/generated/edit-dates.mjs
index a185acf438..d32b86140f 100644
--- a/www/apps/resources/generated/edit-dates.mjs
+++ b/www/apps/resources/generated/edit-dates.mjs
@@ -196,7 +196,7 @@ export const generatedEditDates = {
"app/commerce-modules/auth/create-actor-type/page.mdx": "2024-12-25T13:26:27.176Z",
"app/architectural-modules/page.mdx": "2025-03-12T10:28:44.544Z",
"app/architectural-modules/workflow-engine/redis/page.mdx": "2024-10-15T12:50:59.507Z",
- "app/architectural-modules/notification/sendgrid/page.mdx": "2025-02-26T11:43:13.143Z",
+ "app/architectural-modules/notification/sendgrid/page.mdx": "2025-03-24T07:01:32.437Z",
"app/commerce-modules/api-key/concepts/page.mdx": "2024-10-07T13:59:37.529Z",
"app/architectural-modules/workflow-engine/page.mdx": "2025-03-12T11:55:18.789Z",
"app/_events-reference/page.mdx": "2024-07-03T19:27:13+03:00",
diff --git a/www/apps/ui/src/examples/code-block-demo.tsx b/www/apps/ui/src/examples/code-block-demo.tsx
index 59369b70ed..04e964d719 100644
--- a/www/apps/ui/src/examples/code-block-demo.tsx
+++ b/www/apps/ui/src/examples/code-block-demo.tsx
@@ -3,19 +3,14 @@ import { CodeBlock, Label } from "@medusajs/ui"
const snippets = [
{
label: "cURL",
- language: "markdown",
- code: `curl -H 'x-publishable-key: YOUR_API_KEY' 'http://localhost:9000/store/products/PRODUCT_ID'`,
+ language: "bash",
+ code: `curl 'http://localhost:9000/store/products/PRODUCT_ID'\n -H 'x-publishable-key: YOUR_API_KEY'`,
hideLineNumbers: true,
},
{
- label: "Medusa JS Client",
+ label: "Medusa JS SDK",
language: "jsx",
- code: `// Install the JS Client in your storefront project: @medusajs/medusa-js\n\nimport Medusa from "@medusajs/medusa-js"\n\nconst medusa = new Medusa({ publishableApiKey: "YOUR_API_KEY"})\nconst product = await medusa.products.retrieve("PRODUCT_ID")\nconsole.log(product.id)`,
- },
- {
- label: "Medusa React",
- language: "tsx",
- code: `// Install the React SDK and required dependencies in your storefront project:\n// medusa-react @tanstack/react-query @medusajs/medusa\n\nimport { useProduct } from "medusa-react"\n\nconst { product } = useProduct("PRODUCT_ID")\nconsole.log(product.id)`,
+ code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
},
]
diff --git a/www/apps/ui/src/examples/code-block-no-header.tsx b/www/apps/ui/src/examples/code-block-no-header.tsx
index f49b0ef1a1..85e0ad4244 100644
--- a/www/apps/ui/src/examples/code-block-no-header.tsx
+++ b/www/apps/ui/src/examples/code-block-no-header.tsx
@@ -2,9 +2,9 @@ import { CodeBlock } from "@medusajs/ui"
const snippets = [
{
- label: "Medusa React",
- language: "tsx",
- code: `import { useProduct } from "medusa-react"\n\nconst { product } = useProduct("PRODUCT_ID")\nconsole.log(product.id)`,
+ label: "Medusa JS SDK",
+ language: "jsx",
+ code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
},
]
diff --git a/www/apps/ui/src/examples/code-block-no-lines.tsx b/www/apps/ui/src/examples/code-block-no-lines.tsx
index 02d9e144e6..3348f2af8f 100644
--- a/www/apps/ui/src/examples/code-block-no-lines.tsx
+++ b/www/apps/ui/src/examples/code-block-no-lines.tsx
@@ -2,10 +2,9 @@ import { CodeBlock, Label } from "@medusajs/ui"
const snippets = [
{
- label: "Medusa React",
- language: "tsx",
- code: `import { useProduct } from "medusa-react"\n\nconst { product } = useProduct("PRODUCT_ID")\nconsole.log(product.id)`,
- hideLineNumbers: true,
+ label: "Medusa JS SDK",
+ language: "jsx",
+ code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
},
]
diff --git a/www/apps/ui/src/examples/code-block-single.tsx b/www/apps/ui/src/examples/code-block-single.tsx
index e69912d5c7..a8c9456b16 100644
--- a/www/apps/ui/src/examples/code-block-single.tsx
+++ b/www/apps/ui/src/examples/code-block-single.tsx
@@ -2,9 +2,9 @@ import { CodeBlock, Label } from "@medusajs/ui"
const snippets = [
{
- label: "Medusa React",
- language: "tsx",
- code: `import { useProduct } from "medusa-react"\n\nconst { product } = useProduct("PRODUCT_ID")\nconsole.log(product.id)`,
+ label: "Medusa JS SDK",
+ language: "jsx",
+ code: `// Install the JS SDK in your storefront project: @medusajs/js-sdk\n\nimport Medusa from "@medusajs/js-sdk"\n\nconst medusa = new Medusa({\n baseUrl: import.meta.env.NEXT_PUBLIC_BACKEND_URL || "/",\n publishableKey: process.env.NEXT_PUBLIC_MEDUSA_PAK\n})\nconst { product } = await medusa.store.products.retrieve("prod_123")\nconsole.log(product.id)`,
},
]