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
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "polen",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.11.0-next.2",
|
4
4
|
"type": "module",
|
5
5
|
"description": "A framework for delightful GraphQL developer portals",
|
6
6
|
"author": {
|
@@ -87,18 +87,18 @@
|
|
87
87
|
"@graphql-inspector/core": "^6.2.1",
|
88
88
|
"@graphql-tools/load": "^8.1.0",
|
89
89
|
"@hiogawa/vite-plugin-ssr-css": "^0.0.1",
|
90
|
-
"@hono/node-server": "^1.
|
90
|
+
"@hono/node-server": "^1.16.0",
|
91
91
|
"@mdx-js/mdx": "^3.1.0",
|
92
92
|
"@mdx-js/react": "^3.1.0",
|
93
93
|
"@mdx-js/rollup": "^3.1.0",
|
94
94
|
"@radix-ui/react-icons": "^1.3.2",
|
95
95
|
"@radix-ui/themes": "^3.2.1",
|
96
|
-
"@rolldown/pluginutils": "1.0.0-beta.
|
96
|
+
"@rolldown/pluginutils": "1.0.0-beta.27",
|
97
97
|
"@rollup/pluginutils": "^5.2.0",
|
98
98
|
"@types/jsesc": "^3.0.3",
|
99
99
|
"@vitejs/plugin-react": "^4.6.0",
|
100
100
|
"@vitejs/plugin-react-oxc": "^0.2.3",
|
101
|
-
"@vltpkg/semver": "0.0.0-
|
101
|
+
"@vltpkg/semver": "0.0.0-17",
|
102
102
|
"@vue/reactivity": "^3.5.17",
|
103
103
|
"@wollybeard/kit": "^0.41.0",
|
104
104
|
"@wollybeard/projector": "^0.3.0",
|
@@ -107,12 +107,12 @@
|
|
107
107
|
"codehike": "^1.0.7",
|
108
108
|
"consola": "^3.4.2",
|
109
109
|
"defu": "^6.1.4",
|
110
|
-
"es-toolkit": "^1.39.
|
110
|
+
"es-toolkit": "^1.39.7",
|
111
111
|
"fuse.js": "^7.1.0",
|
112
112
|
"graffle": "8.0.0-next.163",
|
113
113
|
"graphql": "^16.11.0",
|
114
114
|
"gray-matter": "^4.0.3",
|
115
|
-
"hono": "^4.8.
|
115
|
+
"hono": "^4.8.5",
|
116
116
|
"jsesc": "^3.1.0",
|
117
117
|
"jsonc-parser": "^3.3.1",
|
118
118
|
"react": "^19.1.0",
|
@@ -126,22 +126,21 @@
|
|
126
126
|
"remark-parse": "^11.0.0",
|
127
127
|
"remark-rehype": "^11.1.2",
|
128
128
|
"resolve.imports": "^2.0.3",
|
129
|
-
"rolldown": "1.0.0-beta.
|
129
|
+
"rolldown": "1.0.0-beta.27",
|
130
130
|
"simple-git": "^3.28.0",
|
131
131
|
"source-map": "^0.7.4",
|
132
132
|
"superjson": "^2.2.2",
|
133
133
|
"tinyglobby": "^0.2.14",
|
134
|
-
"tree-sitter-graphql-grammar-wasm": "^1.
|
134
|
+
"tree-sitter-graphql-grammar-wasm": "^1.1.0",
|
135
135
|
"tsx": "^4.20.3",
|
136
136
|
"typescript": "^5.8.3",
|
137
137
|
"unified": "^11.0.5",
|
138
138
|
"vfile": "^6.0.3",
|
139
|
-
"vite": "npm:rolldown-vite@^7.0.
|
139
|
+
"vite": "npm:rolldown-vite@^7.0.9",
|
140
140
|
"vite-plugin-inspect": "^11.3.0",
|
141
|
-
"
|
142
|
-
"web-tree-sitter": "^0.25.6",
|
141
|
+
"web-tree-sitter": "^0.25.8",
|
143
142
|
"youch-core": "^0.3.3",
|
144
|
-
"zx": "8.
|
143
|
+
"zx": "8.7.1"
|
145
144
|
},
|
146
145
|
"devDependencies": {
|
147
146
|
"@actions/core": "^1.11.1",
|
@@ -151,15 +150,15 @@
|
|
151
150
|
"@actions/io": "^1.1.3",
|
152
151
|
"@changesets/cli": "^2.29.5",
|
153
152
|
"@molt/command": "^0.9.0",
|
154
|
-
"@octokit/core": "^7.0.
|
153
|
+
"@octokit/core": "^7.0.3",
|
155
154
|
"@octokit/types": "^14.1.0",
|
156
|
-
"@playwright/browser-chromium": "^1.
|
155
|
+
"@playwright/browser-chromium": "^1.54.1",
|
157
156
|
"@testing-library/react": "^16.3.0",
|
158
157
|
"@tsconfig/node-lts": "^22.0.2",
|
159
158
|
"@tsconfig/node22": "^22.0.2",
|
160
159
|
"@tsconfig/strictest": "^2.0.5",
|
161
160
|
"@types/jsdom": "^21.1.7",
|
162
|
-
"@types/node": "^24.0.
|
161
|
+
"@types/node": "^24.0.14",
|
163
162
|
"@types/react": "^19.1.8",
|
164
163
|
"@types/react-dom": "^19.1.6",
|
165
164
|
"@types/semver": "^7.7.0",
|
@@ -167,10 +166,10 @@
|
|
167
166
|
"dripip": "^0.10.0",
|
168
167
|
"fast-check": "^4.2.0",
|
169
168
|
"fs-jetpack": "^5.1.0",
|
170
|
-
"get-port-please": "^3.
|
169
|
+
"get-port-please": "^3.2.0",
|
171
170
|
"globals": "^16.3.0",
|
172
171
|
"jsdom": "^26.1.0",
|
173
|
-
"playwright": "1.
|
172
|
+
"playwright": "1.54.1",
|
174
173
|
"publint": "^0.3.12",
|
175
174
|
"semver": "^7.7.2",
|
176
175
|
"strip-ansi": "^7.1.0",
|
package/src/api/api.ts
CHANGED
@@ -240,22 +240,6 @@ export interface ConfigInput {
|
|
240
240
|
* @default false
|
241
241
|
*/
|
242
242
|
isSelfContainedMode?: boolean
|
243
|
-
/**
|
244
|
-
* Tweak the watch behavior.
|
245
|
-
*/
|
246
|
-
watch?: {
|
247
|
-
/**
|
248
|
-
* Restart the development server when some arbitrary files change.
|
249
|
-
*
|
250
|
-
* Use this to restart when files that are not already watched by vite change.
|
251
|
-
*
|
252
|
-
* @see https://github.com/antfu/vite-plugin-restart
|
253
|
-
*/
|
254
|
-
/**
|
255
|
-
* File paths to watch and restart the development server when they change.
|
256
|
-
*/
|
257
|
-
also?: string[]
|
258
|
-
}
|
259
243
|
/**
|
260
244
|
* Whether to enable debug mode.
|
261
245
|
*
|
@@ -289,6 +273,13 @@ const buildPaths = (rootDir: string): Config[`paths`] => {
|
|
289
273
|
|
290
274
|
const publicAbsolutePath = rootAbsolute(`public`)
|
291
275
|
const publicAbsolute = Path.ensureAbsoluteWith(publicAbsolutePath)
|
276
|
+
|
277
|
+
const assetsAbsolute = Path.ensureAbsoluteWith(buildAbsolute(`assets`))
|
278
|
+
|
279
|
+
// Dev assets paths
|
280
|
+
const devAssetsRelative = 'node_modules/.vite/polen-assets'
|
281
|
+
const devAssetsAbsolute = Path.join(packagePaths.rootDir, devAssetsRelative)
|
282
|
+
|
292
283
|
return {
|
293
284
|
project: {
|
294
285
|
rootDir,
|
@@ -297,7 +288,12 @@ const buildPaths = (rootDir: string): Config[`paths`] => {
|
|
297
288
|
root: `build`,
|
298
289
|
relative: {
|
299
290
|
serverEntrypoint: `app.js`,
|
300
|
-
assets:
|
291
|
+
assets: {
|
292
|
+
root: `assets`,
|
293
|
+
relative: {
|
294
|
+
schemas: `schemas`,
|
295
|
+
},
|
296
|
+
},
|
301
297
|
},
|
302
298
|
},
|
303
299
|
pages: `pages`,
|
@@ -311,7 +307,10 @@ const buildPaths = (rootDir: string): Config[`paths`] => {
|
|
311
307
|
build: {
|
312
308
|
root: buildAbsolute(`.`),
|
313
309
|
serverEntrypoint: buildAbsolute(`app.js`),
|
314
|
-
assets:
|
310
|
+
assets: {
|
311
|
+
root: buildAbsolute(`assets`),
|
312
|
+
schemas: assetsAbsolute(`schemas`),
|
313
|
+
},
|
315
314
|
},
|
316
315
|
public: {
|
317
316
|
root: publicAbsolute(`.`),
|
@@ -319,7 +318,14 @@ const buildPaths = (rootDir: string): Config[`paths`] => {
|
|
319
318
|
},
|
320
319
|
},
|
321
320
|
},
|
322
|
-
framework:
|
321
|
+
framework: {
|
322
|
+
...packagePaths,
|
323
|
+
devAssets: {
|
324
|
+
relative: devAssetsRelative,
|
325
|
+
absolute: devAssetsAbsolute,
|
326
|
+
schemas: Path.join(devAssetsAbsolute, 'schemas'),
|
327
|
+
},
|
328
|
+
},
|
323
329
|
}
|
324
330
|
}
|
325
331
|
|
@@ -331,9 +337,9 @@ export interface Config {
|
|
331
337
|
}
|
332
338
|
server: {
|
333
339
|
port: number
|
334
|
-
|
335
|
-
|
336
|
-
|
340
|
+
routes: {
|
341
|
+
assets: string
|
342
|
+
}
|
337
343
|
}
|
338
344
|
templateVariables: TemplateVariables
|
339
345
|
schemaAugmentations: SchemaAugmentation.Augmentation[]
|
@@ -353,7 +359,12 @@ export interface Config {
|
|
353
359
|
build: {
|
354
360
|
root: string
|
355
361
|
relative: {
|
356
|
-
assets:
|
362
|
+
assets: {
|
363
|
+
root: string
|
364
|
+
relative: {
|
365
|
+
schemas: string
|
366
|
+
}
|
367
|
+
}
|
357
368
|
serverEntrypoint: string
|
358
369
|
}
|
359
370
|
}
|
@@ -366,7 +377,10 @@ export interface Config {
|
|
366
377
|
absolute: {
|
367
378
|
build: {
|
368
379
|
root: string
|
369
|
-
assets:
|
380
|
+
assets: {
|
381
|
+
root: string
|
382
|
+
schemas: string
|
383
|
+
}
|
370
384
|
serverEntrypoint: string
|
371
385
|
}
|
372
386
|
pages: string
|
@@ -376,7 +390,13 @@ export interface Config {
|
|
376
390
|
}
|
377
391
|
}
|
378
392
|
}
|
379
|
-
framework: PackagePaths
|
393
|
+
framework: PackagePaths & {
|
394
|
+
devAssets: {
|
395
|
+
relative: string
|
396
|
+
absolute: string
|
397
|
+
schemas: string
|
398
|
+
}
|
399
|
+
}
|
380
400
|
}
|
381
401
|
advanced: {
|
382
402
|
isSelfContainedMode: boolean
|
@@ -392,15 +412,15 @@ const configInputDefaults: Config = {
|
|
392
412
|
title: `My Developer Portal`,
|
393
413
|
},
|
394
414
|
schemaAugmentations: [],
|
395
|
-
watch: {
|
396
|
-
also: [],
|
397
|
-
},
|
398
415
|
build: {
|
399
416
|
architecture: BuildArchitecture.enum.ssg,
|
400
417
|
base: `/`,
|
401
418
|
},
|
402
419
|
server: {
|
403
420
|
port: 3000,
|
421
|
+
routes: {
|
422
|
+
assets: '/assets',
|
423
|
+
},
|
404
424
|
},
|
405
425
|
schema: null,
|
406
426
|
ssr: {
|
@@ -499,14 +519,13 @@ export const normalizeInput = async (
|
|
499
519
|
config.advanced.explorer = configInput.advanced.explorer
|
500
520
|
}
|
501
521
|
|
502
|
-
if (configInput?.advanced?.watch?.also) {
|
503
|
-
config.watch.also = configInput.advanced.watch.also
|
504
|
-
}
|
505
|
-
|
506
522
|
if (configInput?.server?.port !== undefined) {
|
507
523
|
config.server.port = configInput.server.port
|
508
524
|
}
|
509
525
|
|
526
|
+
// Server routes are not configurable by users yet, use defaults
|
527
|
+
// config.server.routes is already set from defaultConfig
|
528
|
+
|
510
529
|
// Process warnings configuration
|
511
530
|
if (configInput?.warnings?.interactiveWithoutSchema?.enabled !== undefined) {
|
512
531
|
config.warnings.interactiveWithoutSchema.enabled = configInput.warnings.interactiveWithoutSchema.enabled
|
package/src/api/config/merge.ts
CHANGED
@@ -48,22 +48,6 @@ export const mergeInputs = (
|
|
48
48
|
if (base.advanced ?? overrides.advanced) {
|
49
49
|
merged.advanced = spreadShallow(base.advanced, overrides.advanced)
|
50
50
|
|
51
|
-
// Merge advanced.watch config
|
52
|
-
if (base.advanced?.watch ?? overrides.advanced?.watch) {
|
53
|
-
merged.advanced.watch = spreadShallow(
|
54
|
-
base.advanced?.watch,
|
55
|
-
overrides.advanced?.watch,
|
56
|
-
)
|
57
|
-
|
58
|
-
// Merge watch.also arrays
|
59
|
-
if (base.advanced?.watch?.also ?? overrides.advanced?.watch?.also) {
|
60
|
-
merged.advanced.watch.also = [
|
61
|
-
...(base.advanced?.watch?.also ?? []),
|
62
|
-
...(overrides.advanced?.watch?.also ?? []),
|
63
|
-
]
|
64
|
-
}
|
65
|
-
}
|
66
|
-
|
67
51
|
// Merge Vite configs if present
|
68
52
|
if (base.advanced?.vite ?? overrides.advanced?.vite) {
|
69
53
|
merged.advanced.vite = Vite.mergeConfig(
|
@@ -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
|
+
}
|
package/src/api/schema/read.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Arr } from '@wollybeard/kit'
|
2
2
|
import * as DataSources from './data-sources/data-sources.js'
|
3
|
-
import type {
|
3
|
+
import type { NonEmptyChangeSets } from './schema.js'
|
4
4
|
|
5
5
|
export type DataSourceType = `file` | `directory` | `memory` | `data`
|
6
6
|
|
@@ -55,14 +55,14 @@ export interface Config {
|
|
55
55
|
/**
|
56
56
|
* Pre-built schema object to use directly.
|
57
57
|
*/
|
58
|
-
data?:
|
58
|
+
data?: NonEmptyChangeSets
|
59
59
|
}
|
60
60
|
projectRoot: string
|
61
61
|
}
|
62
62
|
|
63
63
|
export const readOrThrow = async (
|
64
64
|
config: Config,
|
65
|
-
): Promise<null |
|
65
|
+
): Promise<null | NonEmptyChangeSets> => {
|
66
66
|
if (config.enabled === false) {
|
67
67
|
return null
|
68
68
|
}
|