@elench/testkit 0.1.65 → 0.1.66

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 (305) hide show
  1. package/lib/app/browser-bridge.mjs +66 -0
  2. package/lib/app/configs.mjs +81 -0
  3. package/lib/app/configs.test.mjs +34 -0
  4. package/lib/cli/command-helpers.mjs +2 -10
  5. package/lib/cli/commands/browser/serve.mjs +3 -62
  6. package/lib/cli/db.mjs +3 -68
  7. package/lib/config/binaries.mjs +34 -0
  8. package/lib/config/database.mjs +9 -6
  9. package/lib/config/index.mjs +2 -31
  10. package/lib/config/runtime.mjs +24 -95
  11. package/lib/config/validation.mjs +18 -62
  12. package/lib/coverage/backend-discovery.mjs +68 -85
  13. package/lib/coverage/backend-discovery.test.mjs +55 -46
  14. package/lib/coverage/graph-builder.mjs +5 -5
  15. package/lib/coverage/next-ir-to-graph.mjs +0 -1
  16. package/lib/coverage/routing.mjs +2 -29
  17. package/lib/coverage/routing.test.mjs +0 -16
  18. package/lib/coverage/shared.mjs +22 -82
  19. package/lib/database/fingerprint.mjs +1 -1
  20. package/lib/known-failures/github-cache.mjs +159 -0
  21. package/lib/known-failures/github-transport.mjs +174 -0
  22. package/lib/known-failures/github.mjs +17 -325
  23. package/lib/runner/default-runtime-runner.mjs +4 -10
  24. package/lib/runner/execution-config.mjs +12 -83
  25. package/lib/runner/live-run.mjs +45 -0
  26. package/lib/runner/managed-processes.mjs +29 -0
  27. package/lib/runner/orchestrator.mjs +57 -188
  28. package/lib/runner/playwright-runner.mjs +4 -11
  29. package/lib/runner/run-finalization.mjs +132 -0
  30. package/lib/runner/run-guards.mjs +45 -0
  31. package/lib/runner/runtime-preparation.mjs +1 -1
  32. package/lib/runner/services.mjs +3 -4
  33. package/lib/runner/template-steps.mjs +8 -45
  34. package/lib/runner/template.mjs +7 -28
  35. package/lib/shared/configured-steps.mjs +178 -0
  36. package/lib/shared/configured-steps.test.mjs +73 -0
  37. package/lib/shared/execution-schema.mjs +74 -0
  38. package/lib/shared/execution-schema.test.mjs +26 -0
  39. package/node_modules/@elench/next-analysis/dist/api-routes.d.ts +7 -0
  40. package/node_modules/@elench/next-analysis/dist/api-routes.d.ts.map +1 -0
  41. package/node_modules/@elench/next-analysis/dist/api-routes.js +66 -0
  42. package/node_modules/@elench/next-analysis/dist/api-routes.js.map +1 -0
  43. package/node_modules/@elench/next-analysis/dist/app-root.d.ts +2 -0
  44. package/node_modules/@elench/next-analysis/dist/app-root.d.ts.map +1 -0
  45. package/node_modules/@elench/next-analysis/dist/app-root.js +7 -0
  46. package/node_modules/@elench/next-analysis/dist/app-root.js.map +1 -0
  47. package/node_modules/@elench/next-analysis/dist/backend-links.d.ts +8 -0
  48. package/node_modules/@elench/next-analysis/dist/backend-links.d.ts.map +1 -0
  49. package/node_modules/@elench/next-analysis/dist/backend-links.js +30 -0
  50. package/node_modules/@elench/next-analysis/dist/backend-links.js.map +1 -0
  51. package/node_modules/@elench/next-analysis/dist/index.d.ts +11 -0
  52. package/node_modules/@elench/next-analysis/dist/index.d.ts.map +1 -0
  53. package/node_modules/@elench/next-analysis/dist/index.js +10 -0
  54. package/node_modules/@elench/next-analysis/dist/index.js.map +1 -0
  55. package/node_modules/@elench/next-analysis/dist/pages.d.ts +7 -0
  56. package/node_modules/@elench/next-analysis/dist/pages.d.ts.map +1 -0
  57. package/node_modules/@elench/next-analysis/dist/pages.js +47 -0
  58. package/node_modules/@elench/next-analysis/dist/pages.js.map +1 -0
  59. package/node_modules/@elench/next-analysis/dist/project.d.ts +3 -0
  60. package/node_modules/@elench/next-analysis/dist/project.d.ts.map +1 -0
  61. package/node_modules/@elench/next-analysis/dist/project.js +102 -0
  62. package/node_modules/@elench/next-analysis/dist/project.js.map +1 -0
  63. package/node_modules/@elench/next-analysis/dist/route-tree.d.ts +7 -0
  64. package/node_modules/@elench/next-analysis/dist/route-tree.d.ts.map +1 -0
  65. package/node_modules/@elench/next-analysis/dist/route-tree.js +575 -0
  66. package/node_modules/@elench/next-analysis/dist/route-tree.js.map +1 -0
  67. package/node_modules/@elench/next-analysis/dist/routes.d.ts +6 -0
  68. package/node_modules/@elench/next-analysis/dist/routes.d.ts.map +1 -0
  69. package/node_modules/@elench/next-analysis/dist/routes.js +41 -0
  70. package/node_modules/@elench/next-analysis/dist/routes.js.map +1 -0
  71. package/node_modules/@elench/next-analysis/dist/server-actions.d.ts +7 -0
  72. package/node_modules/@elench/next-analysis/dist/server-actions.d.ts.map +1 -0
  73. package/node_modules/@elench/next-analysis/dist/server-actions.js +37 -0
  74. package/node_modules/@elench/next-analysis/dist/server-actions.js.map +1 -0
  75. package/node_modules/@elench/next-analysis/dist/shared.d.ts +57 -0
  76. package/node_modules/@elench/next-analysis/dist/shared.d.ts.map +1 -0
  77. package/node_modules/@elench/next-analysis/dist/shared.js +229 -0
  78. package/node_modules/@elench/next-analysis/dist/shared.js.map +1 -0
  79. package/node_modules/@elench/next-analysis/dist/swc.d.ts +53 -0
  80. package/node_modules/@elench/next-analysis/dist/swc.d.ts.map +1 -0
  81. package/node_modules/@elench/next-analysis/dist/swc.js +387 -0
  82. package/node_modules/@elench/next-analysis/dist/swc.js.map +1 -0
  83. package/node_modules/@elench/next-analysis/dist/types.d.ts +125 -0
  84. package/node_modules/@elench/next-analysis/dist/types.d.ts.map +1 -0
  85. package/node_modules/@elench/next-analysis/dist/types.js +2 -0
  86. package/node_modules/@elench/next-analysis/dist/types.js.map +1 -0
  87. package/node_modules/@elench/next-analysis/package.json +15 -2
  88. package/node_modules/@elench/testkit-bridge/dist/index.d.ts +36 -0
  89. package/node_modules/@elench/testkit-bridge/dist/index.d.ts.map +1 -0
  90. package/node_modules/@elench/testkit-bridge/dist/index.js +538 -0
  91. package/node_modules/@elench/testkit-bridge/dist/index.js.map +1 -0
  92. package/node_modules/@elench/testkit-bridge/package.json +16 -5
  93. package/node_modules/@elench/testkit-protocol/dist/index.d.ts +190 -0
  94. package/node_modules/@elench/testkit-protocol/dist/index.d.ts.map +1 -0
  95. package/node_modules/@elench/testkit-protocol/dist/index.js +296 -0
  96. package/node_modules/@elench/testkit-protocol/dist/index.js.map +1 -0
  97. package/node_modules/@elench/testkit-protocol/package.json +14 -7
  98. package/node_modules/@elench/ts-analysis/dist/callables.d.ts +8 -0
  99. package/node_modules/@elench/ts-analysis/dist/callables.d.ts.map +1 -0
  100. package/node_modules/@elench/ts-analysis/dist/callables.js +126 -0
  101. package/node_modules/@elench/ts-analysis/dist/callables.js.map +1 -0
  102. package/node_modules/@elench/ts-analysis/dist/exports.d.ts +6 -0
  103. package/node_modules/@elench/ts-analysis/dist/exports.d.ts.map +1 -0
  104. package/node_modules/@elench/ts-analysis/dist/exports.js +70 -0
  105. package/node_modules/@elench/ts-analysis/dist/exports.js.map +1 -0
  106. package/node_modules/@elench/ts-analysis/dist/index.d.ts +10 -0
  107. package/node_modules/@elench/ts-analysis/dist/index.d.ts.map +1 -0
  108. package/node_modules/@elench/ts-analysis/{src/index.mjs → dist/index.js} +9 -14
  109. package/node_modules/@elench/ts-analysis/dist/index.js.map +1 -0
  110. package/node_modules/@elench/ts-analysis/dist/jsx.d.ts +9 -0
  111. package/node_modules/@elench/ts-analysis/dist/jsx.d.ts.map +1 -0
  112. package/node_modules/@elench/ts-analysis/dist/jsx.js +68 -0
  113. package/node_modules/@elench/ts-analysis/dist/jsx.js.map +1 -0
  114. package/node_modules/@elench/ts-analysis/dist/project.d.ts +5 -0
  115. package/node_modules/@elench/ts-analysis/dist/project.d.ts.map +1 -0
  116. package/node_modules/@elench/ts-analysis/dist/project.js +90 -0
  117. package/node_modules/@elench/ts-analysis/dist/project.js.map +1 -0
  118. package/node_modules/@elench/ts-analysis/dist/requests.d.ts +6 -0
  119. package/node_modules/@elench/ts-analysis/dist/requests.d.ts.map +1 -0
  120. package/node_modules/@elench/ts-analysis/dist/requests.js +140 -0
  121. package/node_modules/@elench/ts-analysis/dist/requests.js.map +1 -0
  122. package/node_modules/@elench/ts-analysis/dist/resolution.d.ts +4 -0
  123. package/node_modules/@elench/ts-analysis/dist/resolution.d.ts.map +1 -0
  124. package/node_modules/@elench/ts-analysis/dist/resolution.js +53 -0
  125. package/node_modules/@elench/ts-analysis/dist/resolution.js.map +1 -0
  126. package/node_modules/@elench/ts-analysis/dist/shared.d.ts +6 -0
  127. package/node_modules/@elench/ts-analysis/dist/shared.d.ts.map +1 -0
  128. package/node_modules/@elench/ts-analysis/dist/shared.js +31 -0
  129. package/node_modules/@elench/ts-analysis/dist/shared.js.map +1 -0
  130. package/node_modules/@elench/ts-analysis/dist/syntax.d.ts +7 -0
  131. package/node_modules/@elench/ts-analysis/dist/syntax.d.ts.map +1 -0
  132. package/node_modules/@elench/ts-analysis/dist/syntax.js +27 -0
  133. package/node_modules/@elench/ts-analysis/dist/syntax.js.map +1 -0
  134. package/node_modules/@elench/ts-analysis/dist/types.d.ts +58 -0
  135. package/node_modules/@elench/ts-analysis/dist/types.d.ts.map +1 -0
  136. package/node_modules/@elench/ts-analysis/dist/types.js +2 -0
  137. package/node_modules/@elench/ts-analysis/dist/types.js.map +1 -0
  138. package/node_modules/@elench/ts-analysis/package.json +18 -2
  139. package/node_modules/typescript/LICENSE.txt +55 -0
  140. package/node_modules/typescript/README.md +50 -0
  141. package/node_modules/typescript/SECURITY.md +41 -0
  142. package/node_modules/typescript/ThirdPartyNoticeText.txt +193 -0
  143. package/node_modules/typescript/bin/tsc +2 -0
  144. package/node_modules/typescript/bin/tsserver +2 -0
  145. package/node_modules/typescript/lib/_tsc.js +133818 -0
  146. package/node_modules/typescript/lib/_tsserver.js +659 -0
  147. package/node_modules/typescript/lib/_typingsInstaller.js +222 -0
  148. package/node_modules/typescript/lib/cs/diagnosticMessages.generated.json +2122 -0
  149. package/node_modules/typescript/lib/de/diagnosticMessages.generated.json +2122 -0
  150. package/node_modules/typescript/lib/es/diagnosticMessages.generated.json +2122 -0
  151. package/node_modules/typescript/lib/fr/diagnosticMessages.generated.json +2122 -0
  152. package/node_modules/typescript/lib/it/diagnosticMessages.generated.json +2122 -0
  153. package/node_modules/typescript/lib/ja/diagnosticMessages.generated.json +2122 -0
  154. package/node_modules/typescript/lib/ko/diagnosticMessages.generated.json +2122 -0
  155. package/node_modules/typescript/lib/lib.d.ts +22 -0
  156. package/node_modules/typescript/lib/lib.decorators.d.ts +384 -0
  157. package/node_modules/typescript/lib/lib.decorators.legacy.d.ts +22 -0
  158. package/node_modules/typescript/lib/lib.dom.asynciterable.d.ts +41 -0
  159. package/node_modules/typescript/lib/lib.dom.d.ts +39429 -0
  160. package/node_modules/typescript/lib/lib.dom.iterable.d.ts +571 -0
  161. package/node_modules/typescript/lib/lib.es2015.collection.d.ts +147 -0
  162. package/node_modules/typescript/lib/lib.es2015.core.d.ts +597 -0
  163. package/node_modules/typescript/lib/lib.es2015.d.ts +28 -0
  164. package/node_modules/typescript/lib/lib.es2015.generator.d.ts +77 -0
  165. package/node_modules/typescript/lib/lib.es2015.iterable.d.ts +605 -0
  166. package/node_modules/typescript/lib/lib.es2015.promise.d.ts +81 -0
  167. package/node_modules/typescript/lib/lib.es2015.proxy.d.ts +128 -0
  168. package/node_modules/typescript/lib/lib.es2015.reflect.d.ts +144 -0
  169. package/node_modules/typescript/lib/lib.es2015.symbol.d.ts +46 -0
  170. package/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts +326 -0
  171. package/node_modules/typescript/lib/lib.es2016.array.include.d.ts +116 -0
  172. package/node_modules/typescript/lib/lib.es2016.d.ts +21 -0
  173. package/node_modules/typescript/lib/lib.es2016.full.d.ts +23 -0
  174. package/node_modules/typescript/lib/lib.es2016.intl.d.ts +31 -0
  175. package/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts +21 -0
  176. package/node_modules/typescript/lib/lib.es2017.d.ts +26 -0
  177. package/node_modules/typescript/lib/lib.es2017.date.d.ts +31 -0
  178. package/node_modules/typescript/lib/lib.es2017.full.d.ts +23 -0
  179. package/node_modules/typescript/lib/lib.es2017.intl.d.ts +44 -0
  180. package/node_modules/typescript/lib/lib.es2017.object.d.ts +49 -0
  181. package/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts +135 -0
  182. package/node_modules/typescript/lib/lib.es2017.string.d.ts +45 -0
  183. package/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts +53 -0
  184. package/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts +77 -0
  185. package/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts +53 -0
  186. package/node_modules/typescript/lib/lib.es2018.d.ts +24 -0
  187. package/node_modules/typescript/lib/lib.es2018.full.d.ts +24 -0
  188. package/node_modules/typescript/lib/lib.es2018.intl.d.ts +83 -0
  189. package/node_modules/typescript/lib/lib.es2018.promise.d.ts +30 -0
  190. package/node_modules/typescript/lib/lib.es2018.regexp.d.ts +37 -0
  191. package/node_modules/typescript/lib/lib.es2019.array.d.ts +79 -0
  192. package/node_modules/typescript/lib/lib.es2019.d.ts +24 -0
  193. package/node_modules/typescript/lib/lib.es2019.full.d.ts +24 -0
  194. package/node_modules/typescript/lib/lib.es2019.intl.d.ts +23 -0
  195. package/node_modules/typescript/lib/lib.es2019.object.d.ts +33 -0
  196. package/node_modules/typescript/lib/lib.es2019.string.d.ts +37 -0
  197. package/node_modules/typescript/lib/lib.es2019.symbol.d.ts +24 -0
  198. package/node_modules/typescript/lib/lib.es2020.bigint.d.ts +765 -0
  199. package/node_modules/typescript/lib/lib.es2020.d.ts +27 -0
  200. package/node_modules/typescript/lib/lib.es2020.date.d.ts +42 -0
  201. package/node_modules/typescript/lib/lib.es2020.full.d.ts +24 -0
  202. package/node_modules/typescript/lib/lib.es2020.intl.d.ts +474 -0
  203. package/node_modules/typescript/lib/lib.es2020.number.d.ts +28 -0
  204. package/node_modules/typescript/lib/lib.es2020.promise.d.ts +47 -0
  205. package/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts +99 -0
  206. package/node_modules/typescript/lib/lib.es2020.string.d.ts +44 -0
  207. package/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts +41 -0
  208. package/node_modules/typescript/lib/lib.es2021.d.ts +23 -0
  209. package/node_modules/typescript/lib/lib.es2021.full.d.ts +24 -0
  210. package/node_modules/typescript/lib/lib.es2021.intl.d.ts +166 -0
  211. package/node_modules/typescript/lib/lib.es2021.promise.d.ts +48 -0
  212. package/node_modules/typescript/lib/lib.es2021.string.d.ts +33 -0
  213. package/node_modules/typescript/lib/lib.es2021.weakref.d.ts +78 -0
  214. package/node_modules/typescript/lib/lib.es2022.array.d.ts +121 -0
  215. package/node_modules/typescript/lib/lib.es2022.d.ts +25 -0
  216. package/node_modules/typescript/lib/lib.es2022.error.d.ts +75 -0
  217. package/node_modules/typescript/lib/lib.es2022.full.d.ts +24 -0
  218. package/node_modules/typescript/lib/lib.es2022.intl.d.ts +145 -0
  219. package/node_modules/typescript/lib/lib.es2022.object.d.ts +26 -0
  220. package/node_modules/typescript/lib/lib.es2022.regexp.d.ts +39 -0
  221. package/node_modules/typescript/lib/lib.es2022.string.d.ts +25 -0
  222. package/node_modules/typescript/lib/lib.es2023.array.d.ts +924 -0
  223. package/node_modules/typescript/lib/lib.es2023.collection.d.ts +21 -0
  224. package/node_modules/typescript/lib/lib.es2023.d.ts +22 -0
  225. package/node_modules/typescript/lib/lib.es2023.full.d.ts +24 -0
  226. package/node_modules/typescript/lib/lib.es2023.intl.d.ts +56 -0
  227. package/node_modules/typescript/lib/lib.es2024.arraybuffer.d.ts +65 -0
  228. package/node_modules/typescript/lib/lib.es2024.collection.d.ts +29 -0
  229. package/node_modules/typescript/lib/lib.es2024.d.ts +26 -0
  230. package/node_modules/typescript/lib/lib.es2024.full.d.ts +24 -0
  231. package/node_modules/typescript/lib/lib.es2024.object.d.ts +29 -0
  232. package/node_modules/typescript/lib/lib.es2024.promise.d.ts +35 -0
  233. package/node_modules/typescript/lib/lib.es2024.regexp.d.ts +25 -0
  234. package/node_modules/typescript/lib/lib.es2024.sharedmemory.d.ts +68 -0
  235. package/node_modules/typescript/lib/lib.es2024.string.d.ts +29 -0
  236. package/node_modules/typescript/lib/lib.es5.d.ts +4601 -0
  237. package/node_modules/typescript/lib/lib.es6.d.ts +23 -0
  238. package/node_modules/typescript/lib/lib.esnext.array.d.ts +35 -0
  239. package/node_modules/typescript/lib/lib.esnext.collection.d.ts +96 -0
  240. package/node_modules/typescript/lib/lib.esnext.d.ts +29 -0
  241. package/node_modules/typescript/lib/lib.esnext.decorators.d.ts +28 -0
  242. package/node_modules/typescript/lib/lib.esnext.disposable.d.ts +193 -0
  243. package/node_modules/typescript/lib/lib.esnext.error.d.ts +24 -0
  244. package/node_modules/typescript/lib/lib.esnext.float16.d.ts +445 -0
  245. package/node_modules/typescript/lib/lib.esnext.full.d.ts +24 -0
  246. package/node_modules/typescript/lib/lib.esnext.intl.d.ts +21 -0
  247. package/node_modules/typescript/lib/lib.esnext.iterator.d.ts +148 -0
  248. package/node_modules/typescript/lib/lib.esnext.promise.d.ts +34 -0
  249. package/node_modules/typescript/lib/lib.esnext.sharedmemory.d.ts +25 -0
  250. package/node_modules/typescript/lib/lib.scripthost.d.ts +322 -0
  251. package/node_modules/typescript/lib/lib.webworker.asynciterable.d.ts +41 -0
  252. package/node_modules/typescript/lib/lib.webworker.d.ts +13150 -0
  253. package/node_modules/typescript/lib/lib.webworker.importscripts.d.ts +23 -0
  254. package/node_modules/typescript/lib/lib.webworker.iterable.d.ts +340 -0
  255. package/node_modules/typescript/lib/pl/diagnosticMessages.generated.json +2122 -0
  256. package/node_modules/typescript/lib/pt-br/diagnosticMessages.generated.json +2122 -0
  257. package/node_modules/typescript/lib/ru/diagnosticMessages.generated.json +2122 -0
  258. package/node_modules/typescript/lib/tr/diagnosticMessages.generated.json +2122 -0
  259. package/node_modules/typescript/lib/tsc.js +8 -0
  260. package/node_modules/typescript/lib/tsserver.js +8 -0
  261. package/node_modules/typescript/lib/tsserverlibrary.d.ts +17 -0
  262. package/node_modules/typescript/lib/tsserverlibrary.js +21 -0
  263. package/node_modules/typescript/lib/typesMap.json +497 -0
  264. package/node_modules/typescript/lib/typescript.d.ts +11437 -0
  265. package/node_modules/typescript/lib/typescript.js +200276 -0
  266. package/node_modules/typescript/lib/typingsInstaller.js +8 -0
  267. package/node_modules/typescript/lib/watchGuard.js +53 -0
  268. package/node_modules/typescript/lib/zh-cn/diagnosticMessages.generated.json +2122 -0
  269. package/node_modules/typescript/lib/zh-tw/diagnosticMessages.generated.json +2122 -0
  270. package/node_modules/typescript/package.json +120 -0
  271. package/package.json +12 -9
  272. package/lib/coverage/fs-walk.mjs +0 -64
  273. package/node_modules/@elench/next-analysis/src/api-routes.mjs +0 -81
  274. package/node_modules/@elench/next-analysis/src/api-routes.test.mjs +0 -22
  275. package/node_modules/@elench/next-analysis/src/app-root.mjs +0 -7
  276. package/node_modules/@elench/next-analysis/src/backend-links.mjs +0 -31
  277. package/node_modules/@elench/next-analysis/src/index.mjs +0 -21
  278. package/node_modules/@elench/next-analysis/src/pages.mjs +0 -68
  279. package/node_modules/@elench/next-analysis/src/project.mjs +0 -94
  280. package/node_modules/@elench/next-analysis/src/project.test.mjs +0 -35
  281. package/node_modules/@elench/next-analysis/src/route-tree.mjs +0 -621
  282. package/node_modules/@elench/next-analysis/src/routes.mjs +0 -41
  283. package/node_modules/@elench/next-analysis/src/routes.test.mjs +0 -25
  284. package/node_modules/@elench/next-analysis/src/server-actions.mjs +0 -53
  285. package/node_modules/@elench/next-analysis/src/server-actions.test.mjs +0 -37
  286. package/node_modules/@elench/next-analysis/src/shared.mjs +0 -209
  287. package/node_modules/@elench/next-analysis/src/swc.mjs +0 -388
  288. package/node_modules/@elench/testkit-bridge/src/index.mjs +0 -583
  289. package/node_modules/@elench/testkit-bridge/src/index.test.mjs +0 -409
  290. package/node_modules/@elench/testkit-protocol/src/index.d.ts +0 -231
  291. package/node_modules/@elench/testkit-protocol/src/index.mjs +0 -265
  292. package/node_modules/@elench/testkit-protocol/src/index.test.mjs +0 -242
  293. package/node_modules/@elench/ts-analysis/src/callables.mjs +0 -135
  294. package/node_modules/@elench/ts-analysis/src/callables.test.mjs +0 -55
  295. package/node_modules/@elench/ts-analysis/src/exports.mjs +0 -69
  296. package/node_modules/@elench/ts-analysis/src/exports.test.mjs +0 -50
  297. package/node_modules/@elench/ts-analysis/src/jsx.mjs +0 -69
  298. package/node_modules/@elench/ts-analysis/src/jsx.test.mjs +0 -43
  299. package/node_modules/@elench/ts-analysis/src/project.mjs +0 -100
  300. package/node_modules/@elench/ts-analysis/src/project.test.mjs +0 -54
  301. package/node_modules/@elench/ts-analysis/src/requests.mjs +0 -141
  302. package/node_modules/@elench/ts-analysis/src/requests.test.mjs +0 -35
  303. package/node_modules/@elench/ts-analysis/src/resolution.mjs +0 -53
  304. package/node_modules/@elench/ts-analysis/src/shared.mjs +0 -32
  305. package/node_modules/@elench/ts-analysis/src/syntax.mjs +0 -27
