polen 0.11.0-next.1 → 0.11.0-next.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/api/api.d.ts +2 -1
- package/build/api/api.d.ts.map +1 -1
- package/build/api/api.js +5 -1
- package/build/api/api.js.map +1 -1
- package/build/api/config/configurator.d.ts +35 -23
- package/build/api/config/configurator.d.ts.map +1 -1
- package/build/api/config/configurator.js +0 -6
- package/build/api/config/configurator.js.map +1 -1
- package/build/api/config/merge.d.ts.map +1 -1
- package/build/api/config/merge.js +0 -11
- package/build/api/config/merge.js.map +1 -1
- package/build/api/content/metadata.d.ts +8 -2
- package/build/api/content/metadata.d.ts.map +1 -1
- package/build/api/content/metadata.js +1 -1
- package/build/api/content/metadata.js.map +1 -1
- package/build/api/iso/$$.d.ts +2 -0
- package/build/api/iso/$$.d.ts.map +1 -0
- package/build/api/iso/$$.js +2 -0
- package/build/api/iso/$$.js.map +1 -0
- package/build/api/iso/$.d.ts +2 -0
- package/build/api/iso/$.d.ts.map +1 -0
- package/build/api/iso/$.js +2 -0
- package/build/api/iso/$.js.map +1 -0
- package/build/api/iso/schema/$$.d.ts +4 -0
- package/build/api/iso/schema/$$.d.ts.map +1 -0
- package/build/api/iso/schema/$$.js +3 -0
- package/build/api/iso/schema/$$.js.map +1 -0
- package/build/api/iso/schema/$.d.ts +2 -0
- package/build/api/iso/schema/$.d.ts.map +1 -0
- package/build/api/iso/schema/$.js +2 -0
- package/build/api/iso/schema/$.js.map +1 -0
- package/build/api/iso/schema/constants.d.ts +25 -0
- package/build/api/iso/schema/constants.d.ts.map +1 -0
- package/build/api/iso/schema/constants.js +42 -0
- package/build/api/iso/schema/constants.js.map +1 -0
- package/build/api/iso/schema/routing.d.ts +22 -0
- package/build/api/iso/schema/routing.d.ts.map +1 -0
- package/build/api/iso/schema/routing.js +39 -0
- package/build/api/iso/schema/routing.js.map +1 -0
- package/build/api/iso.d.ts +2 -0
- package/build/api/iso.d.ts.map +1 -0
- package/build/api/iso.js +2 -0
- package/build/api/iso.js.map +1 -0
- package/build/api/schema/data-sources/data-sources.d.ts +1 -0
- package/build/api/schema/data-sources/data-sources.d.ts.map +1 -1
- package/build/api/schema/data-sources/data-sources.js +1 -0
- package/build/api/schema/data-sources/data-sources.js.map +1 -1
- package/build/api/schema/data-sources/introspection/introspection.d.ts +83 -0
- package/build/api/schema/data-sources/introspection/introspection.d.ts.map +1 -0
- package/build/api/schema/data-sources/introspection/introspection.js +110 -0
- package/build/api/schema/data-sources/introspection/introspection.js.map +1 -0
- package/build/api/schema/metadata.d.ts +11 -3
- package/build/api/schema/metadata.d.ts.map +1 -1
- package/build/api/schema/metadata.js +1 -1
- package/build/api/schema/metadata.js.map +1 -1
- package/build/api/schema/read.d.ts +83 -9
- package/build/api/schema/read.d.ts.map +1 -1
- package/build/api/schema/read.js +15 -6
- package/build/api/schema/read.js.map +1 -1
- package/build/api/schema/schema.d.ts +3 -25
- package/build/api/schema/schema.d.ts.map +1 -1
- package/build/api/schema/schema.js +5 -42
- package/build/api/schema/schema.js.map +1 -1
- package/build/api/schema-source/schema-source.d.ts +1 -1
- package/build/api/schema-source/schema-source.d.ts.map +1 -1
- package/build/api/schema-source/schema-source.js.map +1 -1
- package/build/api/static/manifest.d.ts +1 -2
- package/build/api/static/manifest.d.ts.map +1 -1
- package/build/api/static/manifest.js +1 -1
- package/build/api/static/manifest.js.map +1 -1
- package/build/api/vite/plugins/build.d.ts.map +1 -1
- package/build/api/vite/plugins/build.js +3 -0
- package/build/api/vite/plugins/build.js.map +1 -1
- package/build/api/vite/plugins/core.d.ts.map +1 -1
- package/build/api/vite/plugins/core.js +11 -14
- package/build/api/vite/plugins/core.js.map +1 -1
- package/build/api/vite/plugins/main.d.ts.map +1 -1
- package/build/api/vite/plugins/main.js +1 -8
- package/build/api/vite/plugins/main.js.map +1 -1
- package/build/api/vite/plugins/schema-assets.d.ts.map +1 -1
- package/build/api/vite/plugins/schema-assets.js +52 -11
- package/build/api/vite/plugins/schema-assets.js.map +1 -1
- package/build/cli/commands/open.js +1 -1
- package/build/cli/commands/open.js.map +1 -1
- package/build/lib/grafaid/schema/schema.d.ts +1 -1
- package/build/lib/grafaid/schema/schema.d.ts.map +1 -1
- package/build/lib/grafaid/schema/schema.js +1 -1
- package/build/lib/grafaid/schema/schema.js.map +1 -1
- package/build/lib/kit-temp.js +2 -2
- package/build/lib/kit-temp.js.map +1 -1
- package/build/lib/react-router-aid/react-router-aid.d.ts +5 -3
- package/build/lib/react-router-aid/react-router-aid.d.ts.map +1 -1
- package/build/lib/react-router-aid/react-router-aid.js +7 -4
- package/build/lib/react-router-aid/react-router-aid.js.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.d.ts.map +1 -1
- package/build/template/components/GraphQLInteractive/lib/parser.js +32 -10
- package/build/template/components/GraphQLInteractive/lib/parser.js.map +1 -1
- package/build/template/components/HamburgerMenu.d.ts +1 -0
- package/build/template/components/HamburgerMenu.d.ts.map +1 -1
- package/build/template/components/HamburgerMenu.js +2 -2
- package/build/template/components/HamburgerMenu.js.map +1 -1
- package/build/template/components/ReferenceLink.d.ts.map +1 -1
- package/build/template/components/ReferenceLink.js +2 -4
- package/build/template/components/ReferenceLink.js.map +1 -1
- package/build/template/components/VersionSelector.d.ts +3 -2
- package/build/template/components/VersionSelector.d.ts.map +1 -1
- package/build/template/components/VersionSelector.js +7 -15
- package/build/template/components/VersionSelector.js.map +1 -1
- package/build/template/components/sidebar/Sidebar.d.ts +3 -2
- package/build/template/components/sidebar/Sidebar.d.ts.map +1 -1
- package/build/template/components/sidebar/Sidebar.js +7 -6
- package/build/template/components/sidebar/Sidebar.js.map +1 -1
- package/build/template/components/sidebar/SidebarContext.d.ts +6 -0
- package/build/template/components/sidebar/SidebarContext.d.ts.map +1 -0
- package/build/template/components/sidebar/SidebarContext.js +3 -0
- package/build/template/components/sidebar/SidebarContext.js.map +1 -0
- package/build/template/components/sidebar/SidebarItem.d.ts.map +1 -1
- package/build/template/components/sidebar/SidebarItem.js +11 -4
- package/build/template/components/sidebar/SidebarItem.js.map +1 -1
- package/build/template/hooks/useVersionPath.d.ts.map +1 -1
- package/build/template/hooks/useVersionPath.js +3 -1
- package/build/template/hooks/useVersionPath.js.map +1 -1
- package/build/template/layouts/SidebarLayout.d.ts +3 -2
- package/build/template/layouts/SidebarLayout.d.ts.map +1 -1
- package/build/template/layouts/SidebarLayout.js +2 -2
- package/build/template/layouts/SidebarLayout.js.map +1 -1
- package/build/template/routes/changelog.js +2 -2
- package/build/template/routes/changelog.js.map +1 -1
- package/build/template/routes/index.js +2 -2
- package/build/template/routes/index.js.map +1 -1
- package/build/template/routes/pages.js +2 -2
- package/build/template/routes/pages.js.map +1 -1
- package/build/template/routes/reference.d.ts +27 -4
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +82 -24
- package/build/template/routes/reference.js.map +1 -1
- package/build/template/routes/root.js +3 -3
- package/build/template/routes/root.js.map +1 -1
- package/build/template/server/ssg/get-route-paths.d.ts.map +1 -1
- package/build/template/server/ssg/get-route-paths.js +81 -9
- package/build/template/server/ssg/get-route-paths.js.map +1 -1
- package/build/template/sources/schema-source.d.ts +1 -1
- package/build/template/sources/schema-source.d.ts.map +1 -1
- package/build/template/sources/schema-source.js +2 -1
- package/build/template/sources/schema-source.js.map +1 -1
- package/package.json +19 -17
- package/src/api/api.ts +7 -1
- package/src/api/config/configurator.ts +35 -30
- package/src/api/config/merge.ts +0 -16
- package/src/api/content/metadata.ts +1 -1
- package/src/api/iso/$$.ts +1 -0
- package/src/api/iso/$.ts +1 -0
- package/src/api/iso/schema/$$.ts +5 -0
- package/src/api/iso/schema/$.ts +1 -0
- package/src/api/iso/schema/constants.ts +49 -0
- package/src/api/iso/schema/routing.ts +53 -0
- package/src/api/iso.ts +1 -0
- package/src/api/schema/data-sources/data-sources.ts +1 -0
- package/src/api/schema/data-sources/introspection/introspection.ts +213 -0
- package/src/api/schema/metadata.ts +1 -1
- package/src/api/schema/read.ts +107 -16
- package/src/api/schema/schema.ts +6 -53
- package/src/api/schema-source/schema-source.ts +3 -3
- package/src/api/static/manifest.ts +1 -1
- package/src/api/vite/plugins/build.ts +3 -0
- package/src/api/vite/plugins/core.ts +11 -14
- package/src/api/vite/plugins/main.ts +1 -9
- package/src/api/vite/plugins/schema-assets.ts +59 -12
- package/src/cli/commands/open.ts +1 -1
- package/src/lib/grafaid/schema/schema.ts +1 -0
- package/src/lib/kit-temp.ts +2 -2
- package/src/lib/mask/$.test.ts +3 -3
- package/src/lib/react-router-aid/react-router-aid.ts +12 -6
- package/src/template/components/GraphQLInteractive/lib/parser.ts +32 -16
- package/src/template/components/HamburgerMenu.tsx +3 -1
- package/src/template/components/ReferenceLink.tsx +7 -4
- package/src/template/components/VersionSelector.tsx +10 -18
- package/src/template/components/sidebar/Sidebar.tsx +20 -16
- package/src/template/components/sidebar/SidebarContext.tsx +7 -0
- package/src/template/components/sidebar/SidebarItem.tsx +11 -4
- package/src/template/hooks/useVersionPath.ts +3 -1
- package/src/template/layouts/SidebarLayout.tsx +5 -3
- package/src/template/routes/changelog.tsx +2 -2
- package/src/template/routes/index.tsx +2 -2
- package/src/template/routes/pages.tsx +2 -2
- package/src/template/routes/reference.tsx +90 -25
- package/src/template/routes/root.tsx +3 -3
- package/src/template/server/ssg/get-route-paths.test.ts +145 -0
- package/src/template/server/ssg/get-route-paths.ts +80 -9
- package/src/template/sources/schema-source.ts +2 -1
- package/build/template/lib/schema-utils/constants.d.ts +0 -5
- package/build/template/lib/schema-utils/constants.d.ts.map +0 -1
- package/build/template/lib/schema-utils/constants.js +0 -5
- package/build/template/lib/schema-utils/constants.js.map +0 -1
- package/build/template/routes/reference.$type.$field.d.ts +0 -5
- package/build/template/routes/reference.$type.$field.d.ts.map +0 -1
- package/build/template/routes/reference.$type.$field.js +0 -31
- package/build/template/routes/reference.$type.$field.js.map +0 -1
- package/build/template/routes/reference.$type.d.ts +0 -9
- package/build/template/routes/reference.$type.d.ts.map +0 -1
- package/build/template/routes/reference.$type.js +0 -25
- package/build/template/routes/reference.$type.js.map +0 -1
- package/build/template/routes/reference.version.$version.$type.$field.d.ts +0 -6
- package/build/template/routes/reference.version.$version.$type.$field.d.ts.map +0 -1
- package/build/template/routes/reference.version.$version.$type.$field.js +0 -32
- package/build/template/routes/reference.version.$version.$type.$field.js.map +0 -1
- package/build/template/routes/reference.version.$version.$type.d.ts +0 -11
- package/build/template/routes/reference.version.$version.$type.d.ts.map +0 -1
- package/build/template/routes/reference.version.$version.$type.js +0 -26
- package/build/template/routes/reference.version.$version.$type.js.map +0 -1
- package/src/template/lib/schema-utils/constants.ts +0 -4
- package/src/template/routes/reference.$type.$field.tsx +0 -34
- package/src/template/routes/reference.$type.tsx +0 -29
- package/src/template/routes/reference.version.$version.$type.$field.tsx +0 -35
- package/src/template/routes/reference.version.$version.$type.tsx +0 -30
@@ -1,28 +1,32 @@
|
|
1
1
|
import type { Content } from '#api/content/$'
|
2
2
|
import { Box } from '@radix-ui/themes'
|
3
3
|
import type { BoxOwnProps, LayoutProps, MarginProps } from '@radix-ui/themes/props'
|
4
|
+
import { SidebarContext } from './SidebarContext.js'
|
4
5
|
import { Items } from './SidebarItem.js'
|
5
6
|
|
6
|
-
interface
|
7
|
+
interface Props extends LayoutProps, MarginProps, BoxOwnProps {
|
7
8
|
data: Content.Item[]
|
9
|
+
basePath?: string
|
8
10
|
style?: React.CSSProperties
|
9
11
|
}
|
10
12
|
|
11
|
-
export const Sidebar = ({ data, ...props }:
|
13
|
+
export const Sidebar = ({ data, basePath, ...props }: Props) => {
|
12
14
|
return (
|
13
|
-
<
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
15
|
+
<SidebarContext.Provider value={{ basePath }}>
|
16
|
+
<Box
|
17
|
+
data-testid='sidebar'
|
18
|
+
role='Sidebar'
|
19
|
+
{...props}
|
20
|
+
>
|
21
|
+
<style>
|
22
|
+
{`
|
23
|
+
div[role="Sidebar"] a:not([data-active]):hover {
|
24
|
+
background-color: var(--iris-2) !important;
|
25
|
+
}
|
26
|
+
`}
|
27
|
+
</style>
|
28
|
+
<Items items={data} />
|
29
|
+
</Box>
|
30
|
+
</SidebarContext.Provider>
|
27
31
|
)
|
28
32
|
}
|
@@ -1,9 +1,12 @@
|
|
1
1
|
import type { Content } from '#api/content/$'
|
2
|
+
import { Api } from '#api/iso'
|
2
3
|
import type { React } from '#dep/react/index'
|
3
4
|
import { Texts } from '#template/components/Texts/index'
|
4
5
|
import { Box, Flex } from '@radix-ui/themes'
|
6
|
+
import { useContext } from 'react'
|
5
7
|
import { useLocation } from 'react-router'
|
6
8
|
import { getPathActiveReport, Link } from '../Link.js'
|
9
|
+
import { SidebarContext } from './SidebarContext.js'
|
7
10
|
|
8
11
|
export const Items: React.FC<{ items: Content.Item[] }> = ({ items }) => {
|
9
12
|
return (
|
@@ -50,15 +53,17 @@ const SBLink: React.FC<{
|
|
50
53
|
link: Content.ItemLink | Content.ItemSection
|
51
54
|
}> = ({ link }) => {
|
52
55
|
const location = useLocation()
|
56
|
+
const { basePath } = useContext(SidebarContext)
|
53
57
|
const currentPathExp = location.pathname
|
54
|
-
const
|
58
|
+
const href = Api.Schema.Routing.joinSegmentsAndPaths(basePath, link.pathExp)
|
59
|
+
const active = getPathActiveReport(href, currentPathExp)
|
55
60
|
|
56
61
|
return (
|
57
62
|
<Link
|
58
63
|
role='Sidebar Link'
|
59
64
|
color={active.is ? `iris` : `gray`}
|
60
65
|
data-testid={`sidebar-link-${link.pathExp}`}
|
61
|
-
to={
|
66
|
+
to={href}
|
62
67
|
style={{
|
63
68
|
display: `block`,
|
64
69
|
textDecoration: `none`,
|
@@ -135,12 +140,14 @@ const LinkedSection: React.FC<{
|
|
135
140
|
|
136
141
|
const SectionLink: React.FC<{ link: Content.ItemLink }> = ({ link }) => {
|
137
142
|
const location = useLocation()
|
138
|
-
const
|
143
|
+
const { basePath } = useContext(SidebarContext)
|
144
|
+
const href = Api.Schema.Routing.joinSegmentsAndPaths(basePath, link.pathExp)
|
145
|
+
const active = getPathActiveReport(href, location.pathname)
|
139
146
|
|
140
147
|
return (
|
141
148
|
<Link
|
142
149
|
role='Sidebar Link'
|
143
|
-
to={
|
150
|
+
to={href}
|
144
151
|
color={active.is ? `iris` : `gray`}
|
145
152
|
style={{
|
146
153
|
textDecoration: `none`,
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { Api } from '#api/iso'
|
1
2
|
import { useParams } from 'react-router'
|
2
3
|
|
3
4
|
/**
|
@@ -6,5 +7,6 @@ import { useParams } from 'react-router'
|
|
6
7
|
*/
|
7
8
|
export const useVersionPath = (): string => {
|
8
9
|
const params = useParams()
|
9
|
-
|
10
|
+
const version = params[`version`] || Api.Schema.VERSION_LATEST
|
11
|
+
return Api.Schema.Routing.createReferenceVersionPath(version)
|
10
12
|
}
|
@@ -6,12 +6,13 @@ import { useLocation } from 'react-router'
|
|
6
6
|
import { HamburgerMenu } from '../components/HamburgerMenu.js'
|
7
7
|
import { Sidebar } from '../components/sidebar/Sidebar.js'
|
8
8
|
|
9
|
-
interface
|
9
|
+
interface Props {
|
10
10
|
children: React.ReactNode
|
11
11
|
sidebar: Content.Item[]
|
12
|
+
basePath?: string
|
12
13
|
}
|
13
14
|
|
14
|
-
export const SidebarLayout: React.FC<
|
15
|
+
export const SidebarLayout: React.FC<Props> = ({ children, sidebar, basePath }) => {
|
15
16
|
const location = useLocation()
|
16
17
|
const [mobileMenuOpen, setMobileMenuOpen] = useState(false)
|
17
18
|
|
@@ -45,6 +46,7 @@ export const SidebarLayout: React.FC<SidebarLayoutProps> = ({ children, sidebar
|
|
45
46
|
setMobileMenuOpen(false)
|
46
47
|
}}
|
47
48
|
sidebarData={sidebar}
|
49
|
+
basePath={basePath}
|
48
50
|
/>
|
49
51
|
</Box>
|
50
52
|
)}
|
@@ -56,7 +58,7 @@ export const SidebarLayout: React.FC<SidebarLayoutProps> = ({ children, sidebar
|
|
56
58
|
gridColumn='1 / 3'
|
57
59
|
gridRow='1 / auto'
|
58
60
|
>
|
59
|
-
<Sidebar data={sidebar} />
|
61
|
+
<Sidebar data={sidebar} basePath={basePath} />
|
60
62
|
</Box>
|
61
63
|
)}
|
62
64
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
2
|
-
import {
|
2
|
+
import { route } from '#lib/react-router-aid/react-router-aid'
|
3
3
|
import { createLoader, useLoaderData } from '#lib/react-router-loader/react-router-loader'
|
4
4
|
import { Changelog } from '../components/Changelog.js'
|
5
5
|
import { ChangelogLayout } from '../layouts/index.js'
|
@@ -33,7 +33,7 @@ const Component = () => {
|
|
33
33
|
)
|
34
34
|
}
|
35
35
|
|
36
|
-
export const changelog =
|
36
|
+
export const changelog = route({
|
37
37
|
path: `changelog`,
|
38
38
|
loader,
|
39
39
|
Component,
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import {
|
1
|
+
import { routeIndex } from '#lib/react-router-aid/react-router-aid'
|
2
2
|
import { Box } from '@radix-ui/themes'
|
3
3
|
|
4
4
|
const Component = () => {
|
5
5
|
return <Box>home todo</Box>
|
6
6
|
}
|
7
7
|
|
8
|
-
export const index =
|
8
|
+
export const index = routeIndex({
|
9
9
|
Component,
|
10
10
|
})
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {
|
1
|
+
import { route } from '#lib/react-router-aid/react-router-aid'
|
2
2
|
import { createLoader, useLoaderData } from '#lib/react-router-loader/react-router-loader'
|
3
3
|
import { SidebarLayout } from '#template/layouts/index'
|
4
4
|
import { MDXProvider } from '@mdx-js/react'
|
@@ -101,7 +101,7 @@ const Component = () => {
|
|
101
101
|
)
|
102
102
|
}
|
103
103
|
|
104
|
-
export const pages =
|
104
|
+
export const pages = route({
|
105
105
|
// Pathless layout route - doesn't affect URL paths
|
106
106
|
loader,
|
107
107
|
Component,
|
@@ -1,23 +1,23 @@
|
|
1
1
|
import type { Content } from '#api/content/$'
|
2
|
+
import { Api } from '#api/iso'
|
2
3
|
import { GrafaidOld } from '#lib/grafaid-old/index'
|
3
|
-
import {
|
4
|
+
import { Grafaid } from '#lib/grafaid/index'
|
5
|
+
import { route, routeIndex } from '#lib/react-router-aid/react-router-aid'
|
4
6
|
import { createLoader, useLoaderData } from '#lib/react-router-loader/react-router-loader'
|
5
7
|
import { Box } from '@radix-ui/themes'
|
6
|
-
import { Outlet } from 'react-router'
|
8
|
+
import { Outlet, useParams } from 'react-router'
|
9
|
+
import { Field } from '../components/Field.js'
|
7
10
|
import { MissingSchema } from '../components/MissingSchema.js'
|
11
|
+
import { NamedType } from '../components/NamedType.js'
|
8
12
|
import { VersionSelector } from '../components/VersionSelector.js'
|
9
|
-
import { useVersionPath } from '../hooks/useVersionPath.js'
|
10
13
|
import { SidebarLayout } from '../layouts/index.js'
|
11
|
-
import { VERSION_LATEST } from '../lib/schema-utils/constants.js'
|
12
14
|
import { schemaSource } from '../sources/schema-source.js'
|
13
|
-
import { reference$type } from './reference.$type.js'
|
14
|
-
import { referenceVersion$version$type } from './reference.version.$version.$type.js'
|
15
15
|
|
16
|
-
const loader = createLoader(async ({ params }) => {
|
16
|
+
export const loader = createLoader(async ({ params }) => {
|
17
17
|
// Handle both versioned and unversioned routes:
|
18
18
|
// - Versioned: /reference/version/:version/:type → params.version exists
|
19
19
|
// - Unversioned: /reference/:type → params.version is undefined, defaults to latest
|
20
|
-
const currentVersion = params.version ?? VERSION_LATEST
|
20
|
+
const currentVersion = params.version ?? Api.Schema.VERSION_LATEST
|
21
21
|
|
22
22
|
const schema = await schemaSource.get(currentVersion)
|
23
23
|
const availableVersions = schemaSource.versions
|
@@ -29,7 +29,7 @@ const loader = createLoader(async ({ params }) => {
|
|
29
29
|
}
|
30
30
|
})
|
31
31
|
|
32
|
-
const
|
32
|
+
const RouteReferenceComponent = () => {
|
33
33
|
const data = useLoaderData<typeof loader>()
|
34
34
|
|
35
35
|
if (!data.schema) {
|
@@ -42,9 +42,6 @@ const Component = () => {
|
|
42
42
|
const sidebarItems: Content.Item[] = []
|
43
43
|
const kindEntries = Object.entries(kindMap.list).filter(([_, types]) => types.length > 0)
|
44
44
|
|
45
|
-
// Build path prefix based on current version using new route structure
|
46
|
-
const versionPath = useVersionPath()
|
47
|
-
|
48
45
|
for (const [title, types] of kindEntries) {
|
49
46
|
sidebarItems.push({
|
50
47
|
type: `ItemSection` as const,
|
@@ -54,13 +51,16 @@ const Component = () => {
|
|
54
51
|
links: types.map(type => ({
|
55
52
|
type: `ItemLink` as const,
|
56
53
|
title: type.name,
|
57
|
-
pathExp:
|
54
|
+
pathExp: type.name, // Just the type name, basePath will be prepended
|
58
55
|
})),
|
59
56
|
})
|
60
57
|
}
|
61
58
|
|
59
|
+
// Calculate basePath based on current version
|
60
|
+
const basePath = Api.Schema.Routing.createReferenceBasePath(data.currentVersion)
|
61
|
+
|
62
62
|
return (
|
63
|
-
<SidebarLayout sidebar={sidebarItems}>
|
63
|
+
<SidebarLayout sidebar={sidebarItems} basePath={basePath}>
|
64
64
|
<Box mb={`4`}>
|
65
65
|
<VersionSelector
|
66
66
|
availableVersions={data.availableVersions}
|
@@ -72,18 +72,83 @@ const Component = () => {
|
|
72
72
|
)
|
73
73
|
}
|
74
74
|
|
75
|
-
//
|
76
|
-
const
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
75
|
+
// Shared hooks for schema data validation and retrieval
|
76
|
+
const useReferenceSchema = () => {
|
77
|
+
const data = useLoaderData<typeof loader>('reference')
|
78
|
+
if (!data?.schema) {
|
79
|
+
throw new Error('Schema not found')
|
80
|
+
}
|
81
|
+
return data
|
82
|
+
}
|
83
|
+
|
84
|
+
const useSchemaType = (typeName: string) => {
|
85
|
+
const { schema } = useReferenceSchema()
|
86
|
+
const type = schema.getType(typeName)
|
87
|
+
if (!type) {
|
88
|
+
throw new Error(`Could not find type ${typeName}`)
|
89
|
+
}
|
90
|
+
return type
|
91
|
+
}
|
92
|
+
|
93
|
+
const useSchemaField = (typeName: string, fieldName: string) => {
|
94
|
+
const type = useSchemaType(typeName)
|
95
|
+
if (!Grafaid.Schema.TypesLike.isFielded(type)) {
|
96
|
+
throw new Error(`Type ${typeName} does not have fields`)
|
97
|
+
}
|
98
|
+
|
99
|
+
const fields = type.getFields()
|
100
|
+
const field = fields[fieldName]
|
101
|
+
if (!field) {
|
102
|
+
throw new Error(`Could not find field ${fieldName} on type ${typeName}`)
|
103
|
+
}
|
104
|
+
return field
|
105
|
+
}
|
106
|
+
|
107
|
+
const RouteComponentIndex = () => {
|
108
|
+
return <div>Select a type from the sidebar to view its documentation.</div>
|
109
|
+
}
|
110
|
+
|
111
|
+
const RouteComponentType = () => {
|
112
|
+
const params = useParams() as { type: string }
|
113
|
+
const type = useSchemaType(params.type)
|
114
|
+
return <NamedType data={type} />
|
115
|
+
}
|
116
|
+
|
117
|
+
const RouteComponentTypeField = () => {
|
118
|
+
const params = useParams() as { type: string; field: string }
|
119
|
+
const field = useSchemaField(params.type, params.field)
|
120
|
+
return <Field data={field} />
|
121
|
+
}
|
122
|
+
|
123
|
+
const typeAndFieldRoutes = [
|
124
|
+
routeIndex(RouteComponentIndex),
|
125
|
+
route({
|
126
|
+
path: `:type`,
|
127
|
+
Component: RouteComponentType,
|
128
|
+
errorElement: <MissingSchema />,
|
129
|
+
children: [
|
130
|
+
route({
|
131
|
+
path: `:field`,
|
132
|
+
Component: RouteComponentTypeField,
|
133
|
+
errorElement: <MissingSchema />,
|
134
|
+
}),
|
135
|
+
],
|
136
|
+
}),
|
137
|
+
]
|
82
138
|
|
83
|
-
|
84
|
-
|
139
|
+
/**
|
140
|
+
* Reference documentation with proper nested structure - all routes in one file
|
141
|
+
*/
|
142
|
+
export const reference = route({
|
143
|
+
id: 'reference',
|
85
144
|
path: `reference`,
|
86
145
|
loader,
|
87
|
-
Component,
|
88
|
-
children: [
|
146
|
+
Component: RouteReferenceComponent,
|
147
|
+
children: [
|
148
|
+
...typeAndFieldRoutes,
|
149
|
+
route({
|
150
|
+
path: `version/:version`,
|
151
|
+
children: typeAndFieldRoutes,
|
152
|
+
}),
|
153
|
+
],
|
89
154
|
})
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { ReactRouter } from '#dep/react-router/index'
|
2
|
-
import {
|
2
|
+
import { route } from '#lib/react-router-aid/react-router-aid'
|
3
3
|
import { Box, Flex, Theme } from '@radix-ui/themes'
|
4
4
|
import { Link as LinkReactRouter } from 'react-router'
|
5
5
|
import { Outlet, ScrollRestoration } from 'react-router'
|
@@ -105,7 +105,7 @@ if (PROJECT_SCHEMA) {
|
|
105
105
|
//
|
106
106
|
//
|
107
107
|
|
108
|
-
const notFoundRoute =
|
108
|
+
const notFoundRoute = route({
|
109
109
|
id: `*_not_found`,
|
110
110
|
path: `*`,
|
111
111
|
Component: NotFound,
|
@@ -122,7 +122,7 @@ children.push(notFoundRoute)
|
|
122
122
|
//
|
123
123
|
//
|
124
124
|
|
125
|
-
export const root =
|
125
|
+
export const root = route({
|
126
126
|
path: `/`,
|
127
127
|
Component,
|
128
128
|
children,
|
@@ -0,0 +1,145 @@
|
|
1
|
+
import { beforeEach, describe, expect, test, vi } from 'vitest'
|
2
|
+
|
3
|
+
// Mock node:fs/promises
|
4
|
+
vi.mock('node:fs/promises', () => ({
|
5
|
+
readFile: vi.fn(),
|
6
|
+
}))
|
7
|
+
|
8
|
+
// Mock the virtual import
|
9
|
+
vi.mock('virtual:polen/project/data.jsonsuper', () => ({
|
10
|
+
default: {
|
11
|
+
paths: {
|
12
|
+
project: {
|
13
|
+
absolute: {
|
14
|
+
build: {
|
15
|
+
assets: {
|
16
|
+
schemas: '/mock/schemas',
|
17
|
+
},
|
18
|
+
},
|
19
|
+
},
|
20
|
+
},
|
21
|
+
},
|
22
|
+
},
|
23
|
+
}))
|
24
|
+
|
25
|
+
// Mock the routes
|
26
|
+
vi.mock('../../routes.js', () => ({
|
27
|
+
routes: [
|
28
|
+
{
|
29
|
+
path: 'reference',
|
30
|
+
children: [
|
31
|
+
{
|
32
|
+
path: 'version/:version',
|
33
|
+
children: [
|
34
|
+
{
|
35
|
+
path: ':type',
|
36
|
+
},
|
37
|
+
],
|
38
|
+
},
|
39
|
+
{
|
40
|
+
path: ':type',
|
41
|
+
},
|
42
|
+
],
|
43
|
+
},
|
44
|
+
],
|
45
|
+
}))
|
46
|
+
|
47
|
+
// Mock the API
|
48
|
+
vi.mock('#api/index', () => ({
|
49
|
+
Api: {
|
50
|
+
Schema: {
|
51
|
+
getMetadata: vi.fn(),
|
52
|
+
VERSION_LATEST: 'latest',
|
53
|
+
Routing: {
|
54
|
+
createReferencePath: vi.fn((parts) => {
|
55
|
+
const version = parts.version || 'latest'
|
56
|
+
const basePath = version === 'latest' ? '/reference' : `/reference/version/${version}`
|
57
|
+
if (parts.type) {
|
58
|
+
return parts.field ? `${basePath}/${parts.type}/${parts.field}` : `${basePath}/${parts.type}`
|
59
|
+
}
|
60
|
+
return basePath
|
61
|
+
}),
|
62
|
+
createReferenceBasePath: vi.fn((version) => {
|
63
|
+
return version === 'latest' ? '/reference' : `/reference/version/${version}`
|
64
|
+
}),
|
65
|
+
},
|
66
|
+
},
|
67
|
+
},
|
68
|
+
}))
|
69
|
+
|
70
|
+
describe('getRoutesPaths', () => {
|
71
|
+
beforeEach(() => {
|
72
|
+
vi.resetAllMocks()
|
73
|
+
})
|
74
|
+
|
75
|
+
test('should handle versioned routes without type parameter', async () => {
|
76
|
+
// Mock schema metadata
|
77
|
+
const { Api } = await import('#api/index')
|
78
|
+
vi.mocked(Api.Schema.getMetadata).mockResolvedValue({
|
79
|
+
hasSchema: true,
|
80
|
+
versions: ['2024-01-01', '2024-02-01'],
|
81
|
+
})
|
82
|
+
|
83
|
+
// Mock file system reads with proper GraphQL AST
|
84
|
+
const NodeFs = await import('node:fs/promises')
|
85
|
+
vi.mocked(NodeFs.readFile).mockImplementation(async (path) => {
|
86
|
+
if (typeof path === 'string' && path.includes('.json')) {
|
87
|
+
// Return a minimal GraphQL document AST
|
88
|
+
return JSON.stringify({
|
89
|
+
kind: 'Document',
|
90
|
+
definitions: [],
|
91
|
+
})
|
92
|
+
}
|
93
|
+
throw new Error(`Unexpected file read: ${path}`)
|
94
|
+
})
|
95
|
+
|
96
|
+
const { getRoutesPaths } = await import('./get-route-paths.js')
|
97
|
+
|
98
|
+
// This should not throw "Unhandled parameterized path: /reference/version/:version"
|
99
|
+
await expect(getRoutesPaths()).resolves.toBeDefined()
|
100
|
+
})
|
101
|
+
|
102
|
+
test('should generate paths for all schema versions', async () => {
|
103
|
+
const { Api } = await import('#api/index')
|
104
|
+
vi.mocked(Api.Schema.getMetadata).mockResolvedValue({
|
105
|
+
hasSchema: true,
|
106
|
+
versions: ['2024-01-01', '2024-02-01'],
|
107
|
+
})
|
108
|
+
|
109
|
+
// Mock schema with types - proper GraphQL AST
|
110
|
+
const mockSchema = {
|
111
|
+
kind: 'Document',
|
112
|
+
definitions: [
|
113
|
+
{
|
114
|
+
kind: 'ObjectTypeDefinition',
|
115
|
+
name: { kind: 'Name', value: 'User' },
|
116
|
+
},
|
117
|
+
{
|
118
|
+
kind: 'ObjectTypeDefinition',
|
119
|
+
name: { kind: 'Name', value: 'Post' },
|
120
|
+
},
|
121
|
+
],
|
122
|
+
}
|
123
|
+
|
124
|
+
const NodeFs = await import('node:fs/promises')
|
125
|
+
vi.mocked(NodeFs.readFile).mockImplementation(async (path) => {
|
126
|
+
if (typeof path === 'string' && path.includes('.json')) {
|
127
|
+
return JSON.stringify(mockSchema)
|
128
|
+
}
|
129
|
+
throw new Error(`Unexpected file read: ${path}`)
|
130
|
+
})
|
131
|
+
|
132
|
+
const { getRoutesPaths } = await import('./get-route-paths.js')
|
133
|
+
const paths = await getRoutesPaths()
|
134
|
+
|
135
|
+
// Should include versioned paths
|
136
|
+
expect(paths).toContain('/reference/version/2024-01-01/User')
|
137
|
+
expect(paths).toContain('/reference/version/2024-01-01/Post')
|
138
|
+
expect(paths).toContain('/reference/version/2024-02-01/User')
|
139
|
+
expect(paths).toContain('/reference/version/2024-02-01/Post')
|
140
|
+
|
141
|
+
// Should include unversioned paths
|
142
|
+
expect(paths).toContain('/reference/User')
|
143
|
+
expect(paths).toContain('/reference/Post')
|
144
|
+
})
|
145
|
+
})
|
@@ -11,7 +11,10 @@ import { routes } from '../../routes.js'
|
|
11
11
|
// Maybe we can figure something out too.
|
12
12
|
const knownParameterizedRouteExpressions = {
|
13
13
|
reference_type: `/reference/:type`,
|
14
|
+
reference_type_field: `/reference/:type/:field`,
|
15
|
+
reference_version: `/reference/version/:version`,
|
14
16
|
reference_versioned_type: `/reference/version/:version/:type`,
|
17
|
+
reference_versioned_type_field: `/reference/version/:version/:type/:field`,
|
15
18
|
}
|
16
19
|
|
17
20
|
export const getRoutesPaths = async (): Promise<string[]> => {
|
@@ -19,7 +22,7 @@ export const getRoutesPaths = async (): Promise<string[]> => {
|
|
19
22
|
const routeExpressions = ReactRouterAid.getRouteExpressions(routes)
|
20
23
|
|
21
24
|
// Helper function to load schema from filesystem and add type paths
|
22
|
-
const addTypePathsForVersion = async (version: string,
|
25
|
+
const addTypePathsForVersion = async (version: string, includeFields = false) => {
|
23
26
|
try {
|
24
27
|
const schemaFilePath = NodePath.join(PROJECT_DATA.paths.project.absolute.build.assets.schemas, `${version}.json`)
|
25
28
|
const schemaContent = await NodeFs.readFile(schemaFilePath, 'utf-8')
|
@@ -27,22 +30,70 @@ export const getRoutesPaths = async (): Promise<string[]> => {
|
|
27
30
|
|
28
31
|
visit(schemaAst, {
|
29
32
|
ObjectTypeDefinition(node) {
|
30
|
-
|
33
|
+
const typePath = Api.Schema.Routing.createReferencePath({
|
34
|
+
version: version === Api.Schema.VERSION_LATEST ? undefined : version,
|
35
|
+
type: node.name.value,
|
36
|
+
})
|
37
|
+
paths.add(typePath)
|
38
|
+
|
39
|
+
// Add field paths if requested
|
40
|
+
if (includeFields && node.fields) {
|
41
|
+
for (const field of node.fields) {
|
42
|
+
const fieldPath = Api.Schema.Routing.createReferencePath({
|
43
|
+
version: version === Api.Schema.VERSION_LATEST ? undefined : version,
|
44
|
+
type: node.name.value,
|
45
|
+
field: field.name.value,
|
46
|
+
})
|
47
|
+
paths.add(fieldPath)
|
48
|
+
}
|
49
|
+
}
|
31
50
|
},
|
32
51
|
InterfaceTypeDefinition(node) {
|
33
|
-
|
52
|
+
const typePath = Api.Schema.Routing.createReferencePath({
|
53
|
+
version: version === Api.Schema.VERSION_LATEST ? undefined : version,
|
54
|
+
type: node.name.value,
|
55
|
+
})
|
56
|
+
paths.add(typePath)
|
57
|
+
|
58
|
+
// Add field paths if requested
|
59
|
+
if (includeFields && node.fields) {
|
60
|
+
for (const field of node.fields) {
|
61
|
+
const fieldPath = Api.Schema.Routing.createReferencePath({
|
62
|
+
version: version === Api.Schema.VERSION_LATEST ? undefined : version,
|
63
|
+
type: node.name.value,
|
64
|
+
field: field.name.value,
|
65
|
+
})
|
66
|
+
paths.add(fieldPath)
|
67
|
+
}
|
68
|
+
}
|
34
69
|
},
|
35
70
|
EnumTypeDefinition(node) {
|
36
|
-
|
71
|
+
const typePath = Api.Schema.Routing.createReferencePath({
|
72
|
+
version: version === Api.Schema.VERSION_LATEST ? undefined : version,
|
73
|
+
type: node.name.value,
|
74
|
+
})
|
75
|
+
paths.add(typePath)
|
37
76
|
},
|
38
77
|
InputObjectTypeDefinition(node) {
|
39
|
-
|
78
|
+
const typePath = Api.Schema.Routing.createReferencePath({
|
79
|
+
version: version === Api.Schema.VERSION_LATEST ? undefined : version,
|
80
|
+
type: node.name.value,
|
81
|
+
})
|
82
|
+
paths.add(typePath)
|
40
83
|
},
|
41
84
|
UnionTypeDefinition(node) {
|
42
|
-
|
85
|
+
const typePath = Api.Schema.Routing.createReferencePath({
|
86
|
+
version: version === Api.Schema.VERSION_LATEST ? undefined : version,
|
87
|
+
type: node.name.value,
|
88
|
+
})
|
89
|
+
paths.add(typePath)
|
43
90
|
},
|
44
91
|
ScalarTypeDefinition(node) {
|
45
|
-
|
92
|
+
const typePath = Api.Schema.Routing.createReferencePath({
|
93
|
+
version: version === Api.Schema.VERSION_LATEST ? undefined : version,
|
94
|
+
type: node.name.value,
|
95
|
+
})
|
96
|
+
paths.add(typePath)
|
46
97
|
},
|
47
98
|
})
|
48
99
|
} catch (error) {
|
@@ -59,13 +110,33 @@ export const getRoutesPaths = async (): Promise<string[]> => {
|
|
59
110
|
if (exp === knownParameterizedRouteExpressions.reference_type) {
|
60
111
|
if (hasSchema) {
|
61
112
|
// Add paths for latest version (no version in URL)
|
62
|
-
await addTypePathsForVersion(Api.Schema.VERSION_LATEST
|
113
|
+
await addTypePathsForVersion(Api.Schema.VERSION_LATEST)
|
114
|
+
}
|
115
|
+
} else if (exp === knownParameterizedRouteExpressions.reference_version) {
|
116
|
+
if (hasSchema) {
|
117
|
+
// Add paths for version pages themselves (without type)
|
118
|
+
for (const version of availableVersions) {
|
119
|
+
const versionPath = Api.Schema.Routing.createReferenceBasePath(version)
|
120
|
+
paths.add(versionPath)
|
121
|
+
}
|
122
|
+
}
|
123
|
+
} else if (exp === knownParameterizedRouteExpressions.reference_type_field) {
|
124
|
+
if (hasSchema) {
|
125
|
+
// Add paths for latest version fields
|
126
|
+
await addTypePathsForVersion(Api.Schema.VERSION_LATEST, true)
|
63
127
|
}
|
64
128
|
} else if (exp === knownParameterizedRouteExpressions.reference_versioned_type) {
|
65
129
|
if (hasSchema) {
|
66
130
|
// Add paths for all versions using new route structure
|
67
131
|
for (const version of availableVersions) {
|
68
|
-
await addTypePathsForVersion(version
|
132
|
+
await addTypePathsForVersion(version)
|
133
|
+
}
|
134
|
+
}
|
135
|
+
} else if (exp === knownParameterizedRouteExpressions.reference_versioned_type_field) {
|
136
|
+
if (hasSchema) {
|
137
|
+
// Add paths for all versions with fields
|
138
|
+
for (const version of availableVersions) {
|
139
|
+
await addTypePathsForVersion(version, true)
|
69
140
|
}
|
70
141
|
}
|
71
142
|
} else if (ReactRouterAid.isParameterizedPath(exp)) {
|
@@ -13,8 +13,9 @@ const io = import.meta.env.SSR
|
|
13
13
|
|
14
14
|
// Extract the path after the assets route
|
15
15
|
// e.g., "/assets/schemas/latest.json" -> "schemas/latest.json"
|
16
|
+
// e.g., "/demos/pokemon/assets/schemas/latest.json" -> "schemas/latest.json"
|
16
17
|
const assetsRoute = PROJECT_DATA.server.routes.assets
|
17
|
-
const routePattern = new RegExp(
|
18
|
+
const routePattern = new RegExp(`${assetsRoute}/(.+)$`)
|
18
19
|
const match = path.match(routePattern)
|
19
20
|
const assetPath = match ? match[1] : path
|
20
21
|
|