polen 0.10.0 → 0.11.0-next.2
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 +1 -0
- package/build/api/api.d.ts.map +1 -1
- package/build/api/api.js +1 -0
- package/build/api/api.js.map +1 -1
- package/build/api/config/configurator.d.ts +20 -22
- package/build/api/config/configurator.d.ts.map +1 -1
- package/build/api/config/configurator.js +27 -9
- 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/schema/data-sources/memory/memory.d.ts +2 -2
- package/build/api/schema/data-sources/memory/memory.d.ts.map +1 -1
- package/build/api/schema/data-sources/memory/memory.js +1 -3
- package/build/api/schema/data-sources/memory/memory.js.map +1 -1
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts +7 -3
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js +15 -11
- package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js.map +1 -1
- package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts +16 -7
- package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-directory/schema-directory.js +26 -7
- package/build/api/schema/data-sources/schema-directory/schema-directory.js.map +1 -1
- package/build/api/schema/data-sources/schema-file/schema-file.d.ts +7 -2
- package/build/api/schema/data-sources/schema-file/schema-file.d.ts.map +1 -1
- package/build/api/schema/data-sources/schema-file/schema-file.js +13 -5
- package/build/api/schema/data-sources/schema-file/schema-file.js.map +1 -1
- package/build/api/schema/metadata.d.ts +16 -0
- package/build/api/schema/metadata.d.ts.map +1 -0
- package/build/api/schema/metadata.js +19 -0
- package/build/api/schema/metadata.js.map +1 -0
- package/build/api/schema/read.d.ts +3 -3
- package/build/api/schema/read.d.ts.map +1 -1
- package/build/api/schema/read.js.map +1 -1
- package/build/api/schema/schema.d.ts +33 -2
- package/build/api/schema/schema.d.ts.map +1 -1
- package/build/api/schema/schema.js +42 -0
- package/build/api/schema/schema.js.map +1 -1
- package/build/api/schema-source/index.d.ts +2 -0
- package/build/api/schema-source/index.d.ts.map +1 -0
- package/build/api/schema-source/index.js +2 -0
- package/build/api/schema-source/index.js.map +1 -0
- package/build/api/schema-source/schema-source.d.ts +33 -0
- package/build/api/schema-source/schema-source.d.ts.map +1 -0
- package/build/api/schema-source/schema-source.js +137 -0
- package/build/api/schema-source/schema-source.js.map +1 -0
- 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/core.d.ts +1 -0
- package/build/api/vite/plugins/core.d.ts.map +1 -1
- package/build/api/vite/plugins/core.js +21 -18
- 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 +22 -0
- package/build/api/vite/plugins/schema-assets.d.ts.map +1 -0
- package/build/api/vite/plugins/schema-assets.js +269 -0
- package/build/api/vite/plugins/schema-assets.js.map +1 -0
- package/build/api/vite/plugins/serve.d.ts.map +1 -1
- package/build/api/vite/plugins/serve.js +11 -0
- package/build/api/vite/plugins/serve.js.map +1 -1
- package/build/lib/graphql-change/change-groups.d.ts +2 -0
- package/build/lib/graphql-change/change-groups.d.ts.map +1 -1
- package/build/lib/graphql-change/change-groups.js +54 -0
- package/build/lib/graphql-change/change-groups.js.map +1 -1
- package/build/lib/kit-temp.d.ts +9 -0
- package/build/lib/kit-temp.d.ts.map +1 -1
- package/build/lib/kit-temp.js +12 -0
- package/build/lib/kit-temp.js.map +1 -1
- package/build/lib/path-map/path-map.d.ts.map +1 -1
- package/build/lib/path-map/path-map.js +3 -1
- package/build/lib/path-map/path-map.js.map +1 -1
- package/build/project-data.d.ts +3 -11
- package/build/project-data.d.ts.map +1 -1
- package/build/template/components/Changelog.d.ts +3 -3
- package/build/template/components/Changelog.d.ts.map +1 -1
- package/build/template/components/Changelog.js +8 -84
- package/build/template/components/Changelog.js.map +1 -1
- package/build/template/components/CodeBlock.d.ts +2 -0
- package/build/template/components/CodeBlock.d.ts.map +1 -1
- package/build/template/components/CodeBlock.js +1 -4
- package/build/template/components/CodeBlock.js.map +1 -1
- package/build/template/components/ComponentDispatch.d.ts +34 -0
- package/build/template/components/ComponentDispatch.d.ts.map +1 -0
- package/build/template/components/ComponentDispatch.js +33 -0
- package/build/template/components/ComponentDispatch.js.map +1 -0
- package/build/template/components/ReferenceLink.d.ts +19 -0
- package/build/template/components/ReferenceLink.d.ts.map +1 -0
- package/build/template/components/ReferenceLink.js +19 -0
- package/build/template/components/ReferenceLink.js.map +1 -0
- package/build/template/components/TypeAnnotation.d.ts.map +1 -1
- package/build/template/components/TypeAnnotation.js +3 -3
- package/build/template/components/TypeAnnotation.js.map +1 -1
- package/build/template/components/TypeFieldsLinkList.d.ts.map +1 -1
- package/build/template/components/TypeFieldsLinkList.js +4 -4
- package/build/template/components/TypeFieldsLinkList.js.map +1 -1
- package/build/template/components/TypeIndex.js +2 -2
- package/build/template/components/TypeIndex.js.map +1 -1
- package/build/template/components/VersionSelector.d.ts +7 -0
- package/build/template/components/VersionSelector.d.ts.map +1 -0
- package/build/template/components/VersionSelector.js +30 -0
- package/build/template/components/VersionSelector.js.map +1 -0
- package/build/template/components/graphql/type-link.d.ts.map +1 -1
- package/build/template/components/graphql/type-link.js +2 -2
- package/build/template/components/graphql/type-link.js.map +1 -1
- package/build/template/hooks/useVersionPath.d.ts +6 -0
- package/build/template/hooks/useVersionPath.d.ts.map +1 -0
- package/build/template/hooks/useVersionPath.js +10 -0
- package/build/template/hooks/useVersionPath.js.map +1 -0
- package/build/template/layouts/ChangelogLayout.d.ts.map +1 -0
- package/build/template/{components → layouts}/ChangelogLayout.js +1 -1
- package/build/template/layouts/ChangelogLayout.js.map +1 -0
- package/build/template/layouts/index.d.ts +1 -0
- package/build/template/layouts/index.d.ts.map +1 -1
- package/build/template/layouts/index.js +1 -0
- package/build/template/layouts/index.js.map +1 -1
- package/build/template/lib/fetch-text.d.ts +8 -0
- package/build/template/lib/fetch-text.d.ts.map +1 -0
- package/build/template/lib/fetch-text.js +14 -0
- package/build/template/lib/fetch-text.js.map +1 -0
- package/build/template/lib/polen-url.d.ts +14 -0
- package/build/template/lib/polen-url.d.ts.map +1 -1
- package/build/template/lib/polen-url.js +16 -0
- package/build/template/lib/polen-url.js.map +1 -1
- package/build/template/lib/schema-utils/constants.d.ts +5 -0
- package/build/template/lib/schema-utils/constants.d.ts.map +1 -0
- package/build/template/lib/schema-utils/constants.js +5 -0
- package/build/template/lib/schema-utils/constants.js.map +1 -0
- package/build/template/lib/schema-utils/schema-utils.d.ts +15 -0
- package/build/template/lib/schema-utils/schema-utils.d.ts.map +1 -0
- package/build/template/lib/schema-utils/schema-utils.js +37 -0
- package/build/template/lib/schema-utils/schema-utils.js.map +1 -0
- package/build/template/routes/changelog.d.ts +4 -3
- package/build/template/routes/changelog.d.ts.map +1 -1
- package/build/template/routes/changelog.js +13 -7
- package/build/template/routes/changelog.js.map +1 -1
- package/build/template/routes/pages.d.ts +10 -0
- package/build/template/routes/pages.d.ts.map +1 -0
- package/build/template/routes/pages.js +76 -0
- package/build/template/routes/pages.js.map +1 -0
- package/build/template/routes/reference.$type.$field.js +1 -1
- package/build/template/routes/reference.$type.$field.js.map +1 -1
- package/build/template/routes/reference.$type.d.ts +4 -0
- package/build/template/routes/reference.$type.d.ts.map +1 -1
- package/build/template/routes/reference.$type.js +2 -0
- package/build/template/routes/reference.$type.js.map +1 -1
- package/build/template/routes/reference.d.ts +9 -3
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +30 -8
- package/build/template/routes/reference.js.map +1 -1
- package/build/template/routes/reference.version.$version.$type.$field.d.ts +6 -0
- package/build/template/routes/reference.version.$version.$type.$field.d.ts.map +1 -0
- package/build/template/routes/reference.version.$version.$type.$field.js +32 -0
- package/build/template/routes/reference.version.$version.$type.$field.js.map +1 -0
- package/build/template/routes/reference.version.$version.$type.d.ts +11 -0
- package/build/template/routes/reference.version.$version.$type.d.ts.map +1 -0
- package/build/template/routes/reference.version.$version.$type.js +26 -0
- package/build/template/routes/reference.version.$version.$type.js.map +1 -0
- package/build/template/routes/root.d.ts.map +1 -1
- package/build/template/routes/root.js +8 -72
- package/build/template/routes/root.js.map +1 -1
- package/build/template/server/app.d.ts +22 -1
- package/build/template/server/app.d.ts.map +1 -1
- package/build/template/server/app.js +19 -9
- package/build/template/server/app.js.map +1 -1
- package/build/template/server/main.js +9 -1
- package/build/template/server/main.js.map +1 -1
- package/build/template/server/ssg/generate.js +2 -2
- package/build/template/server/ssg/generate.js.map +1 -1
- package/build/template/server/ssg/get-route-paths.d.ts +1 -1
- package/build/template/server/ssg/get-route-paths.d.ts.map +1 -1
- package/build/template/server/ssg/get-route-paths.js +51 -27
- package/build/template/server/ssg/get-route-paths.js.map +1 -1
- package/build/template/sources/schema-source.d.ts +15 -0
- package/build/template/sources/schema-source.d.ts.map +1 -0
- package/build/template/sources/schema-source.js +63 -0
- package/build/template/sources/schema-source.js.map +1 -0
- package/package.json +16 -17
- package/src/api/api.ts +1 -0
- package/src/api/config/configurator.ts +51 -32
- package/src/api/config/merge.ts +0 -16
- package/src/api/content/metadata.ts +1 -1
- package/src/api/schema/data-sources/memory/memory.ts +3 -5
- package/src/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.ts +29 -13
- package/src/api/schema/data-sources/schema-directory/schema-directory.ts +56 -16
- package/src/api/schema/data-sources/schema-file/schema-file.ts +16 -7
- package/src/api/schema/metadata.ts +23 -0
- package/src/api/schema/read.ts +3 -3
- package/src/api/schema/schema.ts +62 -2
- package/src/api/schema-source/index.ts +1 -0
- package/src/api/schema-source/schema-source.ts +189 -0
- package/src/api/static/manifest.ts +1 -1
- package/src/api/vite/plugins/core.ts +23 -18
- package/src/api/vite/plugins/main.ts +1 -9
- package/src/api/vite/plugins/schema-assets.ts +317 -0
- package/src/api/vite/plugins/serve.ts +15 -8
- package/src/lib/graphql-change/change-groups.ts +57 -0
- package/src/lib/kit-temp.ts +13 -0
- package/src/lib/path-map/$.test.ts +22 -19
- package/src/lib/path-map/path-map.ts +3 -1
- package/src/project-data.ts +3 -11
- package/src/template/components/Changelog.tsx +16 -67
- package/src/template/components/CodeBlock.tsx +3 -5
- package/src/template/components/ComponentDispatch.tsx +42 -0
- package/src/template/components/ReferenceLink.tsx +34 -0
- package/src/template/components/TypeAnnotation.tsx +5 -7
- package/src/template/components/TypeFieldsLinkList.tsx +20 -23
- package/src/template/components/TypeIndex.tsx +10 -12
- package/src/template/components/VersionSelector.tsx +50 -0
- package/src/template/components/graphql/type-link.tsx +4 -3
- package/src/template/hooks/useVersionPath.ts +10 -0
- package/src/template/{components → layouts}/ChangelogLayout.tsx +1 -1
- package/src/template/layouts/index.ts +1 -0
- package/src/template/lib/fetch-text.ts +13 -0
- package/src/template/lib/polen-url.ts +20 -0
- package/src/template/lib/schema-utils/constants.ts +4 -0
- package/src/template/lib/schema-utils/schema-utils.ts +42 -0
- package/src/template/routes/changelog.tsx +17 -8
- package/src/template/routes/pages.tsx +109 -0
- package/src/template/routes/reference.$type.$field.tsx +1 -1
- package/src/template/routes/reference.$type.tsx +2 -0
- package/src/template/routes/reference.tsx +38 -6
- package/src/template/routes/reference.version.$version.$type.$field.tsx +35 -0
- package/src/template/routes/reference.version.$version.$type.tsx +30 -0
- package/src/template/routes/root.tsx +8 -109
- package/src/template/server/app.ts +47 -14
- package/src/template/server/main.ts +9 -1
- package/src/template/server/ssg/generate.ts +2 -2
- package/src/template/server/ssg/get-route-paths.ts +53 -27
- package/src/template/sources/schema-source.ts +68 -0
- package/build/lib/graphql-document/$$.d.ts +0 -5
- package/build/lib/graphql-document/$$.d.ts.map +0 -1
- package/build/lib/graphql-document/$$.js +0 -5
- package/build/lib/graphql-document/$$.js.map +0 -1
- package/build/lib/graphql-document/$.d.ts +0 -2
- package/build/lib/graphql-document/$.d.ts.map +0 -1
- package/build/lib/graphql-document/$.js +0 -2
- package/build/lib/graphql-document/$.js.map +0 -1
- package/build/lib/graphql-document/analysis.d.ts +0 -44
- package/build/lib/graphql-document/analysis.d.ts.map +0 -1
- package/build/lib/graphql-document/analysis.js +0 -361
- package/build/lib/graphql-document/analysis.js.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocument.d.ts +0 -38
- package/build/lib/graphql-document/components/GraphQLDocument.d.ts.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocument.js +0 -151
- package/build/lib/graphql-document/components/GraphQLDocument.js.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts +0 -7
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts.map +0 -1
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js +0 -27
- package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js.map +0 -1
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts +0 -33
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts.map +0 -1
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js +0 -50
- package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js.map +0 -1
- package/build/lib/graphql-document/components/IdentifierLink.d.ts +0 -39
- package/build/lib/graphql-document/components/IdentifierLink.d.ts.map +0 -1
- package/build/lib/graphql-document/components/IdentifierLink.js +0 -75
- package/build/lib/graphql-document/components/IdentifierLink.js.map +0 -1
- package/build/lib/graphql-document/components/graphql-document-styles.d.ts +0 -5
- package/build/lib/graphql-document/components/graphql-document-styles.d.ts.map +0 -1
- package/build/lib/graphql-document/components/graphql-document-styles.js +0 -144
- package/build/lib/graphql-document/components/graphql-document-styles.js.map +0 -1
- package/build/lib/graphql-document/components/index.d.ts +0 -5
- package/build/lib/graphql-document/components/index.d.ts.map +0 -1
- package/build/lib/graphql-document/components/index.js +0 -5
- package/build/lib/graphql-document/components/index.js.map +0 -1
- package/build/lib/graphql-document/example.d.ts +0 -25
- package/build/lib/graphql-document/example.d.ts.map +0 -1
- package/build/lib/graphql-document/example.js +0 -140
- package/build/lib/graphql-document/example.js.map +0 -1
- package/build/lib/graphql-document/graphql-document.d.ts +0 -35
- package/build/lib/graphql-document/graphql-document.d.ts.map +0 -1
- package/build/lib/graphql-document/graphql-document.js +0 -36
- package/build/lib/graphql-document/graphql-document.js.map +0 -1
- package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts +0 -43
- package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts.map +0 -1
- package/build/lib/graphql-document/hooks/use-tooltip-state.js +0 -132
- package/build/lib/graphql-document/hooks/use-tooltip-state.js.map +0 -1
- package/build/lib/graphql-document/positioning-simple.d.ts +0 -63
- package/build/lib/graphql-document/positioning-simple.d.ts.map +0 -1
- package/build/lib/graphql-document/positioning-simple.js +0 -185
- package/build/lib/graphql-document/positioning-simple.js.map +0 -1
- package/build/lib/graphql-document/schema-context.d.ts +0 -8
- package/build/lib/graphql-document/schema-context.d.ts.map +0 -1
- package/build/lib/graphql-document/schema-context.js +0 -11
- package/build/lib/graphql-document/schema-context.js.map +0 -1
- package/build/lib/graphql-document/schema-integration.d.ts +0 -135
- package/build/lib/graphql-document/schema-integration.d.ts.map +0 -1
- package/build/lib/graphql-document/schema-integration.js +0 -328
- package/build/lib/graphql-document/schema-integration.js.map +0 -1
- package/build/lib/graphql-document/types.d.ts +0 -117
- package/build/lib/graphql-document/types.d.ts.map +0 -1
- package/build/lib/graphql-document/types.js +0 -2
- package/build/lib/graphql-document/types.js.map +0 -1
- package/build/template/components/ChangelogLayout.d.ts.map +0 -1
- package/build/template/components/ChangelogLayout.js.map +0 -1
- package/build/template/components/CodeHikePre.d.ts +0 -16
- package/build/template/components/CodeHikePre.d.ts.map +0 -1
- package/build/template/components/CodeHikePre.js +0 -37
- package/build/template/components/CodeHikePre.js.map +0 -1
- package/src/lib/graphql-document/$$.ts +0 -4
- package/src/lib/graphql-document/$.test.ts +0 -132
- package/src/lib/graphql-document/$.ts +0 -1
- package/src/lib/graphql-document/README.md +0 -102
- package/src/lib/graphql-document/analysis.ts +0 -415
- package/src/lib/graphql-document/components/GraphQLDocument.tsx +0 -265
- package/src/lib/graphql-document/components/GraphQLDocument.unit.test.ts +0 -188
- package/src/lib/graphql-document/components/GraphQLDocumentWithSchema.tsx +0 -46
- package/src/lib/graphql-document/components/GraphQLIdentifierPopover.tsx +0 -199
- package/src/lib/graphql-document/components/IdentifierLink.tsx +0 -160
- package/src/lib/graphql-document/components/graphql-document-styles.ts +0 -144
- package/src/lib/graphql-document/components/index.ts +0 -4
- package/src/lib/graphql-document/demo.md +0 -155
- package/src/lib/graphql-document/example.ts +0 -163
- package/src/lib/graphql-document/graphql-document.ts +0 -37
- package/src/lib/graphql-document/hooks/use-tooltip-state.test.ts +0 -76
- package/src/lib/graphql-document/hooks/use-tooltip-state.ts +0 -191
- package/src/lib/graphql-document/positioning-simple.test.ts +0 -248
- package/src/lib/graphql-document/positioning-simple.ts +0 -260
- package/src/lib/graphql-document/schema-context.tsx +0 -20
- package/src/lib/graphql-document/schema-integration.test.ts +0 -365
- package/src/lib/graphql-document/schema-integration.ts +0 -488
- package/src/lib/graphql-document/types.ts +0 -129
- package/src/template/components/CodeHikePre.tsx +0 -51
- /package/build/template/{components → layouts}/ChangelogLayout.d.ts +0 -0
@@ -1,23 +1,21 @@
|
|
1
1
|
import { type HighlightedCode, Pre } from 'codehike/code'
|
2
|
+
import type { GraphQLSchema } from 'graphql'
|
2
3
|
import React from 'react'
|
3
4
|
import PROJECT_DATA from 'virtual:polen/project/data.jsonsuper'
|
4
5
|
import { GraphQLInteractive } from './GraphQLInteractive/index.js'
|
5
6
|
|
6
7
|
interface CodeBlockProps {
|
7
8
|
codeblock: HighlightedCode
|
9
|
+
schema?: GraphQLSchema
|
8
10
|
}
|
9
11
|
|
10
12
|
/**
|
11
13
|
* Code block component for Code Hike
|
12
14
|
* Handles pre-highlighted code blocks and interactive GraphQL blocks
|
13
15
|
*/
|
14
|
-
export const CodeBlock: React.FC<CodeBlockProps> = ({ codeblock }) => {
|
16
|
+
export const CodeBlock: React.FC<CodeBlockProps> = ({ codeblock, schema }) => {
|
15
17
|
// Check if this is an interactive GraphQL block
|
16
18
|
if (codeblock.lang === 'graphql' && codeblock.meta?.includes('interactive')) {
|
17
|
-
const schema = typeof window !== 'undefined'
|
18
|
-
? (window as any).__POLEN_GRAPHQL_SCHEMA__
|
19
|
-
: null
|
20
|
-
|
21
19
|
return (
|
22
20
|
<GraphQLInteractive
|
23
21
|
codeblock={codeblock}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
|
3
|
+
/**
|
4
|
+
* A generic component dispatcher that dynamically renders components from a namespace.
|
5
|
+
*
|
6
|
+
* Useful for cases where you need to select and render a component at runtime based on
|
7
|
+
* a string key, while maintaining some level of type safety through generics.
|
8
|
+
*
|
9
|
+
* @template TComponents - The object/namespace containing the components
|
10
|
+
* @template TName - The key type for component selection (constrained to keyof TComponents)
|
11
|
+
*
|
12
|
+
* @param components - The namespace/object containing the components to choose from
|
13
|
+
* @param name - The key to select which component to render
|
14
|
+
* @param props - The props to pass to the selected component
|
15
|
+
*
|
16
|
+
* @example
|
17
|
+
* ```tsx
|
18
|
+
* import * as MyComponents from './MyComponents'
|
19
|
+
*
|
20
|
+
* const componentName = getComponentName(data)
|
21
|
+
* return (
|
22
|
+
* <ComponentDispatch
|
23
|
+
* components={MyComponents}
|
24
|
+
* name={componentName}
|
25
|
+
* props={{ data }}
|
26
|
+
* />
|
27
|
+
* )
|
28
|
+
* ```
|
29
|
+
*/
|
30
|
+
export const ComponentDispatch = <
|
31
|
+
TComponents extends Record<string, React.ComponentType<any>>,
|
32
|
+
TName extends keyof TComponents,
|
33
|
+
>(
|
34
|
+
{ components, name, props }: {
|
35
|
+
components: TComponents
|
36
|
+
name: TName
|
37
|
+
props: object
|
38
|
+
},
|
39
|
+
) => {
|
40
|
+
const Component = components[name]
|
41
|
+
return React.createElement(Component as any, props)
|
42
|
+
}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type { ReactNode } from 'react'
|
2
|
+
import { useVersionPath } from '../hooks/useVersionPath.js'
|
3
|
+
import { Link } from './Link.js'
|
4
|
+
|
5
|
+
interface Props {
|
6
|
+
/** The GraphQL type name */
|
7
|
+
type: string
|
8
|
+
/** Optional field name for field-specific links */
|
9
|
+
field?: string
|
10
|
+
/** Link content */
|
11
|
+
children: ReactNode
|
12
|
+
}
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Link component for GraphQL schema references that preserves version context
|
16
|
+
*
|
17
|
+
* @example
|
18
|
+
* <ReferenceLink type="User">User</ReferenceLink>
|
19
|
+
* <ReferenceLink type="User" field="name">User.name</ReferenceLink>
|
20
|
+
*/
|
21
|
+
export const ReferenceLink = ({ type, field, children }: Props) => {
|
22
|
+
const versionPath = useVersionPath()
|
23
|
+
|
24
|
+
let path = `/reference/${versionPath}${type}`
|
25
|
+
if (field) {
|
26
|
+
path += `/${field}`
|
27
|
+
}
|
28
|
+
|
29
|
+
return (
|
30
|
+
<Link to={path}>
|
31
|
+
{children}
|
32
|
+
</Link>
|
33
|
+
)
|
34
|
+
}
|
@@ -2,7 +2,7 @@ import { Text } from '@radix-ui/themes'
|
|
2
2
|
import type { GraphQLType } from 'graphql'
|
3
3
|
import { isInputObjectType, isListType, isNamedType, isNonNullType, isScalarType } from 'graphql'
|
4
4
|
import type { FC } from 'react'
|
5
|
-
import {
|
5
|
+
import { ReferenceLink } from './ReferenceLink.js'
|
6
6
|
|
7
7
|
export interface Props {
|
8
8
|
type: GraphQLType // Can be either GraphQLInputType or GraphQLOutputType
|
@@ -40,20 +40,18 @@ export const TypeAnnotation: FC<Props> = ({ type }) => {
|
|
40
40
|
// Handle input object types
|
41
41
|
if (isInputObjectType(namedType)) {
|
42
42
|
return (
|
43
|
-
<
|
44
|
-
to={`/reference/${namedType.name}`}
|
45
|
-
>
|
43
|
+
<ReferenceLink type={namedType.name}>
|
46
44
|
<Text color='green'>{namedType.name}</Text>
|
47
|
-
</
|
45
|
+
</ReferenceLink>
|
48
46
|
)
|
49
47
|
}
|
50
48
|
|
51
49
|
// If it's an expandable type (object or interface), make it a link
|
52
50
|
// if (Grafaid.isExpandableType(namedType)) {
|
53
51
|
return (
|
54
|
-
<
|
52
|
+
<ReferenceLink type={namedType.name}>
|
55
53
|
<Text color={isScalarType(namedType) ? `purple` : `blue`}>{namedType.name}</Text>
|
56
|
-
</
|
54
|
+
</ReferenceLink>
|
57
55
|
)
|
58
56
|
|
59
57
|
// For scalar and other non-expandable types, just render the name
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Box, Flex, Heading } from '@radix-ui/themes'
|
2
2
|
import type { GraphQLInterfaceType, GraphQLObjectType } from 'graphql'
|
3
3
|
import type { FC } from 'react'
|
4
|
-
import {
|
4
|
+
import { ReferenceLink } from './ReferenceLink.js'
|
5
5
|
|
6
6
|
export interface Props {
|
7
7
|
type: GraphQLObjectType | GraphQLInterfaceType
|
@@ -9,27 +9,24 @@ export interface Props {
|
|
9
9
|
|
10
10
|
export const TypeFieldsLinkList: FC<Props> = ({ type }) => {
|
11
11
|
return (
|
12
|
-
|
13
|
-
<
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
</Flex>
|
32
|
-
</Box>
|
33
|
-
)
|
12
|
+
<Box>
|
13
|
+
<Heading>{type.name}</Heading>
|
14
|
+
<Flex direction='column'>
|
15
|
+
{Object.values(type.getFields()).map(field => {
|
16
|
+
return (
|
17
|
+
<Box key={field.name}>
|
18
|
+
<ReferenceLink
|
19
|
+
type={type.name}
|
20
|
+
field={field.name}
|
21
|
+
// TODO: can we use styled from Radix?
|
22
|
+
// activeProps={{ style: { fontWeight: `bold` } }}
|
23
|
+
>
|
24
|
+
{field.name}
|
25
|
+
</ReferenceLink>
|
26
|
+
</Box>
|
27
|
+
)
|
28
|
+
})}
|
29
|
+
</Flex>
|
30
|
+
</Box>
|
34
31
|
)
|
35
32
|
}
|
@@ -3,7 +3,7 @@ import { Box, Flex, Heading } from '@radix-ui/themes'
|
|
3
3
|
import { Obj } from '@wollybeard/kit'
|
4
4
|
import type { GraphQLNamedType, GraphQLSchema } from 'graphql'
|
5
5
|
import type { FC } from 'react'
|
6
|
-
import {
|
6
|
+
import { ReferenceLink } from './ReferenceLink.js'
|
7
7
|
|
8
8
|
export interface Props {
|
9
9
|
schema: GraphQLSchema
|
@@ -31,16 +31,14 @@ const TypeSection: FC<{ title: string; types: GraphQLNamedType[] }> = ({ title,
|
|
31
31
|
|
32
32
|
const TypeList: FC<{ types: GraphQLNamedType[] }> = ({ types }) => {
|
33
33
|
return (
|
34
|
-
|
35
|
-
|
36
|
-
{
|
37
|
-
<
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
</Box>
|
44
|
-
)
|
34
|
+
<Box>
|
35
|
+
{types.map(type => (
|
36
|
+
<Box key={type.name}>
|
37
|
+
<ReferenceLink type={type.name}>
|
38
|
+
{type.name}
|
39
|
+
</ReferenceLink>
|
40
|
+
</Box>
|
41
|
+
))}
|
42
|
+
</Box>
|
45
43
|
)
|
46
44
|
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { Select } from '@radix-ui/themes'
|
2
|
+
import { useNavigate, useParams } from 'react-router'
|
3
|
+
import { VERSION_LATEST } from '../lib/schema-utils/constants.js'
|
4
|
+
|
5
|
+
interface VersionSelectorProps {
|
6
|
+
availableVersions: string[]
|
7
|
+
currentVersion: string
|
8
|
+
}
|
9
|
+
|
10
|
+
export const VersionSelector = ({ availableVersions, currentVersion }: VersionSelectorProps) => {
|
11
|
+
const navigate = useNavigate()
|
12
|
+
const params = useParams()
|
13
|
+
|
14
|
+
// Don't show selector if only one version
|
15
|
+
if (availableVersions.length <= 1) {
|
16
|
+
return null
|
17
|
+
}
|
18
|
+
|
19
|
+
const handleVersionChange = (newVersion: string) => {
|
20
|
+
// Build new path preserving the current type/field if any
|
21
|
+
const currentType = params[`type`]
|
22
|
+
const currentField = params[`field`]
|
23
|
+
|
24
|
+
let newPath = `/reference`
|
25
|
+
if (newVersion !== VERSION_LATEST) {
|
26
|
+
newPath += `/version/${newVersion}`
|
27
|
+
}
|
28
|
+
if (currentType) {
|
29
|
+
newPath += `/${currentType}`
|
30
|
+
if (currentField) {
|
31
|
+
newPath += `/${currentField}`
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
navigate(newPath)
|
36
|
+
}
|
37
|
+
|
38
|
+
return (
|
39
|
+
<Select.Root value={currentVersion} onValueChange={handleVersionChange}>
|
40
|
+
<Select.Trigger />
|
41
|
+
<Select.Content>
|
42
|
+
{availableVersions.map(version => (
|
43
|
+
<Select.Item key={version} value={version}>
|
44
|
+
{version === VERSION_LATEST ? `Latest` : version}
|
45
|
+
</Select.Item>
|
46
|
+
))}
|
47
|
+
</Select.Content>
|
48
|
+
</Select.Root>
|
49
|
+
)
|
50
|
+
}
|
@@ -1,18 +1,19 @@
|
|
1
1
|
import { Grafaid } from '#lib/grafaid/index'
|
2
2
|
import { Code, Flex } from '@radix-ui/themes'
|
3
|
-
import {
|
3
|
+
import { ReferenceLink } from '../ReferenceLink.js'
|
4
4
|
import { TypeKindIcon } from './graphql.js'
|
5
5
|
import { typeKindTokensIndex } from './type-kind-tokens.js'
|
6
6
|
|
7
7
|
export const TypeLink: React.FC<{ type: Grafaid.Schema.TypesLike.Named }> = ({ type }) => {
|
8
8
|
const kind = Grafaid.Schema.typeKindFromClass(type)
|
9
|
+
|
9
10
|
return (
|
10
|
-
<
|
11
|
+
<ReferenceLink type={type.name}>
|
11
12
|
<Flex align='center' gap='1' display='inline-flex'>
|
12
13
|
<TypeKindIcon kind={kind} />
|
13
14
|
{` `}
|
14
15
|
<Code color={typeKindTokensIndex[kind].color} variant='ghost'>{type.name}</Code>
|
15
16
|
</Flex>
|
16
|
-
</
|
17
|
+
</ReferenceLink>
|
17
18
|
)
|
18
19
|
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { useParams } from 'react-router'
|
2
|
+
|
3
|
+
/**
|
4
|
+
* Custom hook to generate version path for versioned routes
|
5
|
+
* Returns the appropriate path prefix for the current version
|
6
|
+
*/
|
7
|
+
export const useVersionPath = (): string => {
|
8
|
+
const params = useParams()
|
9
|
+
return params[`version`] ? `version/${params[`version`]}/` : ``
|
10
|
+
}
|
@@ -8,7 +8,7 @@ import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
|
8
8
|
import { Box, Flex, Text } from '@radix-ui/themes'
|
9
9
|
import type React from 'react'
|
10
10
|
import { useEffect, useState } from 'react'
|
11
|
-
import { renderDate } from '
|
11
|
+
import { renderDate } from '../components/Changelog.js'
|
12
12
|
|
13
13
|
interface ChangelogLayoutProps {
|
14
14
|
children: React.ReactNode
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/**
|
2
|
+
* Fetch text content from a URL
|
3
|
+
* @param url - The URL to fetch from
|
4
|
+
* @returns Promise that resolves to the text content
|
5
|
+
* @throws Error if the request fails
|
6
|
+
*/
|
7
|
+
export const fetchText = async (url: string): Promise<string> => {
|
8
|
+
const response = await fetch(url)
|
9
|
+
if (!response.ok) {
|
10
|
+
throw new Error(`Failed to fetch: ${url} (${response.status} ${response.statusText})`)
|
11
|
+
}
|
12
|
+
return response.text()
|
13
|
+
}
|
@@ -33,3 +33,23 @@ export const polenUrlPath = (...segments: string[]): string => {
|
|
33
33
|
|
34
34
|
return basePath + path
|
35
35
|
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
* Create a Polen URL path for assets.
|
39
|
+
*
|
40
|
+
* This is a convenience wrapper around `polenUrlPath` that automatically
|
41
|
+
* prepends the assets root path.
|
42
|
+
*
|
43
|
+
* @param segments - Path segments within the assets directory
|
44
|
+
* @returns Full URL path to the asset
|
45
|
+
*
|
46
|
+
* @example
|
47
|
+
* polenUrlPathAssets('schemas', 'latest.json') // '/demos/pokemon/assets/schemas/latest.json'
|
48
|
+
* polenUrlPathAssets('images/logo.png') // '/demos/pokemon/assets/images/logo.png'
|
49
|
+
*/
|
50
|
+
export const polenUrlPathAssets = (...segments: string[]): string => {
|
51
|
+
return polenUrlPath(
|
52
|
+
PROJECT_DATA.server.routes.assets,
|
53
|
+
...segments,
|
54
|
+
)
|
55
|
+
}
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { buildSchema, print } from 'graphql'
|
2
|
+
import type { DocumentNode, GraphQLSchema } from 'graphql'
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Convert a GraphQL AST back to a GraphQL Schema object
|
6
|
+
*/
|
7
|
+
export const astToSchema = (ast: DocumentNode): GraphQLSchema => {
|
8
|
+
// Convert AST back to SDL string
|
9
|
+
const sdl = print(ast)
|
10
|
+
// Build schema from SDL
|
11
|
+
return buildSchema(sdl)
|
12
|
+
}
|
13
|
+
|
14
|
+
/**
|
15
|
+
* Simple cache for loaded schemas to avoid repeated conversions
|
16
|
+
*/
|
17
|
+
export const createSchemaCache = () => {
|
18
|
+
const cache = new Map<string, GraphQLSchema>()
|
19
|
+
|
20
|
+
return {
|
21
|
+
get(version: string): GraphQLSchema | undefined {
|
22
|
+
return cache.get(version)
|
23
|
+
},
|
24
|
+
|
25
|
+
set(version: string, schema: GraphQLSchema): void {
|
26
|
+
// Limit cache size to prevent memory issues
|
27
|
+
if (cache.size >= 10) {
|
28
|
+
const firstKey = cache.keys().next().value
|
29
|
+
if (firstKey) cache.delete(firstKey)
|
30
|
+
}
|
31
|
+
cache.set(version, schema)
|
32
|
+
},
|
33
|
+
|
34
|
+
has(version: string): boolean {
|
35
|
+
return cache.has(version)
|
36
|
+
},
|
37
|
+
|
38
|
+
clear(): void {
|
39
|
+
cache.clear()
|
40
|
+
},
|
41
|
+
}
|
42
|
+
}
|
@@ -1,25 +1,34 @@
|
|
1
|
+
import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
1
2
|
import { createRoute } from '#lib/react-router-aid/react-router-aid'
|
2
3
|
import { createLoader, useLoaderData } from '#lib/react-router-loader/react-router-loader'
|
3
|
-
import PROJECT_DATA from 'virtual:polen/project/data.jsonsuper'
|
4
4
|
import { Changelog } from '../components/Changelog.js'
|
5
|
-
import { ChangelogLayout } from '../
|
5
|
+
import { ChangelogLayout } from '../layouts/index.js'
|
6
|
+
import { schemaSource } from '../sources/schema-source.js'
|
7
|
+
|
8
|
+
const loader = createLoader(async () => {
|
9
|
+
// Check if schema exists first
|
10
|
+
if (schemaSource.isEmpty) {
|
11
|
+
return { changesets: [] }
|
12
|
+
}
|
13
|
+
|
14
|
+
// Fetch all changesets with before/after/changes data
|
15
|
+
const changesets = await schemaSource.getAllChangesets()
|
6
16
|
|
7
|
-
const loader = createLoader(() => {
|
8
17
|
return {
|
9
|
-
|
18
|
+
changesets,
|
10
19
|
}
|
11
20
|
})
|
12
21
|
|
13
22
|
const Component = () => {
|
14
23
|
const data = useLoaderData<typeof loader>()
|
15
24
|
|
16
|
-
if (
|
17
|
-
return <div>No
|
25
|
+
if (data.changesets.length === 0) {
|
26
|
+
return <div>No schema versions available for changelog.</div>
|
18
27
|
}
|
19
28
|
|
20
29
|
return (
|
21
|
-
<ChangelogLayout versions={data.
|
22
|
-
<Changelog
|
30
|
+
<ChangelogLayout versions={data.changesets}>
|
31
|
+
<Changelog changesets={data.changesets as [GraphqlChangeset.ChangeSet, ...GraphqlChangeset.ChangeSet[]]} />
|
23
32
|
</ChangelogLayout>
|
24
33
|
)
|
25
34
|
}
|
@@ -0,0 +1,109 @@
|
|
1
|
+
import { createRoute } from '#lib/react-router-aid/react-router-aid'
|
2
|
+
import { createLoader, useLoaderData } from '#lib/react-router-loader/react-router-loader'
|
3
|
+
import { SidebarLayout } from '#template/layouts/index'
|
4
|
+
import { MDXProvider } from '@mdx-js/react'
|
5
|
+
import {
|
6
|
+
Badge,
|
7
|
+
Box,
|
8
|
+
Button,
|
9
|
+
Callout,
|
10
|
+
Card,
|
11
|
+
Code,
|
12
|
+
DataList,
|
13
|
+
Em,
|
14
|
+
Heading,
|
15
|
+
Link,
|
16
|
+
Quote,
|
17
|
+
Separator,
|
18
|
+
Strong,
|
19
|
+
Table,
|
20
|
+
Tabs,
|
21
|
+
Text,
|
22
|
+
Tooltip,
|
23
|
+
} from '@radix-ui/themes'
|
24
|
+
import { Outlet, useLocation } from 'react-router'
|
25
|
+
import PROJECT_DATA_PAGES_CATALOG from 'virtual:polen/project/data/pages-catalog.jsonsuper'
|
26
|
+
import { routes } from 'virtual:polen/project/routes.jsx'
|
27
|
+
import { CodeBlock } from '../components/CodeBlock.js'
|
28
|
+
import { schemaSource } from '../sources/schema-source.js'
|
29
|
+
|
30
|
+
const loader = createLoader(async () => {
|
31
|
+
// Check if schema exists first
|
32
|
+
if (schemaSource.isEmpty) {
|
33
|
+
return { schema: null }
|
34
|
+
}
|
35
|
+
|
36
|
+
// Fetch the latest schema for MDX pages
|
37
|
+
const schema = await schemaSource.get('latest')
|
38
|
+
return { schema }
|
39
|
+
})
|
40
|
+
|
41
|
+
const Component = () => {
|
42
|
+
const { schema } = useLoaderData<typeof loader>()
|
43
|
+
const location = useLocation()
|
44
|
+
|
45
|
+
// Build sidebar from pages catalog
|
46
|
+
// Get the top-level path segment (e.g., '/guide/foo' -> '/guide')
|
47
|
+
const pathSegments = location.pathname.split('/').filter(Boolean)
|
48
|
+
const topLevelPath = pathSegments[0] ? `/${pathSegments[0]}` : '/'
|
49
|
+
|
50
|
+
// Get the sidebar for this section
|
51
|
+
const sidebar = PROJECT_DATA_PAGES_CATALOG.sidebarIndex[topLevelPath]?.items || []
|
52
|
+
|
53
|
+
return (
|
54
|
+
<MDXProvider
|
55
|
+
components={{
|
56
|
+
// Map markdown elements to Radix with spacing
|
57
|
+
p: (props) => <Text as='p' mb='4' {...props} />,
|
58
|
+
h1: (props) => <Heading size='8' mt='6' mb='4' {...props} />,
|
59
|
+
h2: (props) => <Heading size='7' mt='6' mb='3' {...props} />,
|
60
|
+
h3: (props) => <Heading size='6' mt='5' mb='3' {...props} />,
|
61
|
+
h4: (props) => <Heading size='5' mt='5' mb='2' {...props} />,
|
62
|
+
h5: (props) => <Heading size='4' mt='4' mb='2' {...props} />,
|
63
|
+
h6: (props) => <Heading size='3' mt='4' mb='2' {...props} />,
|
64
|
+
strong: Strong,
|
65
|
+
em: Em,
|
66
|
+
code: Code,
|
67
|
+
blockquote: (props) => <Quote my='4' {...props} />,
|
68
|
+
a: Link,
|
69
|
+
hr: (props) => <Separator my='6' {...props} />,
|
70
|
+
table: Table.Root,
|
71
|
+
thead: Table.Header,
|
72
|
+
tbody: Table.Body,
|
73
|
+
tr: Table.Row,
|
74
|
+
th: Table.ColumnHeaderCell,
|
75
|
+
td: Table.Cell,
|
76
|
+
// Lists need spacing too
|
77
|
+
ul: (props) => <Box as='ul' mb='4' style={{ paddingLeft: '1.5rem' }} {...props} />,
|
78
|
+
ol: (props) => <Box as='ol' mb='4' style={{ paddingLeft: '1.5rem' }} {...props} />,
|
79
|
+
li: (props) => <Box as='li' mb='2' {...props} />,
|
80
|
+
|
81
|
+
// Direct Radix components for MDX
|
82
|
+
Badge,
|
83
|
+
Button,
|
84
|
+
// @ts-expect-error
|
85
|
+
Callout,
|
86
|
+
Card,
|
87
|
+
// @ts-expect-error
|
88
|
+
DataList,
|
89
|
+
// @ts-expect-error
|
90
|
+
Tabs,
|
91
|
+
Tooltip,
|
92
|
+
|
93
|
+
// Code Hike component with schema injected
|
94
|
+
CodeBlock: (props: any) => <CodeBlock {...props} schema={schema} />,
|
95
|
+
}}
|
96
|
+
>
|
97
|
+
<SidebarLayout sidebar={sidebar}>
|
98
|
+
<Outlet />
|
99
|
+
</SidebarLayout>
|
100
|
+
</MDXProvider>
|
101
|
+
)
|
102
|
+
}
|
103
|
+
|
104
|
+
export const pages = createRoute({
|
105
|
+
// Pathless layout route - doesn't affect URL paths
|
106
|
+
loader,
|
107
|
+
Component,
|
108
|
+
children: [...routes], // All MDX page routes go here
|
109
|
+
})
|
@@ -3,6 +3,7 @@ import { useLoaderData } from '#lib/react-router-loader/react-router-loader'
|
|
3
3
|
import { useParams } from 'react-router'
|
4
4
|
import { MissingSchema } from '../components/MissingSchema.js'
|
5
5
|
import { NamedType } from '../components/NamedType.js'
|
6
|
+
import { reference$type$field } from './reference.$type.$field.js'
|
6
7
|
import type { reference } from './reference.js'
|
7
8
|
|
8
9
|
const Component = () => {
|
@@ -24,4 +25,5 @@ const Component = () => {
|
|
24
25
|
export const reference$type = createRoute({
|
25
26
|
path: `:type`,
|
26
27
|
Component,
|
28
|
+
children: [reference$type$field],
|
27
29
|
})
|