@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
package/dist/aliases.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.normalizeAliases = void 0;
|
|
4
|
+
const map_record_1 = require("./utils/map-record");
|
|
5
|
+
// Normalize the YAML `aliases` section: a flat map of alias name → path.
|
|
6
|
+
// Paths are normalized to forward slashes with no trailing slash. The
|
|
7
|
+
// entry-by-entry walk is the shared `mapRecord` core.
|
|
8
|
+
const normalizeAliases = (raw) => {
|
|
9
|
+
const source = raw && typeof raw === "object" ? raw : {};
|
|
10
|
+
return (0, map_record_1.mapRecord)(source, (_k, v) => String(v).replace(/\\/g, "/").replace(/\/+$/, ""));
|
|
11
|
+
};
|
|
12
|
+
exports.normalizeAliases = normalizeAliases;
|
package/dist/args.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type Args = {
|
|
2
|
+
config: string | undefined;
|
|
3
|
+
ignore: string[];
|
|
4
|
+
ignoreDir: string[];
|
|
5
|
+
ext: string[];
|
|
6
|
+
files: string[];
|
|
7
|
+
out: string | null | undefined;
|
|
8
|
+
overview: string | null;
|
|
9
|
+
check: boolean;
|
|
10
|
+
cwd: string | null | undefined;
|
|
11
|
+
help: boolean;
|
|
12
|
+
};
|
|
13
|
+
declare const parseArgs: (argv: string[]) => Args;
|
|
14
|
+
export { parseArgs };
|
package/dist/args.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseArgs = void 0;
|
|
4
|
+
// CLI argument parsing for the follow-architecture entry point. Kept in its
|
|
5
|
+
// own module (not config.js) to avoid a require cycle: config.js (the ESLint
|
|
6
|
+
// plugin) needs loadArchitecture from main.js, so main.js must not require
|
|
7
|
+
// config.js back.
|
|
8
|
+
const DEFAULT_OVERVIEW = "architecture-overview.html";
|
|
9
|
+
// Every option that takes a following value, mapped to the field it fills.
|
|
10
|
+
const VALUE_FLAGS = {
|
|
11
|
+
"--config": "config",
|
|
12
|
+
"--ignore": "ignore",
|
|
13
|
+
"--ignore-dir": "ignoreDir",
|
|
14
|
+
"--ext": "ext",
|
|
15
|
+
"--files": "files",
|
|
16
|
+
"--out": "out",
|
|
17
|
+
"--cwd": "cwd",
|
|
18
|
+
};
|
|
19
|
+
// Apply one `--flag VALUE` option, consuming the value at `i + 1`. A list option
|
|
20
|
+
// appends (only when a value follows); a single-value option assigns.
|
|
21
|
+
const applyValue = (args, key, argv, i) => {
|
|
22
|
+
const value = argv[i + 1];
|
|
23
|
+
if (key === "ignore") {
|
|
24
|
+
if (value !== undefined)
|
|
25
|
+
args.ignore.push(value);
|
|
26
|
+
}
|
|
27
|
+
else if (key === "ignoreDir") {
|
|
28
|
+
if (value !== undefined)
|
|
29
|
+
args.ignoreDir.push(value);
|
|
30
|
+
}
|
|
31
|
+
else if (key === "ext") {
|
|
32
|
+
if (value !== undefined)
|
|
33
|
+
args.ext.push(value);
|
|
34
|
+
}
|
|
35
|
+
else if (key === "files") {
|
|
36
|
+
if (value !== undefined)
|
|
37
|
+
args.files.push(value);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
args[key] = value;
|
|
41
|
+
}
|
|
42
|
+
return i + 1;
|
|
43
|
+
};
|
|
44
|
+
// `--overview`'s path is optional: alone it writes the default file, and a
|
|
45
|
+
// following flag must not be swallowed as the path.
|
|
46
|
+
const applyOverview = (args, argv, i) => {
|
|
47
|
+
const next = argv[i + 1];
|
|
48
|
+
if (next && !next.startsWith("--")) {
|
|
49
|
+
args.overview = next;
|
|
50
|
+
return i + 1;
|
|
51
|
+
}
|
|
52
|
+
args.overview = DEFAULT_OVERVIEW;
|
|
53
|
+
return i;
|
|
54
|
+
};
|
|
55
|
+
const parseArgs = (argv) => {
|
|
56
|
+
const args = { config: "architecture.yaml", ignore: [], ignoreDir: [], ext: [], files: [], out: null, overview: null, check: false, cwd: null, help: false };
|
|
57
|
+
for (let i = 0; i < argv.length; i += 1) {
|
|
58
|
+
const a = argv[i];
|
|
59
|
+
const key = VALUE_FLAGS[a];
|
|
60
|
+
if (key) {
|
|
61
|
+
i = applyValue(args, key, argv, i);
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (a === "--overview") {
|
|
65
|
+
i = applyOverview(args, argv, i);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (a === "--check") {
|
|
69
|
+
args.check = true;
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
72
|
+
if (a === "--help" || a === "-h")
|
|
73
|
+
args.help = true;
|
|
74
|
+
}
|
|
75
|
+
return args;
|
|
76
|
+
};
|
|
77
|
+
exports.parseArgs = parseArgs;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const main_1 = require("../main");
|
|
5
|
+
const cli_report_1 = require("../report/cli-report");
|
|
6
|
+
const config_error_guard_1 = require("../report/config-error-guard");
|
|
7
|
+
// What the reader sees when the run cannot even start: one sentence naming what
|
|
8
|
+
// the config claims and what it may claim instead, plus the file to open. The
|
|
9
|
+
// same sentence reaches an editor through the ESLint rule, so the two agree.
|
|
10
|
+
const run = () => {
|
|
11
|
+
try {
|
|
12
|
+
return (0, main_1.main)(process.argv.slice(2));
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
// Both endings are output of the same tool, so both are shaped by the report
|
|
16
|
+
// module: a config mistake is one sentence, a bug keeps its stack. The marker
|
|
17
|
+
// is read by the ONE guard the config-error builders export.
|
|
18
|
+
const e = error instanceof Error ? error : new Error(String(error));
|
|
19
|
+
console.error((0, config_error_guard_1.isConfigError)(e) ? (0, cli_report_1.renderConfigError)(e) : (0, cli_report_1.renderCrashError)(e));
|
|
20
|
+
return 1;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
process.exitCode = run();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Arch, CodeRoles } from "../entities/architecture";
|
|
2
|
+
import type { Candidate, FileFacts } from "../entities/facts";
|
|
3
|
+
declare const classifyRoles: (candidates: Candidate[] | null | undefined, codeRoles: CodeRoles | null | undefined, arch?: Arch | null, fileFacts?: FileFacts | null) => {
|
|
4
|
+
present: string[];
|
|
5
|
+
candidates: Candidate[];
|
|
6
|
+
roleCtx: {
|
|
7
|
+
present: string[];
|
|
8
|
+
candidates: Candidate[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export { classifyRoles };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.classifyRoles = void 0;
|
|
4
|
+
// Classify the file's candidates against the codeRoles.
|
|
5
|
+
//
|
|
6
|
+
// `classifyRoles(candidates, codeRoles)` returns:
|
|
7
|
+
// • `present` — the flat list of role names present in the file
|
|
8
|
+
// • `roleCtx` — `{ present, candidates }` where `candidates` are the
|
|
9
|
+
// enriched facts (each carrying `role`, `parentRole`, and
|
|
10
|
+
// `calls[].targetRole`).
|
|
11
|
+
//
|
|
12
|
+
// The input candidates array is NOT mutated in place — a shallow copy
|
|
13
|
+
// (plus a copy of `calls`) is enriched, so the original facts the
|
|
14
|
+
// pipeline built stay untouched.
|
|
15
|
+
//
|
|
16
|
+
// File-level `when` filters consume `ctx.facts` (which already includes
|
|
17
|
+
// `roles` and `candidates`), so no separate predicate language is needed.
|
|
18
|
+
const connector_1 = require("./connector");
|
|
19
|
+
const classify_1 = require("../utils/classify");
|
|
20
|
+
const read_when_1 = require("../utils/read-when");
|
|
21
|
+
// A file with NO code candidates (a barrel of re-exports, a file of imports)
|
|
22
|
+
// still has a nature a role may describe: the file's own facts are asked
|
|
23
|
+
// against the same `infer` filters. The first role whose infer matches the
|
|
24
|
+
// FILE facts describes the module scope — the same first-match-wins order the
|
|
25
|
+
// pieces use (the shared `utils/classify` walk). A role inferred from a piece's
|
|
26
|
+
// shape (`kind.own`) simply does not match the file, so nothing changes for
|
|
27
|
+
// files that hold code. The qualified read is the shared `readWhen`: only a
|
|
28
|
+
// file that is there is asked.
|
|
29
|
+
const fileRoleOf = (fileFacts, codeRoles, arch) => (0, read_when_1.readWhen)(fileFacts, (f) => f != null, (f) => (0, classify_1.firstMatch)(f, (0, classify_1.definitionsOf)(codeRoles), { ...f, arch }), null);
|
|
30
|
+
const classifyRoles = (candidates, codeRoles, arch, fileFacts = null) => {
|
|
31
|
+
const copy = (candidates ?? []).map((c) => ({ ...c, calls: (c.calls ?? []).map((x) => ({ ...x })) }));
|
|
32
|
+
(0, connector_1.enrichWithRoles)(copy, codeRoles, arch);
|
|
33
|
+
const present = copy.map((c) => c.role).filter((r) => Boolean(r));
|
|
34
|
+
// The module scope answers for statements no piece owns (`export * from`).
|
|
35
|
+
// When no piece got a role, the file itself may still be describable.
|
|
36
|
+
if (!present.length) {
|
|
37
|
+
const fileRole = fileRoleOf(fileFacts, codeRoles, arch);
|
|
38
|
+
if (fileRole)
|
|
39
|
+
present.push(fileRole);
|
|
40
|
+
}
|
|
41
|
+
return { present, candidates: copy, roleCtx: { present, candidates: copy } };
|
|
42
|
+
};
|
|
43
|
+
exports.classifyRoles = classifyRoles;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Arch, CodeRoles } from "../entities/architecture";
|
|
2
|
+
import type { Candidate, CallFact } from "../entities/facts";
|
|
3
|
+
declare const roleOfTarget: (call: Partial<CallFact> | null | undefined, nameToRole: ReadonlyMap<string, Candidate>, arch?: Arch | null) => string | null;
|
|
4
|
+
declare const enrichWithRoles: (candidates: Candidate[], codeRoles: CodeRoles | null | undefined, arch?: Arch | null) => Candidate[];
|
|
5
|
+
export { enrichWithRoles, roleOfTarget };
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.roleOfTarget = exports.enrichWithRoles = void 0;
|
|
4
|
+
// The code-role connector: the ONE place that makes codeRole names usable in
|
|
5
|
+
// any filter. A codeRole is a human-readable extension of a ts-morph kind, so
|
|
6
|
+
// the two are interchangeable in filters. This module is imported by
|
|
7
|
+
// invariants, nodes, and the pipeline — no other module implements
|
|
8
|
+
// role-name resolution.
|
|
9
|
+
//
|
|
10
|
+
// How it works:
|
|
11
|
+
// `enrichWithRoles(candidates, codeRoles)` adds three fields to each
|
|
12
|
+
// candidate fact (in place, mutating the array):
|
|
13
|
+
// • `role` — the candidate's classified role name (first matching
|
|
14
|
+
// codeRole in YAML order), or null.
|
|
15
|
+
// • `parentRole` — the role of the piece this one sits in (the `piece` of
|
|
16
|
+
// its `location`), or null.
|
|
17
|
+
// • Each entry in `calls` gets `targetRole` — the role of the function
|
|
18
|
+
// the call targets (matched by callee name), or null.
|
|
19
|
+
//
|
|
20
|
+
// After enrichment, filters can use plain field access:
|
|
21
|
+
// - `role: { equals: "action" }` → candidate IS an action
|
|
22
|
+
// - `parentRole: { equals: "orchestrator" }` → nested in an orchestrator
|
|
23
|
+
// - `calls: { some: { targetRole: { equals: "pureFunction" } } }`
|
|
24
|
+
// - `kind: { own: { is: { in: ["storeModel"] } } }` → a node's own kind
|
|
25
|
+
//
|
|
26
|
+
// This is the same mechanism used by classifyRoles — the connector does not
|
|
27
|
+
// re-implement infer matching; the first-match walk is the shared
|
|
28
|
+
// `utils/classify` core, over the same `matches` from the queries engine.
|
|
29
|
+
const location_1 = require("../entities/location");
|
|
30
|
+
const classify_1 = require("../utils/classify");
|
|
31
|
+
const fixpoint_1 = require("../utils/fixpoint");
|
|
32
|
+
// The candidate a call names locally: the action first (`self.toggleLine()`
|
|
33
|
+
// resolves to `toggleLine`), then the origin.
|
|
34
|
+
const localTarget = (call, nameToRole) => (call?.action ? nameToRole.get(call.action) : undefined) ?? (call?.origin ? nameToRole.get(call.origin) : undefined) ?? null;
|
|
35
|
+
// The role declared at a call target's location in ANOTHER file — ONE
|
|
36
|
+
// implementation of that question, in `entities/location/homes`. Ambiguous
|
|
37
|
+
// location → null, never a guess.
|
|
38
|
+
const roleAtTarget = (call, arch) => {
|
|
39
|
+
const at = call?.target?.path && arch ? (0, location_1.rolesAtPath)(arch, call.target.path) : [];
|
|
40
|
+
return at.length === 1 ? at[0] : null;
|
|
41
|
+
};
|
|
42
|
+
// The role of the candidate a call targets. A call's `action` is the called
|
|
43
|
+
// member name (`doX` in `store.doX()`) or the full text for a bare-identifier
|
|
44
|
+
// call (`fn`); `origin` is the leftmost chain segment (`store`, `new F`).
|
|
45
|
+
// This is the ONLY place call-target role resolution happens; every consumer
|
|
46
|
+
// (filters via `calls.some.targetRole`) reads the `targetRole` this attaches.
|
|
47
|
+
const roleOfTarget = (call, nameToRole, arch) => {
|
|
48
|
+
const hit = localTarget(call, nameToRole);
|
|
49
|
+
if (hit)
|
|
50
|
+
return hit.role ?? null;
|
|
51
|
+
return roleAtTarget(call, arch);
|
|
52
|
+
};
|
|
53
|
+
exports.roleOfTarget = roleOfTarget;
|
|
54
|
+
// The candidates by name — the table call-target resolution reads.
|
|
55
|
+
const byName = (candidates) => {
|
|
56
|
+
const map = new Map();
|
|
57
|
+
for (const c of candidates)
|
|
58
|
+
if (c.name)
|
|
59
|
+
map.set(c.name, c);
|
|
60
|
+
return map;
|
|
61
|
+
};
|
|
62
|
+
// One classification pass: every candidate gets the first role whose infer
|
|
63
|
+
// matches (YAML order wins). Reports whether any role moved.
|
|
64
|
+
const assignRoles = (candidates, codeRoles, arch) => {
|
|
65
|
+
const defs = (0, classify_1.definitionsOf)(codeRoles);
|
|
66
|
+
const scope = arch ? { arch } : undefined;
|
|
67
|
+
let changed = false;
|
|
68
|
+
for (const c of candidates) {
|
|
69
|
+
const role = (0, classify_1.firstMatch)(c, defs, scope ?? c);
|
|
70
|
+
if (role !== (c.role ?? null))
|
|
71
|
+
changed = true;
|
|
72
|
+
c.role = role;
|
|
73
|
+
}
|
|
74
|
+
return changed;
|
|
75
|
+
};
|
|
76
|
+
// One resolution pass: every call learns the role of its target, then the
|
|
77
|
+
// roles are re-assigned (a role may be inferred from the callees' roles).
|
|
78
|
+
const resolvePass = (candidates, codeRoles, names, arch) => {
|
|
79
|
+
for (const c of candidates) {
|
|
80
|
+
if (!Array.isArray(c.calls))
|
|
81
|
+
continue;
|
|
82
|
+
for (const call of c.calls)
|
|
83
|
+
call.targetRole = roleOfTarget(call, names, arch);
|
|
84
|
+
}
|
|
85
|
+
return assignRoles(candidates, codeRoles, arch);
|
|
86
|
+
};
|
|
87
|
+
// Classify each candidate's role (first matching codeRole in YAML order wins)
|
|
88
|
+
// and attach `targetRole` to each call fact. Mutates the candidates array in
|
|
89
|
+
// place and returns it.
|
|
90
|
+
//
|
|
91
|
+
// `arch` (optional) is the built architecture; when present it is passed as
|
|
92
|
+
// the match scope so location-aware infer operators (e.g. `path`, which takes
|
|
93
|
+
// the same entry interface as `location.allowedFrom`) can resolve node
|
|
94
|
+
// declarations.
|
|
95
|
+
//
|
|
96
|
+
// Role assignment and call-target resolution feed each other: a role may be
|
|
97
|
+
// inferred from the roles of the callees (`calls.some.targetRole`), while a
|
|
98
|
+
// callee's role is what `targetRole` resolves to. The passes repeat until
|
|
99
|
+
// nothing changes (the shared fixpoint walk), at most four times — roles move
|
|
100
|
+
// in one direction only: an earlier entry in the YAML order can newly match,
|
|
101
|
+
// never un-match.
|
|
102
|
+
const enrichWithRoles = (candidates, codeRoles, arch) => {
|
|
103
|
+
if (!Object.keys(codeRoles ?? {}).length)
|
|
104
|
+
return candidates;
|
|
105
|
+
const roles = codeRoles ?? {};
|
|
106
|
+
const names = byName(candidates);
|
|
107
|
+
assignRoles(candidates, roles, arch);
|
|
108
|
+
for (const c of candidates) {
|
|
109
|
+
c.parentRole = c.location?.piece ? (names.get(c.location.piece)?.role ?? null) : null;
|
|
110
|
+
}
|
|
111
|
+
(0, fixpoint_1.untilStable)(() => resolvePass(candidates, roles, names, arch), 4);
|
|
112
|
+
return candidates;
|
|
113
|
+
};
|
|
114
|
+
exports.enrichWithRoles = enrichWithRoles;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type Project } from "ts-morph";
|
|
2
|
+
import type { ObjectLiteral } from "../css/value/scope";
|
|
3
|
+
import type { Arch } from "../entities/architecture";
|
|
4
|
+
import type { Candidate } from "../entities/facts";
|
|
5
|
+
type ProjectRoleIndex = {
|
|
6
|
+
bySlug: Map<string, Candidate[]>;
|
|
7
|
+
objectsBySlug: Map<string, ObjectLiteral[]>;
|
|
8
|
+
};
|
|
9
|
+
declare const projectRoleIndex: (project: Project, arch: Arch, repoFiles: string[]) => ProjectRoleIndex;
|
|
10
|
+
declare const codeRoleScope: (index: ProjectRoleIndex) => Record<string, Candidate[]>;
|
|
11
|
+
declare const objectsFor: (index: ProjectRoleIndex, slugs: readonly string[]) => ObjectLiteral[];
|
|
12
|
+
export { projectRoleIndex, codeRoleScope, objectsFor };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.objectsFor = exports.codeRoleScope = exports.projectRoleIndex = void 0;
|
|
4
|
+
// THE PROJECT-WIDE CLASSIFY PASS. A query scope may name any code role
|
|
5
|
+
// (`codeRole.<slug>`) and read the pieces that carry it ACROSS the repo — a
|
|
6
|
+
// role's object literals, for instance, live in files other than the one the
|
|
7
|
+
// invariant is judging. Classification is per piece and per file, so the pass
|
|
8
|
+
// runs the SAME per-file walk (`collectCandidates` + facets + `classifyRoles`)
|
|
9
|
+
// over every source file and indexes the results by role.
|
|
10
|
+
//
|
|
11
|
+
// Nothing here knows a role name: the index is `slug → candidates`, and the
|
|
12
|
+
// literals are the object-literal initializers of a role's candidates. Cached per
|
|
13
|
+
// project (rebuilt when the project grows), so the whole scan happens once per
|
|
14
|
+
// run, not once per file.
|
|
15
|
+
const ts_morph_1 = require("ts-morph");
|
|
16
|
+
const imports_1 = require("../utils/imports");
|
|
17
|
+
const group_1 = require("../utils/group");
|
|
18
|
+
const ast_1 = require("../entities/ast");
|
|
19
|
+
const frameworks_1 = require("../frameworks");
|
|
20
|
+
const css_1 = require("../css");
|
|
21
|
+
const classify_1 = require("./classify");
|
|
22
|
+
const emptyIndex = () => ({ bySlug: new Map(), objectsBySlug: new Map() });
|
|
23
|
+
// Strip the wrappers that do not change a value: `(x)`, `x as T`, `x satisfies T`,
|
|
24
|
+
// `x!`. A literal written as `{…} satisfies SomeInterface` carries its members on
|
|
25
|
+
// the wrapped literal, so this is where the object node is found.
|
|
26
|
+
const unwrapToLiteral = (node) => {
|
|
27
|
+
let current = node;
|
|
28
|
+
for (;;) {
|
|
29
|
+
if (ts_morph_1.Node.isParenthesizedExpression(current) || ts_morph_1.Node.isAsExpression(current) || ts_morph_1.Node.isSatisfiesExpression(current) || ts_morph_1.Node.isNonNullExpression(current) || ts_morph_1.Node.isTypeAssertion(current)) {
|
|
30
|
+
current = current.getExpression();
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
return ts_morph_1.Node.isObjectLiteralExpression(current) ? current : null;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
// The classified candidate a declaration's initializer belongs to: the same name
|
|
37
|
+
// and start line. A variable holding an object literal has one candidate whose
|
|
38
|
+
// `kind.initializer` is that literal, so name+line is unambiguous here.
|
|
39
|
+
const candidateAt = (classified, name, line) => classified.find((c) => c.name === name && c.lines?.[0] === line) ?? null;
|
|
40
|
+
// Push a role's object literal when the declaration's initializer is one.
|
|
41
|
+
// Exported default (`export default {…}`) is a declaration with the name
|
|
42
|
+
// `default`, so both spellings read the same way.
|
|
43
|
+
const addObject = (entry) => {
|
|
44
|
+
const role = candidateAt(entry.classified, entry.name, entry.line)?.role;
|
|
45
|
+
if (!role)
|
|
46
|
+
return;
|
|
47
|
+
(0, group_1.pushGroup)(entry.objectsBySlug, role, { name: entry.name, node: entry.node });
|
|
48
|
+
};
|
|
49
|
+
// The object-literal initializers of one file's classified candidates.
|
|
50
|
+
const collectObjects = (sf, classified, objectsBySlug) => {
|
|
51
|
+
for (const declaration of sf.getVariableDeclarations()) {
|
|
52
|
+
const initializer = declaration.getInitializer();
|
|
53
|
+
const nameNode = declaration.getNameNode();
|
|
54
|
+
if (!initializer || !ts_morph_1.Node.isIdentifier(nameNode))
|
|
55
|
+
continue;
|
|
56
|
+
const literal = unwrapToLiteral(initializer);
|
|
57
|
+
if (literal)
|
|
58
|
+
addObject({ objectsBySlug, classified, name: nameNode.getText(), line: declaration.getStartLineNumber(), node: literal });
|
|
59
|
+
}
|
|
60
|
+
for (const assignment of sf.getExportAssignments()) {
|
|
61
|
+
const literal = unwrapToLiteral(assignment.getExpression());
|
|
62
|
+
if (literal)
|
|
63
|
+
addObject({ objectsBySlug, classified, name: "default", line: assignment.getStartLineNumber(), node: literal });
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
// One file's classified candidates, with the facets a role may be recognised
|
|
67
|
+
// by. The facets are attached exactly as the per-file pipeline attaches them,
|
|
68
|
+
// so a role classifies the same way here and there.
|
|
69
|
+
// A per-file classify walk; it is not the depth walk's `read`.
|
|
70
|
+
const classifyFile = (sf, run) => {
|
|
71
|
+
const repoRoot = run.arch.repoRoot ?? ".";
|
|
72
|
+
const rel = (0, imports_1.toRel)(repoRoot, sf.getFilePath());
|
|
73
|
+
const text = sf.getFullText();
|
|
74
|
+
const importMap = (0, ast_1.importNameModules)(sf, repoRoot, run.arch.aliases ?? {}, run.repoFiles);
|
|
75
|
+
const candidates = (0, ast_1.collectCandidates)(sf, importMap, rel, repoRoot);
|
|
76
|
+
(0, frameworks_1.enrich)(candidates, { rel, sf, text, repoRoot, importMap });
|
|
77
|
+
(0, css_1.attachToCandidates)(candidates, { sf });
|
|
78
|
+
const fileFacts = (0, ast_1.collectFileFacts)(sf, { rel, repoFiles: run.repoFiles, aliases: run.arch.aliases ?? {}, repoRoot, candidates: [] });
|
|
79
|
+
return (0, classify_1.classifyRoles)(candidates, run.arch.codeRoles, run.arch, fileFacts).candidates;
|
|
80
|
+
};
|
|
81
|
+
// The project index, cached per project and rebuilt when the project grows (the
|
|
82
|
+
// same policy the value scope uses).
|
|
83
|
+
const PROJECT_INDEX = new WeakMap();
|
|
84
|
+
// Cached per project, like the scope cache, but a different index.
|
|
85
|
+
const projectRoleIndex = (project, arch, repoFiles) => {
|
|
86
|
+
const files = project.getSourceFiles();
|
|
87
|
+
const cached = PROJECT_INDEX.get(project);
|
|
88
|
+
if (cached && cached.count === files.length)
|
|
89
|
+
return cached.index;
|
|
90
|
+
const index = emptyIndex();
|
|
91
|
+
for (const sf of files) {
|
|
92
|
+
const classified = classifyFile(sf, { arch, repoFiles });
|
|
93
|
+
for (const candidate of classified) {
|
|
94
|
+
if (!candidate.role)
|
|
95
|
+
continue;
|
|
96
|
+
index.bySlug.set(candidate.role, [...(index.bySlug.get(candidate.role) ?? []), candidate]);
|
|
97
|
+
}
|
|
98
|
+
collectObjects(sf, classified, index.objectsBySlug);
|
|
99
|
+
}
|
|
100
|
+
PROJECT_INDEX.set(project, { count: files.length, index });
|
|
101
|
+
return index;
|
|
102
|
+
};
|
|
103
|
+
exports.projectRoleIndex = projectRoleIndex;
|
|
104
|
+
// The `codeRole` scope object: role slug → the project-wide pieces carrying it.
|
|
105
|
+
// A plain record so the filter engine can navigate it (`codeRole.<slug>`).
|
|
106
|
+
const codeRoleScope = (index) => Object.fromEntries(index.bySlug);
|
|
107
|
+
exports.codeRoleScope = codeRoleScope;
|
|
108
|
+
// The object literals a set of role slugs offers, de-duplicated by literal.
|
|
109
|
+
const objectsFor = (index, slugs) => {
|
|
110
|
+
const seen = new Set();
|
|
111
|
+
const out = [];
|
|
112
|
+
for (const slug of slugs) {
|
|
113
|
+
for (const object of index.objectsBySlug.get(slug) ?? []) {
|
|
114
|
+
if (seen.has(object))
|
|
115
|
+
continue;
|
|
116
|
+
seen.add(object);
|
|
117
|
+
out.push(object);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
};
|
|
122
|
+
exports.objectsFor = objectsFor;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CodeRoles, RawCodeRoles } from "../entities/architecture";
|
|
2
|
+
declare const SCOPE: Readonly<{
|
|
3
|
+
FUNCTION: "function";
|
|
4
|
+
OBJECT: "object";
|
|
5
|
+
METHOD: "method";
|
|
6
|
+
}>;
|
|
7
|
+
declare const normalizeCodeRoles: (raw: RawCodeRoles | null | undefined) => CodeRoles;
|
|
8
|
+
export { normalizeCodeRoles, SCOPE };
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.SCOPE = exports.normalizeCodeRoles = void 0;
|
|
27
|
+
// Normalize the YAML `codeRoles` section — the architecture's model of WHAT
|
|
28
|
+
// code is. A role is the whole description of one kind of code:
|
|
29
|
+
//
|
|
30
|
+
// infer — how to recognise it (filters over ts-morph facts)
|
|
31
|
+
// where — WHERE code of this role may be declared (its home)
|
|
32
|
+
// report — what to say when it is declared elsewhere
|
|
33
|
+
// actions — what may be done with it, and BY WHOM:
|
|
34
|
+
// actions.import.where — who may import it
|
|
35
|
+
// actions.call.where — who may call it
|
|
36
|
+
// actions.mutate.where — who may write INTO it
|
|
37
|
+
// actions.assign.where — who may write into what it was handed
|
|
38
|
+
// actions.read.where — who may read it
|
|
39
|
+
// `where` is THE shared mechanism (utils/where.js): the same
|
|
40
|
+
// entry interface invariants use for `where` / `except`.
|
|
41
|
+
//
|
|
42
|
+
// `scopeAccess` (on an action) lists the chain roots through which that code
|
|
43
|
+
// is reached WITHOUT an import: `{ scope, segments }` — `scope` says what the
|
|
44
|
+
// root IS (`function` / `object` / `method`), `segments` says how it is
|
|
45
|
+
// spelled (`getRoot`, `self.root`, `parent.get`).
|
|
46
|
+
const location_1 = require("../entities/location");
|
|
47
|
+
const kinds_1 = require("../entities/kinds");
|
|
48
|
+
const schema_1 = require("../entities/schema");
|
|
49
|
+
const field_1 = require("../utils/field");
|
|
50
|
+
const keyed_1 = require("../utils/keyed");
|
|
51
|
+
const typed_field_1 = require("../utils/typed-field");
|
|
52
|
+
const map_record_1 = require("../utils/map-record");
|
|
53
|
+
const configError = __importStar(require("../report/configErrors"));
|
|
54
|
+
// Keys of a role that describe the role itself, not an action on it.
|
|
55
|
+
const ROLE_KEYS = new Set(schema_1.SCHEMA.role);
|
|
56
|
+
// `infer` entries: a bare string is a REFERENCE to another role ("this is code
|
|
57
|
+
// that already got that role"), which is how roles compose.
|
|
58
|
+
const parseInfer = (entry) => (typeof entry === "string" ? { role: { equals: entry } } : entry);
|
|
59
|
+
// What a chain root IS. `scope`, not `kind`: this entry describes a place code
|
|
60
|
+
// is reached from, and `kind` already means "the ts-morph kind of a node"
|
|
61
|
+
// everywhere else in the engine.
|
|
62
|
+
const SCOPE = Object.freeze({ FUNCTION: "function", OBJECT: "object", METHOD: "method" });
|
|
63
|
+
exports.SCOPE = SCOPE;
|
|
64
|
+
const SCOPES = Object.values(SCOPE);
|
|
65
|
+
// One `scopeAccess` entry — what the root is, and how it is spelled:
|
|
66
|
+
// { scope: function, segments: [getRoot] } `getRoot(self).x`
|
|
67
|
+
// { scope: object, segments: [self, root] } `self.root.x`
|
|
68
|
+
// { scope: method, segments: [parent, get] } `parent.get("n").x`
|
|
69
|
+
// The scope is read through the shared typed-field walk; a bare string is the
|
|
70
|
+
// function scope's own spelling.
|
|
71
|
+
const isScopeName = (v) => typeof v === "string" && SCOPES.includes(v);
|
|
72
|
+
const accessorScopeOf = (e) => {
|
|
73
|
+
const scope = (0, typed_field_1.typedField)(e, "scope", isScopeName);
|
|
74
|
+
if (scope === undefined)
|
|
75
|
+
throw configError.scopeNotOneOf({ got: (0, field_1.fieldOf)(e, "scope"), allowed: SCOPES });
|
|
76
|
+
return scope;
|
|
77
|
+
};
|
|
78
|
+
const normalizeScopeAccessor = (e) => {
|
|
79
|
+
if (typeof e === "string")
|
|
80
|
+
return { scope: SCOPE.FUNCTION, segments: [e] };
|
|
81
|
+
const scope = accessorScopeOf(e);
|
|
82
|
+
const segments = (0, location_1.toList)((0, field_1.fieldOf)(e, "segments")).map(String);
|
|
83
|
+
if (!segments.length || segments.some((x) => !x))
|
|
84
|
+
throw configError.emptyAccessorSegments({ scope });
|
|
85
|
+
return { scope, segments };
|
|
86
|
+
};
|
|
87
|
+
// The `of:` reader — this action is checked against the named fact class. Lets
|
|
88
|
+
// a design use its own vocabulary (emit / subscribe / dispatch / provide)
|
|
89
|
+
// without the engine knowing that vocabulary.
|
|
90
|
+
const readActionFact = (value) => {
|
|
91
|
+
if (typeof value !== "string" || !kinds_1.FACT_KINDS.includes(value)) {
|
|
92
|
+
throw configError.unknownActionFact({ value, known: kinds_1.FACT_KINDS });
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
};
|
|
96
|
+
const readScopeAccess = (value) => {
|
|
97
|
+
const list = (0, location_1.toList)(value);
|
|
98
|
+
return list.length ? list.map(normalizeScopeAccessor) : null;
|
|
99
|
+
};
|
|
100
|
+
const ACTION_KEYS = {
|
|
101
|
+
where: (value, roles) => (0, location_1.parseWhere)(value, roles),
|
|
102
|
+
except: (value, roles) => (0, location_1.parseWhere)(value, roles),
|
|
103
|
+
of: (value) => readActionFact(value),
|
|
104
|
+
scopeAccess: (value) => readScopeAccess(value),
|
|
105
|
+
};
|
|
106
|
+
const normalizeAction = (name, spec, roles) => {
|
|
107
|
+
for (const key of Object.keys(spec)) {
|
|
108
|
+
if (!(key in ACTION_KEYS)) {
|
|
109
|
+
throw configError.unknownActionKey({ name, key, allowed: Object.keys(ACTION_KEYS) });
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const out = {};
|
|
113
|
+
for (const [key, read] of Object.entries(ACTION_KEYS)) {
|
|
114
|
+
if (spec[key] == null)
|
|
115
|
+
continue;
|
|
116
|
+
const value = read(spec[key], roles);
|
|
117
|
+
if (value != null)
|
|
118
|
+
out[key] = value;
|
|
119
|
+
}
|
|
120
|
+
return out;
|
|
121
|
+
};
|
|
122
|
+
// Roles may name other roles in `infer` (a bare string): a typo must not
|
|
123
|
+
// silently classify nothing.
|
|
124
|
+
const checkReferences = (roles) => {
|
|
125
|
+
const bySlug = new Map(roles.map((r) => [r.slug, r]));
|
|
126
|
+
for (const role of roles) {
|
|
127
|
+
for (const entry of (0, location_1.toList)(role.infer)) {
|
|
128
|
+
if (typeof entry !== "string")
|
|
129
|
+
continue;
|
|
130
|
+
if (!bySlug.has(entry))
|
|
131
|
+
throw configError.roleInfersUnknown({ role: role.slug, entry });
|
|
132
|
+
if (entry === role.slug)
|
|
133
|
+
throw configError.roleInfersItself({ role: role.slug });
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return roles;
|
|
137
|
+
};
|
|
138
|
+
// Roles may be declared as a LIST of `{ slug, … }` entries or as a MAP keyed
|
|
139
|
+
// by slug — the shared `keyedDefs` walk, the same one the nodes section reads.
|
|
140
|
+
// In the list form order matters (first match wins).
|
|
141
|
+
const checkDefs = (defs) => {
|
|
142
|
+
const checked = [];
|
|
143
|
+
for (const def of defs) {
|
|
144
|
+
if (!(0, field_1.isObj)(def))
|
|
145
|
+
throw configError.roleNotAnObject();
|
|
146
|
+
if (!def.slug)
|
|
147
|
+
throw configError.roleWithoutSlug();
|
|
148
|
+
checked.push(def);
|
|
149
|
+
}
|
|
150
|
+
return checked;
|
|
151
|
+
};
|
|
152
|
+
// One action spec: an object with a `where` — a permission that names nobody
|
|
153
|
+
// allows nobody.
|
|
154
|
+
const actionSpecOf = (def, kind, spec) => {
|
|
155
|
+
if (!(0, field_1.isObj)(spec))
|
|
156
|
+
throw configError.actionNotAnObject({ role: def.slug, action: kind });
|
|
157
|
+
if (spec.where == null)
|
|
158
|
+
throw configError.actionWithoutWhere({ role: def.slug, action: kind });
|
|
159
|
+
return spec;
|
|
160
|
+
};
|
|
161
|
+
const actionsOf = (def, roleSlugs) => {
|
|
162
|
+
const declared = (0, field_1.isObj)(def.actions) ? def.actions : {};
|
|
163
|
+
// `declare` is the role's own `where` — one statement, not two. The
|
|
164
|
+
// entry-by-entry walk is the shared `mapRecord` core.
|
|
165
|
+
return (0, map_record_1.mapRecord)(declared, (kind, spec) => normalizeAction(`${def.slug}.actions.${kind}`, actionSpecOf(def, kind, spec), roleSlugs));
|
|
166
|
+
};
|
|
167
|
+
const checkRoleKeys = (def) => {
|
|
168
|
+
if (def.where != null)
|
|
169
|
+
throw configError.roleWhereNotAllowed({ role: def.slug });
|
|
170
|
+
for (const key of Object.keys(def)) {
|
|
171
|
+
if (!ROLE_KEYS.has(key))
|
|
172
|
+
throw configError.unknownRoleKey({ role: def.slug, key, allowed: schema_1.SCHEMA.role });
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
const roleOf = (def, roleSlugs) => ({
|
|
176
|
+
slug: String(def.slug),
|
|
177
|
+
name: typeof def.name === "string" ? def.name : String(def.slug),
|
|
178
|
+
infer: (0, location_1.toList)(def.infer).map(parseInfer),
|
|
179
|
+
report: typeof def.report === "string" || (0, field_1.isObj)(def.report) ? def.report : null,
|
|
180
|
+
actions: actionsOf(def, roleSlugs),
|
|
181
|
+
});
|
|
182
|
+
const normalizeCodeRoles = (raw) => {
|
|
183
|
+
const defs = checkDefs((0, keyed_1.keyedDefs)(raw));
|
|
184
|
+
checkReferences(defs);
|
|
185
|
+
const roleSlugs = new Set(defs.map((d) => String(d.slug)));
|
|
186
|
+
for (const def of defs)
|
|
187
|
+
checkRoleKeys(def);
|
|
188
|
+
return Object.fromEntries(defs.map((def) => [String(def.slug), roleOf(def, roleSlugs)]));
|
|
189
|
+
};
|
|
190
|
+
exports.normalizeCodeRoles = normalizeCodeRoles;
|