@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
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.declaredActions = exports.changesState = exports.CHANGES_STATE = exports.EDGE_FACTS = exports.FACT_KINDS = exports.VIA = exports.RELATION = void 0;
27
- const configError = __importStar(require("../report/configErrors"));
27
+ const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
28
28
  // THE VOCABULARY, as an enum: one name per relation, one spelling everywhere.
29
29
  const RELATION = Object.freeze({
30
30
  IMPORT: "import",
@@ -47,15 +47,15 @@ const CHANGES_STATE = new Set([RELATION.MUTATE, RELATION.ASSIGN]);
47
47
  exports.CHANGES_STATE = CHANGES_STATE;
48
48
  const changesState = (relation) => CHANGES_STATE.has(relation);
49
49
  exports.changesState = changesState;
50
- // The role of the piece of code a fact belongs to, by the piece's name.
51
- const roleOfPiece = (facts, piece) => (piece ? ((facts.candidates ?? []).find((c) => c.name === piece && c.role)?.role ?? null) : null);
50
+ // The entity of the piece of code a fact belongs to, by the piece's name.
51
+ const entityOfPiece = (facts, piece) => piece ? ((facts.candidates ?? []).find((c) => c.name === piece && c.entity)?.entity ?? null) : null;
52
52
  // Is a module path a FILE of this repo?
53
53
  const isRepoModule = (facts, module) => Boolean(module) && (facts.repoFiles ?? []).includes(module ?? "");
54
54
  // The line a candidate starts on.
55
55
  const lineOf = (c) => c.lines?.[0] ?? 1;
56
56
  // The shape EVERY edge has: the target, the piece it belongs to and whether the
57
57
  // target is a library, plus the structured `fact` and its sentence.
58
- const edgeOf = (facts, edge) => ({ ...edge, role: roleOfPiece(facts, edge.piece) });
58
+ const edgeOf = (facts, edge) => ({ ...edge, entity: entityOfPiece(facts, edge.piece) });
59
59
  const callsOf = (facts) => (facts.candidates ?? []).flatMap((c) => (c.calls ?? [])
60
60
  .filter((call) => call.module && !call.receiverOnly)
61
61
  .map((call) => ({
@@ -84,16 +84,22 @@ const writeWhat = ({ target, module, method, onThis, mutate }) => {
84
84
  const writePath = (facts, a, mutate) => {
85
85
  if (!mutate)
86
86
  return facts.location.path;
87
- return a.onThis ? facts.location.path : a.module ?? null;
87
+ return a.onThis ? facts.location.path : (a.module ?? null);
88
88
  };
89
- const writeExternal = (facts, a, mutate) => (mutate && !a.onThis ? !isRepoModule(facts, a.module) : false);
89
+ const writeExternal = (facts, a, mutate) => mutate && !a.onThis ? !isRepoModule(facts, a.module) : false;
90
90
  const assignmentEdge = (facts, c, a, mutate) => edgeOf(facts, {
91
91
  path: writePath(facts, a, mutate),
92
92
  line: a.line ?? lineOf(c),
93
93
  piece: c.name ?? null,
94
94
  external: writeExternal(facts, a, mutate),
95
95
  // THE FACT — what the code did, as data.
96
- fact: { kind: mutate ? RELATION.MUTATE : RELATION.ASSIGN, target: a.target ?? null, module: a.module ?? null, method: a.method ?? null, onThis: Boolean(a.onThis) },
96
+ fact: {
97
+ kind: mutate ? RELATION.MUTATE : RELATION.ASSIGN,
98
+ target: a.target ?? null,
99
+ module: a.module ?? null,
100
+ method: a.method ?? null,
101
+ onThis: Boolean(a.onThis),
102
+ },
97
103
  what: writeWhat({ target: a.target, module: a.module, method: a.method, onThis: Boolean(a.onThis), mutate }),
98
104
  });
99
105
  const assignmentsOf = (facts, { mutate }) => (facts.candidates ?? []).flatMap((c) => (c.assignments ?? [])
@@ -123,10 +129,55 @@ const exportPiece = (facts, exp, names) => {
123
129
  return null;
124
130
  return (facts.candidates ?? []).some((c) => c.name === names[0]) ? names[0] : null;
125
131
  };
126
- const exportFromEdges = (facts) => (facts.exports ?? []).map((exp) => {
132
+ // The file each re-exported name is declared in (a barrel re-exported by a
133
+ // facade hides the same declaring file as the import it stands for).
134
+ const exportGroups = (exp, names) => {
135
+ const groups = new Map();
136
+ if (!exp.from)
137
+ return groups;
138
+ names.forEach((name, at) => {
139
+ const file = exp.declaring?.[at] ?? null;
140
+ if (!file || file === exp.from)
141
+ return;
142
+ const group = groups.get(file) ?? [];
143
+ group.push(name);
144
+ groups.set(file, group);
145
+ });
146
+ return groups;
147
+ };
148
+ const exportFromEdges = (facts) => (facts.exports ?? []).flatMap((exp) => {
127
149
  const names = exp.named ?? [];
128
- const fact = { kind: "export", form: exp.form ?? "named", names, name: exp.name ?? null, source: exp.source ?? null, resolved: exp.from ?? null, reExport: Boolean(exp.from) };
129
- return edgeOf(facts, { path: exp.from ?? facts.location.path, line: exp.line ?? 1, piece: exportPiece(facts, exp, names), external: exp.from ? !isRepoModule(facts, exp.from) : false, fact, what: exportWhat(exp, names) });
150
+ const groups = exportGroups(exp, names);
151
+ const stayed = names.filter((_, at) => {
152
+ const file = exp.declaring?.[at] ?? null;
153
+ return !file || file === exp.from;
154
+ });
155
+ const fact = (resolved) => ({
156
+ kind: "export",
157
+ form: exp.form ?? "named",
158
+ names: stayed,
159
+ name: exp.name ?? null,
160
+ source: exp.source ?? null,
161
+ resolved,
162
+ reExport: Boolean(exp.from),
163
+ });
164
+ const moduleEdge = edgeOf(facts, {
165
+ path: exp.from ?? facts.location.path,
166
+ line: exp.line ?? 1,
167
+ piece: exportPiece(facts, exp, names),
168
+ external: exp.from ? !isRepoModule(facts, exp.from) : false,
169
+ fact: fact(exp.from ?? null),
170
+ what: exportWhat(exp, exp.from && groups.size ? stayed : names),
171
+ });
172
+ const declaredEdges = [...groups].map(([file, grouped]) => edgeOf(facts, {
173
+ path: file,
174
+ line: exp.line ?? 1,
175
+ piece: null,
176
+ external: !isRepoModule(facts, file),
177
+ fact: { ...fact(file), names: grouped, resolved: file },
178
+ what: `re-exports \`${grouped.join("`, `")}\` of \`${file}\``,
179
+ }));
180
+ return [...(groups.size && !stayed.length ? [] : [moduleEdge]), ...declaredEdges];
130
181
  });
131
182
  const declaredExportEdges = (facts) => (facts.candidates ?? [])
132
183
  .filter((c) => c.exported)
@@ -135,7 +186,14 @@ const declaredExportEdges = (facts) => (facts.candidates ?? [])
135
186
  line: lineOf(c),
136
187
  piece: c.name ?? null,
137
188
  external: false,
138
- fact: { kind: "export", form: "declared", names: c.name ? [c.name] : [], name: c.name ?? null, source: null, reExport: false },
189
+ fact: {
190
+ kind: "export",
191
+ form: "declared",
192
+ names: c.name ? [c.name] : [],
193
+ name: c.name ?? null,
194
+ source: null,
195
+ reExport: false,
196
+ },
139
197
  what: "is exported",
140
198
  }));
141
199
  // A declaration that only RENAMES another module's value (`const a = b.c`).
@@ -156,29 +214,72 @@ const declareEdge = (facts, c) => {
156
214
  what: renames ? `re-declares \`${renames.action}\` of \`${renames.module}\`` : "is declared here",
157
215
  });
158
216
  };
217
+ // A named import asks the module to PASS A NAME ON; the law names the file that
218
+ // declares it. Grouping the names by declaring file keeps one edge per target,
219
+ // and a name the chain could not follow stays on the module file.
220
+ const declaredGroups = (imp) => {
221
+ const groups = new Map();
222
+ const module = imp.resolved ?? "";
223
+ (imp.named ?? []).forEach((name, at) => {
224
+ const file = imp.declaring?.[at] ?? null;
225
+ if (!file || file === module)
226
+ return;
227
+ const names = groups.get(file) ?? [];
228
+ names.push(imp.imported?.[at] ?? name);
229
+ groups.set(file, names);
230
+ });
231
+ return groups;
232
+ };
233
+ // The imported TEXT of one target: the module form is unchanged, a declaring
234
+ // file is named with the symbols the file asked it for.
235
+ const importWhat = (imp, file, names) => {
236
+ if (!names?.length || !file)
237
+ return imp.form === "statement" ? `imports \`${imp.resolved}\`` : `requires \`${imp.source}\``;
238
+ return `imports \`${names.join("`, `")}\` of \`${file}\``;
239
+ };
240
+ // Everything a named import touches: the module it wrote (for the names that
241
+ // stayed) plus the file each group of names is declared in.
242
+ const importEdges = (facts, imp, kind) => {
243
+ const groups = declaredGroups(imp);
244
+ const base = { line: imp.line ?? 1, piece: imp.piece ?? null };
245
+ // The plain edge keeps the fact it always had: a target and no symbols.
246
+ const factOf = (file, names) => {
247
+ const base = kind === RELATION.IMPORT
248
+ ? { kind, form: imp.form ?? null, source: imp.source ?? null, resolved: file }
249
+ : { kind, source: imp.source ?? null, resolved: file };
250
+ return names?.length ? { ...base, names } : base;
251
+ };
252
+ const edges = [];
253
+ const stayed = (imp.named ?? []).filter((_, at) => !groups.size || !(imp.declaring?.[at] && imp.declaring[at] !== imp.resolved));
254
+ if (stayed.length || !groups.size) {
255
+ edges.push(edgeOf(facts, {
256
+ path: imp.resolved ?? null,
257
+ ...base,
258
+ external: !isRepoModule(facts, imp.resolved),
259
+ fact: factOf(imp.resolved ?? null, groups.size ? stayed : null),
260
+ what: importWhat(imp, null, null),
261
+ }));
262
+ }
263
+ for (const [file, names] of groups) {
264
+ edges.push(edgeOf(facts, {
265
+ path: file,
266
+ ...base,
267
+ external: !isRepoModule(facts, file),
268
+ fact: factOf(file, names),
269
+ what: importWhat(imp, file, names),
270
+ }));
271
+ }
272
+ return edges;
273
+ };
159
274
  const EDGE_FACTS = {
160
275
  // `import … from "x"` — a resolved static import.
161
276
  [RELATION.IMPORT]: (facts) => (facts.imports ?? [])
162
277
  .filter((imp) => imp.resolved && !imp.typeOnly)
163
- .map((imp) => edgeOf(facts, {
164
- path: imp.resolved ?? null,
165
- line: imp.line ?? 1,
166
- piece: imp.piece ?? null,
167
- external: !isRepoModule(facts, imp.resolved),
168
- fact: { kind: "import", form: imp.form ?? null, source: imp.source ?? null, resolved: imp.resolved ?? null },
169
- what: imp.form === "statement" ? `imports \`${imp.resolved}\`` : `requires \`${imp.source}\``,
170
- })),
278
+ .flatMap((imp) => importEdges(facts, imp, RELATION.IMPORT)),
171
279
  // `import type … from "x"` — a TYPE dependency.
172
280
  [RELATION.TYPE_IMPORT]: (facts) => (facts.imports ?? [])
173
281
  .filter((imp) => imp.resolved && imp.typeOnly)
174
- .map((imp) => edgeOf(facts, {
175
- path: imp.resolved ?? null,
176
- line: imp.line ?? 1,
177
- piece: imp.piece ?? null,
178
- external: !isRepoModule(facts, imp.resolved),
179
- fact: { kind: "typeImport", source: imp.source ?? null, resolved: imp.resolved ?? null },
180
- what: `names a type of \`${imp.resolved}\``,
181
- })),
282
+ .flatMap((imp) => importEdges(facts, imp, RELATION.TYPE_IMPORT)),
182
283
  // EVERY way code leaves the module, whatever the spelling.
183
284
  [RELATION.EXPORT]: (facts) => [...exportFromEdges(facts), ...declaredExportEdges(facts)],
184
285
  // EVERY declaration: `const`/`let`/`var`, `function`, `class`, and a
@@ -194,11 +295,11 @@ const EDGE_FACTS = {
194
295
  [RELATION.READ]: readsOf,
195
296
  };
196
297
  exports.EDGE_FACTS = EDGE_FACTS;
197
- // Which roles declare an ACTION for each relation: `Map<factKind, Map<roleSlug,
298
+ // Which entities declare an ACTION for each relation: `Map<factKind, Map<entitySlug,
198
299
  // action>>`.
199
300
  const declaredActions = (arch) => {
200
301
  const byFact = new Map();
201
- for (const [slug, def] of Object.entries(arch.codeRoles ?? {})) {
302
+ for (const [slug, def] of Object.entries(arch.entities ?? {})) {
202
303
  for (const [key, action] of Object.entries(def.actions ?? {})) {
203
304
  const factKind = action.of ?? key;
204
305
  if (!byFact.has(factKind))
@@ -209,7 +310,7 @@ const declaredActions = (arch) => {
209
310
  return byFact;
210
311
  };
211
312
  exports.declaredActions = declaredActions;
212
- // A role may only say `of: <kind>` for a relation the engine can see, and every
313
+ // An entity may only say `of: <kind>` for a relation the engine can see, and every
213
314
  // declared kind must have a producer. Checked at load, so a typo fails loudly.
214
315
  for (const kind of FACT_KINDS) {
215
316
  if (!EDGE_FACTS[kind])
@@ -1,5 +1,5 @@
1
- import type { Arch, RoleHome } from "../architecture";
2
- declare const homesOf: (arch: Arch, role: string) => RoleHome[];
1
+ import type { Arch, EntityHome } from "@md-code/follow-architecture/entities/architecture";
2
+ declare const homesOf: (arch: Arch, entity: string) => EntityHome[];
3
3
  type Destination = {
4
4
  slug: string | null;
5
5
  path: string | null;
@@ -12,17 +12,17 @@ type Place = {
12
12
  folder: boolean;
13
13
  };
14
14
  declare const sharedPrefix: (template: string, rel: string | null) => number;
15
- declare const destinationsIn: (arch: Arch, role: string, rel: string) => Destination[];
16
- declare const destinationOf: (arch: Arch, role: string, rel: string) => Destination | null;
17
- declare const placeFor: (arch: Arch, role: string, rel: string) => Place | null;
18
- declare const roleFitsAt: (arch: Arch, role: string, rel: string | null | undefined) => boolean;
19
- declare const rolesAtPath: (arch: Arch, path: string | null | undefined) => string[];
20
- declare const homeForRole: (arch: Arch, role: string, rel: string) => {
21
- role: string;
15
+ declare const destinationsIn: (arch: Arch, entity: string, rel: string) => Destination[];
16
+ declare const destinationOf: (arch: Arch, entity: string, rel: string) => Destination | null;
17
+ declare const placeFor: (arch: Arch, entity: string, rel: string) => Place | null;
18
+ declare const entityFitsAt: (arch: Arch, entity: string, rel: string | null | undefined) => boolean;
19
+ declare const entitiesAtPath: (arch: Arch, path: string | null | undefined) => string[];
20
+ declare const homeForEntity: (arch: Arch, entity: string, rel: string) => {
21
+ entity: string;
22
22
  path: string;
23
23
  folder: boolean;
24
24
  concrete: boolean;
25
25
  node: string | null;
26
26
  } | null;
27
- export { homesOf, sharedPrefix, destinationsIn, destinationOf, placeFor, roleFitsAt, rolesAtPath, homeForRole };
27
+ export { homesOf, sharedPrefix, destinationsIn, destinationOf, placeFor, entityFitsAt, entitiesAtPath, homeForEntity };
28
28
  export type { Destination, Place };
@@ -1,22 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.homeForRole = exports.rolesAtPath = exports.roleFitsAt = exports.placeFor = exports.destinationOf = exports.destinationsIn = exports.sharedPrefix = exports.homesOf = void 0;
4
- // THE ROLE → PLACE ANSWER. "Where does code of this role live" is the SAME
3
+ exports.homeForEntity = exports.entitiesAtPath = exports.entityFitsAt = exports.placeFor = exports.destinationOf = exports.destinationsIn = exports.sharedPrefix = exports.homesOf = void 0;
4
+ // THE ENTITY → PLACE ANSWER. "Where does code of this entity live" is the SAME
5
5
  // question as "what does this place entry resolve to", so this module owns both
6
6
  // the declared homes and the concrete place-for-this-file answer.
7
7
  //
8
- // homesOf(arch, role) — the path templates that role may occupy
9
- // placeFor(arch, role, rel) — where this role's code belongs FOR THIS FILE
10
- // destinationOf(arch, role, rel) — the concrete, hostable place, or null
8
+ // homesOf(arch, entity) — the path templates that entity may occupy
9
+ // placeFor(arch, entity, rel) — where this entity's code belongs FOR THIS FILE
10
+ // destinationOf(arch, entity, rel) — the concrete, hostable place, or null
11
11
  //
12
- // Nothing here is stored on the codeRole: a role knows what code IS, never which
12
+ // Nothing here is stored on the entity: an entity knows what code IS, never which
13
13
  // folder it is in. Anything that needs a location asks the tree.
14
- const match_1 = require("../tree/match");
14
+ const match_1 = require("@md-code/follow-architecture/entities/tree/match");
15
15
  const where_1 = require("./where");
16
16
  const place_1 = require("./place");
17
- const rank_1 = require("../../utils/rank");
18
- // Every path the tree gives this role, in the order the config declares them.
19
- const homesOf = (arch, role) => arch.nodes.roleHomes[role] ?? [];
17
+ const rank_1 = require("@md-code/follow-architecture/utils/rank");
18
+ // Every path the tree gives this entity, in the order the config declares them.
19
+ const homesOf = (arch, entity) => arch.nodes.entityHomes[entity] ?? [];
20
20
  exports.homesOf = homesOf;
21
21
  // How much of the template's start this file shares. Used only to pick which
22
22
  // branch of a repeating node the file belongs to — never to allow or deny.
@@ -39,7 +39,9 @@ const sharedPrefix = (template, rel) => {
39
39
  exports.sharedPrefix = sharedPrefix;
40
40
  // The directory a home names: a file child contributes its parent folder.
41
41
  const homeDir = (template) => {
42
- const segs = String(template).split("/").filter((s) => s !== "**");
42
+ const segs = String(template)
43
+ .split("/")
44
+ .filter((s) => s !== "**");
43
45
  return /\.[A-Za-z0-9]+$/.test(segs[segs.length - 1] ?? "") ? segs.slice(0, -1) : segs;
44
46
  };
45
47
  // The folder OF A FILE as segments.
@@ -55,28 +57,43 @@ const sameBranch = (home, dir) => {
55
57
  // Whether this home is in the file's branch. A home that names ONE FILE only
56
58
  // answers for files of exactly that folder; a FOLDER home may sit in a general
57
59
  // branch (`packages/utils`) that still applies.
58
- const branchFor = (fileHome, home, dir) => (fileHome ? home.length === dir.length && sameBranch(home, dir) : sameBranch(home, dir));
60
+ const branchFor = (fileHome, home, dir) => fileHome ? home.length === dir.length && sameBranch(home, dir) : sameBranch(home, dir);
59
61
  const scoreEntry = (entry, i, dir, rel) => {
60
62
  const home = homeDir(entry.template);
61
- const last = String(entry.template).split("/").filter((seg) => seg !== "**").pop() ?? "";
63
+ const last = String(entry.template)
64
+ .split("/")
65
+ .filter((seg) => seg !== "**")
66
+ .pop() ?? "";
62
67
  const fileHome = /\.[A-Za-z0-9]+$/.test(last);
63
68
  const branch = branchFor(fileHome, home, dir);
64
69
  return { entry, i, keep: branch || !fileHome, branch, score: sharedPrefix(entry.template, rel) };
65
70
  };
66
- // The concrete places a role's code may go FOR THIS FILE, best first. The
71
+ // The concrete places an entity's code may go FOR THIS FILE, best first. The
67
72
  // score-keep-rank walk is the shared `rankedOffers` core — the same one the
68
73
  // folder lookalikes use; the scoring policy (branch, prefix, declared order)
69
74
  // is this module's own.
70
- const destinationsIn = (arch, role, rel) => {
71
- const entries = homesOf(arch, role);
75
+ const destinationsIn = (arch, entity, rel) => {
76
+ const entries = homesOf(arch, entity);
72
77
  if (!entries.length)
73
78
  return [];
74
- // A role with ONE declared place has no branch question to answer.
79
+ // An entity with ONE declared place has no branch question to answer.
75
80
  if (entries.length === 1 && !/\*\*\s*$/.test(entries[0].template)) {
76
- return [{ slug: entries[0].node, path: (0, where_1.fillTemplate)(entries[0].template, rel), folder: false, template: entries[0].template }];
81
+ return [
82
+ {
83
+ slug: entries[0].node,
84
+ path: (0, where_1.fillTemplate)(entries[0].template, rel),
85
+ folder: false,
86
+ template: entries[0].template,
87
+ },
88
+ ];
77
89
  }
78
90
  const dir = fileDir(rel);
79
- const destinationOfEntry = (entry) => ({ slug: entry.node, path: (0, where_1.fillTemplate)(entry.template, rel), folder: /\*\*\s*$/.test(entry.template), template: entry.template });
91
+ const destinationOfEntry = (entry) => ({
92
+ slug: entry.node,
93
+ path: (0, where_1.fillTemplate)(entry.template, rel),
94
+ folder: /\*\*\s*$/.test(entry.template),
95
+ template: entry.template,
96
+ });
80
97
  const kept = (0, rank_1.rankedOffers)(entries.map((entry, i) => ({ entry, i })), ({ entry, i }) => {
81
98
  const scored = scoreEntry(entry, i, dir, rel);
82
99
  return scored.keep ? { ...destinationOfEntry(entry), branch: scored.branch, score: scored.score, i } : null;
@@ -84,7 +101,7 @@ const destinationsIn = (arch, role, rel) => {
84
101
  return kept.map(({ slug, path, folder, template }) => ({ slug, path, folder, template }));
85
102
  };
86
103
  exports.destinationsIn = destinationsIn;
87
- // The place a role's code belongs FOR THIS FILE, and only when that place can
104
+ // The place an entity's code belongs FOR THIS FILE, and only when that place can
88
105
  // exist: the FOLDER has to be a real node instance, while a home that names a
89
106
  // FILE may still be created — its parent being an instance is enough.
90
107
  // Does the node that owns the folder own it for THIS destination (the node
@@ -93,13 +110,13 @@ const ownsDest = (arch, hit, dest) => {
93
110
  const parent = arch.nodes.bySlug[dest.slug ?? ""]?.parents[0] ?? null;
94
111
  return hit.slug === dest.slug || (parent != null && hit.slug === parent);
95
112
  };
96
- const hostFolder = (dest) => (dest.folder ? dest.path ?? "" : (0, place_1.dirOf)(dest.path ?? ""));
113
+ const hostFolder = (dest) => (dest.folder ? (dest.path ?? "") : (0, place_1.dirOf)(dest.path ?? ""));
97
114
  const nodeOk = (arch, dest) => {
98
115
  const destNode = arch.nodes.bySlug[dest.slug ?? ""];
99
116
  return !destNode || (0, match_1.ancestorsAreReal)(destNode, dest.path ?? "", arch);
100
117
  };
101
- const destinationOf = (arch, role, rel) => {
102
- for (const dest of destinationsIn(arch, role, rel)) {
118
+ const destinationOf = (arch, entity, rel) => {
119
+ for (const dest of destinationsIn(arch, entity, rel)) {
103
120
  if (!dest?.slug || !dest.path)
104
121
  continue;
105
122
  if (!nodeOk(arch, dest))
@@ -114,19 +131,22 @@ const destinationOf = (arch, role, rel) => {
114
131
  return null;
115
132
  };
116
133
  exports.destinationOf = destinationOf;
117
- // WHERE a role's code belongs FOR THIS FILE — the ONE answer every caller uses.
118
- const placeFor = (arch, role, rel) => {
119
- const dest = destinationOf(arch, role, rel);
134
+ // WHERE an entity's code belongs FOR THIS FILE — the ONE answer every caller uses.
135
+ const placeFor = (arch, entity, rel) => {
136
+ const dest = destinationOf(arch, entity, rel);
120
137
  if (dest?.path)
121
138
  return { path: dest.path, concrete: true, folder: Boolean(dest.folder) };
122
- const homes = homesOf(arch, role).map((h) => h.template);
123
- // A role with SEVERAL homes and none of them hostable here has no answer for
139
+ const homes = homesOf(arch, entity).map((h) => h.template);
140
+ // An entity with SEVERAL homes and none of them hostable here has no answer for
124
141
  // this file: picking one would be a guess dressed as advice.
125
142
  if (homes.length !== 1) {
126
- const nearest = destinationsIn(arch, role, rel)[0];
143
+ const nearest = destinationsIn(arch, entity, rel)[0];
127
144
  if (!nearest?.template)
128
145
  return null;
129
- const last = nearest.template.split("/").filter((seg) => seg !== "**").pop() ?? "";
146
+ const last = nearest.template
147
+ .split("/")
148
+ .filter((seg) => seg !== "**")
149
+ .pop() ?? "";
130
150
  const folder = /\*\*\s*$/.test(nearest.template) || !/\.[A-Za-z0-9]+$/.test(last);
131
151
  return { path: nearest.template.replace(/\/\*\*$/, ""), concrete: false, folder };
132
152
  }
@@ -136,34 +156,40 @@ const placeFor = (arch, role, rel) => {
136
156
  return { path: only.replace(/\/\*\*$/, ""), concrete: false, folder: true };
137
157
  };
138
158
  exports.placeFor = placeFor;
139
- // Does this file sit inside one of the role's homes, asked THROUGH the tree?
140
- const roleFitsAt = (arch, role, rel) => {
159
+ // Does this file sit inside one of the entity's homes, asked THROUGH the tree?
160
+ const entityFitsAt = (arch, entity, rel) => {
141
161
  if (!rel)
142
162
  return false;
143
- return (arch.nodes.roleHomes[role] ?? []).some((h) => (0, where_1.matchesWhere)({ type: "template", template: h.template }, rel, arch, null, null));
163
+ return (arch.nodes.entityHomes[entity] ?? []).some((h) => (0, where_1.matchesWhere)({ type: "template", template: h.template }, rel, arch, null, null));
144
164
  };
145
- exports.roleFitsAt = roleFitsAt;
146
- // The roles whose declared home covers this path — MOST SPECIFIC FIRST.
147
- const rolesAtPath = (arch, path) => {
165
+ exports.entityFitsAt = entityFitsAt;
166
+ // The entities whose declared home covers this path — MOST SPECIFIC FIRST.
167
+ const entitiesAtPath = (arch, path) => {
148
168
  if (!path)
149
169
  return [];
150
- return Object.keys(arch.nodes.roleHomes)
151
- .filter((role) => roleFitsAt(arch, role, path))
152
- .map((role, i) => ({
153
- role,
170
+ return Object.keys(arch.nodes.entityHomes)
171
+ .filter((entity) => entityFitsAt(arch, entity, path))
172
+ .map((entity, i) => ({
173
+ entity,
154
174
  i,
155
- depth: Math.max(0, ...homesOf(arch, role).map((h) => sharedPrefix(h.template, path))),
175
+ depth: Math.max(0, ...homesOf(arch, entity).map((h) => sharedPrefix(h.template, path))),
156
176
  }))
157
177
  .sort((a, b) => b.depth - a.depth || a.i - b.i)
158
- .map((x) => x.role);
178
+ .map((x) => x.entity);
159
179
  };
160
- exports.rolesAtPath = rolesAtPath;
161
- // Where a role's code belongs FOR THIS FILE, as the BOX and the PATH together.
162
- const homeForRole = (arch, role, rel) => {
163
- const place = placeFor(arch, role, rel);
180
+ exports.entitiesAtPath = entitiesAtPath;
181
+ // Where an entity's code belongs FOR THIS FILE, as the BOX and the PATH together.
182
+ const homeForEntity = (arch, entity, rel) => {
183
+ const place = placeFor(arch, entity, rel);
164
184
  if (!place?.path)
165
185
  return null;
166
186
  const folder = place.folder ? place.path : (0, place_1.dirOf)(place.path);
167
- return { role, path: place.path, folder: place.folder, concrete: Boolean(place.concrete), node: (0, match_1.folderOwner)(arch, folder)?.slug ?? null };
187
+ return {
188
+ entity,
189
+ path: place.path,
190
+ folder: place.folder,
191
+ concrete: Boolean(place.concrete),
192
+ node: (0, match_1.folderOwner)(arch, folder)?.slug ?? null,
193
+ };
168
194
  };
169
- exports.homeForRole = homeForRole;
195
+ exports.homeForEntity = homeForEntity;
@@ -1,4 +1,4 @@
1
- import type { Leaf, Place } from "../facts";
1
+ import type { Leaf, Place } from "@md-code/follow-architecture/entities/facts";
2
2
  declare const wordsIn: (name: string | null | undefined) => string[];
3
3
  declare const nameOnly: (name: string | null | undefined) => string;
4
4
  declare const segmentsOf: (rel: string | null | undefined) => string[];
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.dirOf = exports.placeholdersOf = exports.placeOf = exports.leafOf = exports.parentOf = exports.segmentsOf = exports.nameOnly = exports.wordsIn = void 0;
4
- const split_1 = require("../../utils/split");
4
+ const split_1 = require("@md-code/follow-architecture/utils/split");
5
5
  const wordsIn = (name) => String(name ?? "")
6
6
  // camelCase and ALLCAPS runs: `fileName` → file name, `HTMLParser` → HTML Parser
7
7
  .replace(/([a-z0-9])([A-Z])/g, "$1 $2")
@@ -32,7 +32,13 @@ const leafOf = (rel) => {
32
32
  const name = segments[segments.length - 1] ?? "";
33
33
  const fileName = nameOnly(name);
34
34
  // `x.spec.ts` → [".spec", ".ts"]; `.env` is a name, not an extension.
35
- const exts = fileName === name ? [] : name.slice(fileName.length).split(".").filter(Boolean).map((e) => `.${e}`);
35
+ const exts = fileName === name
36
+ ? []
37
+ : name
38
+ .slice(fileName.length)
39
+ .split(".")
40
+ .filter(Boolean)
41
+ .map((e) => `.${e}`);
36
42
  return { path, segments, exts, fileName, words: wordsIn(fileName) };
37
43
  };
38
44
  exports.leafOf = leafOf;
@@ -46,7 +52,8 @@ const placeOf = (rel, repoFiles = []) => {
46
52
  exports.placeOf = placeOf;
47
53
  // The placeholders a template still has (`{kebab-case}`), for a sentence that
48
54
  // tells the reader what to fill in.
49
- const placeholdersOf = (template) => [...new Set(String(template ?? "").match(/\{[^}]+\}/g) ?? [])].map((p) => `\`${p}\``).join(", ") || "its placeholders";
55
+ const placeholdersOf = (template) => [...new Set(String(template ?? "").match(/\{[^}]+\}/g) ?? [])].map((p) => `\`${p}\``).join(", ") ||
56
+ "its placeholders";
50
57
  exports.placeholdersOf = placeholdersOf;
51
58
  // The folder of a path: a file contributes its parent, a folder is itself.
52
59
  const dirOf = (path) => {
@@ -1,17 +1,19 @@
1
- import { toList, type FieldValue } from "../../utils/field";
2
- import type { Arch, WhereEntry } from "../architecture";
3
- import type { FileFacts } from "../facts";
1
+ import { type Aliases } from "@md-code/follow-architecture/utils/aliases";
2
+ import { toList, type FieldValue } from "@md-code/follow-architecture/utils/field";
3
+ import type { Arch, WhereEntry } from "@md-code/follow-architecture/entities/architecture";
4
+ import type { FileFacts } from "@md-code/follow-architecture/entities/facts";
4
5
  type Caps = Record<string, string | undefined>;
5
- declare const parseWhereEntry: (entry: FieldValue, roles?: Set<string> | null) => WhereEntry;
6
- declare const parseWhere: (value: FieldValue | null | undefined, roles?: Set<string> | null) => WhereEntry[];
6
+ declare const parseWhereEntry: (entry: FieldValue, entities?: Set<string> | null, aliases?: Aliases | null) => WhereEntry;
7
+ declare const parseWhere: (value: FieldValue | null | undefined, entities?: Set<string> | null, aliases?: Aliases | null) => WhereEntry[];
7
8
  declare const matchesWhere: (entry: WhereEntry, rel: string, arch: Arch, facts: FileFacts, targetCaps?: Caps) => boolean;
8
9
  declare const checkWhere: (entries: WhereEntry[], rel: string, arch: Arch, facts: FileFacts, targetCaps?: Caps) => boolean;
9
10
  declare const accessorLabel: (e: {
10
11
  scope?: string | null;
11
12
  segments?: string[] | null;
13
+ type?: string | null;
12
14
  } | null | undefined) => string;
13
15
  declare const labelOf: (entry: WhereEntry | null | undefined) => string;
14
16
  declare const fillTemplate: (template: string | null | undefined, rel?: string | null, caps?: Caps | null) => string | null;
15
17
  declare const entryKey: (entry: WhereEntry, rel: string, arch: Arch, facts: FileFacts | null | undefined) => string | null;
16
- export { toList, parseWhereEntry, parseWhere, matchesWhere, checkWhere, accessorLabel, labelOf, fillTemplate, entryKey };
18
+ export { toList, parseWhereEntry, parseWhere, matchesWhere, checkWhere, accessorLabel, labelOf, fillTemplate, entryKey, };
17
19
  export type { Caps };