@md-code/follow-architecture 0.3.0 → 0.3.2

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 (387) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +1310 -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 +132 -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} +98 -61
  14. package/dist/code-entities/project.d.ts +21 -0
  15. package/dist/code-entities/project.js +259 -0
  16. package/dist/code-entities/walk.d.ts +31 -0
  17. package/dist/code-entities/walk.js +105 -0
  18. package/dist/config-options.d.ts +23 -0
  19. package/dist/config-options.js +18 -1
  20. package/dist/config-project.js +27 -9
  21. package/dist/config-report.d.ts +1 -1
  22. package/dist/config-report.js +37 -10
  23. package/dist/config-rule.d.ts +25 -0
  24. package/dist/config-rule.js +106 -13
  25. package/dist/config-state.d.ts +14 -3
  26. package/dist/config-state.js +197 -24
  27. package/dist/config.d.ts +25 -0
  28. package/dist/css/index.d.ts +11 -7
  29. package/dist/css/index.js +141 -30
  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 +18 -8
  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 +21 -9
  37. package/dist/css/syntax/scss/index.d.ts +2 -2
  38. package/dist/css/syntax/scss/index.js +18 -8
  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 +34 -14
  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 +32 -15
  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 +21 -11
  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 +148 -37
  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 +10 -8
  133. package/dist/entities/location/where.js +89 -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 +89 -19
  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 +112 -51
  154. package/dist/entities/tree/entries.d.ts +4 -4
  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 +26 -12
  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 +242 -0
  164. package/dist/fa-store.d.ts +22 -0
  165. package/dist/fa-store.js +232 -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 +297 -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 +25 -11
  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 +62 -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 +219 -0
  190. package/dist/main.d.ts +5 -2
  191. package/dist/main.js +223 -41
  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 +64 -11
  196. package/dist/nodes/finally/emit.d.ts +4 -4
  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 +78 -56
  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 +64 -62
  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.d.ts +1 -1
  226. package/dist/pipeline.js +19 -64
  227. package/dist/release-file.d.ts +3 -0
  228. package/dist/release-file.js +13 -0
  229. package/dist/report/asks.d.ts +3 -3
  230. package/dist/report/asks.js +16 -6
  231. package/dist/report/configErrors.d.ts +55 -27
  232. package/dist/report/configErrors.js +81 -35
  233. package/dist/report/errorTypes/codes/structure.d.ts +1 -1
  234. package/dist/report/errorTypes/codes/structure.js +9 -9
  235. package/dist/report/errorTypes/decision-maker.d.ts +5 -5
  236. package/dist/report/errorTypes/decision-maker.js +21 -11
  237. package/dist/report/errorTypes/destinations.d.ts +5 -5
  238. package/dist/report/errorTypes/destinations.js +52 -34
  239. package/dist/report/errorTypes/finding-type.d.ts +3 -3
  240. package/dist/report/errorTypes/index.d.ts +1 -1
  241. package/dist/report/errorTypes/index.js +17 -7
  242. package/dist/report/errorTypes/types/fileContents.d.ts +4 -4
  243. package/dist/report/errorTypes/types/fileContents.js +11 -5
  244. package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
  245. package/dist/report/errorTypes/types/{unknownRole.js → unknownEntity.js} +12 -7
  246. package/dist/report/errorTypes/types/wrongAction.d.ts +5 -5
  247. package/dist/report/errorTypes/types/wrongAction.js +18 -13
  248. package/dist/report/errorTypes/types/wrongPlacement.d.ts +4 -4
  249. package/dist/report/errorTypes/types/wrongPlacement.js +19 -9
  250. package/dist/report/errorTypes/vocabulary/ids.d.ts +2 -2
  251. package/dist/report/errorTypes/vocabulary/ids.js +3 -3
  252. package/dist/report/errorTypes/vocabulary/phrases.d.ts +2 -2
  253. package/dist/report/errorTypes/vocabulary/phrases.js +39 -26
  254. package/dist/report/errorTypes/vocabulary/places.d.ts +3 -3
  255. package/dist/report/errorTypes/vocabulary/places.js +13 -13
  256. package/dist/report/finding-from.d.ts +3 -3
  257. package/dist/report/finding-from.js +14 -9
  258. package/dist/report/notices.d.ts +6 -1
  259. package/dist/report/notices.js +46 -20
  260. package/dist/report/observed.d.ts +19 -0
  261. package/dist/report/observed.js +87 -0
  262. package/dist/report/render-report.d.ts +1 -1
  263. package/dist/report/render-report.js +33 -30
  264. package/dist/report/user-report/build/bundle.js +26 -7
  265. package/dist/report/user-report/build/bundle.prebuilt.js +799 -297
  266. package/dist/report/user-report/data/collect.d.ts +2 -2
  267. package/dist/report/user-report/data/collect.js +32 -19
  268. package/dist/report/user-report/data/entities.d.ts +7 -0
  269. package/dist/report/user-report/data/{roles.js → entities.js} +27 -22
  270. package/dist/report/user-report/data/{role-examples.d.ts → entity-examples.d.ts} +3 -3
  271. package/dist/report/user-report/data/entity-examples.js +136 -0
  272. package/dist/report/user-report/data/{role-filters.d.ts → entity-filters.d.ts} +2 -2
  273. package/dist/report/user-report/data/{role-filters.js → entity-filters.js} +7 -7
  274. package/dist/report/user-report/data/entity-marks.d.ts +5 -0
  275. package/dist/report/user-report/data/{role-marks.js → entity-marks.js} +11 -11
  276. package/dist/report/user-report/data/file-tree.d.ts +3 -3
  277. package/dist/report/user-report/data/file-tree.js +13 -5
  278. package/dist/report/user-report/data/finding-boundary.d.ts +4 -4
  279. package/dist/report/user-report/data/finding-boundary.js +2 -2
  280. package/dist/report/user-report/data/finding-plan.d.ts +5 -5
  281. package/dist/report/user-report/data/finding-plan.js +10 -10
  282. package/dist/report/user-report/data/finding-title.d.ts +2 -2
  283. package/dist/report/user-report/data/finding-title.js +8 -8
  284. package/dist/report/user-report/data/findings.d.ts +4 -4
  285. package/dist/report/user-report/data/findings.js +30 -20
  286. package/dist/report/user-report/data/graph-edges.d.ts +4 -4
  287. package/dist/report/user-report/data/graph-edges.js +19 -19
  288. package/dist/report/user-report/data/graph-entities.d.ts +6 -0
  289. package/dist/report/user-report/data/graph-entities.js +158 -0
  290. package/dist/report/user-report/data/graph-helpers.d.ts +5 -5
  291. package/dist/report/user-report/data/graph-helpers.js +15 -15
  292. package/dist/report/user-report/data/graph.d.ts +5 -4
  293. package/dist/report/user-report/data/graph.js +28 -21
  294. package/dist/report/user-report/data/nodes.d.ts +2 -2
  295. package/dist/report/user-report/data/nodes.js +33 -23
  296. package/dist/report/user-report/data/rules.d.ts +7 -0
  297. package/dist/report/user-report/data/{invariants.js → rules.js} +13 -13
  298. package/dist/report/user-report/data/scan.d.ts +1 -1
  299. package/dist/report/user-report/data/scan.js +19 -9
  300. package/dist/report/user-report/html/shell.d.ts +1 -1
  301. package/dist/report/user-report/html/shell.js +1 -1
  302. package/dist/report/user-report/index.d.ts +1 -1
  303. package/dist/report/user-report/index.js +17 -7
  304. package/dist/report/user-report/shared/describe.d.ts +1 -1
  305. package/dist/report/user-report/shared/describe.js +6 -6
  306. package/dist/rules/index.d.ts +7 -0
  307. package/dist/{invariants → rules}/index.js +85 -57
  308. package/dist/{invariants → rules}/list-vars.d.ts +2 -2
  309. package/dist/{invariants → rules}/list-vars.js +9 -3
  310. package/dist/{invariants → rules}/name.js +2 -2
  311. package/dist/rules/normalize.d.ts +5 -0
  312. package/dist/rules/normalize.js +108 -0
  313. package/dist/{invariants → rules}/vars.d.ts +9 -7
  314. package/dist/{invariants → rules}/vars.js +5 -5
  315. package/dist/scan-run.d.ts +20 -0
  316. package/dist/scan-run.js +130 -0
  317. package/dist/scripts/audit-report.js +19 -9
  318. package/dist/usage-index.d.ts +4 -0
  319. package/dist/usage-index.js +282 -0
  320. package/dist/usage-mode.d.ts +7 -0
  321. package/dist/usage-mode.js +16 -0
  322. package/dist/usage-pass.d.ts +19 -0
  323. package/dist/usage-pass.js +136 -0
  324. package/dist/usage-prepare.d.ts +2 -0
  325. package/dist/usage-prepare.js +22 -0
  326. package/dist/usage-sweep.d.ts +10 -0
  327. package/dist/usage-sweep.js +264 -0
  328. package/dist/utils/aliases.d.ts +22 -0
  329. package/dist/utils/aliases.js +173 -0
  330. package/dist/utils/classify.d.ts +2 -2
  331. package/dist/utils/classify.js +4 -4
  332. package/dist/utils/configs.js +17 -7
  333. package/dist/utils/distinct.js +4 -2
  334. package/dist/utils/files.js +41 -37
  335. package/dist/utils/fixpoint.js +2 -2
  336. package/dist/utils/host.d.ts +1 -1
  337. package/dist/utils/host.js +4 -1
  338. package/dist/utils/imports.js +83 -19
  339. package/dist/utils/keyed.js +2 -2
  340. package/dist/utils/map-record.js +2 -2
  341. package/dist/utils/packages.d.ts +15 -0
  342. package/dist/utils/packages.js +207 -0
  343. package/dist/utils/path-label.js +3 -1
  344. package/dist/utils/pattern.d.ts +5 -4
  345. package/dist/utils/pattern.js +55 -15
  346. package/dist/utils/permission.d.ts +3 -3
  347. package/dist/utils/permission.js +4 -2
  348. package/dist/utils/plural.js +2 -2
  349. package/dist/utils/qualified.js +4 -4
  350. package/dist/utils/rank.js +2 -2
  351. package/dist/utils/record.js +1 -1
  352. package/dist/utils/search.js +7 -2
  353. package/dist/utils/speak.js +1 -1
  354. package/dist/utils/split.js +14 -1
  355. package/dist/utils/template.d.ts +1 -1
  356. package/dist/utils/template.js +1 -1
  357. package/dist/utils/tokenize.js +6 -1
  358. package/dist/utils/typed-field.js +2 -2
  359. package/dist/utils/verdicts.js +1 -1
  360. package/entities/operators.ts +1 -1
  361. package/package.json +101 -90
  362. package/report/errorTypes/vocabulary/ids.ts +7 -2
  363. package/report/errorTypes/vocabulary/phrases.ts +47 -27
  364. package/report/errorTypes/vocabulary/places.ts +21 -16
  365. package/report/user-report/shared/describe.ts +7 -7
  366. package/dist/code-roles/classify.d.ts +0 -11
  367. package/dist/code-roles/classify.js +0 -43
  368. package/dist/code-roles/connector.d.ts +0 -5
  369. package/dist/code-roles/connector.js +0 -114
  370. package/dist/code-roles/project.d.ts +0 -12
  371. package/dist/code-roles/project.js +0 -122
  372. package/dist/code-roles/roles.d.ts +0 -8
  373. package/dist/invariants/index.d.ts +0 -6
  374. package/dist/invariants/normalize.d.ts +0 -4
  375. package/dist/invariants/normalize.js +0 -95
  376. package/dist/nodes/child-roles.d.ts +0 -3
  377. package/dist/nodes/child-roles.js +0 -12
  378. package/dist/nodes/finally/roles.d.ts +0 -13
  379. package/dist/nodes/finally/roles.js +0 -41
  380. package/dist/report/errorTypes/types/unknownRole.d.ts +0 -9
  381. package/dist/report/user-report/data/graph-roles.d.ts +0 -5
  382. package/dist/report/user-report/data/graph-roles.js +0 -71
  383. package/dist/report/user-report/data/invariants.d.ts +0 -7
  384. package/dist/report/user-report/data/role-examples.js +0 -94
  385. package/dist/report/user-report/data/role-marks.d.ts +0 -5
  386. package/dist/report/user-report/data/roles.d.ts +0 -7
  387. /package/dist/{invariants → rules}/name.d.ts +0 -0
