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,213 @@
|
|
1
|
+
import { Grafaid } from '#lib/grafaid/index'
|
2
|
+
import { GraphqlChange } from '#lib/graphql-change/index'
|
3
|
+
import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
4
|
+
import { GraphqlSchemaLoader } from '#lib/graphql-schema-loader/index'
|
5
|
+
import { Fs, Json, Path } from '@wollybeard/kit'
|
6
|
+
import type { NonEmptyChangeSets, SchemaReadResult } from '../../schema.js'
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Configuration for loading schema via GraphQL introspection.
|
10
|
+
*
|
11
|
+
* Polen supports two introspection features:
|
12
|
+
* 1. **File Convention**: Automatically detects `schema.introspection.json` if present
|
13
|
+
* 2. **Automatic Introspection**: Fetches from your endpoint and creates the file
|
14
|
+
*
|
15
|
+
* When configured, Polen will:
|
16
|
+
* - Execute the standard GraphQL introspection query against your endpoint
|
17
|
+
* - Save the result to `schema.introspection.json` in your project root
|
18
|
+
* - Use this cached file for subsequent builds (no network requests)
|
19
|
+
*
|
20
|
+
* The saved file contains a standard GraphQL introspection query result as defined
|
21
|
+
* in the GraphQL specification, making it compatible with any tool that works with
|
22
|
+
* introspection data (GraphQL Codegen, Apollo CLI, etc.).
|
23
|
+
*
|
24
|
+
* To refresh the schema, delete `schema.introspection.json` and rebuild.
|
25
|
+
*
|
26
|
+
* **Technical details**:
|
27
|
+
* - Uses Graffle's introspection extension
|
28
|
+
* - Performs the full introspection query (all types, fields, descriptions, etc.)
|
29
|
+
* - No customization of the query is currently supported
|
30
|
+
*
|
31
|
+
* @see https://spec.graphql.org/draft/#sec-Introspection - GraphQL Introspection spec
|
32
|
+
* @see https://github.com/graphql/graphql-js/blob/main/src/utilities/getIntrospectionQuery.ts - Reference implementation
|
33
|
+
*
|
34
|
+
* @example
|
35
|
+
* ```ts
|
36
|
+
* // Basic introspection
|
37
|
+
* introspection: {
|
38
|
+
* url: 'https://api.example.com/graphql'
|
39
|
+
* }
|
40
|
+
*
|
41
|
+
* // With authentication
|
42
|
+
* introspection: {
|
43
|
+
* url: 'https://api.example.com/graphql',
|
44
|
+
* headers: {
|
45
|
+
* 'Authorization': `Bearer ${process.env.API_TOKEN}`
|
46
|
+
* }
|
47
|
+
* }
|
48
|
+
* ```
|
49
|
+
*/
|
50
|
+
export interface ConfigInput {
|
51
|
+
/**
|
52
|
+
* The GraphQL endpoint URL to introspect.
|
53
|
+
*
|
54
|
+
* Must be a valid GraphQL endpoint that supports introspection queries.
|
55
|
+
*
|
56
|
+
* @example 'https://api.example.com/graphql'
|
57
|
+
*/
|
58
|
+
url?: string
|
59
|
+
/**
|
60
|
+
* Optional headers to include in the introspection request.
|
61
|
+
*
|
62
|
+
* Use this for authentication, API keys, or any custom headers
|
63
|
+
* required by your GraphQL endpoint.
|
64
|
+
*
|
65
|
+
* @example
|
66
|
+
* ```ts
|
67
|
+
* headers: {
|
68
|
+
* 'Authorization': `Bearer ${process.env.API_TOKEN}`,
|
69
|
+
* 'X-API-Key': process.env.API_KEY
|
70
|
+
* }
|
71
|
+
* ```
|
72
|
+
*/
|
73
|
+
headers?: Record<string, string>
|
74
|
+
projectRoot?: string
|
75
|
+
}
|
76
|
+
|
77
|
+
export interface Config {
|
78
|
+
url: string
|
79
|
+
headers?: Record<string, string>
|
80
|
+
projectRoot: string
|
81
|
+
}
|
82
|
+
|
83
|
+
export const normalizeConfig = (configInput: ConfigInput): Config => {
|
84
|
+
if (!configInput.url) {
|
85
|
+
throw new Error(`Introspection data source requires a URL`)
|
86
|
+
}
|
87
|
+
|
88
|
+
if (!configInput.projectRoot) {
|
89
|
+
throw new Error(`Introspection data source requires a projectRoot`)
|
90
|
+
}
|
91
|
+
|
92
|
+
const config: Config = {
|
93
|
+
url: configInput.url,
|
94
|
+
headers: configInput.headers,
|
95
|
+
projectRoot: configInput.projectRoot,
|
96
|
+
}
|
97
|
+
|
98
|
+
return config
|
99
|
+
}
|
100
|
+
|
101
|
+
const INTROSPECTION_FILE_NAME = `schema.introspection.json`
|
102
|
+
|
103
|
+
const getIntrospectionFilePath = (projectRoot: string) => {
|
104
|
+
return Path.join(projectRoot, INTROSPECTION_FILE_NAME)
|
105
|
+
}
|
106
|
+
|
107
|
+
export const readOrThrow = async (
|
108
|
+
configInput: ConfigInput,
|
109
|
+
): Promise<SchemaReadResult> => {
|
110
|
+
const config = normalizeConfig(configInput)
|
111
|
+
const introspectionFilePath = getIntrospectionFilePath(config.projectRoot)
|
112
|
+
|
113
|
+
// Check if introspection file exists
|
114
|
+
const introspectionFileContent = await Fs.read(introspectionFilePath)
|
115
|
+
let schema: Grafaid.Schema.Schema
|
116
|
+
|
117
|
+
if (introspectionFileContent) {
|
118
|
+
// Load from existing file - no reCreate capability
|
119
|
+
try {
|
120
|
+
const introspectionData = Json.codec.decode(introspectionFileContent)
|
121
|
+
|
122
|
+
// Validate introspection data structure before passing to fromIntrospectionQuery
|
123
|
+
if (!introspectionData || typeof introspectionData !== 'object') {
|
124
|
+
throw new Error('Introspection data must be a valid JSON object')
|
125
|
+
}
|
126
|
+
|
127
|
+
// Allow fromIntrospectionQuery to handle validation of the introspection format
|
128
|
+
// It will provide more specific GraphQL-related error messages
|
129
|
+
if (!('data' in introspectionData)) {
|
130
|
+
throw new Error(
|
131
|
+
'Introspection data missing required "data" property (expected GraphQL introspection result format)',
|
132
|
+
)
|
133
|
+
}
|
134
|
+
|
135
|
+
schema = Grafaid.Schema.fromIntrospectionQuery(introspectionData as any)
|
136
|
+
} catch (error) {
|
137
|
+
if (error instanceof SyntaxError) {
|
138
|
+
throw new Error(`Invalid JSON in ${introspectionFilePath}: ${error.message}`)
|
139
|
+
} else {
|
140
|
+
throw new Error(
|
141
|
+
`Invalid introspection data in ${introspectionFilePath}: ${
|
142
|
+
error instanceof Error ? error.message : String(error)
|
143
|
+
}. Delete this file to fetch fresh introspection data.`,
|
144
|
+
)
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
const schemaData = await createSingleSchemaChangeset(schema)
|
149
|
+
return {
|
150
|
+
data: schemaData,
|
151
|
+
source: { type: 'introspectionFile' },
|
152
|
+
}
|
153
|
+
} else {
|
154
|
+
// Fetch via introspection - can reCreate
|
155
|
+
const introspectionResult = await GraphqlSchemaLoader.load({
|
156
|
+
type: `introspect`,
|
157
|
+
url: config.url,
|
158
|
+
headers: config.headers,
|
159
|
+
})
|
160
|
+
|
161
|
+
schema = introspectionResult
|
162
|
+
|
163
|
+
// Get the raw introspection result for saving
|
164
|
+
const __schema = Grafaid.Schema.toIntrospectionQuery(schema)
|
165
|
+
|
166
|
+
// Wrap in GraphQL response format for consistency with API responses
|
167
|
+
const introspectionData = { data: { __schema } }
|
168
|
+
|
169
|
+
// Write to file
|
170
|
+
await Fs.write({
|
171
|
+
path: introspectionFilePath,
|
172
|
+
content: Json.codec.encode(introspectionData as any),
|
173
|
+
})
|
174
|
+
|
175
|
+
const schemaData = await createSingleSchemaChangeset(schema)
|
176
|
+
return {
|
177
|
+
data: schemaData,
|
178
|
+
source: {
|
179
|
+
type: 'introspectionAuto',
|
180
|
+
reCreate: async () => {
|
181
|
+
// Re-fetch using captured config - capture closure
|
182
|
+
const result = await readOrThrow(configInput)
|
183
|
+
return result.data
|
184
|
+
},
|
185
|
+
},
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
|
190
|
+
/**
|
191
|
+
* Create a single changeset from a schema object.
|
192
|
+
* This is the core logic for handling single (unversioned) schemas from introspection.
|
193
|
+
*/
|
194
|
+
export const createSingleSchemaChangeset = async (schema: Grafaid.Schema.Schema): Promise<NonEmptyChangeSets> => {
|
195
|
+
const date = new Date() // Generate date here for unversioned schema
|
196
|
+
const after = schema
|
197
|
+
const before = Grafaid.Schema.empty
|
198
|
+
const changes = await GraphqlChange.calcChangeset({
|
199
|
+
before,
|
200
|
+
after,
|
201
|
+
})
|
202
|
+
|
203
|
+
const changeset: GraphqlChangeset.ChangeSet = {
|
204
|
+
date,
|
205
|
+
after,
|
206
|
+
before,
|
207
|
+
changes,
|
208
|
+
}
|
209
|
+
|
210
|
+
const result: NonEmptyChangeSets = [changeset]
|
211
|
+
|
212
|
+
return result
|
213
|
+
}
|
@@ -2,7 +2,7 @@ import { Grafaid } from '#lib/grafaid/index'
|
|
2
2
|
import { GraphqlChange } from '#lib/graphql-change/index'
|
3
3
|
import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
4
4
|
import { Arr } from '@wollybeard/kit'
|
5
|
-
import type {
|
5
|
+
import type { NonEmptyChangeSets } from '../../schema.js'
|
6
6
|
|
7
7
|
/**
|
8
8
|
* Configuration for defining schemas programmatically in memory.
|
@@ -68,7 +68,7 @@ export const normalize = (configInput: ConfigInput): Config => {
|
|
68
68
|
|
69
69
|
export const read = async (
|
70
70
|
configInput: ConfigInput,
|
71
|
-
): Promise<null |
|
71
|
+
): Promise<null | NonEmptyChangeSets> => {
|
72
72
|
const config = normalize(configInput)
|
73
73
|
|
74
74
|
if (!Arr.isntEmpty(config.versions)) {
|
@@ -109,9 +109,7 @@ export const read = async (
|
|
109
109
|
|
110
110
|
changesets.reverse()
|
111
111
|
|
112
|
-
const schema:
|
113
|
-
versions: changesets,
|
114
|
-
}
|
112
|
+
const schema: NonEmptyChangeSets = changesets
|
115
113
|
|
116
114
|
return schema
|
117
115
|
}
|
package/src/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Path } from '@wollybeard/kit'
|
2
2
|
|
3
|
-
export type Expression =
|
3
|
+
export type Expression = ExpressionVersioned | ExpressionSingle
|
4
4
|
|
5
5
|
export const parseOrThrow = (fileNameOrSerializedExpression: string): Expression => {
|
6
6
|
const result = parse(fileNameOrSerializedExpression)
|
@@ -18,41 +18,57 @@ export const parse = (fileName: string): null | Expression => {
|
|
18
18
|
}
|
19
19
|
const serializedExpression = path.name
|
20
20
|
|
21
|
-
const
|
22
|
-
if (
|
21
|
+
const versioned = parseExpressionVersionedSerialized(serializedExpression)
|
22
|
+
if (versioned) return { ...versioned, filePath: fileName, type: `FileNameExpressionVersioned` }
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
const single = parseExpressionSingleSerialized(serializedExpression)
|
25
|
+
if (single) return { ...single, filePath: fileName, type: `FileNameExpressionSingle` }
|
26
26
|
|
27
27
|
return null
|
28
28
|
}
|
29
29
|
|
30
30
|
// ----
|
31
31
|
|
32
|
-
export interface
|
33
|
-
type: `
|
32
|
+
export interface ExpressionVersioned {
|
33
|
+
type: `FileNameExpressionVersioned`
|
34
34
|
date: Date
|
35
35
|
filePath: string
|
36
36
|
}
|
37
37
|
|
38
|
-
const
|
38
|
+
const parseExpressionVersionedSerialized = (
|
39
39
|
serializedExpression: string,
|
40
|
-
): Pick<
|
41
|
-
const match =
|
40
|
+
): Pick<ExpressionVersioned, `date`> | null => {
|
41
|
+
const match = expressionVersionedSerializedPattern.exec(serializedExpression)
|
42
42
|
if (!match) return null
|
43
43
|
const { year, month, day } = match.groups as { year: string; month: string; day: string }
|
44
44
|
const date = new Date(parseInt(year), parseInt(month) - 1, parseInt(day))
|
45
45
|
return { date }
|
46
46
|
}
|
47
47
|
|
48
|
-
const
|
48
|
+
const expressionVersionedSerializedPattern = /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/
|
49
49
|
|
50
|
-
// export const
|
51
|
-
// return expression.type === `
|
50
|
+
// export const isExpressionVersioned = (expression: Expression): expression is ExpressionVersioned => {
|
51
|
+
// return expression.type === `FileNameExpressionVersioned`
|
52
52
|
// }
|
53
53
|
|
54
54
|
// ----
|
55
55
|
|
56
|
+
export interface ExpressionSingle {
|
57
|
+
type: `FileNameExpressionSingle`
|
58
|
+
filePath: string
|
59
|
+
}
|
60
|
+
|
61
|
+
const parseExpressionSingleSerialized = (
|
62
|
+
serializedExpression: string,
|
63
|
+
): {} | null => {
|
64
|
+
if (serializedExpression === `schema`) {
|
65
|
+
return {}
|
66
|
+
}
|
67
|
+
return null
|
68
|
+
}
|
69
|
+
|
70
|
+
// ----
|
71
|
+
|
56
72
|
// export interface ExpressionLatest {
|
57
73
|
// type: `FileNameExpressionLatest`
|
58
74
|
// filePath: string
|
@@ -4,7 +4,8 @@ import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
|
4
4
|
import { debugPolen } from '#singletons/debug'
|
5
5
|
import { Arr, Path } from '@wollybeard/kit'
|
6
6
|
import { glob } from 'tinyglobby'
|
7
|
-
import type {
|
7
|
+
import type { NonEmptyChangeSets } from '../../schema.js'
|
8
|
+
import { readSingleSchemaFile } from '../schema-file/schema-file.js'
|
8
9
|
import { FileNameExpression } from './file-name-expression/index.js'
|
9
10
|
|
10
11
|
// const debug = debugPolen.sub([`schema`, `data-source-schema-directory`])
|
@@ -15,15 +16,19 @@ const defaultPaths = {
|
|
15
16
|
}
|
16
17
|
|
17
18
|
/**
|
18
|
-
* Configuration for loading
|
19
|
+
* Configuration for loading schema(s) from a directory.
|
19
20
|
*
|
20
|
-
*
|
21
|
+
* Supports two modes:
|
22
|
+
* 1. Multiple versioned schemas with date prefixes (enables changelog feature)
|
23
|
+
* 2. Single schema file named 'schema.graphql' (non-versioned, like file data source)
|
21
24
|
*/
|
22
25
|
export interface ConfigInput {
|
23
26
|
/**
|
24
|
-
* Path to the directory containing
|
27
|
+
* Path to the directory containing schema files.
|
25
28
|
*
|
26
|
-
*
|
29
|
+
* Supports two patterns:
|
30
|
+
* 1. Multiple versioned files with ISO date prefixes: `YYYY-MM-DD.graphql`
|
31
|
+
* 2. Single file named: `schema.graphql`
|
27
32
|
*
|
28
33
|
* @default './schema'
|
29
34
|
*
|
@@ -36,12 +41,17 @@ export interface ConfigInput {
|
|
36
41
|
* path: './graphql/versions'
|
37
42
|
* ```
|
38
43
|
*
|
39
|
-
* Directory structure
|
44
|
+
* Directory structure examples:
|
40
45
|
* ```
|
46
|
+
* // Versioned schemas (enables changelog)
|
41
47
|
* schema/
|
42
48
|
* 2024-01-15.graphql
|
43
49
|
* 2024-03-20.graphql
|
44
50
|
* 2024-06-10.graphql
|
51
|
+
*
|
52
|
+
* // Single schema (non-versioned)
|
53
|
+
* schema/
|
54
|
+
* schema.graphql
|
45
55
|
* ```
|
46
56
|
*/
|
47
57
|
path?: string
|
@@ -61,7 +71,7 @@ export const normalizeConfig = (configInput: ConfigInput): Config => {
|
|
61
71
|
return config
|
62
72
|
}
|
63
73
|
|
64
|
-
export const readOrThrow = async (configInput: ConfigInput): Promise<null |
|
74
|
+
export const readOrThrow = async (configInput: ConfigInput): Promise<null | NonEmptyChangeSets> => {
|
65
75
|
const config = normalizeConfig(configInput)
|
66
76
|
|
67
77
|
debug(`will search`, config)
|
@@ -80,7 +90,42 @@ export const readOrThrow = async (configInput: ConfigInput): Promise<null | Sche
|
|
80
90
|
const fileNameExpressions = Arr.map(filePaths, FileNameExpression.parseOrThrow)
|
81
91
|
debug(`parsed file names`, fileNameExpressions)
|
82
92
|
|
83
|
-
|
93
|
+
// Separate versioned (dated) and single schema files
|
94
|
+
const versionedExpressions = fileNameExpressions.filter(
|
95
|
+
(expr): expr is FileNameExpression.ExpressionVersioned => expr.type === `FileNameExpressionVersioned`,
|
96
|
+
)
|
97
|
+
const singleExpressions = fileNameExpressions.filter(
|
98
|
+
(expr): expr is FileNameExpression.ExpressionSingle => expr.type === `FileNameExpressionSingle`,
|
99
|
+
)
|
100
|
+
|
101
|
+
// If we have versioned files, use them (versioned takes precedence)
|
102
|
+
if (Arr.isntEmpty(versionedExpressions)) {
|
103
|
+
return await readVersionedSchemas(versionedExpressions)
|
104
|
+
}
|
105
|
+
|
106
|
+
// If we have a single schema file, use it
|
107
|
+
if (Arr.isntEmpty(singleExpressions)) {
|
108
|
+
if (singleExpressions.length > 1) {
|
109
|
+
throw new Error(
|
110
|
+
`Multiple single schema files found, expected exactly one: ${
|
111
|
+
singleExpressions.map(e => e.filePath).join(', ')
|
112
|
+
}`,
|
113
|
+
)
|
114
|
+
}
|
115
|
+
return await readSingleSchemaFile(singleExpressions[0].filePath)
|
116
|
+
}
|
117
|
+
|
118
|
+
// Should not happen since we already checked for empty filePaths
|
119
|
+
throw new Error(`No schema files found despite non-empty file paths`)
|
120
|
+
}
|
121
|
+
|
122
|
+
/**
|
123
|
+
* Read multiple versioned schema files and create changesets
|
124
|
+
*/
|
125
|
+
const readVersionedSchemas = async (
|
126
|
+
versionedExpressions: FileNameExpression.ExpressionVersioned[],
|
127
|
+
): Promise<NonEmptyChangeSets> => {
|
128
|
+
const versions = await Promise.all(Arr.map(versionedExpressions, async fileNameExpression => {
|
84
129
|
const schemaFile = await Grafaid.Schema.read(fileNameExpression.filePath)
|
85
130
|
// Should never happen since these paths come from the glob.
|
86
131
|
if (!schemaFile) throw new Error(`Failed to read schema file: ${fileNameExpression.filePath}`)
|
@@ -90,7 +135,7 @@ export const readOrThrow = async (configInput: ConfigInput): Promise<null | Sche
|
|
90
135
|
schema: schemaFile.content,
|
91
136
|
}
|
92
137
|
}))
|
93
|
-
debug(`read schemas`)
|
138
|
+
debug(`read versioned schemas`)
|
94
139
|
|
95
140
|
versions.sort((a, b) => a.date.getTime() - b.date.getTime())
|
96
141
|
|
@@ -118,11 +163,6 @@ export const readOrThrow = async (configInput: ConfigInput): Promise<null | Sche
|
|
118
163
|
|
119
164
|
changesets.reverse()
|
120
165
|
|
121
|
-
|
122
|
-
|
123
|
-
}
|
124
|
-
|
125
|
-
debug(`computed schema`)
|
126
|
-
|
127
|
-
return schema
|
166
|
+
debug(`computed versioned schema`)
|
167
|
+
return changesets as NonEmptyChangeSets
|
128
168
|
}
|
@@ -2,7 +2,7 @@ import { Grafaid } from '#lib/grafaid/index'
|
|
2
2
|
import { GraphqlChange } from '#lib/graphql-change/index'
|
3
3
|
import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
4
4
|
import { Path } from '@wollybeard/kit'
|
5
|
-
import type {
|
5
|
+
import type { NonEmptyChangeSets } from '../../schema.js'
|
6
6
|
|
7
7
|
const defaultPaths = {
|
8
8
|
schemaFile: `./schema.graphql`,
|
@@ -46,13 +46,24 @@ export const normalizeConfig = (configInput: ConfigInput): Config => {
|
|
46
46
|
|
47
47
|
export const readOrThrow = async (
|
48
48
|
configInput: ConfigInput,
|
49
|
-
): Promise<null |
|
49
|
+
): Promise<null | NonEmptyChangeSets> => {
|
50
50
|
const config = normalizeConfig(configInput)
|
51
51
|
|
52
52
|
const schemaFile = await Grafaid.Schema.read(config.path)
|
53
53
|
if (!schemaFile) return null
|
54
54
|
|
55
|
-
|
55
|
+
return await readSingleSchemaFile(config.path)
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
* Create a single changeset from a schema file path.
|
60
|
+
* This is the core logic for handling single (unversioned) schemas.
|
61
|
+
*/
|
62
|
+
export const readSingleSchemaFile = async (filePath: string): Promise<NonEmptyChangeSets> => {
|
63
|
+
const schemaFile = await Grafaid.Schema.read(filePath)
|
64
|
+
if (!schemaFile) throw new Error(`Failed to read schema file: ${filePath}`)
|
65
|
+
|
66
|
+
const date = new Date() // Generate date here for unversioned schema
|
56
67
|
const after = schemaFile.content
|
57
68
|
const before = Grafaid.Schema.empty
|
58
69
|
const changes = await GraphqlChange.calcChangeset({
|
@@ -60,16 +71,14 @@ export const readOrThrow = async (
|
|
60
71
|
after,
|
61
72
|
})
|
62
73
|
|
63
|
-
const
|
74
|
+
const changeset: GraphqlChangeset.ChangeSet = {
|
64
75
|
date,
|
65
76
|
after,
|
66
77
|
before,
|
67
78
|
changes,
|
68
79
|
}
|
69
80
|
|
70
|
-
const schema:
|
71
|
-
versions: [schemaVersion],
|
72
|
-
}
|
81
|
+
const schema: NonEmptyChangeSets = [changeset]
|
73
82
|
|
74
83
|
return schema
|
75
84
|
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { Fs } from '@wollybeard/kit'
|
2
|
+
import { z } from 'zod'
|
3
|
+
|
4
|
+
export const SchemaMetadataSchema = z.object({
|
5
|
+
/** Whether a schema is present in the project */
|
6
|
+
hasSchema: z.boolean(),
|
7
|
+
/** Array of available version identifiers */
|
8
|
+
versions: z.array(z.string()),
|
9
|
+
})
|
10
|
+
|
11
|
+
export type SchemaMetadata = z.infer<typeof SchemaMetadataSchema>
|
12
|
+
|
13
|
+
export const getMetadata = async (path: string): Promise<SchemaMetadata> => {
|
14
|
+
const result = await Fs.readJson(path)
|
15
|
+
if (!result) {
|
16
|
+
return {
|
17
|
+
hasSchema: false,
|
18
|
+
versions: [],
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
return SchemaMetadataSchema.parse(result)
|
23
|
+
}
|