polen 0.10.0 → 0.11.0-next.10

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 (357) 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 +55 -26
  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/data-sources.d.ts +1 -0
  17. package/build/api/schema/data-sources/data-sources.d.ts.map +1 -1
  18. package/build/api/schema/data-sources/data-sources.js +1 -0
  19. package/build/api/schema/data-sources/data-sources.js.map +1 -1
  20. package/build/api/schema/data-sources/introspection/introspection.d.ts +83 -0
  21. package/build/api/schema/data-sources/introspection/introspection.d.ts.map +1 -0
  22. package/build/api/schema/data-sources/introspection/introspection.js +110 -0
  23. package/build/api/schema/data-sources/introspection/introspection.js.map +1 -0
  24. package/build/api/schema/data-sources/memory/memory.d.ts +2 -2
  25. package/build/api/schema/data-sources/memory/memory.d.ts.map +1 -1
  26. package/build/api/schema/data-sources/memory/memory.js +1 -3
  27. package/build/api/schema/data-sources/memory/memory.js.map +1 -1
  28. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts +7 -3
  29. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.d.ts.map +1 -1
  30. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js +15 -11
  31. package/build/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.js.map +1 -1
  32. package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts +16 -7
  33. package/build/api/schema/data-sources/schema-directory/schema-directory.d.ts.map +1 -1
  34. package/build/api/schema/data-sources/schema-directory/schema-directory.js +26 -7
  35. package/build/api/schema/data-sources/schema-directory/schema-directory.js.map +1 -1
  36. package/build/api/schema/data-sources/schema-file/schema-file.d.ts +7 -2
  37. package/build/api/schema/data-sources/schema-file/schema-file.d.ts.map +1 -1
  38. package/build/api/schema/data-sources/schema-file/schema-file.js +13 -5
  39. package/build/api/schema/data-sources/schema-file/schema-file.js.map +1 -1
  40. package/build/api/schema/metadata.d.ts +16 -0
  41. package/build/api/schema/metadata.d.ts.map +1 -0
  42. package/build/api/schema/metadata.js +19 -0
  43. package/build/api/schema/metadata.js.map +1 -0
  44. package/build/api/schema/read.d.ts +85 -11
  45. package/build/api/schema/read.d.ts.map +1 -1
  46. package/build/api/schema/read.js +15 -6
  47. package/build/api/schema/read.js.map +1 -1
  48. package/build/api/schema/schema.d.ts +33 -2
  49. package/build/api/schema/schema.d.ts.map +1 -1
  50. package/build/api/schema/schema.js +42 -0
  51. package/build/api/schema/schema.js.map +1 -1
  52. package/build/api/schema-source/index.d.ts +2 -0
  53. package/build/api/schema-source/index.d.ts.map +1 -0
  54. package/build/api/schema-source/index.js +2 -0
  55. package/build/api/schema-source/index.js.map +1 -0
  56. package/build/api/schema-source/schema-source.d.ts +33 -0
  57. package/build/api/schema-source/schema-source.d.ts.map +1 -0
  58. package/build/api/schema-source/schema-source.js +137 -0
  59. package/build/api/schema-source/schema-source.js.map +1 -0
  60. package/build/api/static/manifest.d.ts +1 -2
  61. package/build/api/static/manifest.d.ts.map +1 -1
  62. package/build/api/static/manifest.js +1 -1
  63. package/build/api/static/manifest.js.map +1 -1
  64. package/build/api/vite/plugins/build.d.ts.map +1 -1
  65. package/build/api/vite/plugins/build.js +3 -0
  66. package/build/api/vite/plugins/build.js.map +1 -1
  67. package/build/api/vite/plugins/core.d.ts +1 -0
  68. package/build/api/vite/plugins/core.d.ts.map +1 -1
  69. package/build/api/vite/plugins/core.js +25 -22
  70. package/build/api/vite/plugins/core.js.map +1 -1
  71. package/build/api/vite/plugins/main.d.ts.map +1 -1
  72. package/build/api/vite/plugins/main.js +1 -8
  73. package/build/api/vite/plugins/main.js.map +1 -1
  74. package/build/api/vite/plugins/schema-assets.d.ts +22 -0
  75. package/build/api/vite/plugins/schema-assets.d.ts.map +1 -0
  76. package/build/api/vite/plugins/schema-assets.js +310 -0
  77. package/build/api/vite/plugins/schema-assets.js.map +1 -0
  78. package/build/api/vite/plugins/serve.d.ts.map +1 -1
  79. package/build/api/vite/plugins/serve.js +11 -0
  80. package/build/api/vite/plugins/serve.js.map +1 -1
  81. package/build/cli/commands/open.js +1 -1
  82. package/build/cli/commands/open.js.map +1 -1
  83. package/build/lib/grafaid/schema/schema.d.ts +1 -1
  84. package/build/lib/grafaid/schema/schema.d.ts.map +1 -1
  85. package/build/lib/grafaid/schema/schema.js +1 -1
  86. package/build/lib/grafaid/schema/schema.js.map +1 -1
  87. package/build/lib/graphql-change/change-groups.d.ts +2 -0
  88. package/build/lib/graphql-change/change-groups.d.ts.map +1 -1
  89. package/build/lib/graphql-change/change-groups.js +54 -0
  90. package/build/lib/graphql-change/change-groups.js.map +1 -1
  91. package/build/lib/kit-temp.d.ts +9 -0
  92. package/build/lib/kit-temp.d.ts.map +1 -1
  93. package/build/lib/kit-temp.js +14 -2
  94. package/build/lib/kit-temp.js.map +1 -1
  95. package/build/lib/path-map/path-map.d.ts.map +1 -1
  96. package/build/lib/path-map/path-map.js +3 -1
  97. package/build/lib/path-map/path-map.js.map +1 -1
  98. package/build/lib/react-router-aid/react-router-aid.d.ts +5 -3
  99. package/build/lib/react-router-aid/react-router-aid.d.ts.map +1 -1
  100. package/build/lib/react-router-aid/react-router-aid.js +7 -4
  101. package/build/lib/react-router-aid/react-router-aid.js.map +1 -1
  102. package/build/project-data.d.ts +3 -11
  103. package/build/project-data.d.ts.map +1 -1
  104. package/build/template/components/Changelog.d.ts +3 -3
  105. package/build/template/components/Changelog.d.ts.map +1 -1
  106. package/build/template/components/Changelog.js +8 -84
  107. package/build/template/components/Changelog.js.map +1 -1
  108. package/build/template/components/CodeBlock.d.ts +2 -0
  109. package/build/template/components/CodeBlock.d.ts.map +1 -1
  110. package/build/template/components/CodeBlock.js +1 -4
  111. package/build/template/components/CodeBlock.js.map +1 -1
  112. package/build/template/components/ComponentDispatch.d.ts +34 -0
  113. package/build/template/components/ComponentDispatch.d.ts.map +1 -0
  114. package/build/template/components/ComponentDispatch.js +33 -0
  115. package/build/template/components/ComponentDispatch.js.map +1 -0
  116. package/build/template/components/ReferenceLink.d.ts +19 -0
  117. package/build/template/components/ReferenceLink.d.ts.map +1 -0
  118. package/build/template/components/ReferenceLink.js +19 -0
  119. package/build/template/components/ReferenceLink.js.map +1 -0
  120. package/build/template/components/TypeAnnotation.d.ts.map +1 -1
  121. package/build/template/components/TypeAnnotation.js +3 -3
  122. package/build/template/components/TypeAnnotation.js.map +1 -1
  123. package/build/template/components/TypeFieldsLinkList.d.ts.map +1 -1
  124. package/build/template/components/TypeFieldsLinkList.js +4 -4
  125. package/build/template/components/TypeFieldsLinkList.js.map +1 -1
  126. package/build/template/components/TypeIndex.js +2 -2
  127. package/build/template/components/TypeIndex.js.map +1 -1
  128. package/build/template/components/VersionSelector.d.ts +7 -0
  129. package/build/template/components/VersionSelector.d.ts.map +1 -0
  130. package/build/template/components/VersionSelector.js +30 -0
  131. package/build/template/components/VersionSelector.js.map +1 -0
  132. package/build/template/components/graphql/type-link.d.ts.map +1 -1
  133. package/build/template/components/graphql/type-link.js +2 -2
  134. package/build/template/components/graphql/type-link.js.map +1 -1
  135. package/build/template/hooks/useVersionPath.d.ts +6 -0
  136. package/build/template/hooks/useVersionPath.d.ts.map +1 -0
  137. package/build/template/hooks/useVersionPath.js +10 -0
  138. package/build/template/hooks/useVersionPath.js.map +1 -0
  139. package/build/template/layouts/ChangelogLayout.d.ts.map +1 -0
  140. package/build/template/{components → layouts}/ChangelogLayout.js +1 -1
  141. package/build/template/layouts/ChangelogLayout.js.map +1 -0
  142. package/build/template/layouts/index.d.ts +1 -0
  143. package/build/template/layouts/index.d.ts.map +1 -1
  144. package/build/template/layouts/index.js +1 -0
  145. package/build/template/layouts/index.js.map +1 -1
  146. package/build/template/lib/fetch-text.d.ts +8 -0
  147. package/build/template/lib/fetch-text.d.ts.map +1 -0
  148. package/build/template/lib/fetch-text.js +14 -0
  149. package/build/template/lib/fetch-text.js.map +1 -0
  150. package/build/template/lib/polen-url.d.ts +14 -0
  151. package/build/template/lib/polen-url.d.ts.map +1 -1
  152. package/build/template/lib/polen-url.js +16 -0
  153. package/build/template/lib/polen-url.js.map +1 -1
  154. package/build/template/lib/schema-utils/constants.d.ts +5 -0
  155. package/build/template/lib/schema-utils/constants.d.ts.map +1 -0
  156. package/build/template/lib/schema-utils/constants.js +5 -0
  157. package/build/template/lib/schema-utils/constants.js.map +1 -0
  158. package/build/template/lib/schema-utils/schema-utils.d.ts +15 -0
  159. package/build/template/lib/schema-utils/schema-utils.d.ts.map +1 -0
  160. package/build/template/lib/schema-utils/schema-utils.js +37 -0
  161. package/build/template/lib/schema-utils/schema-utils.js.map +1 -0
  162. package/build/template/routes/changelog.d.ts +4 -3
  163. package/build/template/routes/changelog.d.ts.map +1 -1
  164. package/build/template/routes/changelog.js +15 -9
  165. package/build/template/routes/changelog.js.map +1 -1
  166. package/build/template/routes/index.js +2 -2
  167. package/build/template/routes/index.js.map +1 -1
  168. package/build/template/routes/pages.d.ts +10 -0
  169. package/build/template/routes/pages.d.ts.map +1 -0
  170. package/build/template/routes/pages.js +76 -0
  171. package/build/template/routes/pages.js.map +1 -0
  172. package/build/template/routes/reference.d.ts +35 -6
  173. package/build/template/routes/reference.d.ts.map +1 -1
  174. package/build/template/routes/reference.js +97 -14
  175. package/build/template/routes/reference.js.map +1 -1
  176. package/build/template/routes/root.d.ts.map +1 -1
  177. package/build/template/routes/root.js +11 -75
  178. package/build/template/routes/root.js.map +1 -1
  179. package/build/template/server/app.d.ts +22 -1
  180. package/build/template/server/app.d.ts.map +1 -1
  181. package/build/template/server/app.js +19 -9
  182. package/build/template/server/app.js.map +1 -1
  183. package/build/template/server/main.js +9 -1
  184. package/build/template/server/main.js.map +1 -1
  185. package/build/template/server/ssg/generate.js +2 -2
  186. package/build/template/server/ssg/generate.js.map +1 -1
  187. package/build/template/server/ssg/get-route-paths.d.ts +1 -1
  188. package/build/template/server/ssg/get-route-paths.d.ts.map +1 -1
  189. package/build/template/server/ssg/get-route-paths.js +90 -27
  190. package/build/template/server/ssg/get-route-paths.js.map +1 -1
  191. package/build/template/sources/schema-source.d.ts +15 -0
  192. package/build/template/sources/schema-source.d.ts.map +1 -0
  193. package/build/template/sources/schema-source.js +64 -0
  194. package/build/template/sources/schema-source.js.map +1 -0
  195. package/package.json +16 -17
  196. package/src/api/api.ts +1 -0
  197. package/src/api/config/configurator.ts +86 -36
  198. package/src/api/config/merge.ts +0 -16
  199. package/src/api/content/metadata.ts +1 -1
  200. package/src/api/schema/data-sources/data-sources.ts +1 -0
  201. package/src/api/schema/data-sources/introspection/introspection.ts +213 -0
  202. package/src/api/schema/data-sources/memory/memory.ts +3 -5
  203. package/src/api/schema/data-sources/schema-directory/file-name-expression/file-name-expression.ts +29 -13
  204. package/src/api/schema/data-sources/schema-directory/schema-directory.ts +56 -16
  205. package/src/api/schema/data-sources/schema-file/schema-file.ts +16 -7
  206. package/src/api/schema/metadata.ts +23 -0
  207. package/src/api/schema/read.ts +109 -18
  208. package/src/api/schema/schema.ts +62 -2
  209. package/src/api/schema-source/index.ts +1 -0
  210. package/src/api/schema-source/schema-source.ts +189 -0
  211. package/src/api/static/manifest.ts +1 -1
  212. package/src/api/vite/plugins/build.ts +3 -0
  213. package/src/api/vite/plugins/core.ts +27 -22
  214. package/src/api/vite/plugins/main.ts +1 -9
  215. package/src/api/vite/plugins/schema-assets.ts +364 -0
  216. package/src/api/vite/plugins/serve.ts +15 -8
  217. package/src/cli/commands/open.ts +1 -1
  218. package/src/lib/grafaid/schema/schema.ts +1 -0
  219. package/src/lib/graphql-change/change-groups.ts +57 -0
  220. package/src/lib/kit-temp.ts +15 -2
  221. package/src/lib/mask/$.test.ts +3 -3
  222. package/src/lib/path-map/$.test.ts +22 -19
  223. package/src/lib/path-map/path-map.ts +3 -1
  224. package/src/lib/react-router-aid/react-router-aid.ts +12 -6
  225. package/src/project-data.ts +3 -11
  226. package/src/template/components/Changelog.tsx +16 -67
  227. package/src/template/components/CodeBlock.tsx +3 -5
  228. package/src/template/components/ComponentDispatch.tsx +42 -0
  229. package/src/template/components/ReferenceLink.tsx +34 -0
  230. package/src/template/components/TypeAnnotation.tsx +5 -7
  231. package/src/template/components/TypeFieldsLinkList.tsx +20 -23
  232. package/src/template/components/TypeIndex.tsx +10 -12
  233. package/src/template/components/VersionSelector.tsx +50 -0
  234. package/src/template/components/graphql/type-link.tsx +4 -3
  235. package/src/template/hooks/useVersionPath.ts +10 -0
  236. package/src/template/{components → layouts}/ChangelogLayout.tsx +1 -1
  237. package/src/template/layouts/index.ts +1 -0
  238. package/src/template/lib/fetch-text.ts +13 -0
  239. package/src/template/lib/polen-url.ts +20 -0
  240. package/src/template/lib/schema-utils/constants.ts +4 -0
  241. package/src/template/lib/schema-utils/schema-utils.ts +42 -0
  242. package/src/template/routes/changelog.tsx +19 -10
  243. package/src/template/routes/index.tsx +2 -2
  244. package/src/template/routes/pages.tsx +109 -0
  245. package/src/template/routes/reference.tsx +112 -12
  246. package/src/template/routes/root.tsx +11 -112
  247. package/src/template/server/app.ts +47 -14
  248. package/src/template/server/main.ts +9 -1
  249. package/src/template/server/ssg/generate.ts +2 -2
  250. package/src/template/server/ssg/get-route-paths.test.ts +132 -0
  251. package/src/template/server/ssg/get-route-paths.ts +91 -27
  252. package/src/template/sources/schema-source.ts +69 -0
  253. package/build/lib/graphql-document/$$.d.ts +0 -5
  254. package/build/lib/graphql-document/$$.d.ts.map +0 -1
  255. package/build/lib/graphql-document/$$.js +0 -5
  256. package/build/lib/graphql-document/$$.js.map +0 -1
  257. package/build/lib/graphql-document/$.d.ts +0 -2
  258. package/build/lib/graphql-document/$.d.ts.map +0 -1
  259. package/build/lib/graphql-document/$.js +0 -2
  260. package/build/lib/graphql-document/$.js.map +0 -1
  261. package/build/lib/graphql-document/analysis.d.ts +0 -44
  262. package/build/lib/graphql-document/analysis.d.ts.map +0 -1
  263. package/build/lib/graphql-document/analysis.js +0 -361
  264. package/build/lib/graphql-document/analysis.js.map +0 -1
  265. package/build/lib/graphql-document/components/GraphQLDocument.d.ts +0 -38
  266. package/build/lib/graphql-document/components/GraphQLDocument.d.ts.map +0 -1
  267. package/build/lib/graphql-document/components/GraphQLDocument.js +0 -151
  268. package/build/lib/graphql-document/components/GraphQLDocument.js.map +0 -1
  269. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts +0 -7
  270. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts.map +0 -1
  271. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js +0 -27
  272. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js.map +0 -1
  273. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts +0 -33
  274. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts.map +0 -1
  275. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js +0 -50
  276. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js.map +0 -1
  277. package/build/lib/graphql-document/components/IdentifierLink.d.ts +0 -39
  278. package/build/lib/graphql-document/components/IdentifierLink.d.ts.map +0 -1
  279. package/build/lib/graphql-document/components/IdentifierLink.js +0 -75
  280. package/build/lib/graphql-document/components/IdentifierLink.js.map +0 -1
  281. package/build/lib/graphql-document/components/graphql-document-styles.d.ts +0 -5
  282. package/build/lib/graphql-document/components/graphql-document-styles.d.ts.map +0 -1
  283. package/build/lib/graphql-document/components/graphql-document-styles.js +0 -144
  284. package/build/lib/graphql-document/components/graphql-document-styles.js.map +0 -1
  285. package/build/lib/graphql-document/components/index.d.ts +0 -5
  286. package/build/lib/graphql-document/components/index.d.ts.map +0 -1
  287. package/build/lib/graphql-document/components/index.js +0 -5
  288. package/build/lib/graphql-document/components/index.js.map +0 -1
  289. package/build/lib/graphql-document/example.d.ts +0 -25
  290. package/build/lib/graphql-document/example.d.ts.map +0 -1
  291. package/build/lib/graphql-document/example.js +0 -140
  292. package/build/lib/graphql-document/example.js.map +0 -1
  293. package/build/lib/graphql-document/graphql-document.d.ts +0 -35
  294. package/build/lib/graphql-document/graphql-document.d.ts.map +0 -1
  295. package/build/lib/graphql-document/graphql-document.js +0 -36
  296. package/build/lib/graphql-document/graphql-document.js.map +0 -1
  297. package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts +0 -43
  298. package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts.map +0 -1
  299. package/build/lib/graphql-document/hooks/use-tooltip-state.js +0 -132
  300. package/build/lib/graphql-document/hooks/use-tooltip-state.js.map +0 -1
  301. package/build/lib/graphql-document/positioning-simple.d.ts +0 -63
  302. package/build/lib/graphql-document/positioning-simple.d.ts.map +0 -1
  303. package/build/lib/graphql-document/positioning-simple.js +0 -185
  304. package/build/lib/graphql-document/positioning-simple.js.map +0 -1
  305. package/build/lib/graphql-document/schema-context.d.ts +0 -8
  306. package/build/lib/graphql-document/schema-context.d.ts.map +0 -1
  307. package/build/lib/graphql-document/schema-context.js +0 -11
  308. package/build/lib/graphql-document/schema-context.js.map +0 -1
  309. package/build/lib/graphql-document/schema-integration.d.ts +0 -135
  310. package/build/lib/graphql-document/schema-integration.d.ts.map +0 -1
  311. package/build/lib/graphql-document/schema-integration.js +0 -328
  312. package/build/lib/graphql-document/schema-integration.js.map +0 -1
  313. package/build/lib/graphql-document/types.d.ts +0 -117
  314. package/build/lib/graphql-document/types.d.ts.map +0 -1
  315. package/build/lib/graphql-document/types.js +0 -2
  316. package/build/lib/graphql-document/types.js.map +0 -1
  317. package/build/template/components/ChangelogLayout.d.ts.map +0 -1
  318. package/build/template/components/ChangelogLayout.js.map +0 -1
  319. package/build/template/components/CodeHikePre.d.ts +0 -16
  320. package/build/template/components/CodeHikePre.d.ts.map +0 -1
  321. package/build/template/components/CodeHikePre.js +0 -37
  322. package/build/template/components/CodeHikePre.js.map +0 -1
  323. package/build/template/routes/reference.$type.$field.d.ts +0 -5
  324. package/build/template/routes/reference.$type.$field.d.ts.map +0 -1
  325. package/build/template/routes/reference.$type.$field.js +0 -31
  326. package/build/template/routes/reference.$type.$field.js.map +0 -1
  327. package/build/template/routes/reference.$type.d.ts +0 -5
  328. package/build/template/routes/reference.$type.d.ts.map +0 -1
  329. package/build/template/routes/reference.$type.js +0 -23
  330. package/build/template/routes/reference.$type.js.map +0 -1
  331. package/src/lib/graphql-document/$$.ts +0 -4
  332. package/src/lib/graphql-document/$.test.ts +0 -132
  333. package/src/lib/graphql-document/$.ts +0 -1
  334. package/src/lib/graphql-document/README.md +0 -102
  335. package/src/lib/graphql-document/analysis.ts +0 -415
  336. package/src/lib/graphql-document/components/GraphQLDocument.tsx +0 -265
  337. package/src/lib/graphql-document/components/GraphQLDocument.unit.test.ts +0 -188
  338. package/src/lib/graphql-document/components/GraphQLDocumentWithSchema.tsx +0 -46
  339. package/src/lib/graphql-document/components/GraphQLIdentifierPopover.tsx +0 -199
  340. package/src/lib/graphql-document/components/IdentifierLink.tsx +0 -160
  341. package/src/lib/graphql-document/components/graphql-document-styles.ts +0 -144
  342. package/src/lib/graphql-document/components/index.ts +0 -4
  343. package/src/lib/graphql-document/demo.md +0 -155
  344. package/src/lib/graphql-document/example.ts +0 -163
  345. package/src/lib/graphql-document/graphql-document.ts +0 -37
  346. package/src/lib/graphql-document/hooks/use-tooltip-state.test.ts +0 -76
  347. package/src/lib/graphql-document/hooks/use-tooltip-state.ts +0 -191
  348. package/src/lib/graphql-document/positioning-simple.test.ts +0 -248
  349. package/src/lib/graphql-document/positioning-simple.ts +0 -260
  350. package/src/lib/graphql-document/schema-context.tsx +0 -20
  351. package/src/lib/graphql-document/schema-integration.test.ts +0 -365
  352. package/src/lib/graphql-document/schema-integration.ts +0 -488
  353. package/src/lib/graphql-document/types.ts +0 -129
  354. package/src/template/components/CodeHikePre.tsx +0 -51
  355. package/src/template/routes/reference.$type.$field.tsx +0 -34
  356. package/src/template/routes/reference.$type.tsx +0 -27
  357. /package/build/template/{components → layouts}/ChangelogLayout.d.ts +0 -0
