|
1
|
import { OpenAPI } from "types" |
|
2
|
import { getApiRefTagSlug } from "docs-utils" |
|
3
|
import { apiRefIntroSections } from "@/utils/api-ref-paths" |
|
4
|
|
|
5
|
export const AREAS = ["store", "admin"] as const |
|
6
|
|
|
7
|
/** |
|
8
|
* Type guard for the supported API reference areas. |
|
9
|
*/ |
|
10
|
export const isArea = (area: string): area is OpenAPI.Area => |
|
11
|
AREAS.includes(area as OpenAPI.Area) |
|
12
|
|
|
13
|
/** |
|
14
|
* Find an intro section of an area by its slug. |
|
15
|
*/ |
|
16
|
export const getIntroSection = (area: OpenAPI.Area, section: string) => |
|
17
|
(apiRefIntroSections[area] ?? []).find((s) => s.slug === section) |
|
18
|
|
|
19
|
/** |
|
20
|
* Find a tag in the base specs by its slug. |
|
21
|
*/ |
|
22
|
export const getTagBySlug = ( |
|
23
|
data: OpenAPI.ExpandedDocument | undefined, |
|
24
|
section: string |
|
25
|
) => data?.tags?.find((tag) => getApiRefTagSlug(tag.name) === section) |
|
26
|
|
|
27
|
/** |
|
28
|
* The metadata base URL used across the API reference pages. |
|
29
|
*/ |
|
30
|
export const apiRefMetadataBase = new URL( |
|
31
|
process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000" |
|
32
|
) |