@md-code/follow-architecture 0.1.0 → 0.3.0

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 (436) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +202 -0
  3. package/README.md +597 -126
  4. package/dist/aliases.d.ts +3 -0
  5. package/dist/aliases.js +12 -0
  6. package/dist/args.d.ts +14 -0
  7. package/dist/args.js +77 -0
  8. package/dist/bin/follow-architecture.d.ts +2 -0
  9. package/dist/bin/follow-architecture.js +23 -0
  10. package/dist/code-roles/classify.d.ts +11 -0
  11. package/dist/code-roles/classify.js +43 -0
  12. package/dist/code-roles/connector.d.ts +5 -0
  13. package/dist/code-roles/connector.js +114 -0
  14. package/dist/code-roles/project.d.ts +12 -0
  15. package/dist/code-roles/project.js +122 -0
  16. package/dist/code-roles/roles.d.ts +8 -0
  17. package/dist/code-roles/roles.js +190 -0
  18. package/dist/config-options.d.ts +53 -0
  19. package/dist/config-options.js +35 -0
  20. package/dist/config-project.d.ts +4 -0
  21. package/dist/config-project.js +74 -0
  22. package/dist/config-report.d.ts +19 -0
  23. package/dist/config-report.js +134 -0
  24. package/dist/config-rule.d.ts +70 -0
  25. package/dist/config-rule.js +118 -0
  26. package/dist/config-state.d.ts +14 -0
  27. package/dist/config-state.js +96 -0
  28. package/dist/config.d.ts +82 -0
  29. package/dist/config.js +38 -0
  30. package/dist/css/index.d.ts +27 -0
  31. package/dist/css/index.js +140 -0
  32. package/dist/css/syntax/css/gate.d.ts +2 -0
  33. package/dist/css/syntax/css/gate.js +69 -0
  34. package/dist/css/syntax/css/index.d.ts +7 -0
  35. package/dist/css/syntax/css/index.js +41 -0
  36. package/dist/css/syntax/css/reference.d.ts +3 -0
  37. package/dist/css/syntax/css/reference.js +24 -0
  38. package/dist/css/syntax/language.d.ts +25 -0
  39. package/dist/css/syntax/language.js +69 -0
  40. package/dist/css/syntax/scss/index.d.ts +25 -0
  41. package/dist/css/syntax/scss/index.js +85 -0
  42. package/dist/css/syntax/scss/reference.d.ts +3 -0
  43. package/dist/css/syntax/scss/reference.js +11 -0
  44. package/dist/css/syntax/styled/document.d.ts +68 -0
  45. package/dist/css/syntax/styled/document.js +241 -0
  46. package/dist/css/syntax/styled/markup.d.ts +6 -0
  47. package/dist/css/syntax/styled/markup.js +76 -0
  48. package/dist/css/syntax/styled/template.d.ts +23 -0
  49. package/dist/css/syntax/styled/template.js +61 -0
  50. package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
  51. package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
  52. package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
  53. package/dist/css/syntax/tailwind/tailwind.js +118 -0
  54. package/dist/css/value/check.d.ts +86 -0
  55. package/dist/css/value/check.js +122 -0
  56. package/dist/css/value/expression/arithmetic.d.ts +7 -0
  57. package/dist/css/value/expression/arithmetic.js +69 -0
  58. package/dist/css/value/expression/block.d.ts +9 -0
  59. package/dist/css/value/expression/block.js +91 -0
  60. package/dist/css/value/expression/conditional.d.ts +8 -0
  61. package/dist/css/value/expression/conditional.js +53 -0
  62. package/dist/css/value/expression/index.d.ts +5 -0
  63. package/dist/css/value/expression/index.js +69 -0
  64. package/dist/css/value/expression/map.d.ts +7 -0
  65. package/dist/css/value/expression/map.js +113 -0
  66. package/dist/css/value/object/index.d.ts +5 -0
  67. package/dist/css/value/object/index.js +103 -0
  68. package/dist/css/value/object/members.d.ts +7 -0
  69. package/dist/css/value/object/members.js +103 -0
  70. package/dist/css/value/object/node.d.ts +8 -0
  71. package/dist/css/value/object/node.js +129 -0
  72. package/dist/css/value/object/path.d.ts +10 -0
  73. package/dist/css/value/object/path.js +146 -0
  74. package/dist/css/value/pieces.d.ts +61 -0
  75. package/dist/css/value/pieces.js +55 -0
  76. package/dist/css/value/resolve.d.ts +33 -0
  77. package/dist/css/value/resolve.js +94 -0
  78. package/dist/css/value/scope.d.ts +27 -0
  79. package/dist/css/value/scope.js +187 -0
  80. package/dist/css/value/substitute.d.ts +10 -0
  81. package/dist/css/value/substitute.js +113 -0
  82. package/dist/css/value/values.d.ts +23 -0
  83. package/dist/css/value/values.js +131 -0
  84. package/dist/entities/architecture.d.ts +162 -0
  85. package/dist/entities/architecture.js +2 -0
  86. package/dist/entities/ast/assignments-nodes.d.ts +10 -0
  87. package/dist/entities/ast/assignments-nodes.js +64 -0
  88. package/dist/entities/ast/assignments-raw.d.ts +6 -0
  89. package/dist/entities/ast/assignments-raw.js +86 -0
  90. package/dist/entities/ast/assignments-tagged.d.ts +5 -0
  91. package/dist/entities/ast/assignments-tagged.js +180 -0
  92. package/dist/entities/ast/assignments.d.ts +9 -0
  93. package/dist/entities/ast/assignments.js +78 -0
  94. package/dist/entities/ast/branches.d.ts +4 -0
  95. package/dist/entities/ast/branches.js +32 -0
  96. package/dist/entities/ast/calls.d.ts +6 -0
  97. package/dist/entities/ast/calls.js +134 -0
  98. package/dist/entities/ast/classes.d.ts +5 -0
  99. package/dist/entities/ast/classes.js +57 -0
  100. package/dist/entities/ast/climb.d.ts +12 -0
  101. package/dist/entities/ast/climb.js +17 -0
  102. package/dist/entities/ast/comments.d.ts +4 -0
  103. package/dist/entities/ast/comments.js +100 -0
  104. package/dist/entities/ast/declaration.d.ts +4 -0
  105. package/dist/entities/ast/declaration.js +26 -0
  106. package/dist/entities/ast/depth.d.ts +17 -0
  107. package/dist/entities/ast/depth.js +149 -0
  108. package/dist/entities/ast/enums.d.ts +6 -0
  109. package/dist/entities/ast/enums.js +17 -0
  110. package/dist/entities/ast/file-exports.d.ts +7 -0
  111. package/dist/entities/ast/file-exports.js +78 -0
  112. package/dist/entities/ast/file-facts.d.ts +13 -0
  113. package/dist/entities/ast/file-facts.js +35 -0
  114. package/dist/entities/ast/file-imports.d.ts +5 -0
  115. package/dist/entities/ast/file-imports.js +77 -0
  116. package/dist/entities/ast/file.d.ts +5 -0
  117. package/dist/entities/ast/file.js +22 -0
  118. package/dist/entities/ast/functions.d.ts +8 -0
  119. package/dist/entities/ast/functions.js +102 -0
  120. package/dist/entities/ast/heritage.d.ts +4 -0
  121. package/dist/entities/ast/heritage.js +36 -0
  122. package/dist/entities/ast/index.d.ts +6 -0
  123. package/dist/entities/ast/index.js +125 -0
  124. package/dist/entities/ast/kind.d.ts +5 -0
  125. package/dist/entities/ast/kind.js +28 -0
  126. package/dist/entities/ast/loose.d.ts +37 -0
  127. package/dist/entities/ast/loose.js +2 -0
  128. package/dist/entities/ast/modifiers.d.ts +5 -0
  129. package/dist/entities/ast/modifiers.js +32 -0
  130. package/dist/entities/ast/project.d.ts +9 -0
  131. package/dist/entities/ast/project.js +75 -0
  132. package/dist/entities/ast/properties.d.ts +11 -0
  133. package/dist/entities/ast/properties.js +171 -0
  134. package/dist/entities/ast/resolve.d.ts +16 -0
  135. package/dist/entities/ast/resolve.js +307 -0
  136. package/dist/entities/ast/tree.d.ts +29 -0
  137. package/dist/entities/ast/tree.js +351 -0
  138. package/dist/entities/ast/types.d.ts +6 -0
  139. package/dist/entities/ast/types.js +45 -0
  140. package/dist/entities/ast/usage.d.ts +11 -0
  141. package/dist/entities/ast/usage.js +81 -0
  142. package/dist/entities/ast/variables.d.ts +8 -0
  143. package/dist/entities/ast/variables.js +91 -0
  144. package/dist/entities/context.d.ts +29 -0
  145. package/dist/entities/context.js +2 -0
  146. package/dist/entities/facts.d.ts +261 -0
  147. package/dist/entities/facts.js +2 -0
  148. package/dist/entities/findings.d.ts +19 -0
  149. package/dist/entities/findings.js +2 -0
  150. package/dist/entities/kinds.d.ts +40 -0
  151. package/dist/entities/kinds.js +221 -0
  152. package/dist/entities/location/homes.d.ts +28 -0
  153. package/dist/entities/location/homes.js +169 -0
  154. package/dist/entities/location/place.d.ts +10 -0
  155. package/dist/entities/location/place.js +56 -0
  156. package/dist/entities/location/where.d.ts +17 -0
  157. package/dist/entities/location/where.js +218 -0
  158. package/dist/entities/location.d.ts +16 -0
  159. package/dist/entities/location.js +140 -0
  160. package/dist/entities/operators.d.ts +14 -0
  161. package/dist/entities/operators.js +30 -0
  162. package/dist/entities/overview/data.d.ts +43 -0
  163. package/dist/entities/overview/data.js +2 -0
  164. package/dist/entities/overview/decision.d.ts +60 -0
  165. package/dist/entities/overview/decision.js +2 -0
  166. package/dist/entities/overview/file-tree.d.ts +10 -0
  167. package/dist/entities/overview/file-tree.js +2 -0
  168. package/dist/entities/overview/finding.d.ts +58 -0
  169. package/dist/entities/overview/finding.js +2 -0
  170. package/dist/entities/overview/graph.d.ts +65 -0
  171. package/dist/entities/overview/graph.js +2 -0
  172. package/dist/entities/overview/input.d.ts +15 -0
  173. package/dist/entities/overview/input.js +2 -0
  174. package/dist/entities/overview/summaries.d.ts +79 -0
  175. package/dist/entities/overview/summaries.js +2 -0
  176. package/dist/entities/place.d.ts +5 -0
  177. package/dist/entities/place.js +2 -0
  178. package/dist/entities/queries.d.ts +9 -0
  179. package/dist/entities/queries.js +305 -0
  180. package/dist/entities/repair.d.ts +16 -0
  181. package/dist/entities/repair.js +23 -0
  182. package/dist/entities/schema.d.ts +8 -0
  183. package/dist/entities/schema.js +23 -0
  184. package/dist/entities/story.d.ts +47 -0
  185. package/dist/entities/story.js +2 -0
  186. package/dist/entities/structure-facts.d.ts +11 -0
  187. package/dist/entities/structure-facts.js +2 -0
  188. package/dist/entities/token.d.ts +23 -0
  189. package/dist/entities/token.js +2 -0
  190. package/dist/entities/tree/build.d.ts +5 -0
  191. package/dist/entities/tree/build.js +252 -0
  192. package/dist/entities/tree/entries.d.ts +7 -0
  193. package/dist/entities/tree/entries.js +120 -0
  194. package/dist/entities/tree/index.d.ts +6 -0
  195. package/dist/entities/tree/index.js +21 -0
  196. package/dist/entities/tree/match.d.ts +17 -0
  197. package/dist/entities/tree/match.js +176 -0
  198. package/dist/frameworks/angular/index.d.ts +7 -0
  199. package/dist/frameworks/angular/index.js +17 -0
  200. package/dist/frameworks/facet.d.ts +16 -0
  201. package/dist/frameworks/facet.js +2 -0
  202. package/dist/frameworks/index.d.ts +9 -0
  203. package/dist/frameworks/index.js +120 -0
  204. package/dist/frameworks/react/index.d.ts +7 -0
  205. package/dist/frameworks/react/index.js +214 -0
  206. package/dist/frameworks/vue/index.d.ts +7 -0
  207. package/dist/frameworks/vue/index.js +17 -0
  208. package/dist/invariants/index.d.ts +6 -0
  209. package/dist/invariants/index.js +299 -0
  210. package/dist/invariants/list-vars.d.ts +5 -0
  211. package/dist/invariants/list-vars.js +143 -0
  212. package/dist/invariants/name.d.ts +16 -0
  213. package/dist/invariants/name.js +18 -0
  214. package/dist/invariants/normalize.d.ts +4 -0
  215. package/dist/invariants/normalize.js +95 -0
  216. package/dist/invariants/vars.d.ts +20 -0
  217. package/dist/invariants/vars.js +117 -0
  218. package/dist/main.d.ts +7 -0
  219. package/dist/main.js +229 -0
  220. package/dist/nodes/child-roles.d.ts +3 -0
  221. package/dist/nodes/child-roles.js +12 -0
  222. package/dist/nodes/children.d.ts +25 -0
  223. package/dist/nodes/children.js +112 -0
  224. package/dist/nodes/finally/emit.d.ts +6 -0
  225. package/dist/nodes/finally/emit.js +55 -0
  226. package/dist/nodes/finally/index.d.ts +8 -0
  227. package/dist/nodes/finally/index.js +35 -0
  228. package/dist/nodes/finally/queries.d.ts +5 -0
  229. package/dist/nodes/finally/queries.js +22 -0
  230. package/dist/nodes/finally/relations-access.d.ts +5 -0
  231. package/dist/nodes/finally/relations-access.js +46 -0
  232. package/dist/nodes/finally/relations-edge.d.ts +29 -0
  233. package/dist/nodes/finally/relations-edge.js +125 -0
  234. package/dist/nodes/finally/relations-group.d.ts +31 -0
  235. package/dist/nodes/finally/relations-group.js +103 -0
  236. package/dist/nodes/finally/relations.d.ts +5 -0
  237. package/dist/nodes/finally/relations.js +81 -0
  238. package/dist/nodes/finally/required.d.ts +5 -0
  239. package/dist/nodes/finally/required.js +90 -0
  240. package/dist/nodes/finally/roles.d.ts +13 -0
  241. package/dist/nodes/finally/roles.js +41 -0
  242. package/dist/nodes/finally/violation.d.ts +17 -0
  243. package/dist/nodes/finally/violation.js +2 -0
  244. package/dist/nodes/similar.d.ts +21 -0
  245. package/dist/nodes/similar.js +156 -0
  246. package/dist/pipeline-facts.d.ts +11 -0
  247. package/dist/pipeline-facts.js +112 -0
  248. package/dist/pipeline-roles.d.ts +6 -0
  249. package/dist/pipeline-roles.js +75 -0
  250. package/dist/pipeline-unroled.d.ts +14 -0
  251. package/dist/pipeline-unroled.js +193 -0
  252. package/dist/pipeline.d.ts +7 -0
  253. package/dist/pipeline.js +73 -0
  254. package/dist/plugin.d.ts +2 -0
  255. package/dist/plugin.js +3 -0
  256. package/dist/report/asks.d.ts +55 -0
  257. package/dist/report/asks.js +50 -0
  258. package/dist/report/cli-report.d.ts +2 -0
  259. package/dist/report/cli-report.js +13 -0
  260. package/dist/report/config-error-guard.d.ts +8 -0
  261. package/dist/report/config-error-guard.js +5 -0
  262. package/dist/report/configErrors.d.ts +98 -0
  263. package/dist/report/configErrors.js +75 -0
  264. package/dist/report/errorTypes/codes/structure.d.ts +15 -0
  265. package/dist/report/errorTypes/codes/structure.js +76 -0
  266. package/dist/report/errorTypes/decision-maker.d.ts +23 -0
  267. package/dist/report/errorTypes/decision-maker.js +99 -0
  268. package/dist/report/errorTypes/destinations.d.ts +38 -0
  269. package/dist/report/errorTypes/destinations.js +147 -0
  270. package/dist/report/errorTypes/finding-type.d.ts +11 -0
  271. package/dist/report/errorTypes/finding-type.js +2 -0
  272. package/dist/report/errorTypes/index.d.ts +15 -0
  273. package/dist/report/errorTypes/index.js +45 -0
  274. package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
  275. package/dist/report/errorTypes/types/fileContents.js +34 -0
  276. package/dist/report/errorTypes/types/unknownRole.d.ts +9 -0
  277. package/dist/report/errorTypes/types/unknownRole.js +22 -0
  278. package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
  279. package/dist/report/errorTypes/types/wrongAction.js +135 -0
  280. package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
  281. package/dist/report/errorTypes/types/wrongPlacement.js +57 -0
  282. package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
  283. package/dist/report/errorTypes/vocabulary/ids.js +16 -0
  284. package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
  285. package/dist/report/errorTypes/vocabulary/phrases.js +174 -0
  286. package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
  287. package/dist/report/errorTypes/vocabulary/places.js +36 -0
  288. package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
  289. package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
  290. package/dist/report/finding-from.d.ts +9 -0
  291. package/dist/report/finding-from.js +103 -0
  292. package/dist/report/notices.d.ts +4 -0
  293. package/dist/report/notices.js +31 -0
  294. package/dist/report/render-report.d.ts +12 -0
  295. package/dist/report/render-report.js +142 -0
  296. package/dist/report/user-report/build/bundle.d.ts +3 -0
  297. package/dist/report/user-report/build/bundle.js +169 -0
  298. package/dist/report/user-report/build/bundle.prebuilt.js +760 -0
  299. package/dist/report/user-report/data/collect.d.ts +4 -0
  300. package/dist/report/user-report/data/collect.js +80 -0
  301. package/dist/report/user-report/data/file-tree.d.ts +9 -0
  302. package/dist/report/user-report/data/file-tree.js +72 -0
  303. package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
  304. package/dist/report/user-report/data/finding-boundary.js +21 -0
  305. package/dist/report/user-report/data/finding-plan.d.ts +16 -0
  306. package/dist/report/user-report/data/finding-plan.js +45 -0
  307. package/dist/report/user-report/data/finding-title.d.ts +12 -0
  308. package/dist/report/user-report/data/finding-title.js +36 -0
  309. package/dist/report/user-report/data/findings.d.ts +10 -0
  310. package/dist/report/user-report/data/findings.js +171 -0
  311. package/dist/report/user-report/data/graph-edges.d.ts +19 -0
  312. package/dist/report/user-report/data/graph-edges.js +109 -0
  313. package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
  314. package/dist/report/user-report/data/graph-helpers.js +67 -0
  315. package/dist/report/user-report/data/graph-roles.d.ts +5 -0
  316. package/dist/report/user-report/data/graph-roles.js +71 -0
  317. package/dist/report/user-report/data/graph.d.ts +11 -0
  318. package/dist/report/user-report/data/graph.js +90 -0
  319. package/dist/report/user-report/data/invariants.d.ts +7 -0
  320. package/dist/report/user-report/data/invariants.js +62 -0
  321. package/dist/report/user-report/data/nodes.d.ts +11 -0
  322. package/dist/report/user-report/data/nodes.js +106 -0
  323. package/dist/report/user-report/data/role-examples.d.ts +16 -0
  324. package/dist/report/user-report/data/role-examples.js +94 -0
  325. package/dist/report/user-report/data/role-filters.d.ts +15 -0
  326. package/dist/report/user-report/data/role-filters.js +79 -0
  327. package/dist/report/user-report/data/role-marks.d.ts +5 -0
  328. package/dist/report/user-report/data/role-marks.js +79 -0
  329. package/dist/report/user-report/data/roles.d.ts +7 -0
  330. package/dist/report/user-report/data/roles.js +83 -0
  331. package/dist/report/user-report/data/scan.d.ts +8 -0
  332. package/dist/report/user-report/data/scan.js +59 -0
  333. package/dist/report/user-report/html/shell.d.ts +3 -0
  334. package/dist/report/user-report/html/shell.js +27 -0
  335. package/dist/report/user-report/index.d.ts +8 -0
  336. package/dist/report/user-report/index.js +48 -0
  337. package/dist/report/user-report/shared/describe.d.ts +7 -0
  338. package/dist/report/user-report/shared/describe.js +86 -0
  339. package/dist/scripts/audit-report.d.ts +2 -0
  340. package/dist/scripts/audit-report.js +147 -0
  341. package/dist/utils/accumulate.d.ts +6 -0
  342. package/dist/utils/accumulate.js +18 -0
  343. package/dist/utils/article.d.ts +2 -0
  344. package/dist/utils/article.js +12 -0
  345. package/dist/utils/classify.d.ts +12 -0
  346. package/dist/utils/classify.js +25 -0
  347. package/dist/utils/configs.d.ts +25 -0
  348. package/dist/utils/configs.js +87 -0
  349. package/dist/utils/count.d.ts +7 -0
  350. package/dist/utils/count.js +13 -0
  351. package/dist/utils/dispatch.d.ts +2 -0
  352. package/dist/utils/dispatch.js +27 -0
  353. package/dist/utils/distinct.d.ts +2 -0
  354. package/dist/utils/distinct.js +12 -0
  355. package/dist/utils/field.d.ts +14 -0
  356. package/dist/utils/field.js +60 -0
  357. package/dist/utils/file-name.d.ts +2 -0
  358. package/dist/utils/file-name.js +11 -0
  359. package/dist/utils/files.d.ts +7 -0
  360. package/dist/utils/files.js +73 -0
  361. package/dist/utils/fixpoint.d.ts +2 -0
  362. package/dist/utils/fixpoint.js +19 -0
  363. package/dist/utils/gate.d.ts +2 -0
  364. package/dist/utils/gate.js +12 -0
  365. package/dist/utils/group.d.ts +3 -0
  366. package/dist/utils/group.js +33 -0
  367. package/dist/utils/host.d.ts +3 -0
  368. package/dist/utils/host.js +13 -0
  369. package/dist/utils/imports.d.ts +12 -0
  370. package/dist/utils/imports.js +121 -0
  371. package/dist/utils/judged.d.ts +5 -0
  372. package/dist/utils/judged.js +19 -0
  373. package/dist/utils/keyed.d.ts +2 -0
  374. package/dist/utils/keyed.js +23 -0
  375. package/dist/utils/map-record.d.ts +2 -0
  376. package/dist/utils/map-record.js +11 -0
  377. package/dist/utils/path-label.d.ts +6 -0
  378. package/dist/utils/path-label.js +35 -0
  379. package/dist/utils/pattern.d.ts +18 -0
  380. package/dist/utils/pattern.js +191 -0
  381. package/dist/utils/permission.d.ts +16 -0
  382. package/dist/utils/permission.js +16 -0
  383. package/dist/utils/plural.d.ts +2 -0
  384. package/dist/utils/plural.js +9 -0
  385. package/dist/utils/qualified.d.ts +2 -0
  386. package/dist/utils/qualified.js +21 -0
  387. package/dist/utils/rank.d.ts +2 -0
  388. package/dist/utils/rank.js +24 -0
  389. package/dist/utils/read-field.d.ts +12 -0
  390. package/dist/utils/read-field.js +50 -0
  391. package/dist/utils/read-when.d.ts +2 -0
  392. package/dist/utils/read-when.js +17 -0
  393. package/dist/utils/reason.d.ts +4 -0
  394. package/dist/utils/reason.js +9 -0
  395. package/dist/utils/record.d.ts +3 -0
  396. package/dist/utils/record.js +21 -0
  397. package/dist/utils/resolve.d.ts +2 -0
  398. package/dist/utils/resolve.js +24 -0
  399. package/dist/utils/search.d.ts +2 -0
  400. package/dist/utils/search.js +16 -0
  401. package/dist/utils/seen.d.ts +6 -0
  402. package/dist/utils/seen.js +27 -0
  403. package/dist/utils/span.d.ts +5 -0
  404. package/dist/utils/span.js +2 -0
  405. package/dist/utils/speak.d.ts +2 -0
  406. package/dist/utils/speak.js +18 -0
  407. package/dist/utils/split.d.ts +8 -0
  408. package/dist/utils/split.js +8 -0
  409. package/dist/utils/template.d.ts +5 -0
  410. package/dist/utils/template.js +5 -0
  411. package/dist/utils/text.d.ts +4 -0
  412. package/dist/utils/text.js +42 -0
  413. package/dist/utils/tokenize.d.ts +2 -0
  414. package/dist/utils/tokenize.js +13 -0
  415. package/dist/utils/try-read.d.ts +4 -0
  416. package/dist/utils/try-read.js +24 -0
  417. package/dist/utils/typed-field.d.ts +3 -0
  418. package/dist/utils/typed-field.js +16 -0
  419. package/dist/utils/verdicts.d.ts +4 -0
  420. package/dist/utils/verdicts.js +20 -0
  421. package/entities/operators.ts +31 -0
  422. package/package.json +62 -19
  423. package/report/errorTypes/vocabulary/ids.ts +12 -0
  424. package/report/errorTypes/vocabulary/phrases.ts +161 -0
  425. package/report/errorTypes/vocabulary/places.ts +46 -0
  426. package/report/errorTypes/vocabulary/verbs.ts +31 -0
  427. package/report/user-report/shared/describe.ts +107 -0
  428. package/ast.js +0 -107
  429. package/bin/follow-architecture.js +0 -6
  430. package/config.js +0 -82
  431. package/entities/aliases.js +0 -10
  432. package/entities/invariants.js +0 -134
  433. package/entities/nodes.js +0 -112
  434. package/main.js +0 -95
  435. package/report.js +0 -73
  436. package/utils.js +0 -104
