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.
Files changed (314) hide show
  1. package/build/api/api.d.ts +1 -0
  2. package/build/api/api.d.ts.map +1 -1
  3. package/build/api/api.js +1 -0
  4. package/build/api/api.js.map +1 -1
  5. package/build/api/config/configurator.d.ts +20 -3
  6. package/build/api/config/configurator.d.ts.map +1 -1
  7. package/build/api/config/configurator.js +27 -3
  8. package/build/api/config/configurator.js.map +1 -1
  9. package/build/api/schema/data-sources/memory/memory.d.ts +2 -2
  10. package/build/api/schema/data-sources/memory/memory.d.ts.map +1 -1
  11. package/build/api/schema/data-sources/memory/memory.js +1 -3
  12. package/build/api/schema/data-sources/memory/memory.js.map +1 -1
  13. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts +7 -3
  14. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts.map +1 -1
  15. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js +15 -11
  16. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js.map +1 -1
  17. package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts +16 -7
  18. package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts.map +1 -1
  19. package/build/api/schema/data-sources/schema-directory/schema-directory.js +26 -7
  20. package/build/api/schema/data-sources/schema-directory/schema-directory.js.map +1 -1
  21. package/build/api/schema/data-sources/schema-file/schema-file.d.ts +7 -2
  22. package/build/api/schema/data-sources/schema-file/schema-file.d.ts.map +1 -1
  23. package/build/api/schema/data-sources/schema-file/schema-file.js +13 -5
  24. package/build/api/schema/data-sources/schema-file/schema-file.js.map +1 -1
  25. package/build/api/schema/metadata.d.ts +8 -0
  26. package/build/api/schema/metadata.d.ts.map +1 -0
  27. package/build/api/schema/metadata.js +19 -0
  28. package/build/api/schema/metadata.js.map +1 -0
  29. package/build/api/schema/read.d.ts +3 -3
  30. package/build/api/schema/read.d.ts.map +1 -1
  31. package/build/api/schema/read.js.map +1 -1
  32. package/build/api/schema/schema.d.ts +33 -2
  33. package/build/api/schema/schema.d.ts.map +1 -1
  34. package/build/api/schema/schema.js +42 -0
  35. package/build/api/schema/schema.js.map +1 -1
  36. package/build/api/schema-source/index.d.ts +2 -0
  37. package/build/api/schema-source/index.d.ts.map +1 -0
  38. package/build/api/schema-source/index.js +2 -0
  39. package/build/api/schema-source/index.js.map +1 -0
  40. package/build/api/schema-source/schema-source.d.ts +33 -0
  41. package/build/api/schema-source/schema-source.d.ts.map +1 -0
  42. package/build/api/schema-source/schema-source.js +137 -0
  43. package/build/api/schema-source/schema-source.js.map +1 -0
  44. package/build/api/vite/plugins/core.d.ts +1 -0
  45. package/build/api/vite/plugins/core.d.ts.map +1 -1
  46. package/build/api/vite/plugins/core.js +21 -18
  47. package/build/api/vite/plugins/core.js.map +1 -1
  48. package/build/api/vite/plugins/schema-assets.d.ts +22 -0
  49. package/build/api/vite/plugins/schema-assets.d.ts.map +1 -0
  50. package/build/api/vite/plugins/schema-assets.js +269 -0
  51. package/build/api/vite/plugins/schema-assets.js.map +1 -0
  52. package/build/api/vite/plugins/serve.d.ts.map +1 -1
  53. package/build/api/vite/plugins/serve.js +11 -0
  54. package/build/api/vite/plugins/serve.js.map +1 -1
  55. package/build/lib/graphql-change/change-groups.d.ts +2 -0
  56. package/build/lib/graphql-change/change-groups.d.ts.map +1 -1
  57. package/build/lib/graphql-change/change-groups.js +54 -0
  58. package/build/lib/graphql-change/change-groups.js.map +1 -1
  59. package/build/lib/kit-temp.d.ts +9 -0
  60. package/build/lib/kit-temp.d.ts.map +1 -1
  61. package/build/lib/kit-temp.js +12 -0
  62. package/build/lib/kit-temp.js.map +1 -1
  63. package/build/lib/path-map/path-map.d.ts.map +1 -1
  64. package/build/lib/path-map/path-map.js +3 -1
  65. package/build/lib/path-map/path-map.js.map +1 -1
  66. package/build/project-data.d.ts +3 -11
  67. package/build/project-data.d.ts.map +1 -1
  68. package/build/template/components/Changelog.d.ts +3 -3
  69. package/build/template/components/Changelog.d.ts.map +1 -1
  70. package/build/template/components/Changelog.js +8 -84
  71. package/build/template/components/Changelog.js.map +1 -1
  72. package/build/template/components/CodeBlock.d.ts +2 -0
  73. package/build/template/components/CodeBlock.d.ts.map +1 -1
  74. package/build/template/components/CodeBlock.js +1 -4
  75. package/build/template/components/CodeBlock.js.map +1 -1
  76. package/build/template/components/ComponentDispatch.d.ts +34 -0
  77. package/build/template/components/ComponentDispatch.d.ts.map +1 -0
  78. package/build/template/components/ComponentDispatch.js +33 -0
  79. package/build/template/components/ComponentDispatch.js.map +1 -0
  80. package/build/template/components/ReferenceLink.d.ts +19 -0
  81. package/build/template/components/ReferenceLink.d.ts.map +1 -0
  82. package/build/template/components/ReferenceLink.js +19 -0
  83. package/build/template/components/ReferenceLink.js.map +1 -0
  84. package/build/template/components/TypeAnnotation.d.ts.map +1 -1
  85. package/build/template/components/TypeAnnotation.js +3 -3
  86. package/build/template/components/TypeAnnotation.js.map +1 -1
  87. package/build/template/components/TypeFieldsLinkList.d.ts.map +1 -1
  88. package/build/template/components/TypeFieldsLinkList.js +4 -4
  89. package/build/template/components/TypeFieldsLinkList.js.map +1 -1
  90. package/build/template/components/TypeIndex.js +2 -2
  91. package/build/template/components/TypeIndex.js.map +1 -1
  92. package/build/template/components/VersionSelector.d.ts +7 -0
  93. package/build/template/components/VersionSelector.d.ts.map +1 -0
  94. package/build/template/components/VersionSelector.js +30 -0
  95. package/build/template/components/VersionSelector.js.map +1 -0
  96. package/build/template/components/graphql/type-link.d.ts.map +1 -1
  97. package/build/template/components/graphql/type-link.js +2 -2
  98. package/build/template/components/graphql/type-link.js.map +1 -1
  99. package/build/template/hooks/useVersionPath.d.ts +6 -0
  100. package/build/template/hooks/useVersionPath.d.ts.map +1 -0
  101. package/build/template/hooks/useVersionPath.js +10 -0
  102. package/build/template/hooks/useVersionPath.js.map +1 -0
  103. package/build/template/layouts/ChangelogLayout.d.ts.map +1 -0
  104. package/build/template/{components → layouts}/ChangelogLayout.js +1 -1
  105. package/build/template/layouts/ChangelogLayout.js.map +1 -0
  106. package/build/template/layouts/index.d.ts +1 -0
  107. package/build/template/layouts/index.d.ts.map +1 -1
  108. package/build/template/layouts/index.js +1 -0
  109. package/build/template/layouts/index.js.map +1 -1
  110. package/build/template/lib/fetch-text.d.ts +8 -0
  111. package/build/template/lib/fetch-text.d.ts.map +1 -0
  112. package/build/template/lib/fetch-text.js +14 -0
  113. package/build/template/lib/fetch-text.js.map +1 -0
  114. package/build/template/lib/polen-url.d.ts +14 -0
  115. package/build/template/lib/polen-url.d.ts.map +1 -1
  116. package/build/template/lib/polen-url.js +16 -0
  117. package/build/template/lib/polen-url.js.map +1 -1
  118. package/build/template/lib/schema-utils/constants.d.ts +5 -0
  119. package/build/template/lib/schema-utils/constants.d.ts.map +1 -0
  120. package/build/template/lib/schema-utils/constants.js +5 -0
  121. package/build/template/lib/schema-utils/constants.js.map +1 -0
  122. package/build/template/lib/schema-utils/schema-utils.d.ts +15 -0
  123. package/build/template/lib/schema-utils/schema-utils.d.ts.map +1 -0
  124. package/build/template/lib/schema-utils/schema-utils.js +37 -0
  125. package/build/template/lib/schema-utils/schema-utils.js.map +1 -0
  126. package/build/template/routes/changelog.d.ts +4 -3
  127. package/build/template/routes/changelog.d.ts.map +1 -1
  128. package/build/template/routes/changelog.js +13 -7
  129. package/build/template/routes/changelog.js.map +1 -1
  130. package/build/template/routes/pages.d.ts +10 -0
  131. package/build/template/routes/pages.d.ts.map +1 -0
  132. package/build/template/routes/pages.js +76 -0
  133. package/build/template/routes/pages.js.map +1 -0
  134. package/build/template/routes/reference.$type.$field.js +1 -1
  135. package/build/template/routes/reference.$type.$field.js.map +1 -1
  136. package/build/template/routes/reference.$type.d.ts +4 -0
  137. package/build/template/routes/reference.$type.d.ts.map +1 -1
  138. package/build/template/routes/reference.$type.js +2 -0
  139. package/build/template/routes/reference.$type.js.map +1 -1
  140. package/build/template/routes/reference.d.ts +9 -3
  141. package/build/template/routes/reference.d.ts.map +1 -1
  142. package/build/template/routes/reference.js +30 -8
  143. package/build/template/routes/reference.js.map +1 -1
  144. package/build/template/routes/reference.version.$version.$type.$field.d.ts +6 -0
  145. package/build/template/routes/reference.version.$version.$type.$field.d.ts.map +1 -0
  146. package/build/template/routes/reference.version.$version.$type.$field.js +32 -0
  147. package/build/template/routes/reference.version.$version.$type.$field.js.map +1 -0
  148. package/build/template/routes/reference.version.$version.$type.d.ts +11 -0
  149. package/build/template/routes/reference.version.$version.$type.d.ts.map +1 -0
  150. package/build/template/routes/reference.version.$version.$type.js +26 -0
  151. package/build/template/routes/reference.version.$version.$type.js.map +1 -0
  152. package/build/template/routes/root.d.ts.map +1 -1
  153. package/build/template/routes/root.js +8 -72
  154. package/build/template/routes/root.js.map +1 -1
  155. package/build/template/server/app.d.ts +22 -1
  156. package/build/template/server/app.d.ts.map +1 -1
  157. package/build/template/server/app.js +19 -9
  158. package/build/template/server/app.js.map +1 -1
  159. package/build/template/server/main.js +9 -1
  160. package/build/template/server/main.js.map +1 -1
  161. package/build/template/server/ssg/generate.js +2 -2
  162. package/build/template/server/ssg/generate.js.map +1 -1
  163. package/build/template/server/ssg/get-route-paths.d.ts +1 -1
  164. package/build/template/server/ssg/get-route-paths.d.ts.map +1 -1
  165. package/build/template/server/ssg/get-route-paths.js +51 -27
  166. package/build/template/server/ssg/get-route-paths.js.map +1 -1
  167. package/build/template/sources/schema-source.d.ts +15 -0
  168. package/build/template/sources/schema-source.d.ts.map +1 -0
  169. package/build/template/sources/schema-source.js +63 -0
  170. package/build/template/sources/schema-source.js.map +1 -0
  171. package/package.json +1 -1
  172. package/src/api/api.ts +1 -0
  173. package/src/api/config/configurator.ts +51 -6
  174. package/src/api/schema/data-sources/memory/memory.ts +3 -5
  175. package/src/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.ts +29 -13
  176. package/src/api/schema/data-sources/schema-directory/schema-directory.ts +56 -16
  177. package/src/api/schema/data-sources/schema-file/schema-file.ts +16 -7
  178. package/src/api/schema/metadata.ts +23 -0
  179. package/src/api/schema/read.ts +3 -3
  180. package/src/api/schema/schema.ts +62 -2
  181. package/src/api/schema-source/index.ts +1 -0
  182. package/src/api/schema-source/schema-source.ts +189 -0
  183. package/src/api/vite/plugins/core.ts +23 -18
  184. package/src/api/vite/plugins/schema-assets.ts +317 -0
  185. package/src/api/vite/plugins/serve.ts +15 -8
  186. package/src/lib/graphql-change/change-groups.ts +57 -0
  187. package/src/lib/kit-temp.ts +13 -0
  188. package/src/lib/path-map/$.test.ts +22 -19
  189. package/src/lib/path-map/path-map.ts +3 -1
  190. package/src/project-data.ts +3 -11
  191. package/src/template/components/Changelog.tsx +16 -67
  192. package/src/template/components/CodeBlock.tsx +3 -5
  193. package/src/template/components/ComponentDispatch.tsx +42 -0
  194. package/src/template/components/ReferenceLink.tsx +34 -0
  195. package/src/template/components/TypeAnnotation.tsx +5 -7
  196. package/src/template/components/TypeFieldsLinkList.tsx +20 -23
  197. package/src/template/components/TypeIndex.tsx +10 -12
  198. package/src/template/components/VersionSelector.tsx +50 -0
  199. package/src/template/components/graphql/type-link.tsx +4 -3
  200. package/src/template/hooks/useVersionPath.ts +10 -0
  201. package/src/template/{components → layouts}/ChangelogLayout.tsx +1 -1
  202. package/src/template/layouts/index.ts +1 -0
  203. package/src/template/lib/fetch-text.ts +13 -0
  204. package/src/template/lib/polen-url.ts +20 -0
  205. package/src/template/lib/schema-utils/constants.ts +4 -0
  206. package/src/template/lib/schema-utils/schema-utils.ts +42 -0
  207. package/src/template/routes/changelog.tsx +17 -8
  208. package/src/template/routes/pages.tsx +109 -0
  209. package/src/template/routes/reference.$type.$field.tsx +1 -1
  210. package/src/template/routes/reference.$type.tsx +2 -0
  211. package/src/template/routes/reference.tsx +38 -6
  212. package/src/template/routes/reference.version.$version.$type.$field.tsx +35 -0
  213. package/src/template/routes/reference.version.$version.$type.tsx +30 -0
  214. package/src/template/routes/root.tsx +8 -109
  215. package/src/template/server/app.ts +47 -14
  216. package/src/template/server/main.ts +9 -1
  217. package/src/template/server/ssg/generate.ts +2 -2
  218. package/src/template/server/ssg/get-route-paths.ts +53 -27
  219. package/src/template/sources/schema-source.ts +68 -0
  220. package/build/lib/graphql-document/$$.d.ts +0 -5
  221. package/build/lib/graphql-document/$$.d.ts.map +0 -1
  222. package/build/lib/graphql-document/$$.js +0 -5
  223. package/build/lib/graphql-document/$$.js.map +0 -1
  224. package/build/lib/graphql-document/$.d.ts +0 -2
  225. package/build/lib/graphql-document/$.d.ts.map +0 -1
  226. package/build/lib/graphql-document/$.js +0 -2
  227. package/build/lib/graphql-document/$.js.map +0 -1
  228. package/build/lib/graphql-document/analysis.d.ts +0 -44
  229. package/build/lib/graphql-document/analysis.d.ts.map +0 -1
  230. package/build/lib/graphql-document/analysis.js +0 -361
  231. package/build/lib/graphql-document/analysis.js.map +0 -1
  232. package/build/lib/graphql-document/components/GraphQLDocument.d.ts +0 -38
  233. package/build/lib/graphql-document/components/GraphQLDocument.d.ts.map +0 -1
  234. package/build/lib/graphql-document/components/GraphQLDocument.js +0 -151
  235. package/build/lib/graphql-document/components/GraphQLDocument.js.map +0 -1
  236. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts +0 -7
  237. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts.map +0 -1
  238. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js +0 -27
  239. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js.map +0 -1
  240. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts +0 -33
  241. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts.map +0 -1
  242. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js +0 -50
  243. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js.map +0 -1
  244. package/build/lib/graphql-document/components/IdentifierLink.d.ts +0 -39
  245. package/build/lib/graphql-document/components/IdentifierLink.d.ts.map +0 -1
  246. package/build/lib/graphql-document/components/IdentifierLink.js +0 -75
  247. package/build/lib/graphql-document/components/IdentifierLink.js.map +0 -1
  248. package/build/lib/graphql-document/components/graphql-document-styles.d.ts +0 -5
  249. package/build/lib/graphql-document/components/graphql-document-styles.d.ts.map +0 -1
  250. package/build/lib/graphql-document/components/graphql-document-styles.js +0 -144
  251. package/build/lib/graphql-document/components/graphql-document-styles.js.map +0 -1
  252. package/build/lib/graphql-document/components/index.d.ts +0 -5
  253. package/build/lib/graphql-document/components/index.d.ts.map +0 -1
  254. package/build/lib/graphql-document/components/index.js +0 -5
  255. package/build/lib/graphql-document/components/index.js.map +0 -1
  256. package/build/lib/graphql-document/example.d.ts +0 -25
  257. package/build/lib/graphql-document/example.d.ts.map +0 -1
  258. package/build/lib/graphql-document/example.js +0 -140
  259. package/build/lib/graphql-document/example.js.map +0 -1
  260. package/build/lib/graphql-document/graphql-document.d.ts +0 -35
  261. package/build/lib/graphql-document/graphql-document.d.ts.map +0 -1
  262. package/build/lib/graphql-document/graphql-document.js +0 -36
  263. package/build/lib/graphql-document/graphql-document.js.map +0 -1
  264. package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts +0 -43
  265. package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts.map +0 -1
  266. package/build/lib/graphql-document/hooks/use-tooltip-state.js +0 -132
  267. package/build/lib/graphql-document/hooks/use-tooltip-state.js.map +0 -1
  268. package/build/lib/graphql-document/positioning-simple.d.ts +0 -63
  269. package/build/lib/graphql-document/positioning-simple.d.ts.map +0 -1
  270. package/build/lib/graphql-document/positioning-simple.js +0 -185
  271. package/build/lib/graphql-document/positioning-simple.js.map +0 -1
  272. package/build/lib/graphql-document/schema-context.d.ts +0 -8
  273. package/build/lib/graphql-document/schema-context.d.ts.map +0 -1
  274. package/build/lib/graphql-document/schema-context.js +0 -11
  275. package/build/lib/graphql-document/schema-context.js.map +0 -1
  276. package/build/lib/graphql-document/schema-integration.d.ts +0 -135
  277. package/build/lib/graphql-document/schema-integration.d.ts.map +0 -1
  278. package/build/lib/graphql-document/schema-integration.js +0 -328
  279. package/build/lib/graphql-document/schema-integration.js.map +0 -1
  280. package/build/lib/graphql-document/types.d.ts +0 -117
  281. package/build/lib/graphql-document/types.d.ts.map +0 -1
  282. package/build/lib/graphql-document/types.js +0 -2
  283. package/build/lib/graphql-document/types.js.map +0 -1
  284. package/build/template/components/ChangelogLayout.d.ts.map +0 -1
  285. package/build/template/components/ChangelogLayout.js.map +0 -1
  286. package/build/template/components/CodeHikePre.d.ts +0 -16
  287. package/build/template/components/CodeHikePre.d.ts.map +0 -1
  288. package/build/template/components/CodeHikePre.js +0 -37
  289. package/build/template/components/CodeHikePre.js.map +0 -1
  290. package/src/lib/graphql-document/$$.ts +0 -4
  291. package/src/lib/graphql-document/$.test.ts +0 -132
  292. package/src/lib/graphql-document/$.ts +0 -1
  293. package/src/lib/graphql-document/README.md +0 -102
  294. package/src/lib/graphql-document/analysis.ts +0 -415
  295. package/src/lib/graphql-document/components/GraphQLDocument.tsx +0 -265
  296. package/src/lib/graphql-document/components/GraphQLDocument.unit.test.ts +0 -188
  297. package/src/lib/graphql-document/components/GraphQLDocumentWithSchema.tsx +0 -46
  298. package/src/lib/graphql-document/components/GraphQLIdentifierPopover.tsx +0 -199
  299. package/src/lib/graphql-document/components/IdentifierLink.tsx +0 -160
  300. package/src/lib/graphql-document/components/graphql-document-styles.ts +0 -144
  301. package/src/lib/graphql-document/components/index.ts +0 -4
  302. package/src/lib/graphql-document/demo.md +0 -155
  303. package/src/lib/graphql-document/example.ts +0 -163
  304. package/src/lib/graphql-document/graphql-document.ts +0 -37
  305. package/src/lib/graphql-document/hooks/use-tooltip-state.test.ts +0 -76
  306. package/src/lib/graphql-document/hooks/use-tooltip-state.ts +0 -191
  307. package/src/lib/graphql-document/positioning-simple.test.ts +0 -248
  308. package/src/lib/graphql-document/positioning-simple.ts +0 -260
  309. package/src/lib/graphql-document/schema-context.tsx +0 -20
  310. package/src/lib/graphql-document/schema-integration.test.ts +0 -365
  311. package/src/lib/graphql-document/schema-integration.ts +0 -488
  312. package/src/lib/graphql-document/types.ts +0 -129
  313. package/src/template/components/CodeHikePre.tsx +0 -51
  314. /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: `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: buildAbsolute(`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: packagePaths,
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: string
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: string
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 { Schema } from '../../schema.js'
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 | Schema> => {
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: Schema = {
113
- versions: changesets,
114
- }
112
+ const schema: NonEmptyChangeSets = changesets
115
113
 
116
114
  return schema
117
115
  }
