@gqlkit-ts/cli 0.0.1 → 0.2.0

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 (362) hide show
  1. package/LICENSE +21 -0
  2. package/dist/auto-type-generator/auto-type-generator.d.ts +62 -0
  3. package/dist/auto-type-generator/auto-type-generator.d.ts.map +1 -0
  4. package/dist/auto-type-generator/auto-type-generator.js +540 -0
  5. package/dist/auto-type-generator/auto-type-generator.js.map +1 -0
  6. package/dist/auto-type-generator/index.d.ts +4 -0
  7. package/dist/auto-type-generator/index.d.ts.map +1 -0
  8. package/dist/auto-type-generator/index.js +3 -0
  9. package/dist/auto-type-generator/index.js.map +1 -0
  10. package/dist/auto-type-generator/inline-enum-collector.d.ts +31 -0
  11. package/dist/auto-type-generator/inline-enum-collector.d.ts.map +1 -0
  12. package/dist/auto-type-generator/inline-enum-collector.js +157 -0
  13. package/dist/auto-type-generator/inline-enum-collector.js.map +1 -0
  14. package/dist/auto-type-generator/name-collision-validator.d.ts +17 -0
  15. package/dist/auto-type-generator/name-collision-validator.d.ts.map +1 -0
  16. package/dist/auto-type-generator/name-collision-validator.js +68 -0
  17. package/dist/auto-type-generator/name-collision-validator.js.map +1 -0
  18. package/dist/auto-type-generator/naming-convention.d.ts +44 -0
  19. package/dist/auto-type-generator/naming-convention.d.ts.map +1 -0
  20. package/dist/auto-type-generator/naming-convention.js +67 -0
  21. package/dist/auto-type-generator/naming-convention.js.map +1 -0
  22. package/dist/cli.d.ts +2 -0
  23. package/dist/cli.d.ts.map +1 -0
  24. package/dist/cli.js +11 -0
  25. package/dist/cli.js.map +1 -0
  26. package/dist/commands/gen.d.ts +32 -0
  27. package/dist/commands/gen.d.ts.map +1 -0
  28. package/dist/commands/gen.js +101 -0
  29. package/dist/commands/gen.js.map +1 -0
  30. package/dist/commands/main.d.ts +12 -0
  31. package/dist/commands/main.d.ts.map +1 -0
  32. package/dist/commands/main.js +5 -0
  33. package/dist/commands/main.js.map +1 -0
  34. package/dist/config/define-config.d.ts +26 -0
  35. package/dist/config/define-config.d.ts.map +1 -0
  36. package/dist/config/define-config.js +27 -0
  37. package/dist/config/define-config.js.map +1 -0
  38. package/dist/config/index.d.ts +3 -0
  39. package/dist/config/index.d.ts.map +1 -0
  40. package/dist/config/index.js +2 -0
  41. package/dist/config/index.js.map +1 -0
  42. package/dist/config/types.d.ts +131 -0
  43. package/dist/config/types.d.ts.map +1 -0
  44. package/dist/config/types.js +2 -0
  45. package/dist/config/types.js.map +1 -0
  46. package/dist/config-loader/index.d.ts +3 -0
  47. package/dist/config-loader/index.d.ts.map +1 -0
  48. package/dist/config-loader/index.js +2 -0
  49. package/dist/config-loader/index.js.map +1 -0
  50. package/dist/config-loader/loader.d.ts +50 -0
  51. package/dist/config-loader/loader.d.ts.map +1 -0
  52. package/dist/config-loader/loader.js +78 -0
  53. package/dist/config-loader/loader.js.map +1 -0
  54. package/dist/config-loader/validator.d.ts +13 -0
  55. package/dist/config-loader/validator.d.ts.map +1 -0
  56. package/dist/config-loader/validator.js +497 -0
  57. package/dist/config-loader/validator.js.map +1 -0
  58. package/dist/gen-orchestrator/hook-executor/hook-executor.d.ts +25 -0
  59. package/dist/gen-orchestrator/hook-executor/hook-executor.d.ts.map +1 -0
  60. package/dist/gen-orchestrator/hook-executor/hook-executor.js +68 -0
  61. package/dist/gen-orchestrator/hook-executor/hook-executor.js.map +1 -0
  62. package/dist/gen-orchestrator/orchestrator.d.ts +30 -0
  63. package/dist/gen-orchestrator/orchestrator.d.ts.map +1 -0
  64. package/dist/gen-orchestrator/orchestrator.js +505 -0
  65. package/dist/gen-orchestrator/orchestrator.js.map +1 -0
  66. package/dist/gen-orchestrator/reporter/diagnostic-reporter.d.ts +9 -0
  67. package/dist/gen-orchestrator/reporter/diagnostic-reporter.d.ts.map +1 -0
  68. package/dist/gen-orchestrator/reporter/diagnostic-reporter.js +32 -0
  69. package/dist/gen-orchestrator/reporter/diagnostic-reporter.js.map +1 -0
  70. package/dist/gen-orchestrator/reporter/progress-reporter.d.ts +19 -0
  71. package/dist/gen-orchestrator/reporter/progress-reporter.d.ts.map +1 -0
  72. package/dist/gen-orchestrator/reporter/progress-reporter.js +38 -0
  73. package/dist/gen-orchestrator/reporter/progress-reporter.js.map +1 -0
  74. package/dist/gen-orchestrator/writer/file-writer.d.ts +13 -0
  75. package/dist/gen-orchestrator/writer/file-writer.d.ts.map +1 -0
  76. package/dist/gen-orchestrator/writer/file-writer.js +22 -0
  77. package/dist/gen-orchestrator/writer/file-writer.js.map +1 -0
  78. package/dist/index.d.ts +3 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +2 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/resolver-extractor/extract-resolvers.d.ts +49 -0
  83. package/dist/resolver-extractor/extract-resolvers.d.ts.map +1 -0
  84. package/dist/resolver-extractor/extract-resolvers.js +2 -0
  85. package/dist/resolver-extractor/extract-resolvers.js.map +1 -0
  86. package/dist/resolver-extractor/extractor/define-api-extractor.d.ts +60 -0
  87. package/dist/resolver-extractor/extractor/define-api-extractor.d.ts.map +1 -0
  88. package/dist/resolver-extractor/extractor/define-api-extractor.js +509 -0
  89. package/dist/resolver-extractor/extractor/define-api-extractor.js.map +1 -0
  90. package/dist/resolver-extractor/index.d.ts +5 -0
  91. package/dist/resolver-extractor/index.d.ts.map +1 -0
  92. package/dist/resolver-extractor/index.js +2 -0
  93. package/dist/resolver-extractor/index.js.map +1 -0
  94. package/dist/resolver-extractor/validator/abstract-resolver-validator.d.ts +25 -0
  95. package/dist/resolver-extractor/validator/abstract-resolver-validator.d.ts.map +1 -0
  96. package/dist/resolver-extractor/validator/abstract-resolver-validator.js +172 -0
  97. package/dist/resolver-extractor/validator/abstract-resolver-validator.js.map +1 -0
  98. package/dist/resolver-extractor/validator/only-validator.d.ts +61 -0
  99. package/dist/resolver-extractor/validator/only-validator.d.ts.map +1 -0
  100. package/dist/resolver-extractor/validator/only-validator.js +76 -0
  101. package/dist/resolver-extractor/validator/only-validator.js.map +1 -0
  102. package/dist/schema-generator/builder/ast-builder.d.ts +7 -0
  103. package/dist/schema-generator/builder/ast-builder.d.ts.map +1 -0
  104. package/dist/schema-generator/builder/ast-builder.js +417 -0
  105. package/dist/schema-generator/builder/ast-builder.js.map +1 -0
  106. package/dist/schema-generator/emitter/code-emitter.d.ts +15 -0
  107. package/dist/schema-generator/emitter/code-emitter.d.ts.map +1 -0
  108. package/dist/schema-generator/emitter/code-emitter.js +216 -0
  109. package/dist/schema-generator/emitter/code-emitter.js.map +1 -0
  110. package/dist/schema-generator/emitter/sdl-emitter.d.ts +7 -0
  111. package/dist/schema-generator/emitter/sdl-emitter.d.ts.map +1 -0
  112. package/dist/schema-generator/emitter/sdl-emitter.js +11 -0
  113. package/dist/schema-generator/emitter/sdl-emitter.js.map +1 -0
  114. package/dist/schema-generator/generate-schema.d.ts +26 -0
  115. package/dist/schema-generator/generate-schema.d.ts.map +1 -0
  116. package/dist/schema-generator/generate-schema.js +93 -0
  117. package/dist/schema-generator/generate-schema.js.map +1 -0
  118. package/dist/schema-generator/index.d.ts +4 -0
  119. package/dist/schema-generator/index.d.ts.map +1 -0
  120. package/dist/schema-generator/index.js +2 -0
  121. package/dist/schema-generator/index.js.map +1 -0
  122. package/dist/schema-generator/integrator/result-integrator.d.ts +113 -0
  123. package/dist/schema-generator/integrator/result-integrator.d.ts.map +1 -0
  124. package/dist/schema-generator/integrator/result-integrator.js +438 -0
  125. package/dist/schema-generator/integrator/result-integrator.js.map +1 -0
  126. package/dist/schema-generator/pruner/schema-pruner.d.ts +16 -0
  127. package/dist/schema-generator/pruner/schema-pruner.d.ts.map +1 -0
  128. package/dist/schema-generator/pruner/schema-pruner.js +66 -0
  129. package/dist/schema-generator/pruner/schema-pruner.js.map +1 -0
  130. package/dist/schema-generator/resolver-collector/resolver-collector.d.ts +24 -0
  131. package/dist/schema-generator/resolver-collector/resolver-collector.d.ts.map +1 -0
  132. package/dist/schema-generator/resolver-collector/resolver-collector.js +61 -0
  133. package/dist/schema-generator/resolver-collector/resolver-collector.js.map +1 -0
  134. package/dist/shared/constants.d.ts +54 -0
  135. package/dist/shared/constants.d.ts.map +1 -0
  136. package/dist/shared/constants.js +109 -0
  137. package/dist/shared/constants.js.map +1 -0
  138. package/dist/shared/default-value-detector.d.ts +40 -0
  139. package/dist/shared/default-value-detector.d.ts.map +1 -0
  140. package/dist/shared/default-value-detector.js +124 -0
  141. package/dist/shared/default-value-detector.js.map +1 -0
  142. package/dist/shared/diagnostics.d.ts +4 -0
  143. package/dist/shared/diagnostics.d.ts.map +1 -0
  144. package/dist/shared/diagnostics.js +25 -0
  145. package/dist/shared/diagnostics.js.map +1 -0
  146. package/dist/shared/directive-definition-extractor.d.ts +64 -0
  147. package/dist/shared/directive-definition-extractor.d.ts.map +1 -0
  148. package/dist/shared/directive-definition-extractor.js +399 -0
  149. package/dist/shared/directive-definition-extractor.js.map +1 -0
  150. package/dist/shared/directive-detector.d.ts +102 -0
  151. package/dist/shared/directive-detector.d.ts.map +1 -0
  152. package/dist/shared/directive-detector.js +415 -0
  153. package/dist/shared/directive-detector.js.map +1 -0
  154. package/dist/shared/file-scanner.d.ts +25 -0
  155. package/dist/shared/file-scanner.d.ts.map +1 -0
  156. package/dist/shared/file-scanner.js +101 -0
  157. package/dist/shared/file-scanner.js.map +1 -0
  158. package/dist/shared/index.d.ts +10 -0
  159. package/dist/shared/index.d.ts.map +1 -0
  160. package/dist/shared/index.js +6 -0
  161. package/dist/shared/index.js.map +1 -0
  162. package/dist/shared/inline-object-extractor.d.ts +13 -0
  163. package/dist/shared/inline-object-extractor.d.ts.map +1 -0
  164. package/dist/shared/inline-object-extractor.js +65 -0
  165. package/dist/shared/inline-object-extractor.js.map +1 -0
  166. package/dist/shared/inline-object-utils.d.ts +7 -0
  167. package/dist/shared/inline-object-utils.d.ts.map +1 -0
  168. package/dist/shared/inline-object-utils.js +23 -0
  169. package/dist/shared/inline-object-utils.js.map +1 -0
  170. package/dist/shared/interface-detector.d.ts +23 -0
  171. package/dist/shared/interface-detector.d.ts.map +1 -0
  172. package/dist/shared/interface-detector.js +133 -0
  173. package/dist/shared/interface-detector.js.map +1 -0
  174. package/dist/shared/interface-validator.d.ts +9 -0
  175. package/dist/shared/interface-validator.d.ts.map +1 -0
  176. package/dist/shared/interface-validator.js +152 -0
  177. package/dist/shared/interface-validator.js.map +1 -0
  178. package/dist/shared/metadata-detector.d.ts +65 -0
  179. package/dist/shared/metadata-detector.d.ts.map +1 -0
  180. package/dist/shared/metadata-detector.js +333 -0
  181. package/dist/shared/metadata-detector.js.map +1 -0
  182. package/dist/shared/path-utils.d.ts +2 -0
  183. package/dist/shared/path-utils.d.ts.map +1 -0
  184. package/dist/shared/path-utils.js +4 -0
  185. package/dist/shared/path-utils.js.map +1 -0
  186. package/dist/shared/program-factory.d.ts +14 -0
  187. package/dist/shared/program-factory.d.ts.map +1 -0
  188. package/dist/shared/program-factory.js +29 -0
  189. package/dist/shared/program-factory.js.map +1 -0
  190. package/dist/shared/source-location.d.ts +11 -0
  191. package/dist/shared/source-location.d.ts.map +1 -0
  192. package/dist/shared/source-location.js +15 -0
  193. package/dist/shared/source-location.js.map +1 -0
  194. package/dist/shared/tsconfig-loader.d.ts +13 -0
  195. package/dist/shared/tsconfig-loader.d.ts.map +1 -0
  196. package/dist/shared/tsconfig-loader.js +90 -0
  197. package/dist/shared/tsconfig-loader.js.map +1 -0
  198. package/dist/shared/tsdoc-parser.d.ts +12 -0
  199. package/dist/shared/tsdoc-parser.d.ts.map +1 -0
  200. package/dist/shared/tsdoc-parser.js +101 -0
  201. package/dist/shared/tsdoc-parser.js.map +1 -0
  202. package/dist/shared/type-converter.d.ts +3 -0
  203. package/dist/shared/type-converter.d.ts.map +1 -0
  204. package/dist/shared/type-converter.js +83 -0
  205. package/dist/shared/type-converter.js.map +1 -0
  206. package/dist/shared/typescript-utils.d.ts +82 -0
  207. package/dist/shared/typescript-utils.d.ts.map +1 -0
  208. package/dist/shared/typescript-utils.js +197 -0
  209. package/dist/shared/typescript-utils.js.map +1 -0
  210. package/dist/type-extractor/collector/result-collector.d.ts +7 -0
  211. package/dist/type-extractor/collector/result-collector.d.ts.map +1 -0
  212. package/dist/type-extractor/collector/result-collector.js +35 -0
  213. package/dist/type-extractor/collector/result-collector.js.map +1 -0
  214. package/dist/type-extractor/collector/scalar-collector.d.ts +108 -0
  215. package/dist/type-extractor/collector/scalar-collector.d.ts.map +1 -0
  216. package/dist/type-extractor/collector/scalar-collector.js +123 -0
  217. package/dist/type-extractor/collector/scalar-collector.js.map +1 -0
  218. package/dist/type-extractor/converter/field-eligibility.d.ts +34 -0
  219. package/dist/type-extractor/converter/field-eligibility.d.ts.map +1 -0
  220. package/dist/type-extractor/converter/field-eligibility.js +89 -0
  221. package/dist/type-extractor/converter/field-eligibility.js.map +1 -0
  222. package/dist/type-extractor/converter/graphql-converter.d.ts +7 -0
  223. package/dist/type-extractor/converter/graphql-converter.d.ts.map +1 -0
  224. package/dist/type-extractor/converter/graphql-converter.js +338 -0
  225. package/dist/type-extractor/converter/graphql-converter.js.map +1 -0
  226. package/dist/type-extractor/extract-types.d.ts +2 -0
  227. package/dist/type-extractor/extract-types.d.ts.map +1 -0
  228. package/dist/type-extractor/extract-types.js +2 -0
  229. package/dist/type-extractor/extract-types.js.map +1 -0
  230. package/dist/type-extractor/extractor/field-type-resolver.d.ts +28 -0
  231. package/dist/type-extractor/extractor/field-type-resolver.d.ts.map +1 -0
  232. package/dist/type-extractor/extractor/field-type-resolver.js +394 -0
  233. package/dist/type-extractor/extractor/field-type-resolver.js.map +1 -0
  234. package/dist/type-extractor/extractor/type-extractor.d.ts +36 -0
  235. package/dist/type-extractor/extractor/type-extractor.d.ts.map +1 -0
  236. package/dist/type-extractor/extractor/type-extractor.js +1082 -0
  237. package/dist/type-extractor/extractor/type-extractor.js.map +1 -0
  238. package/dist/type-extractor/extractor/type-name-collector.d.ts +24 -0
  239. package/dist/type-extractor/extractor/type-name-collector.d.ts.map +1 -0
  240. package/dist/type-extractor/extractor/type-name-collector.js +102 -0
  241. package/dist/type-extractor/extractor/type-name-collector.js.map +1 -0
  242. package/dist/type-extractor/index.d.ts +4 -0
  243. package/dist/type-extractor/index.d.ts.map +1 -0
  244. package/dist/type-extractor/index.js +2 -0
  245. package/dist/type-extractor/index.js.map +1 -0
  246. package/dist/type-extractor/mapper/scalar-base-type-mapper.d.ts +89 -0
  247. package/dist/type-extractor/mapper/scalar-base-type-mapper.d.ts.map +1 -0
  248. package/dist/type-extractor/mapper/scalar-base-type-mapper.js +158 -0
  249. package/dist/type-extractor/mapper/scalar-base-type-mapper.js.map +1 -0
  250. package/dist/type-extractor/types/diagnostics.d.ts +17 -0
  251. package/dist/type-extractor/types/diagnostics.d.ts.map +1 -0
  252. package/dist/type-extractor/types/diagnostics.js +2 -0
  253. package/dist/type-extractor/types/diagnostics.js.map +1 -0
  254. package/dist/type-extractor/types/graphql.d.ts +42 -0
  255. package/dist/type-extractor/types/graphql.d.ts.map +1 -0
  256. package/dist/type-extractor/types/graphql.js +2 -0
  257. package/dist/type-extractor/types/graphql.js.map +1 -0
  258. package/dist/type-extractor/types/index.d.ts +6 -0
  259. package/dist/type-extractor/types/index.d.ts.map +1 -0
  260. package/dist/type-extractor/types/index.js +2 -0
  261. package/dist/type-extractor/types/index.js.map +1 -0
  262. package/dist/type-extractor/types/ts-type-reference-factory.d.ts +39 -0
  263. package/dist/type-extractor/types/ts-type-reference-factory.d.ts.map +1 -0
  264. package/dist/type-extractor/types/ts-type-reference-factory.js +69 -0
  265. package/dist/type-extractor/types/ts-type-reference-factory.js.map +1 -0
  266. package/dist/type-extractor/types/typescript.d.ts +106 -0
  267. package/dist/type-extractor/types/typescript.d.ts.map +1 -0
  268. package/dist/type-extractor/types/typescript.js +2 -0
  269. package/dist/type-extractor/types/typescript.js.map +1 -0
  270. package/dist/type-extractor/validator/type-validator.d.ts +11 -0
  271. package/dist/type-extractor/validator/type-validator.d.ts.map +1 -0
  272. package/dist/type-extractor/validator/type-validator.js +53 -0
  273. package/dist/type-extractor/validator/type-validator.js.map +1 -0
  274. package/docs/configuration.md +163 -0
  275. package/docs/getting-started.md +117 -0
  276. package/docs/index.md +33 -0
  277. package/docs/integration/apollo.md +109 -0
  278. package/docs/integration/drizzle.md +191 -0
  279. package/docs/integration/yoga.md +108 -0
  280. package/docs/schema/abstract-resolvers.md +146 -0
  281. package/docs/schema/directives.md +196 -0
  282. package/docs/schema/documentation.md +176 -0
  283. package/docs/schema/enums.md +370 -0
  284. package/docs/schema/fields.md +186 -0
  285. package/docs/schema/index.md +38 -0
  286. package/docs/schema/inputs.md +279 -0
  287. package/docs/schema/interfaces.md +178 -0
  288. package/docs/schema/objects.md +188 -0
  289. package/docs/schema/queries-mutations.md +207 -0
  290. package/docs/schema/scalars.md +194 -0
  291. package/docs/schema/unions.md +90 -0
  292. package/docs/what-is-gqlkit.md +22 -0
  293. package/package.json +66 -7
  294. package/src/auto-type-generator/auto-type-generator.ts +925 -0
  295. package/src/auto-type-generator/index.ts +21 -0
  296. package/src/auto-type-generator/inline-enum-collector.ts +290 -0
  297. package/src/auto-type-generator/name-collision-validator.ts +119 -0
  298. package/src/auto-type-generator/naming-convention.ts +126 -0
  299. package/src/cli.ts +11 -0
  300. package/src/commands/gen.ts +141 -0
  301. package/src/commands/main.ts +5 -0
  302. package/src/config/define-config.ts +28 -0
  303. package/src/config/index.ts +7 -0
  304. package/src/config/types.ts +144 -0
  305. package/src/config-loader/index.ts +14 -0
  306. package/src/config-loader/loader.ts +143 -0
  307. package/src/config-loader/validator.ts +672 -0
  308. package/src/gen-orchestrator/hook-executor/hook-executor.ts +117 -0
  309. package/src/gen-orchestrator/orchestrator.ts +784 -0
  310. package/src/gen-orchestrator/reporter/diagnostic-reporter.ts +44 -0
  311. package/src/gen-orchestrator/reporter/progress-reporter.ts +61 -0
  312. package/src/gen-orchestrator/writer/file-writer.ts +38 -0
  313. package/src/index.ts +2 -0
  314. package/src/resolver-extractor/extract-resolvers.ts +63 -0
  315. package/src/resolver-extractor/extractor/define-api-extractor.ts +806 -0
  316. package/src/resolver-extractor/index.ts +19 -0
  317. package/src/resolver-extractor/validator/abstract-resolver-validator.ts +251 -0
  318. package/src/resolver-extractor/validator/only-validator.ts +158 -0
  319. package/src/schema-generator/builder/ast-builder.ts +706 -0
  320. package/src/schema-generator/emitter/code-emitter.ts +351 -0
  321. package/src/schema-generator/emitter/sdl-emitter.ts +13 -0
  322. package/src/schema-generator/generate-schema.ts +170 -0
  323. package/src/schema-generator/index.ts +19 -0
  324. package/src/schema-generator/integrator/result-integrator.ts +690 -0
  325. package/src/schema-generator/pruner/schema-pruner.ts +112 -0
  326. package/src/schema-generator/resolver-collector/resolver-collector.ts +123 -0
  327. package/src/shared/constants.ts +122 -0
  328. package/src/shared/default-value-detector.ts +172 -0
  329. package/src/shared/diagnostics.ts +35 -0
  330. package/src/shared/directive-definition-extractor.ts +564 -0
  331. package/src/shared/directive-detector.ts +556 -0
  332. package/src/shared/file-scanner.ts +170 -0
  333. package/src/shared/index.ts +32 -0
  334. package/src/shared/inline-object-extractor.ts +102 -0
  335. package/src/shared/inline-object-utils.ts +23 -0
  336. package/src/shared/interface-detector.ts +176 -0
  337. package/src/shared/interface-validator.ts +211 -0
  338. package/src/shared/metadata-detector.ts +443 -0
  339. package/src/shared/path-utils.ts +3 -0
  340. package/src/shared/program-factory.ts +51 -0
  341. package/src/shared/source-location.ts +27 -0
  342. package/src/shared/tsconfig-loader.ts +126 -0
  343. package/src/shared/tsdoc-parser.ts +155 -0
  344. package/src/shared/type-converter.ts +99 -0
  345. package/src/shared/typescript-utils.ts +246 -0
  346. package/src/type-extractor/collector/result-collector.ts +57 -0
  347. package/src/type-extractor/collector/scalar-collector.ts +254 -0
  348. package/src/type-extractor/converter/field-eligibility.ts +112 -0
  349. package/src/type-extractor/converter/graphql-converter.ts +459 -0
  350. package/src/type-extractor/extract-types.ts +1 -0
  351. package/src/type-extractor/extractor/field-type-resolver.ts +569 -0
  352. package/src/type-extractor/extractor/type-extractor.ts +1567 -0
  353. package/src/type-extractor/extractor/type-name-collector.ts +130 -0
  354. package/src/type-extractor/index.ts +20 -0
  355. package/src/type-extractor/mapper/scalar-base-type-mapper.ts +265 -0
  356. package/src/type-extractor/types/diagnostics.ts +99 -0
  357. package/src/type-extractor/types/graphql.ts +55 -0
  358. package/src/type-extractor/types/index.ts +37 -0
  359. package/src/type-extractor/types/ts-type-reference-factory.ts +137 -0
  360. package/src/type-extractor/types/typescript.ts +133 -0
  361. package/src/type-extractor/validator/type-validator.ts +77 -0
  362. package/README.md +0 -45