@@ -0,0 +1,252 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.variantsOf = exports.buildTree = void 0;
27
+ // Nodes → path variants (one per parent) + the role homes they imply.
28
+ const children_1 = require("../../nodes/children");
29
+ const schema_1 = require("../schema");
30
+ const keyed_1 = require("../../utils/keyed");
31
+ const configError = __importStar(require("../../report/configErrors"));
32
+ // A regex that never matches — the placeholder `re` of a node before its path is
33
+ // resolved. Overwritten in the same pass that computes the real one.
34
+ const NEVER = /(?!)/;
35
+ // A node's declared parent(s) as a list; the root is `[null]`.
36
+ const parentsOf = (parent) => {
37
+ if (Array.isArray(parent))
38
+ return parent;
39
+ return parent ? [parent] : [null];
40
+ };
41
+ const variantsOf = (n, parentPaths) => parentsOf(n.parent).map((p) => {
42
+ const base = p == null ? null : parentPaths[p];
43
+ const path = base == null || base === "." ? n.name : `${base}/${n.name}`;
44
+ const { re, names, literalLen, isFile } = (0, children_1.nodePrefixRe)(path);
45
+ return { path, re, names, literalLen, isFile };
46
+ });
47
+ exports.variantsOf = variantsOf;
48
+ const NODE_KEYS = new Set(schema_1.SCHEMA.node);
49
+ const make = (n) => {
50
+ for (const key of Object.keys(n)) {
51
+ if (NODE_KEYS.has(key))
52
+ continue;
53
+ throw configError.unknownNodeKey({ node: n.slug, key, allowed: schema_1.SCHEMA.node });
54
+ }
55
+ return {
56
+ slug: n.slug ?? "",
57
+ name: n.name,
58
+ parent: n.parent,
59
+ parents: parentsOf(n.parent),
60
+ children: (n.children ?? []).map(children_1.compileChild),
61
+ // `role:` on the node itself = the whole folder is that code (its `**`).
62
+ roles: (0, children_1.rolesOf)(n),
63
+ report: n.report,
64
+ variants: [],
65
+ path: "",
66
+ re: NEVER,
67
+ prefixRe: NEVER,
68
+ prefixNames: [],
69
+ literalLen: 0,
70
+ isFile: false,
71
+ };
72
+ };
73
+ // The list-or-map walk is the shared `keyedDefs` core; a node def is what the
74
+ // tree validates afterwards.
75
+ const listOf = (nodes) => (0, keyed_1.keyedDefs)(nodes).filter((n) => n != null);
76
+ const indexBySlug = (all) => Object.fromEntries(all.map((n) => [n.slug, n]));
77
+ const validateParents = (all, bySlug) => {
78
+ for (const n of all) {
79
+ for (const p of n.parents) {
80
+ if (p != null && !bySlug[p])
81
+ throw configError.unknownNodeParent({ node: n.slug, parent: p });
82
+ }
83
+ }
84
+ };
85
+ // Resolve every node's path variants (one per declared parent).
86
+ const resolveVariants = (all, bySlug) => {
87
+ const resolvedPath = {};
88
+ const resolvePath = (n) => {
89
+ if (resolvedPath[n.slug] != null)
90
+ return resolvedPath[n.slug];
91
+ const parentPaths = {};
92
+ for (const p of n.parents)
93
+ if (p != null)
94
+ parentPaths[p] = resolvePath(bySlug[p]);
95
+ n.variants = variantsOf(n, parentPaths);
96
+ resolvedPath[n.slug] = n.variants[0].path;
97
+ return resolvedPath[n.slug];
98
+ };
99
+ for (const n of all)
100
+ resolvePath(n);
101
+ };
102
+ // `{ node: slug }` children borrow the referenced node's own name template.
103
+ const resolveNodeChildren = (all, bySlug) => {
104
+ for (const n of all) {
105
+ for (const child of n.children) {
106
+ if (!child.nodeSlug)
107
+ continue;
108
+ const target = bySlug[child.nodeSlug];
109
+ if (!target)
110
+ throw configError.unknownNodeChild({ node: n.slug, child: child.nodeSlug });
111
+ const compiled = (0, children_1.compileChild)(target.name);
112
+ child.re = compiled.re;
113
+ child.captures = compiled.captures;
114
+ child.name = target.name;
115
+ child.folder = compiled.folder;
116
+ if (!child.roles?.length)
117
+ child.roles = target.roles ?? [];
118
+ }
119
+ }
120
+ };
121
+ // A node's `role:` covers any child that names no role of its own.
122
+ const propagateRoles = (all) => {
123
+ for (const n of all) {
124
+ if (!n.roles?.length)
125
+ continue;
126
+ for (const c of n.children) {
127
+ if (c.nodeSlug || c.roles?.length)
128
+ continue;
129
+ c.roles = n.roles;
130
+ }
131
+ }
132
+ };
133
+ // Copy each node's FIRST variant onto the node for direct access.
134
+ const assignPrimary = (all) => {
135
+ for (const n of all) {
136
+ const v0 = n.variants[0];
137
+ n.path = v0.path;
138
+ n.re = v0.re;
139
+ n.prefixRe = v0.re;
140
+ n.prefixNames = v0.names;
141
+ n.literalLen = v0.literalLen;
142
+ n.isFile = v0.isFile;
143
+ }
144
+ };
145
+ // The role homes: a node that declares `role:` IS that code.
146
+ const addHome = (roleHomes, role, template, nodeSlug) => {
147
+ const list = (roleHomes[role] ??= []);
148
+ if (!list.some((h) => h.template === template))
149
+ list.push({ template, node: nodeSlug });
150
+ };
151
+ const ownHomeTemplate = (v) => (v.isFile ? v.path : `${v.path === "." ? "" : `${v.path}/`}**`);
152
+ const variantBasePath = (v, child) => (v.path === "." ? child.name ?? "" : `${v.path}/${child.name}`);
153
+ const childBases = (n, child, bySlug) => {
154
+ if (child.nodeSlug)
155
+ return (bySlug[child.nodeSlug]?.variants ?? []).map((v) => ({ path: v.path, node: child.nodeSlug }));
156
+ return n.variants.map((v) => ({ path: variantBasePath(v, child), node: n.slug }));
157
+ };
158
+ const addChildHomes = (roleHomes, n, child, bySlug) => {
159
+ for (const base of childBases(n, child, bySlug)) {
160
+ // A folder child owns everything below it; a file child only itself.
161
+ const template = child.folder ? `${base.path}/**` : base.path;
162
+ for (const role of child.roles)
163
+ addHome(roleHomes, role, template, base.node);
164
+ }
165
+ };
166
+ const buildRoleHomes = (all, bySlug) => {
167
+ const roleHomes = {};
168
+ for (const n of all) {
169
+ if (!n.roles?.length)
170
+ continue;
171
+ for (const v of n.variants)
172
+ for (const role of n.roles)
173
+ addHome(roleHomes, role, ownHomeTemplate(v), n.slug);
174
+ }
175
+ for (const n of all) {
176
+ for (const child of n.children) {
177
+ if (!child.roles?.length)
178
+ continue;
179
+ addChildHomes(roleHomes, n, child, bySlug);
180
+ }
181
+ }
182
+ return roleHomes;
183
+ };
184
+ // The literal (fixed) folder-child names a parent declares — the values a
185
+ // `{kebab-case}` position is locked to.
186
+ const literalClaims = (parent) => {
187
+ const names = new Map();
188
+ for (const c of parent.children ?? []) {
189
+ if (c.nodeSlug || !c.name || /\{[^}]+\}/.test(c.name))
190
+ continue;
191
+ if (!c.folder)
192
+ continue;
193
+ names.set(c.name, true);
194
+ }
195
+ return [...names.keys()];
196
+ };
197
+ // The nearest ancestor whose name is a placeholder under a literal parent.
198
+ const findFuzzyRoot = (n, bySlug) => {
199
+ let cur = n;
200
+ const seen = new Set();
201
+ while (cur && !seen.has(cur.slug)) {
202
+ seen.add(cur.slug);
203
+ const parent = cur.parents[0] ? bySlug[cur.parents[0]] ?? null : null;
204
+ if (/\{[^}]+\}/.test(cur.name) && parent && !/\{[^}]+\}/.test(parent.name))
205
+ return cur;
206
+ cur = parent;
207
+ }
208
+ return null;
209
+ };
210
+ // Lock every variant that sits under the fuzzy root to the parent's literal
211
+ // child names at the placeholder position.
212
+ const applyClaimsToSharers = (all, fuzzyRoot, index, claims) => {
213
+ for (const n2 of all) {
214
+ const shares = n2.variants.some((v) => v.path === fuzzyRoot.path || v.path.startsWith(`${fuzzyRoot.path}/`));
215
+ if (!shares)
216
+ continue;
217
+ for (const v of n2.variants) {
218
+ if (!v.names[index])
219
+ continue;
220
+ v.claims = [...(v.claims ?? []), ...claims];
221
+ }
222
+ }
223
+ };
224
+ const applyClaims = (all, bySlug) => {
225
+ for (const n of all) {
226
+ const fuzzyRoot = findFuzzyRoot(n, bySlug);
227
+ if (!fuzzyRoot)
228
+ continue;
229
+ const parent = bySlug[fuzzyRoot.parents[0] ?? ""];
230
+ const values = literalClaims(parent);
231
+ if (!values.length)
232
+ continue;
233
+ const index = fuzzyRoot.name.split("/").findIndex((seg) => /^\{[^}]+\}$/.test(seg));
234
+ if (index < 0)
235
+ continue;
236
+ applyClaimsToSharers(all, fuzzyRoot, index, values.map((value) => ({ index, value })));
237
+ }
238
+ };
239
+ const buildTree = (nodes) => {
240
+ const all = listOf(nodes).map(make);
241
+ const bySlug = indexBySlug(all);
242
+ validateParents(all, bySlug);
243
+ resolveVariants(all, bySlug);
244
+ resolveNodeChildren(all, bySlug);
245
+ propagateRoles(all);
246
+ assignPrimary(all);
247
+ const roleHomes = buildRoleHomes(all, bySlug);
248
+ applyClaims(all, bySlug);
249
+ const roots = all.filter((n) => !n.parents[0]);
250
+ return { all, bySlug, roots, roleHomes };
251
+ };
252
+ exports.buildTree = buildTree;
@@ -0,0 +1,7 @@
1
+ import type { FileFacts } from "../facts";
2
+ import type { Arch, ArchChild, ArchNode } from "../architecture";
3
+ import type { Finding, FindingFrom } from "../findings";
4
+ declare const findChild: (children: ArchChild[], seg: string | undefined, isFile: boolean) => ArchChild | null;
5
+ declare const templateNode: (arch: Arch, parentSlug: string, child: ArchChild, relPath: string) => ArchNode | null;
6
+ declare const checkTree: (relPath: string, arch: Arch, out: Finding[], finding: FindingFrom, facts: FileFacts, repoFiles: string[]) => void;
7
+ export { checkTree, findChild, templateNode };
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.templateNode = exports.findChild = exports.checkTree = void 0;
4
+ // Walk a path and report entries the folder does not declare.
5
+ const location_1 = require("../../entities/location");
6
+ const children_1 = require("../../nodes/children");
7
+ const match_1 = require("./match");
8
+ const structure_1 = require("../../report/errorTypes/codes/structure");
9
+ const chooseStructure = structure_1.choose;
10
+ const renderStructure = structure_1.render;
11
+ const buildVars = (match) => ({ path: match.rel, basename: match.seg, ...match.caps });
12
+ const findChild = (children, seg, isFile) => {
13
+ const r = children.filter((c) => c.folder === !isFile && c.re.test(String(seg)));
14
+ return r.length ? r[0] : null;
15
+ };
16
+ exports.findChild = findChild;
17
+ const templateNode = (arch, parentSlug, child, relPath) => {
18
+ const r = arch.nodes.all.filter((n) => n.parents.includes(parentSlug) && n.name === child.name && n.variants.some((v) => v.re.test(relPath)));
19
+ return r.length ? r[r.length - 1] : null;
20
+ };
21
+ exports.templateNode = templateNode;
22
+ // The places the file's roles would put it: at home here, or elsewhere.
23
+ const scanPlaces = (arch, facts, rel) => {
24
+ const ownDir = (0, location_1.dirOf)(rel);
25
+ const homeHere = [];
26
+ const spots = [];
27
+ for (const role of facts?.roles ?? []) {
28
+ const def = arch.codeRoles?.[role];
29
+ if (!def)
30
+ continue;
31
+ const place = (0, location_1.placeFor)(arch, role, rel);
32
+ if (!place)
33
+ continue;
34
+ if (place.path === ownDir || place.path === rel)
35
+ homeHere.push(role);
36
+ else
37
+ spots.push({ role, path: place.path, folder: place.folder, file: place.folder ? null : place.path });
38
+ }
39
+ return { homeHere, spots };
40
+ };
41
+ // What the structure render needs to describe an undeclared entry.
42
+ const structureFactsFor = (match, arch, facts) => {
43
+ const { node } = match;
44
+ const allowed = node.children.map((c) => (c.folder ? `${c.name}/` : c.name));
45
+ // What the folder is FOR, in the reader's words: "a feature holds: …".
46
+ const seen = allowed.length ? ` A \`${node.slug}\` folder holds: ${allowed.map((n) => `\`${n}\``).join(", ")}.` : "";
47
+ const { homeHere, spots } = scanPlaces(arch, facts, match.rel);
48
+ const homeFiles = new Map(spots.filter((sp) => !sp.folder && sp.file === sp.path).map((sp) => [sp.role, sp.path]));
49
+ const dest = spots[0]?.path ?? null;
50
+ const named = node.children.find((c) => !c.folder)?.name ?? "the declared pattern";
51
+ return {
52
+ asDir: match.isFile === false,
53
+ dest,
54
+ duplicate: [...homeFiles.values()][0] ?? null,
55
+ homeHere,
56
+ roles: [...new Set(facts?.roles ?? [])],
57
+ held: [...new Set(spots.map((sp) => sp.role))],
58
+ named,
59
+ seen,
60
+ };
61
+ };
62
+ // The one repair a folder names: the destination box, or the box it leaves.
63
+ const statedFor = (arch, match, verdict, dest) => {
64
+ const destNode = (0, location_1.boxOfPlace)(arch, dest);
65
+ return {
66
+ ask: verdict.ask,
67
+ message: verdict.message,
68
+ fix: verdict.fix,
69
+ to: destNode ? [destNode] : [],
70
+ path: dest,
71
+ from: destNode ? null : (0, location_1.boxOfPlace)(arch, match.rel) ?? match.node.slug ?? null,
72
+ };
73
+ };
74
+ // The entry is not declared here: say where it belongs, in pictures and words.
75
+ const reportUndeclared = (...args) => {
76
+ const [match, out, findingFrom, arch, facts, repoFiles] = args;
77
+ const { node } = match;
78
+ if (node.variants.some((v) => v.isFile))
79
+ return;
80
+ const hasRequired = node.children.some((c) => c.required);
81
+ if (repoFiles && hasRequired && node.required !== true && (0, children_1.missingRequiredChild)(node, arch, match.rel, { repoFiles, concreteFolder: location_1.fillTemplate }))
82
+ return;
83
+ const factsOfStructure = structureFactsFor(match, arch, facts);
84
+ const verdict = renderStructure(chooseStructure(factsOfStructure), factsOfStructure);
85
+ const stated = statedFor(arch, match, verdict, factsOfStructure.dest);
86
+ out.push(findingFrom({ key: "closed", report: node.report ?? stated }, "nodes", node.slug, `nodes:${node.slug}:closed`, buildVars(match)));
87
+ };
88
+ const checkEntry = (...args) => {
89
+ const [match, child, out, findingFrom, arch, facts, repoFiles] = args;
90
+ if (child && child.forbidden) {
91
+ out.push(findingFrom({ key: "forbidden", report: child.report }, "nodes", match.node.slug, `nodes:${match.node.slug}:forbidden`, buildVars(match)));
92
+ return;
93
+ }
94
+ if (!child)
95
+ reportUndeclared(match, out, findingFrom, arch, facts, repoFiles);
96
+ };
97
+ const checkTree = (...args) => {
98
+ const [relPath, arch, out, finding, facts, repoFiles] = args;
99
+ const match = (0, match_1.deepestMatch)(relPath, arch);
100
+ if (!match)
101
+ return;
102
+ const m = match.node.prefixRe.exec(relPath);
103
+ const rest = m?.[match.node.prefixNames.length + 2];
104
+ const parts = rest == null ? [match.seg] : [match.seg, ...rest.split("/")];
105
+ let node = match.node;
106
+ for (let idx = 0; idx < parts.length; idx += 1) {
107
+ const seg = parts[idx];
108
+ const last = idx === parts.length - 1;
109
+ const child = findChild(node.children, seg, last);
110
+ checkEntry({ node, seg, isFile: last, caps: match.caps, rel: relPath }, child, out, finding, arch, facts, repoFiles);
111
+ if (!child) {
112
+ node = null;
113
+ break;
114
+ }
115
+ node = child.slug ? arch.nodes.bySlug[child.slug] ?? null : templateNode(arch, node.slug, child, relPath);
116
+ if (!node)
117
+ break;
118
+ }
119
+ };
120
+ exports.checkTree = checkTree;
@@ -0,0 +1,6 @@
1
+ import { buildTree } from "./build";
2
+ import { matchNode, deepestMatch, folderOwner, instanceAt, ancestorsAreReal, targetCapsFor } from "./match";
3
+ import { checkTree } from "./entries";
4
+ import type { Arch } from "../architecture";
5
+ declare const matchers: (arch: Arch) => ((rel: string) => boolean);
6
+ export { buildTree, checkTree, matchers, matchNode, deepestMatch, folderOwner, instanceAt, targetCapsFor, ancestorsAreReal };
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ancestorsAreReal = exports.targetCapsFor = exports.instanceAt = exports.folderOwner = exports.deepestMatch = exports.matchNode = exports.matchers = exports.checkTree = exports.buildTree = void 0;
4
+ // The tree: where files may live. build.js, match.js, entries.js.
5
+ const build_1 = require("./build");
6
+ Object.defineProperty(exports, "buildTree", { enumerable: true, get: function () { return build_1.buildTree; } });
7
+ const match_1 = require("./match");
8
+ Object.defineProperty(exports, "matchNode", { enumerable: true, get: function () { return match_1.matchNode; } });
9
+ Object.defineProperty(exports, "deepestMatch", { enumerable: true, get: function () { return match_1.deepestMatch; } });
10
+ Object.defineProperty(exports, "folderOwner", { enumerable: true, get: function () { return match_1.folderOwner; } });
11
+ Object.defineProperty(exports, "instanceAt", { enumerable: true, get: function () { return match_1.instanceAt; } });
12
+ Object.defineProperty(exports, "ancestorsAreReal", { enumerable: true, get: function () { return match_1.ancestorsAreReal; } });
13
+ Object.defineProperty(exports, "targetCapsFor", { enumerable: true, get: function () { return match_1.targetCapsFor; } });
14
+ const entries_1 = require("./entries");
15
+ Object.defineProperty(exports, "checkTree", { enumerable: true, get: function () { return entries_1.checkTree; } });
16
+ const matchers = (arch) => {
17
+ const nodeRes = arch.nodes.all.flatMap((n) => n.variants.map((v) => v.re));
18
+ const invGlobs = arch.invariants.map((i) => i.where).filter((w) => Array.isArray(w) && w.length > 0);
19
+ return (rel) => nodeRes.some((re) => re.test(rel)) || invGlobs.some((globs) => globs.some((g) => (g.re ? g.re.test(rel) : false)));
20
+ };
21
+ exports.matchers = matchers;
@@ -0,0 +1,17 @@
1
+ import type { Arch, ArchNode } from "../architecture";
2
+ type Caps = Record<string, string | undefined>;
3
+ type NodeMatch = {
4
+ node: ArchNode;
5
+ seg: string | undefined;
6
+ caps: Caps;
7
+ };
8
+ declare const matchNode: (node: ArchNode, relPath: string) => NodeMatch | null;
9
+ declare const ancestorsAreReal: (node: ArchNode, relPath: string, arch: Arch) => boolean;
10
+ declare const allMatches: (relPath: string, arch: Arch) => NodeMatch[];
11
+ declare const folderOwner: (arch: Arch, folder: string | null | undefined) => ArchNode | null;
12
+ declare const instanceAt: (arch: Arch, slug: string, folder: string | null | undefined) => boolean;
13
+ declare const deepestMatch: (relPath: string, arch: Arch) => NodeMatch | null;
14
+ declare const placeholderPositions: (arch: Arch) => Record<string, number>;
15
+ declare const targetCapsFor: (relPath: string, arch: Arch) => Caps;
16
+ export { matchNode, deepestMatch, folderOwner, instanceAt, ancestorsAreReal, placeholderPositions, targetCapsFor, allMatches };
17
+ export type { NodeMatch, Caps };
@@ -0,0 +1,176 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.allMatches = exports.targetCapsFor = exports.placeholderPositions = exports.ancestorsAreReal = exports.instanceAt = exports.folderOwner = exports.deepestMatch = exports.matchNode = void 0;
27
+ // A path → the node it is, and whether that node is really an instance there.
28
+ const fs = __importStar(require("node:fs"));
29
+ const path = __importStar(require("node:path"));
30
+ const children_1 = require("../../nodes/children");
31
+ const matchNode = (node, relPath) => {
32
+ for (const v of node.variants) {
33
+ const m = v.re.exec(relPath);
34
+ if (!m)
35
+ continue;
36
+ const claim = v.claims?.find((c) => (v.names[c.index] != null) && m[c.index + 1] === c.value);
37
+ if (claim)
38
+ continue;
39
+ const seg = v.isFile ? relPath.split("/").pop() : m[v.names.length + 1];
40
+ return { node: { ...node, path: v.path, prefixRe: v.re, prefixNames: v.names, literalLen: v.literalLen, isFile: v.isFile }, seg, caps: Object.fromEntries(v.names.map((nm, i) => [nm, m[i + 1]])) };
41
+ }
42
+ return null;
43
+ };
44
+ exports.matchNode = matchNode;
45
+ const instanceCache = new WeakMap();
46
+ const isRealInstance = (node, folder, arch) => {
47
+ const required = (node.children ?? []).filter((c) => c.required);
48
+ if (!required.length)
49
+ return true;
50
+ const root = arch?.repoRoot;
51
+ if (!arch || !root || !folder)
52
+ return true;
53
+ let byFolder = instanceCache.get(arch);
54
+ if (!byFolder) {
55
+ byFolder = new Map();
56
+ instanceCache.set(arch, byFolder);
57
+ }
58
+ const key = `${node.slug}::${folder}`;
59
+ const cached = byFolder.get(key);
60
+ if (cached !== undefined)
61
+ return cached;
62
+ const present = (child) => {
63
+ try {
64
+ if (!child.name)
65
+ return false;
66
+ const abs = path.join(root, folder, child.name);
67
+ const st = fs.statSync(abs);
68
+ return child.folder ? st.isDirectory() : st.isFile();
69
+ }
70
+ catch {
71
+ return false;
72
+ }
73
+ };
74
+ const ok = required.every(present);
75
+ byFolder.set(key, ok);
76
+ return ok;
77
+ };
78
+ const ancestorsAreReal = (node, relPath, arch) => {
79
+ const segs = String(relPath).split("/");
80
+ const seen = new Set();
81
+ const walk = (n) => {
82
+ for (const slug of n.parents) {
83
+ if (slug == null)
84
+ continue;
85
+ const parent = arch.nodes.bySlug[slug];
86
+ if (!parent || seen.has(slug))
87
+ continue;
88
+ seen.add(slug);
89
+ const variant = parent.variants.find((v) => v.re.test(relPath));
90
+ if (variant && (parent.children ?? []).some((c) => c.required)) {
91
+ const folder = segs.slice(0, variant.path.split("/").length).join("/");
92
+ if (!isRealInstance(parent, folder, arch))
93
+ return false;
94
+ }
95
+ if (!walk(parent))
96
+ return false;
97
+ }
98
+ return true;
99
+ };
100
+ return walk(node);
101
+ };
102
+ exports.ancestorsAreReal = ancestorsAreReal;
103
+ const allMatches = (relPath, arch) => {
104
+ const found = [];
105
+ for (const n of arch.nodes.all) {
106
+ if (!n.variants.some((v) => v.re.test(relPath)))
107
+ continue;
108
+ if (!ancestorsAreReal(n, relPath, arch))
109
+ continue;
110
+ const m = matchNode(n, relPath);
111
+ if (m)
112
+ found.push(m);
113
+ }
114
+ found.sort((a, b) => a.node.literalLen - b.node.literalLen || a.node.path.length - b.node.path.length);
115
+ return found;
116
+ };
117
+ exports.allMatches = allMatches;
118
+ const folderOwner = (arch, folder) => {
119
+ if (!folder)
120
+ return null;
121
+ const hits = arch.nodes.all
122
+ .filter((n) => n.variants.some((v) => (0, children_1.nodePathRe)(v.path).test(folder)))
123
+ .sort((a, b) => a.literalLen - b.literalLen || a.path.length - b.path.length);
124
+ return hits.length ? hits[hits.length - 1] : null;
125
+ };
126
+ exports.folderOwner = folderOwner;
127
+ const instanceAt = (arch, slug, folder) => {
128
+ if (!folder)
129
+ return false;
130
+ const owner = folderOwner(arch, folder);
131
+ if (owner?.slug !== slug)
132
+ return false;
133
+ return isRealInstance(owner, folder, arch);
134
+ };
135
+ exports.instanceAt = instanceAt;
136
+ const deepestMatch = (relPath, arch) => {
137
+ const r = allMatches(relPath, arch);
138
+ return r.length ? r[r.length - 1] : null;
139
+ };
140
+ exports.deepestMatch = deepestMatch;
141
+ const placeholderPositions = (arch) => {
142
+ const pos = {};
143
+ const globs = [];
144
+ for (const role of Object.values(arch.codeRoles)) {
145
+ for (const entry of Object.values(role.actions).flatMap((a) => a.where ?? [])) {
146
+ if (entry.type === "glob" && entry.glob != null)
147
+ globs.push(entry.glob);
148
+ }
149
+ }
150
+ for (const glob of globs) {
151
+ glob.split("/").forEach((seg, i) => {
152
+ const m = seg.match(/^\{([\w-]+)\}$/);
153
+ if (!m)
154
+ return;
155
+ if (pos[m[1]] == null)
156
+ pos[m[1]] = i;
157
+ else if (pos[m[1]] !== i)
158
+ pos[m[1]] = -1; // not positional
159
+ });
160
+ }
161
+ return pos;
162
+ };
163
+ exports.placeholderPositions = placeholderPositions;
164
+ const targetCapsFor = (relPath, arch) => {
165
+ const caps = allMatches(relPath, arch).reduce((acc, m) => ({ ...acc, ...m.caps }), {});
166
+ const segs = relPath.split("/");
167
+ for (const [nm, idx] of Object.entries(placeholderPositions(arch))) {
168
+ if (idx > 0 && !(nm in caps)) {
169
+ const seg = segs[idx];
170
+ if (seg != null && !seg.includes("{"))
171
+ caps[nm] = seg;
172
+ }
173
+ }
174
+ return caps;
175
+ };
176
+ exports.targetCapsFor = targetCapsFor;
@@ -0,0 +1,7 @@
1
+ import type { Candidate } from "../../entities/facts";
2
+ import type { FacetContext } from "../facet";
3
+ declare const id = "angular";
4
+ declare const enrich: (candidates: Candidate[]) => Candidate[];
5
+ declare const applies: ({ rel, text }: FacetContext) => boolean;
6
+ declare const classAttributes: string[];
7
+ export { id, applies, classAttributes, enrich };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.enrich = exports.classAttributes = exports.applies = exports.id = void 0;
4
+ const id = "angular";
5
+ exports.id = id;
6
+ const enrich = (candidates) => {
7
+ for (const candidate of candidates) {
8
+ candidate.framework = { id, component: false, props: [], forwarded: [] };
9
+ }
10
+ return candidates;
11
+ };
12
+ exports.enrich = enrich;
13
+ // A template writes the class list into `class`, like HTML does.
14
+ const applies = ({ rel, text }) => /\.component\.ts$/i.test(String(rel ?? "")) || /@Component\s*\(/.test(String(text ?? ""));
15
+ exports.applies = applies;
16
+ const classAttributes = ["class"];
17
+ exports.classAttributes = classAttributes;
@@ -0,0 +1,16 @@
1
+ import type { SourceFile } from "ts-morph";
2
+ import type { Candidate } from "../entities/facts";
3
+ type FacetContext = {
4
+ rel?: string | null;
5
+ sf?: SourceFile;
6
+ text?: string | null;
7
+ repoRoot?: string | null;
8
+ importMap?: ReadonlyMap<string, string>;
9
+ };
10
+ interface FrameworkFacet {
11
+ id: string;
12
+ applies: (ctx: FacetContext) => boolean;
13
+ enrich: (candidates: Candidate[], ctx: FacetContext) => Candidate[];
14
+ classAttributes?: string[];
15
+ }
16
+ export type { FacetContext, FrameworkFacet };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ import type { Candidate } from "../entities/facts";
2
+ import type { FacetContext, FrameworkFacet } from "./facet";
3
+ declare const REGISTRY: Record<string, () => FrameworkFacet>;
4
+ declare const facets: () => FrameworkFacet[];
5
+ declare const enrich: (candidates: Candidate[], ctx: FacetContext) => Candidate[];
6
+ declare const classAttributes: () => Set<string>;
7
+ declare const resetFacets: () => void;
8
+ export { enrich, facets, classAttributes, resetFacets, REGISTRY };
9
+ export type { FacetContext, FrameworkFacet };