@md-code/follow-architecture 0.3.0 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (382) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1341 -472
  3. package/dist/args.d.ts +4 -0
  4. package/dist/args.js +18 -1
  5. package/dist/bin/follow-architecture.js +3 -3
  6. package/dist/closure-project.d.ts +4 -0
  7. package/dist/closure-project.js +122 -0
  8. package/dist/code-entities/classify.d.ts +11 -0
  9. package/dist/code-entities/classify.js +45 -0
  10. package/dist/code-entities/connector.d.ts +8 -0
  11. package/dist/code-entities/connector.js +119 -0
  12. package/dist/code-entities/entities.d.ts +9 -0
  13. package/dist/{code-roles/roles.js → code-entities/entities.js} +81 -54
  14. package/dist/code-entities/project.d.ts +21 -0
  15. package/dist/code-entities/project.js +249 -0
  16. package/dist/code-entities/walk.d.ts +31 -0
  17. package/dist/code-entities/walk.js +95 -0
  18. package/dist/config-options.d.ts +23 -0
  19. package/dist/config-options.js +18 -1
  20. package/dist/config-project.js +10 -2
  21. package/dist/config-report.d.ts +1 -1
  22. package/dist/config-report.js +20 -3
  23. package/dist/config-rule.d.ts +25 -0
  24. package/dist/config-rule.js +89 -6
  25. package/dist/config-state.d.ts +14 -3
  26. package/dist/config-state.js +180 -17
  27. package/dist/config.d.ts +25 -0
  28. package/dist/css/index.d.ts +11 -7
  29. package/dist/css/index.js +124 -23
  30. package/dist/css/syntax/css/gate.js +5 -5
  31. package/dist/css/syntax/css/index.d.ts +1 -1
  32. package/dist/css/syntax/css/index.js +1 -1
  33. package/dist/css/syntax/css/reference.d.ts +1 -1
  34. package/dist/css/syntax/css/reference.js +15 -3
  35. package/dist/css/syntax/language.d.ts +1 -1
  36. package/dist/css/syntax/language.js +4 -2
  37. package/dist/css/syntax/scss/index.d.ts +2 -2
  38. package/dist/css/syntax/scss/index.js +1 -1
  39. package/dist/css/syntax/scss/reference.d.ts +1 -1
  40. package/dist/css/syntax/scss/reference.js +7 -1
  41. package/dist/css/syntax/styled/document.d.ts +3 -3
  42. package/dist/css/syntax/styled/document.js +17 -7
  43. package/dist/css/syntax/styled/markup.d.ts +1 -1
  44. package/dist/css/syntax/styled/markup.js +22 -14
  45. package/dist/css/syntax/styled/tags.d.ts +2 -0
  46. package/dist/css/syntax/styled/tags.js +22 -0
  47. package/dist/css/syntax/styled/template.js +10 -4
  48. package/dist/css/syntax/tailwind/tailwind.js +4 -4
  49. package/dist/css/value/check.d.ts +1 -1
  50. package/dist/css/value/check.js +1 -1
  51. package/dist/css/value/expression/arithmetic.d.ts +2 -2
  52. package/dist/css/value/expression/arithmetic.js +7 -3
  53. package/dist/css/value/expression/block.d.ts +2 -2
  54. package/dist/css/value/expression/block.js +4 -3
  55. package/dist/css/value/expression/conditional.d.ts +2 -2
  56. package/dist/css/value/expression/conditional.js +1 -1
  57. package/dist/css/value/expression/index.d.ts +2 -2
  58. package/dist/css/value/expression/index.js +10 -6
  59. package/dist/css/value/expression/map.d.ts +2 -2
  60. package/dist/css/value/expression/map.js +2 -2
  61. package/dist/css/value/object/index.d.ts +2 -2
  62. package/dist/css/value/object/index.js +14 -4
  63. package/dist/css/value/object/members.d.ts +2 -2
  64. package/dist/css/value/object/node.js +9 -4
  65. package/dist/css/value/object/path.d.ts +3 -3
  66. package/dist/css/value/object/path.js +10 -4
  67. package/dist/css/value/pieces.d.ts +3 -3
  68. package/dist/css/value/pieces.js +14 -4
  69. package/dist/css/value/resolve.js +15 -5
  70. package/dist/css/value/scope.d.ts +3 -2
  71. package/dist/css/value/scope.js +25 -7
  72. package/dist/css/value/substitute.js +43 -11
  73. package/dist/entities/architecture.d.ts +28 -25
  74. package/dist/entities/ast/assignments-raw.d.ts +1 -1
  75. package/dist/entities/ast/assignments-raw.js +61 -8
  76. package/dist/entities/ast/assignments-tagged.d.ts +1 -1
  77. package/dist/entities/ast/assignments-tagged.js +22 -7
  78. package/dist/entities/ast/assignments.d.ts +1 -1
  79. package/dist/entities/ast/assignments.js +6 -4
  80. package/dist/entities/ast/branches.d.ts +1 -1
  81. package/dist/entities/ast/calls.d.ts +1 -1
  82. package/dist/entities/ast/calls.js +19 -3
  83. package/dist/entities/ast/classes.d.ts +1 -1
  84. package/dist/entities/ast/classes.js +5 -1
  85. package/dist/entities/ast/comments.d.ts +3 -2
  86. package/dist/entities/ast/comments.js +47 -17
  87. package/dist/entities/ast/declaration.d.ts +1 -1
  88. package/dist/entities/ast/depth.d.ts +2 -2
  89. package/dist/entities/ast/depth.js +15 -8
  90. package/dist/entities/ast/enums.d.ts +1 -1
  91. package/dist/entities/ast/export-chain.d.ts +15 -0
  92. package/dist/entities/ast/export-chain.js +171 -0
  93. package/dist/entities/ast/file-exports.d.ts +1 -1
  94. package/dist/entities/ast/file-exports.js +26 -3
  95. package/dist/entities/ast/file-facts.d.ts +6 -3
  96. package/dist/entities/ast/file-facts.js +33 -4
  97. package/dist/entities/ast/file-imports.d.ts +1 -1
  98. package/dist/entities/ast/file-imports.js +26 -3
  99. package/dist/entities/ast/file.d.ts +2 -2
  100. package/dist/entities/ast/file.js +2 -1
  101. package/dist/entities/ast/functions.d.ts +1 -1
  102. package/dist/entities/ast/functions.js +13 -4
  103. package/dist/entities/ast/heritage.d.ts +1 -1
  104. package/dist/entities/ast/heritage.js +9 -1
  105. package/dist/entities/ast/index.d.ts +6 -3
  106. package/dist/entities/ast/index.js +82 -26
  107. package/dist/entities/ast/kind.d.ts +1 -1
  108. package/dist/entities/ast/kind.js +7 -1
  109. package/dist/entities/ast/modifiers.d.ts +1 -1
  110. package/dist/entities/ast/modifiers.js +4 -4
  111. package/dist/entities/ast/project.js +33 -2
  112. package/dist/entities/ast/properties.d.ts +1 -1
  113. package/dist/entities/ast/properties.js +10 -5
  114. package/dist/entities/ast/resolve.d.ts +1 -1
  115. package/dist/entities/ast/resolve.js +4 -4
  116. package/dist/entities/ast/tree.d.ts +4 -2
  117. package/dist/entities/ast/tree.js +184 -17
  118. package/dist/entities/ast/types.d.ts +1 -1
  119. package/dist/entities/ast/types.js +2 -1
  120. package/dist/entities/ast/usage.d.ts +1 -1
  121. package/dist/entities/ast/usage.js +1 -1
  122. package/dist/entities/ast/variables.d.ts +1 -1
  123. package/dist/entities/context.d.ts +4 -4
  124. package/dist/entities/facts.d.ts +36 -13
  125. package/dist/entities/findings.d.ts +3 -3
  126. package/dist/entities/kinds.d.ts +1 -1
  127. package/dist/entities/kinds.js +131 -30
  128. package/dist/entities/location/homes.d.ts +10 -10
  129. package/dist/entities/location/homes.js +74 -48
  130. package/dist/entities/location/place.d.ts +1 -1
  131. package/dist/entities/location/place.js +10 -3
  132. package/dist/entities/location/where.d.ts +8 -6
  133. package/dist/entities/location/where.js +79 -30
  134. package/dist/entities/location.d.ts +3 -3
  135. package/dist/entities/location.js +17 -17
  136. package/dist/entities/operators.js +1 -1
  137. package/dist/entities/overview/data.d.ts +6 -6
  138. package/dist/entities/overview/decision.d.ts +11 -11
  139. package/dist/entities/overview/finding.d.ts +10 -10
  140. package/dist/entities/overview/graph.d.ts +28 -11
  141. package/dist/entities/overview/input.d.ts +2 -2
  142. package/dist/entities/overview/summaries.d.ts +17 -15
  143. package/dist/entities/queries.d.ts +1 -1
  144. package/dist/entities/queries.js +72 -12
  145. package/dist/entities/repair.d.ts +1 -1
  146. package/dist/entities/repair.js +8 -2
  147. package/dist/entities/schema.d.ts +17 -3
  148. package/dist/entities/schema.js +74 -16
  149. package/dist/entities/story.d.ts +5 -5
  150. package/dist/entities/structure-facts.d.ts +1 -1
  151. package/dist/entities/token.d.ts +4 -4
  152. package/dist/entities/tree/build.d.ts +4 -3
  153. package/dist/entities/tree/build.js +95 -44
  154. package/dist/entities/tree/entries.d.ts +3 -3
  155. package/dist/entities/tree/entries.js +41 -16
  156. package/dist/entities/tree/index.d.ts +2 -2
  157. package/dist/entities/tree/index.js +1 -1
  158. package/dist/entities/tree/match.d.ts +2 -2
  159. package/dist/entities/tree/match.js +9 -5
  160. package/dist/fa-index.d.ts +16 -0
  161. package/dist/fa-index.js +165 -0
  162. package/dist/fa-open.d.ts +51 -0
  163. package/dist/fa-open.js +232 -0
  164. package/dist/fa-store.d.ts +22 -0
  165. package/dist/fa-store.js +222 -0
  166. package/dist/fa-values.d.ts +37 -0
  167. package/dist/fa-values.js +104 -0
  168. package/dist/facts-record.d.ts +45 -0
  169. package/dist/facts-record.js +287 -0
  170. package/dist/frameworks/angular/index.d.ts +2 -2
  171. package/dist/frameworks/angular/index.js +2 -1
  172. package/dist/frameworks/facet.d.ts +3 -1
  173. package/dist/frameworks/facet.js +13 -0
  174. package/dist/frameworks/index.d.ts +1 -1
  175. package/dist/frameworks/index.js +8 -4
  176. package/dist/frameworks/react/index.d.ts +2 -2
  177. package/dist/frameworks/react/index.js +33 -10
  178. package/dist/frameworks/test/index.d.ts +6 -0
  179. package/dist/frameworks/test/index.js +157 -0
  180. package/dist/frameworks/vue/index.d.ts +2 -2
  181. package/dist/frameworks/vue/index.js +2 -1
  182. package/dist/ignore.d.ts +3 -0
  183. package/dist/ignore.js +48 -0
  184. package/dist/index-file.d.ts +43 -0
  185. package/dist/index-file.js +218 -0
  186. package/dist/index-run.d.ts +39 -0
  187. package/dist/index-run.js +217 -0
  188. package/dist/index-zone.d.ts +25 -0
  189. package/dist/index-zone.js +209 -0
  190. package/dist/main.d.ts +5 -2
  191. package/dist/main.js +207 -34
  192. package/dist/nodes/child-entities.d.ts +3 -0
  193. package/dist/nodes/child-entities.js +12 -0
  194. package/dist/nodes/children.d.ts +4 -4
  195. package/dist/nodes/children.js +54 -11
  196. package/dist/nodes/finally/emit.d.ts +3 -3
  197. package/dist/nodes/finally/emit.js +26 -10
  198. package/dist/nodes/finally/entities.d.ts +13 -0
  199. package/dist/nodes/finally/entities.js +42 -0
  200. package/dist/nodes/finally/index.d.ts +6 -6
  201. package/dist/nodes/finally/index.js +8 -8
  202. package/dist/nodes/finally/queries.d.ts +2 -2
  203. package/dist/nodes/finally/queries.js +7 -4
  204. package/dist/nodes/finally/relations-access.d.ts +2 -2
  205. package/dist/nodes/finally/relations-access.js +22 -18
  206. package/dist/nodes/finally/relations-edge.d.ts +5 -5
  207. package/dist/nodes/finally/relations-edge.js +67 -44
  208. package/dist/nodes/finally/relations-group.d.ts +7 -7
  209. package/dist/nodes/finally/relations-group.js +28 -25
  210. package/dist/nodes/finally/relations.d.ts +2 -2
  211. package/dist/nodes/finally/relations.js +16 -12
  212. package/dist/nodes/finally/required.d.ts +3 -3
  213. package/dist/nodes/finally/required.js +9 -7
  214. package/dist/nodes/finally/violation.d.ts +2 -2
  215. package/dist/nodes/similar.d.ts +3 -3
  216. package/dist/nodes/similar.js +61 -49
  217. package/dist/piece-forms.d.ts +9 -0
  218. package/dist/piece-forms.js +68 -0
  219. package/dist/{pipeline-roles.d.ts → pipeline-entities.d.ts} +2 -2
  220. package/dist/{pipeline-roles.js → pipeline-entities.js} +32 -28
  221. package/dist/pipeline-facts.d.ts +4 -3
  222. package/dist/pipeline-facts.js +47 -55
  223. package/dist/{pipeline-unroled.d.ts → pipeline-unclassified.d.ts} +2 -2
  224. package/dist/{pipeline-unroled.js → pipeline-unclassified.js} +58 -63
  225. package/dist/pipeline.js +19 -64
  226. package/dist/release-file.d.ts +3 -0
  227. package/dist/release-file.js +13 -0
  228. package/dist/report/asks.d.ts +3 -3
  229. package/dist/report/asks.js +16 -6
  230. package/dist/report/configErrors.d.ts +55 -27
  231. package/dist/report/configErrors.js +81 -35
  232. package/dist/report/errorTypes/codes/structure.d.ts +1 -1
  233. package/dist/report/errorTypes/codes/structure.js +9 -9
  234. package/dist/report/errorTypes/decision-maker.d.ts +5 -5
  235. package/dist/report/errorTypes/decision-maker.js +4 -4
  236. package/dist/report/errorTypes/destinations.d.ts +5 -5
  237. package/dist/report/errorTypes/destinations.js +52 -34
  238. package/dist/report/errorTypes/finding-type.d.ts +3 -3
  239. package/dist/report/errorTypes/index.d.ts +1 -1
  240. package/dist/report/errorTypes/types/fileContents.d.ts +4 -4
  241. package/dist/report/errorTypes/types/fileContents.js +11 -5
  242. package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
  243. package/dist/report/errorTypes/types/{unknownRole.js → unknownEntity.js} +12 -7
  244. package/dist/report/errorTypes/types/wrongAction.d.ts +5 -5
  245. package/dist/report/errorTypes/types/wrongAction.js +18 -13
  246. package/dist/report/errorTypes/types/wrongPlacement.d.ts +4 -4
  247. package/dist/report/errorTypes/types/wrongPlacement.js +19 -9
  248. package/dist/report/errorTypes/vocabulary/ids.d.ts +2 -2
  249. package/dist/report/errorTypes/vocabulary/ids.js +3 -3
  250. package/dist/report/errorTypes/vocabulary/phrases.d.ts +2 -2
  251. package/dist/report/errorTypes/vocabulary/phrases.js +39 -26
  252. package/dist/report/errorTypes/vocabulary/places.d.ts +3 -3
  253. package/dist/report/errorTypes/vocabulary/places.js +13 -13
  254. package/dist/report/finding-from.d.ts +3 -3
  255. package/dist/report/finding-from.js +14 -9
  256. package/dist/report/notices.d.ts +6 -1
  257. package/dist/report/notices.js +46 -20
  258. package/dist/report/observed.d.ts +19 -0
  259. package/dist/report/observed.js +87 -0
  260. package/dist/report/render-report.d.ts +1 -1
  261. package/dist/report/render-report.js +33 -30
  262. package/dist/report/user-report/build/bundle.js +9 -0
  263. package/dist/report/user-report/build/bundle.prebuilt.js +799 -297
  264. package/dist/report/user-report/data/collect.d.ts +2 -2
  265. package/dist/report/user-report/data/collect.js +15 -12
  266. package/dist/report/user-report/data/entities.d.ts +7 -0
  267. package/dist/report/user-report/data/{roles.js → entities.js} +27 -22
  268. package/dist/report/user-report/data/{role-examples.d.ts → entity-examples.d.ts} +3 -3
  269. package/dist/report/user-report/data/entity-examples.js +126 -0
  270. package/dist/report/user-report/data/{role-filters.d.ts → entity-filters.d.ts} +2 -2
  271. package/dist/report/user-report/data/{role-filters.js → entity-filters.js} +7 -7
  272. package/dist/report/user-report/data/entity-marks.d.ts +5 -0
  273. package/dist/report/user-report/data/{role-marks.js → entity-marks.js} +11 -11
  274. package/dist/report/user-report/data/file-tree.d.ts +3 -3
  275. package/dist/report/user-report/data/file-tree.js +13 -5
  276. package/dist/report/user-report/data/finding-boundary.d.ts +4 -4
  277. package/dist/report/user-report/data/finding-boundary.js +2 -2
  278. package/dist/report/user-report/data/finding-plan.d.ts +5 -5
  279. package/dist/report/user-report/data/finding-plan.js +10 -10
  280. package/dist/report/user-report/data/finding-title.d.ts +2 -2
  281. package/dist/report/user-report/data/finding-title.js +8 -8
  282. package/dist/report/user-report/data/findings.d.ts +4 -4
  283. package/dist/report/user-report/data/findings.js +30 -20
  284. package/dist/report/user-report/data/graph-edges.d.ts +4 -4
  285. package/dist/report/user-report/data/graph-edges.js +19 -19
  286. package/dist/report/user-report/data/graph-entities.d.ts +6 -0
  287. package/dist/report/user-report/data/graph-entities.js +158 -0
  288. package/dist/report/user-report/data/graph-helpers.d.ts +5 -5
  289. package/dist/report/user-report/data/graph-helpers.js +15 -15
  290. package/dist/report/user-report/data/graph.d.ts +5 -4
  291. package/dist/report/user-report/data/graph.js +28 -21
  292. package/dist/report/user-report/data/nodes.d.ts +2 -2
  293. package/dist/report/user-report/data/nodes.js +16 -16
  294. package/dist/report/user-report/data/rules.d.ts +7 -0
  295. package/dist/report/user-report/data/{invariants.js → rules.js} +13 -13
  296. package/dist/report/user-report/data/scan.d.ts +1 -1
  297. package/dist/report/user-report/data/scan.js +2 -2
  298. package/dist/report/user-report/html/shell.d.ts +1 -1
  299. package/dist/report/user-report/html/shell.js +1 -1
  300. package/dist/report/user-report/index.d.ts +1 -1
  301. package/dist/report/user-report/shared/describe.d.ts +1 -1
  302. package/dist/report/user-report/shared/describe.js +6 -6
  303. package/dist/rules/index.d.ts +7 -0
  304. package/dist/{invariants → rules}/index.js +85 -57
  305. package/dist/{invariants → rules}/list-vars.d.ts +2 -2
  306. package/dist/{invariants → rules}/list-vars.js +9 -3
  307. package/dist/{invariants → rules}/name.js +2 -2
  308. package/dist/rules/normalize.d.ts +5 -0
  309. package/dist/{invariants → rules}/normalize.js +35 -32
  310. package/dist/{invariants → rules}/vars.d.ts +9 -7
  311. package/dist/{invariants → rules}/vars.js +5 -5
  312. package/dist/scan-run.d.ts +20 -0
  313. package/dist/scan-run.js +130 -0
  314. package/dist/scripts/audit-report.js +2 -2
  315. package/dist/usage-index.d.ts +4 -0
  316. package/dist/usage-index.js +272 -0
  317. package/dist/usage-mode.d.ts +7 -0
  318. package/dist/usage-mode.js +16 -0
  319. package/dist/usage-pass.d.ts +19 -0
  320. package/dist/usage-pass.js +136 -0
  321. package/dist/usage-prepare.d.ts +2 -0
  322. package/dist/usage-prepare.js +22 -0
  323. package/dist/usage-sweep.d.ts +10 -0
  324. package/dist/usage-sweep.js +254 -0
  325. package/dist/utils/aliases.d.ts +22 -0
  326. package/dist/utils/aliases.js +163 -0
  327. package/dist/utils/classify.d.ts +2 -2
  328. package/dist/utils/classify.js +4 -4
  329. package/dist/utils/distinct.js +4 -2
  330. package/dist/utils/files.js +24 -30
  331. package/dist/utils/fixpoint.js +2 -2
  332. package/dist/utils/host.d.ts +1 -1
  333. package/dist/utils/host.js +4 -1
  334. package/dist/utils/imports.js +66 -12
  335. package/dist/utils/keyed.js +2 -2
  336. package/dist/utils/map-record.js +2 -2
  337. package/dist/utils/packages.d.ts +15 -0
  338. package/dist/utils/packages.js +197 -0
  339. package/dist/utils/path-label.js +3 -1
  340. package/dist/utils/pattern.d.ts +5 -4
  341. package/dist/utils/pattern.js +38 -8
  342. package/dist/utils/permission.d.ts +3 -3
  343. package/dist/utils/permission.js +4 -2
  344. package/dist/utils/plural.js +2 -2
  345. package/dist/utils/qualified.js +4 -4
  346. package/dist/utils/rank.js +2 -2
  347. package/dist/utils/record.js +1 -1
  348. package/dist/utils/search.js +7 -2
  349. package/dist/utils/speak.js +1 -1
  350. package/dist/utils/split.js +14 -1
  351. package/dist/utils/template.d.ts +1 -1
  352. package/dist/utils/template.js +1 -1
  353. package/dist/utils/tokenize.js +6 -1
  354. package/dist/utils/typed-field.js +2 -2
  355. package/dist/utils/verdicts.js +1 -1
  356. package/entities/operators.ts +1 -1
  357. package/package.json +101 -90
  358. package/report/errorTypes/vocabulary/ids.ts +7 -2
  359. package/report/errorTypes/vocabulary/phrases.ts +47 -27
  360. package/report/errorTypes/vocabulary/places.ts +21 -16
  361. package/report/user-report/shared/describe.ts +7 -7
  362. package/dist/code-roles/classify.d.ts +0 -11
  363. package/dist/code-roles/classify.js +0 -43
  364. package/dist/code-roles/connector.d.ts +0 -5
  365. package/dist/code-roles/connector.js +0 -114
  366. package/dist/code-roles/project.d.ts +0 -12
  367. package/dist/code-roles/project.js +0 -122
  368. package/dist/code-roles/roles.d.ts +0 -8
  369. package/dist/invariants/index.d.ts +0 -6
  370. package/dist/invariants/normalize.d.ts +0 -4
  371. package/dist/nodes/child-roles.d.ts +0 -3
  372. package/dist/nodes/child-roles.js +0 -12
  373. package/dist/nodes/finally/roles.d.ts +0 -13
  374. package/dist/nodes/finally/roles.js +0 -41
  375. package/dist/report/errorTypes/types/unknownRole.d.ts +0 -9
  376. package/dist/report/user-report/data/graph-roles.d.ts +0 -5
  377. package/dist/report/user-report/data/graph-roles.js +0 -71
  378. package/dist/report/user-report/data/invariants.d.ts +0 -7
  379. package/dist/report/user-report/data/role-examples.js +0 -94
  380. package/dist/report/user-report/data/role-marks.d.ts +0 -5
  381. package/dist/report/user-report/data/roles.d.ts +0 -7
  382. /package/dist/{invariants → rules}/name.d.ts +0 -0