@@ -0,0 +1,264 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.nameSymbol = exports.sweep = void 0;
37
+ // WHO USES A NAME, IN ONE WALK. `findReferencesAsNodes` asks the language service
38
+ // a question about the whole program once per candidate — 38 000 questions on this
39
+ // repo, ~1.5 ms each, and every answer re-derives what the checker already knows.
40
+ // The same facts are computable in a single pass: resolve every identifier to its
41
+ // symbol, group the occurrences by that symbol, and count.
42
+ //
43
+ // The answer keeps the shape and the meaning of `ReferencesFact`
44
+ // (`entities/facts.ts`): `total` = uses (the declaration's own name is not a use,
45
+ // a use in the declaring file is), `outside` = the ones in other files, `files` =
46
+ // the distinct files, `usedIn` = those where the name is USED and not merely
47
+ // republished by `export … from`.
48
+ const path = __importStar(require("node:path"));
49
+ const ts_morph_1 = require("ts-morph");
50
+ const emptyPart = () => ({ all: 0, used: 0, head: false });
51
+ const tallyOf = (into, symbol) => {
52
+ let tally = into.names.get(symbol);
53
+ if (tally === undefined) {
54
+ tally = new Map();
55
+ into.names.set(symbol, tally);
56
+ }
57
+ return tally;
58
+ };
59
+ const partOf = (name, file) => {
60
+ const found = name.get(file);
61
+ if (found !== undefined)
62
+ return found;
63
+ const part = emptyPart();
64
+ name.set(file, part);
65
+ return part;
66
+ };
67
+ // The file a node lives in, relative to the repo — the spelling a rule sees.
68
+ const relOf = (node, repoRoot) => {
69
+ const file = node.getSourceFile().fileName;
70
+ const rel = path.relative(repoRoot, file);
71
+ return rel.startsWith("..") ? null : rel.split(path.sep).join("/");
72
+ };
73
+ // Is the token part of an `export … from`? The same syntax rule the language
74
+ // service answer is filtered by: walk up to the statement that holds the name.
75
+ const inExportFrom = (node) => {
76
+ for (let current = node.parent; current !== undefined; current = current.parent) {
77
+ if (current.kind === ts_morph_1.ts.SyntaxKind.SourceFile)
78
+ return false;
79
+ if (current.kind === ts_morph_1.ts.SyntaxKind.ExportDeclaration)
80
+ return true;
81
+ }
82
+ return false;
83
+ };
84
+ // A declaration inside `declare global { … }` or `declare module "x" { … }` does
85
+ // not own its symbol: the checker merges those declarations into a symbol of
86
+ // another file's scope, and the walk sees a different one. The language service
87
+ // resolves the merge; the walk does not, so the name is answered exactly.
88
+ const inAmbientBlock = (node) => {
89
+ for (let current = node.parent; current !== undefined; current = current.parent) {
90
+ if (!ts_morph_1.ts.isModuleDeclaration(current))
91
+ continue;
92
+ const flags = ts_morph_1.ts.getCombinedModifierFlags(current);
93
+ if ((flags & ts_morph_1.ts.ModifierFlags.Ambient) !== 0)
94
+ return true;
95
+ if (current.name.kind === ts_morph_1.ts.SyntaxKind.StringLiteral)
96
+ return true;
97
+ }
98
+ return false;
99
+ };
100
+ // The token IS the name the TARGET symbol is declared under — the definition,
101
+ // which the language service does not count as a reference. Asked of the symbol
102
+ // rather than of the parent's shape: a declaration is whatever the checker says
103
+ // declares it. An alias (`import { x }`) declares the alias, not the target, and
104
+ // the language service counts it as a reference to the target — so it is a use.
105
+ const isDefinition = (node, target) => target.declarations !== undefined && target.declarations.some((declared) => declared === node.parent);
106
+ // An alias (`import { x as y }`, `export { x as y }`) names its target: the checker
107
+ // answers references against the TARGET's symbol, and so must the sweep, or the
108
+ // same name would be counted once per alias.
109
+ const targetOf = (checker, symbol) => {
110
+ if ((symbol.flags & ts_morph_1.ts.SymbolFlags.Alias) === 0)
111
+ return symbol;
112
+ try {
113
+ return checker.getAliasedSymbol(symbol);
114
+ }
115
+ catch {
116
+ return symbol;
117
+ }
118
+ };
119
+ // Do we count this token at all? Identifiers everywhere (declarations, uses,
120
+ // member names, shorthand properties, JSX names) and the string spelling of a
121
+ // module-specifier name (`import { "x" as y }`). Nothing else in a file names a binding.
122
+ const isNameToken = (node) => {
123
+ if (node.kind === ts_morph_1.ts.SyntaxKind.Identifier)
124
+ return true;
125
+ if (node.kind !== ts_morph_1.ts.SyntaxKind.StringLiteral)
126
+ return false;
127
+ const parent = node.parent;
128
+ return parent !== undefined && (ts_morph_1.ts.isImportSpecifier(parent) || ts_morph_1.ts.isExportSpecifier(parent));
129
+ };
130
+ // `namespaced` holds the files something imports as `import * as ns`: through a
131
+ // namespace any export may be reached, and the language service answers that
132
+ // shape its own way (it even counts the namespace token itself), so a name
133
+ // declared in such a file is not answered by the walk at all.
134
+ // A name re-exported under another name (`export { PairView as Diff }`) is counted
135
+ // by the language service once per spelling of the specifier, not once per token —
136
+ // three specifiers of `PairView` in one line give it six references where the walk
137
+ // sees three tokens. Not attributable here: such a symbol is asked exactly.
138
+ const isExportAlias = (node) => {
139
+ const parent = node.parent;
140
+ return parent !== undefined && ts_morph_1.ts.isExportSpecifier(parent) && parent.propertyName !== undefined;
141
+ };
142
+ // A class or interface member is answered across the type hierarchy: a use of the
143
+ // interface's `emit` is a reference to the class method that implements it, and
144
+ // the walk sees one symbol per declaration. Not attributable here — asked exactly.
145
+ const isMember = (symbol) => (symbol.flags & (ts_morph_1.ts.SymbolFlags.Property | ts_morph_1.ts.SymbolFlags.Method | ts_morph_1.ts.SymbolFlags.GetAccessor | ts_morph_1.ts.SymbolFlags.SetAccessor)) !== 0;
146
+ const isModuleSymbol = (symbol) => symbol.declarations !== undefined && symbol.declarations.some((each) => each.kind === ts_morph_1.ts.SyntaxKind.SourceFile);
147
+ const modulePath = (module, repoRoot) => {
148
+ for (const each of module.declarations ?? []) {
149
+ if (each.kind !== ts_morph_1.ts.SyntaxKind.SourceFile)
150
+ continue;
151
+ const rel = relOf(each, repoRoot);
152
+ if (rel !== null)
153
+ return rel;
154
+ }
155
+ return null;
156
+ };
157
+ const hasDeclarations = (symbol) => symbol.declarations !== undefined && symbol.declarations.length > 0;
158
+ // The symbol this token names: `{ Post }` declares a property, and the name is a
159
+ // USE of the variable that property reads — the shorthand answers for both.
160
+ const attribute = (node, checker) => {
161
+ const parent = node.parent;
162
+ const symbol = parent !== undefined && ts_morph_1.ts.isShorthandPropertyAssignment(parent)
163
+ ? checker.getShorthandAssignmentValueSymbol(parent)
164
+ : checker.getSymbolAtLocation(node);
165
+ return symbol === undefined ? undefined : targetOf(checker, symbol);
166
+ };
167
+ // One token → one count in its symbol's tally. A declaration in an ambient block,
168
+ // or a name whose symbol has no declaration at all (an augmentation's export), is
169
+ // not attributable by this walk: the name is answered exactly instead.
170
+ const countToken = (node, into, checker, repoRoot) => {
171
+ const target = attribute(node, checker);
172
+ if (target === undefined)
173
+ return;
174
+ const text = node.getText();
175
+ if (isExportAlias(node)) {
176
+ into.aliased.add(target);
177
+ return;
178
+ }
179
+ if (inAmbientBlock(node) || !hasDeclarations(target)) {
180
+ into.unsure.add(text);
181
+ return;
182
+ }
183
+ const rel = relOf(node, repoRoot);
184
+ if (rel === null)
185
+ return;
186
+ if (isModuleSymbol(target)) {
187
+ const file = modulePath(target, repoRoot);
188
+ if (file !== null)
189
+ into.namespaced.add(file);
190
+ return;
191
+ }
192
+ const part = partOf(tallyOf(into, target), rel);
193
+ if (part.all === 0)
194
+ part.head = isDefinition(node, target);
195
+ part.all += 1;
196
+ if (!inExportFrom(node))
197
+ part.used += 1;
198
+ };
199
+ // The whole program, one walk. Files outside the repo (the compiler's own libs, a
200
+ // dependency's `.d.ts`) are skipped: a use in them is not a use in this repo.
201
+ const collect = (program, repoRoot) => {
202
+ const checker = program.getTypeChecker();
203
+ const into = { names: new Map(), unsure: new Set(), namespaced: new Set(), aliased: new Set() };
204
+ for (const file of program.getSourceFiles()) {
205
+ if (relOf(file, repoRoot) === null)
206
+ continue;
207
+ const visit = (node) => {
208
+ if (isNameToken(node))
209
+ countToken(node, into, checker, repoRoot);
210
+ ts_morph_1.ts.forEachChild(node, visit);
211
+ };
212
+ ts_morph_1.ts.forEachChild(file, visit);
213
+ }
214
+ return into;
215
+ };
216
+ // The tally of one symbol as the fact a rule reads. The declaring file is the
217
+ // caller's business: the same name in two modules must answer for its own module.
218
+ // The declaration the caller asks about is not its own reference — the language
219
+ // service skips it, but only when nothing sortable comes before it in its file:
220
+ // a use above the declaration makes the declaration itself a counted reference.
221
+ const answerOf = (name, ownRel) => {
222
+ let total = name.get(ownRel)?.head === true ? -1 : 0;
223
+ const where = [];
224
+ const used = [];
225
+ for (const [file, part] of name) {
226
+ total += part.all;
227
+ if (file === ownRel)
228
+ continue;
229
+ if (part.all > 0)
230
+ where.push(file);
231
+ if (part.used > 0)
232
+ used.push(file);
233
+ }
234
+ return { total, outside: where.reduce((sum, file) => sum + (name.get(file)?.all ?? 0), 0), files: where, usedIn: used };
235
+ };
236
+ // The symbol a NAME TOKEN declares or uses, with aliases resolved: what the
237
+ // checker would answer references about.
238
+ const nameSymbol = (checker, node) => {
239
+ const symbol = checker.getSymbolAtLocation(node);
240
+ return symbol === undefined ? undefined : targetOf(checker, symbol);
241
+ };
242
+ exports.nameSymbol = nameSymbol;
243
+ const sweep = (program, repoRoot) => {
244
+ const { names, unsure, namespaced, aliased } = collect(program, repoRoot);
245
+ // A symbol with more than one declaration is answered per declaration by the
246
+ // language service, and the walk keeps one tally for all of them.
247
+ const merged = new Set();
248
+ for (const [symbol] of names)
249
+ if ((symbol.declarations?.length ?? 0) > 1)
250
+ merged.add(symbol);
251
+ return {
252
+ references: (symbol, ownRel, name) => {
253
+ if (unsure.has(name) || namespaced.has(ownRel) || merged.has(symbol) || isMember(symbol) || aliased.has(symbol))
254
+ return null;
255
+ const tally = names.get(symbol);
256
+ // A symbol the walk never met (a declaration outside the repository, a lib
257
+ // type) has no tally here, and "no uses" would be a claim, not an answer:
258
+ // the caller asks exactly instead.
259
+ return tally === undefined ? null : answerOf(tally, ownRel);
260
+ },
261
+ unsure,
262
+ };
263
+ };
264
+ exports.sweep = sweep;
@@ -0,0 +1,22 @@
1
+ import { type FieldValue } from "@md-code/follow-architecture/utils/field";
2
+ type Aliases = Record<string, string>;
3
+ type Alias = {
4
+ name: string;
5
+ rest: string;
6
+ };
7
+ declare const splitAlias: (aliases: Aliases | null | undefined, specifier: string) => Alias | null;
8
+ type Placement = {
9
+ dirs: string[];
10
+ files: string[];
11
+ };
12
+ type AliasScope = {
13
+ repoRoot?: string | null;
14
+ repoFiles?: readonly string[];
15
+ };
16
+ declare const locateAlias: (aliases: Aliases | null | undefined, name: string, rest: string, scope?: AliasScope) => Placement | null;
17
+ declare const placesOf: (aliases: Aliases | null | undefined, specifier: string, scope?: AliasScope) => string[] | null;
18
+ declare const primaryPlace: (aliases: Aliases | null | undefined, specifier: string, scope?: AliasScope) => string | null;
19
+ declare const expandPattern: (aliases: Aliases | null | undefined, pattern: string, scope?: AliasScope) => string;
20
+ declare const expandLocationFilters: (filter: FieldValue, aliases: Aliases | null | undefined) => FieldValue;
21
+ export { splitAlias, locateAlias, placesOf, primaryPlace, expandPattern, expandLocationFilters };
22
+ export type { Aliases, AliasScope, Placement };
@@ -0,0 +1,173 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.expandLocationFilters = exports.expandPattern = exports.primaryPlace = exports.placesOf = exports.locateAlias = exports.splitAlias = void 0;
37
+ // ONE vocabulary for the architecture's aliases: what a specifier names, where it
38
+ // points, and how a config pattern that starts with `@` becomes a repo path. Its
39
+ // four consumers — the import resolver, node names/children, rule `where`/`ignore`
40
+ // and `location` filters — ask these functions and nothing else, so the alias map
41
+ // and the packages' `exports` are read in exactly one place.
42
+ //
43
+ // Without a scanned set (the config is built before the repo is scanned) only the
44
+ // plain reading is available: `@pkg` is the package folder, `@pkg/x` the folder
45
+ // under it. With `{ repoRoot, repoFiles }` a subpath also goes through the
46
+ // package's manifest and lands on the source its artifact was built from.
47
+ const notices_1 = require("@md-code/follow-architecture/report/notices");
48
+ const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
49
+ const packages_1 = require("@md-code/follow-architecture/utils/packages");
50
+ const field_1 = require("@md-code/follow-architecture/utils/field");
51
+ const splitAlias = (aliases, specifier) => {
52
+ const s = String(specifier ?? "");
53
+ let name = null;
54
+ for (const candidate of Object.keys(aliases ?? {})) {
55
+ if (s !== candidate && !s.startsWith(`${candidate}/`))
56
+ continue;
57
+ if (name == null || candidate.length > name.length)
58
+ name = candidate;
59
+ }
60
+ if (name == null)
61
+ return null;
62
+ return { name, rest: s.slice(name.length).replace(/^\//, "") };
63
+ };
64
+ exports.splitAlias = splitAlias;
65
+ const isStars = (rest) => rest.length > 0 && /^\*(?:\/\*)*$/.test(rest);
66
+ // `@pkg/*` — every public source of the package, for a package that has no
67
+ // folders to walk. Only a scanned set can answer it.
68
+ const starredPlace = (folder, manifest, repoFiles) => {
69
+ const sources = (0, packages_1.publicSources)(folder, manifest, repoFiles);
70
+ return sources.length ? { dirs: [], files: sources } : null;
71
+ };
72
+ const artifactPlace = ({ name, folder, rest, manifest, repoFiles }) => {
73
+ const folderReading = { dirs: [`${folder}/${rest}`], files: [] };
74
+ const artifact = (0, packages_1.exportsPath)(manifest, rest) ?? (0, packages_1.typesVersionPath)(manifest, rest);
75
+ if (artifact == null || !repoFiles)
76
+ return folderReading;
77
+ const source = (0, packages_1.sourceOf)(folder, artifact, repoFiles);
78
+ if (source)
79
+ return { dirs: [], files: [source] };
80
+ (0, notices_1.notice)(`the alias ${name}/${rest} points at ${(0, packages_1.norm)(artifact)}, which no scanned file mirrors`, "the package's `exports` names that file but the package has no source for it — the import resolves to nothing the architecture can see");
81
+ return folderReading;
82
+ };
83
+ // Where an alias subpath points: the package's public entry when its manifest
84
+ // names one, otherwise the folder (or file) under the alias target.
85
+ const locateAlias = (aliases, name, rest, scope = {}) => {
86
+ const target = aliases?.[name];
87
+ if (target == null)
88
+ return null;
89
+ const folder = (0, packages_1.folderOf)(target);
90
+ if (!rest)
91
+ return { dirs: [folder], files: (0, packages_1.isFile)(target) ? [(0, packages_1.norm)(target)] : [] };
92
+ const manifest = (0, packages_1.manifestOf)(scope.repoRoot, folder);
93
+ const repoFiles = scope.repoFiles;
94
+ const starred = repoFiles && isStars(rest) ? starredPlace(folder, manifest, repoFiles) : null;
95
+ return starred ?? artifactPlace({ name, folder, rest, manifest, repoFiles });
96
+ };
97
+ exports.locateAlias = locateAlias;
98
+ // A CONFIG pattern (`@pkg/**`, `@pkg/chip`, `@pkg/themes`) → the repo place(s) it
99
+ // stands for, absolute. `null` when the specifier is not an alias at all.
100
+ const placesOf = (aliases, specifier, scope = {}) => {
101
+ const alias = splitAlias(aliases, specifier);
102
+ if (!alias)
103
+ return null;
104
+ const place = locateAlias(aliases, alias.name, alias.rest, scope);
105
+ const places = [...(place?.dirs ?? []), ...(place?.files ?? [])];
106
+ if (!places.length)
107
+ return [`${(0, packages_1.folderOf)(String(aliases?.[alias.name] ?? ""))}/${alias.rest}`];
108
+ return places;
109
+ };
110
+ exports.placesOf = placesOf;
111
+ // The ONE place a specifier names, when the caller needs a single string (a node's
112
+ // name, a child): the package folder when the alias has one, else the entry file.
113
+ const primaryPlace = (aliases, specifier, scope = {}) => {
114
+ const alias = splitAlias(aliases, specifier);
115
+ if (!alias)
116
+ return null;
117
+ const place = locateAlias(aliases, alias.name, alias.rest, scope);
118
+ if (place == null)
119
+ return null;
120
+ return place.dirs[0] ?? place.files[0] ?? null;
121
+ };
122
+ exports.primaryPlace = primaryPlace;
123
+ // A PREFIX pattern (`@md/utils/`) names a FOLDER and everything under it, so only
124
+ // folders answer it: the alias's entry file is not one.
125
+ const folderPlace = (aliases, specifier, scope) => {
126
+ const alias = splitAlias(aliases, specifier);
127
+ if (!alias) {
128
+ if (!specifier.startsWith("@"))
129
+ return specifier;
130
+ throw configError.unknownAlias({ specifier, known: Object.keys(aliases ?? {}) });
131
+ }
132
+ const place = locateAlias(aliases, alias.name, alias.rest, scope);
133
+ const folder = (0, packages_1.folderOf)(String(aliases?.[alias.name] ?? ""));
134
+ return place?.dirs[0] ?? (alias.rest ? `${folder}/${alias.rest}` : folder);
135
+ };
136
+ // A CONFIG pattern → the repo path it stands for: one path when the alias names
137
+ // one place, a brace alternation when it names several. A `@`-specifier that is
138
+ // NOT an alias is a config error — it would silently match nothing. A trailing
139
+ // `/` is a PREFIX (`startsWith: "@md/utils/"`), not a glob: it must survive, or
140
+ // the filter would widen from `utils/*` to `utils*` and swallow `utils-uniqueness`.
141
+ const expandPattern = (aliases, pattern, scope = {}) => {
142
+ const s = String(pattern ?? "");
143
+ if (s.endsWith("/"))
144
+ return `${folderPlace(aliases, s.slice(0, -1), scope)}/`;
145
+ const places = placesOf(aliases, s, scope);
146
+ if (!places) {
147
+ if (!s.startsWith("@"))
148
+ return s;
149
+ throw configError.unknownAlias({ specifier: s, known: Object.keys(aliases ?? {}) });
150
+ }
151
+ return places.length === 1 ? places[0] : `{${places.join(",")}}`;
152
+ };
153
+ exports.expandPattern = expandPattern;
154
+ // Only a `location` subtree names PLACES. A filter's other strings are values
155
+ // (`equals: "@angular/core"` names a package, not a file), so they stay as written.
156
+ const LOCATION_KEY = "location";
157
+ const rewritePatterns = (value, aliases, inside) => {
158
+ if (typeof value === "string")
159
+ return inside ? expandPattern(aliases, value) : value;
160
+ if ((0, field_1.isList)(value))
161
+ return value.map((item) => rewritePatterns(item, aliases, inside));
162
+ if (!(0, field_1.isObj)(value))
163
+ return value;
164
+ const out = {};
165
+ for (const [key, item] of Object.entries(value)) {
166
+ out[key] = rewritePatterns(item, aliases, inside || key === LOCATION_KEY);
167
+ }
168
+ return out;
169
+ };
170
+ // A filter with every `location` pattern expanded. A filter is plain data, so the
171
+ // rewrite is a copy — the raw config stays as written.
172
+ const expandLocationFilters = (filter, aliases) => rewritePatterns(filter, aliases, false);
173
+ exports.expandLocationFilters = expandLocationFilters;
@@ -1,5 +1,5 @@
1
- import type { QueryFilter, QueryScope } from "../entities/architecture";
2
- import type { FieldValue } from "../utils/field";
1
+ import type { QueryFilter, QueryScope } from "@md-code/follow-architecture/entities/architecture";
2
+ import type { FieldValue } from "@md-code/follow-architecture/utils/field";
3
3
  type Definition = {
4
4
  name: string;
5
5
  infer: QueryFilter;
@@ -3,12 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.firstMatch = exports.definitionsOf = void 0;
4
4
  // A CLASSIFICATION is one mechanism: definitions are tried in DECLARED ORDER
5
5
  // against a subject, and the FIRST whose `infer` filter matches names it. A
6
- // code role classifies a piece of code (`code-roles/connector`), a file's own
7
- // facts (`code-roles/classify`), and the roles a folder's files hold
6
+ // code entity classifies a piece of code (`code-entities/connector`), a file's own
7
+ // facts (`code-entities/classify`), and the entities a folder's files hold
8
8
  // (`nodes/similar`) — all three ask the same question of the same filter
9
9
  // engine, so the walk lives here once. What the definitions ARE and what a
10
- // match MEANS is the caller's own; nothing here knows roles.
11
- const queries_1 = require("../entities/queries");
10
+ // match MEANS is the caller's own; nothing here knows entities.
11
+ const queries_1 = require("@md-code/follow-architecture/entities/queries");
12
12
  // The definitions a record of `{ infer }` specs declares, in the record's own
13
13
  // (YAML) order. A spec without an infer filter can never match.
14
14
  const definitionsOf = (defs) => Object.entries(defs ?? {}).map(([name, def]) => ({ name, infer: def?.infer ?? null }));
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.configFacts = exports.loadConfigs = void 0;
27
37
  // The tool's own configs, declared in the ESLint RULE OPTIONS (and in the CLI
@@ -4,9 +4,11 @@ exports.distinctFlat = void 0;
4
4
  // A DISTINCT COLLECT is one mechanism: every item of a list contributes names
5
5
  // (zero, one, or many), and the answer is the names in first-seen order, each
6
6
  // once. A component's props are the distinct names its parameters contribute
7
- // (`frameworks/react`); an entity's shape is the distinct roles its children
7
+ // (`frameworks/react`); an entity's shape is the distinct entities its children
8
8
  // declare (`nodes/similar`). The walk is the same — flatMap the contributions,
9
9
  // keep the first of each — so it lives here once. What a name IS and where it
10
10
  // comes from is the caller's own.
11
- const distinctFlat = (items, namesOf) => [...new Set(items.flatMap(namesOf))];
11
+ const distinctFlat = (items, namesOf) => [
12
+ ...new Set(items.flatMap(namesOf)),
13
+ ];
12
14
  exports.distinctFlat = distinctFlat;
@@ -15,53 +15,57 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
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
- };
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
25
35
  Object.defineProperty(exports, "__esModule", { value: true });
26
36
  exports.collectFiles = void 0;
27
37
  // The ONE directory walk: which files of a repo the tool looks at. Scan scope is
28
38
  // the tool's (extensions, skipped folders, skipped globs), never the
29
- // architecture's — so there is one walker and two callers.
30
- const fs = __importStar(require("node:fs"));
39
+ // architecture's — so there is one walker and two callers. The recursion itself
40
+ // is the shared one (`@md-code/utils/node/files`): this file only states FA's
41
+ // scan scope on top of it.
31
42
  const path = __importStar(require("node:path"));
32
43
  const minimatch_1 = require("minimatch");
44
+ const files_1 = require("@md-code/utils/node/files");
33
45
  const imports_1 = require("./imports");
34
- const notices_1 = require("../report/notices");
46
+ const notices_1 = require("@md-code/follow-architecture/report/notices");
35
47
  // Absolute paths of every scanned file under `repoRoot`.
36
48
  const collectFiles = (repoRoot, { exts, ignoreDirs, ignoreGlobs = [] }) => {
37
49
  const extSet = new Set(exts);
38
- const ignoreSet = new Set(ignoreDirs);
39
- const out = [];
40
- const walk = (dir) => {
41
- let entries = [];
42
- try {
43
- entries = fs.readdirSync(dir, { withFileTypes: true });
44
- }
45
- catch (error) {
46
- const e = error;
47
- // An unreadable folder is not a scan error: the file list just does not
48
- // include it (folder facts degrade, the rule still runs). The reason is
49
- // reported, so a short list never looks like a complete one.
50
- (0, notices_1.notice)(`the folder ${dir} could not be read`, e.message ?? String(e));
51
- return;
52
- }
53
- for (const entry of entries) {
54
- const abs = path.join(dir, entry.name);
55
- if (entry.isDirectory()) {
56
- if (!ignoreSet.has(entry.name))
57
- walk(abs);
58
- }
59
- else if (extSet.has(path.extname(entry.name)) && !(ignoreGlobs ?? []).some((g) => (0, minimatch_1.minimatch)((0, imports_1.toRel)(repoRoot, abs), g))) {
60
- out.push(abs);
61
- }
62
- }
63
- };
64
- walk(repoRoot);
50
+ // `dot: true` because the walk below visits dot folders and dot files
51
+ // (`.prettierrc.js`, `apps/.tmp-ssr/…`): an ignore glob that cannot name them is
52
+ // not a scope, and `apps/**` would silently keep the dotted half of the tree.
53
+ const ignored = (rel) => ignoreGlobs.some((g) => (0, minimatch_1.minimatch)(rel, g, { dot: true }));
54
+ // The shared walk tests extensions by suffix, FA by the extension itself:
55
+ // the suffix pre-filter may keep a `x.mts` for `.ts`, the filter below drops
56
+ // it again, so the file list is exactly the one FA always had.
57
+ const files = (0, files_1.walk)(repoRoot, exts, ignoreDirs, {
58
+ // A dot directory is scan scope like any other here: FA has always
59
+ // visited `.github`, `.changeset` and friends unless listed as ignored.
60
+ dot: true,
61
+ // An unreadable folder is not a scan error: the file list just does not
62
+ // include it (folder facts degrade, the rule still runs). The reason is
63
+ // reported, so a short list never looks like a complete one.
64
+ onUnreadable: (dir, error) => {
65
+ (0, notices_1.notice)(`the folder ${dir} could not be read`, error instanceof Error ? error.message : String(error));
66
+ },
67
+ });
68
+ const out = files.filter((abs) => extSet.has(path.extname(abs)) && !ignored((0, imports_1.toRel)(repoRoot, abs)));
65
69
  // SORTED, always: `readdirSync` returns whatever order the filesystem
66
70
  // happens to keep (hashed on btrfs, insertion on ext4), so without this the
67
71
  // same tree produced a different report from one machine — or one run — to
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.untilStable = void 0;
4
4
  // A FIXPOINT is one mechanism: a step changes state and reports whether it did,
5
5
  // and the walk repeats until a step changes nothing (or a stated pass limit is
6
- // reached). Role assignment and call-target resolution feed each other — a
7
- // role may be inferred from the roles of the callees, while a callee's role is
6
+ // reached). Entity assignment and call-target resolution feed each other — a
7
+ // entity may be inferred from the entities of the callees, while a callee's entity is
8
8
  // what classification resolves — so the passes repeat until nothing moves.
9
9
  // The walk is the same for any mutually-feeding enrichment; what a step DOES
10
10
  // is the caller's own.
@@ -1,3 +1,3 @@
1
- import type { Candidate } from "../entities/facts";
1
+ import type { Candidate } from "@md-code/follow-architecture/entities/facts";
2
2
  declare const hostOf: (candidates: readonly Candidate[], line: number | null) => Candidate | undefined;
3
3
  export { hostOf };