@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/nodes/children.js
CHANGED
|
@@ -1,11 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (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
|
+
};
|
|
2
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
26
|
+
exports.entitiesOf = exports.ancestorChain = exports.missingRequiredChild = exports.folderContents = exports.compileChild = exports.nodePrefixRe = exports.nodePathRe = void 0;
|
|
4
27
|
// Node child handling: a child is either a plain string name or a
|
|
5
28
|
// `{ kind, name? }` matcher. `compileChild` turns a name into a regex with
|
|
6
29
|
// capture groups; `nodePrefixRe` turns a node path into a prefix matcher.
|
|
7
30
|
// Both live here because they are node-specific, not shared machinery.
|
|
8
|
-
const pattern_1 = require("
|
|
31
|
+
const pattern_1 = require("@md-code/follow-architecture/utils/pattern");
|
|
32
|
+
const schema_1 = require("@md-code/follow-architecture/entities/schema");
|
|
33
|
+
const configError = __importStar(require("@md-code/follow-architecture/report/configErrors"));
|
|
9
34
|
// A regex that never matches: the placeholder `re` of a `{ node }` child before
|
|
10
35
|
// `buildTree` gives it the referenced node's own pattern. It is always replaced
|
|
11
36
|
// before anything reads it, but the type stays a `RegExp`.
|
|
@@ -28,7 +53,7 @@ exports.folderContents = folderContents;
|
|
|
28
53
|
const ancestorChain = (node, arch) => {
|
|
29
54
|
const chain = [];
|
|
30
55
|
const seen = new Set();
|
|
31
|
-
for (let cur = node; cur && !seen.has(cur.slug); cur = cur.parents.length === 1 ? arch.nodes.bySlug[cur.parents[0] ?? ""] ?? null : null) {
|
|
56
|
+
for (let cur = node; cur && !seen.has(cur.slug); cur = cur.parents.length === 1 ? (arch.nodes.bySlug[cur.parents[0] ?? ""] ?? null) : null) {
|
|
32
57
|
seen.add(cur.slug);
|
|
33
58
|
chain.push(cur);
|
|
34
59
|
}
|
|
@@ -70,18 +95,29 @@ const nodePrefixRe = (template) => {
|
|
|
70
95
|
return { re: new RegExp(`^${body}/([^/]+)(?:/(.*))?$`), names, literalLen, isFile: false };
|
|
71
96
|
};
|
|
72
97
|
exports.nodePrefixRe = nodePrefixRe;
|
|
73
|
-
// A child may declare which
|
|
98
|
+
// A child may declare which entity(s) live in it: one entity, several entities (a
|
|
74
99
|
// file holding both a model and its types), or none. The NODE says where code
|
|
75
|
-
// lives — the
|
|
76
|
-
const
|
|
77
|
-
const raw = spec?.
|
|
100
|
+
// lives — the entity says what code is, never where it goes.
|
|
101
|
+
const entitiesOf = (spec) => {
|
|
102
|
+
const raw = spec?.entity;
|
|
78
103
|
if (raw == null)
|
|
79
104
|
return [];
|
|
80
105
|
return (Array.isArray(raw) ? raw : [raw]).map(String).filter(Boolean);
|
|
81
106
|
};
|
|
82
|
-
exports.
|
|
107
|
+
exports.entitiesOf = entitiesOf;
|
|
83
108
|
// `{ node: slug }` — the child IS another declared node.
|
|
84
|
-
const referencedChild = (spec) => ({
|
|
109
|
+
const referencedChild = (spec) => ({
|
|
110
|
+
nodeSlug: String(spec.node),
|
|
111
|
+
name: null,
|
|
112
|
+
re: DETACHED,
|
|
113
|
+
captures: [],
|
|
114
|
+
folder: true,
|
|
115
|
+
required: Boolean(spec.required),
|
|
116
|
+
forbidden: Boolean(spec.forbidden),
|
|
117
|
+
query: null,
|
|
118
|
+
report: spec.report ?? null,
|
|
119
|
+
entities: entitiesOf(spec),
|
|
120
|
+
});
|
|
85
121
|
// A child named by a pattern: a FILE child (extension) or a FOLDER child.
|
|
86
122
|
const childOf = (rawName, spec) => {
|
|
87
123
|
const { body, names: captures } = (0, pattern_1.patternBody)(rawName);
|
|
@@ -99,12 +135,19 @@ const childOf = (rawName, spec) => {
|
|
|
99
135
|
// the child's query but sits elsewhere.
|
|
100
136
|
query: spec?.query ?? null,
|
|
101
137
|
report: spec?.report ?? null,
|
|
102
|
-
|
|
138
|
+
entities: entitiesOf(spec),
|
|
103
139
|
};
|
|
104
140
|
};
|
|
105
141
|
const compileChild = (name) => {
|
|
106
|
-
// A child is either a bare name or a spec `{ name?, node?,
|
|
142
|
+
// A child is either a bare name or a spec `{ name?, node?, entity?, required?, forbidden?, query?, report? }`.
|
|
107
143
|
const spec = name && typeof name === "object" ? name : null;
|
|
144
|
+
if (spec) {
|
|
145
|
+
const known = new Set(schema_1.SCHEMA.child);
|
|
146
|
+
for (const key of Object.keys(spec)) {
|
|
147
|
+
if (!known.has(key))
|
|
148
|
+
throw configError.unknownChildKey({ node: String(spec.name ?? spec.node ?? "child"), key });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
108
151
|
if (spec?.node)
|
|
109
152
|
return referencedChild(spec);
|
|
110
153
|
return childOf(String(spec ? spec.name : name), spec);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ArchNode } from "
|
|
2
|
-
import type { FileContext } from "
|
|
3
|
-
import type { Finding, FindingFrom } from "
|
|
1
|
+
import type { ArchNode } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
3
|
+
import type { Finding, FindingFrom } from "@md-code/follow-architecture/entities/findings";
|
|
4
4
|
import type { Violation } from "./violation";
|
|
5
5
|
declare const emitFindings: (violations: Violation[], ctx: FileContext, node: ArchNode, out: Finding[], findingFrom: FindingFrom) => void;
|
|
6
6
|
export { emitFindings };
|
|
@@ -7,24 +7,29 @@ const withoutDeclareDuplicates = (violations) => {
|
|
|
7
7
|
const called = new Set(violations.filter((v) => v.kind === "call").map((v) => `${v.line}|${v.targetPath}`));
|
|
8
8
|
return violations.filter((v) => v.kind !== "declare" || !called.has(`${v.line}|${v.targetPath}`));
|
|
9
9
|
};
|
|
10
|
-
// Same
|
|
11
|
-
const
|
|
10
|
+
// Same entity, several functions: one sentence naming all of them.
|
|
11
|
+
const entitySentence = (v) => {
|
|
12
12
|
const names = (v.names ?? []).filter(Boolean);
|
|
13
|
-
const shown = names
|
|
13
|
+
const shown = names
|
|
14
|
+
.slice(0, 4)
|
|
15
|
+
.map((n) => `\`${n}\``)
|
|
16
|
+
.join(", ");
|
|
14
17
|
const rest = names.length > 4 ? ` and ${names.length - 4} more` : "";
|
|
15
|
-
const tail = v.where
|
|
18
|
+
const tail = v.where
|
|
19
|
+
? `they belong in ${v.where}`
|
|
20
|
+
: `${v.owning ?? "this folder"} declares no home for a \`${v.entity}\``;
|
|
16
21
|
const move = v.where ? `Move ${shown}${rest} to ${v.where}.` : null;
|
|
17
|
-
return { ...v, fix: move, text: `This file declares \`${v.
|
|
22
|
+
return { ...v, fix: move, text: `This file declares \`${v.entity}\` functions (${shown}${rest}): ${tail}.` };
|
|
18
23
|
};
|
|
19
|
-
// One decision per key:
|
|
24
|
+
// One decision per key: an entity's many functions merge into one sentence; any
|
|
20
25
|
// other violation is its own decision, keyed by its text.
|
|
21
26
|
const decisionsOf = (violations) => {
|
|
22
27
|
const byText = new Map();
|
|
23
28
|
for (const v of violations) {
|
|
24
|
-
const key = v.
|
|
29
|
+
const key = v.entity ? `entity:${v.entity}` : v.text;
|
|
25
30
|
const names = (v.names ?? []).filter(Boolean);
|
|
26
|
-
if (v.
|
|
27
|
-
byText.set(key,
|
|
31
|
+
if (v.entity && names.length > 1 && !byText.has(key)) {
|
|
32
|
+
byText.set(key, entitySentence(v));
|
|
28
33
|
continue;
|
|
29
34
|
}
|
|
30
35
|
if (!byText.has(key))
|
|
@@ -35,7 +40,18 @@ const decisionsOf = (violations) => {
|
|
|
35
40
|
// The structured evidence a relation finding carries — the token the report
|
|
36
41
|
// draws, with the target it names.
|
|
37
42
|
const evidenceOf = (v) => v.kind && v.targetNode
|
|
38
|
-
? {
|
|
43
|
+
? {
|
|
44
|
+
violations: [
|
|
45
|
+
{
|
|
46
|
+
kind: v.kind,
|
|
47
|
+
targetNode: v.targetNode,
|
|
48
|
+
targetPath: v.targetPath ?? null,
|
|
49
|
+
line: v.line,
|
|
50
|
+
destination: v.destination ?? null,
|
|
51
|
+
token: v.token ?? null,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
}
|
|
39
55
|
: {};
|
|
40
56
|
const emitFindings = (...args) => {
|
|
41
57
|
const [violations, ctx, node, out, findingFrom] = args;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Arch, WhereEntry } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { Caps } from "@md-code/follow-architecture/entities/location/where";
|
|
3
|
+
declare const fitsEntity: (entitySlug: string, arch: Arch, rel: string) => boolean;
|
|
4
|
+
type AllowedPlace = {
|
|
5
|
+
entity: string | null;
|
|
6
|
+
paths: string[];
|
|
7
|
+
anywhere?: boolean;
|
|
8
|
+
same?: boolean;
|
|
9
|
+
filter?: boolean;
|
|
10
|
+
};
|
|
11
|
+
declare const allowedPlaces: (entries: WhereEntry[] | null | undefined, arch: Arch, targetCaps: Caps | null) => AllowedPlace[];
|
|
12
|
+
export { fitsEntity, allowedPlaces };
|
|
13
|
+
export type { AllowedPlace };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allowedPlaces = exports.fitsEntity = void 0;
|
|
4
|
+
// Entity ↔ place: is this file a home for that entity, and which paths may an
|
|
5
|
+
// action's `from:` list name.
|
|
6
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
7
|
+
const gate_1 = require("@md-code/follow-architecture/utils/gate");
|
|
8
|
+
// Does this file sit in one of the entity's homes? The home question is the ONE
|
|
9
|
+
// implementation in `entities/location/homes` (`entityFitsAt`, asked through the
|
|
10
|
+
// shared `where` grammar). The two exemptions are the shared gate: an entity
|
|
11
|
+
// nobody declares, or one with no home, restricts nothing — when neither
|
|
12
|
+
// rejection fires, the home answer decides.
|
|
13
|
+
const fitsEntity = (entitySlug, arch, rel) => !(0, gate_1.admitsWhenNoneReject)(entitySlug, [(slug) => !arch.entities?.[slug], (slug) => !(0, location_1.homesOf)(arch, slug).length]) ||
|
|
14
|
+
(0, location_1.entityFitsAt)(arch, entitySlug, rel);
|
|
15
|
+
exports.fitsEntity = fitsEntity;
|
|
16
|
+
const entityPlace = (entry, arch, targetCaps) => {
|
|
17
|
+
const homes = (0, location_1.homesOf)(arch, entry.entity ?? "");
|
|
18
|
+
const paths = homes.map((h) => (0, location_1.fillTemplate)(h.template, null, targetCaps)).filter((p) => Boolean(p));
|
|
19
|
+
// `same: true` is part of the RULE, not decoration: an orchestrator may
|
|
20
|
+
// call an action only inside its own feature. The message has to say so,
|
|
21
|
+
// or it reads as "orchestrators may not call actions at all".
|
|
22
|
+
return { entity: entry.entity ?? null, paths, anywhere: !homes.length, same: Boolean(entry.same) };
|
|
23
|
+
};
|
|
24
|
+
const nodePlace = (entry, arch, targetCaps) => {
|
|
25
|
+
const path = (0, location_1.fillTemplate)(arch.nodes?.bySlug?.[entry.node ?? ""]?.path, null, targetCaps);
|
|
26
|
+
return { entity: null, paths: path ? [path] : [] };
|
|
27
|
+
};
|
|
28
|
+
const allowedPlaces = (entries, arch, targetCaps) => {
|
|
29
|
+
const out = [];
|
|
30
|
+
for (const entry of entries ?? []) {
|
|
31
|
+
if (entry.type === "entity")
|
|
32
|
+
out.push(entityPlace(entry, arch, targetCaps));
|
|
33
|
+
else if (entry.type === "node")
|
|
34
|
+
out.push(nodePlace(entry, arch, targetCaps));
|
|
35
|
+
else if (entry.type === "glob")
|
|
36
|
+
out.push({ entity: null, paths: entry.glob ? [entry.glob] : [] });
|
|
37
|
+
else
|
|
38
|
+
out.push({ entity: null, paths: [], filter: true });
|
|
39
|
+
}
|
|
40
|
+
return out;
|
|
41
|
+
};
|
|
42
|
+
exports.allowedPlaces = allowedPlaces;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { EDGE_FACTS } from "
|
|
2
|
-
import {
|
|
3
|
-
import type { Arch, ArchNode } from "
|
|
4
|
-
import type { FileContext } from "
|
|
5
|
-
import type { Finding, FindingFrom } from "
|
|
1
|
+
import { EDGE_FACTS } from "@md-code/follow-architecture/entities/kinds";
|
|
2
|
+
import { fitsEntity } from "./entities";
|
|
3
|
+
import type { Arch, ArchNode } from "@md-code/follow-architecture/entities/architecture";
|
|
4
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
5
|
+
import type { Finding, FindingFrom } from "@md-code/follow-architecture/entities/findings";
|
|
6
6
|
declare const checkFinally: (ctx: FileContext, arch: Arch, out: Finding[], findingFrom: FindingFrom) => void;
|
|
7
7
|
declare const __exported_missingRequiredChild: (node: ArchNode, arch: Arch, rel: string, files: string[] | null | undefined) => boolean;
|
|
8
|
-
export { checkFinally,
|
|
8
|
+
export { checkFinally, fitsEntity, __exported_missingRequiredChild as missingRequiredChild, EDGE_FACTS };
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EDGE_FACTS = exports.missingRequiredChild = exports.
|
|
3
|
+
exports.EDGE_FACTS = exports.missingRequiredChild = exports.fitsEntity = exports.checkFinally = void 0;
|
|
4
4
|
// finally-follow-architecture: the built-in structure rule. Four questions,
|
|
5
5
|
// one module each, no wording (that lives in report/errorTypes).
|
|
6
|
-
const location_1 = require("
|
|
7
|
-
const
|
|
8
|
-
const children_1 = require("
|
|
9
|
-
const kinds_1 = require("
|
|
6
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
7
|
+
const index_1 = require("@md-code/follow-architecture/entities/tree/index");
|
|
8
|
+
const children_1 = require("@md-code/follow-architecture/nodes/children");
|
|
9
|
+
const kinds_1 = require("@md-code/follow-architecture/entities/kinds");
|
|
10
10
|
Object.defineProperty(exports, "EDGE_FACTS", { enumerable: true, get: function () { return kinds_1.EDGE_FACTS; } });
|
|
11
|
-
const
|
|
12
|
-
Object.defineProperty(exports, "
|
|
11
|
+
const entities_1 = require("./entities");
|
|
12
|
+
Object.defineProperty(exports, "fitsEntity", { enumerable: true, get: function () { return entities_1.fitsEntity; } });
|
|
13
13
|
const required_1 = require("./required");
|
|
14
14
|
const queries_1 = require("./queries");
|
|
15
15
|
const relations_1 = require("./relations");
|
|
@@ -25,7 +25,7 @@ const checkNode = (ctx, node, out, findingFrom) => {
|
|
|
25
25
|
(0, emit_1.emitFindings)(violations, ctx, node, out, findingFrom);
|
|
26
26
|
};
|
|
27
27
|
const checkFinally = (ctx, arch, out, findingFrom) => {
|
|
28
|
-
const match = (0,
|
|
28
|
+
const match = (0, index_1.deepestMatch)(ctx.rel, arch);
|
|
29
29
|
if (!match)
|
|
30
30
|
return;
|
|
31
31
|
checkNode(ctx, match.node, out, findingFrom);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ArchNode } from "
|
|
2
|
-
import type { FileContext } from "
|
|
1
|
+
import type { ArchNode } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
3
3
|
import type { Violation } from "./violation";
|
|
4
4
|
declare const checkChildQueries: (ctx: FileContext, node: ArchNode, violations: Violation[]) => void;
|
|
5
5
|
export { checkChildQueries };
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkChildQueries = void 0;
|
|
4
4
|
// A file that matches a declared child's query but sits outside it.
|
|
5
|
-
const queries_1 = require("
|
|
6
|
-
const children_1 = require("
|
|
7
|
-
const location_1 = require("
|
|
5
|
+
const queries_1 = require("@md-code/follow-architecture/entities/queries");
|
|
6
|
+
const children_1 = require("@md-code/follow-architecture/nodes/children");
|
|
7
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
8
8
|
const checkChildQueries = (ctx, node, violations) => {
|
|
9
9
|
for (const child of node.children) {
|
|
10
10
|
if (!child.query)
|
|
@@ -16,7 +16,10 @@ const checkChildQueries = (ctx, node, violations) => {
|
|
|
16
16
|
if (re.test(ctx.rel))
|
|
17
17
|
continue; // already in the right place
|
|
18
18
|
const where = (0, location_1.fillTemplate)(childPath, ctx.rel);
|
|
19
|
-
violations.push({
|
|
19
|
+
violations.push({
|
|
20
|
+
line: 1,
|
|
21
|
+
text: `this file matches the query of node \`${child.slug ?? child.name}\` and belong in \`${where}\``,
|
|
22
|
+
});
|
|
20
23
|
}
|
|
21
24
|
};
|
|
22
25
|
exports.checkChildQueries = checkChildQueries;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Arch, ActionDef } from "
|
|
2
|
-
import type { FileContext } from "
|
|
1
|
+
import type { Arch, ActionDef } from "@md-code/follow-architecture/entities/architecture";
|
|
2
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
3
3
|
import type { Violation } from "./violation";
|
|
4
4
|
declare const checkAccessorImports: (ctx: FileContext, arch: Arch, declared: Map<string, Map<string, ActionDef>>, violations: Violation[]) => void;
|
|
5
5
|
export { checkAccessorImports };
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.checkAccessorImports = void 0;
|
|
4
|
-
// The accessor-import check:
|
|
4
|
+
// The accessor-import check: an entity handed out ONLY through declared accessors
|
|
5
5
|
// (`scopeAccess`) may not be imported by name. The rule is the architecture's
|
|
6
|
-
// own — the engine only reads which accessors
|
|
6
|
+
// own — the engine only reads which accessors an entity declares and which names
|
|
7
7
|
// an import takes out.
|
|
8
|
-
const queries_1 = require("
|
|
9
|
-
const location_1 = require("
|
|
10
|
-
const kinds_1 = require("
|
|
11
|
-
const
|
|
12
|
-
// The function-scope accessors
|
|
8
|
+
const queries_1 = require("@md-code/follow-architecture/entities/queries");
|
|
9
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
10
|
+
const kinds_1 = require("@md-code/follow-architecture/entities/kinds");
|
|
11
|
+
const entities_1 = require("@md-code/follow-architecture/code-entities/entities");
|
|
12
|
+
// The function-scope accessors an entity declares — the only names it is handed
|
|
13
13
|
// out as.
|
|
14
|
-
const accessorsOf = (action) => (action?.scopeAccess ?? []).filter((x) => x.scope ===
|
|
15
|
-
// The
|
|
14
|
+
const accessorsOf = (action) => (action?.scopeAccess ?? []).filter((x) => x.scope === entities_1.SCOPE.FUNCTION).map((x) => x.segments[0]);
|
|
15
|
+
// The entity's own concrete homes (no placeholders): where an import of it may
|
|
16
16
|
// resolve to.
|
|
17
|
-
const ownFilesOf = (arch,
|
|
17
|
+
const ownFilesOf = (arch, entitySlug) => (0, location_1.homesOf)(arch, entitySlug)
|
|
18
18
|
.map((h) => h.template)
|
|
19
19
|
.filter((t) => !/[*{]/.test(t));
|
|
20
|
-
// One
|
|
21
|
-
const
|
|
20
|
+
// One entity's accessor rule, asked of the file's imports.
|
|
21
|
+
const checkEntityAccess = (ctx, entitySlug, accessors, violations) => {
|
|
22
22
|
const arch = ctx.arch;
|
|
23
|
-
const ownFile = ownFilesOf(arch,
|
|
24
|
-
const importFilter = {
|
|
23
|
+
const ownFile = ownFilesOf(arch, entitySlug);
|
|
24
|
+
const importFilter = {
|
|
25
|
+
resolved: { in: ownFile },
|
|
26
|
+
typeOnly: { equals: false },
|
|
27
|
+
named: { any: { not: { in: accessors } } },
|
|
28
|
+
};
|
|
25
29
|
const repoImports = ctx.facts?.imports ?? [];
|
|
26
30
|
const scope = { arch, fileRel: ctx.rel };
|
|
27
31
|
for (const imp of (0, queries_1.hitOf)(repoImports, { any: importFilter }, scope)) {
|
|
@@ -30,17 +34,17 @@ const checkRoleAccess = (ctx, roleSlug, accessors, violations) => {
|
|
|
30
34
|
continue;
|
|
31
35
|
violations.push({
|
|
32
36
|
line: imp.line ?? 1,
|
|
33
|
-
text: `\`${bad.join("`, `")}\` is taken out of \`${imp.resolved}\`, but \`${
|
|
37
|
+
text: `\`${bad.join("`, `")}\` is taken out of \`${imp.resolved}\`, but \`${entitySlug}\` is handed out only as ${accessors.map((a) => `\`${a}(…)\``).join(", ")}`,
|
|
34
38
|
fix: `Import one of the declared accessors (${accessors.join(", ")}) instead of \`${bad[0]}\`.`,
|
|
35
39
|
});
|
|
36
40
|
}
|
|
37
41
|
};
|
|
38
42
|
const checkAccessorImports = (ctx, arch, declared, violations) => {
|
|
39
|
-
for (const
|
|
40
|
-
const accessors = accessorsOf(declared.get(kinds_1.RELATION.CALL)?.get(
|
|
43
|
+
for (const entitySlug of Object.keys(arch.entities ?? {})) {
|
|
44
|
+
const accessors = accessorsOf(declared.get(kinds_1.RELATION.CALL)?.get(entitySlug));
|
|
41
45
|
if (!accessors.length)
|
|
42
46
|
continue;
|
|
43
|
-
|
|
47
|
+
checkEntityAccess(ctx, entitySlug, accessors, violations);
|
|
44
48
|
}
|
|
45
49
|
};
|
|
46
50
|
exports.checkAccessorImports = checkAccessorImports;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { type Edge } from "
|
|
2
|
-
import type { Arch, ActionDef } from "
|
|
3
|
-
import type { FileContext } from "
|
|
4
|
-
import type { Caps } from "
|
|
1
|
+
import { type Edge } from "@md-code/follow-architecture/entities/kinds";
|
|
2
|
+
import type { Arch, ActionDef } from "@md-code/follow-architecture/entities/architecture";
|
|
3
|
+
import type { FileContext } from "@md-code/follow-architecture/entities/context";
|
|
4
|
+
import type { Caps } from "@md-code/follow-architecture/entities/location/where";
|
|
5
5
|
import type { RelationGroup } from "./relations-group";
|
|
6
6
|
type Pair = {
|
|
7
7
|
targetSlug: string;
|
|
@@ -21,7 +21,7 @@ type JudgeCtx = {
|
|
|
21
21
|
arch: Arch;
|
|
22
22
|
kind: string;
|
|
23
23
|
actionDecls: Map<string, ActionDef>;
|
|
24
|
-
|
|
24
|
+
fileEntities: string[];
|
|
25
25
|
};
|
|
26
26
|
declare const judgeEdge: (edge: Edge, jctx: JudgeCtx) => EdgeJudgment | null;
|
|
27
27
|
declare const joinGroup: (group: RelationGroup, edge: Edge) => void;
|
|
@@ -1,53 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.joinGroup = exports.judgeEdge = void 0;
|
|
4
|
-
// ONE edge, judged by the
|
|
4
|
+
// ONE edge, judged by the entity that owns its target: which target entities could
|
|
5
5
|
// allow it, what each declares, and whether every one of them refuses. The
|
|
6
6
|
// ranking picks the refusal that explains the rule best; only when EVERY
|
|
7
7
|
// target refuses is there a finding to group.
|
|
8
|
-
const location_1 = require("
|
|
9
|
-
const
|
|
10
|
-
const kinds_1 = require("
|
|
11
|
-
const verdicts_1 = require("
|
|
12
|
-
const permission_1 = require("
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
//
|
|
8
|
+
const location_1 = require("@md-code/follow-architecture/entities/location");
|
|
9
|
+
const index_1 = require("@md-code/follow-architecture/entities/tree/index");
|
|
10
|
+
const kinds_1 = require("@md-code/follow-architecture/entities/kinds");
|
|
11
|
+
const verdicts_1 = require("@md-code/follow-architecture/utils/verdicts");
|
|
12
|
+
const permission_1 = require("@md-code/follow-architecture/utils/permission");
|
|
13
|
+
const entities_1 = require("./entities");
|
|
14
|
+
const observed_1 = require("@md-code/follow-architecture/report/observed");
|
|
15
|
+
// The entities the edge's SOURCE speaks with: the piece's own entity when it has
|
|
16
|
+
// one; a file-level statement speaks with the file's entities; an unclassified piece
|
|
16
17
|
// speaks with none.
|
|
17
|
-
const
|
|
18
|
-
const own = edge.
|
|
19
|
-
return edge.piece && !edge.
|
|
18
|
+
const sourceEntitiesOf = (edge, fileEntities) => {
|
|
19
|
+
const own = edge.entity ? [edge.entity] : [...fileEntities];
|
|
20
|
+
return edge.piece && !edge.entity ? [] : own;
|
|
20
21
|
};
|
|
21
|
-
// The
|
|
22
|
-
// own
|
|
23
|
-
const
|
|
22
|
+
// The entities the TARGET may be judged by: a self-statement keeps the source's
|
|
23
|
+
// own entities; anything else asks the tree what is declared at the target path.
|
|
24
|
+
const targetEntitiesOf = (edge, jctx, selfStatement) => {
|
|
24
25
|
if (!selfStatement)
|
|
25
|
-
return (0, location_1.
|
|
26
|
-
if (edge.
|
|
27
|
-
return [edge.
|
|
28
|
-
return jctx.
|
|
26
|
+
return (0, location_1.entitiesAtPath)(jctx.arch, edge.path);
|
|
27
|
+
if (edge.entity)
|
|
28
|
+
return [edge.entity];
|
|
29
|
+
return jctx.fileEntities.length ? jctx.fileEntities : (0, location_1.entitiesAtPath)(jctx.arch, edge.path);
|
|
29
30
|
};
|
|
30
|
-
// The scope one action is judged in: the file's facts, the source's
|
|
31
|
+
// The scope one action is judged in: the file's facts, the source's entities,
|
|
31
32
|
// and the edge itself (the call may need WHAT was passed).
|
|
32
|
-
const scopeOf = (ctx,
|
|
33
|
+
const scopeOf = (ctx, sourceEntities, edge) => {
|
|
33
34
|
const facts = ctx.facts;
|
|
34
|
-
const base = facts ?? {
|
|
35
|
-
|
|
35
|
+
const base = facts ?? {
|
|
36
|
+
lines: [],
|
|
37
|
+
imports: [],
|
|
38
|
+
exports: [],
|
|
39
|
+
location: { path: ctx.rel, segments: [], exts: [], fileName: "", words: [], files: [], siblings: [] },
|
|
40
|
+
reads: [],
|
|
41
|
+
kind: { own: { is: "SourceFile" }, descendants: [] },
|
|
42
|
+
candidates: [],
|
|
43
|
+
entities: [],
|
|
44
|
+
};
|
|
45
|
+
return { ...base, entities: sourceEntities, edge: edge.fact ?? null };
|
|
36
46
|
};
|
|
37
|
-
// One target
|
|
47
|
+
// One target entity's verdict: the action it declares for this fact kind (or a
|
|
38
48
|
// missing one), and whether the source may do it. The allow/except walk is the
|
|
39
|
-
// shared `permissionOf` core; a source with no
|
|
40
|
-
const pairOf = (targetSlug, edge,
|
|
49
|
+
// shared `permissionOf` core; a source with no entities is granted nothing.
|
|
50
|
+
const pairOf = (targetSlug, edge, sourceEntities, jctx) => {
|
|
41
51
|
const { ctx, arch } = jctx;
|
|
42
|
-
const caps = (0,
|
|
52
|
+
const caps = (0, index_1.targetCapsFor)(edge.path ?? "", arch);
|
|
43
53
|
const action = jctx.actionDecls.get(targetSlug);
|
|
44
54
|
if (!action)
|
|
45
55
|
return { targetSlug, action: { where: [], missing: true }, caps, violation: true };
|
|
46
|
-
const { allowed, denied } = (0, permission_1.permissionOf)(action, {
|
|
47
|
-
|
|
56
|
+
const { allowed, denied } = (0, permission_1.permissionOf)(action, {
|
|
57
|
+
rel: ctx.rel,
|
|
58
|
+
arch,
|
|
59
|
+
scope: scopeOf(ctx, sourceEntities, edge),
|
|
60
|
+
caps,
|
|
61
|
+
});
|
|
62
|
+
const violation = sourceEntities.length ? !allowed || denied : true;
|
|
48
63
|
return { targetSlug, action, caps, violation, outward: denied };
|
|
49
64
|
};
|
|
50
|
-
//
|
|
65
|
+
// An entity that NAMES who may do it explains the rule best; a declared action
|
|
51
66
|
// beats a missing one; fewer conditions beat more.
|
|
52
67
|
const rankPairs = (a, b) => Number(Boolean(b.action.where?.length)) - Number(Boolean(a.action.where?.length)) ||
|
|
53
68
|
Number(!b.action.missing) - Number(!a.action.missing) ||
|
|
@@ -61,30 +76,35 @@ const routeOf = (targetSlug, jctx, caps) => {
|
|
|
61
76
|
const route = callOk ? ((callDecl?.scopeAccess ?? [])[0] ?? null) : null;
|
|
62
77
|
return route ? (0, location_1.accessorLabel)(route) : null;
|
|
63
78
|
};
|
|
64
|
-
const declaredCall = (jctx, targetSlug) => jctx.ctx.arch.
|
|
79
|
+
const declaredCall = (jctx, targetSlug) => jctx.ctx.arch.entities[targetSlug]?.actions[kinds_1.RELATION.CALL] ?? null;
|
|
65
80
|
// The concrete destinations the refusal can offer: the allowed places that
|
|
66
81
|
// are not the target itself, not this file, not this folder.
|
|
67
82
|
const destOf = (places, targetSlug, rel) => {
|
|
68
|
-
const others = places.filter((p) => p.
|
|
83
|
+
const others = places.filter((p) => p.entity !== targetSlug);
|
|
69
84
|
const spots = (others.length ? others : places)
|
|
70
85
|
.filter((pl) => !pl.filter)
|
|
71
|
-
.flatMap((pl) => pl.paths.map((path) => ({
|
|
72
|
-
.filter((sp) => sp.path !== rel && sp.path !== (0, location_1.dirOf)(rel) && sp.
|
|
86
|
+
.flatMap((pl) => pl.paths.map((path) => ({ entity: pl.entity, path })))
|
|
87
|
+
.filter((sp) => sp.path !== rel && sp.path !== (0, location_1.dirOf)(rel) && sp.entity !== targetSlug);
|
|
73
88
|
return spots[0]?.path ?? null;
|
|
74
89
|
};
|
|
75
|
-
// The group one refused edge starts or joins. The allowed
|
|
90
|
+
// The group one refused edge starts or joins. The allowed entities are the
|
|
76
91
|
// places WITHOUT the target itself (the target cannot allow its own refusal);
|
|
77
92
|
// only when no other place exists does the target's own list stand.
|
|
78
93
|
const groupOf = (edge, pair, jctx, all) => {
|
|
79
94
|
const { ctx, kind } = jctx;
|
|
80
95
|
const route = routeOf(pair.targetSlug, jctx, pair.caps);
|
|
81
|
-
const others = all.filter((p) => p.
|
|
96
|
+
const others = all.filter((p) => p.entity !== pair.targetSlug);
|
|
82
97
|
const places = others.length ? others : all;
|
|
83
98
|
return {
|
|
84
99
|
kind,
|
|
85
100
|
targetNode: pair.targetSlug,
|
|
86
|
-
|
|
87
|
-
|
|
101
|
+
allowedEntities: [...new Set(places.map((pl) => pl.entity).filter((r) => Boolean(r)))],
|
|
102
|
+
sameEntities: [
|
|
103
|
+
...new Set(places
|
|
104
|
+
.filter((pl) => pl.same)
|
|
105
|
+
.map((pl) => pl.entity)
|
|
106
|
+
.filter((r) => Boolean(r))),
|
|
107
|
+
],
|
|
88
108
|
via: (pair.action.scopeAccess ?? []).map(location_1.accessorLabel),
|
|
89
109
|
route,
|
|
90
110
|
dest: destOf(all, pair.targetSlug, ctx.rel),
|
|
@@ -93,23 +113,26 @@ const groupOf = (edge, pair, jctx, all) => {
|
|
|
93
113
|
path: edge.path,
|
|
94
114
|
pieces: new Map(),
|
|
95
115
|
piece: edge.piece ?? null,
|
|
96
|
-
|
|
116
|
+
pieceEntity: edge.entity ?? null,
|
|
97
117
|
silent: Boolean(pair.action.missing) || !(pair.action.where ?? []).length,
|
|
98
118
|
filtered: Boolean(pair.outward),
|
|
99
119
|
self: edge.path === ctx.rel,
|
|
100
120
|
fact: edge.fact ?? null,
|
|
101
121
|
};
|
|
102
122
|
};
|
|
103
|
-
//
|
|
123
|
+
// What the scan SAW is recorded before the judgment drops the allowed edges below:
|
|
124
|
+
// the graph draws them, and this is the only place both halves are still together.
|
|
125
|
+
// Judge one edge: every target entity's verdict, ranked; when ALL refuse, the
|
|
104
126
|
// best-explaining one names the group.
|
|
105
127
|
const judgeEdge = (edge, jctx) => {
|
|
106
|
-
const
|
|
128
|
+
const sourceEntities = sourceEntitiesOf(edge, jctx.fileEntities);
|
|
107
129
|
const selfStatement = edge.path === jctx.ctx.rel;
|
|
108
|
-
const pairs =
|
|
130
|
+
const pairs = targetEntitiesOf(edge, jctx, selfStatement).map((slug) => pairOf(slug, edge, sourceEntities, jctx));
|
|
131
|
+
(0, observed_1.recordJudged)({ kind: jctx.kind, file: jctx.ctx.rel, line: edge.line ?? 1, sentence: edge.what }, sourceEntities, pairs);
|
|
109
132
|
const worst = (0, verdicts_1.worstWhenAllRefuse)(pairs, rankPairs);
|
|
110
133
|
if (!worst)
|
|
111
134
|
return null;
|
|
112
|
-
const places = (0,
|
|
135
|
+
const places = (0, entities_1.allowedPlaces)(worst.action.where, jctx.arch, worst.caps);
|
|
113
136
|
const group = groupOf(edge, worst, jctx, places);
|
|
114
137
|
const key = `${jctx.kind}|${worst.targetSlug}|${edge.what}`;
|
|
115
138
|
return { key, group };
|
|
@@ -120,6 +143,6 @@ const joinGroup = (group, edge) => {
|
|
|
120
143
|
group.lines.push(edge.line ?? 1);
|
|
121
144
|
group.what.add(edge.what);
|
|
122
145
|
if (edge.piece)
|
|
123
|
-
group.pieces.set(edge.piece, edge.
|
|
146
|
+
group.pieces.set(edge.piece, edge.entity ?? null);
|
|
124
147
|
};
|
|
125
148
|
exports.joinGroup = joinGroup;
|