@@ -0,0 +1,213 @@
1
+ import { Grafaid } from '#lib/grafaid/index'
2
+ import { GraphqlChange } from '#lib/graphql-change/index'
3
+ import type { GraphqlChangeset } from '#lib/graphql-changeset/index'
4
+ import { GraphqlSchemaLoader } from '#lib/graphql-schema-loader/index'
5
+ import { Fs, Json, Path } from '@wollybeard/kit'
6
+ import type { NonEmptyChangeSets, SchemaReadResult } from '../../schema.js'
7
+
8
+ /**
9
+ * Configuration for loading schema via GraphQL introspection.
10
+ *
11
+ * Polen supports two introspection features:
12
+ * 1. **File Convention**: Automatically detects `schema.introspection.json` if present
13
+ * 2. **Automatic Introspection**: Fetches from your endpoint and creates the file
14
+ *
15
+ * When configured, Polen will:
16
+ * - Execute the standard GraphQL introspection query against your endpoint
17
+ * - Save the result to `schema.introspection.json` in your project root
18
+ * - Use this cached file for subsequent builds (no network requests)
19
+ *
20
+ * The saved file contains a standard GraphQL introspection query result as defined
21
+ * in the GraphQL specification, making it compatible with any tool that works with
22
+ * introspection data (GraphQL Codegen, Apollo CLI, etc.).
23
+ *
24
+ * To refresh the schema, delete `schema.introspection.json` and rebuild.
25
+ *
26
+ * **Technical details**:
27
+ * - Uses Graffle's introspection extension
28
+ * - Performs the full introspection query (all types, fields, descriptions, etc.)
29
+ * - No customization of the query is currently supported
30
+ *
31
+ * @see https://spec.graphql.org/draft/#sec-Introspection - GraphQL Introspection spec
32
+ * @see https://github.com/graphql/graphql-js/blob/main/src/utilities/getIntrospectionQuery.ts - Reference implementation
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * // Basic introspection
37
+ * introspection: {
38
+ * url: 'https://api.example.com/graphql'
39
+ * }
40
+ *
41
+ * // With authentication
42
+ * introspection: {
43
+ * url: 'https://api.example.com/graphql',
44
+ * headers: {
45
+ * 'Authorization': `Bearer ${process.env.API_TOKEN}`
46
+ * }
47
+ * }
48
+ * ```
49
+ */
50
+ export interface ConfigInput {
51
+ /**
52
+ * The GraphQL endpoint URL to introspect.
53
+ *
54
+ * Must be a valid GraphQL endpoint that supports introspection queries.
55
+ *
56
+ * @example 'https://api.example.com/graphql'
57
+ */
58
+ url?: string
59
+ /**
60
+ * Optional headers to include in the introspection request.
61
+ *
62
+ * Use this for authentication, API keys, or any custom headers
63
+ * required by your GraphQL endpoint.
64
+ *
65
+ * @example
66
+ * ```ts
67
+ * headers: {
68
+ * 'Authorization': `Bearer ${process.env.API_TOKEN}`,
69
+ * 'X-API-Key': process.env.API_KEY
70
+ * }
71
+ * ```
72
+ */
73
+ headers?: Record<string, string>
74
+ projectRoot?: string
75
+ }
76
+
77
+ export interface Config {
78
+ url: string
79
+ headers?: Record<string, string>
80
+ projectRoot: string
81
+ }
82
+
83
+ export const normalizeConfig = (configInput: ConfigInput): Config => {
84
+ if (!configInput.url) {
85
+ throw new Error(`Introspection data source requires a URL`)
86
+ }
87
+
88
+ if (!configInput.projectRoot) {
89
+ throw new Error(`Introspection data source requires a projectRoot`)
90
+ }
91
+
92
+ const config: Config = {
93
+ url: configInput.url,
94
+ headers: configInput.headers,
95
+ projectRoot: configInput.projectRoot,
96
+ }
97
+
98
+ return config
99
+ }
100
+
101
+ const INTROSPECTION_FILE_NAME = `schema.introspection.json`
102
+
103
+ const getIntrospectionFilePath = (projectRoot: string) => {
104
+ return Path.join(projectRoot, INTROSPECTION_FILE_NAME)
105
+ }
106
+
107
+ export const readOrThrow = async (
108
+ configInput: ConfigInput,
109
+ ): Promise<SchemaReadResult> => {
110
+ const config = normalizeConfig(configInput)
111
+ const introspectionFilePath = getIntrospectionFilePath(config.projectRoot)
112
+
113
+ // Check if introspection file exists
114
+ const introspectionFileContent = await Fs.read(introspectionFilePath)
115
+ let schema: Grafaid.Schema.Schema
116
+
117
+ if (introspectionFileContent) {
118
+ // Load from existing file - no reCreate capability
119
+ try {
120
+ const introspectionData = Json.codec.decode(introspectionFileContent)
121
+
122
+ // Validate introspection data structure before passing to fromIntrospectionQuery
123
+ if (!introspectionData || typeof introspectionData !== 'object') {
124
+ throw new Error('Introspection data must be a valid JSON object')
125
+ }
126
+
127
+ // Allow fromIntrospectionQuery to handle validation of the introspection format
128
+ // It will provide more specific GraphQL-related error messages
129
+ if (!('data' in introspectionData)) {
130
+ throw new Error(
131
+ 'Introspection data missing required "data" property (expected GraphQL introspection result format)',
132
+ )
133
+ }
134
+
135
+ schema = Grafaid.Schema.fromIntrospectionQuery(introspectionData as any)
136
+ } catch (error) {
137
+ if (error instanceof SyntaxError) {
138
+ throw new Error(`Invalid JSON in ${introspectionFilePath}: ${error.message}`)
139
+ } else {
140
+ throw new Error(
141
+ `Invalid introspection data in ${introspectionFilePath}: ${
142
+ error instanceof Error ? error.message : String(error)
143
+ }. Delete this file to fetch fresh introspection data.`,
144
+ )
145
+ }
146
+ }
147
+
148
+ const schemaData = await createSingleSchemaChangeset(schema)
149
+ return {
150
+ data: schemaData,
151
+ source: { type: 'introspectionFile' },
152
+ }
153
+ } else {
154
+ // Fetch via introspection - can reCreate
155
+ const introspectionResult = await GraphqlSchemaLoader.load({
156
+ type: `introspect`,
157
+ url: config.url,
158
+ headers: config.headers,
159
+ })
160
+
161
+ schema = introspectionResult
162
+
163
+ // Get the raw introspection result for saving
164
+ const __schema = Grafaid.Schema.toIntrospectionQuery(schema)
165
+
166
+ // Wrap in GraphQL response format for consistency with API responses
167
+ const introspectionData = { data: { __schema } }
168
+
169
+ // Write to file
170
+ await Fs.write({
171
+ path: introspectionFilePath,
172
+ content: Json.codec.encode(introspectionData as any),
173
+ })
174
+
175
+ const schemaData = await createSingleSchemaChangeset(schema)
176
+ return {
177
+ data: schemaData,
178
+ source: {
179
+ type: 'introspectionAuto',
180
+ reCreate: async () => {
181
+ // Re-fetch using captured config - capture closure
182
+ const result = await readOrThrow(configInput)
183
+ return result.data
184
+ },
185
+ },
186
+ }
187
+ }
188
+ }
189
+
190
+ /**
191
+ * Create a single changeset from a schema object.
192
+ * This is the core logic for handling single (unversioned) schemas from introspection.
193
+ */
194
+ export const createSingleSchemaChangeset = async (schema: Grafaid.Schema.Schema): Promise<NonEmptyChangeSets> => {
195
+ const date = new Date() // Generate date here for unversioned schema
196
+ const after = schema
197
+ const before = Grafaid.Schema.empty
198
+ const changes = await GraphqlChange.calcChangeset({
199
+ before,
200
+ after,
201
+ })
202
+
203
+ const changeset: GraphqlChangeset.ChangeSet = {
204
+ date,
205
+ after,
206
+ before,
207
+ changes,
208
+ }
209
+
210
+ const result: NonEmptyChangeSets = [changeset]
211
+
212
+ return result
213
+ }
@@ -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'
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
+ }