@@ -1,6 +1,6 @@
1
1
  import { Path } from '@wollybeard/kit'
2
2
 
3
- export type Expression = ExpressionPrevious
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 previous = parseExpressionPreviousSerialized(serializedExpression)
22
- if (previous) return { ...previous, filePath: fileName, type: `FileNameExpressionPrevious` }
21
+ const versioned = parseExpressionVersionedSerialized(serializedExpression)
22
+ if (versioned) return { ...versioned, filePath: fileName, type: `FileNameExpressionVersioned` }
23
23
 
24
- // const latest = parseExpressionLatestSerialized(serializedExpression)
25
- // if (latest) return { ...latest, filePath: fileName, type: `FileNameExpressionLatest` }
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 ExpressionPrevious {
33
- type: `FileNameExpressionPrevious`
32
+ export interface ExpressionVersioned {
33
+ type: `FileNameExpressionVersioned`
34
34
  date: Date
35
35
  filePath: string
36
36
  }
37
37
 
38
- const parseExpressionPreviousSerialized = (
38
+ const parseExpressionVersionedSerialized = (
39
39
  serializedExpression: string,
40
- ): Pick<ExpressionPrevious, `date`> | null => {
41
- const match = expressionPreviousSerializedPattern.exec(serializedExpression)
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 expressionPreviousSerializedPattern = /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/
48
+ const expressionVersionedSerializedPattern = /^(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})$/
49
49
 
50
- // export const isExpressionPrevious = (expression: Expression): expression is ExpressionPrevious => {
51
- // return expression.type === `FileNameExpressionPrevious`
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 { Schema } from '../../schema.js'
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 multiple schema versions from a directory.
19
+ * Configuration for loading schema(s) from a directory.
19
20
  *
20
- * Enables the schema changelog feature by loading SDL files with date prefixes.
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 dated SDL files.
27
+ * Path to the directory containing schema files.
25
28
  *
26
- * Files should be named with ISO date prefixes: `YYYY-MM-DD.graphql`
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 example:
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 | Schema> => {
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
- const versions = await Promise.all(Arr.map(fileNameExpressions, async fileNameExpression => {
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
- const schema: Schema = {
122
- versions: changesets,
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 { Schema } from '../../schema.js'
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 | Schema> => {
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
- const date = new Date()
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 schemaVersion: GraphqlChangeset.ChangeSet = {
74
+ const changeset: GraphqlChangeset.ChangeSet = {
64
75
  date,
65
76
  after,
66
77
  before,
67
78
  changes,
68
79
  }
69
80
 
70
- const schema: 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
+ }
@@ -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 { Schema } from './schema.js'
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?: Schema
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 | Schema> => {
65
+ ): Promise<null | NonEmptyChangeSets> => {
66
66
  if (config.enabled === false) {
67
67
  return null
68
68
  }
@@ -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 interface Schema {
8
- versions: [GraphqlChangeset.ChangeSet, ...GraphqlChangeset.ChangeSet[]]
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'