@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
package/dist/main.js CHANGED
@@ -15,26 +15,39 @@ 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
- exports.buildArchitecture = exports.loadArchitecture = exports.main = void 0;
36
+ exports.repoOf = exports.canonicalRoot = exports.buildArchitecture = exports.loadArchitecture = exports.main = void 0;
27
37
  const fs = __importStar(require("node:fs"));
28
38
  const path = __importStar(require("node:path"));
29
39
  const remeda_1 = require("remeda");
30
40
  const tree_1 = require("./entities/tree");
31
- const roles_1 = require("./code-roles/roles");
32
- const normalize_1 = require("./invariants/normalize");
41
+ const entities_1 = require("./code-entities/entities");
42
+ const normalize_1 = require("./rules/normalize");
33
43
  const aliases_1 = require("./aliases");
34
44
  const pipeline_1 = require("./pipeline");
45
+ const index_run_1 = require("./index-run");
46
+ const usage_prepare_1 = require("./usage-prepare");
47
+ const fa_store_1 = require("./fa-store");
35
48
  const pattern_1 = require("./utils/pattern");
36
49
  const cli_report_1 = require("./report/cli-report");
37
- const config_1 = require("./config");
50
+ const scan_run_1 = require("./scan-run");
38
51
  const notices_1 = require("./report/notices");
39
52
  const user_report_1 = require("./report/user-report");
40
53
  const imports_1 = require("./utils/imports");
@@ -42,6 +55,7 @@ const files_1 = require("./utils/files");
42
55
  const args_1 = require("./args");
43
56
  const keyed_1 = require("./utils/keyed");
44
57
  const field_1 = require("./utils/field");
58
+ const schema_1 = require("./entities/schema");
45
59
  const configError = __importStar(require("./report/configErrors"));
46
60
  const yaml = __importStar(require("js-yaml"));
47
61
  // The report layer owns its payload; the input contract is the ONE entity
@@ -51,32 +65,86 @@ const writeOverview = user_report_1.writeOverview;
51
65
  // The nodes section as a list — the shared list-or-map walk, the same one the
52
66
  // tree builder reads.
53
67
  const nodesOf = (raw) => (0, keyed_1.keyedDefs)(raw.nodes).filter((n) => n != null);
