@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,169 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.homeForRole = exports.rolesAtPath = exports.roleFitsAt = exports.placeFor = exports.destinationOf = exports.destinationsIn = exports.sharedPrefix = exports.homesOf = void 0;
|
|
4
|
+
// THE ROLE → PLACE ANSWER. "Where does code of this role live" is the SAME
|
|
5
|
+
// question as "what does this place entry resolve to", so this module owns both
|
|
6
|
+
// the declared homes and the concrete place-for-this-file answer.
|
|
7
|
+
//
|
|
8
|
+
// homesOf(arch, role) — the path templates that role may occupy
|
|
9
|
+
// placeFor(arch, role, rel) — where this role's code belongs FOR THIS FILE
|
|
10
|
+
// destinationOf(arch, role, rel) — the concrete, hostable place, or null
|
|
11
|
+
//
|
|
12
|
+
// Nothing here is stored on the codeRole: a role knows what code IS, never which
|
|
13
|
+
// folder it is in. Anything that needs a location asks the tree.
|
|
14
|
+
const match_1 = require("../tree/match");
|
|
15
|
+
const where_1 = require("./where");
|
|
16
|
+
const place_1 = require("./place");
|
|
17
|
+
const rank_1 = require("../../utils/rank");
|
|
18
|
+
// Every path the tree gives this role, in the order the config declares them.
|
|
19
|
+
const homesOf = (arch, role) => arch.nodes.roleHomes[role] ?? [];
|
|
20
|
+
exports.homesOf = homesOf;
|
|
21
|
+
// How much of the template's start this file shares. Used only to pick which
|
|
22
|
+
// branch of a repeating node the file belongs to — never to allow or deny.
|
|
23
|
+
const sharedPrefix = (template, rel) => {
|
|
24
|
+
const ts = String(template).split("/");
|
|
25
|
+
const rs = String(rel ?? "").split("/");
|
|
26
|
+
let n = 0;
|
|
27
|
+
for (let i = 0; i < ts.length; i += 1) {
|
|
28
|
+
const seg = ts[i];
|
|
29
|
+
if (seg === "**" || /^\{[^}]+\}$/.test(seg)) {
|
|
30
|
+
n += 1;
|
|
31
|
+
continue;
|
|
32
|
+
}
|
|
33
|
+
if (seg !== rs[i])
|
|
34
|
+
break;
|
|
35
|
+
n += 1;
|
|
36
|
+
}
|
|
37
|
+
return n;
|
|
38
|
+
};
|
|
39
|
+
exports.sharedPrefix = sharedPrefix;
|
|
40
|
+
// The directory a home names: a file child contributes its parent folder.
|
|
41
|
+
const homeDir = (template) => {
|
|
42
|
+
const segs = String(template).split("/").filter((s) => s !== "**");
|
|
43
|
+
return /\.[A-Za-z0-9]+$/.test(segs[segs.length - 1] ?? "") ? segs.slice(0, -1) : segs;
|
|
44
|
+
};
|
|
45
|
+
// The folder OF A FILE as segments.
|
|
46
|
+
const fileDir = (rel) => (0, place_1.dirOf)(rel).split("/").filter(Boolean);
|
|
47
|
+
const isPlaceholder = (seg) => /^\{[^}]+\}$/.test(seg);
|
|
48
|
+
// Is the file in the SAME BRANCH as this home? One directory is a prefix of the
|
|
49
|
+
// other. `{kebab-case}` matches any single segment, so a feature's instance
|
|
50
|
+
// always answers for its own files.
|
|
51
|
+
const sameBranch = (home, dir) => {
|
|
52
|
+
const [short, long] = home.length <= dir.length ? [home, dir] : [dir, home];
|
|
53
|
+
return short.every((seg, i) => isPlaceholder(seg) || isPlaceholder(long[i] ?? "") || seg === long[i]);
|
|
54
|
+
};
|
|
55
|
+
// Whether this home is in the file's branch. A home that names ONE FILE only
|
|
56
|
+
// answers for files of exactly that folder; a FOLDER home may sit in a general
|
|
57
|
+
// branch (`packages/utils`) that still applies.
|
|
58
|
+
const branchFor = (fileHome, home, dir) => (fileHome ? home.length === dir.length && sameBranch(home, dir) : sameBranch(home, dir));
|
|
59
|
+
const scoreEntry = (entry, i, dir, rel) => {
|
|
60
|
+
const home = homeDir(entry.template);
|
|
61
|
+
const last = String(entry.template).split("/").filter((seg) => seg !== "**").pop() ?? "";
|
|
62
|
+
const fileHome = /\.[A-Za-z0-9]+$/.test(last);
|
|
63
|
+
const branch = branchFor(fileHome, home, dir);
|
|
64
|
+
return { entry, i, keep: branch || !fileHome, branch, score: sharedPrefix(entry.template, rel) };
|
|
65
|
+
};
|
|
66
|
+
// The concrete places a role's code may go FOR THIS FILE, best first. The
|
|
67
|
+
// score-keep-rank walk is the shared `rankedOffers` core — the same one the
|
|
68
|
+
// folder lookalikes use; the scoring policy (branch, prefix, declared order)
|
|
69
|
+
// is this module's own.
|
|
70
|
+
const destinationsIn = (arch, role, rel) => {
|
|
71
|
+
const entries = homesOf(arch, role);
|
|
72
|
+
if (!entries.length)
|
|
73
|
+
return [];
|
|
74
|
+
// A role with ONE declared place has no branch question to answer.
|
|
75
|
+
if (entries.length === 1 && !/\*\*\s*$/.test(entries[0].template)) {
|
|
76
|
+
return [{ slug: entries[0].node, path: (0, where_1.fillTemplate)(entries[0].template, rel), folder: false, template: entries[0].template }];
|
|
77
|
+
}
|
|
78
|
+
const dir = fileDir(rel);
|
|
79
|
+
const destinationOfEntry = (entry) => ({ slug: entry.node, path: (0, where_1.fillTemplate)(entry.template, rel), folder: /\*\*\s*$/.test(entry.template), template: entry.template });
|
|
80
|
+
const kept = (0, rank_1.rankedOffers)(entries.map((entry, i) => ({ entry, i })), ({ entry, i }) => {
|
|
81
|
+
const scored = scoreEntry(entry, i, dir, rel);
|
|
82
|
+
return scored.keep ? { ...destinationOfEntry(entry), branch: scored.branch, score: scored.score, i } : null;
|
|
83
|
+
}, (a, b) => Number(b.branch) - Number(a.branch) || b.score - a.score || a.i - b.i);
|
|
84
|
+
return kept.map(({ slug, path, folder, template }) => ({ slug, path, folder, template }));
|
|
85
|
+
};
|
|
86
|
+
exports.destinationsIn = destinationsIn;
|
|
87
|
+
// The place a role's code belongs FOR THIS FILE, and only when that place can
|
|
88
|
+
// exist: the FOLDER has to be a real node instance, while a home that names a
|
|
89
|
+
// FILE may still be created — its parent being an instance is enough.
|
|
90
|
+
// Does the node that owns the folder own it for THIS destination (the node
|
|
91
|
+
// itself, or its declared parent)?
|
|
92
|
+
const ownsDest = (arch, hit, dest) => {
|
|
93
|
+
const parent = arch.nodes.bySlug[dest.slug ?? ""]?.parents[0] ?? null;
|
|
94
|
+
return hit.slug === dest.slug || (parent != null && hit.slug === parent);
|
|
95
|
+
};
|
|
96
|
+
const hostFolder = (dest) => (dest.folder ? dest.path ?? "" : (0, place_1.dirOf)(dest.path ?? ""));
|
|
97
|
+
const nodeOk = (arch, dest) => {
|
|
98
|
+
const destNode = arch.nodes.bySlug[dest.slug ?? ""];
|
|
99
|
+
return !destNode || (0, match_1.ancestorsAreReal)(destNode, dest.path ?? "", arch);
|
|
100
|
+
};
|
|
101
|
+
const destinationOf = (arch, role, rel) => {
|
|
102
|
+
for (const dest of destinationsIn(arch, role, rel)) {
|
|
103
|
+
if (!dest?.slug || !dest.path)
|
|
104
|
+
continue;
|
|
105
|
+
if (!nodeOk(arch, dest))
|
|
106
|
+
continue;
|
|
107
|
+
const folder = hostFolder(dest);
|
|
108
|
+
const hit = (0, match_1.folderOwner)(arch, folder);
|
|
109
|
+
if (!hit || !(0, match_1.instanceAt)(arch, hit.slug, folder))
|
|
110
|
+
continue;
|
|
111
|
+
if (ownsDest(arch, hit, dest))
|
|
112
|
+
return dest;
|
|
113
|
+
}
|
|
114
|
+
return null;
|
|
115
|
+
};
|
|
116
|
+
exports.destinationOf = destinationOf;
|
|
117
|
+
// WHERE a role's code belongs FOR THIS FILE — the ONE answer every caller uses.
|
|
118
|
+
const placeFor = (arch, role, rel) => {
|
|
119
|
+
const dest = destinationOf(arch, role, rel);
|
|
120
|
+
if (dest?.path)
|
|
121
|
+
return { path: dest.path, concrete: true, folder: Boolean(dest.folder) };
|
|
122
|
+
const homes = homesOf(arch, role).map((h) => h.template);
|
|
123
|
+
// A role with SEVERAL homes and none of them hostable here has no answer for
|
|
124
|
+
// this file: picking one would be a guess dressed as advice.
|
|
125
|
+
if (homes.length !== 1) {
|
|
126
|
+
const nearest = destinationsIn(arch, role, rel)[0];
|
|
127
|
+
if (!nearest?.template)
|
|
128
|
+
return null;
|
|
129
|
+
const last = nearest.template.split("/").filter((seg) => seg !== "**").pop() ?? "";
|
|
130
|
+
const folder = /\*\*\s*$/.test(nearest.template) || !/\.[A-Za-z0-9]+$/.test(last);
|
|
131
|
+
return { path: nearest.template.replace(/\/\*\*$/, ""), concrete: false, folder };
|
|
132
|
+
}
|
|
133
|
+
const only = homes[0];
|
|
134
|
+
if (!/[*{]/.test(only))
|
|
135
|
+
return { path: only, concrete: true, folder: false };
|
|
136
|
+
return { path: only.replace(/\/\*\*$/, ""), concrete: false, folder: true };
|
|
137
|
+
};
|
|
138
|
+
exports.placeFor = placeFor;
|
|
139
|
+
// Does this file sit inside one of the role's homes, asked THROUGH the tree?
|
|
140
|
+
const roleFitsAt = (arch, role, rel) => {
|
|
141
|
+
if (!rel)
|
|
142
|
+
return false;
|
|
143
|
+
return (arch.nodes.roleHomes[role] ?? []).some((h) => (0, where_1.matchesWhere)({ type: "template", template: h.template }, rel, arch, null, null));
|
|
144
|
+
};
|
|
145
|
+
exports.roleFitsAt = roleFitsAt;
|
|
146
|
+
// The roles whose declared home covers this path — MOST SPECIFIC FIRST.
|
|
147
|
+
const rolesAtPath = (arch, path) => {
|
|
148
|
+
if (!path)
|
|
149
|
+
return [];
|
|
150
|
+
return Object.keys(arch.nodes.roleHomes)
|
|
151
|
+
.filter((role) => roleFitsAt(arch, role, path))
|
|
152
|
+
.map((role, i) => ({
|
|
153
|
+
role,
|
|
154
|
+
i,
|
|
155
|
+
depth: Math.max(0, ...homesOf(arch, role).map((h) => sharedPrefix(h.template, path))),
|
|
156
|
+
}))
|
|
157
|
+
.sort((a, b) => b.depth - a.depth || a.i - b.i)
|
|
158
|
+
.map((x) => x.role);
|
|
159
|
+
};
|
|
160
|
+
exports.rolesAtPath = rolesAtPath;
|
|
161
|
+
// Where a role's code belongs FOR THIS FILE, as the BOX and the PATH together.
|
|
162
|
+
const homeForRole = (arch, role, rel) => {
|
|
163
|
+
const place = placeFor(arch, role, rel);
|
|
164
|
+
if (!place?.path)
|
|
165
|
+
return null;
|
|
166
|
+
const folder = place.folder ? place.path : (0, place_1.dirOf)(place.path);
|
|
167
|
+
return { role, path: place.path, folder: place.folder, concrete: Boolean(place.concrete), node: (0, match_1.folderOwner)(arch, folder)?.slug ?? null };
|
|
168
|
+
};
|
|
169
|
+
exports.homeForRole = homeForRole;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Leaf, Place } from "../facts";
|
|
2
|
+
declare const wordsIn: (name: string | null | undefined) => string[];
|
|
3
|
+
declare const nameOnly: (name: string | null | undefined) => string;
|
|
4
|
+
declare const segmentsOf: (rel: string | null | undefined) => string[];
|
|
5
|
+
declare const parentOf: (rel: string | null | undefined) => string;
|
|
6
|
+
declare const leafOf: (rel: string | null | undefined) => Leaf;
|
|
7
|
+
declare const placeOf: (rel: string | null | undefined, repoFiles?: string[] | null | undefined) => Place;
|
|
8
|
+
declare const placeholdersOf: (template: string | null | undefined) => string;
|
|
9
|
+
declare const dirOf: (path: string | null | undefined) => string;
|
|
10
|
+
export { wordsIn, nameOnly, segmentsOf, parentOf, leafOf, placeOf, placeholdersOf, dirOf };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dirOf = exports.placeholdersOf = exports.placeOf = exports.leafOf = exports.parentOf = exports.segmentsOf = exports.nameOnly = exports.wordsIn = void 0;
|
|
4
|
+
const split_1 = require("../../utils/split");
|
|
5
|
+
const wordsIn = (name) => String(name ?? "")
|
|
6
|
+
// camelCase and ALLCAPS runs: `fileName` → file name, `HTMLParser` → HTML Parser
|
|
7
|
+
.replace(/([a-z0-9])([A-Z])/g, "$1 $2")
|
|
8
|
+
.replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2")
|
|
9
|
+
.split(/[^A-Za-z0-9]+/)
|
|
10
|
+
.map((w) => w.toLowerCase())
|
|
11
|
+
.filter(Boolean);
|
|
12
|
+
exports.wordsIn = wordsIn;
|
|
13
|
+
// The name without ANY extension: `x.spec.ts` → `x`. A leading dot is part of
|
|
14
|
+
// the name (`.env` has no extension, it IS a name).
|
|
15
|
+
const nameOnly = (name) => {
|
|
16
|
+
const n = String(name ?? "");
|
|
17
|
+
const dot = n.indexOf(".", n.startsWith(".") ? 1 : 0);
|
|
18
|
+
return dot > 0 ? n.slice(0, dot) : n;
|
|
19
|
+
};
|
|
20
|
+
exports.nameOnly = nameOnly;
|
|
21
|
+
// ONE PATH → its segments. The split is the shared `partsOf` core; a path drops
|
|
22
|
+
// the empty segments a leading/trailing `/` would leave.
|
|
23
|
+
const segmentsOf = (rel) => (0, split_1.partsOf)(rel, "/").all.filter(Boolean);
|
|
24
|
+
exports.segmentsOf = segmentsOf;
|
|
25
|
+
// The PARENT of any path: one segment up. The root has none — `""`.
|
|
26
|
+
const parentOf = (rel) => segmentsOf(rel).slice(0, -1).join("/");
|
|
27
|
+
exports.parentOf = parentOf;
|
|
28
|
+
// ONE PATH → the names it is made of. No folder, no neighbours.
|
|
29
|
+
const leafOf = (rel) => {
|
|
30
|
+
const path = String(rel ?? "");
|
|
31
|
+
const segments = segmentsOf(path);
|
|
32
|
+
const name = segments[segments.length - 1] ?? "";
|
|
33
|
+
const fileName = nameOnly(name);
|
|
34
|
+
// `x.spec.ts` → [".spec", ".ts"]; `.env` is a name, not an extension.
|
|
35
|
+
const exts = fileName === name ? [] : name.slice(fileName.length).split(".").filter(Boolean).map((e) => `.${e}`);
|
|
36
|
+
return { path, segments, exts, fileName, words: wordsIn(fileName) };
|
|
37
|
+
};
|
|
38
|
+
exports.leafOf = leafOf;
|
|
39
|
+
// The place of a file: its own names, plus the folder it sits in.
|
|
40
|
+
const placeOf = (rel, repoFiles = []) => {
|
|
41
|
+
const leaf = leafOf(rel);
|
|
42
|
+
const dir = parentOf(leaf.path);
|
|
43
|
+
const files = [...new Set((repoFiles ?? []).filter((p) => parentOf(p) === dir))].sort().map(leafOf);
|
|
44
|
+
return { ...leaf, files, siblings: files.filter((f) => f.path !== leaf.path) };
|
|
45
|
+
};
|
|
46
|
+
exports.placeOf = placeOf;
|
|
47
|
+
// The placeholders a template still has (`{kebab-case}`), for a sentence that
|
|
48
|
+
// tells the reader what to fill in.
|
|
49
|
+
const placeholdersOf = (template) => [...new Set(String(template ?? "").match(/\{[^}]+\}/g) ?? [])].map((p) => `\`${p}\``).join(", ") || "its placeholders";
|
|
50
|
+
exports.placeholdersOf = placeholdersOf;
|
|
51
|
+
// The folder of a path: a file contributes its parent, a folder is itself.
|
|
52
|
+
const dirOf = (path) => {
|
|
53
|
+
const p = String(path ?? "");
|
|
54
|
+
return /\.[A-Za-z0-9]+$/.test(p) ? parentOf(p) : p;
|
|
55
|
+
};
|
|
56
|
+
exports.dirOf = dirOf;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { toList, type FieldValue } from "../../utils/field";
|
|
2
|
+
import type { Arch, WhereEntry } from "../architecture";
|
|
3
|
+
import type { FileFacts } from "../facts";
|
|
4
|
+
type Caps = Record<string, string | undefined>;
|
|
5
|
+
declare const parseWhereEntry: (entry: FieldValue, roles?: Set<string> | null) => WhereEntry;
|
|
6
|
+
declare const parseWhere: (value: FieldValue | null | undefined, roles?: Set<string> | null) => WhereEntry[];
|
|
7
|
+
declare const matchesWhere: (entry: WhereEntry, rel: string, arch: Arch, facts: FileFacts, targetCaps?: Caps) => boolean;
|
|
8
|
+
declare const checkWhere: (entries: WhereEntry[], rel: string, arch: Arch, facts: FileFacts, targetCaps?: Caps) => boolean;
|
|
9
|
+
declare const accessorLabel: (e: {
|
|
10
|
+
scope?: string | null;
|
|
11
|
+
segments?: string[] | null;
|
|
12
|
+
} | null | undefined) => string;
|
|
13
|
+
declare const labelOf: (entry: WhereEntry | null | undefined) => string;
|
|
14
|
+
declare const fillTemplate: (template: string | null | undefined, rel?: string | null, caps?: Caps | null) => string | null;
|
|
15
|
+
declare const entryKey: (entry: WhereEntry, rel: string, arch: Arch, facts: FileFacts | null | undefined) => string | null;
|
|
16
|
+
export { toList, parseWhereEntry, parseWhere, matchesWhere, checkWhere, accessorLabel, labelOf, fillTemplate, entryKey };
|
|
17
|
+
export type { Caps };
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.entryKey = exports.fillTemplate = exports.labelOf = exports.accessorLabel = exports.checkWhere = exports.matchesWhere = exports.parseWhere = exports.parseWhereEntry = exports.toList = void 0;
|
|
4
|
+
// THE `where` GRAMMAR — one implementation of "here" / "by this code", shared by
|
|
5
|
+
// node `role:` homes, codeRole actions and invariant `where`/`except`.
|
|
6
|
+
//
|
|
7
|
+
// An entry is one of:
|
|
8
|
+
// { role } code that IS that role (its file declares it)
|
|
9
|
+
// { role, same } …and in the SAME node instance as the target
|
|
10
|
+
// { node } any file under that declared node
|
|
11
|
+
// { template } a path built from the tree (role homes)
|
|
12
|
+
// "glob" a path pattern
|
|
13
|
+
// { <filter> } any filter over the file's facts
|
|
14
|
+
const pattern_1 = require("../../utils/pattern");
|
|
15
|
+
const match_1 = require("../tree/match");
|
|
16
|
+
const queries_1 = require("../queries");
|
|
17
|
+
const place_1 = require("./place");
|
|
18
|
+
const field_1 = require("../../utils/field");
|
|
19
|
+
Object.defineProperty(exports, "toList", { enumerable: true, get: function () { return field_1.toList; } });
|
|
20
|
+
const queryMatcher = () => queries_1.matches;
|
|
21
|
+
const readObjEntry = (entry) => {
|
|
22
|
+
if (entry.role != null)
|
|
23
|
+
return { type: "role", role: String(entry.role), same: Boolean(entry.same), via: entry.via === "import" ? "import" : null };
|
|
24
|
+
if (entry.node != null)
|
|
25
|
+
return { type: "node", node: String(entry.node) };
|
|
26
|
+
if (entry.template != null)
|
|
27
|
+
return { type: "template", template: String(entry.template) };
|
|
28
|
+
return { type: "query", query: entry };
|
|
29
|
+
};
|
|
30
|
+
// Normalize one entry. `roles` (a Set of declared slugs) lets a bare string that
|
|
31
|
+
// names a role become a role reference; without it every string is a glob.
|
|
32
|
+
const parseWhereEntry = (entry, roles = null) => {
|
|
33
|
+
if (typeof entry === "string")
|
|
34
|
+
return roles?.has(entry) && !entry.includes("/") && !entry.includes("*") ? { type: "role", role: entry, same: false } : { type: "glob", glob: entry };
|
|
35
|
+
if (!(0, queries_1.isObj)(entry))
|
|
36
|
+
return { type: "query", query: entry };
|
|
37
|
+
return readObjEntry(entry);
|
|
38
|
+
};
|
|
39
|
+
exports.parseWhereEntry = parseWhereEntry;
|
|
40
|
+
const parseWhere = (value, roles = null) => (0, field_1.toList)(value).map((e) => parseWhereEntry(e, roles));
|
|
41
|
+
exports.parseWhere = parseWhere;
|
|
42
|
+
const patternOf = (entry) => {
|
|
43
|
+
if (entry.type === "glob")
|
|
44
|
+
return entry.glob ?? null;
|
|
45
|
+
if (entry.type === "template")
|
|
46
|
+
return entry.template ?? null;
|
|
47
|
+
return null;
|
|
48
|
+
};
|
|
49
|
+
// Does the path match the pattern, and do its captures agree with the target's?
|
|
50
|
+
const capsAgree = (pattern, rel, targetCaps) => {
|
|
51
|
+
const { re, names } = (0, pattern_1.compilePattern)(pattern);
|
|
52
|
+
const m = re.exec(rel);
|
|
53
|
+
if (!m)
|
|
54
|
+
return false;
|
|
55
|
+
if (!targetCaps)
|
|
56
|
+
return true;
|
|
57
|
+
for (let i = 0; i < names.length; i += 1) {
|
|
58
|
+
if (names[i] in targetCaps && m[i + 1] !== targetCaps[names[i]])
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
return true;
|
|
62
|
+
};
|
|
63
|
+
const sameCaps = (source, target) => {
|
|
64
|
+
for (const [name, value] of Object.entries(target ?? {})) {
|
|
65
|
+
if (!(name in source) || source[name] !== value)
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
return true;
|
|
69
|
+
};
|
|
70
|
+
// `{ role }` — the file declares that role, and (for `same`) in the SAME node.
|
|
71
|
+
const matchesRole = (...args) => {
|
|
72
|
+
const [entry, rel, arch, facts, targetCaps] = args;
|
|
73
|
+
if (!(facts?.roles ?? []).includes(entry.role ?? ""))
|
|
74
|
+
return false;
|
|
75
|
+
if (!entry.same)
|
|
76
|
+
return true;
|
|
77
|
+
const nodeM = (0, match_1.deepestMatch)(rel, arch);
|
|
78
|
+
return sameCaps(nodeM ? (0, match_1.matchNode)(nodeM.node, rel)?.caps ?? {} : {}, targetCaps);
|
|
79
|
+
};
|
|
80
|
+
// `{ node }` — the path is inside that declared node.
|
|
81
|
+
const matchesNodeEntry = (entry, rel, arch) => {
|
|
82
|
+
const node = arch.nodes.bySlug[entry.node ?? ""];
|
|
83
|
+
if (!node)
|
|
84
|
+
return false;
|
|
85
|
+
return node.variants.some((v) => v.re.test(rel));
|
|
86
|
+
};
|
|
87
|
+
// Does this entry designate `rel` for a file with these facts?
|
|
88
|
+
const matchesWhere = (...args) => {
|
|
89
|
+
const [entry, rel, arch, facts, targetCaps = null] = args;
|
|
90
|
+
if (!entry)
|
|
91
|
+
return false;
|
|
92
|
+
const pattern = patternOf(entry);
|
|
93
|
+
if (pattern != null)
|
|
94
|
+
return capsAgree(pattern, rel, targetCaps);
|
|
95
|
+
if (entry.type === "role")
|
|
96
|
+
return matchesRole(entry, rel, arch, facts, targetCaps);
|
|
97
|
+
if (entry.type === "node")
|
|
98
|
+
return matchesNodeEntry(entry, rel, arch);
|
|
99
|
+
// The scope IS the facts (plus the file and the tree), so a `$ref` can compare
|
|
100
|
+
// one fact with another.
|
|
101
|
+
return queryMatcher()(facts ?? {}, entry.query, { ...(facts ?? {}), arch, fileRel: rel });
|
|
102
|
+
};
|
|
103
|
+
exports.matchesWhere = matchesWhere;
|
|
104
|
+
// `true` when NO entry allows it.
|
|
105
|
+
const checkWhere = (...args) => {
|
|
106
|
+
const [entries, rel, arch, facts, targetCaps = null] = args;
|
|
107
|
+
for (const entry of entries ?? [])
|
|
108
|
+
if (matchesWhere(entry, rel, arch, facts, targetCaps))
|
|
109
|
+
return false;
|
|
110
|
+
return true;
|
|
111
|
+
};
|
|
112
|
+
exports.checkWhere = checkWhere;
|
|
113
|
+
// How code is reached through a declared accessor without an import.
|
|
114
|
+
const accessorLabel = (e) => (e?.scope === "function" || e?.scope === "method" ? `${(e.segments ?? []).join(".")}(…)` : (e?.segments ?? []).join("."));
|
|
115
|
+
exports.accessorLabel = accessorLabel;
|
|
116
|
+
const kindOf = (entry) => {
|
|
117
|
+
if (entry.type)
|
|
118
|
+
return entry.type;
|
|
119
|
+
if (entry.role)
|
|
120
|
+
return "role";
|
|
121
|
+
if (entry.node)
|
|
122
|
+
return "node";
|
|
123
|
+
if (entry.glob)
|
|
124
|
+
return "glob";
|
|
125
|
+
if (entry.template)
|
|
126
|
+
return "template";
|
|
127
|
+
return null;
|
|
128
|
+
};
|
|
129
|
+
const orText = (value, fallback) => value ?? fallback;
|
|
130
|
+
const roleLabel = (entry) => `role ${orText(entry.role, "")}${entry.same ? " (same instance)" : ""}`;
|
|
131
|
+
// How one `where` entry reads inside a sentence — the ONE place that knows the
|
|
132
|
+
// entry vocabulary.
|
|
133
|
+
const labelOf = (entry) => {
|
|
134
|
+
if (!entry)
|
|
135
|
+
return "—";
|
|
136
|
+
const kind = kindOf(entry);
|
|
137
|
+
if (kind === "role")
|
|
138
|
+
return roleLabel(entry);
|
|
139
|
+
if (kind === "node")
|
|
140
|
+
return `node ${orText(entry.node, "")}`;
|
|
141
|
+
if (kind === "glob")
|
|
142
|
+
return orText(entry.glob, "—");
|
|
143
|
+
if (kind === "template")
|
|
144
|
+
return orText(entry.template, "—");
|
|
145
|
+
return "filter";
|
|
146
|
+
};
|
|
147
|
+
exports.labelOf = labelOf;
|
|
148
|
+
const placeholderName = (seg) => /^\{([^}]+)\}$/.exec(seg)?.[1] ?? null;
|
|
149
|
+
const tailOf = (seg) => /\{[^}]+\}([^{]*)$/.exec(seg)?.[1] ?? null;
|
|
150
|
+
const lastOf = (relSegs) => relSegs[relSegs.length - 1];
|
|
151
|
+
// A segment that is a placeholder PLUS a fixed tail (`{kebab-case}.ts`).
|
|
152
|
+
const resolveTail = (seg, relSegs, tail) => {
|
|
153
|
+
const own = lastOf(relSegs);
|
|
154
|
+
return own && own !== seg && own.endsWith(tail) ? own : seg;
|
|
155
|
+
};
|
|
156
|
+
// A glob segment (`*.d.ts`) names a FAMILY; the destination is this file's own
|
|
157
|
+
// name in that family.
|
|
158
|
+
const resolveGlob = (seg, relSegs) => {
|
|
159
|
+
const own = lastOf(relSegs);
|
|
160
|
+
const suffix = seg.slice(seg.indexOf("*") + 1);
|
|
161
|
+
const stem = own ? own.replace(/\.[^.]*$/, "") : null;
|
|
162
|
+
return stem ? `${stem}${suffix}` : seg;
|
|
163
|
+
};
|
|
164
|
+
// One template segment resolved against the file's own path.
|
|
165
|
+
const resolveSegment = (seg, i, relSegs, caps) => {
|
|
166
|
+
const whole = placeholderName(seg);
|
|
167
|
+
if (whole != null) {
|
|
168
|
+
const filled = caps?.[whole];
|
|
169
|
+
if (filled != null)
|
|
170
|
+
return filled;
|
|
171
|
+
return relSegs[i] ?? seg;
|
|
172
|
+
}
|
|
173
|
+
const tail = tailOf(seg);
|
|
174
|
+
if (tail != null)
|
|
175
|
+
return resolveTail(seg, relSegs, tail);
|
|
176
|
+
if (seg.includes("*"))
|
|
177
|
+
return resolveGlob(seg, relSegs);
|
|
178
|
+
return seg;
|
|
179
|
+
};
|
|
180
|
+
// A declared template resolved to a concrete path. ONE implementation, used by
|
|
181
|
+
// every caller that needs "where does this template point for THIS file".
|
|
182
|
+
const fillTemplate = (template, rel = null, caps = null) => {
|
|
183
|
+
if (template == null)
|
|
184
|
+
return null;
|
|
185
|
+
const segs = String(template).split("/");
|
|
186
|
+
const relSegs = String(rel ?? "").split("/").filter(Boolean);
|
|
187
|
+
const out = [];
|
|
188
|
+
for (let i = 0; i < segs.length; i += 1) {
|
|
189
|
+
const seg = segs[i];
|
|
190
|
+
if (seg === "**")
|
|
191
|
+
break;
|
|
192
|
+
out.push(resolveSegment(seg, i, relSegs, caps));
|
|
193
|
+
}
|
|
194
|
+
return out.join("/") || (0, place_1.dirOf)(rel);
|
|
195
|
+
};
|
|
196
|
+
exports.fillTemplate = fillTemplate;
|
|
197
|
+
const templateOf = (entry, arch) => {
|
|
198
|
+
if (entry.type === "node")
|
|
199
|
+
return arch.nodes.bySlug[entry.node ?? ""]?.path ?? null;
|
|
200
|
+
return entry.template ?? entry.glob ?? null;
|
|
201
|
+
};
|
|
202
|
+
// The concrete PLACE an entry designates for this file.
|
|
203
|
+
const entryKey = (entry, rel, arch, facts) => {
|
|
204
|
+
if (!matchesWhere(entry, rel, arch, facts ?? null, null))
|
|
205
|
+
return null;
|
|
206
|
+
const fileDir = (0, place_1.dirOf)(rel);
|
|
207
|
+
const template = templateOf(entry, arch);
|
|
208
|
+
const filled = fillTemplate(template, rel);
|
|
209
|
+
if (filled == null)
|
|
210
|
+
return fileDir;
|
|
211
|
+
// A template that names a FAMILY (`…/actions/*.ts`) designates the folder the
|
|
212
|
+
// family lives in.
|
|
213
|
+
const star = String(template).split("/").findIndex((s) => s.includes("*"));
|
|
214
|
+
if (star === -1)
|
|
215
|
+
return filled;
|
|
216
|
+
return filled.split("/").slice(0, star).join("/") || fileDir;
|
|
217
|
+
};
|
|
218
|
+
exports.entryKey = entryKey;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FieldValue } from "../utils/field";
|
|
2
|
+
import type { Arch, QueryScope, WhereEntry } from "./architecture";
|
|
3
|
+
type AsFilter = (loc: FieldValue, entry: FieldValue) => boolean;
|
|
4
|
+
declare const matchesLocation: (value: FieldValue, entry: FieldValue, scope?: QueryScope, asFilter?: AsFilter | null) => boolean;
|
|
5
|
+
type Resolved = {
|
|
6
|
+
node: string | null;
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
9
|
+
declare const resolveLocation: (arch: Arch, location: WhereEntry | string | (WhereEntry | string)[] | null | undefined, rel: string) => Resolved | null;
|
|
10
|
+
declare const boxOfPlace: (arch: Arch, path: string | null | undefined) => string | null;
|
|
11
|
+
export { matchesLocation, resolveLocation, boxOfPlace };
|
|
12
|
+
export { wordsIn, nameOnly, segmentsOf, parentOf, leafOf, placeOf, placeholdersOf, dirOf } from "./location/place";
|
|
13
|
+
export { toList, parseWhereEntry, parseWhere, matchesWhere, checkWhere, accessorLabel, labelOf, fillTemplate, entryKey } from "./location/where";
|
|
14
|
+
export { homesOf, sharedPrefix, destinationsIn, destinationOf, placeFor, roleFitsAt, rolesAtPath, homeForRole } from "./location/homes";
|
|
15
|
+
export type { Resolved };
|
|
16
|
+
export type { Caps } from "./location/where";
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.homeForRole = exports.rolesAtPath = exports.roleFitsAt = exports.placeFor = exports.destinationOf = exports.destinationsIn = exports.sharedPrefix = exports.homesOf = exports.entryKey = exports.fillTemplate = exports.labelOf = exports.accessorLabel = exports.checkWhere = exports.matchesWhere = exports.parseWhere = exports.parseWhereEntry = exports.toList = exports.dirOf = exports.placeholdersOf = exports.placeOf = exports.leafOf = exports.parentOf = exports.segmentsOf = exports.nameOnly = exports.wordsIn = exports.boxOfPlace = exports.resolveLocation = exports.matchesLocation = void 0;
|
|
4
|
+
// WHERE a piece of code is, and WHERE a rule points — one vocabulary, one
|
|
5
|
+
// implementation, used by both sides:
|
|
6
|
+
//
|
|
7
|
+
// • `matchesLocation(value, entry, { arch }, asFilter)` — the `location:`
|
|
8
|
+
// FILTER: "is this candidate / file / edge at that place?" (`"glob"`,
|
|
9
|
+
// `{ node }`, `{ role }`, or a query over the location itself).
|
|
10
|
+
// • `resolveLocation(arch, location, rel)` — the `fix.location` of a REPAIR:
|
|
11
|
+
// the place AND the box it is, for this file, asked of the tree.
|
|
12
|
+
//
|
|
13
|
+
// This module owns the filter and the repair resolution; the three halves of the
|
|
14
|
+
// "where" vocabulary live in sibling modules and are re-exported here, so every
|
|
15
|
+
// consumer keeps importing `entities/location`:
|
|
16
|
+
// • `./location/place` — ONE PATH, cut into its parts;
|
|
17
|
+
// • `./location/where` — the `where` grammar (roles / nodes / globs / filters);
|
|
18
|
+
// • `./location/homes` — the role → place answer.
|
|
19
|
+
const pattern_1 = require("../utils/pattern");
|
|
20
|
+
const tree_1 = require("./tree");
|
|
21
|
+
const queries_1 = require("./queries");
|
|
22
|
+
const place_1 = require("./location/place");
|
|
23
|
+
const homes_1 = require("./location/homes");
|
|
24
|
+
// The place a value names: a candidate's `location`, a file fact, or a bare path.
|
|
25
|
+
const locationOf = (value) => ((0, queries_1.isObj)(value) && value.location != null ? value.location : value);
|
|
26
|
+
const pathOf = (loc) => {
|
|
27
|
+
if (typeof loc === "string")
|
|
28
|
+
return loc;
|
|
29
|
+
if ((0, queries_1.isObj)(loc) && typeof loc.path === "string")
|
|
30
|
+
return loc.path;
|
|
31
|
+
return null;
|
|
32
|
+
};
|
|
33
|
+
// The `arch` carried in a scope: a plain-data record may hold anything readable,
|
|
34
|
+
// but `arch` is the built model (compiled regexes), so it is recognised apart.
|
|
35
|
+
const isArch = (v) => v != null && typeof v === "object" && "nodes" in v && "codeRoles" in v;
|
|
36
|
+
const isScopeRecord = (scope) => scope !== null && scope !== undefined && typeof scope === "object" && !Array.isArray(scope);
|
|
37
|
+
const archOf = (scope) => {
|
|
38
|
+
if (!isScopeRecord(scope))
|
|
39
|
+
return null;
|
|
40
|
+
const a = scope.arch;
|
|
41
|
+
return isArch(a) ? a : null;
|
|
42
|
+
};
|
|
43
|
+
const pathInNode = (arch, nodeSlug, itemPath) => {
|
|
44
|
+
const node = arch?.nodes.bySlug[nodeSlug];
|
|
45
|
+
if (!node)
|
|
46
|
+
return false;
|
|
47
|
+
return node.variants.some((v) => v.re.test(itemPath));
|
|
48
|
+
};
|
|
49
|
+
const pathInRole = (arch, role, itemPath) => (arch?.nodes.roleHomes[role] ?? []).some((h) => (0, pattern_1.compilePattern)(h.template).re.test(itemPath));
|
|
50
|
+
// The `location:` filter. `value` is a candidate, a file fact, an edge or a bare
|
|
51
|
+
// path — they all answer the same question.
|
|
52
|
+
const matchesLocation = (value, entry, scope = {}, asFilter = null) => {
|
|
53
|
+
const arch = archOf(scope);
|
|
54
|
+
const loc = locationOf(value);
|
|
55
|
+
const itemPath = pathOf(loc);
|
|
56
|
+
if (itemPath == null)
|
|
57
|
+
return false;
|
|
58
|
+
// A glob: the plainest statement of a place.
|
|
59
|
+
if (typeof entry === "string")
|
|
60
|
+
return (0, pattern_1.compilePattern)(entry).re.test(itemPath);
|
|
61
|
+
// `{ node: "slug" }` — the path is inside that node.
|
|
62
|
+
if ((0, queries_1.isObj)(entry) && typeof entry.node === "string")
|
|
63
|
+
return pathInNode(arch, entry.node, itemPath);
|
|
64
|
+
// `{ role }` — the path is one of the places that role is declared to live in.
|
|
65
|
+
if ((0, queries_1.isObj)(entry) && typeof entry.role === "string")
|
|
66
|
+
return pathInRole(arch, entry.role, itemPath);
|
|
67
|
+
// A query over the location itself: `{ piece: { isNull: true } }`.
|
|
68
|
+
return asFilter ? asFilter(loc, entry) : true;
|
|
69
|
+
};
|
|
70
|
+
exports.matchesLocation = matchesLocation;
|
|
71
|
+
const resolveRole = (arch, role, rel) => {
|
|
72
|
+
const hit = (0, homes_1.homeForRole)(arch, role, rel);
|
|
73
|
+
return hit?.node ? { node: hit.node, path: hit.path } : null;
|
|
74
|
+
};
|
|
75
|
+
const resolveNode = (arch, nodeSlug, rel) => {
|
|
76
|
+
const home = (0, homes_1.placeFor)(arch, nodeSlug, rel);
|
|
77
|
+
if (home?.path)
|
|
78
|
+
return { node: (0, tree_1.folderOwner)(arch, home.folder ? home.path : (0, place_1.dirOf)(home.path))?.slug ?? nodeSlug, path: home.path };
|
|
79
|
+
const own = arch.nodes.bySlug[nodeSlug]?.path;
|
|
80
|
+
return own ? { node: nodeSlug, path: own } : null;
|
|
81
|
+
};
|
|
82
|
+
// A location entry of a REPAIR → the place and the box, or null.
|
|
83
|
+
const resolveOne = (arch, entry, rel) => {
|
|
84
|
+
if (!entry)
|
|
85
|
+
return null;
|
|
86
|
+
if (typeof entry === "string")
|
|
87
|
+
return { path: entry, node: (0, tree_1.folderOwner)(arch, (0, place_1.dirOf)(entry))?.slug ?? null };
|
|
88
|
+
if (entry.role)
|
|
89
|
+
return resolveRole(arch, entry.role, rel);
|
|
90
|
+
if (entry.node)
|
|
91
|
+
return resolveNode(arch, entry.node, rel);
|
|
92
|
+
return null;
|
|
93
|
+
};
|
|
94
|
+
// A location may be ONE entry or a list of alternatives: the first the tree can
|
|
95
|
+
// answer for THIS file wins.
|
|
96
|
+
const resolveLocation = (arch, location, rel) => {
|
|
97
|
+
const list = Array.isArray(location) ? location : [location];
|
|
98
|
+
for (const entry of list) {
|
|
99
|
+
const hit = resolveOne(arch, entry, rel);
|
|
100
|
+
if (hit?.node)
|
|
101
|
+
return hit;
|
|
102
|
+
}
|
|
103
|
+
return null;
|
|
104
|
+
};
|
|
105
|
+
exports.resolveLocation = resolveLocation;
|
|
106
|
+
// The box that HOLDS a place: `a/b/c.ts` → the node that owns `a/b`.
|
|
107
|
+
const boxOfPlace = (arch, path) => {
|
|
108
|
+
if (!path)
|
|
109
|
+
return null;
|
|
110
|
+
return (0, tree_1.folderOwner)(arch, (0, place_1.dirOf)(path))?.slug ?? null;
|
|
111
|
+
};
|
|
112
|
+
exports.boxOfPlace = boxOfPlace;
|
|
113
|
+
var place_2 = require("./location/place");
|
|
114
|
+
Object.defineProperty(exports, "wordsIn", { enumerable: true, get: function () { return place_2.wordsIn; } });
|
|
115
|
+
Object.defineProperty(exports, "nameOnly", { enumerable: true, get: function () { return place_2.nameOnly; } });
|
|
116
|
+
Object.defineProperty(exports, "segmentsOf", { enumerable: true, get: function () { return place_2.segmentsOf; } });
|
|
117
|
+
Object.defineProperty(exports, "parentOf", { enumerable: true, get: function () { return place_2.parentOf; } });
|
|
118
|
+
Object.defineProperty(exports, "leafOf", { enumerable: true, get: function () { return place_2.leafOf; } });
|
|
119
|
+
Object.defineProperty(exports, "placeOf", { enumerable: true, get: function () { return place_2.placeOf; } });
|
|
120
|
+
Object.defineProperty(exports, "placeholdersOf", { enumerable: true, get: function () { return place_2.placeholdersOf; } });
|
|
121
|
+
Object.defineProperty(exports, "dirOf", { enumerable: true, get: function () { return place_2.dirOf; } });
|
|
122
|
+
var where_1 = require("./location/where");
|
|
123
|
+
Object.defineProperty(exports, "toList", { enumerable: true, get: function () { return where_1.toList; } });
|
|
124
|
+
Object.defineProperty(exports, "parseWhereEntry", { enumerable: true, get: function () { return where_1.parseWhereEntry; } });
|
|
125
|
+
Object.defineProperty(exports, "parseWhere", { enumerable: true, get: function () { return where_1.parseWhere; } });
|
|
126
|
+
Object.defineProperty(exports, "matchesWhere", { enumerable: true, get: function () { return where_1.matchesWhere; } });
|
|
127
|
+
Object.defineProperty(exports, "checkWhere", { enumerable: true, get: function () { return where_1.checkWhere; } });
|
|
128
|
+
Object.defineProperty(exports, "accessorLabel", { enumerable: true, get: function () { return where_1.accessorLabel; } });
|
|
129
|
+
Object.defineProperty(exports, "labelOf", { enumerable: true, get: function () { return where_1.labelOf; } });
|
|
130
|
+
Object.defineProperty(exports, "fillTemplate", { enumerable: true, get: function () { return where_1.fillTemplate; } });
|
|
131
|
+
Object.defineProperty(exports, "entryKey", { enumerable: true, get: function () { return where_1.entryKey; } });
|
|
132
|
+
var homes_2 = require("./location/homes");
|
|
133
|
+
Object.defineProperty(exports, "homesOf", { enumerable: true, get: function () { return homes_2.homesOf; } });
|
|
134
|
+
Object.defineProperty(exports, "sharedPrefix", { enumerable: true, get: function () { return homes_2.sharedPrefix; } });
|
|
135
|
+
Object.defineProperty(exports, "destinationsIn", { enumerable: true, get: function () { return homes_2.destinationsIn; } });
|
|
136
|
+
Object.defineProperty(exports, "destinationOf", { enumerable: true, get: function () { return homes_2.destinationOf; } });
|
|
137
|
+
Object.defineProperty(exports, "placeFor", { enumerable: true, get: function () { return homes_2.placeFor; } });
|
|
138
|
+
Object.defineProperty(exports, "roleFitsAt", { enumerable: true, get: function () { return homes_2.roleFitsAt; } });
|
|
139
|
+
Object.defineProperty(exports, "rolesAtPath", { enumerable: true, get: function () { return homes_2.rolesAtPath; } });
|
|
140
|
+
Object.defineProperty(exports, "homeForRole", { enumerable: true, get: function () { return homes_2.homeForRole; } });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const CONTAINERS: Set<string>;
|
|
2
|
+
declare const QUANTIFIERS: Set<string>;
|
|
3
|
+
declare const SCALAR_OPS: {
|
|
4
|
+
gt: string;
|
|
5
|
+
gte: string;
|
|
6
|
+
lt: string;
|
|
7
|
+
lte: string;
|
|
8
|
+
equals: string;
|
|
9
|
+
in: string;
|
|
10
|
+
not: string;
|
|
11
|
+
isSet: string;
|
|
12
|
+
matches: string;
|
|
13
|
+
};
|
|
14
|
+
export { CONTAINERS, QUANTIFIERS, SCALAR_OPS };
|