polen 0.10.0 → 0.11.0-next.1
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 -3
- package/build/api/config/configurator.d.ts.map +1 -1
- package/build/api/config/configurator.js +27 -3
- package/build/api/config/configurator.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 +8 -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/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/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 +1 -1
- package/src/api/api.ts +1 -0
- package/src/api/config/configurator.ts +51 -6
- 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/vite/plugins/core.ts +23 -18
- 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
@@ -289,6 +289,13 @@ const buildPaths = (rootDir: string): Config[`paths`] => {
|
|
289
289
|
|
290
290
|
const publicAbsolutePath = rootAbsolute(`public`)
|
291
291
|
const publicAbsolute = Path.ensureAbsoluteWith(publicAbsolutePath)
|
292
|
+
|
293
|
+
const assetsAbsolute = Path.ensureAbsoluteWith(buildAbsolute(`assets`))
|
294
|
+
|
295
|
+
// Dev assets paths
|
296
|
+
const devAssetsRelative = 'node_modules/.vite/polen-assets'
|
297
|
+
const devAssetsAbsolute = Path.join(packagePaths.rootDir, devAssetsRelative)
|
298
|
+
|
292
299
|
return {
|
293
300
|
project: {
|
294
301
|
rootDir,
|
@@ -297,7 +304,12 @@ const buildPaths = (rootDir: string): Config[`paths`] => {
|
|
297
304
|
root: `build`,
|
298
305
|
relative: {
|
299
306
|
serverEntrypoint: `app.js`,
|
300
|
-
assets:
|
307
|
+
assets: {
|
308
|
+
root: `assets`,
|
309
|
+
relative: {
|
310
|
+
schemas: `schemas`,
|
311
|
+
},
|
312
|
+
},
|
301
313
|
},
|
302
314
|
},
|
303
315
|
pages: `pages`,
|
@@ -311,7 +323,10 @@ const buildPaths = (rootDir: string): Config[`paths`] => {
|
|
311
323
|
build: {
|
312
324
|
root: buildAbsolute(`.`),
|
313
325
|
serverEntrypoint: buildAbsolute(`app.js`),
|
314
|
-
assets:
|
326
|
+
assets: {
|
327
|
+
root: buildAbsolute(`assets`),
|
328
|
+
schemas: assetsAbsolute(`schemas`),
|
329
|
+
},
|
315
330
|
},
|
316
331
|
public: {
|
317
332
|
root: publicAbsolute(`.`),
|
@@ -319,7 +334,14 @@ const buildPaths = (rootDir: string): Config[`paths`] => {
|
|
319
334
|
},
|
320
335
|
},
|
321
336
|
},
|
322
|
-
framework:
|
337
|
+
framework: {
|
338
|
+
...packagePaths,
|
339
|
+
devAssets: {
|
340
|
+
relative: devAssetsRelative,
|
341
|
+
absolute: devAssetsAbsolute,
|
342
|
+
schemas: Path.join(devAssetsAbsolute, 'schemas'),
|
343
|
+
},
|
344
|
+
},
|
323
345
|
}
|
324
346
|
}
|
325
347
|
|
@@ -331,6 +353,9 @@ export interface Config {
|
|
331
353
|
}
|
332
354
|
server: {
|
333
355
|
port: number
|
356
|
+
routes: {
|
357
|
+
assets: string
|
358
|
+
}
|
334
359
|
}
|
335
360
|
watch: {
|
336
361
|
also: string[]
|
@@ -353,7 +378,12 @@ export interface Config {
|
|
353
378
|
build: {
|
354
379
|
root: string
|
355
380
|
relative: {
|
356
|
-
assets:
|
381
|
+
assets: {
|
382
|
+
root: string
|
383
|
+
relative: {
|
384
|
+
schemas: string
|
385
|
+
}
|
386
|
+
}
|
357
387
|
serverEntrypoint: string
|
358
388
|
}
|
359
389
|
}
|
@@ -366,7 +396,10 @@ export interface Config {
|
|
366
396
|
absolute: {
|
367
397
|
build: {
|
368
398
|
root: string
|
369
|
-
assets:
|
399
|
+
assets: {
|
400
|
+
root: string
|
401
|
+
schemas: string
|
402
|
+
}
|
370
403
|
serverEntrypoint: string
|
371
404
|
}
|
372
405
|
pages: string
|
@@ -376,7 +409,13 @@ export interface Config {
|
|
376
409
|
}
|
377
410
|
}
|
378
411
|
}
|
379
|
-
framework: PackagePaths
|
412
|
+
framework: PackagePaths & {
|
413
|
+
devAssets: {
|
414
|
+
relative: string
|
415
|
+
absolute: string
|
416
|
+
schemas: string
|
417
|
+
}
|
418
|
+
}
|
380
419
|
}
|
381
420
|
advanced: {
|
382
421
|
isSelfContainedMode: boolean
|
@@ -401,6 +440,9 @@ const configInputDefaults: Config = {
|
|
401
440
|
},
|
402
441
|
server: {
|
403
442
|
port: 3000,
|
443
|
+
routes: {
|
444
|
+
assets: '/assets',
|
445
|
+
},
|
404
446
|
},
|
405
447
|
schema: null,
|
406
448
|
ssr: {
|
@@ -507,6 +549,9 @@ export const normalizeInput = async (
|
|
507
549
|
config.server.port = configInput.server.port
|
508
550
|
}
|
509
551
|
|
552
|
+
// Server routes are not configurable by users yet, use defaults
|
553
|
+
// config.server.routes is already set from defaultConfig
|
554
|
+
|
510
555
|
// Process warnings configuration
|
511
556
|
if (configInput?.warnings?.interactiveWithoutSchema?.enabled !== undefined) {
|
512
557
|
config.warnings.interactiveWithoutSchema.enabled = configInput.warnings.interactiveWithoutSchema.enabled
|
@@ -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/v4'
|
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
|
}
|
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'
|