54
- // Every invariant id must be unique, and every role a node names must exist —
55
- // a typo would otherwise give a home to a role nothing ever infers.
68
+ // Every rule id must be unique, and every entity a node names must exist —
69
+ // a typo would otherwise give a home to an entity nothing ever infers.
56
70
  const checkBuilt = (arch) => {
57
- const ids = arch.invariants.map((i) => i.id);
71
+ const ids = arch.rules.map((i) => i.id);
58
72
  if (new Set(ids).size !== ids.length)
59
- throw configError.duplicateInvariantIds(ids);
60
- const known = new Set(Object.keys(arch.codeRoles));
61
- for (const role of Object.keys(arch.nodes.roleHomes)) {
62
- if (!known.has(role))
63
- throw configError.nodeRoleUnknown(role);
73
+ throw configError.duplicateRuleIds(ids);
74
+ const known = new Set(Object.keys(arch.entities));
75
+ for (const entity of Object.keys(arch.nodes.entityHomes)) {
76
+ if (!known.has(entity))
77
+ throw configError.nodeEntityUnknown(entity);
64
78
  }
65
79
  };
80
+ // The tool's own option keys travel in the same bag as the architecture
81
+ // sections (the ESLint rule hands both). They are not sections, and are not
82
+ // shown in the section dictionary.
83
+ const TOOL_KEYS = new Set([
84
+ "config",
85
+ "configs",
86
+ "include",
87
+ "exts",
88
+ "similarity",
89
+ "barrelDepth",
90
+ "ignoreDirs",
91
+ "ignores",
92
+ "exportPath",
93
+ "file",
94
+ "report",
95
+ ]);
96
+ // Old vocabulary is rejected BY NAME — the reader is shown the sections and
97
+ // their meanings, never a guess at what an old key used to mean. `role` on a
98
+ // node or in a `where` entry, `codeRole` as a filter key, and `$codeRole` as a
99
+ // reference are all caught here, before any normalizer can silently ignore them.
100
+ const walkVocabulary = (value) => {
101
+ if (typeof value === "string") {
102
+ if (value.includes("$codeRole"))
103
+ throw configError.legacyReference({ ref: "$codeRole" });
104
+ return;
105
+ }
106
+ if (Array.isArray(value)) {
107
+ for (const item of value)
108
+ walkVocabulary(item);
109
+ return;
110
+ }
111
+ if (!(0, field_1.isObj)(value))
112
+ return;
113
+ for (const [key, item] of Object.entries(value)) {
114
+ if (key === "role")
115
+ throw configError.legacyRoleKey();
116
+ if (key === "codeRole")
117
+ throw configError.legacyFilterKey();
118
+ walkVocabulary(item);
119
+ }
120
+ };
121
+ const assertCurrentVocabulary = (raw) => {
122
+ for (const key of Object.keys(raw)) {
123
+ if (schema_1.SCHEMA.top.includes(key) || TOOL_KEYS.has(key))
124
+ continue;
125
+ throw configError.unknownTopKey({ key });
126
+ }
127
+ walkVocabulary(raw);
128
+ };
66
129
  const buildArchitecture = (raw) => {
67
130
  if (!(0, field_1.isObj)(raw))
68
131
  throw configError.notAnObject();
69
132
  const config = raw;
133
+ assertCurrentVocabulary(config);
70
134
  if (!nodesOf(config).length)
71
135
  throw configError.withoutNodes();
72
- const codeRoles = config.codeRoles ? (0, roles_1.normalizeCodeRoles)(config.codeRoles) : {};
73
- const tree = (0, tree_1.buildTree)(config.nodes);
74
- const invariants = (0, remeda_1.pipe)(config.invariants ?? [], (0, remeda_1.map)((i) => (0, normalize_1.normalizeInvariant)(i, new Set(Object.keys(codeRoles)))));
136
+ // The alias map is read ONCE, before anything that can name a place: node
137
+ // names, rule globs, `location` filters and the import resolver all ask the
138
+ // same `utils/aliases` reader, so a specifier means the same everywhere.
139
+ const aliases = (0, aliases_1.normalizeAliases)(config.aliases ?? {});
140
+ const entities = config.entities ? (0, entities_1.normalizeEntities)(config.entities, aliases) : {};
141
+ const tree = (0, tree_1.buildTree)(config.nodes, aliases);
142
+ const rules = (0, remeda_1.pipe)(config.rules ?? [], (0, remeda_1.map)((i) => (0, normalize_1.normalizeRule)(i, new Set(Object.keys(entities)), aliases)));
75
143
  const arch = {
76
144
  nodes: tree,
77
- codeRoles,
78
- invariants,
79
- aliases: (0, aliases_1.normalizeAliases)(config.aliases ?? {}),
145
+ entities,
146
+ rules,
147
+ aliases,
80
148
  // The config as written, for consumers that show it back (the overview).
81
149
  raw: config,
82
150
  };
@@ -148,18 +216,88 @@ const loadArchitecture = (config) => {
148
216
  return naming(file, () => buildArchitecture(parseArchitecture(readConfigText(file), file)));
149
217
  };
150
218
  exports.loadArchitecture = loadArchitecture;
219
+ // `--barrel-depth <n>`: a positive integer, or the reader is told why not.
220
+ const barrelDepthArg = (raw) => {
221
+ const depth = Number(raw);
222
+ if (!Number.isInteger(depth) || depth < 1)
223
+ throw configError.limitNotPositiveInteger({ key: "--barrel-depth", value: raw });
224
+ return depth;
225
+ };
226
+ // One `--files` entry: a FILE, or a FOLDER with the scanned files it holds.
227
+ // A folder used to match nothing — the entry was dropped for not being a file and
228
+ // the report came back empty. `scanned` is the universe, so a folder can never
229
+ // pull in a file the scan does not read.
230
+ const filesOfEntry = (repoRoot, scanned, entry) => {
231
+ const abs = path.resolve(repoRoot, entry);
232
+ if (!fs.existsSync(abs))
233
+ return [];
234
+ if (fs.statSync(abs).isFile())
235
+ return [abs];
236
+ const prefix = abs.endsWith(path.sep) ? abs : `${abs}${path.sep}`;
237
+ return scanned.filter((file) => file.startsWith(prefix));
238
+ };
151
239
  // The files a run checks: `--files` restricts the scan to the given files
152
240
  // (agent stop-hooks lint only changed files); otherwise every scanned file.
153
241
  const collectedFiles = (repoRoot, scanned, files) => {
154
242
  if (files.length) {
155
- return (0, remeda_1.pipe)(files, (0, remeda_1.map)((rel) => path.resolve(repoRoot, rel)), (0, remeda_1.filter)((abs) => fs.existsSync(abs) && fs.statSync(abs).isFile()), (0, remeda_1.map)((abs) => ({ abs, rel: (0, imports_1.toRel)(repoRoot, abs) })));
243
+ return (0, remeda_1.pipe)(files, (0, remeda_1.flatMap)((entry) => filesOfEntry(repoRoot, scanned, entry)), (0, remeda_1.map)((abs) => ({ abs, rel: (0, imports_1.toRel)(repoRoot, abs) })));
156
244
  }
157
245
  return (0, remeda_1.pipe)(scanned, (0, remeda_1.map)((abs) => ({ abs, rel: (0, imports_1.toRel)(repoRoot, abs) })));
158
246
  };
159
- // The run's findings: every checked file, one shared dedupe store.
247
+ // The run's findings: every checked file, one shared dedupe store. The files are
248
+ // checked against the ONE project over the scan — `references` asks across files,
249
+ // so a per-file project would answer "nobody uses this" for a name the rest of
250
+ // the repo calls.
251
+ // What the index did, for `FA_INDEX_VERBOSE`; a failed write is always reported,
252
+ // because the run then keeps its findings but forgets them.
253
+ const reportIndex = (stats, file) => {
254
+ if (process.env.FA_INDEX_VERBOSE) {
255
+ console.error(`fa index: ${stats.mode} stale=${stats.stale} zone=${stats.zone} extracted=${stats.extracted} written=${stats.written} chunks=${stats.chunks} compacted=${stats.compactions} pruned=${stats.pruned} bytes=${stats.bytes}`);
256
+ }
257
+ if (stats.warning !== null)
258
+ console.error(`follow-architecture: ${stats.warning}`);
259
+ // Not a failure: the records are in the file and the file keeps its size. Said
260
+ // once per run, in the index's words, only when there is a file to name.
261
+ if (stats.compactionWarning !== null && file !== undefined)
262
+ console.error(`follow-architecture: ${(0, fa_store_1.compactionLine)(file, stats.compactionWarning)}`);
263
+ };
264
+ // The files `--files` named that the scan never saw: those are checked the plain
265
+ // way, because nothing about them is in the index.
266
+ const outsideOf = (files, shouldCheck, inside) => (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => shouldCheck(f.rel) && !inside.has(f.abs)));
160
267
  const runFindings = (files, run) => {
161
268
  const dedupe = new Map();
162
- const findings = (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => run.shouldCheck(f.rel)), (0, remeda_1.flatMap)((f) => (0, pipeline_1.checkFile)(f.abs, run.arch, run.project, run.repoFiles, dedupe)));
269
+ // The scan's own answers first: with an index the run reads what it already
270
+ // knows and only looks at what changed. Null means this run has no usable
271
+ // index, and the plain path below reads every file.
272
+ // `--files` narrows what is REPORTED, not what the repo answers: the index still
273
+ // covers every scanned file, so a dependency outside the list is still known.
274
+ const reported = new Set((0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => run.shouldCheck(f.rel)), (0, remeda_1.map)((f) => f.rel)));
275
+ const indexed = (0, index_run_1.runIndexed)({
276
+ arch: run.arch,
277
+ repoFiles: run.repoFiles,
278
+ absFiles: run.scanned,
279
+ scope: run.scope,
280
+ option: run.index,
281
+ usage: run.usage,
282
+ dedupe,
283
+ shouldCheck: (abs) => reported.has((0, imports_1.toRel)(run.arch.repoRoot ?? ".", abs)),
284
+ });
285
+ if (indexed !== null)
286
+ reportIndex(indexed.stats, run.index);
287
+ // Who answers `references`, and — for the plain path below, which reads every
288
+ // file — the name counts that answer it without a project.
289
+ (0, usage_prepare_1.prepareUsage)(run.usage, run.arch.repoRoot ?? ".", run.repoFiles);
290
+ const project = (0, scan_run_1.wholeRepoProject)();
291
+ // `--files` may name a file outside the scan scope: that one is checked the
292
+ // plain way, exactly as before.
293
+ const inside = new Set(run.scanned);
294
+ const outside = indexed === null ? [] : outsideOf(files, run.shouldCheck, inside);
295
+ const findings = indexed !== null
296
+ ? [
297
+ ...indexed.findings,
298
+ ...(0, remeda_1.pipe)(outside, (0, remeda_1.flatMap)((f) => (0, pipeline_1.checkFile)(f.abs, run.arch, project, run.repoFiles, dedupe))),
299
+ ]
300
+ : (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => run.shouldCheck(f.rel)), (0, remeda_1.flatMap)((f) => (0, pipeline_1.checkFile)(f.abs, run.arch, project, run.repoFiles, dedupe)));
163
301
  const orphans = (0, remeda_1.pipe)(files, (0, remeda_1.filter)((f) => !run.shouldCheck(f.rel)), (0, remeda_1.map)((f) => f.rel), (r) => [...r].sort());
