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.
Files changed (332) 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 -22
  6. package/build/api/config/configurator.d.ts.map +1 -1
  7. package/build/api/config/configurator.js +27 -9
  8. package/build/api/config/configurator.js.map +1 -1
  9. package/build/api/config/merge.d.ts.map +1 -1
  10. package/build/api/config/merge.js +0 -11
  11. package/build/api/config/merge.js.map +1 -1
  12. package/build/api/content/metadata.d.ts +8 -2
  13. package/build/api/content/metadata.d.ts.map +1 -1
  14. package/build/api/content/metadata.js +1 -1
  15. package/build/api/content/metadata.js.map +1 -1
  16. package/build/api/schema/data-sources/memory/memory.d.ts +2 -2
  17. package/build/api/schema/data-sources/memory/memory.d.ts.map +1 -1
  18. package/build/api/schema/data-sources/memory/memory.js +1 -3
  19. package/build/api/schema/data-sources/memory/memory.js.map +1 -1
  20. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts +7 -3
  21. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts.map +1 -1
  22. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js +15 -11
  23. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js.map +1 -1
  24. package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts +16 -7
  25. package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts.map +1 -1
  26. package/build/api/schema/data-sources/schema-directory/schema-directory.js +26 -7
  27. package/build/api/schema/data-sources/schema-directory/schema-directory.js.map +1 -1
  28. package/build/api/schema/data-sources/schema-file/schema-file.d.ts +7 -2
  29. package/build/api/schema/data-sources/schema-file/schema-file.d.ts.map +1 -1
  30. package/build/api/schema/data-sources/schema-file/schema-file.js +13 -5
  31. package/build/api/schema/data-sources/schema-file/schema-file.js.map +1 -1
  32. package/build/api/schema/metadata.d.ts +16 -0
  33. package/build/api/schema/metadata.d.ts.map +1 -0
  34. package/build/api/schema/metadata.js +19 -0
  35. package/build/api/schema/metadata.js.map +1 -0
  36. package/build/api/schema/read.d.ts +3 -3
  37. package/build/api/schema/read.d.ts.map +1 -1
  38. package/build/api/schema/read.js.map +1 -1
  39. package/build/api/schema/schema.d.ts +33 -2
  40. package/build/api/schema/schema.d.ts.map +1 -1
  41. package/build/api/schema/schema.js +42 -0
  42. package/build/api/schema/schema.js.map +1 -1
  43. package/build/api/schema-source/index.d.ts +2 -0
  44. package/build/api/schema-source/index.d.ts.map +1 -0
  45. package/build/api/schema-source/index.js +2 -0
  46. package/build/api/schema-source/index.js.map +1 -0
  47. package/build/api/schema-source/schema-source.d.ts +33 -0
  48. package/build/api/schema-source/schema-source.d.ts.map +1 -0
  49. package/build/api/schema-source/schema-source.js +137 -0
  50. package/build/api/schema-source/schema-source.js.map +1 -0
  51. package/build/api/static/manifest.d.ts +1 -2
  52. package/build/api/static/manifest.d.ts.map +1 -1
  53. package/build/api/static/manifest.js +1 -1
  54. package/build/api/static/manifest.js.map +1 -1
  55. package/build/api/vite/plugins/core.d.ts +1 -0
  56. package/build/api/vite/plugins/core.d.ts.map +1 -1
  57. package/build/api/vite/plugins/core.js +21 -18
  58. package/build/api/vite/plugins/core.js.map +1 -1
  59. package/build/api/vite/plugins/main.d.ts.map +1 -1
  60. package/build/api/vite/plugins/main.js +1 -8
  61. package/build/api/vite/plugins/main.js.map +1 -1
  62. package/build/api/vite/plugins/schema-assets.d.ts +22 -0
  63. package/build/api/vite/plugins/schema-assets.d.ts.map +1 -0
  64. package/build/api/vite/plugins/schema-assets.js +269 -0
  65. package/build/api/vite/plugins/schema-assets.js.map +1 -0
  66. package/build/api/vite/plugins/serve.d.ts.map +1 -1
  67. package/build/api/vite/plugins/serve.js +11 -0
  68. package/build/api/vite/plugins/serve.js.map +1 -1
  69. package/build/lib/graphql-change/change-groups.d.ts +2 -0
  70. package/build/lib/graphql-change/change-groups.d.ts.map +1 -1
  71. package/build/lib/graphql-change/change-groups.js +54 -0
  72. package/build/lib/graphql-change/change-groups.js.map +1 -1
  73. package/build/lib/kit-temp.d.ts +9 -0
  74. package/build/lib/kit-temp.d.ts.map +1 -1
  75. package/build/lib/kit-temp.js +12 -0
  76. package/build/lib/kit-temp.js.map +1 -1
  77. package/build/lib/path-map/path-map.d.ts.map +1 -1
  78. package/build/lib/path-map/path-map.js +3 -1
  79. package/build/lib/path-map/path-map.js.map +1 -1
  80. package/build/project-data.d.ts +3 -11
  81. package/build/project-data.d.ts.map +1 -1
  82. package/build/template/components/Changelog.d.ts +3 -3
  83. package/build/template/components/Changelog.d.ts.map +1 -1
  84. package/build/template/components/Changelog.js +8 -84
  85. package/build/template/components/Changelog.js.map +1 -1
  86. package/build/template/components/CodeBlock.d.ts +2 -0
  87. package/build/template/components/CodeBlock.d.ts.map +1 -1
  88. package/build/template/components/CodeBlock.js +1 -4
  89. package/build/template/components/CodeBlock.js.map +1 -1
  90. package/build/template/components/ComponentDispatch.d.ts +34 -0
  91. package/build/template/components/ComponentDispatch.d.ts.map +1 -0
  92. package/build/template/components/ComponentDispatch.js +33 -0
  93. package/build/template/components/ComponentDispatch.js.map +1 -0
  94. package/build/template/components/ReferenceLink.d.ts +19 -0
  95. package/build/template/components/ReferenceLink.d.ts.map +1 -0
  96. package/build/template/components/ReferenceLink.js +19 -0
  97. package/build/template/components/ReferenceLink.js.map +1 -0
  98. package/build/template/components/TypeAnnotation.d.ts.map +1 -1
  99. package/build/template/components/TypeAnnotation.js +3 -3
  100. package/build/template/components/TypeAnnotation.js.map +1 -1
  101. package/build/template/components/TypeFieldsLinkList.d.ts.map +1 -1
  102. package/build/template/components/TypeFieldsLinkList.js +4 -4
  103. package/build/template/components/TypeFieldsLinkList.js.map +1 -1
  104. package/build/template/components/TypeIndex.js +2 -2
  105. package/build/template/components/TypeIndex.js.map +1 -1
  106. package/build/template/components/VersionSelector.d.ts +7 -0
  107. package/build/template/components/VersionSelector.d.ts.map +1 -0
  108. package/build/template/components/VersionSelector.js +30 -0
  109. package/build/template/components/VersionSelector.js.map +1 -0
  110. package/build/template/components/graphql/type-link.d.ts.map +1 -1
  111. package/build/template/components/graphql/type-link.js +2 -2
  112. package/build/template/components/graphql/type-link.js.map +1 -1
  113. package/build/template/hooks/useVersionPath.d.ts +6 -0
  114. package/build/template/hooks/useVersionPath.d.ts.map +1 -0
  115. package/build/template/hooks/useVersionPath.js +10 -0
  116. package/build/template/hooks/useVersionPath.js.map +1 -0
  117. package/build/template/layouts/ChangelogLayout.d.ts.map +1 -0
  118. package/build/template/{components → layouts}/ChangelogLayout.js +1 -1
  119. package/build/template/layouts/ChangelogLayout.js.map +1 -0
  120. package/build/template/layouts/index.d.ts +1 -0
  121. package/build/template/layouts/index.d.ts.map +1 -1
  122. package/build/template/layouts/index.js +1 -0
  123. package/build/template/layouts/index.js.map +1 -1
  124. package/build/template/lib/fetch-text.d.ts +8 -0
  125. package/build/template/lib/fetch-text.d.ts.map +1 -0
  126. package/build/template/lib/fetch-text.js +14 -0
  127. package/build/template/lib/fetch-text.js.map +1 -0
  128. package/build/template/lib/polen-url.d.ts +14 -0
  129. package/build/template/lib/polen-url.d.ts.map +1 -1
  130. package/build/template/lib/polen-url.js +16 -0
  131. package/build/template/lib/polen-url.js.map +1 -1
  132. package/build/template/lib/schema-utils/constants.d.ts +5 -0
  133. package/build/template/lib/schema-utils/constants.d.ts.map +1 -0
  134. package/build/template/lib/schema-utils/constants.js +5 -0
  135. package/build/template/lib/schema-utils/constants.js.map +1 -0
  136. package/build/template/lib/schema-utils/schema-utils.d.ts +15 -0
  137. package/build/template/lib/schema-utils/schema-utils.d.ts.map +1 -0
  138. package/build/template/lib/schema-utils/schema-utils.js +37 -0
  139. package/build/template/lib/schema-utils/schema-utils.js.map +1 -0
  140. package/build/template/routes/changelog.d.ts +4 -3
  141. package/build/template/routes/changelog.d.ts.map +1 -1
  142. package/build/template/routes/changelog.js +13 -7
  143. package/build/template/routes/changelog.js.map +1 -1
  144. package/build/template/routes/pages.d.ts +10 -0
  145. package/build/template/routes/pages.d.ts.map +1 -0
  146. package/build/template/routes/pages.js +76 -0
  147. package/build/template/routes/pages.js.map +1 -0
  148. package/build/template/routes/reference.$type.$field.js +1 -1
  149. package/build/template/routes/reference.$type.$field.js.map +1 -1
  150. package/build/template/routes/reference.$type.d.ts +4 -0
  151. package/build/template/routes/reference.$type.d.ts.map +1 -1
  152. package/build/template/routes/reference.$type.js +2 -0
  153. package/build/template/routes/reference.$type.js.map +1 -1
  154. package/build/template/routes/reference.d.ts +9 -3
  155. package/build/template/routes/reference.d.ts.map +1 -1
  156. package/build/template/routes/reference.js +30 -8
  157. package/build/template/routes/reference.js.map +1 -1
  158. package/build/template/routes/reference.version.$version.$type.$field.d.ts +6 -0
  159. package/build/template/routes/reference.version.$version.$type.$field.d.ts.map +1 -0
  160. package/build/template/routes/reference.version.$version.$type.$field.js +32 -0
  161. package/build/template/routes/reference.version.$version.$type.$field.js.map +1 -0
  162. package/build/template/routes/reference.version.$version.$type.d.ts +11 -0
  163. package/build/template/routes/reference.version.$version.$type.d.ts.map +1 -0
  164. package/build/template/routes/reference.version.$version.$type.js +26 -0
  165. package/build/template/routes/reference.version.$version.$type.js.map +1 -0
  166. package/build/template/routes/root.d.ts.map +1 -1
  167. package/build/template/routes/root.js +8 -72
  168. package/build/template/routes/root.js.map +1 -1
  169. package/build/template/server/app.d.ts +22 -1
  170. package/build/template/server/app.d.ts.map +1 -1
  171. package/build/template/server/app.js +19 -9
  172. package/build/template/server/app.js.map +1 -1
  173. package/build/template/server/main.js +9 -1
  174. package/build/template/server/main.js.map +1 -1
  175. package/build/template/server/ssg/generate.js +2 -2
  176. package/build/template/server/ssg/generate.js.map +1 -1
  177. package/build/template/server/ssg/get-route-paths.d.ts +1 -1
  178. package/build/template/server/ssg/get-route-paths.d.ts.map +1 -1
  179. package/build/template/server/ssg/get-route-paths.js +51 -27
  180. package/build/template/server/ssg/get-route-paths.js.map +1 -1
  181. package/build/template/sources/schema-source.d.ts +15 -0
  182. package/build/template/sources/schema-source.d.ts.map +1 -0
  183. package/build/template/sources/schema-source.js +63 -0
  184. package/build/template/sources/schema-source.js.map +1 -0
  185. package/package.json +16 -17
  186. package/src/api/api.ts +1 -0
  187. package/src/api/config/configurator.ts +51 -32
  188. package/src/api/config/merge.ts +0 -16
  189. package/src/api/content/metadata.ts +1 -1
  190. package/src/api/schema/data-sources/memory/memory.ts +3 -5
  191. package/src/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.ts +29 -13
  192. package/src/api/schema/data-sources/schema-directory/schema-directory.ts +56 -16
  193. package/src/api/schema/data-sources/schema-file/schema-file.ts +16 -7
  194. package/src/api/schema/metadata.ts +23 -0
  195. package/src/api/schema/read.ts +3 -3
  196. package/src/api/schema/schema.ts +62 -2
  197. package/src/api/schema-source/index.ts +1 -0
  198. package/src/api/schema-source/schema-source.ts +189 -0
  199. package/src/api/static/manifest.ts +1 -1
  200. package/src/api/vite/plugins/core.ts +23 -18
  201. package/src/api/vite/plugins/main.ts +1 -9
  202. package/src/api/vite/plugins/schema-assets.ts +317 -0
  203. package/src/api/vite/plugins/serve.ts +15 -8
  204. package/src/lib/graphql-change/change-groups.ts +57 -0
  205. package/src/lib/kit-temp.ts +13 -0
  206. package/src/lib/path-map/$.test.ts +22 -19
  207. package/src/lib/path-map/path-map.ts +3 -1
  208. package/src/project-data.ts +3 -11
  209. package/src/template/components/Changelog.tsx +16 -67
  210. package/src/template/components/CodeBlock.tsx +3 -5
  211. package/src/template/components/ComponentDispatch.tsx +42 -0
  212. package/src/template/components/ReferenceLink.tsx +34 -0
  213. package/src/template/components/TypeAnnotation.tsx +5 -7
  214. package/src/template/components/TypeFieldsLinkList.tsx +20 -23
  215. package/src/template/components/TypeIndex.tsx +10 -12
  216. package/src/template/components/VersionSelector.tsx +50 -0
  217. package/src/template/components/graphql/type-link.tsx +4 -3
  218. package/src/template/hooks/useVersionPath.ts +10 -0
  219. package/src/template/{components → layouts}/ChangelogLayout.tsx +1 -1
  220. package/src/template/layouts/index.ts +1 -0
  221. package/src/template/lib/fetch-text.ts +13 -0
  222. package/src/template/lib/polen-url.ts +20 -0
  223. package/src/template/lib/schema-utils/constants.ts +4 -0
  224. package/src/template/lib/schema-utils/schema-utils.ts +42 -0
  225. package/src/template/routes/changelog.tsx +17 -8
  226. package/src/template/routes/pages.tsx +109 -0
  227. package/src/template/routes/reference.$type.$field.tsx +1 -1
  228. package/src/template/routes/reference.$type.tsx +2 -0
  229. package/src/template/routes/reference.tsx +38 -6
  230. package/src/template/routes/reference.version.$version.$type.$field.tsx +35 -0
  231. package/src/template/routes/reference.version.$version.$type.tsx +30 -0
  232. package/src/template/routes/root.tsx +8 -109
  233. package/src/template/server/app.ts +47 -14
  234. package/src/template/server/main.ts +9 -1
  235. package/src/template/server/ssg/generate.ts +2 -2
  236. package/src/template/server/ssg/get-route-paths.ts +53 -27
  237. package/src/template/sources/schema-source.ts +68 -0
  238. package/build/lib/graphql-document/$$.d.ts +0 -5
  239. package/build/lib/graphql-document/$$.d.ts.map +0 -1
  240. package/build/lib/graphql-document/$$.js +0 -5
  241. package/build/lib/graphql-document/$$.js.map +0 -1
  242. package/build/lib/graphql-document/$.d.ts +0 -2
  243. package/build/lib/graphql-document/$.d.ts.map +0 -1
  244. package/build/lib/graphql-document/$.js +0 -2
  245. package/build/lib/graphql-document/$.js.map +0 -1
  246. package/build/lib/graphql-document/analysis.d.ts +0 -44
  247. package/build/lib/graphql-document/analysis.d.ts.map +0 -1
  248. package/build/lib/graphql-document/analysis.js +0 -361
  249. package/build/lib/graphql-document/analysis.js.map +0 -1
  250. package/build/lib/graphql-document/components/GraphQLDocument.d.ts +0 -38
  251. package/build/lib/graphql-document/components/GraphQLDocument.d.ts.map +0 -1
  252. package/build/lib/graphql-document/components/GraphQLDocument.js +0 -151
  253. package/build/lib/graphql-document/components/GraphQLDocument.js.map +0 -1
  254. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts +0 -7
  255. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts.map +0 -1
  256. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js +0 -27
  257. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js.map +0 -1
  258. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts +0 -33
  259. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts.map +0 -1
  260. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js +0 -50
  261. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js.map +0 -1
  262. package/build/lib/graphql-document/components/IdentifierLink.d.ts +0 -39
  263. package/build/lib/graphql-document/components/IdentifierLink.d.ts.map +0 -1
  264. package/build/lib/graphql-document/components/IdentifierLink.js +0 -75
  265. package/build/lib/graphql-document/components/IdentifierLink.js.map +0 -1
  266. package/build/lib/graphql-document/components/graphql-document-styles.d.ts +0 -5
  267. package/build/lib/graphql-document/components/graphql-document-styles.d.ts.map +0 -1
  268. package/build/lib/graphql-document/components/graphql-document-styles.js +0 -144
  269. package/build/lib/graphql-document/components/graphql-document-styles.js.map +0 -1
  270. package/build/lib/graphql-document/components/index.d.ts +0 -5
  271. package/build/lib/graphql-document/components/index.d.ts.map +0 -1
  272. package/build/lib/graphql-document/components/index.js +0 -5
  273. package/build/lib/graphql-document/components/index.js.map +0 -1
  274. package/build/lib/graphql-document/example.d.ts +0 -25
  275. package/build/lib/graphql-document/example.d.ts.map +0 -1
  276. package/build/lib/graphql-document/example.js +0 -140
  277. package/build/lib/graphql-document/example.js.map +0 -1
  278. package/build/lib/graphql-document/graphql-document.d.ts +0 -35
  279. package/build/lib/graphql-document/graphql-document.d.ts.map +0 -1
  280. package/build/lib/graphql-document/graphql-document.js +0 -36
  281. package/build/lib/graphql-document/graphql-document.js.map +0 -1
  282. package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts +0 -43
  283. package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts.map +0 -1
  284. package/build/lib/graphql-document/hooks/use-tooltip-state.js +0 -132
  285. package/build/lib/graphql-document/hooks/use-tooltip-state.js.map +0 -1
  286. package/build/lib/graphql-document/positioning-simple.d.ts +0 -63
  287. package/build/lib/graphql-document/positioning-simple.d.ts.map +0 -1
  288. package/build/lib/graphql-document/positioning-simple.js +0 -185
  289. package/build/lib/graphql-document/positioning-simple.js.map +0 -1
  290. package/build/lib/graphql-document/schema-context.d.ts +0 -8
  291. package/build/lib/graphql-document/schema-context.d.ts.map +0 -1
  292. package/build/lib/graphql-document/schema-context.js +0 -11
  293. package/build/lib/graphql-document/schema-context.js.map +0 -1
  294. package/build/lib/graphql-document/schema-integration.d.ts +0 -135
  295. package/build/lib/graphql-document/schema-integration.d.ts.map +0 -1
  296. package/build/lib/graphql-document/schema-integration.js +0 -328
  297. package/build/lib/graphql-document/schema-integration.js.map +0 -1
  298. package/build/lib/graphql-document/types.d.ts +0 -117
  299. package/build/lib/graphql-document/types.d.ts.map +0 -1
  300. package/build/lib/graphql-document/types.js +0 -2
  301. package/build/lib/graphql-document/types.js.map +0 -1
  302. package/build/template/components/ChangelogLayout.d.ts.map +0 -1
  303. package/build/template/components/ChangelogLayout.js.map +0 -1
  304. package/build/template/components/CodeHikePre.d.ts +0 -16
  305. package/build/template/components/CodeHikePre.d.ts.map +0 -1
  306. package/build/template/components/CodeHikePre.js +0 -37
  307. package/build/template/components/CodeHikePre.js.map +0 -1
  308. package/src/lib/graphql-document/$$.ts +0 -4
  309. package/src/lib/graphql-document/$.test.ts +0 -132
  310. package/src/lib/graphql-document/$.ts +0 -1
  311. package/src/lib/graphql-document/README.md +0 -102
  312. package/src/lib/graphql-document/analysis.ts +0 -415
  313. package/src/lib/graphql-document/components/GraphQLDocument.tsx +0 -265
  314. package/src/lib/graphql-document/components/GraphQLDocument.unit.test.ts +0 -188
  315. package/src/lib/graphql-document/components/GraphQLDocumentWithSchema.tsx +0 -46
  316. package/src/lib/graphql-document/components/GraphQLIdentifierPopover.tsx +0 -199
  317. package/src/lib/graphql-document/components/IdentifierLink.tsx +0 -160
  318. package/src/lib/graphql-document/components/graphql-document-styles.ts +0 -144
  319. package/src/lib/graphql-document/components/index.ts +0 -4
  320. package/src/lib/graphql-document/demo.md +0 -155
  321. package/src/lib/graphql-document/example.ts +0 -163
  322. package/src/lib/graphql-document/graphql-document.ts +0 -37
  323. package/src/lib/graphql-document/hooks/use-tooltip-state.test.ts +0 -76
  324. package/src/lib/graphql-document/hooks/use-tooltip-state.ts +0 -191
  325. package/src/lib/graphql-document/positioning-simple.test.ts +0 -248
  326. package/src/lib/graphql-document/positioning-simple.ts +0 -260
  327. package/src/lib/graphql-document/schema-context.tsx +0 -20
  328. package/src/lib/graphql-document/schema-integration.test.ts +0 -365
  329. package/src/lib/graphql-document/schema-integration.ts +0 -488
  330. package/src/lib/graphql-document/types.ts +0 -129
  331. package/src/template/components/CodeHikePre.tsx +0 -51
  332. /package/build/template/{components → layouts}/ChangelogLayout.d.ts +0 -0
@@ -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'
@@ -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
+ }
@@ -5,7 +5,7 @@ export const PolenBuildManifestSchema = z.object({
5
5
  type: z.enum([`ssg`, `ssr`]),
6
6
  version: z.string(),
7
7
  basePath: z.string(),
8
- }).loose()
8
+ })
9
9
 
10
10
  export type PolenBuildManifest = z.infer<typeof PolenBuildManifestSchema>
11
11
 
@@ -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?.versions.forEach(version => {
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.versions.length > 1) {
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.project,
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 { Arr, Path } from '@wollybeard/kit'
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({