polen 0.10.0-next.11 → 0.10.0-next.13

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 (340) hide show
  1. package/build/api/builder/builder.js +1 -1
  2. package/build/api/builder/builder.js.map +1 -1
  3. package/build/api/config/load.js +1 -1
  4. package/build/api/config/load.js.map +1 -1
  5. package/build/api/vite/plugins/build.js +1 -1
  6. package/build/api/vite/plugins/build.js.map +1 -1
  7. package/build/api/vite/plugins/core.d.ts.map +1 -1
  8. package/build/api/vite/plugins/core.js +0 -2
  9. package/build/api/vite/plugins/core.js.map +1 -1
  10. package/build/api/vite/plugins/pages.js +1 -1
  11. package/build/api/vite/plugins/pages.js.map +1 -1
  12. package/build/exports/components.d.ts +4 -1
  13. package/build/exports/components.d.ts.map +1 -1
  14. package/build/exports/components.js +4 -1
  15. package/build/exports/components.js.map +1 -1
  16. package/build/lib/demos/config-schema.d.ts +6 -6
  17. package/build/lib/github-actions/runner.js +2 -2
  18. package/build/lib/github-actions/runner.js.map +1 -1
  19. package/build/lib/graphql-document/$$.d.ts +5 -0
  20. package/build/lib/graphql-document/$$.d.ts.map +1 -0
  21. package/build/lib/graphql-document/$$.js +5 -0
  22. package/build/lib/graphql-document/$$.js.map +1 -0
  23. package/build/lib/graphql-document/$.d.ts +2 -0
  24. package/build/lib/graphql-document/$.d.ts.map +1 -0
  25. package/build/lib/graphql-document/$.js +2 -0
  26. package/build/lib/graphql-document/$.js.map +1 -0
  27. package/build/lib/graphql-document/analysis.d.ts +44 -0
  28. package/build/lib/graphql-document/analysis.d.ts.map +1 -0
  29. package/build/lib/graphql-document/analysis.js +361 -0
  30. package/build/lib/graphql-document/analysis.js.map +1 -0
  31. package/build/lib/graphql-document/components/CopyButton.d.ts +19 -0
  32. package/build/lib/graphql-document/components/CopyButton.d.ts.map +1 -0
  33. package/build/lib/graphql-document/components/CopyButton.js +43 -0
  34. package/build/lib/graphql-document/components/CopyButton.js.map +1 -0
  35. package/build/lib/graphql-document/components/GraphQLDocument.d.ts +38 -0
  36. package/build/lib/graphql-document/components/GraphQLDocument.d.ts.map +1 -0
  37. package/build/lib/graphql-document/components/GraphQLDocument.js +130 -0
  38. package/build/lib/graphql-document/components/GraphQLDocument.js.map +1 -0
  39. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts +7 -0
  40. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.d.ts.map +1 -0
  41. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js +45 -0
  42. package/build/lib/graphql-document/components/GraphQLDocumentWithSchema.js.map +1 -0
  43. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts +33 -0
  44. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.d.ts.map +1 -0
  45. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js +48 -0
  46. package/build/lib/graphql-document/components/GraphQLIdentifierPopover.js.map +1 -0
  47. package/build/lib/graphql-document/components/IdentifierLink.d.ts +39 -0
  48. package/build/lib/graphql-document/components/IdentifierLink.d.ts.map +1 -0
  49. package/build/lib/graphql-document/components/IdentifierLink.js +75 -0
  50. package/build/lib/graphql-document/components/IdentifierLink.js.map +1 -0
  51. package/build/lib/graphql-document/components/graphql-document-styles.d.ts +5 -0
  52. package/build/lib/graphql-document/components/graphql-document-styles.d.ts.map +1 -0
  53. package/build/lib/graphql-document/components/graphql-document-styles.js +167 -0
  54. package/build/lib/graphql-document/components/graphql-document-styles.js.map +1 -0
  55. package/build/lib/graphql-document/components/index.d.ts +6 -0
  56. package/build/lib/graphql-document/components/index.d.ts.map +1 -0
  57. package/build/lib/graphql-document/components/index.js +6 -0
  58. package/build/lib/graphql-document/components/index.js.map +1 -0
  59. package/build/lib/graphql-document/example.d.ts +25 -0
  60. package/build/lib/graphql-document/example.d.ts.map +1 -0
  61. package/build/lib/graphql-document/example.js +140 -0
  62. package/build/lib/graphql-document/example.js.map +1 -0
  63. package/build/lib/graphql-document/graphql-document.d.ts +35 -0
  64. package/build/lib/graphql-document/graphql-document.d.ts.map +1 -0
  65. package/build/lib/graphql-document/graphql-document.js +36 -0
  66. package/build/lib/graphql-document/graphql-document.js.map +1 -0
  67. package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts +43 -0
  68. package/build/lib/graphql-document/hooks/use-tooltip-state.d.ts.map +1 -0
  69. package/build/lib/graphql-document/hooks/use-tooltip-state.js +132 -0
  70. package/build/lib/graphql-document/hooks/use-tooltip-state.js.map +1 -0
  71. package/build/lib/graphql-document/positioning-simple.d.ts +68 -0
  72. package/build/lib/graphql-document/positioning-simple.d.ts.map +1 -0
  73. package/build/lib/graphql-document/positioning-simple.js +197 -0
  74. package/build/lib/graphql-document/positioning-simple.js.map +1 -0
  75. package/build/lib/graphql-document/schema-context.d.ts +8 -0
  76. package/build/lib/graphql-document/schema-context.d.ts.map +1 -0
  77. package/build/lib/graphql-document/schema-context.js +11 -0
  78. package/build/lib/graphql-document/schema-context.js.map +1 -0
  79. package/build/lib/graphql-document/schema-integration-example.d.ts +27 -0
  80. package/build/lib/graphql-document/schema-integration-example.d.ts.map +1 -0
  81. package/build/lib/graphql-document/schema-integration-example.js +297 -0
  82. package/build/lib/graphql-document/schema-integration-example.js.map +1 -0
  83. package/build/lib/graphql-document/schema-integration.d.ts +135 -0
  84. package/build/lib/graphql-document/schema-integration.d.ts.map +1 -0
  85. package/build/lib/graphql-document/schema-integration.js +328 -0
  86. package/build/lib/graphql-document/schema-integration.js.map +1 -0
  87. package/build/lib/graphql-document/types.d.ts +117 -0
  88. package/build/lib/graphql-document/types.d.ts.map +1 -0
  89. package/build/lib/graphql-document/types.js +2 -0
  90. package/build/lib/graphql-document/types.js.map +1 -0
  91. package/build/template/components/ArgumentAnnotation.js +10 -0
  92. package/build/template/components/ArgumentAnnotation.js.map +1 -0
  93. package/build/template/components/ArgumentList.js +9 -0
  94. package/build/template/components/ArgumentList.js.map +1 -0
  95. package/build/template/components/ArgumentListAnnotation.js +15 -0
  96. package/build/template/components/ArgumentListAnnotation.js.map +1 -0
  97. package/build/template/components/Changelog.js +44 -0
  98. package/build/template/components/Changelog.js.map +1 -0
  99. package/build/template/components/{CodeBlock.jsx → CodeBlock.js} +4 -5
  100. package/build/template/components/{CodeBlock.jsx.map → CodeBlock.js.map} +1 -1
  101. package/build/template/components/{CodeBlockEnhancer.jsx → CodeBlockEnhancer.js} +4 -4
  102. package/build/template/components/CodeBlockEnhancer.js.map +1 -0
  103. package/build/template/components/DeprecationReason.js +9 -0
  104. package/build/template/components/DeprecationReason.js.map +1 -0
  105. package/build/template/components/Description.js +9 -0
  106. package/build/template/components/Description.js.map +1 -0
  107. package/build/template/components/Field.js +14 -0
  108. package/build/template/components/Field.js.map +1 -0
  109. package/build/template/components/{FieldList.jsx → FieldList.js} +4 -5
  110. package/build/template/components/FieldList.js.map +1 -0
  111. package/build/template/components/{FieldListSection.jsx → FieldListSection.js} +4 -6
  112. package/build/template/components/FieldListSection.js.map +1 -0
  113. package/build/template/components/HamburgerMenu.js +30 -0
  114. package/build/template/components/HamburgerMenu.js.map +1 -0
  115. package/build/template/components/Link.d.ts +1 -1
  116. package/build/template/components/{Link.jsx → Link.js} +4 -5
  117. package/build/template/components/Link.js.map +1 -0
  118. package/build/template/components/Logo.js +20 -0
  119. package/build/template/components/Logo.js.map +1 -0
  120. package/build/template/components/MDXComponents.d.ts +11 -0
  121. package/build/template/components/MDXComponents.d.ts.map +1 -0
  122. package/build/template/components/MDXComponents.js +70 -0
  123. package/build/template/components/MDXComponents.js.map +1 -0
  124. package/build/template/components/{Markdown.jsx → Markdown.js} +3 -2
  125. package/build/template/components/Markdown.js.map +1 -0
  126. package/build/template/components/MissingSchema.d.ts +1 -1
  127. package/build/template/components/MissingSchema.d.ts.map +1 -1
  128. package/build/template/components/MissingSchema.js +5 -0
  129. package/build/template/components/MissingSchema.js.map +1 -0
  130. package/build/template/components/NamedType.js +12 -0
  131. package/build/template/components/NamedType.js.map +1 -0
  132. package/build/template/components/NotFound.js +7 -0
  133. package/build/template/components/NotFound.js.map +1 -0
  134. package/build/template/components/{RadixLink.jsx → RadixLink.js} +1 -1
  135. package/build/template/components/RadixLink.js.map +1 -0
  136. package/build/template/components/TestComponent.d.ts +5 -0
  137. package/build/template/components/TestComponent.d.ts.map +1 -0
  138. package/build/template/components/TestComponent.js +7 -0
  139. package/build/template/components/TestComponent.js.map +1 -0
  140. package/build/template/components/Texts/{MinorHeading.jsx → MinorHeading.js} +4 -3
  141. package/build/template/components/Texts/MinorHeading.js.map +1 -0
  142. package/build/template/components/Texts/texts.js +1 -1
  143. package/build/template/components/Texts/texts.js.map +1 -1
  144. package/build/template/components/ThemeToggle.js +9 -0
  145. package/build/template/components/ThemeToggle.js.map +1 -0
  146. package/build/template/components/{TypeAnnotation.jsx → TypeAnnotation.js} +8 -18
  147. package/build/template/components/TypeAnnotation.js.map +1 -0
  148. package/build/template/components/TypeFieldsLinkList.js +9 -0
  149. package/build/template/components/TypeFieldsLinkList.js.map +1 -0
  150. package/build/template/components/TypeIndex.js +17 -0
  151. package/build/template/components/TypeIndex.js.map +1 -0
  152. package/build/template/components/content/$$.d.ts +1 -0
  153. package/build/template/components/content/$$.d.ts.map +1 -1
  154. package/build/template/components/content/$$.js +1 -0
  155. package/build/template/components/content/$$.js.map +1 -1
  156. package/build/template/components/content/GraphQLDocumentWithSchema.d.ts +8 -0
  157. package/build/template/components/content/GraphQLDocumentWithSchema.d.ts.map +1 -0
  158. package/build/template/components/content/GraphQLDocumentWithSchema.js +16 -0
  159. package/build/template/components/content/GraphQLDocumentWithSchema.js.map +1 -0
  160. package/build/template/components/content/GraphQLDocumentWrapper.d.ts +7 -0
  161. package/build/template/components/content/GraphQLDocumentWrapper.d.ts.map +1 -0
  162. package/build/template/components/content/GraphQLDocumentWrapper.js +62 -0
  163. package/build/template/components/content/GraphQLDocumentWrapper.js.map +1 -0
  164. package/build/template/components/graphql/graphql.d.ts +2 -2
  165. package/build/template/components/graphql/graphql.js +3 -0
  166. package/build/template/components/graphql/graphql.js.map +1 -0
  167. package/build/template/components/graphql/index.d.ts +1 -1
  168. package/build/template/components/graphql/index.js +1 -1
  169. package/build/template/components/graphql/index.js.map +1 -1
  170. package/build/template/components/graphql/{type-kind-icon.jsx → type-kind-icon.js} +3 -2
  171. package/build/template/components/graphql/type-kind-icon.js.map +1 -0
  172. package/build/template/components/graphql/type-link.js +11 -0
  173. package/build/template/components/graphql/type-link.js.map +1 -0
  174. package/build/template/components/sidebar/Sidebar.d.ts +1 -1
  175. package/build/template/components/sidebar/Sidebar.d.ts.map +1 -1
  176. package/build/template/components/sidebar/Sidebar.js +11 -0
  177. package/build/template/components/sidebar/Sidebar.js.map +1 -0
  178. package/build/template/components/sidebar/{SidebarItem.jsx → SidebarItem.js} +15 -32
  179. package/build/template/components/sidebar/SidebarItem.js.map +1 -0
  180. package/build/template/components/sidebar/ToggleButton.d.ts +1 -1
  181. package/build/template/components/sidebar/ToggleButton.d.ts.map +1 -1
  182. package/build/template/components/sidebar/ToggleButton.js +5 -0
  183. package/build/template/components/sidebar/ToggleButton.js.map +1 -0
  184. package/build/template/contexts/{ThemeContext.jsx → ThemeContext.js} +3 -4
  185. package/build/template/contexts/{ThemeContext.jsx.map → ThemeContext.js.map} +1 -1
  186. package/build/template/entry.client.d.ts +1 -0
  187. package/build/template/entry.client.d.ts.map +1 -1
  188. package/build/template/{entry.client.jsx → entry.client.js} +5 -6
  189. package/build/template/entry.client.js.map +1 -0
  190. package/build/template/routes/changelog.d.ts +1 -1
  191. package/build/template/routes/{changelog.jsx → changelog.js} +5 -4
  192. package/build/template/routes/changelog.js.map +1 -0
  193. package/build/template/routes/{index.jsx → index.js} +3 -2
  194. package/build/template/routes/index.js.map +1 -0
  195. package/build/template/routes/reference.$type.$field.d.ts +1 -1
  196. package/build/template/routes/{reference.$type.$field.jsx → reference.$type.$field.js} +6 -5
  197. package/build/template/routes/reference.$type.$field.js.map +1 -0
  198. package/build/template/routes/reference.$type.d.ts +1 -1
  199. package/build/template/routes/{reference.$type.jsx → reference.$type.js} +6 -5
  200. package/build/template/routes/reference.$type.js.map +1 -0
  201. package/build/template/routes/reference.d.ts +2 -2
  202. package/build/template/routes/{reference.jsx → reference.js} +6 -7
  203. package/build/template/routes/reference.js.map +1 -0
  204. package/build/template/routes/root.d.ts +2 -2
  205. package/build/template/routes/root.d.ts.map +1 -1
  206. package/build/template/routes/{root.jsx → root.js} +46 -88
  207. package/build/template/routes/root.js.map +1 -0
  208. package/build/template/routes.js +5 -0
  209. package/build/template/routes.js.map +1 -0
  210. package/build/template/server/app.js +1 -1
  211. package/build/template/server/app.js.map +1 -1
  212. package/build/template/server/{render-page.jsx → render-page.js} +3 -4
  213. package/build/template/server/render-page.js.map +1 -0
  214. package/build/template/server/ssg/generate.js +1 -1
  215. package/build/template/server/ssg/generate.js.map +1 -1
  216. package/build/template/server/ssg/get-route-paths.js +1 -1
  217. package/build/template/server/ssg/get-route-paths.js.map +1 -1
  218. package/build/template/server/view.js +1 -1
  219. package/build/template/server/view.js.map +1 -1
  220. package/package.json +57 -8
  221. package/src/api/vite/plugins/core.ts +0 -3
  222. package/src/api/vite/plugins/pages.ts +1 -1
  223. package/src/exports/components.ts +4 -1
  224. package/src/lib/graphql-document/$$.ts +4 -0
  225. package/src/lib/graphql-document/$.test.ts +132 -0
  226. package/src/lib/graphql-document/$.ts +1 -0
  227. package/src/lib/graphql-document/README.md +102 -0
  228. package/src/lib/graphql-document/analysis.ts +415 -0
  229. package/src/lib/graphql-document/components/CopyButton.tsx +76 -0
  230. package/src/lib/graphql-document/components/GraphQLDocument.tsx +250 -0
  231. package/src/lib/graphql-document/components/GraphQLDocument.unit.test.ts +188 -0
  232. package/src/lib/graphql-document/components/GraphQLDocumentWithSchema.tsx +70 -0
  233. package/src/lib/graphql-document/components/GraphQLIdentifierPopover.tsx +197 -0
  234. package/src/lib/graphql-document/components/IdentifierLink.tsx +160 -0
  235. package/src/lib/graphql-document/components/graphql-document-styles.ts +167 -0
  236. package/src/lib/graphql-document/components/index.ts +5 -0
  237. package/src/lib/graphql-document/demo.md +155 -0
  238. package/src/lib/graphql-document/example.ts +163 -0
  239. package/src/lib/graphql-document/graphql-document.ts +37 -0
  240. package/src/lib/graphql-document/hooks/use-tooltip-state.test.ts +76 -0
  241. package/src/lib/graphql-document/hooks/use-tooltip-state.ts +191 -0
  242. package/src/lib/graphql-document/positioning-simple.test.ts +252 -0
  243. package/src/lib/graphql-document/positioning-simple.ts +271 -0
  244. package/src/lib/graphql-document/schema-context.tsx +20 -0
  245. package/src/lib/graphql-document/schema-integration-example.ts +341 -0
  246. package/src/lib/graphql-document/schema-integration.test.ts +365 -0
  247. package/src/lib/graphql-document/schema-integration.ts +497 -0
  248. package/src/lib/graphql-document/types.ts +129 -0
  249. package/src/template/components/ArgumentAnnotation.tsx +1 -1
  250. package/src/template/components/ArgumentList.tsx +1 -1
  251. package/src/template/components/ArgumentListAnnotation.tsx +2 -2
  252. package/src/template/components/CodeBlockEnhancer.tsx +21 -21
  253. package/src/template/components/DeprecationReason.tsx +1 -1
  254. package/src/template/components/Description.tsx +1 -1
  255. package/src/template/components/Field.tsx +4 -4
  256. package/src/template/components/FieldList.tsx +1 -1
  257. package/src/template/components/FieldListSection.tsx +1 -1
  258. package/src/template/components/Link.tsx +2 -2
  259. package/src/template/components/MDXComponents.tsx +101 -0
  260. package/src/template/components/NamedType.tsx +2 -2
  261. package/src/template/components/TestComponent.tsx +6 -0
  262. package/src/template/components/TypeAnnotation.tsx +1 -1
  263. package/src/template/components/TypeFieldsLinkList.tsx +1 -1
  264. package/src/template/components/TypeIndex.tsx +1 -1
  265. package/src/template/components/content/$$.ts +1 -0
  266. package/src/template/components/content/GraphQLDocumentWithSchema.tsx +18 -0
  267. package/src/template/components/content/GraphQLDocumentWrapper.tsx +82 -0
  268. package/src/template/components/graphql/graphql.tsx +2 -2
  269. package/src/template/components/graphql/index.ts +1 -1
  270. package/src/template/components/graphql/type-link.tsx +2 -2
  271. package/src/template/entry.client.tsx +2 -2
  272. package/src/template/routes/changelog.tsx +1 -1
  273. package/src/template/routes/reference.$type.$field.tsx +3 -3
  274. package/src/template/routes/reference.$type.tsx +3 -3
  275. package/src/template/routes/reference.tsx +3 -3
  276. package/src/template/routes/root.tsx +36 -25
  277. package/src/template/routes.tsx +1 -1
  278. package/src/template/server/app.ts +1 -1
  279. package/src/template/server/ssg/generate.ts +1 -1
  280. package/src/template/server/ssg/get-route-paths.ts +1 -1
  281. package/src/template/server/view.ts +1 -1
  282. package/src/template/styles/code-block.css +32 -0
  283. package/build/template/components/ArgumentAnnotation.jsx +0 -16
  284. package/build/template/components/ArgumentAnnotation.jsx.map +0 -1
  285. package/build/template/components/ArgumentList.jsx +0 -16
  286. package/build/template/components/ArgumentList.jsx.map +0 -1
  287. package/build/template/components/ArgumentListAnnotation.jsx +0 -23
  288. package/build/template/components/ArgumentListAnnotation.jsx.map +0 -1
  289. package/build/template/components/Changelog.jsx +0 -68
  290. package/build/template/components/Changelog.jsx.map +0 -1
  291. package/build/template/components/CodeBlockEnhancer.jsx.map +0 -1
  292. package/build/template/components/DeprecationReason.jsx +0 -10
  293. package/build/template/components/DeprecationReason.jsx.map +0 -1
  294. package/build/template/components/Description.jsx +0 -10
  295. package/build/template/components/Description.jsx.map +0 -1
  296. package/build/template/components/Field.jsx +0 -22
  297. package/build/template/components/Field.jsx.map +0 -1
  298. package/build/template/components/FieldList.jsx.map +0 -1
  299. package/build/template/components/FieldListSection.jsx.map +0 -1
  300. package/build/template/components/HamburgerMenu.jsx +0 -53
  301. package/build/template/components/HamburgerMenu.jsx.map +0 -1
  302. package/build/template/components/Link.jsx.map +0 -1
  303. package/build/template/components/Logo.jsx +0 -29
  304. package/build/template/components/Logo.jsx.map +0 -1
  305. package/build/template/components/Markdown.jsx.map +0 -1
  306. package/build/template/components/MissingSchema.jsx +0 -4
  307. package/build/template/components/MissingSchema.jsx.map +0 -1
  308. package/build/template/components/NamedType.jsx +0 -17
  309. package/build/template/components/NamedType.jsx.map +0 -1
  310. package/build/template/components/NotFound.jsx +0 -26
  311. package/build/template/components/NotFound.jsx.map +0 -1
  312. package/build/template/components/RadixLink.jsx.map +0 -1
  313. package/build/template/components/Texts/MinorHeading.jsx.map +0 -1
  314. package/build/template/components/ThemeToggle.jsx +0 -10
  315. package/build/template/components/ThemeToggle.jsx.map +0 -1
  316. package/build/template/components/TypeAnnotation.jsx.map +0 -1
  317. package/build/template/components/TypeFieldsLinkList.jsx +0 -17
  318. package/build/template/components/TypeFieldsLinkList.jsx.map +0 -1
  319. package/build/template/components/TypeIndex.jsx +0 -27
  320. package/build/template/components/TypeIndex.jsx.map +0 -1
  321. package/build/template/components/graphql/graphql.jsx +0 -3
  322. package/build/template/components/graphql/graphql.jsx.map +0 -1
  323. package/build/template/components/graphql/type-kind-icon.jsx.map +0 -1
  324. package/build/template/components/graphql/type-link.jsx +0 -16
  325. package/build/template/components/graphql/type-link.jsx.map +0 -1
  326. package/build/template/components/sidebar/Sidebar.jsx +0 -15
  327. package/build/template/components/sidebar/Sidebar.jsx.map +0 -1
  328. package/build/template/components/sidebar/SidebarItem.jsx.map +0 -1
  329. package/build/template/components/sidebar/ToggleButton.jsx +0 -6
  330. package/build/template/components/sidebar/ToggleButton.jsx.map +0 -1
  331. package/build/template/entry.client.jsx.map +0 -1
  332. package/build/template/routes/changelog.jsx.map +0 -1
  333. package/build/template/routes/index.jsx.map +0 -1
  334. package/build/template/routes/reference.$type.$field.jsx.map +0 -1
  335. package/build/template/routes/reference.$type.jsx.map +0 -1
  336. package/build/template/routes/reference.jsx.map +0 -1
  337. package/build/template/routes/root.jsx.map +0 -1
  338. package/build/template/routes.jsx +0 -5
  339. package/build/template/routes.jsx.map +0 -1
  340. package/build/template/server/render-page.jsx.map +0 -1
