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
@@ -0,0 +1,317 @@
|
|
1
|
+
import type { Config } from '#api/config/index'
|
2
|
+
import { SchemaAugmentation } from '#api/schema-augmentation/index'
|
3
|
+
import { createSchemaSource } from '#api/schema-source/index'
|
4
|
+
import { Schema } from '#api/schema/index'
|
5
|
+
import type { Vite } from '#dep/vite/index'
|
6
|
+
import { Grafaid } from '#lib/grafaid/index'
|
7
|
+
import { ViteVirtual } from '#lib/vite-virtual/index'
|
8
|
+
import { debugPolen } from '#singletons/debug'
|
9
|
+
import { Cache } from '@wollybeard/kit'
|
10
|
+
import * as NodeFs from 'node:fs/promises'
|
11
|
+
import * as NodePath from 'node:path'
|
12
|
+
import { polenVirtual } from '../vi.js'
|
13
|
+
|
14
|
+
export const viProjectSchemaMetadata = polenVirtual([`project`, `schema-metadata`])
|
15
|
+
|
16
|
+
/**
|
17
|
+
* Vite plugin that generates JSON assets for GraphQL schemas at build time.
|
18
|
+
*
|
19
|
+
* This plugin:
|
20
|
+
* - Reads GraphQL schema files from the project
|
21
|
+
* - Applies schema augmentations
|
22
|
+
* - Converts schemas to AST format and emits as JSON assets
|
23
|
+
* - Creates a metadata file with available versions
|
24
|
+
* - Provides a virtual module for accessing schema metadata
|
25
|
+
*
|
26
|
+
* The generated assets enable client-side loading of different schema versions
|
27
|
+
* without requiring all schemas to be bundled into the main JavaScript bundle.
|
28
|
+
*
|
29
|
+
* @param config - Polen configuration object
|
30
|
+
* @returns Vite plugin instance
|
31
|
+
*/
|
32
|
+
export const SchemaAssets = (config: Config.Config): Vite.Plugin => {
|
33
|
+
const debug = debugPolen.sub(`vite-plugin:schema-assets`)
|
34
|
+
let viteServer: Vite.ViteDevServer | null = null
|
35
|
+
|
36
|
+
// Helper to load and process schema data
|
37
|
+
const loadAndProcessSchemaData = Cache.memoize(async () => {
|
38
|
+
const schemaData = await Schema.readOrThrow({
|
39
|
+
...config.schema,
|
40
|
+
projectRoot: config.paths.project.rootDir,
|
41
|
+
})
|
42
|
+
|
43
|
+
if (!schemaData) {
|
44
|
+
const metadata: Schema.SchemaMetadata = { hasSchema: false, versions: [] }
|
45
|
+
return {
|
46
|
+
schemaData: null,
|
47
|
+
metadata,
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
// Apply augmentations
|
52
|
+
schemaData.forEach(version => {
|
53
|
+
SchemaAugmentation.apply(version.after, config.schemaAugmentations)
|
54
|
+
})
|
55
|
+
|
56
|
+
// Build metadata
|
57
|
+
const versionStrings: string[] = []
|
58
|
+
for (const [index, version] of schemaData.entries()) {
|
59
|
+
const versionName = index === 0 ? Schema.VERSION_LATEST : Schema.dateToVersionString(version.date)
|
60
|
+
versionStrings.push(versionName)
|
61
|
+
}
|
62
|
+
|
63
|
+
const metadata = {
|
64
|
+
hasSchema: true,
|
65
|
+
versions: versionStrings,
|
66
|
+
}
|
67
|
+
|
68
|
+
debug(`schemaDataLoaded`, { versionCount: schemaData.length })
|
69
|
+
|
70
|
+
return {
|
71
|
+
schemaData,
|
72
|
+
metadata,
|
73
|
+
}
|
74
|
+
})
|
75
|
+
|
76
|
+
// Helper to create schema source with filesystem IO
|
77
|
+
const createDevSchemaSource = (metadata: Schema.SchemaMetadata) => {
|
78
|
+
return createSchemaSource({
|
79
|
+
io: {
|
80
|
+
read: async () => {
|
81
|
+
throw new Error('Read not supported in dev asset writer')
|
82
|
+
},
|
83
|
+
write: async (path: string, content: string) => {
|
84
|
+
await NodeFs.writeFile(path, content, 'utf-8')
|
85
|
+
},
|
86
|
+
clearDirectory: async (path: string) => {
|
87
|
+
try {
|
88
|
+
const files = await NodeFs.readdir(path)
|
89
|
+
await Promise.all(files.map(file => NodeFs.rm(NodePath.join(path, file), { force: true })))
|
90
|
+
} catch (error) {
|
91
|
+
// Directory might not exist, which is fine
|
92
|
+
}
|
93
|
+
},
|
94
|
+
removeFile: async (path: string) => {
|
95
|
+
await NodeFs.rm(path, { force: true })
|
96
|
+
},
|
97
|
+
},
|
98
|
+
versions: metadata.versions,
|
99
|
+
assetsPath: config.paths.framework.devAssets.absolute,
|
100
|
+
})
|
101
|
+
}
|
102
|
+
|
103
|
+
// Helper to write assets using schema-source API
|
104
|
+
const writeDevAssets = async (
|
105
|
+
schemaData: Awaited<ReturnType<typeof Schema.readOrThrow>>,
|
106
|
+
metadata: Schema.SchemaMetadata,
|
107
|
+
) => {
|
108
|
+
if (!schemaData) return
|
109
|
+
|
110
|
+
const devAssetsDir = config.paths.framework.devAssets.schemas
|
111
|
+
await NodeFs.mkdir(devAssetsDir, { recursive: true })
|
112
|
+
|
113
|
+
const schemaSource = createDevSchemaSource(metadata)
|
114
|
+
await schemaSource.writeAllAssets(schemaData, metadata)
|
115
|
+
debug(`devAssetsWritten`, { versionCount: schemaData.length })
|
116
|
+
}
|
117
|
+
|
118
|
+
return {
|
119
|
+
name: `polen:schema-assets`,
|
120
|
+
|
121
|
+
configureServer(server) {
|
122
|
+
viteServer = server
|
123
|
+
|
124
|
+
// Clear all assets when dev server starts
|
125
|
+
const clearAssets = async () => {
|
126
|
+
try {
|
127
|
+
// Create a basic schema source just for clearing
|
128
|
+
const schemaSource = createDevSchemaSource({ hasSchema: false, versions: [] })
|
129
|
+
await schemaSource.clearAllAssets()
|
130
|
+
debug(`devAssetsCleared`, {})
|
131
|
+
} catch (error) {
|
132
|
+
// Ignore errors during clearing
|
133
|
+
}
|
134
|
+
}
|
135
|
+
|
136
|
+
// Clear assets immediately
|
137
|
+
void clearAssets()
|
138
|
+
|
139
|
+
// Set up file watching for schema source files
|
140
|
+
if (config.schema?.dataSources?.directory?.path) {
|
141
|
+
// Watch the entire directory for directory mode
|
142
|
+
server.watcher.add(config.schema.dataSources.directory.path)
|
143
|
+
debug(`watchingSchemaDirectory`, { path: config.schema.dataSources.directory.path })
|
144
|
+
}
|
145
|
+
|
146
|
+
if (config.schema?.dataSources?.file?.path) {
|
147
|
+
// Watch the specific file for file mode
|
148
|
+
server.watcher.add(config.schema.dataSources.file.path)
|
149
|
+
debug(`watchingSchemaFile`, { path: config.schema.dataSources.file.path })
|
150
|
+
}
|
151
|
+
|
152
|
+
// Handle file removal
|
153
|
+
server.watcher.on('unlink', async (file) => {
|
154
|
+
const isSchemaFile = config.schema && (() => {
|
155
|
+
const absoluteFile = NodePath.resolve(file)
|
156
|
+
|
157
|
+
// Check if file path matches the configured schema file
|
158
|
+
if (config.schema.dataSources?.file?.path) {
|
159
|
+
const absoluteSchemaFile = NodePath.resolve(
|
160
|
+
config.paths.project.rootDir,
|
161
|
+
config.schema.dataSources.file.path,
|
162
|
+
)
|
163
|
+
if (absoluteFile === absoluteSchemaFile) return true
|
164
|
+
}
|
165
|
+
|
166
|
+
// Check if file path is within the configured schema directory
|
167
|
+
if (config.schema.dataSources?.directory?.path) {
|
168
|
+
const absoluteSchemaDir = NodePath.resolve(
|
169
|
+
config.paths.project.rootDir,
|
170
|
+
config.schema.dataSources.directory.path,
|
171
|
+
)
|
172
|
+
if (absoluteFile.startsWith(absoluteSchemaDir + NodePath.sep)) return true
|
173
|
+
}
|
174
|
+
|
175
|
+
return false
|
176
|
+
})()
|
177
|
+
|
178
|
+
if (isSchemaFile) {
|
179
|
+
debug(`schemaFileRemoved`, { file })
|
180
|
+
|
181
|
+
try {
|
182
|
+
// Clear cache and regenerate
|
183
|
+
loadAndProcessSchemaData.clear()
|
184
|
+
const { schemaData, metadata } = await loadAndProcessSchemaData()
|
185
|
+
|
186
|
+
if (schemaData) {
|
187
|
+
// Write new assets without the removed file
|
188
|
+
await writeDevAssets(schemaData, metadata)
|
189
|
+
debug(`hmr:schemaAssetsUpdatedAfterRemoval`, { versionCount: schemaData.length })
|
190
|
+
} else {
|
191
|
+
// No schema data - clear all assets
|
192
|
+
const schemaSource = createDevSchemaSource({ hasSchema: false, versions: [] })
|
193
|
+
await schemaSource.clearAllAssets()
|
194
|
+
debug(`hmr:allAssetsCleared`, {})
|
195
|
+
}
|
196
|
+
} catch (error) {
|
197
|
+
debug(`hmr:schemaRemovalFailed`, { error })
|
198
|
+
}
|
199
|
+
|
200
|
+
// Send HMR invalidation signal
|
201
|
+
server.ws.send({
|
202
|
+
type: 'custom',
|
203
|
+
event: 'polen:schema-invalidate',
|
204
|
+
data: { timestamp: Date.now() },
|
205
|
+
})
|
206
|
+
|
207
|
+
debug(`hmr:schemaInvalidationSent`, {})
|
208
|
+
}
|
209
|
+
})
|
210
|
+
},
|
211
|
+
|
212
|
+
async buildStart() {
|
213
|
+
debug(`buildStart`, {})
|
214
|
+
|
215
|
+
// Load and process schema data
|
216
|
+
const { schemaData, metadata } = await loadAndProcessSchemaData()
|
217
|
+
|
218
|
+
if (!schemaData) {
|
219
|
+
debug(`noSchemaFound`, {})
|
220
|
+
return
|
221
|
+
}
|
222
|
+
|
223
|
+
// Handle asset generation differently for dev vs build
|
224
|
+
if (viteServer) {
|
225
|
+
// Dev mode: Write assets directly to filesystem
|
226
|
+
await writeDevAssets(schemaData, metadata)
|
227
|
+
debug(`devMode:schemaAssetsWritten`, {})
|
228
|
+
return
|
229
|
+
}
|
230
|
+
|
231
|
+
// Build mode: Create schema source for emitting files
|
232
|
+
const schemaSource = createSchemaSource({
|
233
|
+
io: {
|
234
|
+
read: async () => {
|
235
|
+
throw new Error('Read not supported in build asset emitter')
|
236
|
+
},
|
237
|
+
write: async (path: string, content: string) => {
|
238
|
+
// Convert absolute path to relative filename for Vite
|
239
|
+
const relativePath = NodePath.relative(config.paths.framework.devAssets.absolute, path)
|
240
|
+
const fileName = `${config.paths.project.relative.build.relative.assets.root}/${relativePath}`
|
241
|
+
|
242
|
+
this.emitFile({
|
243
|
+
type: `asset`,
|
244
|
+
fileName,
|
245
|
+
source: content,
|
246
|
+
})
|
247
|
+
},
|
248
|
+
},
|
249
|
+
versions: metadata.versions,
|
250
|
+
assetsPath: config.paths.framework.devAssets.absolute,
|
251
|
+
})
|
252
|
+
|
253
|
+
// Emit all assets using the high-level API
|
254
|
+
await schemaSource.writeAllAssets(schemaData, metadata)
|
255
|
+
debug(`buildMode:allAssetsEmitted`, { versionCount: schemaData.length })
|
256
|
+
},
|
257
|
+
|
258
|
+
async handleHotUpdate({ file, server }) {
|
259
|
+
const isSchemaFile = config.schema && (() => {
|
260
|
+
const absoluteFile = NodePath.resolve(file)
|
261
|
+
|
262
|
+
// Check if file path matches the configured schema file
|
263
|
+
if (config.schema.dataSources?.file?.path) {
|
264
|
+
const absoluteSchemaFile = NodePath.resolve(config.paths.project.rootDir, config.schema.dataSources.file.path)
|
265
|
+
if (absoluteFile === absoluteSchemaFile) return true
|
266
|
+
}
|
267
|
+
|
268
|
+
// Check if file path is within the configured schema directory
|
269
|
+
if (config.schema.dataSources?.directory?.path) {
|
270
|
+
const absoluteSchemaDir = NodePath.resolve(
|
271
|
+
config.paths.project.rootDir,
|
272
|
+
config.schema.dataSources.directory.path,
|
273
|
+
)
|
274
|
+
if (absoluteFile.startsWith(absoluteSchemaDir + NodePath.sep)) return true
|
275
|
+
}
|
276
|
+
|
277
|
+
return false
|
278
|
+
})()
|
279
|
+
if (isSchemaFile) {
|
280
|
+
debug(`schemaFileChanged`, { file })
|
281
|
+
|
282
|
+
// Regenerate schema assets
|
283
|
+
try {
|
284
|
+
loadAndProcessSchemaData.clear()
|
285
|
+
const { schemaData, metadata } = await loadAndProcessSchemaData()
|
286
|
+
|
287
|
+
if (schemaData) {
|
288
|
+
debug(`hmr:schemaRegenerated`, { versionCount: schemaData.length })
|
289
|
+
|
290
|
+
// Write new assets to filesystem
|
291
|
+
await writeDevAssets(schemaData, metadata)
|
292
|
+
}
|
293
|
+
} catch (error) {
|
294
|
+
debug(`hmr:schemaRegenerationFailed`, { error })
|
295
|
+
}
|
296
|
+
|
297
|
+
// Send HMR invalidation signal
|
298
|
+
server.ws.send({
|
299
|
+
type: 'custom',
|
300
|
+
event: 'polen:schema-invalidate',
|
301
|
+
data: { timestamp: Date.now() },
|
302
|
+
})
|
303
|
+
|
304
|
+
debug(`hmr:schemaInvalidationSent`, {})
|
305
|
+
}
|
306
|
+
},
|
307
|
+
|
308
|
+
...ViteVirtual.IdentifiedLoader.toHooks({
|
309
|
+
identifier: viProjectSchemaMetadata,
|
310
|
+
async loader() {
|
311
|
+
debug(`virtualModuleLoad`, { id: viProjectSchemaMetadata.id })
|
312
|
+
const { metadata } = await loadAndProcessSchemaData()
|
313
|
+
return `export default ${JSON.stringify(metadata)}`
|
314
|
+
},
|
315
|
+
}),
|
316
|
+
}
|
317
|
+
}
|
@@ -5,16 +5,10 @@ import type { Vite } from '#dep/vite/index'
|
|
5
5
|
import { createHtmlTransformer } from '#lib/html-utils/html-transformer'
|
6
6
|
import { ResponseInternalServerError } from '#lib/kit-temp'
|
7
7
|
import { debugPolen } from '#singletons/debug'
|
8
|
+
import type { App, AppOptions } from '#template/server/app'
|
8
9
|
import * as HonoNodeServer from '@hono/node-server'
|
9
10
|
import { Err } from '@wollybeard/kit'
|
10
|
-
|
11
|
-
type App = Hono.Hono
|
12
|
-
|
13
|
-
interface AppOptions {
|
14
|
-
hooks?: {
|
15
|
-
transformHtml?: ((html: string, ctx: Hono.Context) => Promise<string> | string)[]
|
16
|
-
}
|
17
|
-
}
|
11
|
+
import * as NodePath from 'node:path'
|
18
12
|
|
19
13
|
interface AppServerModule {
|
20
14
|
createApp: (options: AppOptions) => App
|
@@ -80,6 +74,19 @@ export const Serve = (
|
|
80
74
|
}),
|
81
75
|
],
|
82
76
|
},
|
77
|
+
paths: {
|
78
|
+
base: config.build.base,
|
79
|
+
assets: {
|
80
|
+
// Calculate relative path from CWD to Polen's assets
|
81
|
+
// CWD is user's project directory where they run 'pnpm dev'
|
82
|
+
// Assets are in Polen's dev assets directory
|
83
|
+
directory: NodePath.relative(
|
84
|
+
process.cwd(),
|
85
|
+
config.paths.framework.devAssets.absolute,
|
86
|
+
),
|
87
|
+
route: config.server.routes.assets,
|
88
|
+
},
|
89
|
+
},
|
83
90
|
})
|
84
91
|
})
|
85
92
|
.catch(async (error) => {
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import { neverCase } from '@wollybeard/kit/language'
|
1
2
|
import type {
|
2
3
|
Change,
|
3
4
|
DirectiveAddedChange,
|
@@ -248,3 +249,59 @@ export type DirectiveUsage =
|
|
248
249
|
| DirectiveUsageInputFieldDefinitionRemovedChange
|
249
250
|
|
250
251
|
export const isDirectiveUsage = (change: Change): change is DirectiveUsage => change.type.startsWith(`DIRECTIVE_USAGE_`)
|
252
|
+
|
253
|
+
export type Type =
|
254
|
+
| 'TypeOperation'
|
255
|
+
| 'TypeDescription'
|
256
|
+
| 'FieldOperation'
|
257
|
+
| 'FieldDescription'
|
258
|
+
| 'FieldDeprecation'
|
259
|
+
| 'FieldDeprecationReason'
|
260
|
+
| 'FieldArgumentOperation'
|
261
|
+
| 'FieldArgument'
|
262
|
+
| 'FieldArgumentDescription'
|
263
|
+
| 'EnumValueOperation'
|
264
|
+
| 'EnumValueDescription'
|
265
|
+
| 'EnumValueDeprecationReason'
|
266
|
+
| 'InputFieldOperation'
|
267
|
+
| 'InputFieldDescription'
|
268
|
+
| 'InputFieldDefaultValue'
|
269
|
+
| 'UnionMemberOperation'
|
270
|
+
| 'ObjectTypeInterfaceOperation'
|
271
|
+
| 'DirectiveOperation'
|
272
|
+
| 'DirectiveDescription'
|
273
|
+
| 'DirectiveLocationOperation'
|
274
|
+
| 'DirectiveArgumentOperation'
|
275
|
+
| 'DirectiveArgument'
|
276
|
+
| 'DirectiveArgumentDescription'
|
277
|
+
| 'SchemaRootType'
|
278
|
+
| 'DirectiveUsage'
|
279
|
+
|
280
|
+
export const getType = (change: Change): Type => {
|
281
|
+
if (isTypeOperation(change)) return 'TypeOperation'
|
282
|
+
if (isTypeDescription(change)) return 'TypeDescription'
|
283
|
+
if (isFieldOperation(change)) return 'FieldOperation'
|
284
|
+
if (isFieldDescription(change)) return 'FieldDescription'
|
285
|
+
if (isFieldDeprecation(change)) return 'FieldDeprecation'
|
286
|
+
if (isFieldDeprecationReason(change)) return 'FieldDeprecationReason'
|
287
|
+
if (isFieldArgumentOperation(change)) return 'FieldArgumentOperation'
|
288
|
+
if (isFieldArgument(change)) return 'FieldArgument'
|
289
|
+
if (isFieldArgumentDescription(change)) return 'FieldArgumentDescription'
|
290
|
+
if (isEnumValueOperation(change)) return 'EnumValueOperation'
|
291
|
+
if (isEnumValueDescription(change)) return 'EnumValueDescription'
|
292
|
+
if (isEnumValueDeprecationReason(change)) return 'EnumValueDeprecationReason'
|
293
|
+
if (isInputFieldOperation(change)) return 'InputFieldOperation'
|
294
|
+
if (isInputFieldDescription(change)) return 'InputFieldDescription'
|
295
|
+
if (isInputFieldDefaultValue(change)) return 'InputFieldDefaultValue'
|
296
|
+
if (isUnionMemberOperation(change)) return 'UnionMemberOperation'
|
297
|
+
if (isObjectTypeInterfaceOperation(change)) return 'ObjectTypeInterfaceOperation'
|
298
|
+
if (isDirectiveOperation(change)) return 'DirectiveOperation'
|
299
|
+
if (isDirectiveDescription(change)) return 'DirectiveDescription'
|
300
|
+
if (isDirectiveLocationOperation(change)) return 'DirectiveLocationOperation'
|
301
|
+
if (isDirectiveArgumentOperation(change)) return 'DirectiveArgumentOperation'
|
302
|
+
if (isDirectiveArgument(change)) return 'DirectiveArgument'
|
303
|
+
if (isDirectiveArgumentDescription(change)) return 'DirectiveArgumentDescription'
|
304
|
+
if (isSchemaRootType(change)) return 'SchemaRootType'
|
305
|
+
if (isDirectiveUsage(change)) return 'DirectiveUsage'
|
306
|
+
neverCase(change)
|
307
|
+
}
|
package/src/lib/kit-temp.ts
CHANGED
@@ -181,6 +181,19 @@ export const ensureEnd = (string: string, ending: string) => {
|
|
181
181
|
return string + ending
|
182
182
|
}
|
183
183
|
|
184
|
+
/**
|
185
|
+
* Create a generic cache with clear interface
|
186
|
+
*/
|
187
|
+
export const createCache = <T>() => {
|
188
|
+
const cache = new Map<string, T>()
|
189
|
+
return {
|
190
|
+
has: (key: string) => cache.has(key),
|
191
|
+
get: (key: string) => cache.get(key),
|
192
|
+
set: (key: string, value: T) => cache.set(key, value),
|
193
|
+
clear: () => cache.clear(),
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
184
197
|
export const ResponseInternalServerError = () =>
|
185
198
|
new Response(null, {
|
186
199
|
status: Http.Status.InternalServerError.code,
|
@@ -197,6 +197,22 @@ describe('PathMap', () => {
|
|
197
197
|
})
|
198
198
|
|
199
199
|
describe('property tests', () => {
|
200
|
+
// Helper to normalize base paths the same way PathMap.create does
|
201
|
+
const normalizeBasePath = (base: string): string => {
|
202
|
+
const trimmedBase = base.trim()
|
203
|
+
const collapsedBase = trimmedBase.replace(/\/+/g, '/')
|
204
|
+
const cleanedBase = collapsedBase === '/.' ? '/' : collapsedBase
|
205
|
+
return cleanedBase === '/' ? '/' : cleanedBase.replace(/\/$/, '')
|
206
|
+
}
|
207
|
+
|
208
|
+
// Helper to build absolute paths with proper handling of root base
|
209
|
+
const buildAbsolutePath = (normalizedBase: string, segments: string[]): string => {
|
210
|
+
if (segments.length === 0) return normalizedBase
|
211
|
+
return normalizedBase === '/'
|
212
|
+
? `/${segments.join('/')}`
|
213
|
+
: `${normalizedBase}/${segments.join('/')}`
|
214
|
+
}
|
215
|
+
|
200
216
|
// Arbitrary for valid path segments
|
201
217
|
const pathSegment = fc.stringMatching(/^[a-zA-Z0-9_-]+$/)
|
202
218
|
|
@@ -243,10 +259,7 @@ describe('PathMap', () => {
|
|
243
259
|
fc.assert(
|
244
260
|
fc.property(pathInput, fc.string({ minLength: 1 }).filter(s => s.startsWith('/')), (input, base) => {
|
245
261
|
const paths = PathMap.create(input, base)
|
246
|
-
|
247
|
-
// Base is normalized (trimmed, multiple slashes collapsed, trailing removed)
|
248
|
-
const collapsedBase = base.trim().replace(/\/+/g, '/')
|
249
|
-
const normalizedBase = collapsedBase === '/' ? '/' : collapsedBase.replace(/\/$/, '')
|
262
|
+
const normalizedBase = normalizeBasePath(base)
|
250
263
|
|
251
264
|
function checkAbsolute(obj: any) {
|
252
265
|
for (const [key, value] of Object.entries(obj)) {
|
@@ -278,14 +291,11 @@ describe('PathMap', () => {
|
|
278
291
|
expect(JSON.stringify(p1.rooted)).toBe(JSON.stringify(p2.rooted))
|
279
292
|
|
280
293
|
// Only absolute paths and base should change
|
281
|
-
|
282
|
-
const normalizedBase2 = collapsedBase2 === '/' ? '/' : collapsedBase2.replace(/\/$/, '')
|
283
|
-
expect(p2.base).toBe(normalizedBase2)
|
284
|
-
|
294
|
+
// Use the normalized base from the PathMap itself
|
285
295
|
function checkBase(obj: any) {
|
286
296
|
for (const [key, value] of Object.entries(obj)) {
|
287
297
|
if (typeof value === 'string') {
|
288
|
-
expect(value.startsWith(
|
298
|
+
expect(value.startsWith(p2.base)).toBe(true)
|
289
299
|
} else if (typeof value === 'object') {
|
290
300
|
checkBase(value)
|
291
301
|
}
|
@@ -309,20 +319,13 @@ describe('PathMap', () => {
|
|
309
319
|
if (currentPath.length === 0) {
|
310
320
|
expect(rel.$).toBe('.')
|
311
321
|
expect(rooted.$).toBe('.')
|
312
|
-
|
313
|
-
const collapsedBase = base.trim().replace(/\/+/g, '/')
|
314
|
-
const normalizedBase = collapsedBase === '/' ? '/' : collapsedBase.replace(/\/$/, '')
|
322
|
+
const normalizedBase = normalizeBasePath(base)
|
315
323
|
expect(abs.$).toBe(normalizedBase)
|
316
324
|
} else {
|
317
325
|
expect(rel.$).toBe(currentPath[currentPath.length - 1])
|
318
326
|
expect(rooted.$).toBe(currentPath.join('/'))
|
319
|
-
|
320
|
-
|
321
|
-
const collapsedBase = base.trim().replace(/\/+/g, '/')
|
322
|
-
const normalizedBase = collapsedBase === '/' ? '/' : collapsedBase.replace(/\/$/, '')
|
323
|
-
const expectedAbs = normalizedBase === '/'
|
324
|
-
? `/${currentPath.join('/')}`
|
325
|
-
: `${normalizedBase}/${currentPath.join('/')}`
|
327
|
+
const normalizedBase = normalizeBasePath(base)
|
328
|
+
const expectedAbs = buildAbsolutePath(normalizedBase, currentPath)
|
326
329
|
expect(abs.$).toBe(expectedAbs)
|
327
330
|
}
|
328
331
|
}
|
@@ -113,7 +113,9 @@ export function create<T extends PathInput>(paths: T, base?: string): RelativePa
|
|
113
113
|
const trimmedBase = base.trim()
|
114
114
|
// Collapse multiple slashes to single, then remove trailing (unless it's just "/")
|
115
115
|
const collapsedBase = trimmedBase.replace(/\/+/g, `/`)
|
116
|
-
|
116
|
+
// Handle edge case where base is "/." - this should become "/"
|
117
|
+
const cleanedBase = collapsedBase === `/.` ? `/` : collapsedBase
|
118
|
+
const normalizedBase = cleanedBase === `/` ? `/` : cleanedBase.replace(/\/$/, ``)
|
117
119
|
|
118
120
|
const rooted = processRootedPaths(paths, [])
|
119
121
|
const absolute = processAbsolutePaths(paths, normalizedBase, [])
|
package/src/project-data.ts
CHANGED
@@ -1,18 +1,10 @@
|
|
1
1
|
import type { Config } from '#api/config/index'
|
2
2
|
import type { NavbarItem } from '#api/content/navbar'
|
3
|
-
import type { Schema } from './api/schema/index.js'
|
4
3
|
|
5
4
|
export interface ProjectData {
|
6
|
-
schema: null | Schema.Schema
|
7
5
|
basePath: string
|
8
|
-
paths: Config.Config[
|
6
|
+
paths: Config.Config['paths']
|
9
7
|
navbar: NavbarItem[]
|
10
|
-
server:
|
11
|
-
|
12
|
-
static: {
|
13
|
-
directory: string
|
14
|
-
route: string
|
15
|
-
}
|
16
|
-
}
|
17
|
-
warnings: Config.Config[`warnings`]
|
8
|
+
server: Config.Config['server']
|
9
|
+
warnings: Config.Config['warnings']
|
18
10
|
}
|
@@ -1,15 +1,14 @@
|
|
1
|
-
import type {
|
1
|
+
import type { Api } from '#api/index'
|
2
2
|
import { CRITICALITY_LEVELS } from '#lib/graphql-change/criticality'
|
3
3
|
import { GraphqlChange } from '#lib/graphql-change/index'
|
4
4
|
import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
5
5
|
import type { CriticalityLevel } from '@graphql-inspector/core'
|
6
6
|
import { Box } from '@radix-ui/themes'
|
7
|
-
import
|
8
|
-
import type React from 'react'
|
7
|
+
import React from 'react'
|
9
8
|
import { useMemo } from 'react'
|
10
|
-
import type { Schema as ChangelogData } from '../../api/schema/index.js'
|
11
9
|
import { CriticalitySection } from './Changelog/CriticalitySection.js'
|
12
10
|
import * as Group from './Changelog/groups/index.js'
|
11
|
+
import { ComponentDispatch } from './ComponentDispatch.js'
|
13
12
|
|
14
13
|
export const renderDate = (date: Date) => {
|
15
14
|
return date.toLocaleString(`default`, {
|
@@ -20,10 +19,10 @@ export const renderDate = (date: Date) => {
|
|
20
19
|
})
|
21
20
|
}
|
22
21
|
|
23
|
-
export const Changelog: React.FC<{
|
22
|
+
export const Changelog: React.FC<{ changesets: Api.Schema.NonEmptyChangeSets }> = ({ changesets }) => {
|
24
23
|
return (
|
25
24
|
<Box>
|
26
|
-
{
|
25
|
+
{changesets.map(changeset => <Changeset key={changeset.date.toISOString()} changeset={changeset} />)}
|
27
26
|
</Box>
|
28
27
|
)
|
29
28
|
}
|
@@ -62,69 +61,19 @@ const Changeset: React.FC<{ changeset: GraphqlChangeset.ChangeSet }> = ({ change
|
|
62
61
|
</h1>
|
63
62
|
{groupedChanges.map(group => (
|
64
63
|
<CriticalitySection key={group.level} level={group.level} changes={group.changes}>
|
65
|
-
{group.changes.map(change =>
|
66
|
-
|
67
|
-
|
64
|
+
{group.changes.map(change => {
|
65
|
+
const type = GraphqlChange.Group.getType(change)
|
66
|
+
return (
|
67
|
+
<ComponentDispatch
|
68
|
+
key={`${change.type}-${change.path || change.message}`}
|
69
|
+
components={Group}
|
70
|
+
name={type}
|
71
|
+
props={{ change }}
|
72
|
+
/>
|
73
|
+
)
|
74
|
+
})}
|
68
75
|
</CriticalitySection>
|
69
76
|
))}
|
70
77
|
</Box>
|
71
78
|
)
|
72
79
|
}
|
73
|
-
|
74
|
-
const Change: React.FC<{ change: GraphqlChange.Change; schema: GrafaidOld.Schema.Schema }> = (
|
75
|
-
{ change, schema },
|
76
|
-
) => {
|
77
|
-
if (GraphqlChange.Group.isTypeOperation(change)) {
|
78
|
-
return <Group.TypeOperation change={change} />
|
79
|
-
} else if (GraphqlChange.Group.isTypeDescription(change)) {
|
80
|
-
return <Group.TypeDescription change={change} />
|
81
|
-
} else if (GraphqlChange.Group.isFieldOperation(change)) {
|
82
|
-
return <Group.FieldOperation change={change} />
|
83
|
-
} else if (GraphqlChange.Group.isFieldDescription(change)) {
|
84
|
-
return <Group.FieldDescription change={change} />
|
85
|
-
} else if (GraphqlChange.Group.isFieldDeprecation(change)) {
|
86
|
-
return <Group.FieldDeprecation change={change} />
|
87
|
-
} else if (GraphqlChange.Group.isFieldDeprecationReason(change)) {
|
88
|
-
return <Group.FieldDeprecationReason change={change} />
|
89
|
-
} else if (GraphqlChange.Group.isFieldArgumentOperation(change)) {
|
90
|
-
return <Group.FieldArgumentOperation change={change} />
|
91
|
-
} else if (GraphqlChange.Group.isFieldArgument(change)) {
|
92
|
-
return <Group.FieldArgument change={change} />
|
93
|
-
} else if (GraphqlChange.Group.isFieldArgumentDescription(change)) {
|
94
|
-
return <Group.FieldArgumentDescription change={change} />
|
95
|
-
} else if (GraphqlChange.Group.isEnumValueOperation(change)) {
|
96
|
-
return <Group.EnumValueOperation change={change} />
|
97
|
-
} else if (GraphqlChange.Group.isEnumValueDescription(change)) {
|
98
|
-
return <Group.EnumValueDescription change={change} />
|
99
|
-
} else if (GraphqlChange.Group.isEnumValueDeprecationReason(change)) {
|
100
|
-
return <Group.EnumValueDeprecationReason change={change} />
|
101
|
-
} else if (GraphqlChange.Group.isInputFieldOperation(change)) {
|
102
|
-
return <Group.InputFieldOperation change={change} />
|
103
|
-
} else if (GraphqlChange.Group.isInputFieldDescription(change)) {
|
104
|
-
return <Group.InputFieldDescription change={change} />
|
105
|
-
} else if (GraphqlChange.Group.isInputFieldDefaultValue(change)) {
|
106
|
-
return <Group.InputFieldDefaultValue change={change} />
|
107
|
-
} else if (GraphqlChange.Group.isUnionMemberOperation(change)) {
|
108
|
-
return <Group.UnionMemberOperation change={change} />
|
109
|
-
} else if (GraphqlChange.Group.isObjectTypeInterfaceOperation(change)) {
|
110
|
-
return <Group.ObjectTypeInterfaceOperation change={change} />
|
111
|
-
} else if (GraphqlChange.Group.isDirectiveOperation(change)) {
|
112
|
-
return <Group.DirectiveOperation change={change} />
|
113
|
-
} else if (GraphqlChange.Group.isDirectiveDescription(change)) {
|
114
|
-
return <Group.DirectiveDescription change={change} />
|
115
|
-
} else if (GraphqlChange.Group.isDirectiveLocationOperation(change)) {
|
116
|
-
return <Group.DirectiveLocationOperation change={change} />
|
117
|
-
} else if (GraphqlChange.Group.isDirectiveArgumentOperation(change)) {
|
118
|
-
return <Group.DirectiveArgumentOperation change={change} />
|
119
|
-
} else if (GraphqlChange.Group.isDirectiveArgument(change)) {
|
120
|
-
return <Group.DirectiveArgument change={change} />
|
121
|
-
} else if (GraphqlChange.Group.isDirectiveArgumentDescription(change)) {
|
122
|
-
return <Group.DirectiveArgumentDescription change={change} />
|
123
|
-
} else if (GraphqlChange.Group.isSchemaRootType(change)) {
|
124
|
-
return <Group.SchemaRootType change={change} />
|
125
|
-
} else if (GraphqlChange.Group.isDirectiveUsage(change)) {
|
126
|
-
return <Group.DirectiveUsage change={change} />
|
127
|
-
} else {
|
128
|
-
neverCase(change)
|
129
|
-
}
|
130
|
-
}
|