@md-code/follow-architecture 0.3.0 → 0.3.3

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 (382) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1341 -472
  3. package/dist/args.d.ts +4 -0
  4. package/dist/args.js +18 -1
  5. package/dist/bin/follow-architecture.js +3 -3
  6. package/dist/closure-project.d.ts +4 -0
  7. package/dist/closure-project.js +122 -0
  8. package/dist/code-entities/classify.d.ts +11 -0
  9. package/dist/code-entities/classify.js +45 -0
  10. package/dist/code-entities/connector.d.ts +8 -0
  11. package/dist/code-entities/connector.js +119 -0
  12. package/dist/code-entities/entities.d.ts +9 -0
  13. package/dist/{code-roles/roles.js → code-entities/entities.js} +81 -54
  14. package/dist/code-entities/project.d.ts +21 -0
  15. package/dist/code-entities/project.js +249 -0
  16. package/dist/code-entities/walk.d.ts +31 -0
  17. package/dist/code-entities/walk.js +95 -0
  18. package/dist/config-options.d.ts +23 -0
  19. package/dist/config-options.js +18 -1
  20. package/dist/config-project.js +10 -2
  21. package/dist/config-report.d.ts +1 -1
  22. package/dist/config-report.js +20 -3
  23. package/dist/config-rule.d.ts +25 -0
  24. package/dist/config-rule.js +89 -6
  25. package/dist/config-state.d.ts +14 -3
  26. package/dist/config-state.js +180 -17
  27. package/dist/config.d.ts +25 -0
  28. package/dist/css/index.d.ts +11 -7
  29. package/dist/css/index.js +124 -23
  30. package/dist/css/syntax/css/gate.js +5 -5
  31. package/dist/css/syntax/css/index.d.ts +1 -1
  32. package/dist/css/syntax/css/index.js +1 -1
  33. package/dist/css/syntax/css/reference.d.ts +1 -1
  34. package/dist/css/syntax/css/reference.js +15 -3
  35. package/dist/css/syntax/language.d.ts +1 -1
  36. package/dist/css/syntax/language.js +4 -2
  37. package/dist/css/syntax/scss/index.d.ts +2 -2
  38. package/dist/css/syntax/scss/index.js +1 -1
  39. package/dist/css/syntax/scss/reference.d.ts +1 -1
  40. package/dist/css/syntax/scss/reference.js +7 -1
  41. package/dist/css/syntax/styled/document.d.ts +3 -3
  42. package/dist/css/syntax/styled/document.js +17 -7
  43. package/dist/css/syntax/styled/markup.d.ts +1 -1
  44. package/dist/css/syntax/styled/markup.js +22 -14
  45. package/dist/css/syntax/styled/tags.d.ts +2 -0
  46. package/dist/css/syntax/styled/tags.js +22 -0
  47. package/dist/css/syntax/styled/template.js +10 -4
  48. package/dist/css/syntax/tailwind/tailwind.js +4 -4
  49. package/dist/css/value/check.d.ts +1 -1
  50. package/dist/css/value/check.js +1 -1
  51. package/dist/css/value/expression/arithmetic.d.ts +2 -2
  52. package/dist/css/value/expression/arithmetic.js +7 -3
  53. package/dist/css/value/expression/block.d.ts +2 -2
  54. package/dist/css/value/expression/block.js +4 -3
  55. package/dist/css/value/expression/conditional.d.ts +2 -2
  56. package/dist/css/value/expression/conditional.js +1 -1
  57. package/dist/css/value/expression/index.d.ts +2 -2
  58. package/dist/css/value/expression/index.js +10 -6
  59. package/dist/css/value/expression/map.d.ts +2 -2
  60. package/dist/css/value/expression/map.js +2 -2
  61. package/dist/css/value/object/index.d.ts +2 -2
  62. package/dist/css/value/object/index.js +14 -4
  63. package/dist/css/value/object/members.d.ts +2 -2
  64. package/dist/css/value/object/node.js +9 -4
  65. package/dist/css/value/object/path.d.ts +3 -3
  66. package/dist/css/value/object/path.js +10 -4
  67. package/dist/css/value/pieces.d.ts +3 -3
  68. package/dist/css/value/pieces.js +14 -4
  69. package/dist/css/value/resolve.js +15 -5
  70. package/dist/css/value/scope.d.ts +3 -2
  71. package/dist/css/value/scope.js +25 -7
  72. package/dist/css/value/substitute.js +43 -11
  73. package/dist/entities/architecture.d.ts +28 -25
  74. package/dist/entities/ast/assignments-raw.d.ts +1 -1
  75. package/dist/entities/ast/assignments-raw.js +61 -8
  76. package/dist/entities/ast/assignments-tagged.d.ts +1 -1
  77. package/dist/entities/ast/assignments-tagged.js +22 -7
  78. package/dist/entities/ast/assignments.d.ts +1 -1
  79. package/dist/entities/ast/assignments.js +6 -4
  80. package/dist/entities/ast/branches.d.ts +1 -1
  81. package/dist/entities/ast/calls.d.ts +1 -1
  82. package/dist/entities/ast/calls.js +19 -3
  83. package/dist/entities/ast/classes.d.ts +1 -1
  84. package/dist/entities/ast/classes.js +5 -1
  85. package/dist/entities/ast/comments.d.ts +3 -2
  86. package/dist/entities/ast/comments.js +47 -17
  87. package/dist/entities/ast/declaration.d.ts +1 -1
  88. package/dist/entities/ast/depth.d.ts +2 -2
  89. package/dist/entities/ast/depth.js +15 -8
  90. package/dist/entities/ast/enums.d.ts +1 -1
  91. package/dist/entities/ast/export-chain.d.ts +15 -0
  92. package/dist/entities/ast/export-chain.js +171 -0
  93. package/dist/entities/ast/file-exports.d.ts +1 -1
  94. package/dist/entities/ast/file-exports.js +26 -3
  95. package/dist/entities/ast/file-facts.d.ts +6 -3
  96. package/dist/entities/ast/file-facts.js +33 -4
  97. package/dist/entities/ast/file-imports.d.ts +1 -1
  98. package/dist/entities/ast/file-imports.js +26 -3
  99. package/dist/entities/ast/file.d.ts +2 -2
  100. package/dist/entities/ast/file.js +2 -1
  101. package/dist/entities/ast/functions.d.ts +1 -1
  102. package/dist/entities/ast/functions.js +13 -4
  103. package/dist/entities/ast/heritage.d.ts +1 -1
  104. package/dist/entities/ast/heritage.js +9 -1
  105. package/dist/entities/ast/index.d.ts +6 -3
  106. package/dist/entities/ast/index.js +82 -26
  107. package/dist/entities/ast/kind.d.ts +1 -1
  108. package/dist/entities/ast/kind.js +7 -1
  109. package/dist/entities/ast/modifiers.d.ts +1 -1
  110. package/dist/entities/ast/modifiers.js +4 -4
  111. package/dist/entities/ast/project.js +33 -2
  112. package/dist/entities/ast/properties.d.ts +1 -1
  113. package/dist/entities/ast/properties.js +10 -5
  114. package/dist/entities/ast/resolve.d.ts +1 -1
  115. package/dist/entities/ast/resolve.js +4 -4
  116. package/dist/entities/ast/tree.d.ts +4 -2
  117. package/dist/entities/ast/tree.js +184 -17
  118. package/dist/entities/ast/types.d.ts +1 -1
  119. package/dist/entities/ast/types.js +2 -1
  120. package/dist/entities/ast/usage.d.ts +1 -1
  121. package/dist/entities/ast/usage.js +1 -1
  122. package/dist/entities/ast/variables.d.ts +1 -1
  123. package/dist/entities/context.d.ts +4 -4
  124. package/dist/entities/facts.d.ts +36 -13
  125. package/dist/entities/findings.d.ts +3 -3
  126. package/dist/entities/kinds.d.ts +1 -1
  127. package/dist/entities/kinds.js +131 -30
  128. package/dist/entities/location/homes.d.ts +10 -10
  129. package/dist/entities/location/homes.js +74 -48
  130. package/dist/entities/location/place.d.ts +1 -1
  131. package/dist/entities/location/place.js +10 -3
  132. package/dist/entities/location/where.d.ts +8 -6
  133. package/dist/entities/location/where.js +79 -30
  134. package/dist/entities/location.d.ts +3 -3
  135. package/dist/entities/location.js +17 -17
  136. package/dist/entities/operators.js +1 -1
  137. package/dist/entities/overview/data.d.ts +6 -6
  138. package/dist/entities/overview/decision.d.ts +11 -11
  139. package/dist/entities/overview/finding.d.ts +10 -10
  140. package/dist/entities/overview/graph.d.ts +28 -11
  141. package/dist/entities/overview/input.d.ts +2 -2
  142. package/dist/entities/overview/summaries.d.ts +17 -15
  143. package/dist/entities/queries.d.ts +1 -1
  144. package/dist/entities/queries.js +72 -12
  145. package/dist/entities/repair.d.ts +1 -1
  146. package/dist/entities/repair.js +8 -2
  147. package/dist/entities/schema.d.ts +17 -3
  148. package/dist/entities/schema.js +74 -16
  149. package/dist/entities/story.d.ts +5 -5
  150. package/dist/entities/structure-facts.d.ts +1 -1
  151. package/dist/entities/token.d.ts +4 -4
  152. package/dist/entities/tree/build.d.ts +4 -3
  153. package/dist/entities/tree/build.js +95 -44
  154. package/dist/entities/tree/entries.d.ts +3 -3
  155. package/dist/entities/tree/entries.js +41 -16
  156. package/dist/entities/tree/index.d.ts +2 -2
  157. package/dist/entities/tree/index.js +1 -1
  158. package/dist/entities/tree/match.d.ts +2 -2
  159. package/dist/entities/tree/match.js +9 -5
  160. package/dist/fa-index.d.ts +16 -0
  161. package/dist/fa-index.js +165 -0
  162. package/dist/fa-open.d.ts +51 -0
  163. package/dist/fa-open.js +232 -0
  164. package/dist/fa-store.d.ts +22 -0
  165. package/dist/fa-store.js +222 -0
  166. package/dist/fa-values.d.ts +37 -0
  167. package/dist/fa-values.js +104 -0
  168. package/dist/facts-record.d.ts +45 -0
  169. package/dist/facts-record.js +287 -0
  170. package/dist/frameworks/angular/index.d.ts +2 -2
  171. package/dist/frameworks/angular/index.js +2 -1
  172. package/dist/frameworks/facet.d.ts +3 -1
  173. package/dist/frameworks/facet.js +13 -0
  174. package/dist/frameworks/index.d.ts +1 -1
  175. package/dist/frameworks/index.js +8 -4
  176. package/dist/frameworks/react/index.d.ts +2 -2
  177. package/dist/frameworks/react/index.js +33 -10
  178. package/dist/frameworks/test/index.d.ts +6 -0
  179. package/dist/frameworks/test/index.js +157 -0
  180. package/dist/frameworks/vue/index.d.ts +2 -2
  181. package/dist/frameworks/vue/index.js +2 -1
  182. package/dist/ignore.d.ts +3 -0
  183. package/dist/ignore.js +48 -0
  184. package/dist/index-file.d.ts +43 -0
  185. package/dist/index-file.js +218 -0
  186. package/dist/index-run.d.ts +39 -0
  187. package/dist/index-run.js +217 -0
  188. package/dist/index-zone.d.ts +25 -0
  189. package/dist/index-zone.js +209 -0
  190. package/dist/main.d.ts +5 -2
  191. package/dist/main.js +207 -34
  192. package/dist/nodes/child-entities.d.ts +3 -0
  193. package/dist/nodes/child-entities.js +12 -0
  194. package/dist/nodes/children.d.ts +4 -4
  195. package/dist/nodes/children.js +54 -11
  196. package/dist/nodes/finally/emit.d.ts +3 -3
  197. package/dist/nodes/finally/emit.js +26 -10
  198. package/dist/nodes/finally/entities.d.ts +13 -0
  199. package/dist/nodes/finally/entities.js +42 -0
  200. package/dist/nodes/finally/index.d.ts +6 -6
  201. package/dist/nodes/finally/index.js +8 -8
  202. package/dist/nodes/finally/queries.d.ts +2 -2
  203. package/dist/nodes/finally/queries.js +7 -4
  204. package/dist/nodes/finally/relations-access.d.ts +2 -2
  205. package/dist/nodes/finally/relations-access.js +22 -18
  206. package/dist/nodes/finally/relations-edge.d.ts +5 -5
  207. package/dist/nodes/finally/relations-edge.js +67 -44
  208. package/dist/nodes/finally/relations-group.d.ts +7 -7
  209. package/dist/nodes/finally/relations-group.js +28 -25
  210. package/dist/nodes/finally/relations.d.ts +2 -2
  211. package/dist/nodes/finally/relations.js +16 -12
  212. package/dist/nodes/finally/required.d.ts +3 -3
  213. package/dist/nodes/finally/required.js +9 -7
  214. package/dist/nodes/finally/violation.d.ts +2 -2
  215. package/dist/nodes/similar.d.ts +3 -3
  216. package/dist/nodes/similar.js +61 -49
  217. package/dist/piece-forms.d.ts +9 -0
  218. package/dist/piece-forms.js +68 -0
  219. package/dist/{pipeline-roles.d.ts → pipeline-entities.d.ts} +2 -2
  220. package/dist/{pipeline-roles.js → pipeline-entities.js} +32 -28
  221. package/dist/pipeline-facts.d.ts +4 -3
  222. package/dist/pipeline-facts.js +47 -55
  223. package/dist/{pipeline-unroled.d.ts → pipeline-unclassified.d.ts} +2 -2
  224. package/dist/{pipeline-unroled.js → pipeline-unclassified.js} +58 -63
  225. package/dist/pipeline.js +19 -64
  226. package/dist/release-file.d.ts +3 -0
  227. package/dist/release-file.js +13 -0
  228. package/dist/report/asks.d.ts +3 -3
  229. package/dist/report/asks.js +16 -6
  230. package/dist/report/configErrors.d.ts +55 -27
  231. package/dist/report/configErrors.js +81 -35
  232. package/dist/report/errorTypes/codes/structure.d.ts +1 -1
  233. package/dist/report/errorTypes/codes/structure.js +9 -9
  234. package/dist/report/errorTypes/decision-maker.d.ts +5 -5
  235. package/dist/report/errorTypes/decision-maker.js +4 -4
  236. package/dist/report/errorTypes/destinations.d.ts +5 -5
  237. package/dist/report/errorTypes/destinations.js +52 -34
  238. package/dist/report/errorTypes/finding-type.d.ts +3 -3
  239. package/dist/report/errorTypes/index.d.ts +1 -1
  240. package/dist/report/errorTypes/types/fileContents.d.ts +4 -4
  241. package/dist/report/errorTypes/types/fileContents.js +11 -5
  242. package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
  243. package/dist/report/errorTypes/types/{unknownRole.js → unknownEntity.js} +12 -7
  244. package/dist/report/errorTypes/types/wrongAction.d.ts +5 -5
  245. package/dist/report/errorTypes/types/wrongAction.js +18 -13
  246. package/dist/report/errorTypes/types/wrongPlacement.d.ts +4 -4
  247. package/dist/report/errorTypes/types/wrongPlacement.js +19 -9
  248. package/dist/report/errorTypes/vocabulary/ids.d.ts +2 -2
  249. package/dist/report/errorTypes/vocabulary/ids.js +3 -3
  250. package/dist/report/errorTypes/vocabulary/phrases.d.ts +2 -2
  251. package/dist/report/errorTypes/vocabulary/phrases.js +39 -26
  252. package/dist/report/errorTypes/vocabulary/places.d.ts +3 -3
  253. package/dist/report/errorTypes/vocabulary/places.js +13 -13
  254. package/dist/report/finding-from.d.ts +3 -3
  255. package/dist/report/finding-from.js +14 -9
  256. package/dist/report/notices.d.ts +6 -1
  257. package/dist/report/notices.js +46 -20
  258. package/dist/report/observed.d.ts +19 -0
  259. package/dist/report/observed.js +87 -0
  260. package/dist/report/render-report.d.ts +1 -1
  261. package/dist/report/render-report.js +33 -30
  262. package/dist/report/user-report/build/bundle.js +9 -0
  263. package/dist/report/user-report/build/bundle.prebuilt.js +799 -297
  264. package/dist/report/user-report/data/collect.d.ts +2 -2
  265. package/dist/report/user-report/data/collect.js +15 -12
  266. package/dist/report/user-report/data/entities.d.ts +7 -0
  267. package/dist/report/user-report/data/{roles.js → entities.js} +27 -22
  268. package/dist/report/user-report/data/{role-examples.d.ts → entity-examples.d.ts} +3 -3
  269. package/dist/report/user-report/data/entity-examples.js +126 -0
  270. package/dist/report/user-report/data/{role-filters.d.ts → entity-filters.d.ts} +2 -2
  271. package/dist/report/user-report/data/{role-filters.js → entity-filters.js} +7 -7
  272. package/dist/report/user-report/data/entity-marks.d.ts +5 -0
  273. package/dist/report/user-report/data/{role-marks.js → entity-marks.js} +11 -11
  274. package/dist/report/user-report/data/file-tree.d.ts +3 -3
  275. package/dist/report/user-report/data/file-tree.js +13 -5
  276. package/dist/report/user-report/data/finding-boundary.d.ts +4 -4
  277. package/dist/report/user-report/data/finding-boundary.js +2 -2
  278. package/dist/report/user-report/data/finding-plan.d.ts +5 -5
  279. package/dist/report/user-report/data/finding-plan.js +10 -10
  280. package/dist/report/user-report/data/finding-title.d.ts +2 -2
  281. package/dist/report/user-report/data/finding-title.js +8 -8
  282. package/dist/report/user-report/data/findings.d.ts +4 -4
  283. package/dist/report/user-report/data/findings.js +30 -20
  284. package/dist/report/user-report/data/graph-edges.d.ts +4 -4
  285. package/dist/report/user-report/data/graph-edges.js +19 -19
  286. package/dist/report/user-report/data/graph-entities.d.ts +6 -0
  287. package/dist/report/user-report/data/graph-entities.js +158 -0
  288. package/dist/report/user-report/data/graph-helpers.d.ts +5 -5
  289. package/dist/report/user-report/data/graph-helpers.js +15 -15
  290. package/dist/report/user-report/data/graph.d.ts +5 -4
  291. package/dist/report/user-report/data/graph.js +28 -21
  292. package/dist/report/user-report/data/nodes.d.ts +2 -2
  293. package/dist/report/user-report/data/nodes.js +16 -16
  294. package/dist/report/user-report/data/rules.d.ts +7 -0
  295. package/dist/report/user-report/data/{invariants.js → rules.js} +13 -13
  296. package/dist/report/user-report/data/scan.d.ts +1 -1
  297. package/dist/report/user-report/data/scan.js +2 -2
  298. package/dist/report/user-report/html/shell.d.ts +1 -1
  299. package/dist/report/user-report/html/shell.js +1 -1
  300. package/dist/report/user-report/index.d.ts +1 -1
  301. package/dist/report/user-report/shared/describe.d.ts +1 -1
  302. package/dist/report/user-report/shared/describe.js +6 -6
  303. package/dist/rules/index.d.ts +7 -0
  304. package/dist/{invariants → rules}/index.js +85 -57
  305. package/dist/{invariants → rules}/list-vars.d.ts +2 -2
  306. package/dist/{invariants → rules}/list-vars.js +9 -3
  307. package/dist/{invariants → rules}/name.js +2 -2
  308. package/dist/rules/normalize.d.ts +5 -0
  309. package/dist/{invariants → rules}/normalize.js +35 -32
  310. package/dist/{invariants → rules}/vars.d.ts +9 -7
  311. package/dist/{invariants → rules}/vars.js +5 -5
  312. package/dist/scan-run.d.ts +20 -0
  313. package/dist/scan-run.js +130 -0
  314. package/dist/scripts/audit-report.js +2 -2
  315. package/dist/usage-index.d.ts +4 -0
  316. package/dist/usage-index.js +272 -0
  317. package/dist/usage-mode.d.ts +7 -0
  318. package/dist/usage-mode.js +16 -0
  319. package/dist/usage-pass.d.ts +19 -0
  320. package/dist/usage-pass.js +136 -0
  321. package/dist/usage-prepare.d.ts +2 -0
  322. package/dist/usage-prepare.js +22 -0
  323. package/dist/usage-sweep.d.ts +10 -0
  324. package/dist/usage-sweep.js +254 -0
  325. package/dist/utils/aliases.d.ts +22 -0
  326. package/dist/utils/aliases.js +163 -0
  327. package/dist/utils/classify.d.ts +2 -2
  328. package/dist/utils/classify.js +4 -4
  329. package/dist/utils/distinct.js +4 -2
  330. package/dist/utils/files.js +24 -30
  331. package/dist/utils/fixpoint.js +2 -2
  332. package/dist/utils/host.d.ts +1 -1
  333. package/dist/utils/host.js +4 -1
  334. package/dist/utils/imports.js +66 -12
  335. package/dist/utils/keyed.js +2 -2
  336. package/dist/utils/map-record.js +2 -2
  337. package/dist/utils/packages.d.ts +15 -0
  338. package/dist/utils/packages.js +197 -0
  339. package/dist/utils/path-label.js +3 -1
  340. package/dist/utils/pattern.d.ts +5 -4
  341. package/dist/utils/pattern.js +38 -8
  342. package/dist/utils/permission.d.ts +3 -3
  343. package/dist/utils/permission.js +4 -2
  344. package/dist/utils/plural.js +2 -2
  345. package/dist/utils/qualified.js +4 -4
  346. package/dist/utils/rank.js +2 -2
  347. package/dist/utils/record.js +1 -1
  348. package/dist/utils/search.js +7 -2
  349. package/dist/utils/speak.js +1 -1
  350. package/dist/utils/split.js +14 -1
  351. package/dist/utils/template.d.ts +1 -1
  352. package/dist/utils/template.js +1 -1
  353. package/dist/utils/tokenize.js +6 -1
  354. package/dist/utils/typed-field.js +2 -2
  355. package/dist/utils/verdicts.js +1 -1
  356. package/entities/operators.ts +1 -1
  357. package/package.json +101 -90
  358. package/report/errorTypes/vocabulary/ids.ts +7 -2
  359. package/report/errorTypes/vocabulary/phrases.ts +47 -27
  360. package/report/errorTypes/vocabulary/places.ts +21 -16
  361. package/report/user-report/shared/describe.ts +7 -7
  362. package/dist/code-roles/classify.d.ts +0 -11
  363. package/dist/code-roles/classify.js +0 -43
  364. package/dist/code-roles/connector.d.ts +0 -5
  365. package/dist/code-roles/connector.js +0 -114
  366. package/dist/code-roles/project.d.ts +0 -12
  367. package/dist/code-roles/project.js +0 -122
  368. package/dist/code-roles/roles.d.ts +0 -8
  369. package/dist/invariants/index.d.ts +0 -6
  370. package/dist/invariants/normalize.d.ts +0 -4
  371. package/dist/nodes/child-roles.d.ts +0 -3
  372. package/dist/nodes/child-roles.js +0 -12
  373. package/dist/nodes/finally/roles.d.ts +0 -13
  374. package/dist/nodes/finally/roles.js +0 -41
  375. package/dist/report/errorTypes/types/unknownRole.d.ts +0 -9
  376. package/dist/report/user-report/data/graph-roles.d.ts +0 -5
  377. package/dist/report/user-report/data/graph-roles.js +0 -71
  378. package/dist/report/user-report/data/invariants.d.ts +0 -7
  379. package/dist/report/user-report/data/role-examples.js +0 -94
  380. package/dist/report/user-report/data/role-marks.d.ts +0 -5
  381. package/dist/report/user-report/data/roles.d.ts +0 -7
  382. /package/dist/{invariants → rules}/name.d.ts +0 -0