164
302
  return { findings, orphans };
165
303
  };
@@ -193,37 +331,81 @@ const writeTextReport = (args, run) => {
193
331
  }
194
332
  return args.check && run.findings.length > 0 ? 1 : 0;
195
333
  };
334
+ const configOf = (args, cwd) => typeof args.config === "string" ? path.resolve(cwd, args.config) : args.config;
335
+ // ONE DIRECTORY, ONE NAME. The index is keyed by the repo root, and the same
336
+ // directory answers to several names: a symlinked home reaches it as `/home/...`
337
+ // or as `/var/home/...`, and the CLI and the editor's server each pick their own.
338
+ // An index written under one spelling was foreign under the other, so the rule
339
+ // silently re-read the whole repo on its first pull — a `--config` path the shell
340
+ // spelled one way and the server another were two repos. Both entry points
341
+ // canonicalise the root BEFORE it becomes a file path, so the file, the header and
342
+ // every abs path in it agree.
343
+ const canonicalRoot = (dir) => {
344
+ try {
345
+ return fs.realpathSync(dir);
346
+ }
347
+ catch {
348
+ return dir;
349
+ }
350
+ };
351
+ exports.canonicalRoot = canonicalRoot;
352
+ // The repo starts where the architecture file is — the SAME anchor the ESLint
353
+ // rule uses — so `--config ../arch.yaml` scans the repo that file describes.
354
+ // An explicit `--cwd` still decides where the scan begins.
355
+ const repoOf = (args, cwd) => {
356
+ if (typeof args.config !== "string" || args.cwd != null)
357
+ return canonicalRoot(cwd);
358
+ return canonicalRoot(path.dirname(path.resolve(cwd, args.config)));
359
+ };
360
+ exports.repoOf = repoOf;
196
361
  const main = (argv) => {
197
362
  const args = (0, args_1.parseArgs)(argv);
198
363
  if (args.help) {
199
- console.log("usage: follow-architecture [--config <path>] [--ext <.ext>]... [--ignore <glob>]... [--ignore-dir <name>]... [--files <path>]... [--out <path>] [--overview [path]] [--check]");
364
+ console.log("usage: follow-architecture [--config <path>] [--ext <.ext>]... [--ignore <glob>]... [--ignore-dir <name>]... [--files <path>]... [--out <path>] [--overview [path]] [--index <path|off>] [--usage <checker|index>] [--barrel-depth <n>] [--check]");
200
365
  return 0;
201
366
  }
202
367
  const cwd = path.resolve(args.cwd ?? process.cwd());
203
- // The repo starts where the architecture file is — the SAME anchor the ESLint
204
- // rule uses — so `--config ../arch.yaml` scans the repo that file describes.
205
- // An explicit `--cwd` still decides where the scan begins.
206
- const configPath = typeof args.config === "string" ? path.resolve(cwd, args.config) : args.config;
207
- const repoRoot = typeof configPath === "string" && args.cwd == null ? path.dirname(configPath) : cwd;
368
+ const configPath = configOf(args, cwd);
369
+ const repoRoot = repoOf(args, cwd);
208
370
  const arch = loadArchitecture(configPath);
209
371
  arch.repoRoot = repoRoot;
372
+ // How far a name may travel through barrels before the walk stops. A TOOL
373
+ // option (`--barrel-depth`, the rule's `barrelDepth`), never a config section:
374
+ // where a name is judged is the law, not a per-repo budget.
375
+ if (args.barrelDepth !== undefined)
376
+ arch.barrelDepth = barrelDepthArg(args.barrelDepth);
210
377
  const shouldCheck = (0, tree_1.matchers)(arch);
211
378
  // Scan scope is the TOOL's: its defaults, extended by `--ext`, never by the
212
379
  // architecture (which describes code, not how to find it).
213
380
  const exts = [...new Set([...pattern_1.DEFAULT_EXTS, ...(args.ext ?? [])])];
214
381
  const ignoreDirs = [...new Set([...pattern_1.DEFAULT_IGNORE_DIRS, ...(args.ignoreDir ?? [])])];
382
+ // Repo-relative paths the tool does not read at all — the apps, the platform
383
+ // packages and the tooling outside the contract — extended by `--ignore`.
384
+ const ignoreGlobs = [...new Set([...pattern_1.DEFAULT_IGNORE_PATHS, ...(args.ignore ?? [])])];
215
385
  // ONE walk: the scan list, the repo file list and the ts-morph project are the
216
386
  // same set of files. `references` asks who uses a name ACROSS files.
217
- const scanned = (0, files_1.collectFiles)(repoRoot, { exts, ignoreDirs, ignoreGlobs: args.ignore ?? [] });
218
- const project = (0, config_1.openProject)(repoRoot, scanned, arch);
387
+ const scanned = (0, files_1.collectFiles)(repoRoot, { exts, ignoreDirs, ignoreGlobs });
388
+ // The scan's file list decides which project holds what: per-file work reads the
389
+ // shards this run opens, whole-repo questions read the one project over `scanned`.
390
+ (0, scan_run_1.openRun)({ repoRoot, arch, absFiles: scanned });
219
391
  const collected = collectedFiles(repoRoot, scanned, args.files);
220
392
  // `repoFiles` is the FULL repo file list (for import resolution and folder
221
393
  // facts), even when `--files` restricts which files are CHECKED.
222
394
  const repoFiles = (0, remeda_1.pipe)(scanned, (0, remeda_1.map)((abs) => (0, imports_1.toRel)(repoRoot, abs)));
223
- const { findings, orphans } = runFindings(collected, { arch, project, repoFiles, shouldCheck });
224
- const run = { arch, findings, orphans, repoFiles, repoRoot, configPath, project };
225
- if (args.overview)
226
- return writeOverviewReport({ overview: args.overview, check: args.check }, run);
227
- return writeTextReport({ out: args.out, check: args.check }, { findings, orphans, repoRoot });
395
+ const scope = { exts, ignoreDirs, ignoreGlobs };
396
+ const { findings, orphans } = runFindings(collected, {
397
+ arch,
398
+ repoFiles,
399
+ shouldCheck,
400
+ scanned,
401
+ scope,
402
+ index: args.index,
403
+ usage: args.usage,
404
+ });
405
+ const code = args.overview
406
+ ? writeOverviewReport({ overview: args.overview, check: args.check }, { arch, findings, orphans, repoFiles, repoRoot, configPath, project: (0, scan_run_1.wholeRepoProject)() })
407
+ : writeTextReport({ out: args.out, check: args.check }, { findings, orphans, repoRoot });
408
+ (0, scan_run_1.endRun)();
409
+ return code;
228
410
  };