@@ -0,0 +1,497 @@
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 GraphQLEnumType,
12
+ type GraphQLField,
13
+ type GraphQLInputField,
14
+ type GraphQLInputObjectType,
15
+ type GraphQLInterfaceType,
16
+ type GraphQLObjectType,
17
+ type GraphQLScalarType,
18
+ type GraphQLSchema,
19
+ type GraphQLType,
20
+ type GraphQLUnionType,
21
+ isEnumType,
22
+ isInputObjectType,
23
+ isInterfaceType,
24
+ isListType,
25
+ isNonNullType,
26
+ isObjectType,
27
+ isScalarType,
28
+ isUnionType,
29
+ } from 'graphql'
30
+ import { analyze } from './analysis.ts'
31
+ import type { Identifier } from './types.ts'
32
+
33
+ /**
34
+ * Documentation extracted from GraphQL schema
35
+ */
36
+ export interface Documentation {
37
+ /** Description from schema SDL or introspection */
38
+ description?: string
39
+ /** Type signature (e.g., "String!", "[User!]!") */
40
+ typeInfo: string
41
+ /** Whether this field/type is deprecated */
42
+ deprecated?: {
43
+ reason: string
44
+ replacement?: string
45
+ }
46
+ /** Default value for arguments */
47
+ defaultValue?: string
48
+ }
49
+
50
+ /**
51
+ * Result of resolving an identifier against the schema
52
+ */
53
+ export interface SchemaResolution {
54
+ /** Whether the identifier exists in the schema */
55
+ exists: boolean
56
+ /** Documentation extracted from schema */
57
+ documentation?: Documentation
58
+ /** URL to the reference page for this identifier */
59
+ referenceUrl: string
60
+ /** Whether this identifier is deprecated */
61
+ deprecated?: {
62
+ reason: string
63
+ replacement?: string
64
+ }
65
+ /** The GraphQL type if this is a type identifier */
66
+ graphqlType?: GraphQLType
67
+ }
68
+
69
+ /**
70
+ * Interface for resolving GraphQL identifiers against a schema
71
+ */
72
+ export interface SchemaResolver {
73
+ /**
74
+ * Resolve an identifier against the schema
75
+ */
76
+ resolveIdentifier(identifier: Identifier): SchemaResolution | null
77
+
78
+ /**
79
+ * Get documentation for a schema path
80
+ */
81
+ getDocumentation(schemaPath: string[]): Documentation | null
82
+
83
+ /**
84
+ * Generate a reference URL for a schema path
85
+ */
86
+ generateReferenceLink(schemaPath: string[]): string
87
+
88
+ /**
89
+ * Check if a type exists in the schema
90
+ */
91
+ typeExists(typeName: string): boolean
92
+
93
+ /**
94
+ * Get all available types for validation
95
+ */
96
+ getAllTypes(): string[]
97
+ }
98
+
99
+ /**
100
+ * Configuration for URL generation
101
+ */
102
+ export interface RouteConfig {
103
+ /** Base path for reference pages (default: "/reference") */
104
+ basePath?: string
105
+ /** Whether to include fragments in URLs (default: true) */
106
+ includeFragments?: boolean
107
+ }
108
+
109
+ /**
110
+ * Polen's implementation of SchemaResolver
111
+ */
112
+ export class PolenSchemaResolver implements SchemaResolver {
113
+ constructor(
114
+ private schema: GraphQLSchema,
115
+ private routeConfig: RouteConfig = {},
116
+ ) {}
117
+
118
+ /**
119
+ * Resolve an identifier against the schema
120
+ */
121
+ resolveIdentifier(identifier: Identifier): SchemaResolution | null {
122
+ const basePath = this.routeConfig.basePath || '/reference'
123
+
124
+ switch (identifier.kind) {
125
+ case 'Type':
126
+ return this.resolveType(identifier, basePath)
127
+
128
+ case 'Field':
129
+ return this.resolveField(identifier, basePath)
130
+
131
+ case 'Argument':
132
+ return this.resolveArgument(identifier, basePath)
133
+
134
+ case 'Variable':
135
+ // Variables don't have schema resolution
136
+ return {
137
+ exists: true,
138
+ referenceUrl: `${basePath}#variables`,
139
+ documentation: {
140
+ typeInfo: 'Variable',
141
+ description: `Query variable: $${identifier.name}`,
142
+ },
143
+ }
144
+
145
+ case 'Directive':
146
+ return this.resolveDirective(identifier, basePath)
147
+
148
+ case 'Fragment':
149
+ // Fragments don't have schema resolution
150
+ return {
151
+ exists: true,
152
+ referenceUrl: `${basePath}#fragments`,
153
+ documentation: {
154
+ typeInfo: 'Fragment',
155
+ description: `Fragment: ${identifier.name}`,
156
+ },
157
+ }
158
+
159
+ default:
160
+ return null
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Get documentation for a schema path
166
+ */
167
+ getDocumentation(schemaPath: string[]): Documentation | null {
168
+ if (schemaPath.length === 0) return null
169
+
170
+ const [typeName, fieldName, argName] = schemaPath
171
+
172
+ if (!typeName) return null
173
+
174
+ const type = this.schema.getType(typeName)
175
+ if (!type) return null
176
+
177
+ // Type-level documentation
178
+ if (schemaPath.length === 1) {
179
+ return {
180
+ typeInfo: this.getTypeSignature(type),
181
+ description: type.description || undefined,
182
+ deprecated: 'deprecationReason' in type
183
+ ? {
184
+ reason: (type as any).deprecationReason,
185
+ }
186
+ : undefined,
187
+ }
188
+ }
189
+
190
+ // Field-level documentation
191
+ if (fieldName && schemaPath.length === 2) {
192
+ const field = this.getFieldFromType(type, fieldName)
193
+ if (!field) return null
194
+
195
+ return {
196
+ typeInfo: this.getTypeSignature(field.type),
197
+ description: field.description || undefined,
198
+ deprecated: field.deprecationReason
199
+ ? {
200
+ reason: field.deprecationReason,
201
+ }
202
+ : undefined,
203
+ }
204
+ }
205
+
206
+ // Argument-level documentation
207
+ if (fieldName && argName && schemaPath.length === 3) {
208
+ const field = this.getFieldFromType(type, fieldName)
209
+ if (!field || !('args' in field)) return null
210
+
211
+ const arg = field.args.find((a: any) => a.name === argName)
212
+ if (!arg) return null
213
+
214
+ return {
215
+ typeInfo: this.getTypeSignature(arg.type),
216
+ description: arg.description || undefined,
217
+ defaultValue: arg.defaultValue !== undefined
218
+ ? String(arg.defaultValue)
219
+ : undefined,
220
+ }
221
+ }
222
+
223
+ return null
224
+ }
225
+
226
+ /**
227
+ * Generate a reference URL for a schema path
228
+ */
229
+ generateReferenceLink(schemaPath: string[]): string {
230
+ const basePath = this.routeConfig.basePath || '/reference'
231
+ const includeFragments = this.routeConfig.includeFragments !== false
232
+
233
+ if (schemaPath.length === 0) return basePath
234
+
235
+ const [typeName, fieldName, argName] = schemaPath
236
+
237
+ // Type reference
238
+ if (schemaPath.length === 1) {
239
+ return `${basePath}/${typeName}`
240
+ }
241
+
242
+ // Field reference
243
+ if (fieldName && schemaPath.length === 2) {
244
+ const fragment = includeFragments ? `#${fieldName}` : ''
245
+ return `${basePath}/${typeName}${fragment}`
246
+ }
247
+
248
+ // Argument reference
249
+ if (fieldName && argName && schemaPath.length === 3) {
250
+ const fragment = includeFragments ? `#${fieldName}-${argName}` : ''
251
+ return `${basePath}/${typeName}${fragment}`
252
+ }
253
+
254
+ return `${basePath}/${typeName}`
255
+ }
256
+
257
+ /**
258
+ * Check if a type exists in the schema
259
+ */
260
+ typeExists(typeName: string): boolean {
261
+ return !!this.schema.getType(typeName)
262
+ }
263
+
264
+ /**
265
+ * Get all available types for validation
266
+ */
267
+ getAllTypes(): string[] {
268
+ return Object.keys(this.schema.getTypeMap())
269
+ .filter(name => !name.startsWith('__')) // Filter out introspection types
270
+ }
271
+
272
+ // Private helper methods
273
+
274
+ private resolveType(identifier: Identifier, basePath: string): SchemaResolution {
275
+ const type = this.schema.getType(identifier.name)
276
+
277
+ return {
278
+ exists: !!type,
279
+ graphqlType: type || undefined,
280
+ referenceUrl: `${basePath}/${identifier.name}`,
281
+ documentation: type
282
+ ? {
283
+ typeInfo: this.getTypeSignature(type),
284
+ description: type.description || undefined,
285
+ }
286
+ : undefined,
287
+ }
288
+ }
289
+
290
+ private resolveField(identifier: Identifier, basePath: string): SchemaResolution {
291
+ if (!identifier.parentType) {
292
+ return {
293
+ exists: false,
294
+ referenceUrl: `${basePath}#${identifier.name}`,
295
+ }
296
+ }
297
+
298
+ const parentType = this.schema.getType(identifier.parentType)
299
+ if (!parentType) {
300
+ return {
301
+ exists: false,
302
+ referenceUrl: `${basePath}/${identifier.parentType}#${identifier.name}`,
303
+ }
304
+ }
305
+
306
+ const field = this.getFieldFromType(parentType, identifier.name)
307
+
308
+ return {
309
+ exists: !!field,
310
+ referenceUrl: `${basePath}/${identifier.parentType}#${identifier.name}`,
311
+ documentation: field
312
+ ? {
313
+ typeInfo: this.getTypeSignature(field.type),
314
+ description: field.description || undefined,
315
+ deprecated: field.deprecationReason
316
+ ? {
317
+ reason: field.deprecationReason,
318
+ }
319
+ : undefined,
320
+ }
321
+ : undefined,
322
+ deprecated: field?.deprecationReason
323
+ ? {
324
+ reason: field.deprecationReason,
325
+ }
326
+ : undefined,
327
+ }
328
+ }
329
+
330
+ private resolveArgument(identifier: Identifier, basePath: string): SchemaResolution {
331
+ const schemaPath = identifier.schemaPath
332
+ if (schemaPath.length < 3) {
333
+ return {
334
+ exists: false,
335
+ referenceUrl: `${basePath}#${identifier.name}`,
336
+ }
337
+ }
338
+
339
+ const [typeName, fieldName] = schemaPath
340
+ if (!typeName || !fieldName) {
341
+ return {
342
+ exists: false,
343
+ referenceUrl: `${basePath}#${identifier.name}`,
344
+ }
345
+ }
346
+
347
+ const parentType = this.schema.getType(typeName)
348
+ if (!parentType) {
349
+ return {
350
+ exists: false,
351
+ referenceUrl: `${basePath}/${typeName}#${fieldName}-${identifier.name}`,
352
+ }
353
+ }
354
+
355
+ const field = this.getFieldFromType(parentType, fieldName)
356
+ if (!field || !('args' in field)) {
357
+ return {
358
+ exists: false,
359
+ referenceUrl: `${basePath}/${typeName}#${fieldName}-${identifier.name}`,
360
+ }
361
+ }
362
+
363
+ const arg = field.args.find((a: any) => a.name === identifier.name)
364
+
365
+ return {
366
+ exists: !!arg,
367
+ referenceUrl: `${basePath}/${typeName}#${fieldName}-${identifier.name}`,
368
+ documentation: arg
369
+ ? {
370
+ typeInfo: this.getTypeSignature(arg.type),
371
+ description: arg.description || undefined,
372
+ defaultValue: arg.defaultValue !== undefined
373
+ ? String(arg.defaultValue)
374
+ : undefined,
375
+ }
376
+ : undefined,
377
+ }
378
+ }
379
+
380
+ private resolveDirective(identifier: Identifier, basePath: string): SchemaResolution {
381
+ const directive = this.schema.getDirective(identifier.name)
382
+
383
+ return {
384
+ exists: !!directive,
385
+ referenceUrl: `${basePath}/directives#${identifier.name}`,
386
+ documentation: directive
387
+ ? {
388
+ typeInfo: 'Directive',
389
+ description: directive.description || undefined,
390
+ }
391
+ : undefined,
392
+ }
393
+ }
394
+
395
+ private getFieldFromType(type: GraphQLType, fieldName: string): GraphQLField<any, any> | GraphQLInputField | null {
396
+ if (isObjectType(type) || isInterfaceType(type)) {
397
+ return type.getFields()[fieldName] || null
398
+ }
399
+
400
+ if (isInputObjectType(type)) {
401
+ return type.getFields()[fieldName] || null
402
+ }
403
+
404
+ return null
405
+ }
406
+
407
+ private getTypeSignature(type: GraphQLType): string {
408
+ if (isNonNullType(type)) {
409
+ return `${this.getTypeSignature(type.ofType)}!`
410
+ }
411
+
412
+ if (isListType(type)) {
413
+ return `[${this.getTypeSignature(type.ofType)}]`
414
+ }
415
+
416
+ return getNamedType(type).name
417
+ }
418
+ }
419
+
420
+ /**
421
+ * Create a schema resolver for Polen
422
+ */
423
+ export const createPolenSchemaResolver = (
424
+ schema: GraphQLSchema,
425
+ routeConfig?: RouteConfig,
426
+ ): SchemaResolver => {
427
+ return new PolenSchemaResolver(schema, routeConfig)
428
+ }
429
+
430
+ /**
431
+ * Enhanced analysis result with schema resolution
432
+ */
433
+ export interface SchemaAwareAnalysisResult {
434
+ /** Original analysis result */
435
+ analysis: import('./types.ts').AnalysisResult
436
+ /** Schema resolutions for all identifiers */
437
+ resolutions: Map<string, SchemaResolution>
438
+ /** Validation errors from schema checking */
439
+ schemaErrors: Array<{
440
+ identifier: Identifier
441
+ message: string
442
+ severity: 'error' | 'warning'
443
+ }>
444
+ }
445
+
446
+ /**
447
+ * Perform schema-aware analysis of a GraphQL document
448
+ */
449
+ export const analyzeWithSchema = (
450
+ source: string,
451
+ schema: GraphQLSchema,
452
+ routeConfig?: RouteConfig,
453
+ ): SchemaAwareAnalysisResult => {
454
+ const analysis = analyze(source, {
455
+ schema,
456
+ validateAgainstSchema: true,
457
+ includePositions: true,
458
+ })
459
+
460
+ const resolver = createPolenSchemaResolver(schema, routeConfig)
461
+ const resolutions = new Map<string, SchemaResolution>()
462
+ const schemaErrors: SchemaAwareAnalysisResult['schemaErrors'] = []
463
+
464
+ // Resolve all identifiers against schema
465
+ for (const identifier of analysis.identifiers.all) {
466
+ const key = `${identifier.position.start}-${identifier.name}-${identifier.kind}`
467
+ const resolution = resolver.resolveIdentifier(identifier)
468
+
469
+ if (resolution) {
470
+ resolutions.set(key, resolution)
471
+
472
+ // Add validation errors for non-existent identifiers
473
+ if (!resolution.exists && (identifier.kind === 'Type' || identifier.kind === 'Field')) {
474
+ schemaErrors.push({
475
+ identifier,
476
+ message: `${identifier.kind} "${identifier.name}" does not exist in schema`,
477
+ severity: 'error',
478
+ })
479
+ }
480
+
481
+ // Add deprecation warnings
482
+ if (resolution.deprecated) {
483
+ schemaErrors.push({
484
+ identifier,
485
+ message: `${identifier.kind} "${identifier.name}" is deprecated: ${resolution.deprecated.reason}`,
486
+ severity: 'warning',
487
+ })
488
+ }
489
+ }
490
+ }
491
+
492
+ return {
493
+ analysis,
494
+ resolutions,
495
+ schemaErrors,
496
+ }
497
+ }
@@ -0,0 +1,129 @@
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,7 +1,7 @@
1
1
  import { Box, Flex, Text } from '@radix-ui/themes'
2
2
  import type { GraphQLArgument } from 'graphql'
3
3
  import type { FC } from 'react'
4
- import { TypeAnnotation } from './TypeAnnotation.jsx'
4
+ import { TypeAnnotation } from './TypeAnnotation.js'
5
5
 
6
6
  export interface Props {
7
7
  data: GraphQLArgument
@@ -1,7 +1,7 @@
1
1
  import { Box, Flex, Heading, Text } from '@radix-ui/themes'
2
2
  import type { GraphQLArgument } from 'graphql'
3
3
  import type { FC } from 'react'
4
- import { TypeAnnotation } from './TypeAnnotation.jsx'
4
+ import { TypeAnnotation } from './TypeAnnotation.tsx'
5
5
 
6
6
  export interface Props {
7
7
  args: readonly GraphQLArgument[]
@@ -2,8 +2,8 @@ import { GrafaidOld } from '#lib/grafaid-old/index'
2
2
  import { Box, Text } from '@radix-ui/themes'
3
3
  import type { GraphQLField } from 'graphql'
4
4
  import type { FC } from 'react'
5
- import { ArgumentAnnotation } from './ArgumentAnnotation.jsx'
6
- import { FieldList } from './FieldList.jsx'
5
+ import { ArgumentAnnotation } from './ArgumentAnnotation.tsx'
6
+ import { FieldList } from './FieldList.tsx'
7
7
 
8
8
  export interface Props {
9
9
  field: GraphQLField<any, any>