@@ -1,265 +0,0 @@
1
- export const TESTKIT_BROWSER_PROTOCOL_VERSION = 1;
2
- export const TESTKIT_COVERAGE_GRAPH_VERSION = 1;
3
-
4
- const TARGET_KINDS = new Set(["testId", "role", "text", "css", "xpath", "component"]);
5
- const CONFIDENCE_LEVELS = new Set(["low", "medium", "high"]);
6
- const FAILURE_STATES = new Set(["failing", "healthy", "unavailable"]);
7
- const COVERAGE_STATES = new Set(["covered", "missing", "unavailable"]);
8
- const NODE_KINDS = new Set([
9
- "page_view",
10
- "ui_surface",
11
- "ui_action",
12
- "client_request",
13
- "api_route",
14
- "server_action",
15
- "server_capability",
16
- "data_capability",
17
- "test_file",
18
- ]);
19
- const EDGE_KINDS = new Set([
20
- "contains",
21
- "renders",
22
- "triggers",
23
- "requests",
24
- "handles",
25
- "delegates_to",
26
- "covers",
27
- ]);
28
- const EVIDENCE_SOURCES = new Set(["convention", "static", "runtime"]);
29
-
30
- export function normalizeBrowserTarget(value) {
31
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
32
- const kind = normalizeOptionalString(value.kind);
33
- const targetValue = normalizeOptionalString(value.value);
34
- if (!kind || !TARGET_KINDS.has(kind) || !targetValue) return null;
35
- const label = normalizeOptionalString(value.label);
36
- const confidence = normalizeOptionalString(value.confidence);
37
- return {
38
- kind,
39
- value: targetValue,
40
- ...(label ? { label } : {}),
41
- ...(confidence && CONFIDENCE_LEVELS.has(confidence) ? { confidence } : {}),
42
- };
43
- }
44
-
45
- export function normalizeBrowserMetadata(value) {
46
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
47
- const label = normalizeOptionalString(value.label);
48
- const origins = normalizeStringArray(value.origins);
49
- const routes = normalizeStringArray(value.routes);
50
- const targets = Array.isArray(value.targets) ? value.targets.map(normalizeBrowserTarget).filter(Boolean) : [];
51
- if (!label && origins.length === 0 && routes.length === 0 && targets.length === 0) {
52
- return null;
53
- }
54
- return {
55
- ...(label ? { label } : {}),
56
- ...(origins.length > 0 ? { origins } : {}),
57
- ...(routes.length > 0 ? { routes } : {}),
58
- ...(targets.length > 0 ? { targets } : {}),
59
- };
60
- }
61
-
62
- export function normalizeBrowserMetadataDocument(value) {
63
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
64
- const schemaVersion =
65
- Number.isInteger(value.schemaVersion) && value.schemaVersion > 0
66
- ? value.schemaVersion
67
- : TESTKIT_BROWSER_PROTOCOL_VERSION;
68
- const browser = normalizeBrowserMetadata(value.browser);
69
- if (!browser) return null;
70
- return {
71
- schemaVersion,
72
- browser,
73
- };
74
- }
75
-
76
- export function normalizeCoverageGraphNode(value) {
77
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
78
- const id = normalizeOptionalString(value.id);
79
- const kind = normalizeOptionalString(value.kind);
80
- const service = normalizeOptionalString(value.service);
81
- const label = normalizeOptionalString(value.label);
82
- if (!id || !kind || !NODE_KINDS.has(kind) || !service || !label) return null;
83
- const filePath = normalizeOptionalString(value.filePath);
84
- const route = normalizeOptionalString(value.route);
85
- const method = normalizeOptionalString(value.method);
86
- const path = normalizeOptionalString(value.path);
87
- const target = normalizeBrowserTarget(value.target);
88
- const metadata = normalizeMetadataRecord(value.metadata);
89
- return {
90
- id,
91
- kind,
92
- service,
93
- label,
94
- ...(filePath ? { filePath } : {}),
95
- ...(route ? { route } : {}),
96
- ...(method ? { method } : {}),
97
- ...(path ? { path } : {}),
98
- ...(target ? { target } : {}),
99
- ...(metadata ? { metadata } : {}),
100
- };
101
- }
102
-
103
- export function normalizeCoverageGraphEdge(value) {
104
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
105
- const id = normalizeOptionalString(value.id);
106
- const kind = normalizeOptionalString(value.kind);
107
- const from = normalizeOptionalString(value.from);
108
- const to = normalizeOptionalString(value.to);
109
- if (!id || !kind || !EDGE_KINDS.has(kind) || !from || !to) return null;
110
- const confidence = normalizeOptionalString(value.confidence);
111
- const metadata = normalizeMetadataRecord(value.metadata);
112
- return {
113
- id,
114
- kind,
115
- from,
116
- to,
117
- ...(confidence && CONFIDENCE_LEVELS.has(confidence) ? { confidence } : {}),
118
- ...(metadata ? { metadata } : {}),
119
- };
120
- }
121
-
122
- export function normalizeCoverageEvidence(value) {
123
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
124
- const id = normalizeOptionalString(value.id);
125
- const source = normalizeOptionalString(value.source);
126
- const service = normalizeOptionalString(value.service);
127
- const suiteName = normalizeOptionalString(value.suiteName);
128
- const selectionType = normalizeOptionalString(value.selectionType);
129
- const framework = normalizeOptionalString(value.framework);
130
- const testFilePath = normalizeOptionalString(value.testFilePath);
131
- const coveredNodeIds = normalizeStringArray(value.coveredNodeIds);
132
- if (
133
- !id ||
134
- !source ||
135
- !EVIDENCE_SOURCES.has(source) ||
136
- !service ||
137
- !suiteName ||
138
- !selectionType ||
139
- !framework ||
140
- !testFilePath ||
141
- coveredNodeIds.length === 0
142
- ) {
143
- return null;
144
- }
145
- const confidence = normalizeOptionalString(value.confidence);
146
- const details = normalizeEvidenceDetails(value.details);
147
- return {
148
- id,
149
- source,
150
- service,
151
- suiteName,
152
- selectionType,
153
- framework,
154
- testFilePath,
155
- coveredNodeIds,
156
- ...(confidence && CONFIDENCE_LEVELS.has(confidence) ? { confidence } : {}),
157
- ...(details ? { details } : {}),
158
- };
159
- }
160
-
161
- const DIAGNOSTIC_LEVELS = new Set(["info", "warn"]);
162
-
163
- export function normalizeCoverageGraphDiagnostic(value) {
164
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
165
- const level = normalizeOptionalString(value.level);
166
- const code = normalizeOptionalString(value.code);
167
- const filePath = normalizeOptionalString(value.filePath);
168
- const service = normalizeOptionalString(value.service);
169
- const message = normalizeOptionalString(value.message);
170
- if (!level || !code || !filePath || !service || !message) return null;
171
- if (!DIAGNOSTIC_LEVELS.has(level)) return null;
172
- return { level, code, filePath, service, message };
173
- }
174
-
175
- export function normalizeCoverageGraph(value) {
176
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
177
- const schemaVersion =
178
- Number.isInteger(value.schemaVersion) && value.schemaVersion > 0
179
- ? value.schemaVersion
180
- : TESTKIT_COVERAGE_GRAPH_VERSION;
181
- const nodes = Array.isArray(value.nodes) ? value.nodes.map(normalizeCoverageGraphNode).filter(Boolean) : [];
182
- const edges = Array.isArray(value.edges) ? value.edges.map(normalizeCoverageGraphEdge).filter(Boolean) : [];
183
- const evidence = Array.isArray(value.evidence)
184
- ? value.evidence.map(normalizeCoverageEvidence).filter(Boolean)
185
- : [];
186
- const diagnostics = Array.isArray(value.diagnostics)
187
- ? value.diagnostics.map(normalizeCoverageGraphDiagnostic).filter(Boolean)
188
- : [];
189
- if (nodes.length === 0) return null;
190
- return {
191
- schemaVersion,
192
- nodes,
193
- edges,
194
- evidence,
195
- diagnostics,
196
- };
197
- }
198
-
199
- export function isPageOverlayResponse(value) {
200
- return Boolean(normalizePageOverlayResponse(value));
201
- }
202
-
203
- export function normalizePageOverlayResponse(value) {
204
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
205
- if (value.protocolVersion !== TESTKIT_BROWSER_PROTOCOL_VERSION) return null;
206
- if (!value.page || typeof value.page !== "object") return null;
207
- if (!value.match || typeof value.match !== "object") return null;
208
- if (!value.summary || typeof value.summary !== "object") return null;
209
- if (!Array.isArray(value.coverage) || !Array.isArray(value.failures)) return null;
210
- if (!FAILURE_STATES.has(value.summary.failureState)) return null;
211
- if (!COVERAGE_STATES.has(value.summary.coverageState)) return null;
212
- return value;
213
- }
214
-
215
- export function createBridgeErrorResponse(code, message) {
216
- return {
217
- protocolVersion: TESTKIT_BROWSER_PROTOCOL_VERSION,
218
- error: {
219
- code,
220
- message,
221
- },
222
- };
223
- }
224
-
225
- function normalizeEvidenceDetails(value) {
226
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
227
- const requestPaths = normalizeStringArray(value.requestPaths);
228
- const route = normalizeOptionalString(value.route);
229
- const targets = Array.isArray(value.targets) ? value.targets.map(normalizeBrowserTarget).filter(Boolean) : [];
230
- if (requestPaths.length === 0 && !route && targets.length === 0) return null;
231
- return {
232
- ...(requestPaths.length > 0 ? { requestPaths } : {}),
233
- ...(route ? { route } : {}),
234
- ...(targets.length > 0 ? { targets } : {}),
235
- };
236
- }
237
-
238
- function normalizeMetadataRecord(value) {
239
- if (!value || typeof value !== "object" || Array.isArray(value)) return null;
240
- const normalized = {};
241
- for (const [key, entry] of Object.entries(value)) {
242
- const normalizedKey = normalizeOptionalString(key);
243
- if (!normalizedKey) continue;
244
- if (
245
- entry === null ||
246
- typeof entry === "string" ||
247
- typeof entry === "number" ||
248
- typeof entry === "boolean"
249
- ) {
250
- normalized[normalizedKey] = entry;
251
- }
252
- }
253
- return Object.keys(normalized).length > 0 ? normalized : null;
254
- }
255
-
256
- function normalizeStringArray(value) {
257
- if (!Array.isArray(value)) return [];
258
- return value.map(normalizeOptionalString).filter(Boolean);
259
- }
260
-
261
- function normalizeOptionalString(value) {
262
- if (typeof value !== "string") return null;
263
- const normalized = value.trim();
264
- return normalized.length > 0 ? normalized : null;
265
- }
@@ -1,242 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- TESTKIT_BROWSER_PROTOCOL_VERSION,
4
- TESTKIT_COVERAGE_GRAPH_VERSION,
5
- isPageOverlayResponse,
6
- normalizeBrowserTarget,
7
- normalizeCoverageEvidence,
8
- normalizeCoverageGraph,
9
- normalizeCoverageGraphDiagnostic,
10
- normalizeCoverageGraphEdge,
11
- normalizeCoverageGraphNode,
12
- } from "./index.mjs";
13
-
14
- describe("testkit browser protocol", () => {
15
- it("normalizes browser targets", () => {
16
- expect(
17
- normalizeBrowserTarget({
18
- kind: "testId",
19
- value: "coverage-refresh-button",
20
- confidence: "high",
21
- })
22
- ).toEqual({
23
- kind: "testId",
24
- value: "coverage-refresh-button",
25
- confidence: "high",
26
- });
27
- });
28
-
29
- it("normalizes coverage graph nodes and edges", () => {
30
- expect(
31
- normalizeCoverageGraphNode({
32
- id: "page_view:web:/coverage",
33
- kind: "page_view",
34
- service: "web",
35
- label: "Coverage",
36
- route: "/coverage",
37
- })
38
- ).toEqual({
39
- id: "page_view:web:/coverage",
40
- kind: "page_view",
41
- service: "web",
42
- label: "Coverage",
43
- route: "/coverage",
44
- });
45
-
46
- expect(
47
- normalizeCoverageGraphEdge({
48
- id: "edge-1",
49
- kind: "requests",
50
- from: "page_view:web:/coverage",
51
- to: "client_request:web:/api/coverage",
52
- confidence: "high",
53
- })
54
- ).toEqual({
55
- id: "edge-1",
56
- kind: "requests",
57
- from: "page_view:web:/coverage",
58
- to: "client_request:web:/api/coverage",
59
- confidence: "high",
60
- });
61
- });
62
-
63
- it("normalizes positive coverage evidence", () => {
64
- expect(
65
- normalizeCoverageEvidence({
66
- id: "evidence-1",
67
- source: "convention",
68
- confidence: "high",
69
- service: "web",
70
- suiteName: "coverage",
71
- selectionType: "pw",
72
- framework: "playwright",
73
- testFilePath: "app/__testkit__/coverage/home.pw.testkit.ts",
74
- coveredNodeIds: ["page_view:web:/coverage"],
75
- details: {
76
- route: "/coverage",
77
- requestPaths: ["/api/coverage"],
78
- targets: [
79
- {
80
- kind: "testId",
81
- value: "coverage-refresh-button",
82
- confidence: "high",
83
- },
84
- ],
85
- },
86
- })
87
- ).toEqual({
88
- id: "evidence-1",
89
- source: "convention",
90
- confidence: "high",
91
- service: "web",
92
- suiteName: "coverage",
93
- selectionType: "pw",
94
- framework: "playwright",
95
- testFilePath: "app/__testkit__/coverage/home.pw.testkit.ts",
96
- coveredNodeIds: ["page_view:web:/coverage"],
97
- details: {
98
- route: "/coverage",
99
- requestPaths: ["/api/coverage"],
100
- targets: [
101
- {
102
- kind: "testId",
103
- value: "coverage-refresh-button",
104
- confidence: "high",
105
- },
106
- ],
107
- },
108
- });
109
- });
110
-
111
- it("normalizes coverage graph diagnostics", () => {
112
- expect(
113
- normalizeCoverageGraphDiagnostic({
114
- level: "warn",
115
- code: "no-service-context",
116
- filePath: "tests/example.int.testkit.ts",
117
- service: "web",
118
- message: 'No coverage context available for service "web".',
119
- })
120
- ).toEqual({
121
- level: "warn",
122
- code: "no-service-context",
123
- filePath: "tests/example.int.testkit.ts",
124
- service: "web",
125
- message: 'No coverage context available for service "web".',
126
- });
127
-
128
- expect(normalizeCoverageGraphDiagnostic({ level: "error", code: "x", filePath: "f", service: "s", message: "m" })).toBeNull();
129
- expect(normalizeCoverageGraphDiagnostic({ level: "warn", code: "", filePath: "f", service: "s", message: "m" })).toBeNull();
130
- expect(normalizeCoverageGraphDiagnostic(null)).toBeNull();
131
- });
132
-
133
- it("normalizes graph payloads with diagnostics", () => {
134
- expect(
135
- normalizeCoverageGraph({
136
- schemaVersion: TESTKIT_COVERAGE_GRAPH_VERSION,
137
- nodes: [
138
- {
139
- id: "page_view:web:/coverage",
140
- kind: "page_view",
141
- service: "web",
142
- label: "Coverage",
143
- route: "/coverage",
144
- },
145
- ],
146
- edges: [],
147
- evidence: [],
148
- diagnostics: [
149
- {
150
- level: "info",
151
- code: "zero-coverage-inferred",
152
- filePath: "tests/example.pw.testkit.ts",
153
- service: "web",
154
- message: "No routes matched.",
155
- },
156
- ],
157
- })
158
- ).toEqual({
159
- schemaVersion: TESTKIT_COVERAGE_GRAPH_VERSION,
160
- nodes: [
161
- {
162
- id: "page_view:web:/coverage",
163
- kind: "page_view",
164
- service: "web",
165
- label: "Coverage",
166
- route: "/coverage",
167
- },
168
- ],
169
- edges: [],
170
- evidence: [],
171
- diagnostics: [
172
- {
173
- level: "info",
174
- code: "zero-coverage-inferred",
175
- filePath: "tests/example.pw.testkit.ts",
176
- service: "web",
177
- message: "No routes matched.",
178
- },
179
- ],
180
- });
181
- });
182
-
183
- it("normalizes graph payloads without diagnostics field", () => {
184
- expect(
185
- normalizeCoverageGraph({
186
- schemaVersion: TESTKIT_COVERAGE_GRAPH_VERSION,
187
- nodes: [
188
- {
189
- id: "page_view:web:/coverage",
190
- kind: "page_view",
191
- service: "web",
192
- label: "Coverage",
193
- route: "/coverage",
194
- },
195
- ],
196
- edges: [],
197
- evidence: [],
198
- })
199
- ).toEqual({
200
- schemaVersion: TESTKIT_COVERAGE_GRAPH_VERSION,
201
- nodes: [
202
- {
203
- id: "page_view:web:/coverage",
204
- kind: "page_view",
205
- service: "web",
206
- label: "Coverage",
207
- route: "/coverage",
208
- },
209
- ],
210
- edges: [],
211
- evidence: [],
212
- diagnostics: [],
213
- });
214
- });
215
-
216
- it("recognizes valid page overlay responses", () => {
217
- expect(
218
- isPageOverlayResponse({
219
- protocolVersion: TESTKIT_BROWSER_PROTOCOL_VERSION,
220
- page: { url: "http://localhost:3000/coverage", origin: "http://localhost:3000", route: "/coverage" },
221
- match: {
222
- protocolVersion: TESTKIT_BROWSER_PROTOCOL_VERSION,
223
- url: "http://localhost:3000/coverage",
224
- origin: "http://localhost:3000",
225
- route: "/coverage",
226
- matched: true,
227
- product: { name: "web", directory: "/tmp/web" },
228
- service: { name: "web", baseUrl: "http://localhost:3000", origin: "http://localhost:3000" },
229
- },
230
- run: { artifactAvailable: true, generatedAt: null, status: "failed" },
231
- summary: {
232
- failureState: "failing",
233
- coverageState: "covered",
234
- relatedFailureCount: 1,
235
- relatedCoverageCount: 1,
236
- },
237
- failures: [],
238
- coverage: [],
239
- })
240
- ).toBe(true);
241
- });
242
- });
@@ -1,135 +0,0 @@
1
- import ts from "typescript";
2
- import { extractStringLiteral } from "./syntax.mjs";
3
-
4
- export function collectImports(sourceFile, options) {
5
- const imports = new Map();
6
- for (const statement of sourceFile.statements) {
7
- if (!ts.isImportDeclaration(statement) || !statement.importClause) continue;
8
- const specifier = extractStringLiteral(statement.moduleSpecifier);
9
- if (!specifier) continue;
10
- const resolvedFilePath = options.resolveImportPath(specifier);
11
- const sourceContent = resolvedFilePath ? options.readSourceFile(resolvedFilePath) : null;
12
- const serverActionImport = Boolean(sourceContent && options.isServerActionFile(sourceContent));
13
-
14
- if (statement.importClause.name) {
15
- imports.set(statement.importClause.name.text, {
16
- importedName: "default",
17
- specifier,
18
- resolvedFilePath,
19
- isServerAction: serverActionImport,
20
- });
21
- }
22
-
23
- const bindings = statement.importClause.namedBindings;
24
- if (!bindings || !ts.isNamedImports(bindings)) continue;
25
- for (const element of bindings.elements) {
26
- const localName = element.name.text;
27
- const importedName = element.propertyName?.text || localName;
28
- imports.set(localName, {
29
- importedName,
30
- specifier,
31
- resolvedFilePath,
32
- isServerAction: serverActionImport,
33
- });
34
- }
35
- }
36
- return imports;
37
- }
38
-
39
- export function collectTopLevelFunctions(sourceFile) {
40
- const functions = new Map();
41
- for (const statement of sourceFile.statements) {
42
- if (ts.isFunctionDeclaration(statement) && statement.name) {
43
- functions.set(statement.name.text, statement);
44
- continue;
45
- }
46
-
47
- if (!ts.isVariableStatement(statement)) continue;
48
- for (const declaration of statement.declarationList.declarations) {
49
- if (!ts.isIdentifier(declaration.name) || !declaration.initializer) continue;
50
- if (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)) {
51
- functions.set(declaration.name.text, declaration.initializer);
52
- }
53
- }
54
- }
55
- return functions;
56
- }
57
-
58
- export function collectExportedCallables(sourceFile, topLevelFunctions) {
59
- const exports = new Map();
60
- for (const statement of sourceFile.statements) {
61
- if (ts.isFunctionDeclaration(statement) && statement.name && hasExportModifier(statement.modifiers)) {
62
- exports.set(statement.name.text, statement);
63
- continue;
64
- }
65
-
66
- if (!ts.isVariableStatement(statement) || !hasExportModifier(statement.modifiers)) continue;
67
- for (const declaration of statement.declarationList.declarations) {
68
- if (!ts.isIdentifier(declaration.name) || !declaration.initializer) continue;
69
- if (ts.isArrowFunction(declaration.initializer) || ts.isFunctionExpression(declaration.initializer)) {
70
- exports.set(declaration.name.text, declaration.initializer);
71
- } else if (ts.isIdentifier(declaration.initializer)) {
72
- const referenced = topLevelFunctions.get(declaration.initializer.text);
73
- if (referenced) exports.set(declaration.name.text, referenced);
74
- }
75
- }
76
- }
77
- return exports;
78
- }
79
-
80
- export function collectScopeLocalFunctions(node) {
81
- const functions = new Map();
82
- const callableBody = "body" in node ? node.body : null;
83
- if (!callableBody) return functions;
84
-
85
- const visit = (child) => {
86
- if (ts.isFunctionDeclaration(child) && child.name) {
87
- functions.set(child.name.text, child);
88
- if (child !== callableBody) return;
89
- }
90
-
91
- if (
92
- child !== callableBody &&
93
- (ts.isArrowFunction(child) || ts.isFunctionExpression(child))
94
- ) {
95
- return;
96
- }
97
-
98
- if (ts.isVariableDeclaration(child) && ts.isIdentifier(child.name) && child.initializer) {
99
- if (ts.isArrowFunction(child.initializer) || ts.isFunctionExpression(child.initializer)) {
100
- functions.set(child.name.text, child.initializer);
101
- }
102
- }
103
-
104
- ts.forEachChild(child, visit);
105
- };
106
-
107
- visit(callableBody);
108
- return functions;
109
- }
110
-
111
- export function findDefaultExportCallable(sourceFile, localFunctions) {
112
- for (const statement of sourceFile.statements) {
113
- if (ts.isFunctionDeclaration(statement) && hasDefaultModifier(statement.modifiers)) {
114
- return statement;
115
- }
116
-
117
- if (ts.isExportAssignment(statement)) {
118
- if (ts.isIdentifier(statement.expression)) {
119
- return localFunctions.get(statement.expression.text) || null;
120
- }
121
- if (ts.isArrowFunction(statement.expression) || ts.isFunctionExpression(statement.expression)) {
122
- return statement.expression;
123
- }
124
- }
125
- }
126
- return null;
127
- }
128
-
129
- function hasExportModifier(modifiers) {
130
- return Boolean(modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword));
131
- }
132
-
133
- function hasDefaultModifier(modifiers) {
134
- return Boolean(modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.DefaultKeyword));
135
- }
@@ -1,55 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- collectExportedCallables,
4
- collectImports,
5
- collectScopeLocalFunctions,
6
- collectTopLevelFunctions,
7
- createSourceFile,
8
- findDefaultExportCallable,
9
- } from "./index.mjs";
10
-
11
- describe("@elench/ts-analysis callables", () => {
12
- it("collects top-level, exported, and scope-local callables", () => {
13
- const content = `
14
- import { saveSettings as save } from "./actions";
15
-
16
- function helper() {}
17
- const localArrow = () => {};
18
-
19
- export function namedExport() {}
20
- export const exportedArrow = () => {};
21
-
22
- export default function Page() {
23
- function nestedDecl() {}
24
- const nestedArrow = () => {};
25
- return <button onClick={nestedArrow}>Save</button>;
26
- }
27
- `;
28
- const sourceFile = createSourceFile("page.tsx", content);
29
- const topLevel = collectTopLevelFunctions(sourceFile);
30
- const exported = collectExportedCallables(sourceFile, topLevel);
31
- const defaultExport = findDefaultExportCallable(sourceFile, topLevel);
32
- const locals = collectScopeLocalFunctions(defaultExport);
33
-
34
- expect([...topLevel.keys()]).toEqual(["helper", "localArrow", "namedExport", "exportedArrow", "Page"]);
35
- expect([...exported.keys()]).toEqual(["namedExport", "exportedArrow", "Page"]);
36
- expect([...locals.keys()]).toEqual(["nestedDecl", "nestedArrow"]);
37
- });
38
-
39
- it("collects imports with server action metadata", () => {
40
- const sourceFile = createSourceFile(
41
- "page.tsx",
42
- `import action, { saveSettings as save } from "./actions"; import { Button } from "@/components/ui/button";`
43
- );
44
- const imports = collectImports(sourceFile, {
45
- readSourceFile: (filePath) => (filePath === "src/app/actions.ts" ? '"use server";\nexport async function saveSettings() {}' : "export const Button = () => null;"),
46
- resolveImportPath: (specifier) =>
47
- specifier === "./actions" ? "src/app/actions.ts" : specifier === "@/components/ui/button" ? "src/components/ui/button.tsx" : null,
48
- isServerActionFile: (content) => content.includes('"use server"'),
49
- });
50
-
51
- expect(imports.get("action")).toMatchObject({ importedName: "default", isServerAction: true });
52
- expect(imports.get("save")).toMatchObject({ importedName: "saveSettings", isServerAction: true });
53
- expect(imports.get("Button")).toMatchObject({ importedName: "Button", isServerAction: false });
54
- });
55
- });