@@ -0,0 +1,287 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.namesCodeEntity = exports.slimmable = exports.needsUsage = exports.checkLive = exports.checkRecord = exports.extractFileFacts = void 0;
27
+ // A FILE'S FACTS AS A RECORD. `extractFileFacts` is the only producer: it reads
28
+ // one file through the AST and returns DATA — numbers, strings, `{rel,start,
29
+ // end,line}` positions — plus the file's dependency list. Nothing in the record
30
+ // points back at a ts-morph node, a SourceFile, a Project or a closure, so the
31
+ // record survives a JSON round-trip and a run can hold one file's facts without
32
+ // holding its syntax.
33
+ //
34
+ // `checkRecord` is the other half: the checks (entity homes, unclassified,
35
+ // tree, rules) run on the record, not on the AST. Everything that can be
36
+ // answered from the data is answered here; the two questions that need the
37
+ // PROJECT are named at the point they are asked:
38
+ // • `resolution` of a CSS template — it reads the expressions the template
39
+ // quoted, so the template's node is restored by position (`restoreResolution`);
40
+ // • the object literals a rule resolves against — materialised by position
41
+ // (`objectsFor`), never held in the record.
42
+ // `references` / `implementations` are the CHECKER's answers, and they are
43
+ // DATA — but they are also the only answers that are statements about EVERY
44
+ // file, so they cannot be asked where the project holds one chunk. The extraction
45
+ // leaves them null; a pass of its own opens one project over the whole repo, asks
46
+ // them once per published name and stores the answers in the index (`fa-usage`);
47
+ // the checks then read a number instead of opening a project.
48
+ const path = __importStar(require("node:path"));
49
+ const node_crypto_1 = require("node:crypto");
50
+ const pipeline_facts_1 = require("./pipeline-facts");
51
+ Object.defineProperty(exports, "needsUsage", { enumerable: true, get: function () { return pipeline_facts_1.needsUsage; } });
52
+ const usage_pass_1 = require("./usage-pass");
53
+ const usage_mode_1 = require("./usage-mode");
54
+ const classify_1 = require("./code-entities/classify");
55
+ const project_1 = require("./code-entities/project");
56
+ const tree_1 = require("./entities/tree");
57
+ const finally_1 = require("./nodes/finally");
58
+ const rules_1 = require("./rules");
59
+ const cli_report_1 = require("./report/cli-report");
60
+ const pipeline_entities_1 = require("./pipeline-entities");
61
+ const pipeline_unclassified_1 = require("./pipeline-unclassified");
62
+ const index_1 = require("./css/index");
63
+ const notices_1 = require("./report/notices");
64
+ const observed_1 = require("./report/observed");
65
+ const fa_values_1 = require("./fa-values");
66
+ // Does any filter name the project-wide `entity` scope (as a field or a
67
+ // `$entity.…` reference)? Only then is the project-wide classify pass worth
68
+ // running — a config that never asks for it pays nothing.
69
+ const filterNamesCodeEntity = (filter) => {
70
+ if (typeof filter === "string")
71
+ return filter.includes("$entity");
72
+ if (Array.isArray(filter))
73
+ return filter.some(filterNamesCodeEntity);
74
+ if (filter === null || typeof filter !== "object")
75
+ return false;
76
+ return Object.entries(filter).some(([key, value]) => key === "entity" || filterNamesCodeEntity(value));
77
+ };
78
+ const ruleNamesCodeEntity = (inv) => inv.when !== null && filterNamesCodeEntity(inv.when)
79
+ ? true
80
+ : inv.infer.some(filterNamesCodeEntity) || inv.children.some(ruleNamesCodeEntity);
81
+ const namesCodeEntity = (invs) => invs.some(ruleNamesCodeEntity);
82
+ exports.namesCodeEntity = namesCodeEntity;
83
+ // The lazy `entity` scope: entity slug → the project-wide classified pieces.
84
+ // Defined as a getter so the whole-project scan runs only when a filter reads
85
+ // it, and memoised in the closure so it runs once per file.
86
+ const defineCodeEntity = (facts, build) => {
87
+ if (!facts)
88
+ return;
89
+ let cached = null;
90
+ Object.defineProperty(facts, "entity", {
91
+ enumerable: true,
92
+ configurable: true,
93
+ get: () => (cached ??= build()),
94
+ });
95
+ };
96
+ // The files this one depends on: every import that resolved INSIDE the repo.
97
+ // An import of a library package resolves to nothing, which is exactly right —
98
+ // a library cannot change between two runs of this repo.
99
+ // Every in-repo module this file reads FROM: what it imports, and what it
100
+ // re-exports. A barrel's `export { x } from "./x"` is a real read — a change
101
+ // behind it changes this file, and a file that starts to use the barrel changes
102
+ // the files behind it. Without the re-export edges a dependency chain stops at
103
+ // the barrel and a reverse walk cannot reach what the barrel hides.
104
+ const depsOf = (facts, repoFiles) => {
105
+ const known = new Set(repoFiles);
106
+ // Only a resolved repo path is a dependency: an export's `from` also carries a
107
+ // bare module name when resolution failed, and a name is not a file to watch.
108
+ const links = [...facts.imports.map((entry) => entry.resolved), ...facts.exports.map((entry) => entry.from)];
109
+ const inside = links.filter((link) => typeof link === "string" && known.has(link));
110
+ return [...new Set(inside)].sort();
111
+ };
112
+ const hashOf = (text) => (0, node_crypto_1.createHash)("sha256").update(text).digest("hex");
113
+ // One file → its record. The AST is read once (the same collection the checks
114
+ // used to do inline); the file's syntax is released by `checkFile` after the
115
+ // checks, so a run holds facts, not trees.
116
+ // A record is DATA: it may carry the file's facts, never a candidate's shortcut back
117
+ // to them. `checkRecord` puts `c.file` back from `record.facts` when the checks run.
118
+ const withoutFile = (candidates) => candidates.map((c) => {
119
+ const { file: _file, ...rest } = c;
120
+ return rest;
121
+ });
122
+ const extractFileFacts = (abs, run) => {
123
+ // A record is read FOR a file and outlives its syntax: a CSS template keeps the
124
+ // position it was found at, and the check restores what it needs by position.
125
+ const { arch, project, repoFiles } = run;
126
+ const capture = (0, notices_1.beginNotices)();
127
+ // In `usage: checker` the answers are NOT asked for here: the run's usage pass
128
+ // asks them, and `checkRecord` puts them back (`applyUsage`). In `usage: index`
129
+ // they come from the occurrence index, which needs no project — so they are
130
+ // asked right here, and the run needs no usage pass at all.
131
+ const { ctx, candidates, fileFacts, text } = (0, pipeline_facts_1.collectFacts)(abs, arch, project, repoFiles, (0, usage_mode_1.usageMode)() === "index", true, run.text);
132
+ return {
133
+ rel: ctx.rel,
134
+ hash: hashOf(text),
135
+ deps: depsOf(fileFacts, repoFiles),
136
+ notices: capture.end(),
137
+ facts: fileFacts,
138
+ candidates: withoutFile(candidates),
139
+ objects: [],
140
+ };
141
+ };
142
+ exports.extractFileFacts = extractFileFacts;
143
+ // The context a check layer needs, built from the record alone. `sf` is absent
144
+ // on purpose: a check that reached for the syntax would be a second reading of
145
+ // the file, not a reading of its facts.
146
+ const recordContext = (record, run) => {
147
+ const repoRoot = run.arch.repoRoot ?? ".";
148
+ const rel = record.rel;
149
+ return {
150
+ abs: path.resolve(repoRoot, rel),
151
+ rel,
152
+ dir: path.posix.dirname(rel),
153
+ basename: path.posix.basename(rel),
154
+ repoRoot,
155
+ aliases: run.arch.aliases ?? {},
156
+ arch: run.arch,
157
+ entities: [],
158
+ entityCtx: null,
159
+ facts: null,
160
+ repoFiles: run.repoFiles,
161
+ dedupe: run.dedupe,
162
+ };
163
+ };
164
+ // A record's css templates are data: the expressions they quoted are the
165
+ // template node's, found by the position the fact kept.
166
+ const restoreTemplates = (candidates, rel, project) => {
167
+ for (const candidate of candidates) {
168
+ for (const template of candidate.framework?.css?.templates ?? [])
169
+ (0, index_1.restoreResolution)(template, rel, project);
170
+ }
171
+ };
172
+ // The checks themselves, in the order the pipeline runs them. Both entry points
173
+ // below end here: the record path hands over data, the live reference path hands
174
+ // over the context `collectFacts` built. A difference between the two is then a
175
+ // difference in the translation to data, never in the checks.
176
+ const runChecks = (ctx, withEntities, run) => {
177
+ const { arch, project, repoFiles, dedupe, present, live, parts } = run;
178
+ const { before, nodes, after } = parts;
179
+ // WHAT THE SCAN SEES: the judged relations are the graph's arrows, so this
180
+ // file's answer is recorded while the checks run and committed when they end.
181
+ (0, observed_1.beginObserved)(ctx.rel, ctx.repoRoot ?? "");
182
+ // The project-wide entity index serves two things, both lazy: the `entity`
183
+ // scope a filter can navigate, and the objects resolution resolves against.
184
+ if (namesCodeEntity(arch.rules))
185
+ defineCodeEntity(ctx.facts, () => (0, project_1.entityScope)((0, project_1.projectEntityIndex)(arch, repoFiles)));
186
+ // The literals themselves live in the record as positions; a rule that names
187
+ // an object entity is the one asking for the nodes, so only then is the
188
+ // project consulted. A record read back from the index carries the resolution
189
+ // it was written with — there is no project to re-resolve against, and a rule's
190
+ // resolution step must then leave the stored answer alone.
191
+ if (project) {
192
+ ctx.objectsFor = (slugs) => (0, project_1.objectsFor)((0, project_1.projectEntityIndex)(arch, repoFiles), slugs, arch);
193
+ // A record's css templates are data: the expressions they quoted are the
194
+ // template node's, found by the position the fact kept. The live path read
195
+ // the template from its node, so its resolution is already registered.
196
+ if (!live)
197
+ restoreTemplates(withEntities, ctx.rel, project);
198
+ }
199
+ // ENTITY HOMES: every candidate must fit its entity's declared home.
200
+ (0, pipeline_entities_1.checkEntityHomes)(withEntities, ctx, arch, before);
201
+ // UNCLASSIFIED: the pieces no entity describes, and the file nothing
202
+ // describes. The lookalike question is about folders other than this file's,
203
+ // so it needs a project that holds every scanned file.
204
+ if (project)
205
+ (0, pipeline_unclassified_1.checkUnclassified)(withEntities, { present, ctx, arch, project, repoFiles, out: nodes });
206
+ // STRUCTURE: the node tree, then the built-in structure rule (kind +
207
+ // declaration), then the rules.
208
+ (0, tree_1.checkTree)(ctx.rel, arch, after, cli_report_1.findingFrom, ctx.facts, ctx.repoFiles);
209
+ (0, finally_1.checkFinally)(ctx, arch, after, cli_report_1.findingFrom);
210
+ (0, rules_1.checkRules)(arch.rules, ctx, after, cli_report_1.findingFrom, dedupe);
211
+ // The rules are the only reader of a template's capability; the readings they
212
+ // materialised are written on the facts, so the closures (and the live source
213
+ // they hold) go now rather than at the end of the process.
214
+ (0, index_1.forgetResolutions)(withEntities);
215
+ (0, observed_1.endObserved)(ctx.rel);
216
+ };
217
+ // Classify the candidates and fill the context the checks read: the step both
218
+ // entry points share.
219
+ const classifyInto = (ctx, candidates, fileFacts, run) => {
220
+ const { arch, repoFiles } = run;
221
+ const { present, entityCtx, candidates: withEntities, } = (0, classify_1.classifyEntities)(candidates, arch.entities ?? {}, arch, fileFacts);
222
+ ctx.entities = present;
223
+ ctx.entityCtx = entityCtx;
224
+ fileFacts.entities = [...new Set(present)];
225
+ // File facts (candidates attached) — the rules' filter target.
226
+ ctx.facts = { ...fileFacts, candidates: withEntities, entities: [...new Set(present)], repoFiles: [...repoFiles] };
227
+ return { present, withEntities };
228
+ };
229
+ // The record's checks. `project` is passed only to the two questions that need
230
+ // it (CSS resolution, the object literals a rule resolves against) and to the
231
+ // lookalike scan, which asks about OTHER files; `null` answers the rule layer
232
+ // from the record alone.
233
+ const checkRecord = (record, run) => {
234
+ const { arch, project, repoFiles, dedupe } = run;
235
+ const ctx = recordContext(record, { arch, repoFiles, dedupe });
236
+ // `c.file` is the snapshot every candidate carries — one shared object, put
237
+ // back here so a record that went through JSON keeps the same answers.
238
+ for (const candidate of record.candidates)
239
+ candidate.file = record.facts;
240
+ // The checker's answers are data now: put them back before anything reads a
241
+ // candidate, so every layer below sees the facts a live run would. A caller that
242
+ // holds this file's syntax and has no stored answer (the one-file path) has them
243
+ // asked right here: that is cheap for one file, and the indexed run never does it.
244
+ const usage = run.usage ?? (run.sf ? (0, usage_pass_1.usageFor)(run.sf, record.candidates, arch.repoRoot ?? ".") : null);
245
+ (0, fa_values_1.applyUsage)(record.candidates, usage);
246
+ const { present, withEntities } = classifyInto(ctx, record.candidates, record.facts, { arch, repoFiles });
247
+ // The record keeps the CLASSIFIED pieces: they are what the project-wide index
248
+ // groups by entity, so a run that reads the record back needs no classify pass.
249
+ record.candidates = withEntities;
250
+ if (run.sf)
251
+ record.objects = (0, project_1.fileObjects)(run.sf, withEntities);
252
+ const parts = { before: [], nodes: [], after: [] };
253
+ const capture = (0, notices_1.beginNotices)();
254
+ runChecks(ctx, withEntities, { arch, project, repoFiles, dedupe, present, live: false, parts });
255
+ record.notices = [...(record.notices ?? []), ...capture.end()];
256
+ // The report is the same whether this file was read now or in an earlier run:
257
+ // its lines are repeated here, in the order the reading produced them — the
258
+ // usage pass, which ran after the extraction, last.
259
+ (0, notices_1.replayNotices)(record.notices);
260
+ (0, notices_1.replayNotices)(usage?.notices ?? []);
261
+ return parts;
262
+ };
263
+ exports.checkRecord = checkRecord;
264
+ // The REFERENCE path: the same checks on the context `collectFacts` built, with
265
+ // no record in between. It exists so a parity run can compare the two
266
+ // (`FA_CHECKS=live`); nothing else calls it.
267
+ const checkLive = (abs, run) => {
268
+ const { arch, project, repoFiles, dedupe } = run;
269
+ const { ctx, candidates, fileFacts } = (0, pipeline_facts_1.collectFacts)(abs, arch, project, repoFiles, (0, pipeline_facts_1.needsUsage)(arch), false);
270
+ for (const candidate of candidates)
271
+ candidate.file = fileFacts;
272
+ const { present, withEntities } = classifyInto(ctx, candidates, fileFacts, { arch, repoFiles });
273
+ const parts = { before: [], nodes: [], after: [] };
274
+ runChecks(ctx, withEntities, { arch, project, repoFiles, dedupe, present, live: true, parts });
275
+ return parts;
276
+ };
277
+ exports.checkLive = checkLive;
278
+ // The record as the index keeps it: data only. The one field a run must not write
279
+ // is the shared facts snapshot every candidate points at (it is re-attached on
280
+ // read), and the file's own copy of its candidates is the `candidates` list.
281
+ const slimmable = (record) => {
282
+ for (const candidate of record.candidates)
283
+ delete candidate.file;
284
+ record.facts.candidates = [];
285
+ return record;
286
+ };
287
+ exports.slimmable = slimmable;
@@ -1,5 +1,5 @@
1
- import type { Candidate } from "../../entities/facts";
2
- import type { FacetContext } from "../facet";
1
+ import type { Candidate } from "@md-code/follow-architecture/entities/facts";
2
+ import { type FacetContext } from "@md-code/follow-architecture/frameworks/facet";
3
3
  declare const id = "angular";