229
411
  exports.main = main;
@@ -0,0 +1,3 @@
1
+ import type { Arch, ArchChild } from "@md-code/follow-architecture/entities/architecture";
2
+ declare const entitiesOfChild: (arch: Arch, child: ArchChild | null | undefined) => string[];
3
+ export { entitiesOfChild };
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.entitiesOfChild = void 0;
4
+ const entitiesOfChild = (arch, child) => {
5
+ if (!child)
6
+ return [];
7
+ if (child.entities?.length)
8
+ return child.entities;
9
+ const target = child.nodeSlug ? arch.nodes.bySlug[child.nodeSlug] : null;
10
+ return target?.entities ?? [];
11
+ };
12
+ exports.entitiesOfChild = entitiesOfChild;
@@ -1,4 +1,4 @@
1
- import type { Arch, ArchChild, ArchNode, ArchVariant, RawChild, RawNode } from "../entities/architecture";
1
+ import type { Arch, ArchChild, ArchNode, ArchVariant, RawChild, RawNode } from "@md-code/follow-architecture/entities/architecture";
2
2
  type FolderContents = {
3
3
  present: Set<string>;
4
4
  declared: ArchChild[];
@@ -16,10 +16,10 @@ declare const missingRequiredChild: (node: ArchNode, arch: Arch, rel: string, ct
16
16
  declare const nodePathRe: (template: string) => RegExp;
17
17
  type PrefixMatcher = Pick<ArchVariant, "re" | "names" | "literalLen" | "isFile">;
18
18
  declare const nodePrefixRe: (template: string) => PrefixMatcher;
19
- declare const rolesOf: (spec: {
20
- role?: string | string[] | null;
19
+ declare const entitiesOf: (spec: {
20
+ entity?: string | string[] | null;
21
21
  } | null | undefined) => string[];
22
22
  declare const compileChild: (name: RawChild) => ArchChild;
23
- export { nodePathRe, nodePrefixRe, compileChild, folderContents, missingRequiredChild, ancestorChain, rolesOf };
23
+ export { nodePathRe, nodePrefixRe, compileChild, folderContents, missingRequiredChild, ancestorChain, entitiesOf };
24
24
  export type { ConcreteFolder };
25
25
  export type { RawNode, RawChild };
@@ -1,11 +1,46 @@
1
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
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.rolesOf = exports.ancestorChain = exports.missingRequiredChild = exports.folderContents = exports.compileChild = exports.nodePrefixRe = exports.nodePathRe = void 0;
36
+ exports.entitiesOf = exports.ancestorChain = exports.missingRequiredChild = exports.folderContents = exports.compileChild = exports.nodePrefixRe = exports.nodePathRe = void 0;
4
37
  // Node child handling: a child is either a plain string name or a
5
38
  // `{ kind, name? }` matcher. `compileChild` turns a name into a regex with
6
39
  // capture groups; `nodePrefixRe` turns a node path into a prefix matcher.
7
40
  // Both live here because they are node-specific, not shared machinery.
8
- const pattern_1 = require("../utils/pattern");
41
+ const pattern_1 = require("@md-code/follow-architecture/utils/pattern");
42
+ const schema_1 = require("@md-code/follow-architecture/entities/schema");
43
+ const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
9
44
  // A regex that never matches: the placeholder `re` of a `{ node }` child before
10
45
  // `buildTree` gives it the referenced node's own pattern. It is always replaced
11
46
  // before anything reads it, but the type stays a `RegExp`.
@@ -28,7 +63,7 @@ exports.folderContents = folderContents;
28
63
  const ancestorChain = (node, arch) => {
29
64
  const chain = [];
30
65
  const seen = new Set();
31
- for (let cur = node; cur && !seen.has(cur.slug); cur = cur.parents.length === 1 ? arch.nodes.bySlug[cur.parents[0] ?? ""] ?? null : null) {
66
+ for (let cur = node; cur && !seen.has(cur.slug); cur = cur.parents.length === 1 ? (arch.nodes.bySlug[cur.parents[0] ?? ""] ?? null) : null) {
32
67
  seen.add(cur.slug);
33
68
  chain.push(cur);
34
69
  }
@@ -70,18 +105,29 @@ const nodePrefixRe = (template) => {
70
105
  return { re: new RegExp(`^${body}/([^/]+)(?:/(.*))?$`), names, literalLen, isFile: false };
71
106
  };
72
107
  exports.nodePrefixRe = nodePrefixRe;
73
- // A child may declare which codeRole(s) live in it: one role, several roles (a
108
+ // A child may declare which entity(s) live in it: one entity, several entities (a
74
109
  // file holding both a model and its types), or none. The NODE says where code
75
- // lives — the codeRole says what code is, never where it goes.
76
- const rolesOf = (spec) => {
77
- const raw = spec?.role;
110
+ // lives — the entity says what code is, never where it goes.
111
+ const entitiesOf = (spec) => {
112
+ const raw = spec?.entity;
78
113
  if (raw == null)
79
114
  return [];
80
115
  return (Array.isArray(raw) ? raw : [raw]).map(String).filter(Boolean);
81
116
  };
82
- exports.rolesOf = rolesOf;
117
+ exports.entitiesOf = entitiesOf;
83
118
  // `{ node: slug }` — the child IS another declared node.
84
- const referencedChild = (spec) => ({ nodeSlug: String(spec.node), name: null, re: DETACHED, captures: [], folder: true, required: Boolean(spec.required), forbidden: Boolean(spec.forbidden), query: null, report: spec.report ?? null, roles: rolesOf(spec) });
119
+ const referencedChild = (spec) => ({
120
+ nodeSlug: String(spec.node),
121
+ name: null,
122
+ re: DETACHED,
123
+ captures: [],
124
+ folder: true,
125
+ required: Boolean(spec.required),
126
+ forbidden: Boolean(spec.forbidden),
127
+ query: null,
128
+ report: spec.report ?? null,
129
+ entities: entitiesOf(spec),
130
+ });
85
131
  // A child named by a pattern: a FILE child (extension) or a FOLDER child.
86
132
  const childOf = (rawName, spec) => {
87
133
  const { body, names: captures } = (0, pattern_1.patternBody)(rawName);
@@ -99,12 +145,19 @@ const childOf = (rawName, spec) => {
99
145
  // the child's query but sits elsewhere.
100
146
  query: spec?.query ?? null,
101
147
  report: spec?.report ?? null,
102
- roles: rolesOf(spec),
148
+ entities: entitiesOf(spec),
103
149
  };
104
150
  };
105
151
  const compileChild = (name) => {
106
- // A child is either a bare name or a spec `{ name?, node?, role?, required?, forbidden?, query?, report? }`.
152
+ // A child is either a bare name or a spec `{ name?, node?, entity?, required?, forbidden?, query?, report? }`.
107
153
  const spec = name && typeof name === "object" ? name : null;
154
+ if (spec) {
155
+ const known = new Set(schema_1.SCHEMA.child);
156
+ for (const key of Object.keys(spec)) {
157
+ if (!known.has(key))
158
+ throw configError.unknownChildKey({ node: String(spec.name ?? spec.node ?? "child"), key });
159
+ }
160
+ }
108
161
  if (spec?.node)
109
162
  return referencedChild(spec);
110
163
  return childOf(String(spec ? spec.name : name), spec);
@@ -1,6 +1,6 @@
1
- import type { ArchNode } from "../../entities/architecture";
2
- import type { FileContext } from "../../entities/context";
3
- import type { Finding, FindingFrom } from "../../entities/findings";
1
+ import type { ArchNode } from "@md-code/follow-architecture/entities/architecture";
2
+ import type { FileContext } from "@md-code/follow-architecture/entities/context";
3
+ import type { Finding, FindingFrom } from "@md-code/follow-architecture/entities/findings";
4
4
  import type { Violation } from "./violation";
5
- declare const emitFindings: (violations: Violation[], ctx: FileContext, node: ArchNode, out: Finding[], findingFrom: FindingFrom) => void;
5
+ declare const emitFindings: (...args: [violations: Violation[], ctx: FileContext, node: ArchNode, out: Finding[], findingFrom: FindingFrom]) => void;
6
6
  export { emitFindings };
@@ -7,24 +7,29 @@ const withoutDeclareDuplicates = (violations) => {
7
7
  const called = new Set(violations.filter((v) => v.kind === "call").map((v) => `${v.line}|${v.targetPath}`));
8
8
  return violations.filter((v) => v.kind !== "declare" || !called.has(`${v.line}|${v.targetPath}`));
9
9
  };
10
- // Same role, several functions: one sentence naming all of them.
11
- const roleSentence = (v) => {
10
+ // Same entity, several functions: one sentence naming all of them.
11
+ const entitySentence = (v) => {
12
12
  const names = (v.names ?? []).filter(Boolean);
13
- const shown = names.slice(0, 4).map((n) => `\`${n}\``).join(", ");
13
+ const shown = names
14
+ .slice(0, 4)
15
+ .map((n) => `\`${n}\``)
16
+ .join(", ");
14
17
  const rest = names.length > 4 ? ` and ${names.length - 4} more` : "";
15
- const tail = v.where ? `they belong in ${v.where}` : `${v.owning ?? "this folder"} declares no home for a \`${v.role}\``;
18
+ const tail = v.where
19
+ ? `they belong in ${v.where}`
20
+ : `${v.owning ?? "this folder"} declares no home for a \`${v.entity}\``;
16
21
  const move = v.where ? `Move ${shown}${rest} to ${v.where}.` : null;
17
- return { ...v, fix: move, text: `This file declares \`${v.role}\` functions (${shown}${rest}): ${tail}.` };
22
+ return { ...v, fix: move, text: `This file declares \`${v.entity}\` functions (${shown}${rest}): ${tail}.` };
18
23
  };
19
- // One decision per key: a role's many functions merge into one sentence; any
24
+ // One decision per key: an entity's many functions merge into one sentence; any
20
25
  // other violation is its own decision, keyed by its text.
21
26
  const decisionsOf = (violations) => {
22
27
  const byText = new Map();
23
28
  for (const v of violations) {
24
- const key = v.role ? `role:${v.role}` : v.text;
29
+ const key = v.entity ? `entity:${v.entity}` : v.text;
25
30
  const names = (v.names ?? []).filter(Boolean);
26
- if (v.role && names.length > 1 && !byText.has(key)) {
27
- byText.set(key, roleSentence(v));
31
+ if (v.entity && names.length > 1 && !byText.has(key)) {
32
+ byText.set(key, entitySentence(v));
28
33
  continue;
29
34
  }
30
35
  if (!byText.has(key))
@@ -35,7 +40,18 @@ const decisionsOf = (violations) => {
35
40
  // The structured evidence a relation finding carries — the token the report
36
41
  // draws, with the target it names.
37
42
  const evidenceOf = (v) => v.kind && v.targetNode
38
- ? { violations: [{ kind: v.kind, targetNode: v.targetNode, targetPath: v.targetPath ?? null, line: v.line, destination: v.destination ?? null, token: v.token ?? null }] }
43
+ ? {
44
+ violations: [
45
+ {
46
+ kind: v.kind,
47
+ targetNode: v.targetNode,
48
+ targetPath: v.targetPath ?? null,
49
+ line: v.line,
50
+ destination: v.destination ?? null,
51
+ token: v.token ?? null,
52
+ },
53
+ ],
54
+ }
39
55
  : {};
40
56
  const emitFindings = (...args) => {
41
57
  const [violations, ctx, node, out, findingFrom] = args;
@@ -0,0 +1,13 @@
1
+ import type { Arch, WhereEntry } from "@md-code/follow-architecture/entities/architecture";
2
+ import type { Caps } from "@md-code/follow-architecture/entities/location/where";
3
+ declare const fitsEntity: (entitySlug: string, arch: Arch, rel: string) => boolean;
4
+ type AllowedPlace = {
5
+ entity: string | null;
6
+ paths: string[];
7
+ anywhere?: boolean;
8
+ same?: boolean;
9
+ filter?: boolean;
10
+ };
11
+ declare const allowedPlaces: (entries: WhereEntry[] | null | undefined, arch: Arch, targetCaps: Caps | null) => AllowedPlace[];
12
+ export { fitsEntity, allowedPlaces };
13
+ export type { AllowedPlace };
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.allowedPlaces = exports.fitsEntity = void 0;
4
+ // Entity ↔ place: is this file a home for that entity, and which paths may an
5
+ // action's `from:` list name.
6
+ const location_1 = require("@md-code/follow-architecture/entities/location");
7
+ const gate_1 = require("@md-code/follow-architecture/utils/gate");
8
+ // Does this file sit in one of the entity's homes? The home question is the ONE
9
+ // implementation in `entities/location/homes` (`entityFitsAt`, asked through the
10
+ // shared `where` grammar). The two exemptions are the shared gate: an entity
11
+ // nobody declares, or one with no home, restricts nothing — when neither
12
+ // rejection fires, the home answer decides.
13
+ const fitsEntity = (entitySlug, arch, rel) => !(0, gate_1.admitsWhenNoneReject)(entitySlug, [(slug) => !arch.entities?.[slug], (slug) => !(0, location_1.homesOf)(arch, slug).length]) ||
14
+ (0, location_1.entityFitsAt)(arch, entitySlug, rel);
15
+ exports.fitsEntity = fitsEntity;
16
+ const entityPlace = (entry, arch, targetCaps) => {
17
+ const homes = (0, location_1.homesOf)(arch, entry.entity ?? "");
18
+ const paths = homes.map((h) => (0, location_1.fillTemplate)(h.template, null, targetCaps)).filter((p) => Boolean(p));
19
+ // `same: true` is part of the RULE, not decoration: an orchestrator may
20
+ // call an action only inside its own feature. The message has to say so,
21
+ // or it reads as "orchestrators may not call actions at all".
22
+ return { entity: entry.entity ?? null, paths, anywhere: !homes.length, same: Boolean(entry.same) };
23
+ };
24
+ const nodePlace = (entry, arch, targetCaps) => {
25
+ const path = (0, location_1.fillTemplate)(arch.nodes?.bySlug?.[entry.node ?? ""]?.path, null, targetCaps);
26
+ return { entity: null, paths: path ? [path] : [] };
27
+ };
28
+ const allowedPlaces = (entries, arch, targetCaps) => {
29
+ const out = [];
30
+ for (const entry of entries ?? []) {
31
+ if (entry.type === "entity")
32
+ out.push(entityPlace(entry, arch, targetCaps));
33
+ else if (entry.type === "node")
34
+ out.push(nodePlace(entry, arch, targetCaps));
35
+ else if (entry.type === "glob")
36
+ out.push({ entity: null, paths: entry.glob ? [entry.glob] : [] });
37
+ else
38
+ out.push({ entity: null, paths: [], filter: true });
39
+ }
40
+ return out;
41
+ };
42
+ exports.allowedPlaces = allowedPlaces;
@@ -1,8 +1,8 @@
1
- import { EDGE_FACTS } from "../../entities/kinds";
2
- import { fitsRole } from "./roles";
3
- import type { Arch, ArchNode } from "../../entities/architecture";
4
- import type { FileContext } from "../../entities/context";
5
- import type { Finding, FindingFrom } from "../../entities/findings";
1
+ import { EDGE_FACTS } from "@md-code/follow-architecture/entities/kinds";
2
+ import { fitsEntity } from "./entities";
3
+ import type { Arch, ArchNode } from "@md-code/follow-architecture/entities/architecture";
4
+ import type { FileContext } from "@md-code/follow-architecture/entities/context";
5
+ import type { Finding, FindingFrom } from "@md-code/follow-architecture/entities/findings";
6
6
  declare const checkFinally: (ctx: FileContext, arch: Arch, out: Finding[], findingFrom: FindingFrom) => void;
7
7
  declare const __exported_missingRequiredChild: (node: ArchNode, arch: Arch, rel: string, files: string[] | null | undefined) => boolean;
8
- export { checkFinally, fitsRole, __exported_missingRequiredChild as missingRequiredChild, EDGE_FACTS };
8
+ export { checkFinally, fitsEntity, __exported_missingRequiredChild as missingRequiredChild, EDGE_FACTS };