polen 0.10.0 → 0.11.0-next.10
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 +55 -26
- 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/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/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 +85 -11
- 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 +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/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 +1 -0
- package/build/api/vite/plugins/core.d.ts.map +1 -1
- package/build/api/vite/plugins/core.js +25 -22
- 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 +310 -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/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/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 +14 -2
- 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/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/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 +15 -9
- 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.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.d.ts +35 -6
- package/build/template/routes/reference.d.ts.map +1 -1
- package/build/template/routes/reference.js +97 -14
- package/build/template/routes/reference.js.map +1 -1
- package/build/template/routes/root.d.ts.map +1 -1
- package/build/template/routes/root.js +11 -75
- 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 +90 -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 +64 -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 +86 -36
- package/src/api/config/merge.ts +0 -16
- package/src/api/content/metadata.ts +1 -1
- 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/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 +109 -18
- 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/build.ts +3 -0
- package/src/api/vite/plugins/core.ts +27 -22
- package/src/api/vite/plugins/main.ts +1 -9
- package/src/api/vite/plugins/schema-assets.ts +364 -0
- package/src/api/vite/plugins/serve.ts +15 -8
- package/src/cli/commands/open.ts +1 -1
- package/src/lib/grafaid/schema/schema.ts +1 -0
- package/src/lib/graphql-change/change-groups.ts +57 -0
- package/src/lib/kit-temp.ts +15 -2
- package/src/lib/mask/$.test.ts +3 -3
- package/src/lib/path-map/$.test.ts +22 -19
- package/src/lib/path-map/path-map.ts +3 -1
- package/src/lib/react-router-aid/react-router-aid.ts +12 -6
- 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 +19 -10
- package/src/template/routes/index.tsx +2 -2
- package/src/template/routes/pages.tsx +109 -0
- package/src/template/routes/reference.tsx +112 -12
- package/src/template/routes/root.tsx +11 -112
- 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.test.ts +132 -0
- package/src/template/server/ssg/get-route-paths.ts +91 -27
- package/src/template/sources/schema-source.ts +69 -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/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 -5
- package/build/template/routes/reference.$type.d.ts.map +0 -1
- package/build/template/routes/reference.$type.js +0 -23
- package/build/template/routes/reference.$type.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/src/template/routes/reference.$type.$field.tsx +0 -34
- package/src/template/routes/reference.$type.tsx +0 -27
- /package/build/template/{components → layouts}/ChangelogLayout.d.ts +0 -0
@@ -0,0 +1,132 @@
|
|
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
|
+
},
|
54
|
+
},
|
55
|
+
}))
|
56
|
+
|
57
|
+
describe('getRoutesPaths', () => {
|
58
|
+
beforeEach(() => {
|
59
|
+
vi.resetAllMocks()
|
60
|
+
})
|
61
|
+
|
62
|
+
test('should handle versioned routes without type parameter', async () => {
|
63
|
+
// Mock schema metadata
|
64
|
+
const { Api } = await import('#api/index')
|
65
|
+
vi.mocked(Api.Schema.getMetadata).mockResolvedValue({
|
66
|
+
hasSchema: true,
|
67
|
+
versions: ['2024-01-01', '2024-02-01'],
|
68
|
+
})
|
69
|
+
|
70
|
+
// Mock file system reads with proper GraphQL AST
|
71
|
+
const NodeFs = await import('node:fs/promises')
|
72
|
+
vi.mocked(NodeFs.readFile).mockImplementation(async (path) => {
|
73
|
+
if (typeof path === 'string' && path.includes('.json')) {
|
74
|
+
// Return a minimal GraphQL document AST
|
75
|
+
return JSON.stringify({
|
76
|
+
kind: 'Document',
|
77
|
+
definitions: [],
|
78
|
+
})
|
79
|
+
}
|
80
|
+
throw new Error(`Unexpected file read: ${path}`)
|
81
|
+
})
|
82
|
+
|
83
|
+
const { getRoutesPaths } = await import('./get-route-paths.js')
|
84
|
+
|
85
|
+
// This should not throw "Unhandled parameterized path: /reference/version/:version"
|
86
|
+
await expect(getRoutesPaths()).resolves.toBeDefined()
|
87
|
+
})
|
88
|
+
|
89
|
+
test('should generate paths for all schema versions', async () => {
|
90
|
+
const { Api } = await import('#api/index')
|
91
|
+
vi.mocked(Api.Schema.getMetadata).mockResolvedValue({
|
92
|
+
hasSchema: true,
|
93
|
+
versions: ['2024-01-01', '2024-02-01'],
|
94
|
+
})
|
95
|
+
|
96
|
+
// Mock schema with types - proper GraphQL AST
|
97
|
+
const mockSchema = {
|
98
|
+
kind: 'Document',
|
99
|
+
definitions: [
|
100
|
+
{
|
101
|
+
kind: 'ObjectTypeDefinition',
|
102
|
+
name: { kind: 'Name', value: 'User' },
|
103
|
+
},
|
104
|
+
{
|
105
|
+
kind: 'ObjectTypeDefinition',
|
106
|
+
name: { kind: 'Name', value: 'Post' },
|
107
|
+
},
|
108
|
+
],
|
109
|
+
}
|
110
|
+
|
111
|
+
const NodeFs = await import('node:fs/promises')
|
112
|
+
vi.mocked(NodeFs.readFile).mockImplementation(async (path) => {
|
113
|
+
if (typeof path === 'string' && path.includes('.json')) {
|
114
|
+
return JSON.stringify(mockSchema)
|
115
|
+
}
|
116
|
+
throw new Error(`Unexpected file read: ${path}`)
|
117
|
+
})
|
118
|
+
|
119
|
+
const { getRoutesPaths } = await import('./get-route-paths.js')
|
120
|
+
const paths = await getRoutesPaths()
|
121
|
+
|
122
|
+
// Should include versioned paths
|
123
|
+
expect(paths).toContain('/reference/version/2024-01-01/User')
|
124
|
+
expect(paths).toContain('/reference/version/2024-01-01/Post')
|
125
|
+
expect(paths).toContain('/reference/version/2024-02-01/User')
|
126
|
+
expect(paths).toContain('/reference/version/2024-02-01/Post')
|
127
|
+
|
128
|
+
// Should include unversioned paths
|
129
|
+
expect(paths).toContain('/reference/User')
|
130
|
+
expect(paths).toContain('/reference/Post')
|
131
|
+
})
|
132
|
+
})
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
import { visit } from 'graphql'
|
3
|
-
// Or your specific import path for this type
|
1
|
+
import { Api } from '#api/index'
|
4
2
|
import { ReactRouterAid } from '#lib/react-router-aid/index'
|
3
|
+
import { visit } from 'graphql'
|
4
|
+
import * as NodeFs from 'node:fs/promises'
|
5
|
+
import * as NodePath from 'node:path'
|
5
6
|
import PROJECT_DATA from 'virtual:polen/project/data.jsonsuper'
|
6
7
|
import { routes } from '../../routes.js'
|
7
8
|
|
@@ -10,37 +11,100 @@ import { routes } from '../../routes.js'
|
|
10
11
|
// Maybe we can figure something out too.
|
11
12
|
const knownParameterizedRouteExpressions = {
|
12
13
|
reference_type: `/reference/:type`,
|
14
|
+
reference_type_field: `/reference/:type/:field`,
|
15
|
+
reference_version: `/reference/version/:version`,
|
16
|
+
reference_versioned_type: `/reference/version/:version/:type`,
|
17
|
+
reference_versioned_type_field: `/reference/version/:version/:type/:field`,
|
13
18
|
}
|
14
19
|
|
15
|
-
export const getRoutesPaths = (): string[] => {
|
20
|
+
export const getRoutesPaths = async (): Promise<string[]> => {
|
16
21
|
const paths = new Set<string>()
|
17
22
|
const routeExpressions = ReactRouterAid.getRouteExpressions(routes)
|
18
23
|
|
24
|
+
// Helper function to load schema from filesystem and add type paths
|
25
|
+
const addTypePathsForVersion = async (version: string, pathPrefix: string, includeFields = false) => {
|
26
|
+
try {
|
27
|
+
const schemaFilePath = NodePath.join(PROJECT_DATA.paths.project.absolute.build.assets.schemas, `${version}.json`)
|
28
|
+
const schemaContent = await NodeFs.readFile(schemaFilePath, 'utf-8')
|
29
|
+
const schemaAst = JSON.parse(schemaContent)
|
30
|
+
|
31
|
+
visit(schemaAst, {
|
32
|
+
ObjectTypeDefinition(node) {
|
33
|
+
const typePath = `${pathPrefix}/${node.name.value}`
|
34
|
+
paths.add(typePath)
|
35
|
+
|
36
|
+
// Add field paths if requested
|
37
|
+
if (includeFields && node.fields) {
|
38
|
+
for (const field of node.fields) {
|
39
|
+
paths.add(`${typePath}/${field.name.value}`)
|
40
|
+
}
|
41
|
+
}
|
42
|
+
},
|
43
|
+
InterfaceTypeDefinition(node) {
|
44
|
+
const typePath = `${pathPrefix}/${node.name.value}`
|
45
|
+
paths.add(typePath)
|
46
|
+
|
47
|
+
// Add field paths if requested
|
48
|
+
if (includeFields && node.fields) {
|
49
|
+
for (const field of node.fields) {
|
50
|
+
paths.add(`${typePath}/${field.name.value}`)
|
51
|
+
}
|
52
|
+
}
|
53
|
+
},
|
54
|
+
EnumTypeDefinition(node) {
|
55
|
+
paths.add(`${pathPrefix}/${node.name.value}`)
|
56
|
+
},
|
57
|
+
InputObjectTypeDefinition(node) {
|
58
|
+
paths.add(`${pathPrefix}/${node.name.value}`)
|
59
|
+
},
|
60
|
+
UnionTypeDefinition(node) {
|
61
|
+
paths.add(`${pathPrefix}/${node.name.value}`)
|
62
|
+
},
|
63
|
+
ScalarTypeDefinition(node) {
|
64
|
+
paths.add(`${pathPrefix}/${node.name.value}`)
|
65
|
+
},
|
66
|
+
})
|
67
|
+
} catch (error) {
|
68
|
+
throw new Error(`SSG failed to load schema for version ${version}. Ensure schema assets are built. ${error}`)
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
const schemaMetadataPath = NodePath.join(PROJECT_DATA.paths.project.absolute.build.assets.schemas, 'metadata.json')
|
73
|
+
|
74
|
+
const schemaMetadata = await Api.Schema.getMetadata(schemaMetadataPath)
|
75
|
+
const { hasSchema, versions: availableVersions } = schemaMetadata
|
76
|
+
|
19
77
|
for (const exp of routeExpressions) {
|
20
78
|
if (exp === knownParameterizedRouteExpressions.reference_type) {
|
21
|
-
if (
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
79
|
+
if (hasSchema) {
|
80
|
+
// Add paths for latest version (no version in URL)
|
81
|
+
await addTypePathsForVersion(Api.Schema.VERSION_LATEST, `/reference`)
|
82
|
+
}
|
83
|
+
} else if (exp === knownParameterizedRouteExpressions.reference_version) {
|
84
|
+
if (hasSchema) {
|
85
|
+
// Add paths for version pages themselves (without type)
|
86
|
+
for (const version of availableVersions) {
|
87
|
+
paths.add(`/reference/version/${version}`)
|
88
|
+
}
|
89
|
+
}
|
90
|
+
} else if (exp === knownParameterizedRouteExpressions.reference_type_field) {
|
91
|
+
if (hasSchema) {
|
92
|
+
// Add paths for latest version fields
|
93
|
+
await addTypePathsForVersion(Api.Schema.VERSION_LATEST, `/reference`, true)
|
94
|
+
}
|
95
|
+
} else if (exp === knownParameterizedRouteExpressions.reference_versioned_type) {
|
96
|
+
if (hasSchema) {
|
97
|
+
// Add paths for all versions using new route structure
|
98
|
+
for (const version of availableVersions) {
|
99
|
+
await addTypePathsForVersion(version, `/reference/version/${version}`)
|
100
|
+
}
|
101
|
+
}
|
102
|
+
} else if (exp === knownParameterizedRouteExpressions.reference_versioned_type_field) {
|
103
|
+
if (hasSchema) {
|
104
|
+
// Add paths for all versions with fields
|
105
|
+
for (const version of availableVersions) {
|
106
|
+
await addTypePathsForVersion(version, `/reference/version/${version}`, true)
|
107
|
+
}
|
44
108
|
}
|
45
109
|
} else if (ReactRouterAid.isParameterizedPath(exp)) {
|
46
110
|
throw new Error(`Unhandled parameterized path: ${exp}`)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
import PROJECT_DATA from 'virtual:polen/project/data.jsonsuper'
|
2
|
+
import PROJECT_SCHEMA_METADATA from 'virtual:polen/project/schema-metadata'
|
3
|
+
import { createSchemaSource } from '../../api/schema-source/index.js'
|
4
|
+
import { polenUrlPathAssets } from '../lib/polen-url.js'
|
5
|
+
|
6
|
+
// Environment-specific IO implementation
|
7
|
+
const io = import.meta.env.SSR
|
8
|
+
? {
|
9
|
+
// Server-side: Read from filesystem
|
10
|
+
read: async (path: string) => {
|
11
|
+
// Dynamic import to keep fs out of client bundle
|
12
|
+
const { readFile } = await import('node:fs/promises')
|
13
|
+
|
14
|
+
// Extract the path after the assets route
|
15
|
+
// e.g., "/assets/schemas/latest.json" -> "schemas/latest.json"
|
16
|
+
// e.g., "/demos/pokemon/assets/schemas/latest.json" -> "schemas/latest.json"
|
17
|
+
const assetsRoute = PROJECT_DATA.server.routes.assets
|
18
|
+
const routePattern = new RegExp(`${assetsRoute}/(.+)$`)
|
19
|
+
const match = path.match(routePattern)
|
20
|
+
const assetPath = match ? match[1] : path
|
21
|
+
|
22
|
+
// In SSR, we need to read from the correct location
|
23
|
+
// During dev, assets are served from Polen's node_modules
|
24
|
+
// In production, they're in the build output directory
|
25
|
+
let fullPath: string
|
26
|
+
if (import.meta.env.DEV) {
|
27
|
+
// Development: Read from Polen's Vite cache
|
28
|
+
fullPath = `${PROJECT_DATA.paths.framework.devAssets.absolute}/${assetPath}`
|
29
|
+
} else {
|
30
|
+
// Production: Read from build output
|
31
|
+
// The server runs from the project root, and assets are in build/assets/
|
32
|
+
fullPath =
|
33
|
+
`${PROJECT_DATA.paths.project.relative.build.root}/${PROJECT_DATA.paths.project.relative.build.relative.assets.root}/${assetPath}`
|
34
|
+
}
|
35
|
+
|
36
|
+
return readFile(fullPath, 'utf-8')
|
37
|
+
},
|
38
|
+
}
|
39
|
+
: {
|
40
|
+
// Client-side: Fetch from HTTP
|
41
|
+
read: async (path: string) => {
|
42
|
+
const response = await fetch(path)
|
43
|
+
if (!response.ok) {
|
44
|
+
throw new Error(`Failed to fetch: ${path} (${response.status} ${response.statusText})`)
|
45
|
+
}
|
46
|
+
return response.text()
|
47
|
+
},
|
48
|
+
}
|
49
|
+
|
50
|
+
// Create and export the source object directly
|
51
|
+
export const schemaSource = createSchemaSource({
|
52
|
+
io,
|
53
|
+
versions: PROJECT_SCHEMA_METADATA.versions,
|
54
|
+
assetsPath: polenUrlPathAssets(),
|
55
|
+
})
|
56
|
+
|
57
|
+
// HMR cache invalidation for development
|
58
|
+
if (import.meta.hot) {
|
59
|
+
import.meta.hot.on('polen:schema-invalidate', () => {
|
60
|
+
console.log('[HMR] Schema cache invalidated')
|
61
|
+
schemaSource.clearCache()
|
62
|
+
|
63
|
+
// Brute force approach: reload the page to ensure fresh data
|
64
|
+
// This guarantees all components see the updated schema immediately
|
65
|
+
// TODO: When we have reactive data fetching, remove this reload
|
66
|
+
// and let the reactive system handle updates gracefully
|
67
|
+
window.location.reload()
|
68
|
+
})
|
69
|
+
}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$$.d.ts","sourceRoot":"","sources":["../../../src/lib/graphql-document/$$.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,YAAY,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$$.js","sourceRoot":"","sources":["../../../src/lib/graphql-document/$$.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA;AACvC,cAAc,yBAAyB,CAAA;AACvC,cAAc,YAAY,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$.d.ts","sourceRoot":"","sources":["../../../src/lib/graphql-document/$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAA"}
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"$.js","sourceRoot":"","sources":["../../../src/lib/graphql-document/$.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,eAAe,MAAM,uBAAuB,CAAA"}
|
@@ -1,44 +0,0 @@
|
|
1
|
-
import { type DocumentNode, type GraphQLError, type GraphQLSchema } from 'graphql';
|
2
|
-
import type { AnalysisConfig, AnalysisResult, GraphQLAnalyzer, IdentifierMap } from './types.js';
|
3
|
-
/**
|
4
|
-
* Default GraphQL document analyzer implementation
|
5
|
-
*/
|
6
|
-
export declare class DefaultGraphQLAnalyzer implements GraphQLAnalyzer {
|
7
|
-
/**
|
8
|
-
* Parse a GraphQL document string into an AST
|
9
|
-
*/
|
10
|
-
parse(source: string): DocumentNode;
|
11
|
-
/**
|
12
|
-
* Validate a GraphQL document against a schema
|
13
|
-
*/
|
14
|
-
validateAgainstSchema(ast: DocumentNode, schema: GraphQLSchema): GraphQLError[];
|
15
|
-
/**
|
16
|
-
* Extract all identifiers from a GraphQL AST
|
17
|
-
*/
|
18
|
-
extractIdentifiers(ast: DocumentNode, config?: AnalysisConfig): IdentifierMap;
|
19
|
-
/**
|
20
|
-
* Perform complete analysis of a GraphQL document
|
21
|
-
*/
|
22
|
-
analyze(source: string, config?: AnalysisConfig): AnalysisResult;
|
23
|
-
private addIdentifier;
|
24
|
-
private getPosition;
|
25
|
-
private getTypePosition;
|
26
|
-
private extractTypeName;
|
27
|
-
private isObjectField;
|
28
|
-
private inferReturnType;
|
29
|
-
private createContext;
|
30
|
-
private createIdentifierMap;
|
31
|
-
}
|
32
|
-
/**
|
33
|
-
* Default analyzer instance
|
34
|
-
*/
|
35
|
-
export declare const analyzer: DefaultGraphQLAnalyzer;
|
36
|
-
/**
|
37
|
-
* Convenience function to analyze a GraphQL document
|
38
|
-
*/
|
39
|
-
export declare const analyze: (source: string, config?: AnalysisConfig) => AnalysisResult;
|
40
|
-
/**
|
41
|
-
* Convenience function to extract identifiers from a GraphQL document
|
42
|
-
*/
|
43
|
-
export declare const extractIdentifiers: (source: string, config?: AnalysisConfig) => IdentifierMap;
|
44
|
-
//# sourceMappingURL=analysis.d.ts.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../../src/lib/graphql-document/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,YAAY,EAGjB,KAAK,YAAY,EACjB,KAAK,aAAa,EAMnB,MAAM,SAAS,CAAA;AAChB,OAAO,KAAK,EACV,cAAc,EAEd,cAAc,EACd,eAAe,EAGf,aAAa,EACd,MAAM,YAAY,CAAA;AAEnB;;GAEG;AACH,qBAAa,sBAAuB,YAAW,eAAe;IAC5D;;OAEG;IACH,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAUnC;;OAEG;IACH,qBAAqB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,GAAG,YAAY,EAAE;IAI/E;;OAEG;IACH,kBAAkB,CAAC,GAAG,EAAE,YAAY,EAAE,MAAM,GAAE,cAAmB,GAAG,aAAa;IA4MjF;;OAEG;IACH,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,GAAE,cAAmB,GAAG,cAAc;IA+BpE,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,WAAW;IAcnB,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,eAAe;IAWvB,OAAO,CAAC,aAAa;IAyBrB,OAAO,CAAC,eAAe;IAQvB,OAAO,CAAC,aAAa;IAcrB,OAAO,CAAC,mBAAmB;CAsB5B;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,wBAA+B,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,OAAO,GAAI,QAAQ,MAAM,EAAE,SAAS,cAAc,KAAG,cAEjE,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,SAAS,cAAc,KAAG,aAG5E,CAAA"}
|