@@ -0,0 +1,101 @@
1
+ import ts from "typescript";
2
+ function getSymbolFromNode(node, checker) {
3
+ if (ts.isInterfaceDeclaration(node) || ts.isTypeAliasDeclaration(node)) {
4
+ return checker.getSymbolAtLocation(node.name);
5
+ }
6
+ if (ts.isEnumDeclaration(node)) {
7
+ return checker.getSymbolAtLocation(node.name);
8
+ }
9
+ if (ts.isVariableStatement(node)) {
10
+ const declaration = node.declarationList.declarations[0];
11
+ if (declaration && ts.isIdentifier(declaration.name)) {
12
+ return checker.getSymbolAtLocation(declaration.name);
13
+ }
14
+ }
15
+ return undefined;
16
+ }
17
+ function getTagCommentText(comment) {
18
+ if (typeof comment === "string") {
19
+ const trimmed = comment.replace(/\r\n/g, "\n").trim();
20
+ return trimmed === "" ? undefined : trimmed;
21
+ }
22
+ if (Array.isArray(comment)) {
23
+ const text = comment
24
+ .map((part) => part.text)
25
+ .join("")
26
+ .replace(/\r\n/g, "\n")
27
+ .trim();
28
+ return text === "" ? undefined : text;
29
+ }
30
+ return undefined;
31
+ }
32
+ function extractDescriptionTagContent(declarations) {
33
+ if (!declarations) {
34
+ return undefined;
35
+ }
36
+ for (const declaration of declarations) {
37
+ const jsdocTags = ts.getJSDocTags(declaration);
38
+ for (const tag of jsdocTags) {
39
+ if (tag.tagName.text === "description") {
40
+ return getTagCommentText(tag.comment);
41
+ }
42
+ }
43
+ }
44
+ return undefined;
45
+ }
46
+ function extractDeprecatedFromDeclarations(declarations) {
47
+ if (!declarations) {
48
+ return undefined;
49
+ }
50
+ for (const declaration of declarations) {
51
+ const jsdocTags = ts.getJSDocTags(declaration);
52
+ for (const tag of jsdocTags) {
53
+ if (tag.tagName.text === "deprecated") {
54
+ const reason = getTagCommentText(tag.comment);
55
+ return {
56
+ isDeprecated: true,
57
+ reason: reason ?? null,
58
+ };
59
+ }
60
+ }
61
+ }
62
+ return undefined;
63
+ }
64
+ function normalizeLineEndings(text) {
65
+ return text.replace(/\r\n/g, "\n");
66
+ }
67
+ function extractDescriptionFromSymbol(symbol, checker) {
68
+ const documentationComment = symbol.getDocumentationComment(checker);
69
+ if (documentationComment.length > 0) {
70
+ const description = normalizeLineEndings(ts.displayPartsToString(documentationComment).trim());
71
+ if (description !== "") {
72
+ return description;
73
+ }
74
+ }
75
+ const descriptionTagContent = extractDescriptionTagContent(symbol.getDeclarations());
76
+ if (descriptionTagContent) {
77
+ return normalizeLineEndings(descriptionTagContent);
78
+ }
79
+ return undefined;
80
+ }
81
+ export function extractTsDocInfo(node, checker) {
82
+ const symbol = getSymbolFromNode(node, checker);
83
+ if (!symbol) {
84
+ return { description: null, deprecated: null };
85
+ }
86
+ const description = extractDescriptionFromSymbol(symbol, checker);
87
+ const deprecated = extractDeprecatedFromDeclarations(symbol.getDeclarations());
88
+ return {
89
+ description: description ?? null,
90
+ deprecated: deprecated ?? null,
91
+ };
92
+ }
93
+ export function extractTsDocFromSymbol(symbol, checker) {
94
+ const description = extractDescriptionFromSymbol(symbol, checker);
95
+ const deprecated = extractDeprecatedFromDeclarations(symbol.getDeclarations());
96
+ return {
97
+ description: description ?? null,
98
+ deprecated: deprecated ?? null,
99
+ };
100
+ }
101
+ //# sourceMappingURL=tsdoc-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tsdoc-parser.js","sourceRoot":"","sources":["../../src/shared/tsdoc-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY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,EAAE,OAAO,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,iCAAiC,CAClD,MAAM,CAAC,eAAe,EAAE,CACzB,CAAC;IAEF,OAAO;QACL,WAAW,EAAE,WAAW,IAAI,IAAI;QAChC,UAAU,EAAE,UAAU,IAAI,IAAI;KAC/B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { GraphQLFieldType, TSTypeReference } from "../type-extractor/types/index.js";
2
+ export declare function convertTsTypeToGraphQLType(tsType: TSTypeReference, optional?: boolean): GraphQLFieldType;
3
+ //# sourceMappingURL=type-converter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-converter.d.ts","sourceRoot":"","sources":["../../src/shared/type-converter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EAChB,MAAM,kCAAkC,CAAC;AAsB1C,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,eAAe,EACvB,QAAQ,UAAQ,GACf,gBAAgB,CAsElB"}
@@ -0,0 +1,83 @@
1
+ import { PRIMITIVE_TYPE_MAP } from "./constants.js";
2
+ function convertElementTypeName(elementType) {
3
+ if (elementType.kind === "scalar") {
4
+ return elementType.scalarInfo?.scalarName ?? elementType.name ?? "String";
5
+ }
6
+ if (elementType.kind === "primitive") {
7
+ return PRIMITIVE_TYPE_MAP[elementType.name ?? ""] ?? "String";
8
+ }
9
+ if (elementType.kind === "reference") {
10
+ return elementType.name ?? "Unknown";
11
+ }
12
+ if (elementType.kind === "inlineObject") {
13
+ return "__INLINE_OBJECT__";
14
+ }
15
+ if (elementType.kind === "inlineEnum") {
16
+ return "__INLINE_ENUM__";
17
+ }
18
+ return elementType.name ?? "String";
19
+ }
20
+ export function convertTsTypeToGraphQLType(tsType, optional = false) {
21
+ const nullable = tsType.nullable || optional;
22
+ if (tsType.kind === "array") {
23
+ const elementType = tsType.elementType;
24
+ const elementTypeName = elementType
25
+ ? convertElementTypeName(elementType)
26
+ : "String";
27
+ const listItemNullable = elementType?.nullable ?? false;
28
+ return {
29
+ typeName: elementTypeName,
30
+ nullable,
31
+ list: true,
32
+ listItemNullable,
33
+ };
34
+ }
35
+ if (tsType.kind === "scalar") {
36
+ return {
37
+ typeName: tsType.scalarInfo?.scalarName ?? tsType.name ?? "String",
38
+ nullable,
39
+ list: false,
40
+ listItemNullable: null,
41
+ };
42
+ }
43
+ if (tsType.kind === "primitive") {
44
+ const graphqlType = PRIMITIVE_TYPE_MAP[tsType.name ?? ""] ?? "String";
45
+ return {
46
+ typeName: graphqlType,
47
+ nullable,
48
+ list: false,
49
+ listItemNullable: null,
50
+ };
51
+ }
52
+ if (tsType.kind === "reference") {
53
+ return {
54
+ typeName: tsType.name ?? "Unknown",
55
+ nullable,
56
+ list: false,
57
+ listItemNullable: null,
58
+ };
59
+ }
60
+ if (tsType.kind === "inlineObject") {
61
+ return {
62
+ typeName: "__INLINE_OBJECT__",
63
+ nullable,
64
+ list: false,
65
+ listItemNullable: null,
66
+ };
67
+ }
68
+ if (tsType.kind === "inlineEnum") {
69
+ return {
70
+ typeName: "__INLINE_ENUM__",
71
+ nullable,
72
+ list: false,
73
+ listItemNullable: null,
74
+ };
75
+ }
76
+ return {
77
+ typeName: tsType.name ?? "String",
78
+ nullable,
79
+ list: false,
80
+ listItemNullable: null,
81
+ };
82
+ }
83
+ //# sourceMappingURL=type-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-converter.js","sourceRoot":"","sources":["../../src/shared/type-converter.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,SAAS,sBAAsB,CAAC,WAA4B;IAC1D,IAAI,WAAW,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QAClC,OAAO,WAAW,CAAC,UAAU,EAAE,UAAU,IAAI,WAAW,CAAC,IAAI,IAAI,QAAQ,CAAC;IAC5E,CAAC;IACD,IAAI,WAAW,CAAC,IAAI,KAAK,WAAW,E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AC,IAAI,KAAK,WAAW,EAAE,CAAC;QAChC,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,CAAC,IAAI,QAAQ,CAAC;QACtE,OAAO;YACL,QAAQ,EAAE,WAAW;YACrB,QAAQ;YACR,IAAI,EAAE,KAAK;YACX,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE,CAAC;QAChC,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,IAAI,IAAI,SAAS;YAClC,QAAQ;YACR,IAAI,EAAE,KAAK;YACX,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;QACnC,OAAO;YACL,QAAQ,EAAE,mBAAmB;YAC7B,QAAQ;YACR,IAAI,EAAE,KAAK;YACX,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACjC,OAAO;YACL,QAAQ,EAAE,iBAAiB;YAC3B,QAAQ;YACR,IAAI,EAAE,KAAK;YACX,gBAAgB,EAAE,IAAI;SACvB,CAAC;IACJ,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,IAAI,IAAI,QAAQ;QACjC,QAAQ;QACR,IAAI,EAAE,KAAK;QACX,gBAAgB,EAAE,IAAI;KACvB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,82 @@
1
+ import ts from "typescript";
2
+ /**
3
+ * Extracts type name from a TypeNode.
4
+ * Handles both simple identifiers and qualified names.
5
+ */
6
+ export declare function getTypeNameFromNode(typeNode: ts.TypeNode): string | null;
7
+ /**
8
+ * Checks if a type represents null or undefined.
9
+ */
10
+ export declare function isNullOrUndefined(type: ts.Type): boolean;
11
+ /**
12
+ * Filters non-null type nodes from a union type node.
13
+ */
14
+ export declare function filterNonNullTypeNodes(typeNode: ts.UnionTypeNode): ts.TypeNode[];
15
+ /**
16
+ * Finds the first non-null type node from a union type node.
17
+ */
18
+ export declare function findNonNullTypeNode(typeNode: ts.UnionTypeNode): ts.TypeNode | undefined;
19
+ /**
20
+ * Checks if a union type contains null or undefined.
21
+ */
22
+ export declare function isNullableUnion(type: ts.Type): boolean;
23
+ /**
24
+ * Gets non-nullable types from a union type.
25
+ */
26
+ export declare function getNonNullableTypes(type: ts.Type): ts.Type[];
27
+ /**
28
+ * Checks if a type contains undefined.
29
+ * This is used to determine property optionality from resolved types,
30
+ * which correctly handles utility types like Required<T> and Partial<T>.
31
+ *
32
+ * In TypeScript:
33
+ * - Optional properties (?) add undefined to the type
34
+ * - Partial<T> adds undefined to all property types
35
+ * - Required<T> removes undefined from all property types
36
+ */
37
+ export declare function hasUndefinedInType(type: ts.Type): boolean;
38
+ /**
39
+ * Checks if a node has the export modifier.
40
+ */
41
+ export declare function isExported(node: ts.Node): boolean;
42
+ /**
43
+ * Checks if a type is an anonymous object type (like inline type literals).
44
+ * Named types and type aliases are not considered anonymous.
45
+ * This is used to determine if an intersection member should trigger
46
+ * treating the whole intersection as an inline object.
47
+ */
48
+ export declare function isAnonymousObjectType(type: ts.Type): boolean;
49
+ /**
50
+ * Extracts property symbols from a type, handling intersection types
51
+ * and falling back to getApparentType when getProperties() returns empty.
52
+ */
53
+ export declare function extractPropertySymbols(type: ts.Type, checker: ts.TypeChecker): ts.Symbol[];
54
+ /**
55
+ * Determines if an intersection type should be treated as an inline object.
56
+ * Returns true when:
57
+ * - Case 1: Has at least one anonymous/inline member
58
+ * - Case 2: All members are object-like types that should be merged
59
+ */
60
+ export declare function shouldTreatIntersectionAsInline(type: ts.IntersectionType): boolean;
61
+ /**
62
+ * Internal TypeScript symbol with parent reference.
63
+ * Used to access the parent enum symbol from enum member types.
64
+ */
65
+ export type SymbolWithParent = ts.Symbol & {
66
+ parent?: ts.Symbol;
67
+ };
68
+ /**
69
+ * Finds the parent enum symbol if all types belong to the same enum.
70
+ * Returns null if types are empty, don't have a common parent enum, or belong to different enums.
71
+ */
72
+ export declare function findEnumParentSymbol(types: readonly ts.Type[]): ts.Symbol | null;
73
+ /**
74
+ * Checks if a union type is a boolean union (true | false with optional null/undefined).
75
+ */
76
+ export declare function isBooleanUnion(type: ts.Type): boolean;
77
+ /**
78
+ * Resolves a symbol to its original symbol by following alias chains.
79
+ * This is necessary for re-exports where the symbol is an alias.
80
+ */
81
+ export declare function resolveOriginalSymbol(symbol: ts.Symbol, checker: ts.TypeChecker): ts.Symbol;
82
+ //# sourceMappingURL=typescript-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-utils.d.ts","sourceRoot":"","sources":["../../src/shared/typescript-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAG5B;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,GAAG,MAAM,GAAG,IAAI,CAUxE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAKxD;AAYD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,EAAE,CAAC,aAAa,GACzB,EAAE,CAAC,QAAQ,EAAE,CAEf;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,EAAE,CAAC,aAAa,GACzB,EAAE,CAAC,QAAQ,GAAG,SAAS,CAEzB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAGtD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAG5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAMzD;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAGjD;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAS5D;AAkBD;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,IAAI,EAAE,EAAE,CAAC,IAAI,EACb,OAAO,EAAE,EAAE,CAAC,WAAW,GACtB,EAAE,CAAC,MAAM,EAAE,CA0Bb;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC7C,IAAI,EAAE,EAAE,CAAC,gBAAgB,GACxB,OAAO,CAcT;AAED;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,EAAE,CAAC,MAAM,GAAG;IAAE,MAAM,CAAC,EAAE,EAAE,CAAC,MAAM,CAAA;CAAE,CAAC;AAElE;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,SAAS,EAAE,CAAC,IAAI,EAAE,GACxB,EAAE,CAAC,MAAM,GAAG,IAAI,CAgBlB;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,GAAG,OAAO,CAOrD;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,EAAE,CAAC,MAAM,EACjB,OAAO,EAAE,EAAE,CAAC,WAAW,GACtB,EAAE,CAAC,MAAM,CAKX"}
@@ -0,0 +1,197 @@
1
+ import ts from "typescript";
2
+ import { isInlineObjectType } from "./inline-object-utils.js";
3
+ /**
4
+ * Extracts type name from a TypeNode.
5
+ * Handles both simple identifiers and qualified names.
6
+ */
7
+ export function getTypeNameFromNode(typeNode) {
8
+ if (ts.isTypeReferenceNode(typeNode)) {
9
+ if (ts.isIdentifier(typeNode.typeName)) {
10
+ return typeNode.typeName.text;
11
+ }
12
+ if (ts.isQualifiedName(typeNode.typeName)) {
13
+ return typeNode.typeName.right.text;
14
+ }
15
+ }
16
+ return null;
17
+ }
18
+ /**
19
+ * Checks if a type represents null or undefined.
20
+ */
21
+ export function isNullOrUndefined(type) {
22
+ return ((type.flags & ts.TypeFlags.Null) !== 0 ||
23
+ (type.flags & ts.TypeFlags.Undefined) !== 0);
24
+ }
25
+ /**
26
+ * Checks if a TypeNode represents null (literal null type).
27
+ */
28
+ function isNullTypeNode(typeNode) {
29
+ return (ts.isLiteralTypeNode(typeNode) &&
30
+ typeNode.literal.kind === ts.SyntaxKind.NullKeyword);
31
+ }
32
+ /**
33
+ * Filters non-null type nodes from a union type node.
34
+ */
35
+ export function filterNonNullTypeNodes(typeNode) {
36
+ return typeNode.types.filter((t) => !isNullTypeNode(t));
37
+ }
38
+ /**
39
+ * Finds the first non-null type node from a union type node.
40
+ */
41
+ export function findNonNullTypeNode(typeNode) {
42
+ return filterNonNullTypeNodes(typeNode)[0];
43
+ }
44
+ /**
45
+ * Checks if a union type contains null or undefined.
46
+ */
47
+ export function isNullableUnion(type) {
48
+ if (!type.isUnion())
49
+ return false;
50
+ return type.types.some((t) => isNullOrUndefined(t));
51
+ }
52
+ /**
53
+ * Gets non-nullable types from a union type.
54
+ */
55
+ export function getNonNullableTypes(type) {
56
+ if (!type.isUnion())
57
+ return [type];
58
+ return type.types.filter((t) => !isNullOrUndefined(t));
59
+ }
60
+ /**
61
+ * Checks if a type contains undefined.
62
+ * This is used to determine property optionality from resolved types,
63
+ * which correctly handles utility types like Required<T> and Partial<T>.
64
+ *
65
+ * In TypeScript:
66
+ * - Optional properties (?) add undefined to the type
67
+ * - Partial<T> adds undefined to all property types
68
+ * - Required<T> removes undefined from all property types
69
+ */
70
+ export function hasUndefinedInType(type) {
71
+ if ((type.flags & ts.TypeFlags.Undefined) !== 0)
72
+ return true;
73
+ if (type.isUnion()) {
74
+ return type.types.some((t) => (t.flags & ts.TypeFlags.Undefined) !== 0);
75
+ }
76
+ return false;
77
+ }
78
+ /**
79
+ * Checks if a node has the export modifier.
80
+ */
81
+ export function isExported(node) {
82
+ const modifiers = ts.getCombinedModifierFlags(node);
83
+ return (modifiers & ts.ModifierFlags.Export) !== 0;
84
+ }
85
+ /**
86
+ * Checks if a type is an anonymous object type (like inline type literals).
87
+ * Named types and type aliases are not considered anonymous.
88
+ * This is used to determine if an intersection member should trigger
89
+ * treating the whole intersection as an inline object.
90
+ */
91
+ export function isAnonymousObjectType(type) {
92
+ if (type.aliasSymbol) {
93
+ return false;
94
+ }
95
+ if (!type.symbol) {
96
+ return true;
97
+ }
98
+ const symbolName = type.symbol.getName();
99
+ return symbolName === "__type" || symbolName === "";
100
+ }
101
+ /**
102
+ * Checks if a type is an object-like type (interface, anonymous object, or mapped type).
103
+ * Used to determine if an intersection of object types should be treated as inline.
104
+ */
105
+ function isObjectLikeType(type) {
106
+ if (!(type.flags & ts.TypeFlags.Object)) {
107
+ return false;
108
+ }
109
+ const objectType = type;
110
+ return ((objectType.objectFlags & ts.ObjectFlags.Interface) !== 0 ||
111
+ (objectType.objectFlags & ts.ObjectFlags.Anonymous) !== 0 ||
112
+ (objectType.objectFlags & ts.ObjectFlags.Mapped) !== 0);
113
+ }
114
+ /**
115
+ * Extracts property symbols from a type, handling intersection types
116
+ * and falling back to getApparentType when getProperties() returns empty.
117
+ */
118
+ export function extractPropertySymbols(type, checker) {
119
+ if (type.isIntersection()) {
120
+ const allProps = new Map();
121
+ for (const member of type.types) {
122
+ const memberProps = member.getProperties();
123
+ for (const prop of memberProps) {
124
+ const propName = prop.getName();
125
+ if (!allProps.has(propName)) {
126
+ allProps.set(propName, prop);
127
+ }
128
+ }
129
+ }
130
+ return [...allProps.values()];
131
+ }
132
+ const properties = type.getProperties();
133
+ if (properties.length > 0) {
134
+ return [...properties];
135
+ }
136
+ const apparentType = checker.getApparentType(type);
137
+ if (apparentType !== type) {
138
+ return [...apparentType.getProperties()];
139
+ }
140
+ return [];
141
+ }
142
+ /**
143
+ * Determines if an intersection type should be treated as an inline object.
144
+ * Returns true when:
145
+ * - Case 1: Has at least one anonymous/inline member
146
+ * - Case 2: All members are object-like types that should be merged
147
+ */
148
+ export function shouldTreatIntersectionAsInline(type) {
149
+ const hasResolvableMember = type.types.some((t) => isInlineObjectType(t) || isAnonymousObjectType(t));
150
+ if (hasResolvableMember) {
151
+ return true;
152
+ }
153
+ const allObjectLike = type.types.every((t) => isObjectLikeType(t));
154
+ if (allObjectLike) {
155
+ return true;
156
+ }
157
+ return false;
158
+ }
159
+ /**
160
+ * Finds the parent enum symbol if all types belong to the same enum.
161
+ * Returns null if types are empty, don't have a common parent enum, or belong to different enums.
162
+ */
163
+ export function findEnumParentSymbol(types) {
164
+ if (types.length === 0)
165
+ return null;
166
+ const firstSymbol = types[0].symbol;
167
+ const parentSymbol = firstSymbol?.parent;
168
+ if (!parentSymbol || !(parentSymbol.flags & ts.SymbolFlags.Enum)) {
169
+ return null;
170
+ }
171
+ const allBelongToSameEnum = types.every((t) => {
172
+ const sym = t.symbol;
173
+ return sym?.parent === parentSymbol;
174
+ });
175
+ return allBelongToSameEnum ? parentSymbol : null;
176
+ }
177
+ /**
178
+ * Checks if a union type is a boolean union (true | false with optional null/undefined).
179
+ */
180
+ export function isBooleanUnion(type) {
181
+ if (!type.isUnion())
182
+ return false;
183
+ const nonNullTypes = getNonNullableTypes(type);
184
+ return (nonNullTypes.length === 2 &&
185
+ nonNullTypes.every((t) => t.flags & ts.TypeFlags.BooleanLiteral));
186
+ }
187
+ /**
188
+ * Resolves a symbol to its original symbol by following alias chains.
189
+ * This is necessary for re-exports where the symbol is an alias.
190
+ */
191
+ export function resolveOriginalSymbol(symbol, checker) {
192
+ if (symbol.flags & ts.SymbolFlags.Alias) {
193
+ return checker.getAliasedSymbol(symbol);
194
+ }
195
+ return symbol;
196
+ }
197
+ //# sourceMappingURL=typescript-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typescript-utils.js","sourceRoot":"","sources":["../../src/shared/typescript-utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CA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+ export interface ExtractTypesResult {
3
+ readonly types: ReadonlyArray<GraphQLTypeInfo>;
4
+ readonly diagnostics: Diagnostics;
5
+ }
6
+ export declare function collectResults(types: ReadonlyArray<GraphQLTypeInfo>, diagnostics: ReadonlyArray<Diagnostic>): ExtractTypesResult;
7
+ //# sourceMappingURL=result-collector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-collector.d.ts","sourceRoot":"","sources":["../../../src/type-extractor/collector/result-collector.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EAEX,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC/C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC;CACnC;AA4BD,wBAAgB,cAAc,CAC5B,KAAK,EAAE,aAAa,CAAC,eAAe,CAAC,EACrC,WAAW,EAAE,aAAa,CAAC,UAAU,CAAC,GACrC,kBAAkB,CAcpB"}
@@ -0,0 +1,35 @@
1
+ import { deduplicateDiagnostics } from "../../shared/index.js";
2
+ function sortFields(fields) {
3
+ return [...fields].sort((a, b) => a.name.localeCompare(b.name));
4
+ }
5
+ function sortUnionMembers(members) {
6
+ return [...members].sort((a, b) => a.localeCompare(b));
7
+ }
8
+ function sortType(type) {
9
+ if (type.kind === "Object" && type.fields) {
10
+ return {
11
+ ...type,
12
+ fields: sortFields(type.fields),
13
+ };
14
+ }
15
+ if (type.kind === "Union" && type.unionMembers) {
16
+ return {
17
+ ...type,
18
+ unionMembers: sortUnionMembers(type.unionMembers),
19
+ };
20
+ }
21
+ return type;
22
+ }
23
+ export function collectResults(types, diagnostics) {
24
+ const sortedTypes = [...types]
25
+ .sort((a, b) => a.name.localeCompare(b.name))
26
+ .map(sortType);
27
+ const uniqueDiagnostics = deduplicateDiagnostics(diagnostics);
28
+ const errors = uniqueDiagnostics.filter((d) => d.severity === "error");
29
+ const warnings = uniqueDiagnostics.filter((d) => d.severity === "warning");
30
+ return {
31
+ types: sortedTypes,
32
+ diagnostics: { errors, warnings },
33
+ };
34
+ }
35
+ //# sourceMappingURL=result-collector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result-collector.js","sourceRoot":"","sources":["../../../src/type-extractor/collector/result-collector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAa/D,SAAS,UAAU,CAAC,MAAgC;IAClD,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,gBAAgB,CAAC,OAA8B;IACtD,OAAO,CAAC,GAAG,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;AACzD,CAAC;AAED,SAAS,QAAQ,CAAC,IAAqB;IACrC,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;QAC1C,OAAO;YACL,GAAG,IAAI;YACP,MAAM,EAAE,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC;SAChC,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QAC/C,OAAO;YACL,GAAG,IAAI;YACP,YAAY,EAAE,gBAAgB,CAAC,IAAI,CAAC,YAAY,CAAC;SAClD,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,cAAc,CAC5B,KAAqC,EACrC,WAAsC;IAEtC,MAAM,WAAW,GAAG,CAAC,GAAG,KAAK,CAAC;SAC3B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SAC5C,GAAG,CAAC,QAAQ,CAAC,CAAC;IAEjB,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,WAAW,CAAC,CAAC;IAE9D,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;IAE3E,OAAO;QACL,KAAK,EAAE,WAAW;QAClB,WAAW,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;KAClC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Information about a detected scalar type from metadata detection.
3
+ */
4
+ export interface ScalarMetadataInfo {
5
+ /** The GraphQL scalar name */
6
+ readonly scalarName: string;
7
+ /** The TypeScript type name */
8
+ readonly typeName: string;
9
+ /** Usage constraint: "input", "output", or null for both */
10
+ readonly only: "input" | "output" | null;
11
+ /** Source file path */
12
+ readonly sourceFile: string;
13
+ /** Line number in source file */
14
+ readonly line: number;
15
+ /** TSDoc description if available */
16
+ readonly description: string | null;
17
+ }
18
+ /**
19
+ * Configuration scalar mapping information.
20
+ */
21
+ export interface ConfigScalarMapping extends ScalarMetadataInfo {
22
+ /** Whether this mapping comes from config file */
23
+ readonly fromConfig: boolean;
24
+ }
25
+ /**
26
+ * Reference to a scalar type.
27
+ */
28
+ export interface ScalarTypeRef {
29
+ /** TypeScript type name */
30
+ readonly typeName: string;
31
+ /** Source file path */
32
+ readonly sourceFile: string;
33
+ /** Line number in source file */
34
+ readonly line: number;
35
+ }
36
+ /**
37
+ * Description source information.
38
+ */
39
+ export interface DescriptionSource {
40
+ /** Description text */
41
+ readonly text: string;
42
+ /** Source file path */
43
+ readonly sourceFile: string;
44
+ /** Line number in source file */
45
+ readonly line: number;
46
+ /** Whether this description comes from config */
47
+ readonly fromConfig: boolean;
48
+ }
49
+ /**
50
+ * Collected scalar type with input/output type information.
51
+ */
52
+ export interface CollectedScalarType {
53
+ /** GraphQL scalar name */
54
+ readonly scalarName: string;
55
+ /** Input type reference (exactly one required) */
56
+ readonly inputType: ScalarTypeRef | null;
57
+ /** Output type references (one or more required, union built from these) */
58
+ readonly outputTypes: ReadonlyArray<ScalarTypeRef>;
59
+ /** Description sources */
60
+ readonly descriptions: ReadonlyArray<DescriptionSource>;
61
+ /** Whether this is a custom scalar (not built-in) */
62
+ readonly isCustom: boolean;
63
+ }
64
+ /**
65
+ * Diagnostic error information.
66
+ */
67
+ export interface ScalarCollectorDiagnostic {
68
+ readonly code: "MULTIPLE_INPUT_TYPES" | "MISSING_INPUT_TYPE" | "MISSING_OUTPUT_TYPE";
69
+ readonly message: string;
70
+ readonly severity: "error";
71
+ }
72
+ /**
73
+ * Result type for scalar collection.
74
+ */
75
+ export type CollectScalarsResult = {
76
+ success: true;
77
+ data: ReadonlyArray<CollectedScalarType>;
78
+ } | {
79
+ success: false;
80
+ errors: ReadonlyArray<ScalarCollectorDiagnostic>;
81
+ };
82
+ /**
83
+ * Merges multiple descriptions into a single string with blank line separators.
84
+ * Descriptions are expected to be pre-sorted by file path alphabetically
85
+ * and by line number within the same file.
86
+ *
87
+ * @param descriptions - Array of description sources to merge
88
+ * @returns Merged description string, or null if no descriptions available
89
+ */
90
+ export declare function mergeDescriptions(descriptions: ReadonlyArray<DescriptionSource>): string | null;
91
+ /**
92
+ * Options for scalar collection.
93
+ */
94
+ export interface CollectScalarsOptions {
95
+ /** Root path for normalizing source file paths in error messages */
96
+ readonly sourceRoot?: string | null;
97
+ }
98
+ /**
99
+ * Collects scalar definitions from types and config,
100
+ * validates constraints, and builds type parameters.
101
+ *
102
+ * @param scalarInfos - Scalar metadata from source files
103
+ * @param configScalars - Scalar mappings from config file
104
+ * @param options - Collection options
105
+ * @returns Result with collected scalars or diagnostics
106
+ */
107
+ export declare function collectScalars(scalarInfos: ReadonlyArray<ScalarMetadataInfo>, configScalars: ReadonlyArray<ConfigScalarMapping>, options?: CollectScalarsOptions): CollectScalarsResult;
108
+ //# sourceMappingURL=scalar-collector.d.ts.map