4
4
  declare const enrich: (candidates: Candidate[]) => Candidate[];
5
5
  declare const applies: ({ rel, text }: FacetContext) => boolean;
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.enrich = exports.classAttributes = exports.applies = exports.id = void 0;
4
+ const facet_1 = require("@md-code/follow-architecture/frameworks/facet");
4
5
  const id = "angular";
5
6
  exports.id = id;
6
7
  const enrich = (candidates) => {
7
8
  for (const candidate of candidates) {
8
- candidate.framework = { id, component: false, props: [], forwarded: [] };
9
+ (0, facet_1.attach)(candidate, { id, component: false, props: [], forwarded: [] });
9
10
  }
10
11
  return candidates;
11
12
  };
@@ -1,5 +1,5 @@
1
1
  import type { SourceFile } from "ts-morph";
2
- import type { Candidate } from "../entities/facts";
2
+ import type { Candidate, FrameworkFacts } from "@md-code/follow-architecture/entities/facts";
3
3
  type FacetContext = {
4
4
  rel?: string | null;
5
5
  sf?: SourceFile;
@@ -13,4 +13,6 @@ interface FrameworkFacet {
13
13
  enrich: (candidates: Candidate[], ctx: FacetContext) => Candidate[];
14
14
  classAttributes?: string[];
15
15
  }
16
+ declare const attach: (candidate: Candidate, facts: FrameworkFacts) => FrameworkFacts;
17
+ export { attach };
16
18
  export type { FacetContext, FrameworkFacet };
@@ -1,2 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.attach = void 0;
4
+ // Writing the namespace: MERGE, never replace. `framework` is one home with a
5
+ // branch per reader, and several readers may read the same file — react's
6
+ // components, the test reader's runner, the style facet's templates. A reader that
7
+ // assigned the whole object would erase what another had already found (that is
8
+ // how a `.tsx` test would lose its component reading), so every writer goes
9
+ // through here and names only the fields it read.
10
+ const attach = (candidate, facts) => {
11
+ const merged = { ...(candidate.framework ?? {}), ...facts };
12
+ candidate.framework = merged;
13
+ return merged;
14
+ };
15
+ exports.attach = attach;
@@ -1,4 +1,4 @@
1
- import type { Candidate } from "../entities/facts";
1
+ import type { Candidate } from "@md-code/follow-architecture/entities/facts";
2
2
  import type { FacetContext, FrameworkFacet } from "./facet";
3
3
  declare const REGISTRY: Record<string, () => FrameworkFacet>;
4
4
  declare const facets: () => FrameworkFacet[];
@@ -35,17 +35,21 @@ exports.REGISTRY = exports.resetFacets = exports.classAttributes = exports.facet
35
35
  //
36
36
  // Facets never edit core facts. A facet that throws is isolated and reported — a
37
37
  // broken reader must not take the analysis of a file down with it.
38
- const notices_1 = require("../report/notices");
39
- const reason_1 = require("../utils/reason");
38
+ const notices_1 = require("@md-code/follow-architecture/report/notices");
39
+ const reason_1 = require("@md-code/follow-architecture/utils/reason");
40
40
  const react = __importStar(require("./react"));
41
41
  const vue = __importStar(require("./vue"));
42
42
  const angular = __importStar(require("./angular"));
43
+ const test = __importStar(require("./test"));
43
44
  // The built-in facets, by id. Adding a framework is a module plus an entry here —
44
- // the engine never changes.
45
+ // the engine never changes. `test` is a reader like the others: it reads the same
46
+ // file for a different question, and the order is what makes `id` deterministic
47
+ // (a component reading wins over the test reading on the same candidate).
45
48
  const REGISTRY = {
46
49
  react: () => react,
47
50
  vue: () => vue,
48
51
  angular: () => angular,
52
+ test: () => test,
49
53
  };
50
54
  exports.REGISTRY = REGISTRY;
51
55
  let cache = null;
@@ -70,7 +74,7 @@ const facets = () => {
70
74
  };
71
75
  exports.facets = facets;
72
76
  // `ctx` is the run context a facet may ask about: the file, its path, its text.
73
- // Enrichment happens once per file, before classification, so a code role can be
77
+ // Enrichment happens once per file, before classification, so a code entity can be
74
78
  // defined on a framework fact just like on `kind`.
75
79
  const enrich = (candidates, ctx) => {
76
80
  for (const facet of facets()) {
@@ -1,5 +1,5 @@
1
- import type { Candidate } from "../../entities/facts";
2
- import type { FacetContext } from "../facet";
1
+ import type { Candidate } from "@md-code/follow-architecture/entities/facts";
2
+ import { type FacetContext } from "@md-code/follow-architecture/frameworks/facet";
3
3
  declare const id = "react";
4
4
  declare const enrich: (candidates: Candidate[], ctx: FacetContext) => Candidate[];
5
5
  declare const applies: ({ rel, sf }: FacetContext) => boolean;
@@ -14,9 +14,10 @@ exports.enrich = exports.classAttributes = exports.applies = exports.id = void 0
14
14
  // as everything it received. This is props drilling as a NUMBER, so
15
15
  // a rule says `gt: 3` or `gt: 10` without any engine change.
16
16
  const ts_morph_1 = require("ts-morph");
17
- const tree_1 = require("../../entities/ast/tree");
18
- const climb_1 = require("../../entities/ast/climb");
19
- const distinct_1 = require("../../utils/distinct");
17
+ const tree_1 = require("@md-code/follow-architecture/entities/ast/tree");
18
+ const climb_1 = require("@md-code/follow-architecture/entities/ast/climb");
19
+ const distinct_1 = require("@md-code/follow-architecture/utils/distinct");
20
+ const facet_1 = require("@md-code/follow-architecture/frameworks/facet");
20
21
  const id = "react";
21
22
  exports.id = id;
22
23
  // "Is this a function?" is asked of the SHAPE, not of a list of kind names: a
@@ -49,7 +50,7 @@ const nearestFunction = (node) => {
49
50
  const stop = (0, climb_1.climbFrom)(node, { isHolder: isFunctionLike });
50
51
  return stop.found ? stop.node : null;
51
52
  };
52
- const openingOf = (element) => (ts_morph_1.Node.isJsxElement(element) ? element.getOpeningElement() : element);
53
+ const openingOf = (element) => ts_morph_1.Node.isJsxElement(element) ? element.getOpeningElement() : element;
53
54
  const tagOf = (element) => {
54
55
  const tag = openingOf(element).getTagNameNode();
55
56
  return tag ? String(tag.getText()) : null;
@@ -129,10 +130,15 @@ const componentTag = (tag) => (tag && /^[A-Z][\w$]*$/.test(tag) ? tag : null);
129
130
  // identifier argument that names a piece in this file. One hop only; anything
130
131
  // else is the wrapper itself.
131
132
  const aliasTargetOf = (sf, tag, names) => {
132
- const initializer = sf.getVariableDeclarations().find((declaration) => declaration.getName() === tag)?.getInitializer();
133
+ const initializer = sf
134
+ .getVariableDeclarations()
135
+ .find((declaration) => declaration.getName() === tag)
136
+ ?.getInitializer();
133
137
  if (!initializer || !ts_morph_1.Node.isCallExpression(initializer))
134
138
  return null;
135
- const target = initializer.getArguments().find((argument) => ts_morph_1.Node.isIdentifier(argument) && names.has(argument.getText()));
139
+ const target = initializer
140
+ .getArguments()
141
+ .find((argument) => ts_morph_1.Node.isIdentifier(argument) && names.has(argument.getText()));
136
142
  return target && ts_morph_1.Node.isIdentifier(target) ? target.getText() : null;
137
143
  };
138
144
  // The links the depth walk follows: every component this piece renders, and the
@@ -167,7 +173,9 @@ const IDENTIFIER = /[A-Za-z_$][\w$]*/g;
167
173
  // The local names one event attribute references. A braced expression may name
168
174
  // one or several (`onClick={busy ? stop : go}`); a name the file does not
169
175
  // declare is not one of ours.
170
- const namesInEvent = (attribute, names) => attribute.value ? [...attribute.value.matchAll(IDENTIFIER)].map((match) => match[0]).filter((name) => names.has(name)) : [];
176
+ const namesInEvent = (attribute, names) => attribute.value
177
+ ? [...attribute.value.matchAll(IDENTIFIER)].map((match) => match[0]).filter((name) => names.has(name))
178
+ : [];
171
179
  const handlerNamesOf = (own, names) => {
172
180
  const handlers = new Set();
173
181
  for (const element of own) {
@@ -181,9 +189,16 @@ const handlerNamesOf = (own, names) => {
181
189
  return handlers;
182
190
  };
183
191
  const elementsOf = (sf) => {
184
- const elements = [...sf.getDescendantsOfKind(tree_1.SK.JsxSelfClosingElement), ...sf.getDescendantsOfKind(tree_1.SK.JsxElement)];
192
+ const elements = [
193
+ ...sf.getDescendantsOfKind(tree_1.SK.JsxSelfClosingElement),
194
+ ...sf.getDescendantsOfKind(tree_1.SK.JsxElement),
195
+ ];
185
196
  return elements
186
- .map((element) => ({ pos: element.getStart(), owner: nearestFunction(element)?.getStartLineNumber() ?? null, facts: elementFacts(element) }))
197
+ .map((element) => ({
198
+ pos: element.getStart(),
199
+ owner: nearestFunction(element)?.getStartLineNumber() ?? null,
200
+ facts: elementFacts(element),
201
+ }))
187
202
  .filter((entry) => entry.facts.tag)
188
203
  .sort((a, b) => a.pos - b.pos);
189
204
  };
@@ -201,7 +216,15 @@ const enrich = (candidates, ctx) => {
201
216
  const startLine = renderStartLine(candidate);
202
217
  const own = elements.filter((entry) => startLine !== null && entry.owner === startLine).map((entry) => entry.facts);
203
218
  const received = receivedOf(candidate);
204
- candidate.framework = { id, component: own.length > 0, jsx: own, props: received, forwarded: forwardedOf(own, received), links: linksOf(own, ctx, names), handler: candidate.name ? handlers.has(candidate.name) : false };
219
+ (0, facet_1.attach)(candidate, {
220
+ id,
221
+ component: own.length > 0,
222
+ jsx: own,
223
+ props: received,
224
+ forwarded: forwardedOf(own, received),
225
+ links: linksOf(own, ctx, names),
226
+ handler: candidate.name ? handlers.has(candidate.name) : false,
227
+ });
205
228
  }
206
229
  return candidates;
207
230
  };
@@ -0,0 +1,6 @@
1
+ import { type FacetContext } from "@md-code/follow-architecture/frameworks/facet";
2
+ import type { Candidate } from "@md-code/follow-architecture/entities/facts";
3
+ declare const id = "test";
4
+ declare const enrich: (candidates: Candidate[], ctx: FacetContext) => Candidate[];
5
+ declare const applies: ({ sf }: FacetContext) => boolean;
6
+ export { id, applies, enrich };
@@ -0,0 +1,157 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enrich = exports.applies = exports.id = void 0;
4
+ // Tests: what a file written for a test runner is.
5
+ //
6
+ // The engine sees `describe(...)`, `it(...)`, `expect(...)` as calls like any
7
+ // other; this facet reads them as a test file's facts, so an entity can be
8
+ // inferred from what the file DOES rather than from where it happens to live:
9
+ //
10
+ // runner the module the test API was imported from (`vitest` → "vitest",
11
+ // `@jest/globals` → "jest")
12
+ // cases `it`/`test` calls — the tests themselves
13
+ // asserts `expect` calls
14
+ // hooks the `before*`/`after*` hooks the file installs, by name
15
+ // snapshots `toMatchSnapshot`/`toMatchInlineSnapshot` calls
16
+ // mocks `vi.*`/`jest.*` mock calls
17
+ //
18
+ // A TYPE-only import is a TypeScript reading, not a test: `import type { Mock }
19
+ // from "vitest"` — or a `type` specifier — brings no runtime, so a file that only
20
+ // borrows a test type stays a plain module.
21
+ //
22
+ // The facts are the FILE's: a test file is a test file in every piece it declares,
23
+ // the same way the vue and angular gates attach their base to every candidate. The
24
+ // namespace is written through `attach`, so a component reading already on the
25
+ // candidate (a `.tsx` test that renders) keeps its id and its jsx — the test facts
26
+ // sit beside it instead of replacing them.
27
+ const ts_morph_1 = require("ts-morph");
28
+ const tree_1 = require("@md-code/follow-architecture/entities/ast/tree");
29
+ const properties_1 = require("@md-code/follow-architecture/entities/ast/properties");
30
+ const facet_1 = require("@md-code/follow-architecture/frameworks/facet");
31
+ const id = "test";
32
+ exports.id = id;
33
+ // The modules a test runtime is imported FROM, and the id the fact carries. A
34
+ // reader's vocabulary, not the engine's: another runner is one entry here.
35
+ const RUNNERS = new Map([
36
+ ["vitest", "vitest"],
37
+ ["@jest/globals", "jest"],
38
+ ]);
39
+ // Does the import bring a VALUE binding? A `type`-only declaration, or one whose
40
+ // every named specifier is `type`, is the type checker's business only.
41
+ const hasValueBinding = (declaration) => {
42
+ if (declaration.isTypeOnly())
43
+ return false;
44
+ const named = declaration.getNamedImports();
45
+ if (named.length === 0)
46
+ return true;
47
+ return named.some((specifier) => !specifier.isTypeOnly());
48
+ };
49
+ const runnerOf = (sf) => {
50
+ for (const declaration of sf.getImportDeclarations()) {
51
+ const runner = RUNNERS.get(declaration.getModuleSpecifierValue());
52
+ if (runner && hasValueBinding(declaration))
53
+ return runner;
54
+ }
55
+ return null;
56
+ };
57
+ // The call NAMES a test file is written with — the runners' own vocabulary, so it
58
+ // lives here rather than in the engine. A name is read as its chain's ROOT
59
+ // (`it.each(…)` is a case, `expect(x).toMatchSnapshot()` is an assertion), and the
60
+ // terminal member is kept for the matchers.
61
+ const CASES = new Set(["it", "test"]);
62
+ const ASSERTS = new Set(["expect"]);
63
+ const HOOKS = new Set(["beforeAll", "beforeEach", "afterAll", "afterEach"]);
64
+ const SNAPSHOTS = new Set(["toMatchSnapshot", "toMatchInlineSnapshot"]);
65
+ const MOCKS = new Set([
66
+ "mock",
67
+ "doMock",
68
+ "unmock",
69
+ "doUnmock",
70
+ "fn",
71
+ "spyOn",
72
+ "stubGlobal",
73
+ "mocked",
74
+ "importActual",
75
+ "importMock",
76
+ ]);
77
+ const MOCK_ROOTS = new Set(["vi", "jest"]);
78
+ // A chain is ONE call. `expect(x).toBe(y)` is a single assertion and its inner
79
+ // `expect(x)` is where that assertion begins — counting both would double every
80
+ // number the reader reports, so a call that is a chain's first link is skipped and
81
+ // the outermost call speaks for it.
82
+ const isChainStart = (call) => {
83
+ const parent = call.getParent();
84
+ if (!parent)
85
+ return false;
86
+ if (ts_morph_1.Node.isPropertyAccessExpression(parent) || ts_morph_1.Node.isElementAccessExpression(parent))
87
+ return parent.getExpression() === call;
88
+ if (ts_morph_1.Node.isCallExpression(parent))
89
+ return parent.getExpression() === call;
90
+ if (ts_morph_1.Node.isTaggedTemplateExpression(parent))
91
+ return parent.getTag() === call;
92
+ return false;
93
+ };
94
+ const rootOf = (expr) => {
95
+ const origin = (0, properties_1.leftmostOrigin)(expr);
96
+ return origin ? origin.split(".")[0] : null;
97
+ };
98
+ // One call, one bucket — the bucket its root names (`vi.mock` is a mock, `it` a
99
+ // case, `expect` an assertion). A chain speaks once: the outermost call is counted,
100
+ // the inner `expect(x)` is the same assertion beginning.
101
+ const tally = (target, counts, hooks) => {
102
+ const root = rootOf(target);
103
+ const member = (0, properties_1.lastMemberName)(target);
104
+ if (!root)
105
+ return;
106
+ if (CASES.has(root))
107
+ counts.cases += 1;
108
+ if (HOOKS.has(root))
109
+ hooks.add(root);
110
+ if (MOCK_ROOTS.has(root) && member !== null && MOCKS.has(member))
111
+ counts.mocks += 1;
112
+ if (!ASSERTS.has(root))
113
+ return;
114
+ // A snapshot match IS an assertion — counted as both, because the two questions
115
+ // a rule asks ("is anything asserted here?" and "does this file pin output?")
116
+ // have different answers.
117
+ counts.asserts += 1;
118
+ if (member !== null && SNAPSHOTS.has(member))
119
+ counts.snapshots += 1;
120
+ };
121
+ // What the file's calls say: one walk over the calls it makes.
122
+ const countsOf = (sf) => {
123
+ const counts = { cases: 0, asserts: 0, snapshots: 0, mocks: 0 };
124
+ const hooks = new Set();
125
+ for (const call of sf.getDescendantsOfKind(tree_1.SK.CallExpression)) {
126
+ if (!isChainStart(call))
127
+ tally(call.getExpression(), counts, hooks);
128
+ }
129
+ return { ...counts, hooks: [...hooks] };
130
+ };
131
+ // The file's test facts — or nothing at all. A file with no test runtime and no
132
+ // test call is not a test file, so it gets no `framework.test` (an absent fact is
133
+ // never a false one).
134
+ const testFactsOf = (sf) => {
135
+ const runner = runnerOf(sf);
136
+ const counts = countsOf(sf);
137
+ if (!runner && !counts.cases && !counts.asserts)
138
+ return null;
139
+ return { runner, ...counts };
140
+ };
141
+ const enrich = (candidates, ctx) => {
142
+ const test = ctx.sf ? testFactsOf(ctx.sf) : null;
143
+ if (!test)
144
+ return candidates;
145
+ for (const candidate of candidates) {
146
+ // The component readers own `id` where they spoke; the test reader names the
147
+ // file only where nobody else did.
148
+ (0, facet_1.attach)(candidate, { id: candidate.framework?.id ?? id, test });
149
+ }
150
+ return candidates;
151
+ };
152
+ exports.enrich = enrich;
153
+ // Cheap gate: a test runtime imported, or a call spelled like a test API (the
154
+ // globals-only flavour — a jest file that imports nothing). A .ts helper pays a
155
+ // text scan and, when it calls nothing test-shaped, one import read.
156
+ const applies = ({ sf }) => Boolean(sf) && (runnerOf(sf) !== null || /(^|[^\w$.])(it|test|expect)\s*\(/.test(sf.getFullText()));
157
+ exports.applies = applies;
@@ -1,5 +1,5 @@
1
- import type { Candidate } from "../../entities/facts";
2
- import type { FacetContext } from "../facet";
1
+ import type { Candidate } from "@md-code/follow-architecture/entities/facts";
2
+ import { type FacetContext } from "@md-code/follow-architecture/frameworks/facet";
3
3
  declare const id = "vue";
4
4
  declare const enrich: (candidates: Candidate[]) => Candidate[];
5
5
  declare const applies: ({ rel, text }: FacetContext) => boolean;