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/src/api/schema/schema.ts
CHANGED
@@ -4,6 +4,66 @@ export * as DataSources from './data-sources/data-sources.js'
|
|
4
4
|
|
5
5
|
export * from './read.js'
|
6
6
|
|
7
|
-
export
|
8
|
-
|
7
|
+
export * from './metadata.js'
|
8
|
+
|
9
|
+
export type ChangeSets = GraphqlChangeset.ChangeSet[]
|
10
|
+
|
11
|
+
export type NonEmptyChangeSets = [GraphqlChangeset.ChangeSet, ...GraphqlChangeset.ChangeSet[]]
|
12
|
+
|
13
|
+
/**
|
14
|
+
* Changelog data structure for JSON serialization
|
15
|
+
*/
|
16
|
+
export interface ChangelogData {
|
17
|
+
changes: GraphqlChangeset.ChangeSet['changes']
|
18
|
+
date: string
|
19
|
+
}
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Constants for schema versioning
|
23
|
+
*/
|
24
|
+
|
25
|
+
/**
|
26
|
+
* The version identifier for the latest schema
|
27
|
+
*/
|
28
|
+
export const VERSION_LATEST = `latest`
|
29
|
+
|
30
|
+
/**
|
31
|
+
* Fallback version name when date parsing fails
|
32
|
+
*/
|
33
|
+
export const VERSION_UNKNOWN_FALLBACK = `unknown`
|
34
|
+
|
35
|
+
/**
|
36
|
+
* Convert a date to a version string in YYYY-MM-DD format
|
37
|
+
*/
|
38
|
+
export const dateToVersionString = (date: Date): string => {
|
39
|
+
return date.toLocaleDateString('en-CA')
|
40
|
+
}
|
41
|
+
|
42
|
+
/**
|
43
|
+
* Determine if a version at the given index should have a changelog file.
|
44
|
+
* Only non-oldest versions get changelog files.
|
45
|
+
*/
|
46
|
+
export const shouldVersionHaveChangelog = (versionIndex: number, totalVersions: number): boolean => {
|
47
|
+
return versionIndex < totalVersions - 1
|
48
|
+
}
|
49
|
+
|
50
|
+
/**
|
51
|
+
* Convert a version string back to a Date
|
52
|
+
*/
|
53
|
+
export const versionStringToDate = (version: string): Date => {
|
54
|
+
if (version === VERSION_LATEST) {
|
55
|
+
return new Date()
|
56
|
+
}
|
57
|
+
|
58
|
+
// Use modern date parsing - the version string should be in YYYY-MM-DD format
|
59
|
+
// which is ISO 8601 compatible
|
60
|
+
const parsedDate = new Date(version + 'T00:00:00Z')
|
61
|
+
|
62
|
+
// Check if the date is valid
|
63
|
+
if (!isNaN(parsedDate.getTime())) {
|
64
|
+
return parsedDate
|
65
|
+
}
|
66
|
+
|
67
|
+
// Throw error for invalid dates instead of silently defaulting
|
68
|
+
throw new Error(`Invalid version string: ${version}`)
|
9
69
|
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './schema-source.js'
|
@@ -0,0 +1,189 @@
|
|
1
|
+
import { Schema } from '#api/schema/index'
|
2
|
+
import { Grafaid } from '#lib/grafaid/index'
|
3
|
+
import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
|
4
|
+
import { astToSchema } from '#template/lib/schema-utils/schema-utils'
|
5
|
+
import { Cache } from '@wollybeard/kit'
|
6
|
+
import type { GraphQLSchema } from 'graphql'
|
7
|
+
|
8
|
+
type WriteFile = (path: string, content: string) => Promise<void>
|
9
|
+
|
10
|
+
type ReadFile = (locator: string) => Promise<string>
|
11
|
+
|
12
|
+
type ClearDirectory = (path: string) => Promise<void>
|
13
|
+
|
14
|
+
type RemoveFile = (path: string) => Promise<void>
|
15
|
+
|
16
|
+
const NoImplementationWriteFile: WriteFile = async (path: string, content: string) => {
|
17
|
+
throw new Error('Write operations not supported in this environment')
|
18
|
+
}
|
19
|
+
|
20
|
+
const NoImplementationClearDirectory: ClearDirectory = async (path: string) => {
|
21
|
+
throw new Error('Directory operations not supported in this environment')
|
22
|
+
}
|
23
|
+
|
24
|
+
const NoImplementationRemoveFile: RemoveFile = async (path: string) => {
|
25
|
+
throw new Error('File removal operations not supported in this environment')
|
26
|
+
}
|
27
|
+
|
28
|
+
interface SchemaSourceConfig {
|
29
|
+
io: {
|
30
|
+
read: ReadFile
|
31
|
+
write?: WriteFile
|
32
|
+
clearDirectory?: ClearDirectory
|
33
|
+
removeFile?: RemoveFile
|
34
|
+
}
|
35
|
+
versions: string[]
|
36
|
+
assetsPath: string
|
37
|
+
}
|
38
|
+
|
39
|
+
export const createSchemaSource = (config: SchemaSourceConfig) => {
|
40
|
+
const getSchemaPath = (version: string) => `${config.assetsPath}/schemas/${version}.json`
|
41
|
+
|
42
|
+
const getChangelogPath = (version: string) => `${config.assetsPath}/schemas/${version}.changelog.json`
|
43
|
+
|
44
|
+
const getSchemasDirectory = () => `${config.assetsPath}/schemas`
|
45
|
+
|
46
|
+
const getMetadataPath = () => `${config.assetsPath}/schemas/metadata.json`
|
47
|
+
|
48
|
+
const ioWrite = config.io.write || NoImplementationWriteFile
|
49
|
+
const ioClearDirectory = config.io.clearDirectory || NoImplementationClearDirectory
|
50
|
+
const ioRemoveFile = config.io.removeFile || NoImplementationRemoveFile
|
51
|
+
|
52
|
+
// Memoize only the base IO read operation
|
53
|
+
const ioReadMemoized = Cache.memoize(config.io.read)
|
54
|
+
|
55
|
+
const get = async (version: string): Promise<GraphQLSchema> => {
|
56
|
+
const content = await ioReadMemoized(getSchemaPath(version))
|
57
|
+
const schemaAst = JSON.parse(content)
|
58
|
+
const schema = astToSchema(schemaAst)
|
59
|
+
return schema
|
60
|
+
}
|
61
|
+
|
62
|
+
const getChangelog = async (version: string): Promise<Schema.ChangelogData> => {
|
63
|
+
const content = await ioReadMemoized(getChangelogPath(version))
|
64
|
+
return JSON.parse(content)
|
65
|
+
}
|
66
|
+
|
67
|
+
const getAllChangesets = async (): Promise<GraphqlChangeset.ChangeSet[]> => {
|
68
|
+
const changesets: GraphqlChangeset.ChangeSet[] = []
|
69
|
+
|
70
|
+
for (let i = 0; i < config.versions.length; i++) {
|
71
|
+
const version = config.versions[i]
|
72
|
+
if (!version) continue
|
73
|
+
|
74
|
+
const schema = await get(version)
|
75
|
+
if (!schema) continue
|
76
|
+
|
77
|
+
// Only try to read changelog for non-oldest versions (matching writeDevAssets logic)
|
78
|
+
let changelogData = null
|
79
|
+
if (i < config.versions.length - 1) {
|
80
|
+
changelogData = await getChangelog(version)
|
81
|
+
}
|
82
|
+
|
83
|
+
if (changelogData) {
|
84
|
+
const prevVersion = config.versions[i + 1]
|
85
|
+
const prevSchema = prevVersion ? await get(prevVersion) : null
|
86
|
+
|
87
|
+
if (prevSchema) {
|
88
|
+
changesets.push({
|
89
|
+
after: schema,
|
90
|
+
before: prevSchema,
|
91
|
+
changes: changelogData.changes,
|
92
|
+
date: new Date(changelogData.date),
|
93
|
+
})
|
94
|
+
}
|
95
|
+
} else {
|
96
|
+
// Oldest version - no changelog, use existing utility
|
97
|
+
changesets.push({
|
98
|
+
after: schema,
|
99
|
+
before: Grafaid.Schema.empty,
|
100
|
+
changes: [],
|
101
|
+
date: Schema.versionStringToDate(version),
|
102
|
+
})
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
return changesets
|
107
|
+
}
|
108
|
+
|
109
|
+
return {
|
110
|
+
//
|
111
|
+
// Properties
|
112
|
+
//
|
113
|
+
versions: config.versions,
|
114
|
+
isEmpty: config.versions.length === 0,
|
115
|
+
|
116
|
+
//
|
117
|
+
// Methods
|
118
|
+
//
|
119
|
+
get,
|
120
|
+
getChangelog,
|
121
|
+
getAllChangesets,
|
122
|
+
|
123
|
+
// Expose the memoized reader's clear method
|
124
|
+
clearCache: ioReadMemoized.clear,
|
125
|
+
|
126
|
+
// Write operations (use the writer, which throws if not provided)
|
127
|
+
writeSchema: async (version: string, schema: GraphQLSchema) => {
|
128
|
+
const ast = Grafaid.Schema.AST.parse(Grafaid.Schema.print(schema))
|
129
|
+
await ioWrite(getSchemaPath(version), JSON.stringify(ast))
|
130
|
+
},
|
131
|
+
|
132
|
+
writeChangelog: async (version: string, changelog: Schema.ChangelogData) => {
|
133
|
+
await ioWrite(getChangelogPath(version), JSON.stringify(changelog))
|
134
|
+
},
|
135
|
+
|
136
|
+
// Directory operations
|
137
|
+
clearAllAssets: async () => {
|
138
|
+
await ioClearDirectory(getSchemasDirectory())
|
139
|
+
},
|
140
|
+
|
141
|
+
removeAsset: async (version: string) => {
|
142
|
+
try {
|
143
|
+
await ioRemoveFile(getSchemaPath(version))
|
144
|
+
} catch (error) {
|
145
|
+
// Swallow errors for file removal as requested
|
146
|
+
}
|
147
|
+
|
148
|
+
try {
|
149
|
+
await ioRemoveFile(getChangelogPath(version))
|
150
|
+
} catch (error) {
|
151
|
+
// Swallow errors for file removal as requested
|
152
|
+
}
|
153
|
+
},
|
154
|
+
|
155
|
+
writeMetadata: async (metadata: Schema.SchemaMetadata) => {
|
156
|
+
await ioWrite(getMetadataPath(), JSON.stringify(metadata, null, 2))
|
157
|
+
},
|
158
|
+
|
159
|
+
writeAllAssets: async (
|
160
|
+
schemaData: Awaited<ReturnType<typeof Schema.readOrThrow>>,
|
161
|
+
metadata: Schema.SchemaMetadata,
|
162
|
+
) => {
|
163
|
+
if (!schemaData) return
|
164
|
+
|
165
|
+
// Write schema and changelog files
|
166
|
+
for (const [index, version] of schemaData.entries()) {
|
167
|
+
const versionName = index === 0 ? Schema.VERSION_LATEST : Schema.dateToVersionString(version.date)
|
168
|
+
|
169
|
+
// Write schema file
|
170
|
+
await ioWrite(
|
171
|
+
getSchemaPath(versionName),
|
172
|
+
JSON.stringify(Grafaid.Schema.AST.parse(Grafaid.Schema.print(version.after))),
|
173
|
+
)
|
174
|
+
|
175
|
+
// Write changelog file (except for the oldest/last version)
|
176
|
+
if (Schema.shouldVersionHaveChangelog(index, schemaData.length)) {
|
177
|
+
const changelogData = {
|
178
|
+
changes: version.changes,
|
179
|
+
date: version.date.toISOString(),
|
180
|
+
}
|
181
|
+
await ioWrite(getChangelogPath(versionName), JSON.stringify(changelogData))
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
// Write metadata file
|
186
|
+
await ioWrite(getMetadataPath(), JSON.stringify(metadata, null, 2))
|
187
|
+
},
|
188
|
+
}
|
189
|
+
}
|
@@ -2,23 +2,29 @@ import type { Config } from '#api/config/index'
|
|
2
2
|
import { Content } from '#api/content/$'
|
3
3
|
import { createNavbar } from '#api/content/navbar'
|
4
4
|
import { VitePluginSelfContainedMode } from '#cli/_/self-contained-mode'
|
5
|
+
import { Hono } from '#dep/hono/index'
|
5
6
|
import type { ReactRouter } from '#dep/react-router/index'
|
6
7
|
import type { Vite } from '#dep/vite/index'
|
7
8
|
import { VitePluginJson } from '#lib/vite-plugin-json/index'
|
8
9
|
import { ViteVirtual } from '#lib/vite-virtual/index'
|
9
10
|
import { debugPolen } from '#singletons/debug'
|
10
11
|
import { superjson } from '#singletons/superjson'
|
12
|
+
import * as HonoNodeServer from '@hono/node-server'
|
13
|
+
import { serveStatic } from '@hono/node-server/serve-static'
|
11
14
|
import { Json, Str } from '@wollybeard/kit'
|
15
|
+
import * as NodePath from 'node:path'
|
12
16
|
import type { ProjectData } from '../../../project-data.js'
|
13
17
|
import { SchemaAugmentation } from '../../schema-augmentation/index.js'
|
14
18
|
import { Schema } from '../../schema/index.js'
|
15
19
|
import { createLogger } from '../logger.js'
|
16
20
|
import { polenVirtual } from '../vi.js'
|
17
21
|
import { Pages } from './pages.js'
|
22
|
+
import { SchemaAssets } from './schema-assets.js'
|
18
23
|
|
19
24
|
const viTemplateVariables = polenVirtual([`template`, `variables`])
|
20
25
|
const viTemplateSchemaAugmentations = polenVirtual([`template`, `schema-augmentations`])
|
21
26
|
export const viProjectData = polenVirtual([`project`, `data.jsonsuper`], { allowPluginProcessing: true })
|
27
|
+
export const viProjectSchema = polenVirtual([`project`, `schema.jsonsuper`], { allowPluginProcessing: true })
|
22
28
|
|
23
29
|
export interface ProjectRoutesModule {
|
24
30
|
routes: ReactRouter.RouteObject[]
|
@@ -34,7 +40,7 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
34
40
|
projectRoot: config.paths.project.rootDir,
|
35
41
|
})
|
36
42
|
// todo: augmentations scoped to a version
|
37
|
-
schema?.
|
43
|
+
schema?.forEach(version => {
|
38
44
|
SchemaAugmentation.apply(version.after, config.schemaAugmentations)
|
39
45
|
})
|
40
46
|
schemaCache = schema
|
@@ -68,6 +74,7 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
68
74
|
|
69
75
|
return [
|
70
76
|
...plugins,
|
77
|
+
SchemaAssets(config),
|
71
78
|
/**
|
72
79
|
* If a `polen*` import is encountered from the user's project, resolve it to the currently
|
73
80
|
* running source code of Polen rather than the user's node_modules.
|
@@ -133,11 +140,11 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
133
140
|
__BUILD_ARCHITECTURE_SSG__: Json.encode(config.build.architecture === `ssg`),
|
134
141
|
'process.env.NODE_ENV': Json.encode(config.advanced.debug ? 'development' : 'production'),
|
135
142
|
},
|
136
|
-
customLogger: createLogger(config),
|
143
|
+
// customLogger: createLogger(config),
|
137
144
|
esbuild: false,
|
138
145
|
build: {
|
139
146
|
target: `esnext`,
|
140
|
-
assetsDir: config.paths.project.relative.build.relative.assets,
|
147
|
+
assetsDir: config.paths.project.relative.build.relative.assets.root,
|
141
148
|
rollupOptions: {
|
142
149
|
treeshake: {
|
143
150
|
// Aggressive tree-shaking for smallest bundles
|
@@ -153,6 +160,16 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
153
160
|
}
|
154
161
|
},
|
155
162
|
...ViteVirtual.IdentifiedLoader.toHooks(
|
163
|
+
{
|
164
|
+
identifier: viProjectSchema,
|
165
|
+
async loader() {
|
166
|
+
const debug = debugPolen.sub(`module-project-schema`)
|
167
|
+
debug(`load`, { id: viProjectSchema.id })
|
168
|
+
|
169
|
+
const schema = await readSchema()
|
170
|
+
return superjson.stringify(schema)
|
171
|
+
},
|
172
|
+
},
|
156
173
|
{
|
157
174
|
identifier: viTemplateVariables,
|
158
175
|
loader() {
|
@@ -185,7 +202,7 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
185
202
|
// hydration mismatches between SSR (where base path is prepended) and client
|
186
203
|
// (where basename is configured). This ensures consistent behavior.
|
187
204
|
navbar.push({ pathExp: `/reference`, title: `Reference` })
|
188
|
-
if (schema.
|
205
|
+
if (schema.length > 1) {
|
189
206
|
navbar.push({ pathExp: `/changelog`, title: `Changelog` })
|
190
207
|
}
|
191
208
|
}
|
@@ -204,22 +221,10 @@ export const Core = (config: Config.Config): Vite.PluginOption[] => {
|
|
204
221
|
//
|
205
222
|
|
206
223
|
const projectData: ProjectData = {
|
207
|
-
schema,
|
208
224
|
basePath: config.build.base,
|
209
|
-
paths: config.paths
|
225
|
+
paths: config.paths,
|
210
226
|
navbar, // Complete navbar with schema and pages
|
211
|
-
server:
|
212
|
-
port: config.server.port,
|
213
|
-
static: {
|
214
|
-
// todo
|
215
|
-
// relative from CWD of process that boots n1ode server
|
216
|
-
// can easily break! Use path relative in server??
|
217
|
-
directory: `./` + config.paths.project.relative.build.root,
|
218
|
-
// Uses Hono route syntax - includes base path
|
219
|
-
route: config.build.base.slice(0, -1) + `/` + config.paths.project.relative.build.relative.assets
|
220
|
-
+ `/*`,
|
221
|
-
},
|
222
|
-
},
|
227
|
+
server: config.server,
|
223
228
|
warnings: config.warnings,
|
224
229
|
}
|
225
230
|
|
@@ -2,9 +2,8 @@ import type { Config } from '#api/config/index'
|
|
2
2
|
import type { Vite } from '#dep/vite/index'
|
3
3
|
import { vitePluginSsrCss } from '@hiogawa/vite-plugin-ssr-css'
|
4
4
|
import ViteReact from '@vitejs/plugin-react-oxc'
|
5
|
-
import {
|
5
|
+
import { Path } from '@wollybeard/kit'
|
6
6
|
import Inspect from 'vite-plugin-inspect'
|
7
|
-
import Restart from 'vite-plugin-restart'
|
8
7
|
import { Branding } from './branding.js'
|
9
8
|
import { Build } from './build.js'
|
10
9
|
import { Core } from './core.js'
|
@@ -26,13 +25,6 @@ export const Main = (
|
|
26
25
|
plugins.push(plugin)
|
27
26
|
}
|
28
27
|
|
29
|
-
if (Arr.isntEmpty(config.watch.also)) {
|
30
|
-
const plugin = Restart({
|
31
|
-
restart: config.watch.also,
|
32
|
-
})
|
33
|
-
plugins.push(plugin)
|
34
|
-
}
|
35
|
-
|
36
28
|
plugins.push(
|
37
29
|
ViteReact(),
|
38
30
|
vitePluginSsrCss({
|