chore: improve JS Client TSDoc comments (#5582)
* add oas schema to tsdoc parser * add tsdoc (part 1) * Finished tsdoc in js client * general fixes * added tsdoc in core medusa package * parse schema tags in model files * added maxlevel option * added more tsdoc * added tsdoc in core * added TSDoc in core package * generated client types * support featureFlag and expandable tags * added support for resource feature flag note * fix api ignore plugin * added eslint plugin * support feature flag and expandable badges * adjusted overview page + generated reference * revert generated files * added changeset * add details about new typedoc options * fix broken link
This commit is contained in:
1 parent
c68da6d685
commit
91615f9c45
748 files changed
+12354
-1684
No files matched your search
@@ -1096,17 +1096,12 @@ export default Products`,
|
||||
|
||||
|
||||
In the response of listing API Routes, aside from the entities retrieved,
|
||||
there are three pagination-related fields returned: `count`, `limit`, and
|
||||
`offset`.
|
||||
there are three pagination-related fields returned:
|
||||
|
||||
|
||||
Similar to the query parameters, `limit` is the maximum number of items that
|
||||
can be returned in the response, and `field` is the number of items that
|
||||
were skipped before the entities in the result.
|
||||
|
||||
|
||||
`count` is the total number of available items of this entity. It can be
|
||||
used to determine how many pages are there.
|
||||
- `limit`: the maximum number of items that can be returned in the response.
|
||||
- `offset`: the number of items that were skipped before the entities in the result.
|
||||
- `count`: the total number of available items of this entity. It can be used to determine how many pages are there.
|
||||
|
||||
|
||||
For example, if the `count` is 100 and the `limit` is 50, you can divide the
|
||||
|
||||
@@ -155,7 +155,7 @@ You can learn more about publishable API keys and how to use them in [this docum
|
||||
### How to Create a Publishable API Key
|
||||
|
||||
You can create a publishable API key either using the [admin REST APIs](https://docs.medusajs.com/development/publishable-api-keys/admin/manage-publishable-api-keys),
|
||||
or using the [Medusa admin](https://docs.medusajs.com/user-guide/settings/publishable-api-keys).
|
||||
or using the [Medusa admin dashboard](https://docs.medusajs.com/user-guide/settings/publishable-api-keys).
|
||||
|
||||
### How to Use a Publishable API Key
|
||||
|
||||
@@ -1038,17 +1038,12 @@ export default Products`,
|
||||
|
||||
|
||||
In the response of listing API Routes, aside from the entities retrieved,
|
||||
there are three pagination-related fields returned: `count`, `limit`, and
|
||||
`offset`.
|
||||
there are three pagination-related fields returned:
|
||||
|
||||
|
||||
Similar to the query parameters, `limit` is the maximum number of items that
|
||||
can be returned in the response, and `field` is the number of items that
|
||||
were skipped before the entities in the result.
|
||||
|
||||
|
||||
`count` is the total number of available items of this entity. It can be
|
||||
used to determine how many pages are there.
|
||||
- `limit`: the maximum number of items that can be returned in the response.
|
||||
- `offset`: the number of items that were skipped before the entities in the result.
|
||||
- `count`: the total number of available items of this entity. It can be used to determine how many pages are there.
|
||||
|
||||
|
||||
For example, if the `count` is 100 and the `limit` is 50, you can divide the
|
||||
|
||||
@@ -7,9 +7,8 @@ import type { TagsOperationDescriptionSectionResponsesProps } from "./Responses"
|
||||
import dynamic from "next/dynamic"
|
||||
import TagsOperationDescriptionSectionParameters from "./Parameters"
|
||||
import MDXContentClient from "@/components/MDXContent/Client"
|
||||
import type { TagsOperationFeatureFlagNoticeProps } from "../FeatureFlagNotice"
|
||||
import { useArea } from "../../../../providers/area"
|
||||
import { Feedback, Badge, NextLink } from "docs-ui"
|
||||
import { Feedback, Badge, NextLink, FeatureFlagNotice } from "docs-ui"
|
||||
import { usePathname } from "next/navigation"
|
||||
import formatReportLink from "../../../../utils/format-report-link"
|
||||
|
||||
@@ -27,12 +26,6 @@ const TagsOperationDescriptionSectionResponses =
|
||||
dynamic<TagsOperationDescriptionSectionResponsesProps>(
|
||||
async () => import("./Responses")
|
||||
) as React.FC<TagsOperationDescriptionSectionResponsesProps>
|
||||
|
||||
const TagsOperationFeatureFlagNotice =
|
||||
dynamic<TagsOperationFeatureFlagNoticeProps>(
|
||||
async () => import("../FeatureFlagNotice")
|
||||
) as React.FC<TagsOperationFeatureFlagNoticeProps>
|
||||
|
||||
type TagsOperationDescriptionSectionProps = {
|
||||
operation: Operation
|
||||
}
|
||||
@@ -52,7 +45,7 @@ const TagsOperationDescriptionSection = ({
|
||||
</Badge>
|
||||
)}
|
||||
{operation["x-featureFlag"] && (
|
||||
<TagsOperationFeatureFlagNotice
|
||||
<FeatureFlagNotice
|
||||
featureFlag={operation["x-featureFlag"]}
|
||||
tooltipTextClassName="font-normal text-medusa-fg-subtle"
|
||||
badgeClassName="ml-0.5"
|
||||
|
||||
@@ -1,18 +1,12 @@
|
||||
import type { SchemaObject } from "@/types/openapi"
|
||||
import dynamic from "next/dynamic"
|
||||
import type { TooltipProps } from "docs-ui"
|
||||
import type { TagsOperationFeatureFlagNoticeProps } from "../../FeatureFlagNotice"
|
||||
import { Badge, NextLink } from "docs-ui"
|
||||
import { Badge, ExpandableNotice, FeatureFlagNotice, NextLink } from "docs-ui"
|
||||
|
||||
const Tooltip = dynamic<TooltipProps>(
|
||||
async () => (await import("docs-ui")).Tooltip
|
||||
) as React.FC<TooltipProps>
|
||||
|
||||
const TagsOperationFeatureFlagNotice =
|
||||
dynamic<TagsOperationFeatureFlagNoticeProps>(
|
||||
async () => import("../../FeatureFlagNotice")
|
||||
) as React.FC<TagsOperationFeatureFlagNoticeProps>
|
||||
|
||||
export type TagOperationParametersNameProps = {
|
||||
name: string
|
||||
isRequired?: boolean
|
||||
@@ -35,25 +29,13 @@ const TagOperationParametersName = ({
|
||||
{schema["x-expandable"] && (
|
||||
<>
|
||||
<br />
|
||||
<Tooltip
|
||||
tooltipChildren={
|
||||
<>
|
||||
If this request accepts an <code>expand</code> parameter,
|
||||
<br /> this field can be{" "}
|
||||
<NextLink href="#expanding-fields">expanded</NextLink> into an
|
||||
object.
|
||||
</>
|
||||
}
|
||||
clickable
|
||||
>
|
||||
<Badge variant="blue">expandable</Badge>
|
||||
</Tooltip>
|
||||
<ExpandableNotice type="request" link="#expanding-fields" />
|
||||
</>
|
||||
)}
|
||||
{schema["x-featureFlag"] && (
|
||||
<>
|
||||
<br />
|
||||
<TagsOperationFeatureFlagNotice
|
||||
<FeatureFlagNotice
|
||||
featureFlag={schema["x-featureFlag"]}
|
||||
type="parameter"
|
||||
/>
|
||||
|
||||
@@ -284,7 +284,7 @@ npx medusa develop
|
||||
|
||||
You must also use an authenticated user to send batch job requests. You can refer to the [authentication guide in the API reference](https://docs.medusajs.com/api/admin#authentication) for more details.
|
||||
|
||||
If you follow along with the JS Client code snippets, make sure to [install and set it up first](../../js-client/overview.md).
|
||||
If you follow along with the JS Client code snippets, make sure to [install and set it up first](../../js-client/overview.mdx).
|
||||
|
||||
### Create Batch Job
|
||||
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ If you don't pass a publishable API Key for the store API Routes `/store/product
|
||||
|
||||
## Using Medusa JS Client
|
||||
|
||||
When using [Medusa’s JS Client](../../../js-client/overview.md), you can pass it to the client only once when you create the instance of the client:
|
||||
When using [Medusa’s JS Client](../../../js-client/overview.mdx), you can pass it to the client only once when you create the instance of the client:
|
||||
|
||||
```ts
|
||||
const medusa = new Medusa({
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
---
|
||||
description: 'Learn how to install the Medusa JS Client in a storefront. Medusa JS Client provides easy access to the Medusa API from a client written in TypeScript.'
|
||||
---
|
||||
|
||||
# Medusa JS Client
|
||||
|
||||
The [Medusa JS Client](https://www.npmjs.com/package/@medusajs/medusa-js) provides easy access to the Medusa API from a client written in TypeScript. This reference guides you to learn what methods the client has and how you can use them.
|
||||
|
||||
This client can be use as an alternative to directly interacting with the [REST APIs](https://docs.medusajs.com/api/store).
|
||||
|
||||
## Installation
|
||||
|
||||
To install the Medusa JS Client run the following command:
|
||||
|
||||
```bash npm2yarn
|
||||
npm install @medusajs/medusa-js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
Import Medusa as a default import and initiate it:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
|
||||
const medusa = new Medusa()
|
||||
```
|
||||
|
||||
### Troubleshooting: Could not find a declaration file for module '@medusajs/medusa-js'
|
||||
|
||||
If you import `@medusajs/medusa-js` in your code and see the following TypeScript error:
|
||||
|
||||
```bash
|
||||
Could not find a declaration file for module '@medusajs/medusa-js'
|
||||
```
|
||||
|
||||
Make sure to set `moduleResolution` in your `tsconfig.json` to `nodenext` or `node`:
|
||||
|
||||
```json title=tsconfig.json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "nodenext",
|
||||
// ...
|
||||
},
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## How to Use this Reference
|
||||
|
||||
You'll find in the sidebar of this reference names of different resources. These resources are properties in the Medusa instance you initialize and you can access them directly using the instance. Then, you'll be able to access the methods or nested resources within those resources.
|
||||
|
||||
For example, to create a new customer you can access the [create](../references/js-client/customers/classes/customers.CustomerResource.mdx#create) method under the [customers](../references/js-client/customers/classes/customers.CustomerResource.mdx) property of your client:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
|
||||
const medusa = new Medusa()
|
||||
|
||||
// use method
|
||||
medusa.customers.create({
|
||||
// data
|
||||
})
|
||||
```
|
||||
|
||||
The `customers` resource also has another resource `addresses` nested inside it with its own method that you can access similarly:
|
||||
|
||||
```ts
|
||||
medusa.customers.addresses.addAddress({
|
||||
// data
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Authentication
|
||||
|
||||
Authentication can be achieved in two ways using the `medusa-js` client: either by utilizing API keys or by using cookie based authentication. Each method has its own unique use case.
|
||||
|
||||
### Using API keys
|
||||
|
||||
API keys can only be used for admin functionality in Medusa since only users of the admin system have API keys. Refer to the [Configuration](#configuration) section to learn how to add the API key to requests.
|
||||
|
||||
You can follow [this guide](https://docs.medusajs.com/api/admin#authentication) to learn how to create an API key for an admin user.
|
||||
|
||||
### Using cookies
|
||||
|
||||
Authentication using cookies is done automatically by Axios, which is used within the Medusa JS Client, when authenticating using the [auth](../references/js-client/auth/classes/auth.AuthResource.mdx) API Routes. After authentication, all subsequent calls will be authenticated.
|
||||
|
||||
---
|
||||
|
||||
## Configuration
|
||||
|
||||
### Initialize with config object
|
||||
|
||||
The package can be initialized with several options:
|
||||
|
||||
```ts
|
||||
const medusa = new Medusa({
|
||||
maxRetries: 3,
|
||||
baseUrl: "https://api.example.com",
|
||||
})
|
||||
```
|
||||
|
||||
| Option | Default | Description |
|
||||
| ------------------- | ------------------------- | --------------------------------------------------------- |
|
||||
| `maxRetries` | `0` | The amount of times a request is retried. |
|
||||
| `baseUrl` | `'http://localhost:9000'` | The url to which requests are made to. |
|
||||
| `apiKey` | `''` | Optional API key used for authenticating admin requests. |
|
||||
| `publishableApiKey` | `''` | Optional publishable API key used for storefront requests. You can create a publishable API key either using the [admin APIs](../development/publishable-api-keys/admin/manage-publishable-api-keys.mdx) or the [Medusa admin](../user-guide/settings/publishable-api-keys.mdx). |
|
||||
@@ -0,0 +1,576 @@
|
||||
---
|
||||
description: 'Learn how to install the Medusa JS Client in a storefront. Medusa JS Client provides easy access to the Medusa API from a client written in TypeScript.'
|
||||
---
|
||||
|
||||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
# Medusa JS Client
|
||||
|
||||
The [Medusa JS Client](https://www.npmjs.com/package/@medusajs/medusa-js) provides easy access to the Medusa backend's REST APIs within TypeScript or JavaScript frontend projects.
|
||||
|
||||
For example, if you're creating a storefront with frameworks like Nuxt, you can send requests to the backend using this client.
|
||||
|
||||
This reference provides details on the available methods including examples of each.
|
||||
|
||||
## Installation
|
||||
|
||||
To install the Medusa JS Client run the following command:
|
||||
|
||||
```bash npm2yarn
|
||||
npm install @medusajs/medusa-js
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Usage
|
||||
|
||||
To use the Medusa client, import `Medusa` and initialize the client:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
})
|
||||
```
|
||||
|
||||
Where `MEDUSA_BACKEND_URL` is the URL to your Medusa backend. If the `baseUrl` option is not provided, the default backend URL used is `http://localhost:9000`.
|
||||
|
||||
After initialization, you can use the client's properties and methods to send requests to the Medusa backend.
|
||||
|
||||
<details>
|
||||
<summary>
|
||||
Troubleshooting: Could not find a declaration file for module '@medusajs/medusa-js'
|
||||
</summary>
|
||||
|
||||
If you import `@medusajs/medusa-js` in your code and see the following TypeScript error:
|
||||
|
||||
```bash
|
||||
Could not find a declaration file for module '@medusajs/medusa-js'
|
||||
```
|
||||
|
||||
Make sure to set `moduleResolution` in your `tsconfig.json` to `nodenext` or `node`:
|
||||
|
||||
```json title=tsconfig.json
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "nodenext",
|
||||
// ...
|
||||
},
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
## How to Use this Reference
|
||||
|
||||
You'll find in the sidebar of this reference names of different resources. These resources are properties in the Medusa client instance you initialize. You can access the methods or nested resources of each of the properties to send requests to the backend.
|
||||
|
||||
For example, to create a new customer you can access the [create](../references/js-client/customers/classes/customers.CustomerResource.mdx#create) method under the [customers](../references/js-client/customers/classes/customers.CustomerResource.mdx) property of your client:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
|
||||
const medusa = new Medusa()
|
||||
|
||||
// use method
|
||||
medusa.customers.create({
|
||||
// data
|
||||
})
|
||||
```
|
||||
|
||||
The `customers` resource also has another resource `addresses` nested inside it with its own method that you can access similarly:
|
||||
|
||||
```ts
|
||||
medusa.customers.addresses.addAddress({
|
||||
// data
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Client Options
|
||||
|
||||
The client accepts the following options on initialization:
|
||||
|
||||
| Option | Default | Description |
|
||||
| ------------------- | ------------------------- | --------------------------------------------------------- |
|
||||
| `maxRetries` | `0` | The amount of times a request is retried. |
|
||||
| `baseUrl` | `'http://localhost:9000'` | The url to which requests are made to. |
|
||||
| `apiKey` | `''` | Optional API key used for authenticating admin requests. |
|
||||
| `publishableApiKey` | `''` | Optional publishable API key used for storefront requests. You can create a publishable API key either using the [admin APIs](../development/publishable-api-keys/admin/manage-publishable-api-keys.mdx) or the [Medusa admin](../user-guide/settings/publishable-api-keys.mdx). |
|
||||
| `customHeaders` | `{}` | Optional headers to attach to every request. |
|
||||
|
||||
|
||||
For example:
|
||||
|
||||
```ts
|
||||
const medusa = new Medusa({
|
||||
maxRetries: 3,
|
||||
baseUrl: "https://api.example.com",
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Authentication
|
||||
|
||||
### JWT Token
|
||||
|
||||
You can use a JWT token to authenticate both admin users and customers. Authentication state is managed by the client, which is ideal for Jamstack applications and mobile applications.
|
||||
|
||||
You can authenticate the admin user using the [admin.auth.getToken](../references/js-client/admin_auth/classes/admin_auth.AdminAuthResource.mdx#getToken) method, and the customer using the [auth.getToken](../references/js-client/auth/classes/auth.AuthResource.mdx#getToken) method.
|
||||
|
||||
Once the user or customer is authenticated successfully, the Medusa client automatically attaches an Authorization Bearer header to all subsequent requests.
|
||||
|
||||
For example:
|
||||
|
||||
<Tabs groupId="client-authentication-type" isCodeTabs={true}>
|
||||
<TabItem value="user" label="Admin User" default>
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
await medusa.admin.auth.getToken({
|
||||
email: "user@example.com",
|
||||
password: "supersecret",
|
||||
})
|
||||
// send authenticated requests now
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="customer" label="Customer">
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
await medusa.auth.getToken({
|
||||
email: "user@example.com",
|
||||
password: "supersecret",
|
||||
})
|
||||
// send authenticated requests now
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### Cookie Session ID
|
||||
|
||||
You can authenticate admin users or customers using cookie session ID.
|
||||
|
||||
You can authenticate the admin user using the [admin.auth.createSession](../references/js-client/admin_auth/classes/admin_auth.AdminAuthResource.mdx#createSession) method, and the customer using the [auth.authenticate](../references/js-client/auth/classes/auth.AuthResource.mdx#authenticate) method.
|
||||
|
||||
Once the user or customer is authenticated successfully, the Medusa client sets and attached the session ID in the cookie for all subsequent requests.
|
||||
|
||||
For example:
|
||||
|
||||
<Tabs groupId="client-authentication-type" isCodeTabs={true}>
|
||||
<TabItem value="user" label="Admin User" default>
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
await medusa.admin.AdminAuthResource.createSession({
|
||||
email: "user@example.com",
|
||||
password: "supersecret",
|
||||
})
|
||||
// send authenticated requests now
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="customer" label="Customer">
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
await medusa.auth.authenticate({
|
||||
email: "user@example.com",
|
||||
password: "user@example.com",
|
||||
})
|
||||
// send authenticated requests now
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
### API Key
|
||||
|
||||
You can authenticate admin users with a personal API Token.
|
||||
|
||||
If a user doesn't have a personal API token, create one with the [admin.users.update](../references/js-client/admin_users/classes/admin_users.AdminUsersResource.mdx#update) method:
|
||||
|
||||
<Tabs groupId="client-type" isCodeTabs={true}>
|
||||
<TabItem value="js-client" label="JS Client" default>
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.users.update(userId, {
|
||||
api_token,
|
||||
})
|
||||
.then(({ user }) => {
|
||||
console.log(user.api_token)
|
||||
})
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
<TabItem value="curl" label="cURL">
|
||||
|
||||
```bash
|
||||
curl -L -X POST '<BACKEND_URL>/admin/users/<USER_ID>' \\
|
||||
-H 'Cookie: connect.sid={sid}' \\
|
||||
-H 'Content-Type: application/json' \\
|
||||
--data-raw '{
|
||||
"api_token": "{api_token}"
|
||||
}'
|
||||
```
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
Then, initialize the Medusa client passing it the `apiKey` option:
|
||||
|
||||
```ts
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
apiKey: "{api_token}",
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Publishable API Key
|
||||
|
||||
Publishable API Keys allow you to send a request to Store API routes with a pre-defined scope. You can associate the publishable API key with one or more resources, such as sales channels, then include the publishable API key in the header of your requests.
|
||||
|
||||
The Medusa backend will infer the scope of the current request based on the publishable API key. At the moment, publishable API keys only work with sales channels.
|
||||
|
||||
It's highly recommended to create a publishable API key and pass it as an initialization option of the Medusa client.
|
||||
|
||||
You can learn more about publishable API keys and how to use them in [this documentation](../development/publishable-api-keys/index.mdx).
|
||||
|
||||
### Create a Publishable API Key
|
||||
|
||||
You can create a publishable API key either using the [admin REST APIs](../development/publishable-api-keys/admin/manage-publishable-api-keys.mdx), or using the [Medusa admin dashboard](../user-guide/settings/publishable-api-keys.mdx).
|
||||
|
||||
### Use a Publishable API Key
|
||||
|
||||
To use the publishable API key, pass it as an option to the Medusa client:
|
||||
|
||||
```ts
|
||||
const medusa = new Medusa({
|
||||
maxRetries: 3,
|
||||
baseUrl: "https://api.example.com",
|
||||
publishableApiKey,
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## HTTP Compression
|
||||
|
||||
If you've enabled HTTP Compression in your Medusa configurations, and you want to disable it for some requests, you can pass the `x-no-compression` header in the `customHeaders` parameter which is available in all methods.
|
||||
|
||||
For example:
|
||||
|
||||
```ts
|
||||
medusa.products.list({}, {
|
||||
"x-no-compression": true,
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Expanding Fields
|
||||
|
||||
In many methods you'll find an `expand` property that can be accepted within one of the method's parameters. You can use the `expand` property to unpack an entity's relations and return them in the response.
|
||||
|
||||
:::warning
|
||||
|
||||
The relations you pass to `expand` replace any relations that are expanded by default in the request.
|
||||
|
||||
:::
|
||||
|
||||
### Expanding One Relation
|
||||
|
||||
For example, when you retrieve products, you can retrieve their collection by passing to the `expand` query parameter the value `collection`:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
expand: "collection",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
### Expanding Multiple Relations
|
||||
|
||||
You can expand more than one relation by separating the relations in the `expand` query parameter with a comma.
|
||||
|
||||
For example, to retrieve both the variants and the collection of products, pass to the `expand` query parameter the value `variants,collection`:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
expand: "variants,collection",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
### Prevent Expanding Relations
|
||||
|
||||
Some requests expand relations by default. You can prevent that by passing
|
||||
an empty expand value to retrieve an entity without any extra relations.
|
||||
|
||||
For example:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
expand: "",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
This would retrieve each product with only its properties, without any
|
||||
relations like `collection`.
|
||||
|
||||
---
|
||||
|
||||
## Selecting Fields
|
||||
|
||||
In many methods you'll find a `fields` property that can be accepted within one of the method's parameters. You can use the `fields` property to specify which
|
||||
fields in the entity should be returned in the response.
|
||||
|
||||
:::warning
|
||||
|
||||
If you pass a `fields` query parameter, only the fields you
|
||||
pass in the value along with the `id` of the entity will be returned in the
|
||||
response.
|
||||
|
||||
:::
|
||||
|
||||
|
||||
The `fields` query parameter does not affect the expanded relations. You'll have to use the [Expand parameter](#expanding-fields) instead.
|
||||
|
||||
|
||||
### Selecting One Field
|
||||
|
||||
For example, when you retrieve a list of products, you can retrieve only the titles of the products by passing `title` as a value to the `fields` query parameter:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
fields: "title",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
As mentioned above, the expanded relations such as `variants` will still be returned as they're not affected by the `fields` parameter.
|
||||
|
||||
You can ensure that only the `title` field is returned by passing an empty value to the `expand` query parameter. For example:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
fields: "title",
|
||||
expand: "",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
### Selecting Multiple Fields
|
||||
|
||||
You can pass more than one field by seperating the field names in the `fields` query parameter with a comma.
|
||||
|
||||
For example, to select the `title` and `handle` of products:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
fields: "title,handle",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
### Retrieve Only the ID
|
||||
|
||||
You can pass an empty `fields` query parameter to return only the ID of an entity.
|
||||
|
||||
For example:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
fields: "",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
You can also pair with an empty `expand` query parameter to ensure that the
|
||||
relations aren't retrieved as well. For example:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
fields: "",
|
||||
expand: "",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pagination
|
||||
|
||||
### Query Parameters
|
||||
|
||||
In listing methods, such as list customers or list products, you can control the pagination using the query parameters `limit` and `offset`.
|
||||
|
||||
`limit` is used to specify the maximum number of items that can be return in the response. `offset` is used to specify how many items to skip before returning the resulting entities.
|
||||
|
||||
You can use the `offset` query parameter to change between pages. For example, if the limit is `50`, at page one the offset should be `0`; at page two the offset should be `50`, and so on.
|
||||
|
||||
For example, to limit the number of products returned in the list products method:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
limit: 5,
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
### Response Fields
|
||||
|
||||
In the response of listing methods, aside from the entities retrieved,
|
||||
there are three pagination-related fields returned:
|
||||
|
||||
- `limit`: the maximum number of items that can be returned in the response.
|
||||
- `offset`: the number of items that were skipped before the entities in the result.
|
||||
- `count`: the total number of available items of this entity. It can be used to determine how many pages are there.
|
||||
|
||||
For example, if the `count` is 100 and the `limit` is 50, you can divide the `count` by the `limit` to get the number of pages: `100/50 = 2 pages`.
|
||||
|
||||
### Sort Order
|
||||
|
||||
The `order` field available on methods supporting pagination allows you to sort the retrieved items by an attribute of that item. For example, you can sort products by their `created_at` attribute by setting `order` to `created_at`:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
order: "created_at",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
By default, the sort direction will be ascending. To change it to descending, pass a dash (`-`) before the attribute name. For example:
|
||||
|
||||
```ts
|
||||
import Medusa from "@medusajs/medusa-js"
|
||||
const medusa = new Medusa({
|
||||
baseUrl: MEDUSA_BACKEND_URL,
|
||||
maxRetries: 3,
|
||||
})
|
||||
// must be previously logged in or use api token
|
||||
medusa.admin.products.list({
|
||||
order: "-created_at",
|
||||
})
|
||||
.then(({ products, limit, offset, count }) => {
|
||||
console.log(products.length)
|
||||
})
|
||||
```
|
||||
|
||||
This sorts the products by their `created_at` attribute in the descending order.
|
||||
@@ -11,7 +11,7 @@ import TabItem from '@theme/TabItem';
|
||||
|
||||
:::tip
|
||||
|
||||
Alternatively, you can use Medusa’s [JS Client](../js-client/overview.md) or the [REST APIs](https://docs.medusajs.com/api/store).
|
||||
Alternatively, you can use Medusa’s [JS Client](../js-client/overview.mdx) or the [REST APIs](https://docs.medusajs.com/api/store).
|
||||
|
||||
:::
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ It is also assumed you already have a storefront set up. It can be a custom stor
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ It is also assumed you already have a storefront set up. It can be a custom stor
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client and JavaScript’s Fetch API.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, JavaScript’s Fetch API, or cURL.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ It's also assumed you already have a storefront set up. It can be a custom store
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, JavaScript’s Fetch API, or cURL.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ It is also assumed you already have a storefront set up. It can be a custom stor
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ It is also assumed you already have a storefront set up. It can be a custom stor
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ Furthermore, inventory levels are tied to a location ID. So, it’s recommended
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ This guide assumes you have a stock location and inventory modules installed. Yo
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ This guide assumes you have a stock location and inventory modules installed. Yo
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ This guide assumes you have a stock location module installed. You can use Medus
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ It's also assumed you already have a storefront set up. It can be a custom store
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client and JavaScript’s Fetch API.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ It's also assumed you already have a storefront set up. It can be a custom store
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client and JavaScript’s Fetch API.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ It is also assumed you already have a storefront set up. It can be a custom stor
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client and JavaScript’s Fetch API.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ It is also assumed you already have a storefront set up. It can be a custom stor
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ It's also assumed you already have a storefront set up. It can be a custom store
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client and JavaScript’s Fetch API.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ No
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, JavaScript’s Fetch API, or cURL.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and [have created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and [have created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -848,7 +848,7 @@ No
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ It's also assumed you already have a storefront set up. It can be a custom store
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ It's also assumed you already have a storefront set up. It can be a custom store
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ It is also assumed you already have a storefront set up. It can be a custom stor
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ It's assumed that you already have a Medusa backend installed and set up. If not
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and [have created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and [have created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ It is also assumed you already have a storefront set up. It can be a custom stor
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.md) and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client installed](../../../js-client/overview.mdx) and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, JavaScript’s Fetch API, or cURL.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ It is assumed that you already have a Medusa backend installed and set up. If no
|
||||
|
||||
This guide includes code snippets to send requests to your Medusa backend using Medusa’s JS Client, among other methods.
|
||||
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.md) installed and have [created an instance of the client](../../../js-client/overview.md#configuration).
|
||||
If you follow the JS Client code blocks, it’s assumed you already have [Medusa’s JS Client](../../../js-client/overview.mdx) installed and have [created an instance of the client](../../../js-client/overview.mdx#configuration).
|
||||
|
||||
### Medusa React
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ You can instead follow this recipe that will guide you through implementing feat
|
||||
The storefront connects to the backend to retrieve and process data. You can use different tools or libraries when connecting your storefront to the backend.
|
||||
|
||||
- **For React-based storefronts:** you can use [Medusa React](../medusa-react/overview.mdx). It provides you with the necessary hooks to retrieve or manipulate data on your backend.
|
||||
- **For JavaScript frameworks:** you can use [Medusa’s JavaScript Client](../js-client/overview.md) in any JavaScript framework. This NPM package facilitates interacting with the backend’s REST APIs.
|
||||
- **For JavaScript frameworks:** you can use [Medusa’s JavaScript Client](../js-client/overview.mdx) in any JavaScript framework. This NPM package facilitates interacting with the backend’s REST APIs.
|
||||
- **For other frontend technologies:** you can interact directly with the Medusa backend by sending requests to its [Store REST APIs](https://docs.medusajs.com/api/store).
|
||||
|
||||
:::tip
|
||||
|
||||
@@ -1,8 +1,21 @@
|
||||
import { DetailsSummary, InlineCode, MarkdownContent } from "docs-ui"
|
||||
import {
|
||||
Badge,
|
||||
DetailsSummary,
|
||||
ExpandableNotice,
|
||||
FeatureFlagNotice,
|
||||
InlineCode,
|
||||
MarkdownContent,
|
||||
} from "docs-ui"
|
||||
import React from "react"
|
||||
import Details from "../../../theme/Details"
|
||||
import clsx from "clsx"
|
||||
import { Parameter } from ".."
|
||||
import {
|
||||
ArrowDownLeftMini,
|
||||
ArrowsPointingOutMini,
|
||||
TriangleRightMini,
|
||||
} from "@medusajs/icons"
|
||||
import IconFlagMini from "../../../theme/Icon/FlagMini"
|
||||
|
||||
type ParameterTypesItemsProps = {
|
||||
parameters: Parameter[]
|
||||
@@ -13,17 +26,48 @@ const ParameterTypesItems = ({
|
||||
parameters,
|
||||
level = 1,
|
||||
}: ParameterTypesItemsProps) => {
|
||||
function getGroupName() {
|
||||
switch (level) {
|
||||
case 1:
|
||||
return "group/parameterOne"
|
||||
case 2:
|
||||
return "group/parameterTwo"
|
||||
case 3:
|
||||
return "group/parameterThree"
|
||||
case 4:
|
||||
return "group/parameterFour"
|
||||
}
|
||||
}
|
||||
function getBorderForGroupName() {
|
||||
switch (level) {
|
||||
case 1:
|
||||
return "group-open/parameterOne:border-solid group-open/parameterOne:border-0 group-open/parameterOne:border-b"
|
||||
case 2:
|
||||
return "group-open/parameterTwo:border-solid group-open/parameterTwo:border-0 group-open/parameterTwo:border-b"
|
||||
case 3:
|
||||
return "group-open/parameterThree:border-solid group-open/parameterThree:border-0 group-open/parameterThree:border-b"
|
||||
case 4:
|
||||
return "group-open/parameterFour:border-solid group-open/parameterFour:border-0 group-open/parameterFour:border-b"
|
||||
}
|
||||
}
|
||||
function getRotateForGroupName() {
|
||||
switch (level) {
|
||||
case 1:
|
||||
return "group-open/parameterOne:rotate-90"
|
||||
case 2:
|
||||
return "group-open/parameterTwo:rotate-90"
|
||||
case 3:
|
||||
return "group-open/parameterThree:rotate-90"
|
||||
case 4:
|
||||
return "group-open/parameterFour:rotate-90"
|
||||
}
|
||||
}
|
||||
function getItemClassNames(details = true) {
|
||||
return clsx(
|
||||
level < 3 && [
|
||||
"odd:[&:not(:first-child):not(:last-child)]:!border-y last:not(:first-child):!border-t",
|
||||
"first:!border-t-0 first:not(:last-child):!border-b last:!border-b-0 even:!border-y-0",
|
||||
],
|
||||
details && level == 1 && `group/parameter`,
|
||||
!details &&
|
||||
level == 1 &&
|
||||
`group-open/parameter:border-solid group-open/parameter:border-0 group-open/parameter:border-b`,
|
||||
level >= 3 && "!border-0"
|
||||
"odd:[&:not(:first-child):not(:last-child)]:!border-y last:not(:first-child):!border-t",
|
||||
"first:!border-t-0 first:not(:last-child):!border-b last:!border-b-0 even:!border-y-0",
|
||||
details && getGroupName(),
|
||||
!details && getBorderForGroupName()
|
||||
)
|
||||
}
|
||||
function getSummary(parameter: Parameter, key: number, nested = true) {
|
||||
@@ -48,16 +92,15 @@ const ParameterTypesItems = ({
|
||||
) : undefined
|
||||
}
|
||||
expandable={parameter.children?.length > 0}
|
||||
hideExpandableIcon={true}
|
||||
className={clsx(
|
||||
getItemClassNames(false),
|
||||
level < 3 && "!p-1",
|
||||
!nested && "cursor-default",
|
||||
level >= 3 && [
|
||||
"pl-1 mt-1",
|
||||
"mx-1 relative before:content-[''] before:h-full before:w-0.25",
|
||||
"before:absolute before:top-0 before:left-0",
|
||||
"before:bg-medusa-fg-muted before:rounded-full",
|
||||
]
|
||||
"py-1 pr-1",
|
||||
level === 1 && "pl-1",
|
||||
level === 2 && "pl-3",
|
||||
level === 3 && "pl-[120px]",
|
||||
level === 4 && "pl-[160px]",
|
||||
!nested && "cursor-default"
|
||||
)}
|
||||
onClick={(e) => {
|
||||
const targetElm = e.target as HTMLElement
|
||||
@@ -68,35 +111,63 @@ const ParameterTypesItems = ({
|
||||
}
|
||||
}}
|
||||
>
|
||||
<div className="flex gap-0.75">
|
||||
<InlineCode>{parameter.name}</InlineCode>
|
||||
<span className="font-monospace text-compact-small-plus text-medusa-fg-subtle">
|
||||
<MarkdownContent allowedElements={["a"]} unwrapDisallowed={true}>
|
||||
{parameter.type}
|
||||
</MarkdownContent>
|
||||
</span>
|
||||
{parameter.optional === false && (
|
||||
<span
|
||||
<div className="flex gap-0.5">
|
||||
{nested && (
|
||||
<TriangleRightMini
|
||||
className={clsx(
|
||||
"text-compact-x-small-plus uppercase",
|
||||
"text-medusa-fg-error"
|
||||
"text-medusa-fg-subtle transition-transform",
|
||||
getRotateForGroupName()
|
||||
)}
|
||||
>
|
||||
Required
|
||||
</span>
|
||||
/>
|
||||
)}
|
||||
{!nested && level > 1 && (
|
||||
<ArrowDownLeftMini
|
||||
className={clsx("text-medusa-fg-subtle flip-y")}
|
||||
/>
|
||||
)}
|
||||
<div className="flex gap-0.75 flex-wrap">
|
||||
<InlineCode>{parameter.name}</InlineCode>
|
||||
<span className="font-monospace text-compact-small-plus text-medusa-fg-subtle">
|
||||
<MarkdownContent allowedElements={["a"]} unwrapDisallowed={true}>
|
||||
{parameter.type}
|
||||
</MarkdownContent>
|
||||
</span>
|
||||
{parameter.optional === false && (
|
||||
<span
|
||||
className={clsx(
|
||||
"text-compact-x-small-plus uppercase",
|
||||
"text-medusa-fg-error"
|
||||
)}
|
||||
>
|
||||
Required
|
||||
</span>
|
||||
)}
|
||||
{parameter.featureFlag && (
|
||||
<FeatureFlagNotice
|
||||
featureFlag={parameter.featureFlag}
|
||||
type="parameter"
|
||||
badgeClassName="!p-0 leading-none"
|
||||
badgeContent={
|
||||
<IconFlagMini className="!text-medusa-tag-green-text" />
|
||||
}
|
||||
/>
|
||||
)}
|
||||
{parameter.expandable && (
|
||||
<ExpandableNotice
|
||||
type="method"
|
||||
link="#"
|
||||
badgeClassName="!p-0 leading-none"
|
||||
badgeContent={<ArrowsPointingOutMini />}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</DetailsSummary>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={clsx(
|
||||
level > 1 && "bg-docs-bg-surface rounded",
|
||||
level >= 3 && "mb-1"
|
||||
)}
|
||||
>
|
||||
<div>
|
||||
{parameters.map((parameter, key) => {
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -8,6 +8,8 @@ export type Parameter = {
|
||||
optional?: boolean
|
||||
defaultValue?: string
|
||||
description?: string
|
||||
featureFlag?: string
|
||||
expandable: boolean
|
||||
children?: Parameter[]
|
||||
}
|
||||
|
||||
@@ -22,7 +24,7 @@ const ParameterTypes = ({
|
||||
}: ParameterTypesType) => {
|
||||
return (
|
||||
<div
|
||||
className={clsx("bg-docs-bg shadow-card-rest rounded", className)}
|
||||
className={clsx("bg-docs-bg-surface shadow-card-rest rounded", className)}
|
||||
{...props}
|
||||
>
|
||||
<ParameterTypesItems parameters={parameters} />
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { IconProps } from "@medusajs/icons/dist/types"
|
||||
import clsx from "clsx"
|
||||
import React from "react"
|
||||
|
||||
const IconFlagMini = (props: IconProps) => {
|
||||
return (
|
||||
<svg
|
||||
width={props.width || 20}
|
||||
height={props.height || 20}
|
||||
viewBox="0 0 20 20"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
{...props}
|
||||
className={clsx("text-ui-fg-subtle", props.className)}
|
||||
>
|
||||
<path
|
||||
d="M5 4V5.51664M5 5.51664L6.51482 5.05445C7.65471 4.70701 8.85891 4.86835 9.90977 5.5093L9.96883 5.54531C10.9985 6.1731 12.1759 6.34089 13.2965 6.0195L14.9973 5.53131C14.7905 7.8586 14.7914 10.2064 15 12.5334L13.2971 13.0216C12.1764 13.3434 10.9987 13.1758 9.96883 12.5481L9.90977 12.5121C8.85891 11.8711 7.65471 11.7098 6.51482 12.0572L5 12.5194M5 5.51664V12.5194M5 16V12.5194"
|
||||
stroke="currentColor"
|
||||
strokeWidth="1.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
|
||||
export default IconFlagMini
|
||||
@@ -101,6 +101,7 @@ import {
|
||||
} from "@medusajs/icons"
|
||||
import IconPuzzleSolid from "./PuzzleSolid"
|
||||
import IconNextjs from "./Nextjs"
|
||||
import IconFlagMini from "./FlagMini"
|
||||
|
||||
export default {
|
||||
"academic-cap-solid": AcademicCapSolid,
|
||||
@@ -159,6 +160,7 @@ export default {
|
||||
"folder-open": FolderOpen,
|
||||
gatsby: Gatsby,
|
||||
"gift-solid": GiftSolid,
|
||||
"flag-mini": IconFlagMini,
|
||||
github: Github,
|
||||
"globe-europe": GlobeEurope,
|
||||
"globe-europe-solid": GlobeEuropeSolid,
|
||||
|
||||
Reference in new issue
Block a user