@@ -0,0 +1,22 @@
1
+ import { type Light, type Usage } from "./fa-values";
2
+ import { type Index } from "./fa-open";
3
+ import type { FileRecord } from "@md-code/follow-architecture/facts-record";
4
+ declare const flushChunk: (index: Index) => void;
5
+ declare const keepFacts: (index: Index, file: string, record: FileRecord, light: Light) => boolean;
6
+ declare const keepVerdict: (index: Index, file: string, light: Light) => boolean;
7
+ declare const keepUsage: (index: Index, file: string, usage: Usage) => boolean;
8
+ declare const settle: (index: Index) => void;
9
+ declare const finish: (index: Index) => {
10
+ written: number;
11
+ bytes: number;
12
+ warning: string | null;
13
+ chunks: number;
14
+ compactions: number;
15
+ compactionWarning: string | null;
16
+ };
17
+ declare const compactionLine: (file: string, reason: string) => string;
18
+ declare const prune: (index: Index, keep: readonly string[]) => {
19
+ marked: number;
20
+ dropped: number;
21
+ };
22
+ export { flushChunk, keepFacts, keepVerdict, keepUsage, settle, finish, prune, compactionLine };
@@ -0,0 +1,222 @@
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.compactionLine = exports.prune = exports.finish = exports.settle = exports.keepUsage = exports.keepVerdict = exports.keepFacts = exports.flushChunk = void 0;
27
+ // THE WRITE SIDE OF THE FACTS INDEX: one chunk of values per flush — every
28
+ // section, one lock, one fsync — the light values of the checks, the checker's
29
+ // answers of the usage pass, and the prune that drops the sections of a file that
30
+ // is gone. What is stored and why is described in `fa-index.ts`.
31
+ const fs = __importStar(require("node:fs"));
32
+ const index_cache_1 = require("@md-code/utils/node/index-cache");
33
+ const fa_values_1 = require("./fa-values");
34
+ const fa_open_1 = require("./fa-open");
35
+ const sizeOf = (file) => {
36
+ try {
37
+ return fs.statSync(file).size;
38
+ }
39
+ catch {
40
+ return 0;
41
+ }
42
+ };
43
+ // The stat the value of `file` describes: the one this run's plan took before the
44
+ // file was read. Every queue here is filled from a value that was just computed — a
45
+ // record, a summary, a verdict, an answer — so no value is ever carried over, and
46
+ // none of them may be dated with the file's stat at WRITE time: that stat is newer
47
+ // than the bytes they describe, and a stamp that is too fresh is the staleness this
48
+ // exists to prevent. The fallback is for a file no plan of this run named, which
49
+ // only a file that appeared after the light pass could be (and that file is never
50
+ // queued); it is the weaker guarantee `writeSection` documents, kept for symmetry.
51
+ const stampOf = (index, opened, file) => index.stamps.get(file) ?? opened.handle.liveStat(file);
52
+ // Every section of one chunk, then ONE flush: two writes to the same file would
53
+ // take the lock and fsync twice for values that belong to the same files.
54
+ const writeBoth = (opened, index) => {
55
+ const fileBytesBefore = sizeOf(opened.file);
56
+ const blankBefore = opened.handle.stats().blankBytes;
57
+ let bytes = 0;
58
+ const put = (name, v, entries) => {
59
+ if (entries.length === 0)
60
+ return;
61
+ const section = opened.handle.section(name);
62
+ for (const entry of entries) {
63
+ const value = { v, tool: index.tool, facts: entry.facts };
64
+ const stamp = stampOf(index, opened, entry.path);
65
+ if (stamp !== null) {
66
+ value.m = stamp.mtimeMs;
67
+ value.s = stamp.size;
68
+ }
69
+ section.set(entry.path, value);
70
+ bytes += Buffer.byteLength(JSON.stringify(value), "utf8");
71
+ }
72
+ };
73
+ put(fa_open_1.SECTION_NAME, fa_open_1.SECTION_VERSION, index.pending);
74
+ put(fa_open_1.PEERS_NAME, fa_open_1.PEERS_VERSION, index.peers);
75
+ put(fa_open_1.OUT_NAME, fa_open_1.OUT_VERSION, index.out);
76
+ put(fa_open_1.USAGE_NAME, fa_open_1.USAGE_VERSION, index.usage);
77
+ let compacted = false;
78
+ let blankAfter = blankBefore;
79
+ let warning = null;
80
+ let compactionWarning = null;
81
+ try {
82
+ const flushed = opened.handle.flush();
83
+ compacted = flushed.compacted;
84
+ blankAfter = flushed.blankBytesAfter;
85
+ // The records landed; only the padding they left did not get reclaimed. The
86
+ // reason is carried out as its own sentence, never as a failed write.
87
+ compactionWarning = flushed.compactionWarning;
88
+ }
89
+ catch (error) {
90
+ warning = error instanceof Error ? error.message : String(error);
91
+ }
92
+ return {
93
+ written: index.pending.length,
94
+ dropped: 0,
95
+ bytes,
96
+ fileBytesBefore,
97
+ fileBytesAfter: warning === null ? sizeOf(opened.file) : fileBytesBefore,
98
+ blankBytesBefore: blankBefore,
99
+ blankBytesAfter: blankAfter,
100
+ compacted,
101
+ warning,
102
+ compactionWarning,
103
+ };
104
+ };
105
+ // Hand the pending values to the index and drop the handle: the next access
106
+ // re-reads the file, which is what keeps one chunk of records in heap instead of
107
+ // the whole repo's.
108
+ const flushChunk = (index) => {
109
+ if (index.pending.length === 0 &&
110
+ index.peers.length === 0 &&
111
+ index.out.length === 0 &&
112
+ index.usage.length === 0)
113
+ return;
114
+ const opened = (0, fa_open_1.handleOf)(index);
115
+ if (opened === null)
116
+ return;
117
+ // A record for a file the index has never seen is written with an empty common
118
+ // part (size 0, no hash), and freshness compares THAT: without this stat the
119
+ // record is stale the moment it lands and the next run writes it again. Asking
120
+ // for the status first lets the index record the file's own identity.
121
+ for (const entry of [...index.pending, ...index.peers, ...index.out, ...index.usage])
122
+ opened.handle.status(entry.path);
123
+ const result = writeBoth(opened, index);
124
+ index.pending = [];
125
+ index.peers = [];
126
+ index.out = [];
127
+ index.usage = [];
128
+ index.written += result.written;
129
+ index.bytes += result.bytes;
130
+ index.chunks += 1;
131
+ if (result.compacted)
132
+ index.compactions += 1;
133
+ (0, fa_open_1.takeWarning)(index, result.warning);
134
+ (0, fa_open_1.takeCompactionWarning)(index, result.compactionWarning);
135
+ (0, fa_open_1.endChunk)(index);
136
+ };
137
+ exports.flushChunk = flushChunk;
138
+ const maybeFlush = (index) => {
139
+ if (index.pending.length >= fa_open_1.CHUNK || index.out.length >= fa_open_1.CHUNK || index.usage.length >= fa_open_1.CHUNK)
140
+ flushChunk(index);
141
+ };
142
+ // Store a freshly extracted file: its record, its pieces (their own section, so a
143
+ // run that never names a code entity never decodes them) and the summary a run
144
+ // needs about it before its checks have run (light, `findings: null`). False when
145
+ // this run may not write — the caller then keeps the record in memory.
146
+ const keepFacts = (index, file, record, light) => {
147
+ if (index.refused)
148
+ return false;
149
+ index.pending.push({ path: file, facts: (0, fa_values_1.jsonOf)((0, fa_values_1.slimRecord)(record)) });
150
+ index.peers.push({ path: file, facts: (0, fa_values_1.jsonOf)(record.candidates) });
151
+ index.out.push({ path: file, facts: (0, fa_values_1.jsonOf)(light) });
152
+ maybeFlush(index);
153
+ return true;
154
+ };
155
+ exports.keepFacts = keepFacts;
156
+ // Store one file's verdicts; the record it was derived from is already stored.
157
+ const keepVerdict = (index, file, light) => {
158
+ if (index.refused)
159
+ return false;
160
+ index.out.push({ path: file, facts: (0, fa_values_1.jsonOf)(light) });
161
+ maybeFlush(index);
162
+ return true;
163
+ };
164
+ exports.keepVerdict = keepVerdict;
165
+ // Store the checker's answers for one file — written by the run's usage pass, read
166
+ // by every later check of that file. Small: two numbers and a few paths per name.
167
+ const keepUsage = (index, file, usage) => {
168
+ if (index.refused)
169
+ return false;
170
+ index.usage.push({ path: file, facts: (0, fa_values_1.jsonOf)(usage) });
171
+ maybeFlush(index);
172
+ return true;
173
+ };
174
+ exports.keepUsage = keepUsage;
175
+ // Everything extracted is on disk before the checks read it back: the scan pass
176
+ // asks the index for a record, not for the queue of the extraction.
177
+ const settle = (index) => flushChunk(index);
178
+ exports.settle = settle;
179
+ const finish = (index) => {
180
+ flushChunk(index);
181
+ return {
182
+ written: index.written,
183
+ bytes: index.bytes,
184
+ warning: index.warning,
185
+ chunks: index.chunks,
186
+ compactions: index.compactions,
187
+ compactionWarning: index.compactionWarning,
188
+ };
189
+ };
190
+ exports.finish = finish;
191
+ // One line for a deferred compaction, in the index's own words: the file kept
192
+ // its size, and saying "could not write" would be a lie about records that
193
+ // landed. Reported once per run by the caller that prints the index's story.
194
+ const compactionLine = (file, reason) => `${file}: compaction deferred: ${reason} — the file keeps its size`;
195
+ exports.compactionLine = compactionLine;
196
+ // Drop every section of the files that are gone. A run that has seen the whole
197
+ // file list is the one that can tell, and it must drop the pieces and the verdicts
198
+ // with the record they were derived from: a stale summary would answer for a file
199
+ // that no longer exists.
200
+ const prune = (index, keep) => {
201
+ const opened = (0, fa_open_1.handleOf)(index);
202
+ if (opened === null)
203
+ return { marked: 0, dropped: 0 };
204
+ let marked = 0;
205
+ let dropped = 0;
206
+ let warning = null;
207
+ try {
208
+ for (const name of [fa_open_1.SECTION_NAME, fa_open_1.PEERS_NAME, fa_open_1.OUT_NAME, fa_open_1.USAGE_NAME]) {
209
+ const result = (0, index_cache_1.pruneSection)({ index: opened.handle, name, keep });
210
+ marked = Math.max(marked, result.marked);
211
+ dropped += result.dropped;
212
+ }
213
+ opened.handle.flush();
214
+ }
215
+ catch (error) {
216
+ warning = error instanceof Error ? error.message : String(error);
217
+ }
218
+ (0, fa_open_1.takeWarning)(index, warning);
219
+ (0, fa_open_1.endChunk)(index);
220
+ return { marked, dropped };
221
+ };
222
+ exports.prune = prune;
@@ -0,0 +1,37 @@
1
+ import type { Json } from "@md-code/utils/node/index-cache";
2
+ import type { Candidate, RecordObject, ReferencesFact } from "@md-code/follow-architecture/entities/facts";
3
+ import type { FileRecord, Parts } from "@md-code/follow-architecture/facts-record";
4
+ type Summary = {
5
+ entities: string[];
6
+ objects: RecordObject[];
7
+ deps: string[];
8
+ };
9
+ type Light = {
10
+ findings: Parts | null;
11
+ notices: string[];
12
+ summary: Summary;
13
+ };
14
+ declare const summaryOf: (record: FileRecord) => Summary;
15
+ declare const slimRecord: (record: FileRecord) => FileRecord;
16
+ declare const member: (value: Json | undefined, key: string) => Json | undefined;
17
+ declare const isBag: (value: Json | undefined) => boolean;
18
+ declare const jsonOf: <T>(value: T) => Json;
19
+ declare const looksParts: (value: Json | undefined) => boolean;
20
+ declare const looksRecord: (value: Json) => boolean;
21
+ declare const looksLight: (value: Json) => boolean;
22
+ declare const recordOf: (value: Json) => FileRecord | null;
23
+ declare const candidatesOf: (value: Json) => Candidate[] | null;
24
+ declare const lightOf: (value: Json) => Light | null;
25
+ type UsageAnswer = {
26
+ references: ReferencesFact | null;
27
+ implementations: number | null;
28
+ };
29
+ type Usage = {
30
+ answers: Record<string, UsageAnswer>;
31
+ notices: string[];
32
+ };
33
+ declare const looksUsage: (value: Json) => boolean;
34
+ declare const usageOf: (value: Json) => Usage | null;
35
+ declare const applyUsage: (candidates: readonly Candidate[], usage: Usage | null) => void;
36
+ export type { Light, Summary, Usage, UsageAnswer };
37
+ export { summaryOf, slimRecord, member, isBag, jsonOf, looksParts, looksRecord, looksLight, looksUsage, recordOf, candidatesOf, lightOf, usageOf, applyUsage, };
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.applyUsage = exports.usageOf = exports.lightOf = exports.candidatesOf = exports.recordOf = exports.looksUsage = exports.looksLight = exports.looksRecord = exports.looksParts = exports.jsonOf = exports.isBag = exports.member = exports.slimRecord = exports.summaryOf = void 0;
4
+ // A record, reduced to what answers a question about OTHER files: the literals'
5
+ // places, the entities and the deps.
6
+ const summaryOf = (record) => ({
7
+ entities: [...(record.facts.entities ?? [])],
8
+ objects: record.objects,
9
+ deps: [...record.deps],
10
+ });
11
+ exports.summaryOf = summaryOf;
12
+ // A record without its pieces: the pieces are stored once, in `fa-peers`, and a
13
+ // check puts them back. Two copies of the same list were half the index.
14
+ const slimRecord = (record) => ({ ...record, candidates: [] });
15
+ exports.slimRecord = slimRecord;
16
+ // One member of a JSON value, or undefined when there is none — the shape tests
17
+ // below read a stored value without a single type assertion.
18
+ const member = (value, key) => typeof value === "object" && value !== null && !Array.isArray(value) ? value[key] : undefined;
19
+ exports.member = member;
20
+ const isBag = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
21
+ exports.isBag = isBag;
22
+ // The typed view of a value about to be stored: the index takes plain JSON, and
23
+ // this package compiles without a single type assertion.
24
+ const jsonOf = (value) => {
25
+ const copy = JSON.parse(JSON.stringify(value));
26
+ return copy;
27
+ };
28
+ exports.jsonOf = jsonOf;
29
+ const looksParts = (value) => isBag(value) && ["before", "nodes", "after"].every((name) => Array.isArray(member(value, name)));
30
+ exports.looksParts = looksParts;
31
+ // A heavy value is ours only when it still carries a record. Anything else
32
+ // (another schema, a hand edit, a truncated write) reads as stale.
33
+ const looksRecord = (value) => typeof member(value, "rel") === "string" && Array.isArray(member(value, "deps")) && isBag(member(value, "facts"));
34
+ exports.looksRecord = looksRecord;
35
+ // A light value is ours only when it carries a summary and the verdict slot: a
36
+ // `findings` key that is absent means another schema, one that is null means the
37
+ // facts are stored and the checks have not run against them.
38
+ const looksLight = (value) => {
39
+ if (typeof member(value, "notices") === "undefined")
40
+ return false;
41
+ const findings = member(value, "findings");
42
+ if (findings !== null && findings !== undefined && !looksParts(findings))
43
+ return false;
44
+ const summary = member(value, "summary");
45
+ if (!isBag(summary))
46
+ return false;
47
+ return Array.isArray(member(summary, "deps")) && Array.isArray(member(summary, "entities"));
48
+ };
49
+ exports.looksLight = looksLight;
50
+ const recordOf = (value) => {
51
+ if (!looksRecord(value))
52
+ return null;
53
+ const record = JSON.parse(JSON.stringify(value));
54
+ return record;
55
+ };
56
+ exports.recordOf = recordOf;
57
+ // A file's pieces, read back from their own section: plain data, one file at a time.
58
+ const candidatesOf = (value) => {
59
+ if (!Array.isArray(value))
60
+ return null;
61
+ const list = JSON.parse(JSON.stringify(value));
62
+ return list;
63
+ };
64
+ exports.candidatesOf = candidatesOf;
65
+ const lightOf = (value) => {
66
+ if (!looksLight(value))
67
+ return null;
68
+ const light = JSON.parse(JSON.stringify(value));
69
+ return light;
70
+ };
71
+ exports.lightOf = lightOf;
72
+ const looksUsage = (value) => {
73
+ if (typeof member(value, "notices") === "undefined")
74
+ return false;
75
+ const answers = member(value, "answers");
76
+ if (!isBag(answers))
77
+ return false;
78
+ return Object.keys(answers).every((key) => isBag(member(answers, key)));
79
+ };
80
+ exports.looksUsage = looksUsage;
81
+ const usageOf = (value) => {
82
+ if (!looksUsage(value))
83
+ return null;
84
+ const usage = JSON.parse(JSON.stringify(value));
85
+ return usage;
86
+ };
87
+ exports.usageOf = usageOf;
88
+ // The checker's answers, put back on the declarations they belong to: the record
89
+ // keeps a position per candidate (what a record can keep) and the answers are
90
+ // keyed by it. A name the pass had nothing to say about keeps its `null`.
91
+ const applyUsage = (candidates, usage) => {
92
+ if (usage === null)
93
+ return;
94
+ for (const candidate of candidates) {
95
+ if (candidate.at === undefined)
96
+ continue;
97
+ const answer = usage.answers[String(candidate.at)];
98
+ if (answer === undefined)
99
+ continue;
100
+ candidate.references = answer.references;
101
+ candidate.implementations = answer.implementations;
102
+ }
103
+ };
104
+ exports.applyUsage = applyUsage;
@@ -0,0 +1,45 @@
1
+ import type { Project, SourceFile } from "ts-morph";
2
+ import { needsUsage } from "./pipeline-facts";
3
+ import type { Arch, Rule } from "./entities/architecture";
4
+ import type { Candidate, FileFacts, RecordObject } from "./entities/facts";
5
+ import type { Finding } from "./entities/findings";
6
+ import { type Usage } from "./fa-values";
7
+ import type { SeenStore } from "./utils/seen";
8
+ type FileRecord = {
9
+ rel: string;
10
+ hash: string;
11
+ deps: string[];
12
+ facts: FileFacts;
13
+ candidates: Candidate[];
14
+ objects: RecordObject[];
15
+ notices: string[];
16
+ };
17
+ type Parts = {
18
+ before: Finding[];
19
+ nodes: Finding[];
20
+ after: Finding[];
21
+ };
22
+ declare const namesCodeEntity: (invs: readonly Rule[]) => boolean;
23
+ declare const extractFileFacts: (abs: string, run: {
24
+ arch: Arch;
25
+ project: Project;
26
+ repoFiles: string[];
27
+ text?: string;
28
+ }) => FileRecord;
29
+ declare const checkRecord: (record: FileRecord, run: {
30
+ arch: Arch;
31
+ project: Project | null;
32
+ repoFiles: string[];
33
+ dedupe: SeenStore;
34
+ sf?: SourceFile | null;
35
+ usage?: Usage | null;
36
+ }) => Parts;
37
+ declare const checkLive: (abs: string, run: {
38
+ arch: Arch;
39
+ project: Project;
40
+ repoFiles: string[];
41
+ dedupe: SeenStore;
42
+ }) => Parts;
43
+ declare const slimmable: (record: FileRecord) => FileRecord;
44
+ export { extractFileFacts, checkRecord, checkLive, needsUsage, slimmable, namesCodeEntity };
45
+ export type { FileRecord, Parts };