@md-code/follow-architecture 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/LICENSE +202 -0
- package/README.md +584 -141
- package/dist/aliases.d.ts +3 -0
- package/dist/aliases.js +12 -0
- package/dist/args.d.ts +14 -0
- package/dist/args.js +77 -0
- package/dist/bin/follow-architecture.d.ts +2 -0
- package/dist/bin/follow-architecture.js +23 -0
- package/dist/code-roles/classify.d.ts +11 -0
- package/dist/code-roles/classify.js +43 -0
- package/dist/code-roles/connector.d.ts +5 -0
- package/dist/code-roles/connector.js +114 -0
- package/dist/code-roles/project.d.ts +12 -0
- package/dist/code-roles/project.js +122 -0
- package/dist/code-roles/roles.d.ts +8 -0
- package/dist/code-roles/roles.js +190 -0
- package/dist/config-options.d.ts +53 -0
- package/dist/config-options.js +35 -0
- package/dist/config-project.d.ts +4 -0
- package/dist/config-project.js +74 -0
- package/dist/config-report.d.ts +19 -0
- package/dist/config-report.js +134 -0
- package/dist/config-rule.d.ts +70 -0
- package/dist/config-rule.js +118 -0
- package/dist/config-state.d.ts +14 -0
- package/dist/config-state.js +96 -0
- package/dist/config.d.ts +82 -0
- package/dist/config.js +38 -0
- package/dist/css/index.d.ts +27 -0
- package/dist/css/index.js +140 -0
- package/dist/css/syntax/css/gate.d.ts +2 -0
- package/dist/css/syntax/css/gate.js +69 -0
- package/dist/css/syntax/css/index.d.ts +7 -0
- package/dist/css/syntax/css/index.js +41 -0
- package/dist/css/syntax/css/reference.d.ts +3 -0
- package/dist/css/syntax/css/reference.js +24 -0
- package/dist/css/syntax/language.d.ts +25 -0
- package/dist/css/syntax/language.js +69 -0
- package/dist/css/syntax/scss/index.d.ts +25 -0
- package/dist/css/syntax/scss/index.js +85 -0
- package/dist/css/syntax/scss/reference.d.ts +3 -0
- package/dist/css/syntax/scss/reference.js +11 -0
- package/dist/css/syntax/styled/document.d.ts +68 -0
- package/dist/css/syntax/styled/document.js +241 -0
- package/dist/css/syntax/styled/markup.d.ts +6 -0
- package/dist/css/syntax/styled/markup.js +76 -0
- package/dist/css/syntax/styled/template.d.ts +23 -0
- package/dist/css/syntax/styled/template.js +61 -0
- package/dist/css/syntax/tailwind/tailwind-engine.d.ts +23 -0
- package/dist/css/syntax/tailwind/tailwind-engine.js +37 -0
- package/dist/css/syntax/tailwind/tailwind.d.ts +26 -0
- package/dist/css/syntax/tailwind/tailwind.js +118 -0
- package/dist/css/value/check.d.ts +86 -0
- package/dist/css/value/check.js +122 -0
- package/dist/css/value/expression/arithmetic.d.ts +7 -0
- package/dist/css/value/expression/arithmetic.js +69 -0
- package/dist/css/value/expression/block.d.ts +9 -0
- package/dist/css/value/expression/block.js +91 -0
- package/dist/css/value/expression/conditional.d.ts +8 -0
- package/dist/css/value/expression/conditional.js +53 -0
- package/dist/css/value/expression/index.d.ts +5 -0
- package/dist/css/value/expression/index.js +69 -0
- package/dist/css/value/expression/map.d.ts +7 -0
- package/dist/css/value/expression/map.js +113 -0
- package/dist/css/value/object/index.d.ts +5 -0
- package/dist/css/value/object/index.js +103 -0
- package/dist/css/value/object/members.d.ts +7 -0
- package/dist/css/value/object/members.js +103 -0
- package/dist/css/value/object/node.d.ts +8 -0
- package/dist/css/value/object/node.js +129 -0
- package/dist/css/value/object/path.d.ts +10 -0
- package/dist/css/value/object/path.js +146 -0
- package/dist/css/value/pieces.d.ts +61 -0
- package/dist/css/value/pieces.js +55 -0
- package/dist/css/value/resolve.d.ts +33 -0
- package/dist/css/value/resolve.js +94 -0
- package/dist/css/value/scope.d.ts +27 -0
- package/dist/css/value/scope.js +187 -0
- package/dist/css/value/substitute.d.ts +10 -0
- package/dist/css/value/substitute.js +113 -0
- package/dist/css/value/values.d.ts +23 -0
- package/dist/css/value/values.js +131 -0
- package/dist/entities/architecture.d.ts +162 -0
- package/dist/entities/architecture.js +2 -0
- package/dist/entities/ast/assignments-nodes.d.ts +10 -0
- package/dist/entities/ast/assignments-nodes.js +64 -0
- package/dist/entities/ast/assignments-raw.d.ts +6 -0
- package/dist/entities/ast/assignments-raw.js +86 -0
- package/dist/entities/ast/assignments-tagged.d.ts +5 -0
- package/dist/entities/ast/assignments-tagged.js +180 -0
- package/dist/entities/ast/assignments.d.ts +9 -0
- package/dist/entities/ast/assignments.js +78 -0
- package/dist/entities/ast/branches.d.ts +4 -0
- package/dist/entities/ast/branches.js +32 -0
- package/dist/entities/ast/calls.d.ts +6 -0
- package/dist/entities/ast/calls.js +134 -0
- package/dist/entities/ast/classes.d.ts +5 -0
- package/dist/entities/ast/classes.js +57 -0
- package/dist/entities/ast/climb.d.ts +12 -0
- package/dist/entities/ast/climb.js +17 -0
- package/dist/entities/ast/comments.d.ts +4 -0
- package/dist/entities/ast/comments.js +100 -0
- package/dist/entities/ast/declaration.d.ts +4 -0
- package/dist/entities/ast/declaration.js +26 -0
- package/dist/entities/ast/depth.d.ts +17 -0
- package/dist/entities/ast/depth.js +149 -0
- package/dist/entities/ast/enums.d.ts +6 -0
- package/dist/entities/ast/enums.js +17 -0
- package/dist/entities/ast/file-exports.d.ts +7 -0
- package/dist/entities/ast/file-exports.js +78 -0
- package/dist/entities/ast/file-facts.d.ts +13 -0
- package/dist/entities/ast/file-facts.js +35 -0
- package/dist/entities/ast/file-imports.d.ts +5 -0
- package/dist/entities/ast/file-imports.js +77 -0
- package/dist/entities/ast/file.d.ts +5 -0
- package/dist/entities/ast/file.js +22 -0
- package/dist/entities/ast/functions.d.ts +8 -0
- package/dist/entities/ast/functions.js +102 -0
- package/dist/entities/ast/heritage.d.ts +4 -0
- package/dist/entities/ast/heritage.js +36 -0
- package/dist/entities/ast/index.d.ts +6 -0
- package/dist/entities/ast/index.js +125 -0
- package/dist/entities/ast/kind.d.ts +5 -0
- package/dist/entities/ast/kind.js +28 -0
- package/dist/entities/ast/loose.d.ts +37 -0
- package/dist/entities/ast/loose.js +2 -0
- package/dist/entities/ast/modifiers.d.ts +5 -0
- package/dist/entities/ast/modifiers.js +32 -0
- package/dist/entities/ast/project.d.ts +9 -0
- package/dist/entities/ast/project.js +75 -0
- package/dist/entities/ast/properties.d.ts +11 -0
- package/dist/entities/ast/properties.js +171 -0
- package/dist/entities/ast/resolve.d.ts +16 -0
- package/dist/entities/ast/resolve.js +307 -0
- package/dist/entities/ast/tree.d.ts +29 -0
- package/dist/entities/ast/tree.js +351 -0
- package/dist/entities/ast/types.d.ts +6 -0
- package/dist/entities/ast/types.js +45 -0
- package/dist/entities/ast/usage.d.ts +11 -0
- package/dist/entities/ast/usage.js +81 -0
- package/dist/entities/ast/variables.d.ts +8 -0
- package/dist/entities/ast/variables.js +91 -0
- package/dist/entities/context.d.ts +29 -0
- package/dist/entities/context.js +2 -0
- package/dist/entities/facts.d.ts +261 -0
- package/dist/entities/facts.js +2 -0
- package/dist/entities/findings.d.ts +19 -0
- package/dist/entities/findings.js +2 -0
- package/dist/entities/kinds.d.ts +40 -0
- package/dist/entities/kinds.js +221 -0
- package/dist/entities/location/homes.d.ts +28 -0
- package/dist/entities/location/homes.js +169 -0
- package/dist/entities/location/place.d.ts +10 -0
- package/dist/entities/location/place.js +56 -0
- package/dist/entities/location/where.d.ts +17 -0
- package/dist/entities/location/where.js +218 -0
- package/dist/entities/location.d.ts +16 -0
- package/dist/entities/location.js +140 -0
- package/dist/entities/operators.d.ts +14 -0
- package/dist/entities/operators.js +30 -0
- package/dist/entities/overview/data.d.ts +43 -0
- package/dist/entities/overview/data.js +2 -0
- package/dist/entities/overview/decision.d.ts +60 -0
- package/dist/entities/overview/decision.js +2 -0
- package/dist/entities/overview/file-tree.d.ts +10 -0
- package/dist/entities/overview/file-tree.js +2 -0
- package/dist/entities/overview/finding.d.ts +58 -0
- package/dist/entities/overview/finding.js +2 -0
- package/dist/entities/overview/graph.d.ts +65 -0
- package/dist/entities/overview/graph.js +2 -0
- package/dist/entities/overview/input.d.ts +15 -0
- package/dist/entities/overview/input.js +2 -0
- package/dist/entities/overview/summaries.d.ts +79 -0
- package/dist/entities/overview/summaries.js +2 -0
- package/dist/entities/place.d.ts +5 -0
- package/dist/entities/place.js +2 -0
- package/dist/entities/queries.d.ts +9 -0
- package/dist/entities/queries.js +305 -0
- package/dist/entities/repair.d.ts +16 -0
- package/dist/entities/repair.js +23 -0
- package/dist/entities/schema.d.ts +8 -0
- package/dist/entities/schema.js +23 -0
- package/dist/entities/story.d.ts +47 -0
- package/dist/entities/story.js +2 -0
- package/dist/entities/structure-facts.d.ts +11 -0
- package/dist/entities/structure-facts.js +2 -0
- package/dist/entities/token.d.ts +23 -0
- package/dist/entities/token.js +2 -0
- package/dist/entities/tree/build.d.ts +5 -0
- package/dist/entities/tree/build.js +252 -0
- package/dist/entities/tree/entries.d.ts +7 -0
- package/dist/entities/tree/entries.js +120 -0
- package/dist/entities/tree/index.d.ts +6 -0
- package/dist/entities/tree/index.js +21 -0
- package/dist/entities/tree/match.d.ts +17 -0
- package/dist/entities/tree/match.js +176 -0
- package/dist/frameworks/angular/index.d.ts +7 -0
- package/dist/frameworks/angular/index.js +17 -0
- package/dist/frameworks/facet.d.ts +16 -0
- package/dist/frameworks/facet.js +2 -0
- package/dist/frameworks/index.d.ts +9 -0
- package/dist/frameworks/index.js +120 -0
- package/dist/frameworks/react/index.d.ts +7 -0
- package/dist/frameworks/react/index.js +214 -0
- package/dist/frameworks/vue/index.d.ts +7 -0
- package/dist/frameworks/vue/index.js +17 -0
- package/dist/invariants/index.d.ts +6 -0
- package/dist/invariants/index.js +299 -0
- package/dist/invariants/list-vars.d.ts +5 -0
- package/dist/invariants/list-vars.js +143 -0
- package/dist/invariants/name.d.ts +16 -0
- package/dist/invariants/name.js +18 -0
- package/dist/invariants/normalize.d.ts +4 -0
- package/dist/invariants/normalize.js +95 -0
- package/dist/invariants/vars.d.ts +20 -0
- package/dist/invariants/vars.js +117 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.js +229 -0
- package/dist/nodes/child-roles.d.ts +3 -0
- package/dist/nodes/child-roles.js +12 -0
- package/dist/nodes/children.d.ts +25 -0
- package/dist/nodes/children.js +112 -0
- package/dist/nodes/finally/emit.d.ts +6 -0
- package/dist/nodes/finally/emit.js +55 -0
- package/dist/nodes/finally/index.d.ts +8 -0
- package/dist/nodes/finally/index.js +35 -0
- package/dist/nodes/finally/queries.d.ts +5 -0
- package/dist/nodes/finally/queries.js +22 -0
- package/dist/nodes/finally/relations-access.d.ts +5 -0
- package/dist/nodes/finally/relations-access.js +46 -0
- package/dist/nodes/finally/relations-edge.d.ts +29 -0
- package/dist/nodes/finally/relations-edge.js +125 -0
- package/dist/nodes/finally/relations-group.d.ts +31 -0
- package/dist/nodes/finally/relations-group.js +103 -0
- package/dist/nodes/finally/relations.d.ts +5 -0
- package/dist/nodes/finally/relations.js +81 -0
- package/dist/nodes/finally/required.d.ts +5 -0
- package/dist/nodes/finally/required.js +90 -0
- package/dist/nodes/finally/roles.d.ts +13 -0
- package/dist/nodes/finally/roles.js +41 -0
- package/dist/nodes/finally/violation.d.ts +17 -0
- package/dist/nodes/finally/violation.js +2 -0
- package/dist/nodes/similar.d.ts +21 -0
- package/dist/nodes/similar.js +156 -0
- package/dist/pipeline-facts.d.ts +11 -0
- package/dist/pipeline-facts.js +112 -0
- package/dist/pipeline-roles.d.ts +6 -0
- package/dist/pipeline-roles.js +75 -0
- package/dist/pipeline-unroled.d.ts +14 -0
- package/dist/pipeline-unroled.js +193 -0
- package/dist/pipeline.d.ts +7 -0
- package/dist/pipeline.js +73 -0
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.js +3 -0
- package/dist/report/asks.d.ts +55 -0
- package/dist/report/asks.js +50 -0
- package/dist/report/cli-report.d.ts +2 -0
- package/dist/report/cli-report.js +13 -0
- package/dist/report/config-error-guard.d.ts +8 -0
- package/dist/report/config-error-guard.js +5 -0
- package/dist/report/configErrors.d.ts +98 -0
- package/dist/report/configErrors.js +75 -0
- package/dist/report/errorTypes/codes/structure.d.ts +15 -0
- package/dist/report/errorTypes/codes/structure.js +76 -0
- package/dist/report/errorTypes/decision-maker.d.ts +23 -0
- package/dist/report/errorTypes/decision-maker.js +99 -0
- package/dist/report/errorTypes/destinations.d.ts +38 -0
- package/dist/report/errorTypes/destinations.js +147 -0
- package/dist/report/errorTypes/finding-type.d.ts +11 -0
- package/dist/report/errorTypes/finding-type.js +2 -0
- package/dist/report/errorTypes/index.d.ts +15 -0
- package/dist/report/errorTypes/index.js +45 -0
- package/dist/report/errorTypes/types/fileContents.d.ts +9 -0
- package/dist/report/errorTypes/types/fileContents.js +34 -0
- package/dist/report/errorTypes/types/unknownRole.d.ts +9 -0
- package/dist/report/errorTypes/types/unknownRole.js +22 -0
- package/dist/report/errorTypes/types/wrongAction.d.ts +22 -0
- package/dist/report/errorTypes/types/wrongAction.js +135 -0
- package/dist/report/errorTypes/types/wrongPlacement.d.ts +9 -0
- package/dist/report/errorTypes/types/wrongPlacement.js +57 -0
- package/dist/report/errorTypes/vocabulary/ids.d.ts +5 -0
- package/dist/report/errorTypes/vocabulary/ids.js +16 -0
- package/dist/report/errorTypes/vocabulary/phrases.d.ts +10 -0
- package/dist/report/errorTypes/vocabulary/phrases.js +174 -0
- package/dist/report/errorTypes/vocabulary/places.d.ts +8 -0
- package/dist/report/errorTypes/vocabulary/places.js +36 -0
- package/dist/report/errorTypes/vocabulary/verbs.d.ts +7 -0
- package/dist/report/errorTypes/vocabulary/verbs.js +30 -0
- package/dist/report/finding-from.d.ts +9 -0
- package/dist/report/finding-from.js +103 -0
- package/dist/report/notices.d.ts +4 -0
- package/dist/report/notices.js +31 -0
- package/dist/report/render-report.d.ts +12 -0
- package/dist/report/render-report.js +142 -0
- package/dist/report/user-report/build/bundle.d.ts +3 -0
- package/dist/report/user-report/build/bundle.js +169 -0
- package/dist/report/user-report/build/bundle.prebuilt.js +760 -0
- package/dist/report/user-report/data/collect.d.ts +4 -0
- package/dist/report/user-report/data/collect.js +80 -0
- package/dist/report/user-report/data/file-tree.d.ts +9 -0
- package/dist/report/user-report/data/file-tree.js +72 -0
- package/dist/report/user-report/data/finding-boundary.d.ts +9 -0
- package/dist/report/user-report/data/finding-boundary.js +21 -0
- package/dist/report/user-report/data/finding-plan.d.ts +16 -0
- package/dist/report/user-report/data/finding-plan.js +45 -0
- package/dist/report/user-report/data/finding-title.d.ts +12 -0
- package/dist/report/user-report/data/finding-title.js +36 -0
- package/dist/report/user-report/data/findings.d.ts +10 -0
- package/dist/report/user-report/data/findings.js +171 -0
- package/dist/report/user-report/data/graph-edges.d.ts +19 -0
- package/dist/report/user-report/data/graph-edges.js +109 -0
- package/dist/report/user-report/data/graph-helpers.d.ts +7 -0
- package/dist/report/user-report/data/graph-helpers.js +67 -0
- package/dist/report/user-report/data/graph-roles.d.ts +5 -0
- package/dist/report/user-report/data/graph-roles.js +71 -0
- package/dist/report/user-report/data/graph.d.ts +11 -0
- package/dist/report/user-report/data/graph.js +90 -0
- package/dist/report/user-report/data/invariants.d.ts +7 -0
- package/dist/report/user-report/data/invariants.js +62 -0
- package/dist/report/user-report/data/nodes.d.ts +11 -0
- package/dist/report/user-report/data/nodes.js +106 -0
- package/dist/report/user-report/data/role-examples.d.ts +16 -0
- package/dist/report/user-report/data/role-examples.js +94 -0
- package/dist/report/user-report/data/role-filters.d.ts +15 -0
- package/dist/report/user-report/data/role-filters.js +79 -0
- package/dist/report/user-report/data/role-marks.d.ts +5 -0
- package/dist/report/user-report/data/role-marks.js +79 -0
- package/dist/report/user-report/data/roles.d.ts +7 -0
- package/dist/report/user-report/data/roles.js +83 -0
- package/dist/report/user-report/data/scan.d.ts +8 -0
- package/dist/report/user-report/data/scan.js +59 -0
- package/dist/report/user-report/html/shell.d.ts +3 -0
- package/dist/report/user-report/html/shell.js +27 -0
- package/dist/report/user-report/index.d.ts +8 -0
- package/dist/report/user-report/index.js +48 -0
- package/dist/report/user-report/shared/describe.d.ts +7 -0
- package/dist/report/user-report/shared/describe.js +86 -0
- package/dist/scripts/audit-report.d.ts +2 -0
- package/dist/scripts/audit-report.js +147 -0
- package/dist/utils/accumulate.d.ts +6 -0
- package/dist/utils/accumulate.js +18 -0
- package/dist/utils/article.d.ts +2 -0
- package/dist/utils/article.js +12 -0
- package/dist/utils/classify.d.ts +12 -0
- package/dist/utils/classify.js +25 -0
- package/dist/utils/configs.d.ts +25 -0
- package/dist/utils/configs.js +87 -0
- package/dist/utils/count.d.ts +7 -0
- package/dist/utils/count.js +13 -0
- package/dist/utils/dispatch.d.ts +2 -0
- package/dist/utils/dispatch.js +27 -0
- package/dist/utils/distinct.d.ts +2 -0
- package/dist/utils/distinct.js +12 -0
- package/dist/utils/field.d.ts +14 -0
- package/dist/utils/field.js +60 -0
- package/dist/utils/file-name.d.ts +2 -0
- package/dist/utils/file-name.js +11 -0
- package/dist/utils/files.d.ts +7 -0
- package/dist/utils/files.js +73 -0
- package/dist/utils/fixpoint.d.ts +2 -0
- package/dist/utils/fixpoint.js +19 -0
- package/dist/utils/gate.d.ts +2 -0
- package/dist/utils/gate.js +12 -0
- package/dist/utils/group.d.ts +3 -0
- package/dist/utils/group.js +33 -0
- package/dist/utils/host.d.ts +3 -0
- package/dist/utils/host.js +13 -0
- package/dist/utils/imports.d.ts +12 -0
- package/dist/utils/imports.js +121 -0
- package/dist/utils/judged.d.ts +5 -0
- package/dist/utils/judged.js +19 -0
- package/dist/utils/keyed.d.ts +2 -0
- package/dist/utils/keyed.js +23 -0
- package/dist/utils/map-record.d.ts +2 -0
- package/dist/utils/map-record.js +11 -0
- package/dist/utils/path-label.d.ts +6 -0
- package/dist/utils/path-label.js +35 -0
- package/dist/utils/pattern.d.ts +18 -0
- package/dist/utils/pattern.js +191 -0
- package/dist/utils/permission.d.ts +16 -0
- package/dist/utils/permission.js +16 -0
- package/dist/utils/plural.d.ts +2 -0
- package/dist/utils/plural.js +9 -0
- package/dist/utils/qualified.d.ts +2 -0
- package/dist/utils/qualified.js +21 -0
- package/dist/utils/rank.d.ts +2 -0
- package/dist/utils/rank.js +24 -0
- package/dist/utils/read-field.d.ts +12 -0
- package/dist/utils/read-field.js +50 -0
- package/dist/utils/read-when.d.ts +2 -0
- package/dist/utils/read-when.js +17 -0
- package/dist/utils/reason.d.ts +4 -0
- package/dist/utils/reason.js +9 -0
- package/dist/utils/record.d.ts +3 -0
- package/dist/utils/record.js +21 -0
- package/dist/utils/resolve.d.ts +2 -0
- package/dist/utils/resolve.js +24 -0
- package/dist/utils/search.d.ts +2 -0
- package/dist/utils/search.js +16 -0
- package/dist/utils/seen.d.ts +6 -0
- package/dist/utils/seen.js +27 -0
- package/dist/utils/span.d.ts +5 -0
- package/dist/utils/span.js +2 -0
- package/dist/utils/speak.d.ts +2 -0
- package/dist/utils/speak.js +18 -0
- package/dist/utils/split.d.ts +8 -0
- package/dist/utils/split.js +8 -0
- package/dist/utils/template.d.ts +5 -0
- package/dist/utils/template.js +5 -0
- package/dist/utils/text.d.ts +4 -0
- package/dist/utils/text.js +42 -0
- package/dist/utils/tokenize.d.ts +2 -0
- package/dist/utils/tokenize.js +13 -0
- package/dist/utils/try-read.d.ts +4 -0
- package/dist/utils/try-read.js +24 -0
- package/dist/utils/typed-field.d.ts +3 -0
- package/dist/utils/typed-field.js +16 -0
- package/dist/utils/verdicts.d.ts +4 -0
- package/dist/utils/verdicts.js +20 -0
- package/entities/operators.ts +31 -0
- package/package.json +61 -18
- package/report/errorTypes/vocabulary/ids.ts +12 -0
- package/report/errorTypes/vocabulary/phrases.ts +161 -0
- package/report/errorTypes/vocabulary/places.ts +46 -0
- package/report/errorTypes/vocabulary/verbs.ts +31 -0
- package/report/user-report/shared/describe.ts +107 -0
- package/ast.js +0 -107
- package/bin/follow-architecture.js +0 -6
- package/config.js +0 -101
- package/entities/aliases.js +0 -10
- package/entities/invariants.js +0 -134
- package/entities/nodes.js +0 -112
- package/main.js +0 -96
- package/plugin.js +0 -5
- package/report.js +0 -73
- package/utils.js +0 -104
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkAccessorImports = void 0;
|
|
4
|
+
// The accessor-import check: a role handed out ONLY through declared accessors
|
|
5
|
+
// (`scopeAccess`) may not be imported by name. The rule is the architecture's
|
|
6
|
+
// own — the engine only reads which accessors a role declares and which names
|
|
7
|
+
// an import takes out.
|
|
8
|
+
const queries_1 = require("../../entities/queries");
|
|
9
|
+
const location_1 = require("../../entities/location");
|
|
10
|
+
const kinds_1 = require("../../entities/kinds");
|
|
11
|
+
const roles_1 = require("../../code-roles/roles");
|
|
12
|
+
// The function-scope accessors a role declares — the only names it is handed
|
|
13
|
+
// out as.
|
|
14
|
+
const accessorsOf = (action) => (action?.scopeAccess ?? []).filter((x) => x.scope === roles_1.SCOPE.FUNCTION).map((x) => x.segments[0]);
|
|
15
|
+
// The role's own concrete homes (no placeholders): where an import of it may
|
|
16
|
+
// resolve to.
|
|
17
|
+
const ownFilesOf = (arch, roleSlug) => (0, location_1.homesOf)(arch, roleSlug)
|
|
18
|
+
.map((h) => h.template)
|
|
19
|
+
.filter((t) => !/[*{]/.test(t));
|
|
20
|
+
// One role's accessor rule, asked of the file's imports.
|
|
21
|
+
const checkRoleAccess = (ctx, roleSlug, accessors, violations) => {
|
|
22
|
+
const arch = ctx.arch;
|
|
23
|
+
const ownFile = ownFilesOf(arch, roleSlug);
|
|
24
|
+
const importFilter = { resolved: { in: ownFile }, typeOnly: { equals: false }, named: { any: { not: { in: accessors } } } };
|
|
25
|
+
const repoImports = ctx.facts?.imports ?? [];
|
|
26
|
+
const scope = { arch, fileRel: ctx.rel };
|
|
27
|
+
for (const imp of (0, queries_1.hitOf)(repoImports, { any: importFilter }, scope)) {
|
|
28
|
+
const bad = (0, queries_1.hitOf)(imp.named ?? [], { any: { not: { in: accessors } } }, scope);
|
|
29
|
+
if (!bad.length)
|
|
30
|
+
continue;
|
|
31
|
+
violations.push({
|
|
32
|
+
line: imp.line ?? 1,
|
|
33
|
+
text: `\`${bad.join("`, `")}\` is taken out of \`${imp.resolved}\`, but \`${roleSlug}\` is handed out only as ${accessors.map((a) => `\`${a}(…)\``).join(", ")}`,
|
|
34
|
+
fix: `Import one of the declared accessors (${accessors.join(", ")}) instead of \`${bad[0]}\`.`,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const checkAccessorImports = (ctx, arch, declared, violations) => {
|
|
39
|
+
for (const roleSlug of Object.keys(arch.codeRoles ?? {})) {
|
|
40
|
+
const accessors = accessorsOf(declared.get(kinds_1.RELATION.CALL)?.get(roleSlug));
|
|
41
|
+
if (!accessors.length)
|
|
42
|
+
continue;
|
|
43
|
+
checkRoleAccess(ctx, roleSlug, accessors, violations);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.checkAccessorImports = checkAccessorImports;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type Edge } from "../../entities/kinds";
|
|
2
|
+
import type { Arch, ActionDef } from "../../entities/architecture";
|
|
3
|
+
import type { FileContext } from "../../entities/context";
|
|
4
|
+
import type { Caps } from "../../entities/location/where";
|
|
5
|
+
import type { RelationGroup } from "./relations-group";
|
|
6
|
+
type Pair = {
|
|
7
|
+
targetSlug: string;
|
|
8
|
+
action: ActionDef & {
|
|
9
|
+
missing?: boolean;
|
|
10
|
+
};
|
|
11
|
+
caps: Caps;
|
|
12
|
+
violation: boolean;
|
|
13
|
+
outward?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type EdgeJudgment = {
|
|
16
|
+
key: string;
|
|
17
|
+
group: RelationGroup;
|
|
18
|
+
};
|
|
19
|
+
type JudgeCtx = {
|
|
20
|
+
ctx: FileContext;
|
|
21
|
+
arch: Arch;
|
|
22
|
+
kind: string;
|
|
23
|
+
actionDecls: Map<string, ActionDef>;
|
|
24
|
+
fileRoles: string[];
|
|
25
|
+
};
|
|
26
|
+
declare const judgeEdge: (edge: Edge, jctx: JudgeCtx) => EdgeJudgment | null;
|
|
27
|
+
declare const joinGroup: (group: RelationGroup, edge: Edge) => void;
|
|
28
|
+
export { judgeEdge, joinGroup };
|
|
29
|
+
export type { EdgeJudgment, Pair };
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.joinGroup = exports.judgeEdge = void 0;
|
|
4
|
+
// ONE edge, judged by the role that owns its target: which target roles could
|
|
5
|
+
// allow it, what each declares, and whether every one of them refuses. The
|
|
6
|
+
// ranking picks the refusal that explains the rule best; only when EVERY
|
|
7
|
+
// target refuses is there a finding to group.
|
|
8
|
+
const location_1 = require("../../entities/location");
|
|
9
|
+
const tree_1 = require("../../entities/tree");
|
|
10
|
+
const kinds_1 = require("../../entities/kinds");
|
|
11
|
+
const verdicts_1 = require("../../utils/verdicts");
|
|
12
|
+
const permission_1 = require("../../utils/permission");
|
|
13
|
+
const roles_1 = require("./roles");
|
|
14
|
+
// The roles the edge's SOURCE speaks with: the piece's own role when it has
|
|
15
|
+
// one; a file-level statement speaks with the file's roles; an unroled piece
|
|
16
|
+
// speaks with none.
|
|
17
|
+
const sourceRolesOf = (edge, fileRoles) => {
|
|
18
|
+
const own = edge.role ? [edge.role] : [...fileRoles];
|
|
19
|
+
return edge.piece && !edge.role ? [] : own;
|
|
20
|
+
};
|
|
21
|
+
// The roles the TARGET may be judged by: a self-statement keeps the source's
|
|
22
|
+
// own roles; anything else asks the tree what is declared at the target path.
|
|
23
|
+
const targetRolesOf = (edge, jctx, selfStatement) => {
|
|
24
|
+
if (!selfStatement)
|
|
25
|
+
return (0, location_1.rolesAtPath)(jctx.arch, edge.path);
|
|
26
|
+
if (edge.role)
|
|
27
|
+
return [edge.role];
|
|
28
|
+
return jctx.fileRoles.length ? jctx.fileRoles : (0, location_1.rolesAtPath)(jctx.arch, edge.path);
|
|
29
|
+
};
|
|
30
|
+
// The scope one action is judged in: the file's facts, the source's roles,
|
|
31
|
+
// and the edge itself (the call may need WHAT was passed).
|
|
32
|
+
const scopeOf = (ctx, sourceRoles, edge) => {
|
|
33
|
+
const facts = ctx.facts;
|
|
34
|
+
const base = facts ?? { lines: [], imports: [], exports: [], location: { path: ctx.rel, segments: [], exts: [], fileName: "", words: [], files: [], siblings: [] }, reads: [], kind: { own: { is: "SourceFile" }, descendants: [] }, candidates: [], roles: [] };
|
|
35
|
+
return { ...base, roles: sourceRoles, edge: edge.fact ?? null };
|
|
36
|
+
};
|
|
37
|
+
// One target role's verdict: the action it declares for this fact kind (or a
|
|
38
|
+
// missing one), and whether the source may do it. The allow/except walk is the
|
|
39
|
+
// shared `permissionOf` core; a source with no roles is granted nothing.
|
|
40
|
+
const pairOf = (targetSlug, edge, sourceRoles, jctx) => {
|
|
41
|
+
const { ctx, arch } = jctx;
|
|
42
|
+
const caps = (0, tree_1.targetCapsFor)(edge.path ?? "", arch);
|
|
43
|
+
const action = jctx.actionDecls.get(targetSlug);
|
|
44
|
+
if (!action)
|
|
45
|
+
return { targetSlug, action: { where: [], missing: true }, caps, violation: true };
|
|
46
|
+
const { allowed, denied } = (0, permission_1.permissionOf)(action, { rel: ctx.rel, arch, scope: scopeOf(ctx, sourceRoles, edge), caps });
|
|
47
|
+
const violation = sourceRoles.length ? !allowed || denied : true;
|
|
48
|
+
return { targetSlug, action, caps, violation, outward: denied };
|
|
49
|
+
};
|
|
50
|
+
// A role that NAMES who may do it explains the rule best; a declared action
|
|
51
|
+
// beats a missing one; fewer conditions beat more.
|
|
52
|
+
const rankPairs = (a, b) => Number(Boolean(b.action.where?.length)) - Number(Boolean(a.action.where?.length)) ||
|
|
53
|
+
Number(!b.action.missing) - Number(!a.action.missing) ||
|
|
54
|
+
(a.action.where ?? []).length - (b.action.where ?? []).length;
|
|
55
|
+
// The route the architecture DOES allow to the same code, if it names one:
|
|
56
|
+
// a `call` permission with a declared accessor.
|
|
57
|
+
const routeOf = (targetSlug, jctx, caps) => {
|
|
58
|
+
const { ctx, arch } = jctx;
|
|
59
|
+
const callDecl = declaredCall(jctx, targetSlug);
|
|
60
|
+
const callOk = callDecl?.where ? !(0, location_1.checkWhere)(callDecl.where, ctx.rel, arch, ctx.facts, caps) : false;
|
|
61
|
+
const route = callOk ? ((callDecl?.scopeAccess ?? [])[0] ?? null) : null;
|
|
62
|
+
return route ? (0, location_1.accessorLabel)(route) : null;
|
|
63
|
+
};
|
|
64
|
+
const declaredCall = (jctx, targetSlug) => jctx.ctx.arch.codeRoles[targetSlug]?.actions[kinds_1.RELATION.CALL] ?? null;
|
|
65
|
+
// The concrete destinations the refusal can offer: the allowed places that
|
|
66
|
+
// are not the target itself, not this file, not this folder.
|
|
67
|
+
const destOf = (places, targetSlug, rel) => {
|
|
68
|
+
const others = places.filter((p) => p.role !== targetSlug);
|
|
69
|
+
const spots = (others.length ? others : places)
|
|
70
|
+
.filter((pl) => !pl.filter)
|
|
71
|
+
.flatMap((pl) => pl.paths.map((path) => ({ role: pl.role, path })))
|
|
72
|
+
.filter((sp) => sp.path !== rel && sp.path !== (0, location_1.dirOf)(rel) && sp.role !== targetSlug);
|
|
73
|
+
return spots[0]?.path ?? null;
|
|
74
|
+
};
|
|
75
|
+
// The group one refused edge starts or joins. The allowed roles are the
|
|
76
|
+
// places WITHOUT the target itself (the target cannot allow its own refusal);
|
|
77
|
+
// only when no other place exists does the target's own list stand.
|
|
78
|
+
const groupOf = (edge, pair, jctx, all) => {
|
|
79
|
+
const { ctx, kind } = jctx;
|
|
80
|
+
const route = routeOf(pair.targetSlug, jctx, pair.caps);
|
|
81
|
+
const others = all.filter((p) => p.role !== pair.targetSlug);
|
|
82
|
+
const places = others.length ? others : all;
|
|
83
|
+
return {
|
|
84
|
+
kind,
|
|
85
|
+
targetNode: pair.targetSlug,
|
|
86
|
+
allowedRoles: [...new Set(places.map((pl) => pl.role).filter((r) => Boolean(r)))],
|
|
87
|
+
sameRoles: [...new Set(places.filter((pl) => pl.same).map((pl) => pl.role).filter((r) => Boolean(r)))],
|
|
88
|
+
via: (pair.action.scopeAccess ?? []).map(location_1.accessorLabel),
|
|
89
|
+
route,
|
|
90
|
+
dest: destOf(all, pair.targetSlug, ctx.rel),
|
|
91
|
+
lines: [],
|
|
92
|
+
what: new Set(),
|
|
93
|
+
path: edge.path,
|
|
94
|
+
pieces: new Map(),
|
|
95
|
+
piece: edge.piece ?? null,
|
|
96
|
+
pieceRole: edge.role ?? null,
|
|
97
|
+
silent: Boolean(pair.action.missing) || !(pair.action.where ?? []).length,
|
|
98
|
+
filtered: Boolean(pair.outward),
|
|
99
|
+
self: edge.path === ctx.rel,
|
|
100
|
+
fact: edge.fact ?? null,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
// Judge one edge: every target role's verdict, ranked; when ALL refuse, the
|
|
104
|
+
// best-explaining one names the group.
|
|
105
|
+
const judgeEdge = (edge, jctx) => {
|
|
106
|
+
const sourceRoles = sourceRolesOf(edge, jctx.fileRoles);
|
|
107
|
+
const selfStatement = edge.path === jctx.ctx.rel;
|
|
108
|
+
const pairs = targetRolesOf(edge, jctx, selfStatement).map((slug) => pairOf(slug, edge, sourceRoles, jctx));
|
|
109
|
+
const worst = (0, verdicts_1.worstWhenAllRefuse)(pairs, rankPairs);
|
|
110
|
+
if (!worst)
|
|
111
|
+
return null;
|
|
112
|
+
const places = (0, roles_1.allowedPlaces)(worst.action.where, jctx.arch, worst.caps);
|
|
113
|
+
const group = groupOf(edge, worst, jctx, places);
|
|
114
|
+
const key = `${jctx.kind}|${worst.targetSlug}|${edge.what}`;
|
|
115
|
+
return { key, group };
|
|
116
|
+
};
|
|
117
|
+
exports.judgeEdge = judgeEdge;
|
|
118
|
+
// Merge one edge into its group: the line, the what, the piece.
|
|
119
|
+
const joinGroup = (group, edge) => {
|
|
120
|
+
group.lines.push(edge.line ?? 1);
|
|
121
|
+
group.what.add(edge.what);
|
|
122
|
+
if (edge.piece)
|
|
123
|
+
group.pieces.set(edge.piece, edge.role ?? null);
|
|
124
|
+
};
|
|
125
|
+
exports.joinGroup = joinGroup;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Arch, QueryFilter } from "../../entities/architecture";
|
|
2
|
+
import type { FileContext } from "../../entities/context";
|
|
3
|
+
import type { Violation } from "./violation";
|
|
4
|
+
import type { RelationToken as SharedToken } from "../../entities/token";
|
|
5
|
+
type RelationGroup = {
|
|
6
|
+
kind: string;
|
|
7
|
+
targetNode: string;
|
|
8
|
+
allowedRoles: string[];
|
|
9
|
+
sameRoles: string[];
|
|
10
|
+
via: string[];
|
|
11
|
+
route: string | null;
|
|
12
|
+
dest: string | null;
|
|
13
|
+
lines: number[];
|
|
14
|
+
what: Set<string>;
|
|
15
|
+
path: string | null;
|
|
16
|
+
pieces: Map<string, string | null>;
|
|
17
|
+
piece: string | null;
|
|
18
|
+
pieceRole: string | null;
|
|
19
|
+
silent: boolean;
|
|
20
|
+
filtered: boolean;
|
|
21
|
+
self: boolean;
|
|
22
|
+
fact: QueryFilter | null;
|
|
23
|
+
};
|
|
24
|
+
type RelationToken = Required<Pick<SharedToken, "code" | "via">> & {
|
|
25
|
+
fact: QueryFilter | null;
|
|
26
|
+
subject: Pick<Required<NonNullable<SharedToken["subject"]>>, "pieces" | "roles" | "plural">;
|
|
27
|
+
why: Required<NonNullable<SharedToken["why"]>>;
|
|
28
|
+
};
|
|
29
|
+
declare const describeGroups: (groups: ReadonlyMap<string, RelationGroup>, ctx: FileContext, arch: Arch, violations: Violation[]) => void;
|
|
30
|
+
export { describeGroups };
|
|
31
|
+
export type { RelationGroup, RelationToken };
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeGroups = void 0;
|
|
4
|
+
// One verdict per group of refused relations, built from facts and nothing
|
|
5
|
+
// else: the sentence (`relationMessage`), the repair, and one violation per
|
|
6
|
+
// line the group covers.
|
|
7
|
+
const tree_1 = require("../../entities/tree");
|
|
8
|
+
const kinds_1 = require("../../entities/kinds");
|
|
9
|
+
const phrases_1 = require("../../report/errorTypes/vocabulary/phrases");
|
|
10
|
+
// The owner role of a state-changing relation's target — the report names it.
|
|
11
|
+
const ownerRoleOf = (g, arch) => {
|
|
12
|
+
if (!(0, kinds_1.changesState)(g.kind))
|
|
13
|
+
return null;
|
|
14
|
+
const owner = (0, tree_1.deepestMatch)(String(g.path ?? ""), arch)?.node ?? null;
|
|
15
|
+
return (owner?.roles ?? []).filter(Boolean)[0] ?? null;
|
|
16
|
+
};
|
|
17
|
+
// The fact with the owner role attached — the report names it. A fact that is
|
|
18
|
+
// not a record carries nothing to attach to.
|
|
19
|
+
const factWithOwner = (g, ownerRole) => {
|
|
20
|
+
if (!g.fact || typeof g.fact !== "object" || Array.isArray(g.fact))
|
|
21
|
+
return null;
|
|
22
|
+
return { ...g.fact, ownerRole };
|
|
23
|
+
};
|
|
24
|
+
// Why the relation is refused: nothing allows it, some roles do, or nobody may.
|
|
25
|
+
const whyCodeOf = (g) => {
|
|
26
|
+
if (g.silent)
|
|
27
|
+
return "silent";
|
|
28
|
+
return g.allowedRoles.length ? "allowed" : "nobody";
|
|
29
|
+
};
|
|
30
|
+
const tokenOf = (g, arch, fileRoles) => {
|
|
31
|
+
const names = [...g.pieces.keys()];
|
|
32
|
+
const roles = [...new Set([...g.pieces.values()].filter((r) => Boolean(r)))];
|
|
33
|
+
const ownerRole = ownerRoleOf(g, arch);
|
|
34
|
+
return {
|
|
35
|
+
code: "relation.forbidden",
|
|
36
|
+
fact: factWithOwner(g, ownerRole),
|
|
37
|
+
subject: { pieces: names, roles: names.length ? roles : [...fileRoles], plural: names.length > 1 },
|
|
38
|
+
// The route the architecture DOES allow to the same code, if it names one.
|
|
39
|
+
via: g.via?.[0] ?? g.route ?? null,
|
|
40
|
+
why: {
|
|
41
|
+
code: whyCodeOf(g),
|
|
42
|
+
roles: g.allowedRoles,
|
|
43
|
+
// The ones the rule limits to the SAME feature instance.
|
|
44
|
+
sameRoles: g.sameRoles,
|
|
45
|
+
self: Boolean(g.self),
|
|
46
|
+
outward: Boolean(g.filtered),
|
|
47
|
+
targetNode: g.targetNode ?? null,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
// THE REPAIR for a relation the architecture refuses — always about the CODE,
|
|
52
|
+
// never about editing the rule: what to delete, or which of the code that MAY do
|
|
53
|
+
// it should own the line. A finding with no repair was a card with nothing to do
|
|
54
|
+
// (48 of them in one run).
|
|
55
|
+
const relationFix = (g, token) => {
|
|
56
|
+
const target = `\`${g.path ?? g.targetNode}\``;
|
|
57
|
+
const kind = g.kind;
|
|
58
|
+
const roles = token.why.roles;
|
|
59
|
+
// The call itself is fine; the VALUE it was given is what the `except` refused.
|
|
60
|
+
if (token.why.outward) {
|
|
61
|
+
return { code: "rewrite", fix: `Keep this \`${kind}\` of ${target} and change what it is given: the rule's \`except\` refuses that value.` };
|
|
62
|
+
}
|
|
63
|
+
if (!roles.length) {
|
|
64
|
+
// Nothing declares who may do it — or nobody may: either way the line is the
|
|
65
|
+
// thing that goes, and saying so is the whole advice.
|
|
66
|
+
return {
|
|
67
|
+
code: "remove",
|
|
68
|
+
fix: `Delete this \`${kind}\` of ${target}: no code in this architecture is allowed to reach \`${g.targetNode}\` that way, so the line cannot be made legal where it stands.`,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const who = roles.map((r) => `\`${r}\``).join(", ");
|
|
72
|
+
return {
|
|
73
|
+
code: "remove",
|
|
74
|
+
fix: `Delete this \`${kind}\` of ${target}, or do it from ${who} — that is the only code that may ${kind} it${token.why.sameRoles.length ? ", and only in the same feature instance" : ""}.`,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
// One group → one verdict, carried on every line it covers.
|
|
78
|
+
const describeGroup = (g, ctx, arch, violations) => {
|
|
79
|
+
const token = tokenOf(g, arch, ctx.facts?.roles ?? []);
|
|
80
|
+
const text = (0, phrases_1.relationMessage)(token, { file: ctx.rel });
|
|
81
|
+
const lines = [...new Set(g.lines)].sort((a, b) => a - b);
|
|
82
|
+
// ONE repair per group, carried on every line it covers: a finding without
|
|
83
|
+
// a fix is a card with nothing to do.
|
|
84
|
+
const repair = relationFix(g, token);
|
|
85
|
+
for (const line of lines) {
|
|
86
|
+
violations.push({
|
|
87
|
+
kind: g.kind,
|
|
88
|
+
targetNode: g.targetNode,
|
|
89
|
+
targetPath: g.path,
|
|
90
|
+
line,
|
|
91
|
+
text,
|
|
92
|
+
fix: repair.fix,
|
|
93
|
+
ask: repair.code,
|
|
94
|
+
destination: g.dest ?? null,
|
|
95
|
+
token,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
const describeGroups = (groups, ctx, arch, violations) => {
|
|
100
|
+
for (const g of groups.values())
|
|
101
|
+
describeGroup(g, ctx, arch, violations);
|
|
102
|
+
};
|
|
103
|
+
exports.describeGroups = describeGroups;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Arch } from "../../entities/architecture";
|
|
2
|
+
import type { FileContext } from "../../entities/context";
|
|
3
|
+
import type { Violation } from "./violation";
|
|
4
|
+
declare const checkRelations: (ctx: FileContext, arch: Arch, violations: Violation[]) => void;
|
|
5
|
+
export { checkRelations };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkRelations = void 0;
|
|
4
|
+
// Relations: every file→file edge, judged by the role that owns the target.
|
|
5
|
+
// Collect (group the refusals), then describe (one token per group). The
|
|
6
|
+
// judgment of ONE edge lives in `relations-edge`; the accessor-import check
|
|
7
|
+
// in `relations-access`; the group's sentence in `relations-group`.
|
|
8
|
+
const kinds_1 = require("../../entities/kinds");
|
|
9
|
+
const gate_1 = require("../../utils/gate");
|
|
10
|
+
const judged_1 = require("../../utils/judged");
|
|
11
|
+
const accumulate_1 = require("../../utils/accumulate");
|
|
12
|
+
const relations_edge_1 = require("./relations-edge");
|
|
13
|
+
const relations_access_1 = require("./relations-access");
|
|
14
|
+
const relations_group_1 = require("./relations-group");
|
|
15
|
+
// The edges of one fact kind, each once (a call and its declare are one line).
|
|
16
|
+
const uniqueEdges = (kind, edges) => {
|
|
17
|
+
const seen = new Set();
|
|
18
|
+
const out = [];
|
|
19
|
+
for (const edge of edges) {
|
|
20
|
+
const key = `${kind}:${edge.path}:${edge.line}:${edge.what}`;
|
|
21
|
+
if (seen.has(key))
|
|
22
|
+
continue;
|
|
23
|
+
seen.add(key);
|
|
24
|
+
out.push(edge);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
};
|
|
28
|
+
// Is this edge the closed-world rule's business? A LIBRARY is not a place the
|
|
29
|
+
// tree declares: `react`, `@apollo/client`, `fs` have no node and no role home,
|
|
30
|
+
// so there is no folder-level rule to judge them by. What a piece may do with a
|
|
31
|
+
// library is the CANDIDATE's own business — `infer` reads `calls.module` /
|
|
32
|
+
// `imports.source` directly. Skipping here keeps the closed-world rule about
|
|
33
|
+
// REPO code; a library edge judged against an empty home list would report
|
|
34
|
+
// every `styled.div` and every `useState` as a forbidden relation. The verdicts
|
|
35
|
+
// are the shared gate: an edge is judged when none of the skips fires.
|
|
36
|
+
const judgedEdge = (edge, fileRoles) => (0, gate_1.admitsWhenNoneReject)(edge, [(e) => e.external, (e) => Boolean(e.piece) && !e.role, (e) => !e.piece && !fileRoles.length]);
|
|
37
|
+
// The edges of one fact kind that the closed-world rule owns (not a library's,
|
|
38
|
+
// not an unroled piece's, not a roleless file's) — the ones it judges.
|
|
39
|
+
const ownedEdges = (kind, ctx) => {
|
|
40
|
+
const facts = ctx.facts;
|
|
41
|
+
if (!facts)
|
|
42
|
+
return [];
|
|
43
|
+
const fileRoles = facts.roles ?? [];
|
|
44
|
+
return uniqueEdges(kind, kinds_1.EDGE_FACTS[kind](facts)).filter((e) => judgedEdge(e, fileRoles));
|
|
45
|
+
};
|
|
46
|
+
// One kind's refusals → groups. The judge-and-keep walk is the shared
|
|
47
|
+
// `judgedItems` core; the keyed merge is the shared `accumulateByKey` core.
|
|
48
|
+
// Returns whether any edge of this kind was owned (passed the skips).
|
|
49
|
+
const collectKind = (kind, actionDecls, jctx) => {
|
|
50
|
+
const { ctx, arch, groups } = jctx;
|
|
51
|
+
const fileRoles = ctx.facts?.roles ?? [];
|
|
52
|
+
const edges = ownedEdges(kind, ctx);
|
|
53
|
+
const judgments = (0, judged_1.judgedItems)(edges, (e) => (0, relations_edge_1.judgeEdge)(e, { ctx, arch, kind, actionDecls, fileRoles }));
|
|
54
|
+
(0, accumulate_1.accumulateByKey)(judgments.map(({ item, verdict }) => ({ key: verdict.key, item, bucket: verdict.group })), groups, relations_edge_1.joinGroup);
|
|
55
|
+
return edges.length > 0;
|
|
56
|
+
};
|
|
57
|
+
// The refusals of every fact kind, grouped. The accessor-import check is the
|
|
58
|
+
// run's own question about the file's imports: the original asked it once per
|
|
59
|
+
// owned edge (the emitter keeps one finding per decision, so the repeated
|
|
60
|
+
// identical violations collapsed to one) — so it is asked once, and only when
|
|
61
|
+
// some edge was owned, exactly the original's condition.
|
|
62
|
+
const collectRefusals = (ctx, arch, declared, violations) => {
|
|
63
|
+
const groups = new Map();
|
|
64
|
+
let anyOwned = false;
|
|
65
|
+
for (const kind of kinds_1.FACT_KINDS) {
|
|
66
|
+
if (collectKind(kind, declared.get(kind) ?? new Map(), { ctx, arch, groups }))
|
|
67
|
+
anyOwned = true;
|
|
68
|
+
}
|
|
69
|
+
if (anyOwned)
|
|
70
|
+
(0, relations_access_1.checkAccessorImports)(ctx, arch, declared, violations);
|
|
71
|
+
return groups;
|
|
72
|
+
};
|
|
73
|
+
const checkRelations = (ctx, arch, violations) => {
|
|
74
|
+
if (!ctx.facts)
|
|
75
|
+
return;
|
|
76
|
+
// 1. COLLECT — every edge judged, the refusals grouped.
|
|
77
|
+
const groups = collectRefusals(ctx, arch, (0, kinds_1.declaredActions)(arch), violations);
|
|
78
|
+
// 2. DESCRIBE — one verdict per group, built from facts and nothing else.
|
|
79
|
+
(0, relations_group_1.describeGroups)(groups, ctx, arch, violations);
|
|
80
|
+
};
|
|
81
|
+
exports.checkRelations = checkRelations;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ArchNode } from "../../entities/architecture";
|
|
2
|
+
import type { FileContext } from "../../entities/context";
|
|
3
|
+
import type { Finding, FindingFrom } from "../../entities/findings";
|
|
4
|
+
declare const checkRequiredChildren: (ctx: FileContext, node: ArchNode, out: Finding[], findingFrom: FindingFrom) => void;
|
|
5
|
+
export { checkRequiredChildren };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkRequiredChildren = void 0;
|
|
4
|
+
// Required children: is this folder an instance of its node, and is anything
|
|
5
|
+
// the node requires missing.
|
|
6
|
+
const location_1 = require("../../entities/location");
|
|
7
|
+
const children_1 = require("../children");
|
|
8
|
+
// Where the run remembers which folders it has already spoken for.
|
|
9
|
+
const foldersOf = (ctx) => ctx.dedupe?.get("required") ?? new Set();
|
|
10
|
+
const remember = (ctx, folders, key) => {
|
|
11
|
+
folders.add(key);
|
|
12
|
+
ctx.dedupe?.set("required", folders);
|
|
13
|
+
};
|
|
14
|
+
// A home outside the folder: a place the code could move to. A home inside
|
|
15
|
+
// (or the folder itself) is not an offer.
|
|
16
|
+
const outsideHome = (path, folder) => Boolean(path) && path !== folder && !path.startsWith(`${folder}/`);
|
|
17
|
+
// The homes the file's own roles would put its code in, outside this folder —
|
|
18
|
+
// the destinations a "this folder is not described" finding can offer.
|
|
19
|
+
const homesOutside = (ctx, arch, folder) => {
|
|
20
|
+
const byPath = new Map();
|
|
21
|
+
for (const c of ctx.facts?.candidates ?? []) {
|
|
22
|
+
if (!c.role)
|
|
23
|
+
continue;
|
|
24
|
+
const path = (0, location_1.placeFor)(arch, c.role, ctx.rel)?.path ?? null;
|
|
25
|
+
if (outsideHome(path, folder) && !byPath.has(path))
|
|
26
|
+
byPath.set(path, c.role);
|
|
27
|
+
}
|
|
28
|
+
return byPath;
|
|
29
|
+
};
|
|
30
|
+
// A folder none of the node's declared children are in: not a folder this
|
|
31
|
+
// architecture describes. Said once per folder.
|
|
32
|
+
const foreignFolder = (...args) => {
|
|
33
|
+
const [ctx, owner, folder, declared, out, findingFrom] = args;
|
|
34
|
+
const arch = ctx.arch;
|
|
35
|
+
const key = `nodes:${owner.slug}:foreign:${folder}`;
|
|
36
|
+
const folders = foldersOf(ctx);
|
|
37
|
+
if (folders.has(key))
|
|
38
|
+
return;
|
|
39
|
+
remember(ctx, folders, key);
|
|
40
|
+
const byPath = homesOutside(ctx, arch, folder);
|
|
41
|
+
const where = byPath.size ? [...byPath.entries()].map(([path, role]) => `\`${path}\` (${role})`).join(" and ") : null;
|
|
42
|
+
out.push(findingFrom({
|
|
43
|
+
key,
|
|
44
|
+
report: {
|
|
45
|
+
ask: "move",
|
|
46
|
+
message: `\`${folder}\` is not a folder this architecture describes: none of the files node \`${owner.slug}\` declares are here (${declared.map((c) => `\`${c.name}${c.folder ? "/" : ""}\``).join(", ")}).`,
|
|
47
|
+
fix: where ? `Move each part of \`${folder}\` to its own home: ${where}.` : null,
|
|
48
|
+
},
|
|
49
|
+
}, "nodes", owner.slug, `nodes:${owner.slug}:foreign`, { path: ctx.rel, folder, node: owner.slug }));
|
|
50
|
+
};
|
|
51
|
+
// One required child missing from the folder: the node's own report, or the
|
|
52
|
+
// default "create it" demand. Said once per (folder, child).
|
|
53
|
+
const missingChild = (...args) => {
|
|
54
|
+
const [ctx, owner, folder, child, out, findingFrom] = args;
|
|
55
|
+
const key = `nodes:${owner.slug}:required:${folder}:${child.name}`;
|
|
56
|
+
const folders = foldersOf(ctx);
|
|
57
|
+
if (folders.has(key))
|
|
58
|
+
return;
|
|
59
|
+
remember(ctx, folders, key);
|
|
60
|
+
out.push(findingFrom({
|
|
61
|
+
key,
|
|
62
|
+
report: child.report ?? {
|
|
63
|
+
ask: "add",
|
|
64
|
+
message: `\`{folder}\` is not a \`{node}\`: \`{child}\` is required here and is missing.`,
|
|
65
|
+
fix: `Create \`{child}\` in \`{folder}\`.`,
|
|
66
|
+
},
|
|
67
|
+
data: { node: owner.slug, folder, missing: child.name },
|
|
68
|
+
}, "nodes", owner.slug, `nodes:${owner.slug}:required`, { path: ctx.rel, folder, node: owner.slug, child: child.name, missing: child.name }));
|
|
69
|
+
};
|
|
70
|
+
// The required children the folder does not hold.
|
|
71
|
+
const missingOf = (required, present) => required.filter((child) => ![...present].some((name) => child.re.test(name)));
|
|
72
|
+
// One owner's required children, checked against what the folder holds.
|
|
73
|
+
const checkOwner = (ctx, owner, out, findingFrom) => {
|
|
74
|
+
const required = (owner.children ?? []).filter((c) => c.required);
|
|
75
|
+
const folder = required.length ? (0, location_1.fillTemplate)(owner.path, ctx.rel) : null;
|
|
76
|
+
if (!folder)
|
|
77
|
+
return;
|
|
78
|
+
const { present, declared, anyDeclared } = (0, children_1.folderContents)(owner, folder, ctx.repoFiles);
|
|
79
|
+
if (!anyDeclared) {
|
|
80
|
+
foreignFolder(ctx, owner, folder, declared, out, findingFrom);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for (const child of missingOf(required, present))
|
|
84
|
+
missingChild(ctx, owner, folder, child, out, findingFrom);
|
|
85
|
+
};
|
|
86
|
+
const checkRequiredChildren = (ctx, node, out, findingFrom) => {
|
|
87
|
+
for (const owner of (0, children_1.ancestorChain)(node, ctx.arch))
|
|
88
|
+
checkOwner(ctx, owner, out, findingFrom);
|
|
89
|
+
};
|
|
90
|
+
exports.checkRequiredChildren = checkRequiredChildren;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Arch, WhereEntry } from "../../entities/architecture";
|
|
2
|
+
import type { Caps } from "../../entities/location/where";
|
|
3
|
+
declare const fitsRole: (roleSlug: string, arch: Arch, rel: string) => boolean;
|
|
4
|
+
type AllowedPlace = {
|
|
5
|
+
role: 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 { fitsRole, allowedPlaces };
|
|
13
|
+
export type { AllowedPlace };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.allowedPlaces = exports.fitsRole = void 0;
|
|
4
|
+
// Role ↔ place: is this file a home for that role, and which paths may an
|
|
5
|
+
// action's `from:` list name.
|
|
6
|
+
const location_1 = require("../../entities/location");
|
|
7
|
+
const gate_1 = require("../../utils/gate");
|
|
8
|
+
// Does this file sit in one of the role's homes? The home question is the ONE
|
|
9
|
+
// implementation in `entities/location/homes` (`roleFitsAt`, asked through the
|
|
10
|
+
// shared `where` grammar). The two exemptions are the shared gate: a role
|
|
11
|
+
// nobody declares, or one with no home, restricts nothing — when neither
|
|
12
|
+
// rejection fires, the home answer decides.
|
|
13
|
+
const fitsRole = (roleSlug, arch, rel) => !(0, gate_1.admitsWhenNoneReject)(roleSlug, [(slug) => !arch.codeRoles?.[slug], (slug) => !(0, location_1.homesOf)(arch, slug).length]) || (0, location_1.roleFitsAt)(arch, roleSlug, rel);
|
|
14
|
+
exports.fitsRole = fitsRole;
|
|
15
|
+
const rolePlace = (entry, arch, targetCaps) => {
|
|
16
|
+
const homes = (0, location_1.homesOf)(arch, entry.role ?? "");
|
|
17
|
+
const paths = homes.map((h) => (0, location_1.fillTemplate)(h.template, null, targetCaps)).filter((p) => Boolean(p));
|
|
18
|
+
// `same: true` is part of the RULE, not decoration: an orchestrator may
|
|
19
|
+
// call an action only inside its own feature. The message has to say so,
|
|
20
|
+
// or it reads as "orchestrators may not call actions at all".
|
|
21
|
+
return { role: entry.role ?? null, paths, anywhere: !homes.length, same: Boolean(entry.same) };
|
|
22
|
+
};
|
|
23
|
+
const nodePlace = (entry, arch, targetCaps) => {
|
|
24
|
+
const path = (0, location_1.fillTemplate)(arch.nodes?.bySlug?.[entry.node ?? ""]?.path, null, targetCaps);
|
|
25
|
+
return { role: null, paths: path ? [path] : [] };
|
|
26
|
+
};
|
|
27
|
+
const allowedPlaces = (entries, arch, targetCaps) => {
|
|
28
|
+
const out = [];
|
|
29
|
+
for (const entry of entries ?? []) {
|
|
30
|
+
if (entry.type === "role")
|
|
31
|
+
out.push(rolePlace(entry, arch, targetCaps));
|
|
32
|
+
else if (entry.type === "node")
|
|
33
|
+
out.push(nodePlace(entry, arch, targetCaps));
|
|
34
|
+
else if (entry.type === "glob")
|
|
35
|
+
out.push({ role: null, paths: entry.glob ? [entry.glob] : [] });
|
|
36
|
+
else
|
|
37
|
+
out.push({ role: null, paths: [], filter: true });
|
|
38
|
+
}
|
|
39
|
+
return out;
|
|
40
|
+
};
|
|
41
|
+
exports.allowedPlaces = allowedPlaces;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FieldValue } from "../../utils/field";
|
|
2
|
+
type Violation = {
|
|
3
|
+
line: number;
|
|
4
|
+
text: string;
|
|
5
|
+
fix?: string | null;
|
|
6
|
+
ask?: string | null;
|
|
7
|
+
kind?: string;
|
|
8
|
+
role?: string | null;
|
|
9
|
+
names?: string[];
|
|
10
|
+
where?: string | null;
|
|
11
|
+
owning?: string | null;
|
|
12
|
+
targetNode?: string | null;
|
|
13
|
+
targetPath?: string | null;
|
|
14
|
+
destination?: string | null;
|
|
15
|
+
token?: FieldValue;
|
|
16
|
+
};
|
|
17
|
+
export type { Violation };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Arch, ArchNode } from "../entities/architecture";
|
|
2
|
+
import type { ScanContext } from "../entities/context";
|
|
3
|
+
declare const criteriaOf: (arch: Arch, node: ArchNode) => string[];
|
|
4
|
+
type SimilarCache = {
|
|
5
|
+
files: Map<string, string[]>;
|
|
6
|
+
};
|
|
7
|
+
type SimilarScan = ScanContext & {
|
|
8
|
+
arch?: Arch;
|
|
9
|
+
cache?: SimilarCache;
|
|
10
|
+
};
|
|
11
|
+
type Lookalike = {
|
|
12
|
+
slug: string;
|
|
13
|
+
path: string | null;
|
|
14
|
+
score: number;
|
|
15
|
+
hit: number;
|
|
16
|
+
total: number;
|
|
17
|
+
roles: string[];
|
|
18
|
+
};
|
|
19
|
+
declare const similarNodes: (arch: Arch, folder: string, ctx: SimilarScan | null | undefined, threshold?: number) => Lookalike[];
|
|
20
|
+
export { similarNodes, criteriaOf };
|
|
21
|
+
export type { SimilarCache, Lookalike };
|