@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.
- package/CHANGELOG.md +38 -0
- package/README.md +1341 -472
- package/dist/args.d.ts +4 -0
- package/dist/args.js +18 -1
- package/dist/bin/follow-architecture.js +3 -3
- package/dist/closure-project.d.ts +4 -0
- package/dist/closure-project.js +122 -0
- package/dist/code-entities/classify.d.ts +11 -0
- package/dist/code-entities/classify.js +45 -0
- package/dist/code-entities/connector.d.ts +8 -0
- package/dist/code-entities/connector.js +119 -0
- package/dist/code-entities/entities.d.ts +9 -0
- package/dist/{code-roles/roles.js → code-entities/entities.js} +81 -54
- package/dist/code-entities/project.d.ts +21 -0
- package/dist/code-entities/project.js +249 -0
- package/dist/code-entities/walk.d.ts +31 -0
- package/dist/code-entities/walk.js +95 -0
- package/dist/config-options.d.ts +23 -0
- package/dist/config-options.js +18 -1
- package/dist/config-project.js +10 -2
- package/dist/config-report.d.ts +1 -1
- package/dist/config-report.js +20 -3
- package/dist/config-rule.d.ts +25 -0
- package/dist/config-rule.js +89 -6
- package/dist/config-state.d.ts +14 -3
- package/dist/config-state.js +180 -17
- package/dist/config.d.ts +25 -0
- package/dist/css/index.d.ts +11 -7
- package/dist/css/index.js +124 -23
- package/dist/css/syntax/css/gate.js +5 -5
- package/dist/css/syntax/css/index.d.ts +1 -1
- package/dist/css/syntax/css/index.js +1 -1
- package/dist/css/syntax/css/reference.d.ts +1 -1
- package/dist/css/syntax/css/reference.js +15 -3
- package/dist/css/syntax/language.d.ts +1 -1
- package/dist/css/syntax/language.js +4 -2
- package/dist/css/syntax/scss/index.d.ts +2 -2
- package/dist/css/syntax/scss/index.js +1 -1
- package/dist/css/syntax/scss/reference.d.ts +1 -1
- package/dist/css/syntax/scss/reference.js +7 -1
- package/dist/css/syntax/styled/document.d.ts +3 -3
- package/dist/css/syntax/styled/document.js +17 -7
- package/dist/css/syntax/styled/markup.d.ts +1 -1
- package/dist/css/syntax/styled/markup.js +22 -14
- package/dist/css/syntax/styled/tags.d.ts +2 -0
- package/dist/css/syntax/styled/tags.js +22 -0
- package/dist/css/syntax/styled/template.js +10 -4
- package/dist/css/syntax/tailwind/tailwind.js +4 -4
- package/dist/css/value/check.d.ts +1 -1
- package/dist/css/value/check.js +1 -1
- package/dist/css/value/expression/arithmetic.d.ts +2 -2
- package/dist/css/value/expression/arithmetic.js +7 -3
- package/dist/css/value/expression/block.d.ts +2 -2
- package/dist/css/value/expression/block.js +4 -3
- package/dist/css/value/expression/conditional.d.ts +2 -2
- package/dist/css/value/expression/conditional.js +1 -1
- package/dist/css/value/expression/index.d.ts +2 -2
- package/dist/css/value/expression/index.js +10 -6
- package/dist/css/value/expression/map.d.ts +2 -2
- package/dist/css/value/expression/map.js +2 -2
- package/dist/css/value/object/index.d.ts +2 -2
- package/dist/css/value/object/index.js +14 -4
- package/dist/css/value/object/members.d.ts +2 -2
- package/dist/css/value/object/node.js +9 -4
- package/dist/css/value/object/path.d.ts +3 -3
- package/dist/css/value/object/path.js +10 -4
- package/dist/css/value/pieces.d.ts +3 -3
- package/dist/css/value/pieces.js +14 -4
- package/dist/css/value/resolve.js +15 -5
- package/dist/css/value/scope.d.ts +3 -2
- package/dist/css/value/scope.js +25 -7
- package/dist/css/value/substitute.js +43 -11
- package/dist/entities/architecture.d.ts +28 -25
- package/dist/entities/ast/assignments-raw.d.ts +1 -1
- package/dist/entities/ast/assignments-raw.js +61 -8
- package/dist/entities/ast/assignments-tagged.d.ts +1 -1
- package/dist/entities/ast/assignments-tagged.js +22 -7
- package/dist/entities/ast/assignments.d.ts +1 -1
- package/dist/entities/ast/assignments.js +6 -4
- package/dist/entities/ast/branches.d.ts +1 -1
- package/dist/entities/ast/calls.d.ts +1 -1
- package/dist/entities/ast/calls.js +19 -3
- package/dist/entities/ast/classes.d.ts +1 -1
- package/dist/entities/ast/classes.js +5 -1
- package/dist/entities/ast/comments.d.ts +3 -2
- package/dist/entities/ast/comments.js +47 -17
- package/dist/entities/ast/declaration.d.ts +1 -1
- package/dist/entities/ast/depth.d.ts +2 -2
- package/dist/entities/ast/depth.js +15 -8
- package/dist/entities/ast/enums.d.ts +1 -1
- package/dist/entities/ast/export-chain.d.ts +15 -0
- package/dist/entities/ast/export-chain.js +171 -0
- package/dist/entities/ast/file-exports.d.ts +1 -1
- package/dist/entities/ast/file-exports.js +26 -3
- package/dist/entities/ast/file-facts.d.ts +6 -3
- package/dist/entities/ast/file-facts.js +33 -4
- package/dist/entities/ast/file-imports.d.ts +1 -1
- package/dist/entities/ast/file-imports.js +26 -3
- package/dist/entities/ast/file.d.ts +2 -2
- package/dist/entities/ast/file.js +2 -1
- package/dist/entities/ast/functions.d.ts +1 -1
- package/dist/entities/ast/functions.js +13 -4
- package/dist/entities/ast/heritage.d.ts +1 -1
- package/dist/entities/ast/heritage.js +9 -1
- package/dist/entities/ast/index.d.ts +6 -3
- package/dist/entities/ast/index.js +82 -26
- package/dist/entities/ast/kind.d.ts +1 -1
- package/dist/entities/ast/kind.js +7 -1
- package/dist/entities/ast/modifiers.d.ts +1 -1
- package/dist/entities/ast/modifiers.js +4 -4
- package/dist/entities/ast/project.js +33 -2
- package/dist/entities/ast/properties.d.ts +1 -1
- package/dist/entities/ast/properties.js +10 -5
- package/dist/entities/ast/resolve.d.ts +1 -1
- package/dist/entities/ast/resolve.js +4 -4
- package/dist/entities/ast/tree.d.ts +4 -2
- package/dist/entities/ast/tree.js +184 -17
- package/dist/entities/ast/types.d.ts +1 -1
- package/dist/entities/ast/types.js +2 -1
- package/dist/entities/ast/usage.d.ts +1 -1
- package/dist/entities/ast/usage.js +1 -1
- package/dist/entities/ast/variables.d.ts +1 -1
- package/dist/entities/context.d.ts +4 -4
- package/dist/entities/facts.d.ts +36 -13
- package/dist/entities/findings.d.ts +3 -3
- package/dist/entities/kinds.d.ts +1 -1
- package/dist/entities/kinds.js +131 -30
- package/dist/entities/location/homes.d.ts +10 -10
- package/dist/entities/location/homes.js +74 -48
- package/dist/entities/location/place.d.ts +1 -1
- package/dist/entities/location/place.js +10 -3
- package/dist/entities/location/where.d.ts +8 -6
- package/dist/entities/location/where.js +79 -30
- package/dist/entities/location.d.ts +3 -3
- package/dist/entities/location.js +17 -17
- package/dist/entities/operators.js +1 -1
- package/dist/entities/overview/data.d.ts +6 -6
- package/dist/entities/overview/decision.d.ts +11 -11
- package/dist/entities/overview/finding.d.ts +10 -10
- package/dist/entities/overview/graph.d.ts +28 -11
- package/dist/entities/overview/input.d.ts +2 -2
- package/dist/entities/overview/summaries.d.ts +17 -15
- package/dist/entities/queries.d.ts +1 -1
- package/dist/entities/queries.js +72 -12
- package/dist/entities/repair.d.ts +1 -1
- package/dist/entities/repair.js +8 -2
- package/dist/entities/schema.d.ts +17 -3
- package/dist/entities/schema.js +74 -16
- package/dist/entities/story.d.ts +5 -5
- package/dist/entities/structure-facts.d.ts +1 -1
- package/dist/entities/token.d.ts +4 -4
- package/dist/entities/tree/build.d.ts +4 -3
- package/dist/entities/tree/build.js +95 -44
- package/dist/entities/tree/entries.d.ts +3 -3
- package/dist/entities/tree/entries.js +41 -16
- package/dist/entities/tree/index.d.ts +2 -2
- package/dist/entities/tree/index.js +1 -1
- package/dist/entities/tree/match.d.ts +2 -2
- package/dist/entities/tree/match.js +9 -5
- package/dist/fa-index.d.ts +16 -0
- package/dist/fa-index.js +165 -0
- package/dist/fa-open.d.ts +51 -0
- package/dist/fa-open.js +232 -0
- package/dist/fa-store.d.ts +22 -0
- package/dist/fa-store.js +222 -0
- package/dist/fa-values.d.ts +37 -0
- package/dist/fa-values.js +104 -0
- package/dist/facts-record.d.ts +45 -0
- package/dist/facts-record.js +287 -0
- package/dist/frameworks/angular/index.d.ts +2 -2
- package/dist/frameworks/angular/index.js +2 -1
- package/dist/frameworks/facet.d.ts +3 -1
- package/dist/frameworks/facet.js +13 -0
- package/dist/frameworks/index.d.ts +1 -1
- package/dist/frameworks/index.js +8 -4
- package/dist/frameworks/react/index.d.ts +2 -2
- package/dist/frameworks/react/index.js +33 -10
- package/dist/frameworks/test/index.d.ts +6 -0
- package/dist/frameworks/test/index.js +157 -0
- package/dist/frameworks/vue/index.d.ts +2 -2
- package/dist/frameworks/vue/index.js +2 -1
- package/dist/ignore.d.ts +3 -0
- package/dist/ignore.js +48 -0
- package/dist/index-file.d.ts +43 -0
- package/dist/index-file.js +218 -0
- package/dist/index-run.d.ts +39 -0
- package/dist/index-run.js +217 -0
- package/dist/index-zone.d.ts +25 -0
- package/dist/index-zone.js +209 -0
- package/dist/main.d.ts +5 -2
- package/dist/main.js +207 -34
- package/dist/nodes/child-entities.d.ts +3 -0
- package/dist/nodes/child-entities.js +12 -0
- package/dist/nodes/children.d.ts +4 -4
- package/dist/nodes/children.js +54 -11
- package/dist/nodes/finally/emit.d.ts +3 -3
- package/dist/nodes/finally/emit.js +26 -10
- package/dist/nodes/finally/entities.d.ts +13 -0
- package/dist/nodes/finally/entities.js +42 -0
- package/dist/nodes/finally/index.d.ts +6 -6
- package/dist/nodes/finally/index.js +8 -8
- package/dist/nodes/finally/queries.d.ts +2 -2
- package/dist/nodes/finally/queries.js +7 -4
- package/dist/nodes/finally/relations-access.d.ts +2 -2
- package/dist/nodes/finally/relations-access.js +22 -18
- package/dist/nodes/finally/relations-edge.d.ts +5 -5
- package/dist/nodes/finally/relations-edge.js +67 -44
- package/dist/nodes/finally/relations-group.d.ts +7 -7
- package/dist/nodes/finally/relations-group.js +28 -25
- package/dist/nodes/finally/relations.d.ts +2 -2
- package/dist/nodes/finally/relations.js +16 -12
- package/dist/nodes/finally/required.d.ts +3 -3
- package/dist/nodes/finally/required.js +9 -7
- package/dist/nodes/finally/violation.d.ts +2 -2
- package/dist/nodes/similar.d.ts +3 -3
- package/dist/nodes/similar.js +61 -49
- package/dist/piece-forms.d.ts +9 -0
- package/dist/piece-forms.js +68 -0
- package/dist/{pipeline-roles.d.ts → pipeline-entities.d.ts} +2 -2
- package/dist/{pipeline-roles.js → pipeline-entities.js} +32 -28
- package/dist/pipeline-facts.d.ts +4 -3
- package/dist/pipeline-facts.js +47 -55
- package/dist/{pipeline-unroled.d.ts → pipeline-unclassified.d.ts} +2 -2
- package/dist/{pipeline-unroled.js → pipeline-unclassified.js} +58 -63
- package/dist/pipeline.js +19 -64
- package/dist/release-file.d.ts +3 -0
- package/dist/release-file.js +13 -0
- package/dist/report/asks.d.ts +3 -3
- package/dist/report/asks.js +16 -6
- package/dist/report/configErrors.d.ts +55 -27
- package/dist/report/configErrors.js +81 -35
- package/dist/report/errorTypes/codes/structure.d.ts +1 -1
- package/dist/report/errorTypes/codes/structure.js +9 -9
- package/dist/report/errorTypes/decision-maker.d.ts +5 -5
- package/dist/report/errorTypes/decision-maker.js +4 -4
- package/dist/report/errorTypes/destinations.d.ts +5 -5
- package/dist/report/errorTypes/destinations.js +52 -34
- package/dist/report/errorTypes/finding-type.d.ts +3 -3
- package/dist/report/errorTypes/index.d.ts +1 -1
- package/dist/report/errorTypes/types/fileContents.d.ts +4 -4
- package/dist/report/errorTypes/types/fileContents.js +11 -5
- package/dist/report/errorTypes/types/unknownEntity.d.ts +9 -0
- package/dist/report/errorTypes/types/{unknownRole.js → unknownEntity.js} +12 -7
- package/dist/report/errorTypes/types/wrongAction.d.ts +5 -5
- package/dist/report/errorTypes/types/wrongAction.js +18 -13
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +4 -4
- package/dist/report/errorTypes/types/wrongPlacement.js +19 -9
- package/dist/report/errorTypes/vocabulary/ids.d.ts +2 -2
- package/dist/report/errorTypes/vocabulary/ids.js +3 -3
- package/dist/report/errorTypes/vocabulary/phrases.d.ts +2 -2
- package/dist/report/errorTypes/vocabulary/phrases.js +39 -26
- package/dist/report/errorTypes/vocabulary/places.d.ts +3 -3
- package/dist/report/errorTypes/vocabulary/places.js +13 -13
- package/dist/report/finding-from.d.ts +3 -3
- package/dist/report/finding-from.js +14 -9
- package/dist/report/notices.d.ts +6 -1
- package/dist/report/notices.js +46 -20
- package/dist/report/observed.d.ts +19 -0
- package/dist/report/observed.js +87 -0
- package/dist/report/render-report.d.ts +1 -1
- package/dist/report/render-report.js +33 -30
- package/dist/report/user-report/build/bundle.js +9 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +799 -297
- package/dist/report/user-report/data/collect.d.ts +2 -2
- package/dist/report/user-report/data/collect.js +15 -12
- package/dist/report/user-report/data/entities.d.ts +7 -0
- package/dist/report/user-report/data/{roles.js → entities.js} +27 -22
- package/dist/report/user-report/data/{role-examples.d.ts → entity-examples.d.ts} +3 -3
- package/dist/report/user-report/data/entity-examples.js +126 -0
- package/dist/report/user-report/data/{role-filters.d.ts → entity-filters.d.ts} +2 -2
- package/dist/report/user-report/data/{role-filters.js → entity-filters.js} +7 -7
- package/dist/report/user-report/data/entity-marks.d.ts +5 -0
- package/dist/report/user-report/data/{role-marks.js → entity-marks.js} +11 -11
- package/dist/report/user-report/data/file-tree.d.ts +3 -3
- package/dist/report/user-report/data/file-tree.js +13 -5
- package/dist/report/user-report/data/finding-boundary.d.ts +4 -4
- package/dist/report/user-report/data/finding-boundary.js +2 -2
- package/dist/report/user-report/data/finding-plan.d.ts +5 -5
- package/dist/report/user-report/data/finding-plan.js +10 -10
- package/dist/report/user-report/data/finding-title.d.ts +2 -2
- package/dist/report/user-report/data/finding-title.js +8 -8
- package/dist/report/user-report/data/findings.d.ts +4 -4
- package/dist/report/user-report/data/findings.js +30 -20
- package/dist/report/user-report/data/graph-edges.d.ts +4 -4
- package/dist/report/user-report/data/graph-edges.js +19 -19
- package/dist/report/user-report/data/graph-entities.d.ts +6 -0
- package/dist/report/user-report/data/graph-entities.js +158 -0
- package/dist/report/user-report/data/graph-helpers.d.ts +5 -5
- package/dist/report/user-report/data/graph-helpers.js +15 -15
- package/dist/report/user-report/data/graph.d.ts +5 -4
- package/dist/report/user-report/data/graph.js +28 -21
- package/dist/report/user-report/data/nodes.d.ts +2 -2
- package/dist/report/user-report/data/nodes.js +16 -16
- package/dist/report/user-report/data/rules.d.ts +7 -0
- package/dist/report/user-report/data/{invariants.js → rules.js} +13 -13
- package/dist/report/user-report/data/scan.d.ts +1 -1
- package/dist/report/user-report/data/scan.js +2 -2
- package/dist/report/user-report/html/shell.d.ts +1 -1
- package/dist/report/user-report/html/shell.js +1 -1
- package/dist/report/user-report/index.d.ts +1 -1
- package/dist/report/user-report/shared/describe.d.ts +1 -1
- package/dist/report/user-report/shared/describe.js +6 -6
- package/dist/rules/index.d.ts +7 -0
- package/dist/{invariants → rules}/index.js +85 -57
- package/dist/{invariants → rules}/list-vars.d.ts +2 -2
- package/dist/{invariants → rules}/list-vars.js +9 -3
- package/dist/{invariants → rules}/name.js +2 -2
- package/dist/rules/normalize.d.ts +5 -0
- package/dist/{invariants → rules}/normalize.js +35 -32
- package/dist/{invariants → rules}/vars.d.ts +9 -7
- package/dist/{invariants → rules}/vars.js +5 -5
- package/dist/scan-run.d.ts +20 -0
- package/dist/scan-run.js +130 -0
- package/dist/scripts/audit-report.js +2 -2
- package/dist/usage-index.d.ts +4 -0
- package/dist/usage-index.js +272 -0
- package/dist/usage-mode.d.ts +7 -0
- package/dist/usage-mode.js +16 -0
- package/dist/usage-pass.d.ts +19 -0
- package/dist/usage-pass.js +136 -0
- package/dist/usage-prepare.d.ts +2 -0
- package/dist/usage-prepare.js +22 -0
- package/dist/usage-sweep.d.ts +10 -0
- package/dist/usage-sweep.js +254 -0
- package/dist/utils/aliases.d.ts +22 -0
- package/dist/utils/aliases.js +163 -0
- package/dist/utils/classify.d.ts +2 -2
- package/dist/utils/classify.js +4 -4
- package/dist/utils/distinct.js +4 -2
- package/dist/utils/files.js +24 -30
- package/dist/utils/fixpoint.js +2 -2
- package/dist/utils/host.d.ts +1 -1
- package/dist/utils/host.js +4 -1
- package/dist/utils/imports.js +66 -12
- package/dist/utils/keyed.js +2 -2
- package/dist/utils/map-record.js +2 -2
- package/dist/utils/packages.d.ts +15 -0
- package/dist/utils/packages.js +197 -0
- package/dist/utils/path-label.js +3 -1
- package/dist/utils/pattern.d.ts +5 -4
- package/dist/utils/pattern.js +38 -8
- package/dist/utils/permission.d.ts +3 -3
- package/dist/utils/permission.js +4 -2
- package/dist/utils/plural.js +2 -2
- package/dist/utils/qualified.js +4 -4
- package/dist/utils/rank.js +2 -2
- package/dist/utils/record.js +1 -1
- package/dist/utils/search.js +7 -2
- package/dist/utils/speak.js +1 -1
- package/dist/utils/split.js +14 -1
- package/dist/utils/template.d.ts +1 -1
- package/dist/utils/template.js +1 -1
- package/dist/utils/tokenize.js +6 -1
- package/dist/utils/typed-field.js +2 -2
- package/dist/utils/verdicts.js +1 -1
- package/entities/operators.ts +1 -1
- package/package.json +101 -90
- package/report/errorTypes/vocabulary/ids.ts +7 -2
- package/report/errorTypes/vocabulary/phrases.ts +47 -27
- package/report/errorTypes/vocabulary/places.ts +21 -16
- package/report/user-report/shared/describe.ts +7 -7
- package/dist/code-roles/classify.d.ts +0 -11
- package/dist/code-roles/classify.js +0 -43
- package/dist/code-roles/connector.d.ts +0 -5
- package/dist/code-roles/connector.js +0 -114
- package/dist/code-roles/project.d.ts +0 -12
- package/dist/code-roles/project.js +0 -122
- package/dist/code-roles/roles.d.ts +0 -8
- package/dist/invariants/index.d.ts +0 -6
- package/dist/invariants/normalize.d.ts +0 -4
- package/dist/nodes/child-roles.d.ts +0 -3
- package/dist/nodes/child-roles.js +0 -12
- package/dist/nodes/finally/roles.d.ts +0 -13
- package/dist/nodes/finally/roles.js +0 -41
- package/dist/report/errorTypes/types/unknownRole.d.ts +0 -9
- package/dist/report/user-report/data/graph-roles.d.ts +0 -5
- package/dist/report/user-report/data/graph-roles.js +0 -71
- package/dist/report/user-report/data/invariants.d.ts +0 -7
- package/dist/report/user-report/data/role-examples.js +0 -94
- package/dist/report/user-report/data/role-marks.d.ts +0 -5
- package/dist/report/user-report/data/roles.d.ts +0 -7
- /package/dist/{invariants → rules}/name.d.ts +0 -0
package/dist/utils/search.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.matchesText = void 0;
|
|
4
4
|
// A TEXT SEARCH is one mechanism: does a haystack contain a needle, ignoring
|
|
5
5
|
// case? An empty needle matches everything (no filter). The browser searches
|
|
6
|
-
// findings /
|
|
6
|
+
// findings / entities / nodes (`utils/format`); any consumer that filters text by
|
|
7
7
|
// a substring asks the same question. The decision is the shared gate — admit
|
|
8
8
|
// when none of the refusals fires (no needle to filter by, or the needle is
|
|
9
9
|
// absent) — the same `admitsWhenNoneReject` the AST read gate uses.
|
|
@@ -12,5 +12,10 @@ const gate_1 = require("./gate");
|
|
|
12
12
|
// admits every haystack (no filter). A non-empty needle is refused only when
|
|
13
13
|
// the haystack does not contain it. Spelling the empty case as its own `!n`
|
|
14
14
|
// refusal would invert it — the refusal fires first and the list empties.
|
|
15
|
-
const matchesText = (haystack, needle) => (0, gate_1.admitsWhenNoneReject)(needle, [
|
|
15
|
+
const matchesText = (haystack, needle) => (0, gate_1.admitsWhenNoneReject)(needle, [
|
|
16
|
+
(n) => Boolean(n) &&
|
|
17
|
+
!String(haystack ?? "")
|
|
18
|
+
.toLowerCase()
|
|
19
|
+
.includes(n.toLowerCase()),
|
|
20
|
+
]);
|
|
16
21
|
exports.matchesText = matchesText;
|
package/dist/utils/speak.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.speakOnce = void 0;
|
|
4
4
|
// A SPOKEN SET is one mechanism: a subject is named once — the first time it
|
|
5
5
|
// answers, it is remembered; every later answer of the same subject is silent.
|
|
6
|
-
// The
|
|
6
|
+
// The rule runtime speaks once per PIECE per rule (a `const` holding an
|
|
7
7
|
// arrow answers two entries, the reader needs one sentence); any consumer that
|
|
8
8
|
// names subjects without repeating itself asks the same question. The walk is
|
|
9
9
|
// the same — ask, remember, answer — so it lives here once. What a subject IS
|
package/dist/utils/split.js
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.partsOf = void 0;
|
|
4
|
+
// The same handful of paths is cut over and over — every finding names a file,
|
|
5
|
+
// every rule names a folder — so the split is memoised per separator. The parts
|
|
6
|
+
// are read-only: a reader that needs a derived array (filtered segments) makes
|
|
7
|
+
// one, and nothing here is ever mutated.
|
|
8
|
+
// Module-wide, keyed by separator + text: it grows to the paths split in one run
|
|
9
|
+
// (bounded by the working tree — a CLI run dies with it).
|
|
10
|
+
const memo = new Map();
|
|
4
11
|
const partsOf = (text, separator) => {
|
|
12
|
+
const key = `${separator}\u0000${text ?? ""}`;
|
|
13
|
+
const cached = memo.get(key);
|
|
14
|
+
if (cached)
|
|
15
|
+
return cached;
|
|
5
16
|
const all = String(text ?? "").split(separator);
|
|
6
|
-
|
|
17
|
+
const parts = { all, head: all.slice(0, -1), last: all[all.length - 1] ?? "" };
|
|
18
|
+
memo.set(key, parts);
|
|
19
|
+
return parts;
|
|
7
20
|
};
|
|
8
21
|
exports.partsOf = partsOf;
|
package/dist/utils/template.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldValue } from "
|
|
1
|
+
import type { FieldValue } from "@md-code/follow-architecture/utils/field";
|
|
2
2
|
type TemplateVars = Record<string, FieldValue>;
|
|
3
3
|
declare const substitute: (text: string, vars: TemplateVars) => string;
|
|
4
4
|
export { substitute };
|
package/dist/utils/template.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.substitute = void 0;
|
|
4
|
-
const substitute = (text, vars) => String(text).replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g, (whole, k) =>
|
|
4
|
+
const substitute = (text, vars) => String(text).replace(/\{([A-Za-z][A-Za-z0-9_]*)\}/g, (whole, k) => vars[k] != null ? String(vars[k]) : whole);
|
|
5
5
|
exports.substitute = substitute;
|
package/dist/utils/tokenize.js
CHANGED
|
@@ -9,5 +9,10 @@ exports.tokenize = void 0;
|
|
|
9
9
|
//
|
|
10
10
|
// A GLOBAL utility: tailwind, a class attribute, any facet reads a token list
|
|
11
11
|
// the same way.
|
|
12
|
-
const tokenize = (text) => [
|
|
12
|
+
const tokenize = (text) => [
|
|
13
|
+
...new Set(String(text ?? "")
|
|
14
|
+
.trim()
|
|
15
|
+
.split(/\s+/)
|
|
16
|
+
.filter(Boolean)),
|
|
17
|
+
];
|
|
13
18
|
exports.tokenize = tokenize;
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.typedField = void 0;
|
|
4
4
|
// A TYPED FIELD is one mechanism: a record's field is read as plain data, and
|
|
5
5
|
// only the value of the expected shape is kept — anything else is nothing. A
|
|
6
|
-
// report template's string fields are read this way (`
|
|
7
|
-
// scope accessor's `scope` is read this way (`code-
|
|
6
|
+
// report template's string fields are read this way (`rules/index`); a
|
|
7
|
+
// scope accessor's `scope` is read this way (`code-entities/entities`). The walk is
|
|
8
8
|
// the same — read, qualify, keep or drop — so it lives here once. What the
|
|
9
9
|
// field IS and which shape qualifies is the caller's own.
|
|
10
10
|
const field_1 = require("./field");
|
package/dist/utils/verdicts.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.worstWhenAllRefuse = void 0;
|
|
4
4
|
// A VERDICT LIST is one mechanism: entries are judged, the refusals are ranked
|
|
5
5
|
// by how well they EXPLAIN the rule, and the best explanation is the one the
|
|
6
|
-
// reader gets. The relation check ranks the target
|
|
6
|
+
// reader gets. The relation check ranks the target entities an edge could be
|
|
7
7
|
// judged by (`nodes/finally/relations`); any consumer that must pick the most
|
|
8
8
|
// informative refusal asks the same question. The ranking is the caller's own
|
|
9
9
|
// policy; the walk — rank, then take the head only when EVERY entry refuses —
|
package/entities/operators.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// The operator vocabulary AS THE REPORT READS IT: which keys stand for a list,
|
|
4
4
|
// which of them say "one of them", and how a scalar operator is spelled for a
|
|
5
|
-
// human. Two readers share it — the Node-side summarizer (`data/
|
|
5
|
+
// human. Two readers share it — the Node-side summarizer (`data/rules.js`)
|
|
6
6
|
// and the browser describer (`src/utils/describe.js`) — because they used to
|
|
7
7
|
// carry the same three tables twice and printed two different truths.
|
|
8
8
|
//
|
package/package.json
CHANGED
|
@@ -1,92 +1,103 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
2
|
+
"name": "@md-code/follow-architecture",
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "ESLint rule + CLI that enforces a declarative architecture: where files may live, what they may be named, and what they may contain.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": "DrBoria <dr.boria@gmail.com>",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/DrBoria/follow-architecture.git"
|
|
11
|
+
},
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/DrBoria/follow-architecture/issues"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/DrBoria/follow-architecture#readme",
|
|
16
|
+
"main": "dist/plugin.js",
|
|
17
|
+
"types": "dist/plugin.d.ts",
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=18"
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"follow-architecture": "dist/bin/follow-architecture.js"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist/",
|
|
26
|
+
"report/user-report/shared/",
|
|
27
|
+
"report/errorTypes/vocabulary/",
|
|
28
|
+
"entities/operators.ts",
|
|
29
|
+
"README.md",
|
|
30
|
+
"CHANGELOG.md"
|
|
31
|
+
],
|
|
32
|
+
"exports": {
|
|
33
|
+
".": "./dist/plugin.js",
|
|
34
|
+
"./plugin": "./dist/plugin.js",
|
|
35
|
+
"./config": "./dist/config.js",
|
|
36
|
+
"./main": "./dist/main.js",
|
|
37
|
+
"./package.json": "./package.json",
|
|
38
|
+
"./*": "./dist/*.js",
|
|
39
|
+
"./*.js": "./dist/*.js"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@md-code/utils": "^0.0.2",
|
|
43
|
+
"@typescript-eslint/parser": "^8.71.0",
|
|
44
|
+
"css-tree": "^3.2.1",
|
|
45
|
+
"highlight.js": "^11.12.0",
|
|
46
|
+
"js-yaml": "^5.4.2",
|
|
47
|
+
"minimatch": "^9.0.4",
|
|
48
|
+
"postcss": "^8.5.32",
|
|
49
|
+
"postcss-scss": "^4.0.9",
|
|
50
|
+
"postcss-selector-parser": "^7.1.7",
|
|
51
|
+
"postcss-value-parser": "^4.2.0",
|
|
52
|
+
"remeda": "^2.50.0",
|
|
53
|
+
"stylis": "^4.4.0",
|
|
54
|
+
"tailwindcss": "^3.4.0",
|
|
55
|
+
"ts-morph": "^24.0.0"
|
|
56
|
+
},
|
|
57
|
+
"peerDependencies": {
|
|
58
|
+
"eslint": ">=8.40.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"format": "prettier --write \"**/*.{ts,tsx,js,jsx,css,json}\" --ignore-path ../../.prettierignore",
|
|
62
|
+
"format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,css,json}\" --ignore-path ../../.prettierignore",
|
|
63
|
+
"clean": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
64
|
+
"build": "npm run clean && tsc -p tsconfig.json && npm run prebuild:report",
|
|
65
|
+
"prebuild:report": "node scripts/build-report-bundle.mjs",
|
|
66
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
67
|
+
"lint:products": "ESLINT_BIN=\"$PWD/node_modules/.bin/eslint\"; cd ../.. && NODE_OPTIONS=--max-old-space-size=13312 LINT_OVERVIEW=0 \"$ESLINT_BIN\" --config packages/follow-architecture/eslint.products.config.mjs packages",
|
|
68
|
+
"lint:products:overview": "ESLINT_BIN=\"$PWD/node_modules/.bin/eslint\"; cd ../.. && NODE_OPTIONS=--max-old-space-size=13312 LINT_OVERVIEW=1 \"$ESLINT_BIN\" --config packages/follow-architecture/eslint.products.config.mjs packages",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"overview": "node dist/bin/follow-architecture.js --overview architecture-overview.html",
|
|
71
|
+
"prepublishOnly": "npm run build && vitest run --no-file-parallelism",
|
|
72
|
+
"lint": "eslint ."
|
|
73
|
+
},
|
|
74
|
+
"devDependencies": {
|
|
75
|
+
"@md-code/component-uniqueness": "^0.3.0",
|
|
76
|
+
"@md-code/components": "^0.0.2",
|
|
77
|
+
"@md-code/entities-uniqueness": "^0.3.0",
|
|
78
|
+
"@md-code/sections": "^0.0.3",
|
|
79
|
+
"@md-code/utils-uniqueness": "^0.3.0",
|
|
80
|
+
"@types/node": "^26.6.6",
|
|
81
|
+
"@types/react": "^18",
|
|
82
|
+
"@types/react-dom": "^18",
|
|
83
|
+
"esbuild": "^0.25.12",
|
|
84
|
+
"react": "^18.3.1",
|
|
85
|
+
"react-dom": "^18.3.1",
|
|
86
|
+
"styled-components": "^6.6.0",
|
|
87
|
+
"typescript": "^5.5",
|
|
88
|
+
"typescript-eslint": "^8.73.0",
|
|
89
|
+
"vite": "^6.4.5",
|
|
90
|
+
"vitest": "^5.0.3",
|
|
91
|
+
"@md-code/styles": "^0.0.1",
|
|
92
|
+
"@md-code/config": "^0.0.1"
|
|
93
|
+
},
|
|
94
|
+
"publishConfig": {
|
|
95
|
+
"access": "public"
|
|
96
|
+
},
|
|
97
|
+
"keywords": [
|
|
98
|
+
"eslint",
|
|
99
|
+
"eslint-rule",
|
|
100
|
+
"architecture",
|
|
101
|
+
"typescript"
|
|
102
|
+
]
|
|
92
103
|
}
|
|
@@ -7,6 +7,11 @@
|
|
|
7
7
|
// the finding judges the file's own contents
|
|
8
8
|
const __exported_WRONG_ACTION = "wrongAction";
|
|
9
9
|
const __exported_WRONG_PLACEMENT = "wrongPlacement";
|
|
10
|
-
const
|
|
10
|
+
const __exported_UNKNOWN_ENTITY = "unknownEntity";
|
|
11
11
|
const __exported_FILE_CONTENTS = "fileContents";
|
|
12
|
-
export {
|
|
12
|
+
export {
|
|
13
|
+
__exported_WRONG_ACTION as WRONG_ACTION,
|
|
14
|
+
__exported_WRONG_PLACEMENT as WRONG_PLACEMENT,
|
|
15
|
+
__exported_UNKNOWN_ENTITY as UNKNOWN_ENTITY,
|
|
16
|
+
__exported_FILE_CONTENTS as FILE_CONTENTS,
|
|
17
|
+
};
|
|
@@ -5,10 +5,16 @@
|
|
|
5
5
|
// the ONE spelling the text and the picture read. Every field is read through
|
|
6
6
|
// the shared field readers — a fact is plain data, never an `any`.
|
|
7
7
|
|
|
8
|
-
import { RELATION } from "
|
|
9
|
-
import { fieldOf, isObj, type FieldValue } from "
|
|
10
|
-
import {
|
|
11
|
-
|
|
8
|
+
import { RELATION } from "@md-code/follow-architecture/entities/kinds";
|
|
9
|
+
import { fieldOf, isObj, type FieldValue } from "@md-code/follow-architecture/utils/field";
|
|
10
|
+
import {
|
|
11
|
+
stringField,
|
|
12
|
+
stringListField,
|
|
13
|
+
recordField,
|
|
14
|
+
recordListField,
|
|
15
|
+
booleanField,
|
|
16
|
+
} from "@md-code/follow-architecture/utils/read-field";
|
|
17
|
+
import { article } from "@md-code/follow-architecture/utils/article";
|
|
12
18
|
|
|
13
19
|
const q = (s: FieldValue): string => (s == null ? "—" : `\`${s}\``);
|
|
14
20
|
const list = (xs: readonly FieldValue[]): string => xs.map(q).join(", ");
|
|
@@ -38,7 +44,8 @@ const pluralize = (text: string): string => {
|
|
|
38
44
|
// The export forms that read as a re-export of a whole module / a default.
|
|
39
45
|
const exportFormText = (fact: FieldValue): string | null => {
|
|
40
46
|
const form = stringField(fact, "form");
|
|
41
|
-
if (form === "namespace")
|
|
47
|
+
if (form === "namespace")
|
|
48
|
+
return `re-exports ${q(fieldOf(fact, "source"))} as ${q(stringListField(fact, "names")[0] ?? fieldOf(fact, "name"))}`;
|
|
42
49
|
if (form === "star") return `re-exports ${q(fieldOf(fact, "source"))}`;
|
|
43
50
|
if (form === "default") return "is exported as its default";
|
|
44
51
|
if (form === "equals") return "is exported with `export =`";
|
|
@@ -78,8 +85,9 @@ const callText = (fact: FieldValue): string =>
|
|
|
78
85
|
|
|
79
86
|
const mutateText = (fact: FieldValue): string => {
|
|
80
87
|
if (booleanField(fact, "onThis")) return `changes ${q(fieldOf(fact, "target"))} of its own file`;
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
88
|
+
const ownerEntity = fieldOf(fact, "ownerEntity");
|
|
89
|
+
if (ownerEntity)
|
|
90
|
+
return `changes ${q(fieldOf(fact, "target"))} of the ${q(ownerEntity)} (${q(fieldOf(fact, "module"))})`;
|
|
83
91
|
return `changes ${q(fieldOf(fact, "target"))} of ${q(fieldOf(fact, "module"))}`;
|
|
84
92
|
};
|
|
85
93
|
|
|
@@ -89,8 +97,18 @@ const declareText = (fact: FieldValue): string => {
|
|
|
89
97
|
return "is declared here";
|
|
90
98
|
};
|
|
91
99
|
|
|
92
|
-
|
|
93
|
-
|
|
100
|
+
// A named import names the SYMBOLS it takes (and the file that declares them):
|
|
101
|
+
// `imports `codeEditor` of `packages/styles/themes/editor.ts``. A module-level
|
|
102
|
+
// import keeps its one-word form.
|
|
103
|
+
const importText = (fact: FieldValue): string => {
|
|
104
|
+
if (stringField(fact, "form") !== "statement") return `requires ${q(fieldOf(fact, "source"))}`;
|
|
105
|
+
const names = fieldOf(fact, "names");
|
|
106
|
+
const symbols = Array.isArray(names) ? names.filter((name) => typeof name === "string") : [];
|
|
107
|
+
|
|
108
|
+
return symbols.length
|
|
109
|
+
? `imports ${list(symbols)} of ${q(fieldOf(fact, "resolved"))}`
|
|
110
|
+
: `imports ${q(fieldOf(fact, "resolved"))}`;
|
|
111
|
+
};
|
|
94
112
|
|
|
95
113
|
const assignText = (fact: FieldValue): string => {
|
|
96
114
|
const method = fieldOf(fact, "method");
|
|
@@ -116,38 +134,40 @@ const factText = (fact: FieldValue): string => {
|
|
|
116
134
|
return `does a \`${kind}\` the architecture does not describe`;
|
|
117
135
|
};
|
|
118
136
|
|
|
119
|
-
const
|
|
120
|
-
if (!
|
|
121
|
-
return
|
|
137
|
+
const entitiesSuffix = (entities: string[]): string => {
|
|
138
|
+
if (!entities.length) return "";
|
|
139
|
+
return entities.length === 1 ? ` (${entities[0]})` : ` (${entities.join(" / ")})`;
|
|
122
140
|
};
|
|
123
141
|
|
|
124
142
|
const subjectText = (subject: FieldValue, file: string): string => {
|
|
125
|
-
const
|
|
126
|
-
const
|
|
127
|
-
const
|
|
143
|
+
const entityNames = stringListField(subject, "entities").filter(Boolean);
|
|
144
|
+
const entities = entityNames.map(q);
|
|
145
|
+
const entitiesPart = entitiesSuffix(entities);
|
|
128
146
|
if (!isObj(subject) || booleanField(subject, "scope")) {
|
|
129
|
-
return `the module scope of ${q(file)}${
|
|
147
|
+
return `the module scope of ${q(file)}${entitiesPart}`;
|
|
130
148
|
}
|
|
131
149
|
const pieces = stringListField(subject, "pieces").filter(Boolean).map(q);
|
|
132
|
-
if (!pieces.length) return `the module scope of ${q(file)}${
|
|
133
|
-
const who =
|
|
134
|
-
return `${pieces.join(", ")}${who || " (which no
|
|
150
|
+
if (!pieces.length) return `the module scope of ${q(file)}${entitiesPart}`;
|
|
151
|
+
const who = entityNames.length === 1 ? ` (${article(entityNames[0])} ${q(entityNames[0])})` : entitiesPart;
|
|
152
|
+
return `${pieces.join(", ")}${who || " (which no entity describes)"}`;
|
|
135
153
|
};
|
|
136
154
|
|
|
137
155
|
// WHY it is refused — a code from the engine, not a sentence.
|
|
138
156
|
const whyText = (why: FieldValue): string => {
|
|
139
157
|
if (!isObj(why)) return "it is not allowed";
|
|
140
158
|
if (stringField(why, "code") === "silent") return "nothing in the architecture allows it";
|
|
141
|
-
const same = new Set(stringListField(why, "
|
|
142
|
-
//
|
|
143
|
-
// limit the sentence reads as "this
|
|
159
|
+
const same = new Set(stringListField(why, "sameEntities"));
|
|
160
|
+
// An entity the rule limits to the SAME feature instance says so: without the
|
|
161
|
+
// limit the sentence reads as "this entity may not do it at all", which is the
|
|
144
162
|
// opposite of what the architecture declares.
|
|
145
|
-
const
|
|
146
|
-
|
|
163
|
+
const entities = stringListField(why, "entities")
|
|
164
|
+
.filter(Boolean)
|
|
165
|
+
.map((r) => (same.has(r) ? `${q(r)} in the same feature` : q(r)));
|
|
166
|
+
// The entity DOES allow the call — what it refuses is the value handed over.
|
|
147
167
|
if (booleanField(why, "outward")) return "that value may not be handed to it";
|
|
148
|
-
if (!
|
|
149
|
-
if (booleanField(why, "self")) return `only ${
|
|
150
|
-
return `only ${
|
|
168
|
+
if (!entities.length) return stringField(why, "code") === "nobody" ? "no code may do it" : "it is not allowed";
|
|
169
|
+
if (booleanField(why, "self")) return `only ${entities.join(", ")} may do it`;
|
|
170
|
+
return `only ${entities.join(", ")} may do it with ${q(fieldOf(why, "targetNode"))} code`;
|
|
151
171
|
};
|
|
152
172
|
|
|
153
173
|
// The one sentence a refused relation gets.
|
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
// Engine names → report names:
|
|
3
|
+
// Engine names → report names: entity → box, place → node.
|
|
4
4
|
|
|
5
5
|
// ONE source for every place question. `homeFor`, `nodeAtPath`, `homeTemplates`
|
|
6
6
|
// and `pathOf` used to be spelled again here, in a second wording, next to the
|
|
7
7
|
// real ones in `entities/location.js` — the report and the engine then disagreed
|
|
8
|
-
// about where
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
// about where an entity lives. This file only NAMES things now.
|
|
9
|
+
import {
|
|
10
|
+
homesOf,
|
|
11
|
+
entitiesAtPath as entitiesDeclaredAt,
|
|
12
|
+
homeForEntity,
|
|
13
|
+
boxOfPlace,
|
|
14
|
+
} from "@md-code/follow-architecture/entities/location";
|
|
15
|
+
import type { Arch } from "@md-code/follow-architecture/entities/architecture";
|
|
16
|
+
import type { NodeSummary } from "@md-code/follow-architecture/entities/overview/summaries";
|
|
17
|
+
import type { Places } from "@md-code/follow-architecture/entities/overview/decision";
|
|
13
18
|
|
|
14
19
|
const make = ({ nodes, arch }: { nodes: NodeSummary[]; arch: Arch }): Places => {
|
|
15
20
|
const folderOf = (slug: string | null | undefined): string | null => {
|
|
@@ -21,26 +26,26 @@ const make = ({ nodes, arch }: { nodes: NodeSummary[]; arch: Arch }): Places =>
|
|
|
21
26
|
// A node slug as the path a human recognises.
|
|
22
27
|
const pathOf = (slug: string): string => nodes.find((n) => n.slug === slug)?.paths?.[0] ?? slug;
|
|
23
28
|
|
|
24
|
-
// EVERY
|
|
25
|
-
//
|
|
26
|
-
const
|
|
29
|
+
// EVERY entity that declares a place — the set a destination decision chooses
|
|
30
|
+
// from: everything the tree says could be here.
|
|
31
|
+
const entities = (): string[] => Object.keys(arch.nodes.entityHomes);
|
|
27
32
|
|
|
28
|
-
//
|
|
33
|
+
// Entities whose declared home covers this path, most specific first: what this
|
|
29
34
|
// file already IS, according to the tree.
|
|
30
|
-
const
|
|
35
|
+
const entitiesAtPath = (rel: string): string[] => entitiesDeclaredAt(arch, rel);
|
|
31
36
|
|
|
32
|
-
// The path templates
|
|
33
|
-
const homeTemplates = (
|
|
37
|
+
// The path templates an entity declares (`…/constants.ts`, `…/actions/**`).
|
|
38
|
+
const homeTemplates = (entity: string): string[] => homesOf(arch, entity).map((h) => h.template);
|
|
34
39
|
|
|
35
|
-
// Where this
|
|
40
|
+
// Where this entity's code belongs FOR THIS FILE, and the box that hosts it —
|
|
36
41
|
// the engine's own answer, never a folder invented here.
|
|
37
|
-
const homeFor = (
|
|
42
|
+
const homeFor = (entity: string, rel: string) => homeForEntity(arch, entity, rel);
|
|
38
43
|
|
|
39
44
|
// The box that HOLDS a path — `apps/backend/document/store.ts` → the node that
|
|
40
45
|
// owns `apps/backend/document`.
|
|
41
46
|
const nodeAtPath = (path: string | null | undefined): string | null => boxOfPlace(arch, path);
|
|
42
47
|
|
|
43
|
-
return { folderOf, pathOf,
|
|
48
|
+
return { folderOf, pathOf, entities, entitiesAtPath, homeTemplates, homeFor, nodeAtPath };
|
|
44
49
|
};
|
|
45
50
|
|
|
46
51
|
export { make };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
// Turn a nested architecture query (`infer` blocks,
|
|
3
|
+
// Turn a nested architecture query (`infer` blocks, rule conditions, `when`
|
|
4
4
|
// blocks) into short, readable lines: `subscriptions.length > 0`,
|
|
5
5
|
// `descendants[*].kind = ClassDeclaration`. ONE walk, shared by the Node-side
|
|
6
|
-
// summarizer (`data/
|
|
6
|
+
// summarizer (`data/rules`) and the browser describer
|
|
7
7
|
// (`src/utils/describe`), which used to carry the same algorithm twice and
|
|
8
8
|
// could drift.
|
|
9
9
|
//
|
|
@@ -13,14 +13,15 @@
|
|
|
13
13
|
// setValue the text an `is set` operator prints; `undefined` keeps the value
|
|
14
14
|
// the query carries (the browser reader), `""` blanks it (Node side)
|
|
15
15
|
|
|
16
|
-
import { CONTAINERS, QUANTIFIERS, SCALAR_OPS } from "
|
|
17
|
-
import { isObj, isList, type FieldValue } from "
|
|
18
|
-
import { dispatchOn } from "
|
|
16
|
+
import { CONTAINERS, QUANTIFIERS, SCALAR_OPS } from "@md-code/follow-architecture/entities/operators";
|
|
17
|
+
import { isObj, isList, type FieldValue } from "@md-code/follow-architecture/utils/field";
|
|
18
|
+
import { dispatchOn } from "@md-code/follow-architecture/utils/dispatch";
|
|
19
19
|
|
|
20
20
|
// One condition line: a path, an operator, and the value it demands.
|
|
21
21
|
type Condition = { path: string; op: string; value: string };
|
|
22
22
|
|
|
23
|
-
const fmt = (v: FieldValue): string =>
|
|
23
|
+
const fmt = (v: FieldValue): string =>
|
|
24
|
+
typeof v === "string" || typeof v === "number" || typeof v === "boolean" ? String(v) : JSON.stringify(v);
|
|
24
25
|
|
|
25
26
|
// The presentation options: which keys are prose, and what `is set` prints.
|
|
26
27
|
type DescribeOptions = { ignore?: readonly string[]; setValue?: string };
|
|
@@ -47,7 +48,6 @@ const walkAt = (child: FieldValue, trail: string[], state: Walk): void => {
|
|
|
47
48
|
// The scalar operator a key names, if it is one (the table is the engine's own).
|
|
48
49
|
const scalarOpOf = (key: string): string | undefined => Object.entries(SCALAR_OPS).find(([k]) => k === key)?.[1];
|
|
49
50
|
|
|
50
|
-
|
|
51
51
|
const walkEntry = (key: string, child: FieldValue, state: Walk): void => {
|
|
52
52
|
if (state.ignore.has(key)) return;
|
|
53
53
|
if (key === "at") {
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Arch, CodeRoles } from "../entities/architecture";
|
|
2
|
-
import type { Candidate, FileFacts } from "../entities/facts";
|
|
3
|
-
declare const classifyRoles: (candidates: Candidate[] | null | undefined, codeRoles: CodeRoles | null | undefined, arch?: Arch | null, fileFacts?: FileFacts | null) => {
|
|
4
|
-
present: string[];
|
|
5
|
-
candidates: Candidate[];
|
|
6
|
-
roleCtx: {
|
|
7
|
-
present: string[];
|
|
8
|
-
candidates: Candidate[];
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
export { classifyRoles };
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.classifyRoles = void 0;
|
|
4
|
-
// Classify the file's candidates against the codeRoles.
|
|
5
|
-
//
|
|
6
|
-
// `classifyRoles(candidates, codeRoles)` returns:
|
|
7
|
-
// • `present` — the flat list of role names present in the file
|
|
8
|
-
// • `roleCtx` — `{ present, candidates }` where `candidates` are the
|
|
9
|
-
// enriched facts (each carrying `role`, `parentRole`, and
|
|
10
|
-
// `calls[].targetRole`).
|
|
11
|
-
//
|
|
12
|
-
// The input candidates array is NOT mutated in place — a shallow copy
|
|
13
|
-
// (plus a copy of `calls`) is enriched, so the original facts the
|
|
14
|
-
// pipeline built stay untouched.
|
|
15
|
-
//
|
|
16
|
-
// File-level `when` filters consume `ctx.facts` (which already includes
|
|
17
|
-
// `roles` and `candidates`), so no separate predicate language is needed.
|
|
18
|
-
const connector_1 = require("./connector");
|
|
19
|
-
const classify_1 = require("../utils/classify");
|
|
20
|
-
const read_when_1 = require("../utils/read-when");
|
|
21
|
-
// A file with NO code candidates (a barrel of re-exports, a file of imports)
|
|
22
|
-
// still has a nature a role may describe: the file's own facts are asked
|
|
23
|
-
// against the same `infer` filters. The first role whose infer matches the
|
|
24
|
-
// FILE facts describes the module scope — the same first-match-wins order the
|
|
25
|
-
// pieces use (the shared `utils/classify` walk). A role inferred from a piece's
|
|
26
|
-
// shape (`kind.own`) simply does not match the file, so nothing changes for
|
|
27
|
-
// files that hold code. The qualified read is the shared `readWhen`: only a
|
|
28
|
-
// file that is there is asked.
|
|
29
|
-
const fileRoleOf = (fileFacts, codeRoles, arch) => (0, read_when_1.readWhen)(fileFacts, (f) => f != null, (f) => (0, classify_1.firstMatch)(f, (0, classify_1.definitionsOf)(codeRoles), { ...f, arch }), null);
|
|
30
|
-
const classifyRoles = (candidates, codeRoles, arch, fileFacts = null) => {
|
|
31
|
-
const copy = (candidates ?? []).map((c) => ({ ...c, calls: (c.calls ?? []).map((x) => ({ ...x })) }));
|
|
32
|
-
(0, connector_1.enrichWithRoles)(copy, codeRoles, arch);
|
|
33
|
-
const present = copy.map((c) => c.role).filter((r) => Boolean(r));
|
|
34
|
-
// The module scope answers for statements no piece owns (`export * from`).
|
|
35
|
-
// When no piece got a role, the file itself may still be describable.
|
|
36
|
-
if (!present.length) {
|
|
37
|
-
const fileRole = fileRoleOf(fileFacts, codeRoles, arch);
|
|
38
|
-
if (fileRole)
|
|
39
|
-
present.push(fileRole);
|
|
40
|
-
}
|
|
41
|
-
return { present, candidates: copy, roleCtx: { present, candidates: copy } };
|
|
42
|
-
};
|
|
43
|
-
exports.classifyRoles = classifyRoles;
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Arch, CodeRoles } from "../entities/architecture";
|
|
2
|
-
import type { Candidate, CallFact } from "../entities/facts";
|
|
3
|
-
declare const roleOfTarget: (call: Partial<CallFact> | null | undefined, nameToRole: ReadonlyMap<string, Candidate>, arch?: Arch | null) => string | null;
|
|
4
|
-
declare const enrichWithRoles: (candidates: Candidate[], codeRoles: CodeRoles | null | undefined, arch?: Arch | null) => Candidate[];
|
|
5
|
-
export { enrichWithRoles, roleOfTarget };
|