docs: update api-reference project for v2 (#7307)
* remove everything v1 and make v2 default * move main v2 rewrites to book * move rewrites to book + other fixes
This commit is contained in:
@@ -10,10 +10,10 @@ NEXT_PUBLIC_DOCS_URL=
|
||||
NEXT_PUBLIC_UI_URL=
|
||||
NEXT_PUBLIC_RESOURCES_URL=
|
||||
NEXT_PUBLIC_USER_GUIDE_URL=
|
||||
NEXT_PUBLIC_DOCS_V1_URL=
|
||||
NEXT_PUBLIC_API_V1_URL=
|
||||
ALGOLIA_WRITE_API_KEY=
|
||||
ANALYZE_BUNDLE=
|
||||
NEXT_PUBLIC_AI_ASSISTANT_URL=
|
||||
NEXT_PUBLIC_AI_WEBSITE_ID=
|
||||
NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
|
||||
NEXT_PUBLIC_VERSIONING=
|
||||
NEXT_PUBLIC_SHOW_V2=
|
||||
NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY=
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,34 +0,0 @@
|
||||
import { CodeTabs, CodeTab } from "docs-ui"
|
||||
import Space from "@/components/Space"
|
||||
import DownloadFull from "@/components/DownloadFull"
|
||||
|
||||
### Just Getting Started?
|
||||
|
||||
Check out the [quickstart guide](https://docs.medusajs.com/create-medusa-app).
|
||||
|
||||
<Space bottom={8} />
|
||||
|
||||
### Client Libraries
|
||||
|
||||
<CodeTabs group="clients">
|
||||
<CodeTab label="Medusa JS Client" value="js-client">
|
||||
|
||||
```bash
|
||||
npm install @medusajs/medusa-js
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
<CodeTab label="Medusa React" value="medusa-react">
|
||||
|
||||
```bash
|
||||
npm install medusa-react @tanstack/react-query @medusajs/medusa
|
||||
```
|
||||
|
||||
</CodeTab>
|
||||
</CodeTabs>
|
||||
|
||||
### Download Full Reference
|
||||
|
||||
Download this reference as an OpenApi YAML file. You can import this file to tools like Postman and start sending requests directly to your Medusa backend.
|
||||
|
||||
<DownloadFull />
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,13 @@
|
||||
import AreaProvider from "@/providers/area"
|
||||
import AdminContentV1 from "../../_mdx/v1/admin.mdx"
|
||||
import StoreContentV1 from "../../_mdx/v1/store.mdx"
|
||||
import ClientLibrariesV1 from "../../_mdx/v1/client-libraries.mdx"
|
||||
import AdminContentV2 from "../../_mdx/admin.mdx"
|
||||
import StoreContentV2 from "../../_mdx/store.mdx"
|
||||
import ClientLibrariesV2 from "../../_mdx/client-libraries.mdx"
|
||||
import Section from "@/components/Section"
|
||||
import Tags from "@/components/Tags"
|
||||
import type { Area } from "@/types/openapi"
|
||||
import DividedLayout from "@/layouts/Divided"
|
||||
import { capitalize } from "docs-ui"
|
||||
import PageTitleProvider from "../../../providers/page-title"
|
||||
import PageHeading from "../../../components/PageHeading"
|
||||
import PageTitleProvider from "@/providers/page-title"
|
||||
|
||||
type ReferencePageProps = {
|
||||
params: {
|
||||
@@ -20,16 +19,20 @@ const ReferencePage = async ({ params: { area } }: ReferencePageProps) => {
|
||||
return (
|
||||
<AreaProvider area={area}>
|
||||
<PageTitleProvider>
|
||||
<PageHeading className="!text-h2 block lg:hidden" />
|
||||
<h1 className="!text-h2 block lg:hidden">
|
||||
Medusa V2 {capitalize(area)} API Reference
|
||||
</h1>
|
||||
<DividedLayout
|
||||
mainContent={
|
||||
<Section>
|
||||
<PageHeading className="!text-h2 hidden lg:block" />
|
||||
{area.includes("admin") && <AdminContentV1 />}
|
||||
{area.includes("store") && <StoreContentV1 />}
|
||||
<h1 className="!text-h2 hidden lg:block">
|
||||
Medusa V2 {capitalize(area)} API Reference
|
||||
</h1>
|
||||
{area.includes("admin") && <AdminContentV2 />}
|
||||
{area.includes("store") && <StoreContentV2 />}
|
||||
</Section>
|
||||
}
|
||||
codeContent={<ClientLibrariesV1 />}
|
||||
codeContent={<ClientLibrariesV2 />}
|
||||
className="flex-col-reverse"
|
||||
/>
|
||||
<Tags />
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 253 KiB |
@@ -1,62 +0,0 @@
|
||||
import AreaProvider from "@/providers/area"
|
||||
import AdminContentV2 from "../../../_mdx/v2/admin.mdx"
|
||||
import StoreContentV2 from "../../../_mdx/v2/store.mdx"
|
||||
import ClientLibrariesV2 from "../../../_mdx/v2/client-libraries.mdx"
|
||||
import Section from "@/components/Section"
|
||||
import Tags from "@/components/Tags"
|
||||
import type { Area } from "@/types/openapi"
|
||||
import DividedLayout from "@/layouts/Divided"
|
||||
import { capitalize } from "docs-ui"
|
||||
import PageTitleProvider from "@/providers/page-title"
|
||||
import PageHeading from "@/components/PageHeading"
|
||||
|
||||
type ReferencePageProps = {
|
||||
params: {
|
||||
area: Area
|
||||
}
|
||||
}
|
||||
|
||||
const ReferencePage = async ({ params: { area } }: ReferencePageProps) => {
|
||||
return (
|
||||
<AreaProvider area={area}>
|
||||
<PageTitleProvider>
|
||||
<PageHeading className="!text-h2 block lg:hidden" />
|
||||
<DividedLayout
|
||||
mainContent={
|
||||
<Section>
|
||||
<PageHeading className="!text-h2 hidden lg:block" />
|
||||
{area.includes("admin") && <AdminContentV2 />}
|
||||
{area.includes("store") && <StoreContentV2 />}
|
||||
</Section>
|
||||
}
|
||||
codeContent={<ClientLibrariesV2 />}
|
||||
className="flex-col-reverse"
|
||||
/>
|
||||
<Tags />
|
||||
</PageTitleProvider>
|
||||
</AreaProvider>
|
||||
)
|
||||
}
|
||||
|
||||
export default ReferencePage
|
||||
|
||||
export function generateMetadata({ params: { area } }: ReferencePageProps) {
|
||||
return {
|
||||
title: `Medusa ${capitalize(area)} API Reference`,
|
||||
description: `REST API reference for the Medusa ${area} API. This reference includes code snippets and examples for Medusa JS Client and cURL.`,
|
||||
metadataBase: process.env.NEXT_PUBLIC_BASE_URL,
|
||||
}
|
||||
}
|
||||
|
||||
export const dynamicParams = false
|
||||
|
||||
export async function generateStaticParams() {
|
||||
return [
|
||||
{
|
||||
area: "admin",
|
||||
},
|
||||
{
|
||||
area: "store",
|
||||
},
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 253 KiB |
@@ -24,7 +24,7 @@ export async function GET() {
|
||||
const defaultIndexData = {
|
||||
version: ["current"],
|
||||
lang: "en",
|
||||
_tags: ["api", area],
|
||||
_tags: ["api", `${area}-v2`],
|
||||
}
|
||||
// find and parse static headers from pages
|
||||
const dom = await JSDOM.fromURL(getUrl(area))
|
||||
|
||||
@@ -2,12 +2,11 @@ import { NextResponse } from "next/server"
|
||||
import path from "path"
|
||||
import OpenAPIParser from "@readme/openapi-parser"
|
||||
import getPathsOfTag from "@/utils/get-paths-of-tag"
|
||||
import type { ExpandedDocument, Version } from "@/types/openapi"
|
||||
import type { ExpandedDocument } from "@/types/openapi"
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url)
|
||||
const area = searchParams.get("area")
|
||||
const version = (searchParams.get("version") as Version) || "1"
|
||||
const expand = searchParams.get("expand")
|
||||
if (area !== "admin" && area !== "store") {
|
||||
return NextResponse.json(
|
||||
@@ -21,11 +20,7 @@ export async function GET(request: Request) {
|
||||
)
|
||||
}
|
||||
const baseSpecs = (await OpenAPIParser.parse(
|
||||
path.join(
|
||||
process.cwd(),
|
||||
version === "1" ? "specs" : "specs-v2",
|
||||
`${area}/openapi.yaml`
|
||||
)
|
||||
path.join(process.cwd(), "specs", area, "openapi.yaml")
|
||||
)) as ExpandedDocument
|
||||
|
||||
if (expand) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { existsSync, readFileSync } from "fs"
|
||||
import { NextResponse } from "next/server"
|
||||
import path from "path"
|
||||
import { Version } from "../../../../types/openapi"
|
||||
|
||||
type DownloadParams = {
|
||||
params: {
|
||||
@@ -10,16 +9,8 @@ type DownloadParams = {
|
||||
}
|
||||
|
||||
export function GET(request: Request, { params }: DownloadParams) {
|
||||
const { searchParams } = new URL(request.url)
|
||||
const { area } = params
|
||||
const version =
|
||||
process.env.NEXT_PUBLIC_VERSIONING === "true"
|
||||
? (searchParams.get("version") as Version) || "1"
|
||||
: "1"
|
||||
const filePath = path.join(
|
||||
process.cwd(),
|
||||
`${version === "1" ? "specs" : "specs-v2"}/${area}/openapi.full.yaml`
|
||||
)
|
||||
const filePath = path.join(process.cwd(), "specs", area, "openapi.full.yaml")
|
||||
|
||||
if (!existsSync(filePath)) {
|
||||
return new NextResponse(null, {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import { SchemaObject, Version } from "../../../types/openapi"
|
||||
import { SchemaObject } from "../../../types/openapi"
|
||||
import path from "path"
|
||||
import { existsSync, promises as fs } from "fs"
|
||||
import { parseDocument } from "yaml"
|
||||
@@ -8,7 +8,6 @@ export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url)
|
||||
let name = searchParams.get("name")
|
||||
const area = searchParams.get("area")
|
||||
const version = (searchParams.get("version") as Version) || "1"
|
||||
|
||||
if (!name) {
|
||||
return NextResponse.json(
|
||||
@@ -40,7 +39,7 @@ export async function GET(request: Request) {
|
||||
|
||||
const schemaPath = path.join(
|
||||
process.cwd(),
|
||||
version === "1" ? "specs" : "specs-v2",
|
||||
"specs",
|
||||
area,
|
||||
"components",
|
||||
"schemas",
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import path from "path"
|
||||
import getPathsOfTag from "@/utils/get-paths-of-tag"
|
||||
import { Version } from "../../../types/openapi"
|
||||
|
||||
export async function GET(request: Request) {
|
||||
const { searchParams } = new URL(request.url)
|
||||
const tagName = searchParams.get("tagName") || ""
|
||||
const area = searchParams.get("area")
|
||||
const version = (searchParams.get("version") as Version) || "1"
|
||||
|
||||
if (area !== "admin" && area !== "store") {
|
||||
return NextResponse.json(
|
||||
@@ -23,10 +21,9 @@ export async function GET(request: Request) {
|
||||
|
||||
// this is just to ensure that vercel picks up these files on build
|
||||
path.join(process.cwd(), "specs")
|
||||
path.join(process.cwd(), "specs-v2")
|
||||
|
||||
// get path files
|
||||
const paths = await getPathsOfTag(tagName, area, version)
|
||||
const paths = await getPathsOfTag(tagName, area)
|
||||
|
||||
return NextResponse.json(
|
||||
{
|
||||
|
||||
@@ -11,20 +11,19 @@ import { useMemo } from "react"
|
||||
import { config } from "../../config"
|
||||
import { usePathname } from "next/navigation"
|
||||
import VersionSwitcher from "../VersionSwitcher"
|
||||
import { useVersion } from "../../providers/version"
|
||||
import basePathUrl from "../../utils/base-path-url"
|
||||
|
||||
const Navbar = () => {
|
||||
const { setMobileSidebarOpen, mobileSidebarOpen } = useSidebar()
|
||||
const pathname = usePathname()
|
||||
const { isLoading } = usePageLoading()
|
||||
const { isVersioningEnabled } = useVersion()
|
||||
|
||||
const navbarItems = useMemo(
|
||||
() =>
|
||||
getNavbarItems({
|
||||
basePath: config.baseUrl,
|
||||
activePath: pathname,
|
||||
version: process.env.NEXT_PUBLIC_SHOW_V2 ? "v1" : "legacy",
|
||||
version: "v2",
|
||||
}),
|
||||
[pathname]
|
||||
)
|
||||
@@ -32,17 +31,15 @@ const Navbar = () => {
|
||||
return (
|
||||
<UiNavbar
|
||||
logo={{
|
||||
light: "/images/logo-icon.png",
|
||||
dark: "/images/logo-icon-dark.png",
|
||||
light: basePathUrl("/images/logo-icon.png"),
|
||||
dark: basePathUrl("/images/logo-icon-dark.png"),
|
||||
}}
|
||||
items={navbarItems}
|
||||
mobileMenuButton={{
|
||||
setMobileSidebarOpen,
|
||||
mobileSidebarOpen,
|
||||
}}
|
||||
additionalActionsBefore={
|
||||
<>{isVersioningEnabled && <VersionSwitcher />}</>
|
||||
}
|
||||
additionalActionsBefore={<VersionSwitcher />}
|
||||
additionalActionsAfter={<FeedbackModal />}
|
||||
isLoading={isLoading}
|
||||
/>
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { capitalize } from "docs-ui"
|
||||
import { useArea } from "../../providers/area"
|
||||
import { useVersion } from "../../providers/version"
|
||||
|
||||
type PageHeadingProps = {
|
||||
className?: string
|
||||
}
|
||||
|
||||
const PageHeading = ({ className }: PageHeadingProps) => {
|
||||
const { area } = useArea()
|
||||
const { version, isVersioningEnabled } = useVersion()
|
||||
|
||||
const versionText = isVersioningEnabled ? ` V${version}` : ""
|
||||
|
||||
return (
|
||||
<h1 className={className}>
|
||||
Medusa{versionText} {capitalize(area)} API Reference
|
||||
</h1>
|
||||
)
|
||||
}
|
||||
|
||||
export default PageHeading
|
||||
@@ -4,7 +4,7 @@ import getSectionId from "@/utils/get-section-id"
|
||||
import type { OpenAPIV3 } from "openapi-types"
|
||||
import useSWR from "swr"
|
||||
import type { Operation, PathsObject } from "@/types/openapi"
|
||||
import { useSidebar, swrFetcher, getLinkWithBasePath } from "docs-ui"
|
||||
import { useSidebar, swrFetcher } from "docs-ui"
|
||||
import { Fragment, useEffect, useMemo } from "react"
|
||||
import dynamic from "next/dynamic"
|
||||
import type { TagOperationProps } from "../Operation"
|
||||
@@ -15,7 +15,7 @@ import getTagChildSidebarItems from "@/utils/get-tag-child-sidebar-items"
|
||||
import { useLoading } from "@/providers/loading"
|
||||
import DividedLoading from "@/components/DividedLoading"
|
||||
import { SidebarItemSections, SidebarItemType } from "types"
|
||||
import { useVersion } from "../../../providers/version"
|
||||
import basePathUrl from "../../../utils/base-path-url"
|
||||
|
||||
const TagOperation = dynamic<TagOperationProps>(
|
||||
async () => import("../Operation")
|
||||
@@ -28,7 +28,6 @@ export type TagPathsProps = {
|
||||
const TagPaths = ({ tag, className }: TagPathsProps) => {
|
||||
const tagSlugName = useMemo(() => getSectionId([tag.name]), [tag])
|
||||
const { area } = useArea()
|
||||
const { version } = useVersion()
|
||||
const { items, addItems, findItemInSection } = useSidebar()
|
||||
const { baseSpecs } = useBaseSpecs()
|
||||
const { loading } = useLoading()
|
||||
@@ -44,10 +43,7 @@ const TagPaths = ({ tag, className }: TagPathsProps) => {
|
||||
paths: PathsObject
|
||||
}>(
|
||||
!Object.keys(paths).length
|
||||
? getLinkWithBasePath(
|
||||
`/tag?tagName=${tagSlugName}&area=${area}&version=${version}`,
|
||||
process.env.NEXT_PUBLIC_BASE_PATH
|
||||
)
|
||||
? basePathUrl(`/api/tag?tagName=${tagSlugName}&area=${area}`)
|
||||
: null,
|
||||
swrFetcher,
|
||||
{
|
||||
|
||||
@@ -4,7 +4,6 @@ import getSectionId from "@/utils/get-section-id"
|
||||
import { useInView } from "react-intersection-observer"
|
||||
import { useEffect, useMemo, useState } from "react"
|
||||
import {
|
||||
getLinkWithBasePath,
|
||||
isElmWindow,
|
||||
swrFetcher,
|
||||
useScrollController,
|
||||
@@ -25,8 +24,8 @@ import { usePathname } from "next/navigation"
|
||||
import formatReportLink from "@/utils/format-report-link"
|
||||
import { SchemaObject, TagObject } from "@/types/openapi"
|
||||
import useSWR from "swr"
|
||||
import { useVersion } from "@/providers/version"
|
||||
import { TagSectionSchemaProps } from "./Schema"
|
||||
import basePathUrl from "../../../utils/base-path-url"
|
||||
|
||||
export type TagSectionProps = {
|
||||
tag: TagObject
|
||||
@@ -54,14 +53,12 @@ const TagSection = ({ tag }: TagSectionProps) => {
|
||||
const { area } = useArea()
|
||||
const pathname = usePathname()
|
||||
const { scrollableElement } = useScrollController()
|
||||
const { version } = useVersion()
|
||||
const { data } = useSWR<{
|
||||
schema: SchemaObject
|
||||
}>(
|
||||
tag["x-associatedSchema"]
|
||||
? getLinkWithBasePath(
|
||||
`/schema?name=${tag["x-associatedSchema"].$ref}&area=${area}&version=${version}`,
|
||||
process.env.NEXT_PUBLIC_BASE_PATH
|
||||
? basePathUrl(
|
||||
`/api/schema?name=${tag["x-associatedSchema"].$ref}&area=${area}`
|
||||
)
|
||||
: null,
|
||||
swrFetcher,
|
||||
|
||||
@@ -7,12 +7,12 @@ import { useBaseSpecs } from "@/providers/base-specs"
|
||||
import dynamic from "next/dynamic"
|
||||
import type { TagSectionProps } from "./Section"
|
||||
import { useArea } from "@/providers/area"
|
||||
import { swrFetcher, useSidebar, getLinkWithBasePath } from "docs-ui"
|
||||
import { swrFetcher, useSidebar } from "docs-ui"
|
||||
import getSectionId from "@/utils/get-section-id"
|
||||
import { ExpandedDocument } from "@/types/openapi"
|
||||
import getTagChildSidebarItems from "@/utils/get-tag-child-sidebar-items"
|
||||
import { SidebarItemSections } from "types"
|
||||
import { useVersion } from "../../providers/version"
|
||||
import basePathUrl from "../../utils/base-path-url"
|
||||
|
||||
const TagSection = dynamic<TagSectionProps>(
|
||||
async () => import("./Section")
|
||||
@@ -33,14 +33,10 @@ const Tags = () => {
|
||||
const { baseSpecs, setBaseSpecs } = useBaseSpecs()
|
||||
const { addItems } = useSidebar()
|
||||
const { area } = useArea()
|
||||
const { version } = useVersion()
|
||||
|
||||
const { data } = useSWR<ExpandedDocument>(
|
||||
loadData && !baseSpecs
|
||||
? getLinkWithBasePath(
|
||||
`/base-specs?area=${area}&expand=${expand}&version=${version}`,
|
||||
process.env.NEXT_PUBLIC_BASE_PATH
|
||||
)
|
||||
? basePathUrl(`/api/base-specs?area=${area}&expand=${expand}`)
|
||||
: null,
|
||||
swrFetcher,
|
||||
{
|
||||
|
||||
@@ -3,41 +3,20 @@
|
||||
import { Toggle } from "docs-ui"
|
||||
import clsx from "clsx"
|
||||
import { usePathname } from "next/navigation"
|
||||
import { useVersion } from "../../providers/version"
|
||||
|
||||
const VersionSwitcher = () => {
|
||||
const pathname = usePathname()
|
||||
const { version } = useVersion()
|
||||
|
||||
return (
|
||||
<div className="flex gap-0.5 justify-center items-center">
|
||||
<span
|
||||
className={clsx(
|
||||
version === "1" && "text-medusa-fg-subtle",
|
||||
version === "2" && "text-medusa-fg-disabled"
|
||||
)}
|
||||
>
|
||||
V1
|
||||
</span>
|
||||
<span className={clsx("text-medusa-fg-disabled")}>V1</span>
|
||||
<Toggle
|
||||
checked={version === "2"}
|
||||
onCheckedChange={(checked) => {
|
||||
let newPath = pathname.replace("/v2", "")
|
||||
if (checked) {
|
||||
newPath += `/v2`
|
||||
}
|
||||
|
||||
location.href = location.href.replace(pathname, newPath)
|
||||
checked={true}
|
||||
onCheckedChange={() => {
|
||||
location.href = process.env.NEXT_PUBLIC_API_V1_URL + pathname
|
||||
}}
|
||||
/>
|
||||
<span
|
||||
className={clsx(
|
||||
version === "1" && "text-medusa-fg-disabled",
|
||||
version === "2" && "text-medusa-fg-subtle"
|
||||
)}
|
||||
>
|
||||
V2
|
||||
</span>
|
||||
<span className={clsx("text-medusa-fg-subtle")}>V2</span>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import { DocsConfig } from "types"
|
||||
import { mobileSidebarItemsV1, legacyMobileSidebarItems } from "docs-ui"
|
||||
import { mobileSidebarItemsV2 } from "docs-ui"
|
||||
|
||||
export const config: DocsConfig = {
|
||||
baseUrl: process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000",
|
||||
basePath: process.env.NEXT_PUBLIC_BASE_PATH,
|
||||
// sidebar is auto generated
|
||||
sidebar: {
|
||||
top: [
|
||||
@@ -13,6 +14,6 @@ export const config: DocsConfig = {
|
||||
},
|
||||
],
|
||||
bottom: [],
|
||||
mobile: process.env.NEXT_PUBLIC_SHOW_V2 ? mobileSidebarItemsV1 : legacyMobileSidebarItems,
|
||||
mobile: mobileSidebarItemsV2,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
import { NextResponse } from "next/server"
|
||||
import type { NextRequest } from "next/server"
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
if (
|
||||
process.env.NEXT_PUBLIC_VERSIONING !== "true" &&
|
||||
request.url.includes("/v2")
|
||||
) {
|
||||
const url = new URL(request.url)
|
||||
return NextResponse.redirect(
|
||||
new URL(url.pathname.replace("/v2", ""), request.url)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: "/api/:path*",
|
||||
}
|
||||
@@ -3,45 +3,17 @@ import bundleAnalyzer from "@next/bundle-analyzer"
|
||||
|
||||
/** @type {import('next').NextConfig} */
|
||||
const nextConfig = {
|
||||
basePath: process.env.NEXT_PUBLIC_BASE_PATH || "/v2",
|
||||
async rewrites() {
|
||||
const fallbacks = [
|
||||
{
|
||||
source: "/ui",
|
||||
destination: `${process.env.NEXT_PUBLIC_UI_URL}/ui`,
|
||||
},
|
||||
{
|
||||
source: "/ui/:path*",
|
||||
destination: `${process.env.NEXT_PUBLIC_UI_URL}/ui/:path*`,
|
||||
},
|
||||
{
|
||||
source: "/:path*",
|
||||
destination: `${process.env.NEXT_PUBLIC_DOCS_URL}/:path*`,
|
||||
},
|
||||
]
|
||||
|
||||
if (process.env.NEXT_PUBLIC_SHOW_V2) {
|
||||
fallbacks.push(
|
||||
{
|
||||
source: "/v2/resources",
|
||||
destination: `${process.env.NEXT_PUBLIC_DOCS_V2_URL}/v2/resources`,
|
||||
},
|
||||
{
|
||||
source: "/v2/resources/:path*",
|
||||
destination: `${process.env.NEXT_PUBLIC_DOCS_V2_URL}/v2/resources/:path*`,
|
||||
},
|
||||
{
|
||||
source: "/v2",
|
||||
destination: `${process.env.NEXT_PUBLIC_DOCS_V2_URL}/v2`,
|
||||
},
|
||||
{
|
||||
source: "/v2/:path*",
|
||||
destination: `${process.env.NEXT_PUBLIC_DOCS_V2_URL}/v2/:path*`,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
fallback: fallbacks,
|
||||
fallback: [
|
||||
{
|
||||
source: "/:path*",
|
||||
destination: `${
|
||||
process.env.NEXT_PUBLIC_DOCS_URL || "https://localhost:3001"
|
||||
}/:path*`,
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
webpack: (config) => {
|
||||
|
||||
@@ -21,8 +21,8 @@ const AreaProvider = ({ area: passedArea, children }: AreaProviderProps) => {
|
||||
const { defaultFilters, setDefaultFilters } = useSearch()
|
||||
|
||||
useEffect(() => {
|
||||
if (!defaultFilters.includes(area)) {
|
||||
setDefaultFilters([area])
|
||||
if (!defaultFilters.includes(`${area}-v2`)) {
|
||||
setDefaultFilters([`${area}-v2`])
|
||||
}
|
||||
}, [area, defaultFilters, setDefaultFilters])
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
import BaseSpecsProvider from "./base-specs"
|
||||
import SidebarProvider from "./sidebar"
|
||||
import SearchProvider from "./search"
|
||||
import VersionProvider from "./version"
|
||||
import { config } from "../config"
|
||||
|
||||
type ProvidersProps = {
|
||||
@@ -30,9 +29,7 @@ const Providers = ({ children }: ProvidersProps) => {
|
||||
<ScrollControllerProvider scrollableSelector="#main">
|
||||
<SidebarProvider>
|
||||
<SearchProvider>
|
||||
<MobileProvider>
|
||||
<VersionProvider>{children}</VersionProvider>
|
||||
</MobileProvider>
|
||||
<MobileProvider>{children}</MobileProvider>
|
||||
</SearchProvider>
|
||||
</SidebarProvider>
|
||||
</ScrollControllerProvider>
|
||||
|
||||
@@ -3,11 +3,10 @@
|
||||
import {
|
||||
usePageLoading,
|
||||
SearchProvider as UiSearchProvider,
|
||||
AiAssistantCommandIcon,
|
||||
AiAssistantProvider,
|
||||
searchFiltersV1,
|
||||
searchFiltersV2,
|
||||
} from "docs-ui"
|
||||
import { config } from "../config"
|
||||
import basePathUrl from "../utils/base-path-url"
|
||||
|
||||
type SearchProviderProps = {
|
||||
children: React.ReactNode
|
||||
@@ -33,49 +32,26 @@ const SearchProvider = ({ children }: SearchProviderProps) => {
|
||||
title: "Getting started? Try one of the following terms.",
|
||||
items: [
|
||||
"Install Medusa with create-medusa-app",
|
||||
"Next.js quickstart",
|
||||
"Admin dashboard quickstart",
|
||||
"Commerce modules",
|
||||
"Medusa architecture",
|
||||
"What is an API route?",
|
||||
"What is a Module?",
|
||||
"What is a Workflow?",
|
||||
],
|
||||
},
|
||||
{
|
||||
title: "Developing with Medusa",
|
||||
items: [
|
||||
"Recipes",
|
||||
"How to create API routes",
|
||||
"How to create an entity",
|
||||
"How to create a plugin",
|
||||
"How to create a Module",
|
||||
"How to create an API route",
|
||||
"How to create a data model",
|
||||
"How to create an admin widget",
|
||||
],
|
||||
},
|
||||
],
|
||||
checkInternalPattern: new RegExp(
|
||||
`^${config.baseUrl}/api/(admin|store)`
|
||||
`^${config.baseUrl}${basePathUrl("/api/(admin|store)")}`
|
||||
),
|
||||
filterOptions: searchFiltersV1,
|
||||
filterOptions: searchFiltersV2,
|
||||
}}
|
||||
commands={[
|
||||
{
|
||||
name: "ai-assistant",
|
||||
icon: <AiAssistantCommandIcon />,
|
||||
component: (
|
||||
<AiAssistantProvider
|
||||
apiUrl={process.env.NEXT_PUBLIC_AI_ASSISTANT_URL || "temp"}
|
||||
websiteId={process.env.NEXT_PUBLIC_AI_WEBSITE_ID || "temp"}
|
||||
recaptchaSiteKey={
|
||||
process.env.NEXT_PUBLIC_AI_API_ASSISTANT_RECAPTCHA_SITE_KEY ||
|
||||
"temp"
|
||||
}
|
||||
/>
|
||||
),
|
||||
title: "AI Assistant",
|
||||
badge: {
|
||||
variant: "purple",
|
||||
children: "Beta",
|
||||
},
|
||||
},
|
||||
]}
|
||||
>
|
||||
{children}
|
||||
</UiSearchProvider>
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
"use client"
|
||||
|
||||
import { createContext, useContext, useMemo } from "react"
|
||||
import { Version } from "../types/openapi"
|
||||
import { usePathname } from "next/navigation"
|
||||
|
||||
type VersionContextType = {
|
||||
version: Version
|
||||
isVersioningEnabled: boolean
|
||||
}
|
||||
|
||||
const VersionContext = createContext<VersionContextType | null>(null)
|
||||
|
||||
type VersionProviderProps = {
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
const VersionProvider = ({ children }: VersionProviderProps) => {
|
||||
const pathname = usePathname()
|
||||
|
||||
const version = useMemo(() => {
|
||||
return pathname.includes("v2") ? "2" : "1"
|
||||
}, [pathname])
|
||||
|
||||
return (
|
||||
<VersionContext.Provider
|
||||
value={{
|
||||
version,
|
||||
isVersioningEnabled: process.env.NEXT_PUBLIC_VERSIONING === "true",
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</VersionContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export default VersionProvider
|
||||
|
||||
export const useVersion = (): VersionContextType => {
|
||||
const context = useContext(VersionContext)
|
||||
|
||||
if (!context) {
|
||||
throw new Error("useVersion must be used inside an VersionProvider")
|
||||
}
|
||||
|
||||
return context
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/collections' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/collections' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/collections/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/collections/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/collections/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/currencies' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/customer-groups' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/customer-groups' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/customer-groups/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/customer-groups/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/customer-groups/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/customer-groups/{id}/customers' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/customer-groups/{id}/customers/batch' \
|
||||
-H 'x-medusa-access-token: {api_token}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"customer_ids": [
|
||||
{
|
||||
"id": "id_dx2Wieq4uGG"
|
||||
}
|
||||
]
|
||||
}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/customers' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/customers' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/customers/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/customers/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/inventory-items' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/inventory-items' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/inventory-items/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/inventory-items/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/inventory-items/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/inventory-items/{id}/location-levels' \
|
||||
-H 'x-medusa-access-token: {api_token}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"location_id": "{value}",
|
||||
"stocked_quantity": 1506469662949376
|
||||
}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/inventory-items/{id}/location-levels/{location_id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/inventory-items/{id}/location-levels/{location_id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/invites' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/invites' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,7 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/invites/accept' \
|
||||
-H 'x-medusa-access-token: {api_token}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"first_name": "{value}",
|
||||
"last_name": "{value}"
|
||||
}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/payments/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/payments/{id}/capture' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/payments/{id}/refund' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/price-lists' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,14 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/price-lists' \
|
||||
-H 'x-medusa-access-token: {api_token}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"title": "{value}",
|
||||
"description": "{value}",
|
||||
"prices": [
|
||||
{
|
||||
"currency_code": "{value}",
|
||||
"amount": 1270314195484672,
|
||||
"variant_id": "{value}"
|
||||
}
|
||||
]
|
||||
}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/price-lists/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/price-lists/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/price-lists/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"prices": [
|
||||
{
|
||||
"currency_code": "{value}",
|
||||
"amount": 1670236243755008,
|
||||
"variant_id": "{value}"
|
||||
}
|
||||
]
|
||||
}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/products' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/products' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/products/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/products/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/products/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/products/{id}/options' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/products/{id}/options/{option_id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/products/{id}/options/{option_id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/products/{id}/variants' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/products/{id}/variants' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/products/{id}/variants/{variant_id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/products/{id}/variants/{variant_id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/regions' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/regions' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/regions/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/regions/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/regions/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/sales-channels' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/sales-channels' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/sales-channels/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/sales-channels/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/sales-channels/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,6 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/stock-locations' \
|
||||
-H 'x-medusa-access-token: {api_token}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"name": "Dorthy"
|
||||
}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/stock-locations/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/stock-locations/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/tax-rates' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,7 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/tax-rates' \
|
||||
-H 'x-medusa-access-token: {api_token}' \
|
||||
-H 'Content-Type: application/json' \
|
||||
--data-raw '{
|
||||
"name": "Emilio",
|
||||
"tax_region_id": "{value}"
|
||||
}'
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/tax-rates/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/tax-rates/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/tax-rates/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/users' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X POST '{backend_url}/admin/users' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl -X DELETE '{backend_url}/admin/users/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
@@ -1,2 +0,0 @@
|
||||
curl '{backend_url}/admin/users/{id}' \
|
||||
-H 'x-medusa-access-token: {api_token}'
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user