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
@@ -1,488 +0,0 @@
1
- /**
2
- * Layer 2: Schema Integration
3
- *
4
- * Bridge between GraphQL analysis and Polen's schema system.
5
- * Resolves identifiers against the actual schema, extracts documentation,
6
- * and generates reference URLs for navigation.
7
- */
8
-
9
- import {
10
- getNamedType,
11
- type GraphQLField,
12
- type GraphQLInputField,
13
- type GraphQLSchema,
14
- type GraphQLType,
15
- isInputObjectType,
16
- isInterfaceType,
17
- isListType,
18
- isNonNullType,
19
- isObjectType,
20
- } from 'graphql'
21
- import { analyze } from './analysis.js'
22
- import type { Identifier } from './types.js'
23
-
24
- /**
25
- * Documentation extracted from GraphQL schema
26
- */
27
- export interface Documentation {
28
- /** Description from schema SDL or introspection */
29
- description?: string
30
- /** Type signature (e.g., "String!", "[User!]!") */
31
- typeInfo: string
32
- /** Whether this field/type is deprecated */
33
- deprecated?: {
34
- reason: string
35
- replacement?: string
36
- }
37
- /** Default value for arguments */
38
- defaultValue?: string
39
- }
40
-
41
- /**
42
- * Result of resolving an identifier against the schema
43
- */
44
- export interface SchemaResolution {
45
- /** Whether the identifier exists in the schema */
46
- exists: boolean
47
- /** Documentation extracted from schema */
48
- documentation?: Documentation
49
- /** URL to the reference page for this identifier */
50
- referenceUrl: string
51
- /** Whether this identifier is deprecated */
52
- deprecated?: {
53
- reason: string
54
- replacement?: string
55
- }
56
- /** The GraphQL type if this is a type identifier */
57
- graphqlType?: GraphQLType
58
- }
59
-
60
- /**
61
- * Interface for resolving GraphQL identifiers against a schema
62
- */
63
- export interface SchemaResolver {
64
- /**
65
- * Resolve an identifier against the schema
66
- */
67
- resolveIdentifier(identifier: Identifier): SchemaResolution | null
68
-
69
- /**
70
- * Get documentation for a schema path
71
- */
72
- getDocumentation(schemaPath: string[]): Documentation | null
73
-
74
- /**
75
- * Generate a reference URL for a schema path
76
- */
77
- generateReferenceLink(schemaPath: string[]): string
78
-
79
- /**
80
- * Check if a type exists in the schema
81
- */
82
- typeExists(typeName: string): boolean
83
-
84
- /**
85
- * Get all available types for validation
86
- */
87
- getAllTypes(): string[]
88
- }
89
-
90
- /**
91
- * Configuration for URL generation
92
- */
93
- export interface RouteConfig {
94
- /** Base path for reference pages (default: "/reference") */
95
- basePath?: string
96
- /** Whether to include fragments in URLs (default: true) */
97
- includeFragments?: boolean
98
- }
99
-
100
- /**
101
- * Polen's implementation of SchemaResolver
102
- */
103
- export class PolenSchemaResolver implements SchemaResolver {
104
- constructor(
105
- private schema: GraphQLSchema,
106
- private routeConfig: RouteConfig = {},
107
- ) {}
108
-
109
- /**
110
- * Resolve an identifier against the schema
111
- */
112
- resolveIdentifier(identifier: Identifier): SchemaResolution | null {
113
- const basePath = this.routeConfig.basePath || `/reference`
114
-
115
- switch (identifier.kind) {
116
- case `Type`:
117
- return this.resolveType(identifier, basePath)
118
-
119
- case `Field`:
120
- return this.resolveField(identifier, basePath)
121
-
122
- case `Argument`:
123
- return this.resolveArgument(identifier, basePath)
124
-
125
- case `Variable`:
126
- // Variables don't have schema resolution
127
- return {
128
- exists: true,
129
- referenceUrl: `${basePath}#variables`,
130
- documentation: {
131
- typeInfo: `Variable`,
132
- description: `Query variable: $${identifier.name}`,
133
- },
134
- }
135
-
136
- case `Directive`:
137
- return this.resolveDirective(identifier, basePath)
138
-
139
- case `Fragment`:
140
- // Fragments don't have schema resolution
141
- return {
142
- exists: true,
143
- referenceUrl: `${basePath}#fragments`,
144
- documentation: {
145
- typeInfo: `Fragment`,
146
- description: `Fragment: ${identifier.name}`,
147
- },
148
- }
149
-
150
- default:
151
- return null
152
- }
153
- }
154
-
155
- /**
156
- * Get documentation for a schema path
157
- */
158
- getDocumentation(schemaPath: string[]): Documentation | null {
159
- if (schemaPath.length === 0) return null
160
-
161
- const [typeName, fieldName, argName] = schemaPath
162
-
163
- if (!typeName) return null
164
-
165
- const type = this.schema.getType(typeName)
166
- if (!type) return null
167
-
168
- // Type-level documentation
169
- if (schemaPath.length === 1) {
170
- return {
171
- typeInfo: this.getTypeSignature(type),
172
- description: type.description || undefined,
173
- deprecated: `deprecationReason` in type
174
- ? {
175
- reason: (type as any).deprecationReason,
176
- }
177
- : undefined,
178
- }
179
- }
180
-
181
- // Field-level documentation
182
- if (fieldName && schemaPath.length === 2) {
183
- const field = this.getFieldFromType(type, fieldName)
184
- if (!field) return null
185
-
186
- return {
187
- typeInfo: this.getTypeSignature(field.type),
188
- description: field.description || undefined,
189
- deprecated: field.deprecationReason
190
- ? {
191
- reason: field.deprecationReason,
192
- }
193
- : undefined,
194
- }
195
- }
196
-
197
- // Argument-level documentation
198
- if (fieldName && argName && schemaPath.length === 3) {
199
- const field = this.getFieldFromType(type, fieldName)
200
- if (!field || !(`args` in field)) return null
201
-
202
- const arg = field.args.find((a: any) => a.name === argName)
203
- if (!arg) return null
204
-
205
- return {
206
- typeInfo: this.getTypeSignature(arg.type),
207
- description: arg.description || undefined,
208
- defaultValue: arg.defaultValue !== undefined
209
- ? String(arg.defaultValue)
210
- : undefined,
211
- }
212
- }
213
-
214
- return null
215
- }
216
-
217
- /**
218
- * Generate a reference URL for a schema path
219
- */
220
- generateReferenceLink(schemaPath: string[]): string {
221
- const basePath = this.routeConfig.basePath || `/reference`
222
- const includeFragments = this.routeConfig.includeFragments !== false
223
-
224
- if (schemaPath.length === 0) return basePath
225
-
226
- const [typeName, fieldName, argName] = schemaPath
227
-
228
- // Type reference
229
- if (schemaPath.length === 1) {
230
- return `${basePath}/${typeName}`
231
- }
232
-
233
- // Field reference
234
- if (fieldName && schemaPath.length === 2) {
235
- const fragment = includeFragments ? `#${fieldName}` : ``
236
- return `${basePath}/${typeName}${fragment}`
237
- }
238
-
239
- // Argument reference
240
- if (fieldName && argName && schemaPath.length === 3) {
241
- const fragment = includeFragments ? `#${fieldName}-${argName}` : ``
242
- return `${basePath}/${typeName}${fragment}`
243
- }
244
-
245
- return `${basePath}/${typeName}`
246
- }
247
-
248
- /**
249
- * Check if a type exists in the schema
250
- */
251
- typeExists(typeName: string): boolean {
252
- return !!this.schema.getType(typeName)
253
- }
254
-
255
- /**
256
- * Get all available types for validation
257
- */
258
- getAllTypes(): string[] {
259
- return Object.keys(this.schema.getTypeMap())
260
- .filter(name => !name.startsWith(`__`)) // Filter out introspection types
261
- }
262
-
263
- // Private helper methods
264
-
265
- private resolveType(identifier: Identifier, basePath: string): SchemaResolution {
266
- const type = this.schema.getType(identifier.name)
267
-
268
- return {
269
- exists: !!type,
270
- graphqlType: type || undefined,
271
- referenceUrl: `${basePath}/${identifier.name}`,
272
- documentation: type
273
- ? {
274
- typeInfo: this.getTypeSignature(type),
275
- description: type.description || undefined,
276
- }
277
- : undefined,
278
- }
279
- }
280
-
281
- private resolveField(identifier: Identifier, basePath: string): SchemaResolution {
282
- if (!identifier.parentType) {
283
- return {
284
- exists: false,
285
- referenceUrl: `${basePath}#${identifier.name}`,
286
- }
287
- }
288
-
289
- const parentType = this.schema.getType(identifier.parentType)
290
- if (!parentType) {
291
- return {
292
- exists: false,
293
- referenceUrl: `${basePath}/${identifier.parentType}#${identifier.name}`,
294
- }
295
- }
296
-
297
- const field = this.getFieldFromType(parentType, identifier.name)
298
-
299
- return {
300
- exists: !!field,
301
- referenceUrl: `${basePath}/${identifier.parentType}#${identifier.name}`,
302
- documentation: field
303
- ? {
304
- typeInfo: this.getTypeSignature(field.type),
305
- description: field.description || undefined,
306
- deprecated: field.deprecationReason
307
- ? {
308
- reason: field.deprecationReason,
309
- }
310
- : undefined,
311
- }
312
- : undefined,
313
- deprecated: field?.deprecationReason
314
- ? {
315
- reason: field.deprecationReason,
316
- }
317
- : undefined,
318
- }
319
- }
320
-
321
- private resolveArgument(identifier: Identifier, basePath: string): SchemaResolution {
322
- const schemaPath = identifier.schemaPath
323
- if (schemaPath.length < 3) {
324
- return {
325
- exists: false,
326
- referenceUrl: `${basePath}#${identifier.name}`,
327
- }
328
- }
329
-
330
- const [typeName, fieldName] = schemaPath
331
- if (!typeName || !fieldName) {
332
- return {
333
- exists: false,
334
- referenceUrl: `${basePath}#${identifier.name}`,
335
- }
336
- }
337
-
338
- const parentType = this.schema.getType(typeName)
339
- if (!parentType) {
340
- return {
341
- exists: false,
342
- referenceUrl: `${basePath}/${typeName}#${fieldName}-${identifier.name}`,
343
- }
344
- }
345
-
346
- const field = this.getFieldFromType(parentType, fieldName)
347
- if (!field || !(`args` in field)) {
348
- return {
349
- exists: false,
350
- referenceUrl: `${basePath}/${typeName}#${fieldName}-${identifier.name}`,
351
- }
352
- }
353
-
354
- const arg = field.args.find((a: any) => a.name === identifier.name)
355
-
356
- return {
357
- exists: !!arg,
358
- referenceUrl: `${basePath}/${typeName}#${fieldName}-${identifier.name}`,
359
- documentation: arg
360
- ? {
361
- typeInfo: this.getTypeSignature(arg.type),
362
- description: arg.description || undefined,
363
- defaultValue: arg.defaultValue !== undefined
364
- ? String(arg.defaultValue)
365
- : undefined,
366
- }
367
- : undefined,
368
- }
369
- }
370
-
371
- private resolveDirective(identifier: Identifier, basePath: string): SchemaResolution {
372
- const directive = this.schema.getDirective(identifier.name)
373
-
374
- return {
375
- exists: !!directive,
376
- referenceUrl: `${basePath}/directives#${identifier.name}`,
377
- documentation: directive
378
- ? {
379
- typeInfo: `Directive`,
380
- description: directive.description || undefined,
381
- }
382
- : undefined,
383
- }
384
- }
385
-
386
- private getFieldFromType(type: GraphQLType, fieldName: string): GraphQLField<any, any> | GraphQLInputField | null {
387
- if (isObjectType(type) || isInterfaceType(type)) {
388
- return type.getFields()[fieldName] || null
389
- }
390
-
391
- if (isInputObjectType(type)) {
392
- return type.getFields()[fieldName] || null
393
- }
394
-
395
- return null
396
- }
397
-
398
- private getTypeSignature(type: GraphQLType): string {
399
- if (isNonNullType(type)) {
400
- return `${this.getTypeSignature(type.ofType)}!`
401
- }
402
-
403
- if (isListType(type)) {
404
- return `[${this.getTypeSignature(type.ofType)}]`
405
- }
406
-
407
- return getNamedType(type).name
408
- }
409
- }
410
-
411
- /**
412
- * Create a schema resolver for Polen
413
- */
414
- export const createPolenSchemaResolver = (
415
- schema: GraphQLSchema,
416
- routeConfig?: RouteConfig,
417
- ): SchemaResolver => {
418
- return new PolenSchemaResolver(schema, routeConfig)
419
- }
420
-
421
- /**
422
- * Enhanced analysis result with schema resolution
423
- */
424
- export interface SchemaAwareAnalysisResult {
425
- /** Original analysis result */
426
- analysis: import('./types.js').AnalysisResult
427
- /** Schema resolutions for all identifiers */
428
- resolutions: Map<string, SchemaResolution>
429
- /** Validation errors from schema checking */
430
- schemaErrors: {
431
- identifier: Identifier
432
- message: string
433
- severity: `error` | `warning`
434
- }[]
435
- }
436
-
437
- /**
438
- * Perform schema-aware analysis of a GraphQL document
439
- */
440
- export const analyzeWithSchema = (
441
- source: string,
442
- schema: GraphQLSchema,
443
- routeConfig?: RouteConfig,
444
- ): SchemaAwareAnalysisResult => {
445
- const analysis = analyze(source, {
446
- schema,
447
- validateAgainstSchema: true,
448
- includePositions: true,
449
- })
450
-
451
- const resolver = createPolenSchemaResolver(schema, routeConfig)
452
- const resolutions = new Map<string, SchemaResolution>()
453
- const schemaErrors: SchemaAwareAnalysisResult[`schemaErrors`] = []
454
-
455
- // Resolve all identifiers against schema
456
- for (const identifier of analysis.identifiers.all) {
457
- const key = `${identifier.position.start}-${identifier.name}-${identifier.kind}`
458
- const resolution = resolver.resolveIdentifier(identifier)
459
-
460
- if (resolution) {
461
- resolutions.set(key, resolution)
462
-
463
- // Add validation errors for non-existent identifiers
464
- if (!resolution.exists && (identifier.kind === `Type` || identifier.kind === `Field`)) {
465
- schemaErrors.push({
466
- identifier,
467
- message: `${identifier.kind} "${identifier.name}" does not exist in schema`,
468
- severity: `error`,
469
- })
470
- }
471
-
472
- // Add deprecation warnings
473
- if (resolution.deprecated) {
474
- schemaErrors.push({
475
- identifier,
476
- message: `${identifier.kind} "${identifier.name}" is deprecated: ${resolution.deprecated.reason}`,
477
- severity: `warning`,
478
- })
479
- }
480
- }
481
- }
482
-
483
- return {
484
- analysis,
485
- resolutions,
486
- schemaErrors,
487
- }
488
- }
@@ -1,129 +0,0 @@
1
- import type { DocumentNode, GraphQLError, GraphQLSchema } from 'graphql'
2
-
3
- /**
4
- * Represents a GraphQL identifier found in a document
5
- */
6
- export interface Identifier {
7
- /** The name of the identifier (e.g., 'User', 'name', 'id') */
8
- name: string
9
- /** The kind of GraphQL construct this identifier represents */
10
- kind: `Type` | `Field` | `Argument` | `Directive` | `Variable` | `Fragment`
11
- /** Position information in the source document */
12
- position: {
13
- /** Character offset from start of document */
14
- start: number
15
- /** Character offset for end of identifier */
16
- end: number
17
- /** Line number (1-based) */
18
- line: number
19
- /** Column number (1-based) */
20
- column: number
21
- }
22
- /** The parent type name if this is a field or argument */
23
- parentType?: string
24
- /** Path through the schema to this identifier (e.g., ['User', 'posts', 'title']) */
25
- schemaPath: string[]
26
- /** Context about where this identifier appears */
27
- context: IdentifierContext
28
- }
29
-
30
- /**
31
- * Additional context about where an identifier appears in the document
32
- */
33
- export interface IdentifierContext {
34
- /** The operation type if this identifier is within an operation */
35
- operationType?: `query` | `mutation` | `subscription`
36
- /** The operation name if this identifier is within a named operation */
37
- operationName?: string
38
- /** Whether this identifier is in a fragment definition */
39
- inFragment?: string
40
- /** The selection path leading to this identifier */
41
- selectionPath: string[]
42
- }
43
-
44
- /**
45
- * Map of all identifiers found in a GraphQL document
46
- */
47
- export interface IdentifierMap {
48
- /** Quick lookup by character position */
49
- byPosition: Map<number, Identifier>
50
- /** Grouped by identifier kind for easy filtering */
51
- byKind: Map<Identifier[`kind`], Identifier[]>
52
- /** Any validation errors found during analysis */
53
- errors: AnalysisError[]
54
- /** All identifiers as a flat array */
55
- all: Identifier[]
56
- }
57
-
58
- /**
59
- * Analysis error with context about the identifier that caused it
60
- */
61
- export interface AnalysisError {
62
- /** The identifier that caused the error (if applicable) */
63
- identifier?: Identifier
64
- /** Human-readable error message */
65
- message: string
66
- /** Error severity level */
67
- severity: `error` | `warning` | `info`
68
- /** Position in the document where the error occurred */
69
- position?: {
70
- line: number
71
- column: number
72
- }
73
- }
74
-
75
- /**
76
- * Result of analyzing a GraphQL document
77
- */
78
- export interface AnalysisResult {
79
- /** The parsed AST */
80
- ast: DocumentNode
81
- /** Map of all identifiers found */
82
- identifiers: IdentifierMap
83
- /** Whether the document parsed successfully */
84
- isValid: boolean
85
- /** Any parse or validation errors */
86
- errors: GraphQLError[]
87
- }
88
-
89
- /**
90
- * Configuration for GraphQL document analysis
91
- */
92
- export interface AnalysisConfig {
93
- /** Whether to include position information for identifiers */
94
- includePositions?: boolean
95
- /** Whether to validate against a schema (if provided) */
96
- validateAgainstSchema?: boolean
97
- /** Schema to validate against */
98
- schema?: GraphQLSchema
99
- /** Whether to extract fragment information */
100
- includeFragments?: boolean
101
- }
102
-
103
- /**
104
- * Interface for the main GraphQL analyzer
105
- */
106
- export interface GraphQLAnalyzer {
107
- /**
108
- * Parse a GraphQL document string into an AST
109
- */
110
- parse(source: string): DocumentNode
111
-
112
- /**
113
- * Extract all identifiers from a GraphQL AST
114
- */
115
- extractIdentifiers(ast: DocumentNode, config?: AnalysisConfig): IdentifierMap
116
-
117
- /**
118
- * Validate a GraphQL document against a schema
119
- */
120
- validateAgainstSchema(
121
- ast: DocumentNode,
122
- schema: GraphQLSchema,
123
- ): GraphQLError[]
124
-
125
- /**
126
- * Perform complete analysis of a GraphQL document
127
- */
128
- analyze(source: string, config?: AnalysisConfig): AnalysisResult
129
- }
@@ -1,51 +0,0 @@
1
- import { Pre as CodeHikePre } from 'codehike/code'
2
- import React from 'react'
3
- import { GraphQLDocument } from '../../lib/graphql-document/components/GraphQLDocument.js'
4
-
5
- type CodeHikePreProps = React.ComponentProps<typeof CodeHikePre>
6
- type HTMLPreProps = React.ComponentPropsWithoutRef<'pre'>
7
- type PreProps = CodeHikePreProps | HTMLPreProps
8
-
9
- /**
10
- * Custom Pre component that adds interactive GraphQL support to Code Hike
11
- *
12
- * Usage in MDX:
13
- * ```graphql interactive
14
- * query { ... }
15
- * ```
16
- */
17
- export const Pre: React.FC<PreProps> = (props) => {
18
- // Check if this is a Code Hike pre component (has 'code' prop)
19
- if ('code' in props && props.code) {
20
- const { code } = props
21
-
22
- // Check if this is an interactive GraphQL block
23
- if (code.lang === 'graphql' && code.meta?.includes('interactive')) {
24
- // Extract the GraphQL schema if available
25
- const schema = typeof window !== 'undefined'
26
- ? (window as any).__POLEN_GRAPHQL_SCHEMA__
27
- : null
28
-
29
- // For interactive GraphQL blocks, we need to apply Code Hike's styling
30
- // but add GraphQLDocument's interactive features
31
- return (
32
- <GraphQLDocument
33
- schema={schema}
34
- options={{
35
- className: 'ch-code-container',
36
- // Use Code Hike's Pre component for rendering
37
- renderCode: () => <CodeHikePre {...props as CodeHikePreProps} />,
38
- }}
39
- >
40
- {code.code}
41
- </GraphQLDocument>
42
- )
43
- }
44
-
45
- // For other Code Hike code blocks, use Code Hike's Pre
46
- return <CodeHikePre {...props as CodeHikePreProps} />
47
- }
48
-
49
- // For standard HTML pre elements, render as-is
50
- return <pre {...props as HTMLPreProps} />
51
- }