@transitrix/diagrams 1.0.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/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/__tests__/edge-path.test.d.ts +1 -0
- package/dist/__tests__/edge-path.test.js +39 -0
- package/dist/__tests__/scope.test.d.ts +1 -0
- package/dist/__tests__/scope.test.js +23 -0
- package/dist/__tests__/yaml-normalize.test.d.ts +1 -0
- package/dist/__tests__/yaml-normalize.test.js +148 -0
- package/dist/activities/__tests__/cpm.test.d.ts +1 -0
- package/dist/activities/__tests__/cpm.test.js +146 -0
- package/dist/activities/__tests__/gantt.test.d.ts +1 -0
- package/dist/activities/__tests__/gantt.test.js +224 -0
- package/dist/activities/__tests__/layout.test.d.ts +1 -0
- package/dist/activities/__tests__/layout.test.js +98 -0
- package/dist/activities/__tests__/validate.test.d.ts +1 -0
- package/dist/activities/__tests__/validate.test.js +363 -0
- package/dist/activities/cpm.d.ts +2 -0
- package/dist/activities/cpm.js +86 -0
- package/dist/activities/gantt.d.ts +6 -0
- package/dist/activities/gantt.js +250 -0
- package/dist/activities/index.d.ts +5 -0
- package/dist/activities/index.js +4 -0
- package/dist/activities/layout.d.ts +2 -0
- package/dist/activities/layout.js +103 -0
- package/dist/activities/types.d.ts +125 -0
- package/dist/activities/types.js +1 -0
- package/dist/activities/validate.d.ts +2 -0
- package/dist/activities/validate.js +326 -0
- package/dist/activity-card/__tests__/example.test.d.ts +1 -0
- package/dist/activity-card/__tests__/example.test.js +56 -0
- package/dist/activity-card/__tests__/layout.test.d.ts +1 -0
- package/dist/activity-card/__tests__/layout.test.js +57 -0
- package/dist/activity-card/__tests__/resolver.test.d.ts +1 -0
- package/dist/activity-card/__tests__/resolver.test.js +146 -0
- package/dist/activity-card/__tests__/validate.test.d.ts +1 -0
- package/dist/activity-card/__tests__/validate.test.js +116 -0
- package/dist/activity-card/index.d.ts +5 -0
- package/dist/activity-card/index.js +3 -0
- package/dist/activity-card/layout.d.ts +7 -0
- package/dist/activity-card/layout.js +167 -0
- package/dist/activity-card/resolver.d.ts +7 -0
- package/dist/activity-card/resolver.js +310 -0
- package/dist/activity-card/types.d.ts +175 -0
- package/dist/activity-card/types.js +20 -0
- package/dist/activity-card/validate.d.ts +3 -0
- package/dist/activity-card/validate.js +145 -0
- package/dist/actor/__tests__/validate.test.d.ts +1 -0
- package/dist/actor/__tests__/validate.test.js +57 -0
- package/dist/actor/index.d.ts +3 -0
- package/dist/actor/index.js +2 -0
- package/dist/actor/types.d.ts +20 -0
- package/dist/actor/types.js +4 -0
- package/dist/actor/validate.d.ts +2 -0
- package/dist/actor/validate.js +34 -0
- package/dist/applications/__tests__/validate.test.d.ts +1 -0
- package/dist/applications/__tests__/validate.test.js +223 -0
- package/dist/applications/index.d.ts +2 -0
- package/dist/applications/index.js +1 -0
- package/dist/applications/types.d.ts +39 -0
- package/dist/applications/types.js +1 -0
- package/dist/applications/validate.d.ts +3 -0
- package/dist/applications/validate.js +109 -0
- package/dist/assertion/__tests__/example.test.d.ts +1 -0
- package/dist/assertion/__tests__/example.test.js +32 -0
- package/dist/assertion/__tests__/validate.test.d.ts +1 -0
- package/dist/assertion/__tests__/validate.test.js +130 -0
- package/dist/assertion/index.d.ts +4 -0
- package/dist/assertion/index.js +2 -0
- package/dist/assertion/types.d.ts +43 -0
- package/dist/assertion/types.js +7 -0
- package/dist/assertion/validate.d.ts +9 -0
- package/dist/assertion/validate.js +137 -0
- package/dist/blocks/__tests__/layout.test.d.ts +1 -0
- package/dist/blocks/__tests__/layout.test.js +153 -0
- package/dist/blocks/__tests__/validate.test.d.ts +1 -0
- package/dist/blocks/__tests__/validate.test.js +235 -0
- package/dist/blocks/index.d.ts +4 -0
- package/dist/blocks/index.js +2 -0
- package/dist/blocks/layout.d.ts +4 -0
- package/dist/blocks/layout.js +145 -0
- package/dist/blocks/types.d.ts +56 -0
- package/dist/blocks/types.js +1 -0
- package/dist/blocks/validate.d.ts +9 -0
- package/dist/blocks/validate.js +186 -0
- package/dist/capability-map/__tests__/validate.test.d.ts +1 -0
- package/dist/capability-map/__tests__/validate.test.js +212 -0
- package/dist/capability-map/index.d.ts +2 -0
- package/dist/capability-map/index.js +1 -0
- package/dist/capability-map/types.d.ts +26 -0
- package/dist/capability-map/types.js +1 -0
- package/dist/capability-map/validate.d.ts +3 -0
- package/dist/capability-map/validate.js +103 -0
- package/dist/change/__tests__/validate.test.d.ts +1 -0
- package/dist/change/__tests__/validate.test.js +73 -0
- package/dist/change/index.d.ts +2 -0
- package/dist/change/index.js +1 -0
- package/dist/change/types.d.ts +17 -0
- package/dist/change/types.js +3 -0
- package/dist/change/validate.d.ts +2 -0
- package/dist/change/validate.js +57 -0
- package/dist/compliance/__tests__/classify.test.d.ts +1 -0
- package/dist/compliance/__tests__/classify.test.js +24 -0
- package/dist/compliance/__tests__/confidence.test.d.ts +1 -0
- package/dist/compliance/__tests__/confidence.test.js +78 -0
- package/dist/compliance/__tests__/coverage-metric.test.d.ts +1 -0
- package/dist/compliance/__tests__/coverage-metric.test.js +164 -0
- package/dist/compliance/__tests__/demo-scenario.test.d.ts +1 -0
- package/dist/compliance/__tests__/demo-scenario.test.js +226 -0
- package/dist/compliance/__tests__/example.test.d.ts +1 -0
- package/dist/compliance/__tests__/example.test.js +51 -0
- package/dist/compliance/__tests__/gap-report.test.d.ts +1 -0
- package/dist/compliance/__tests__/gap-report.test.js +113 -0
- package/dist/compliance/__tests__/html.test.d.ts +1 -0
- package/dist/compliance/__tests__/html.test.js +122 -0
- package/dist/compliance/__tests__/impact.test.d.ts +1 -0
- package/dist/compliance/__tests__/impact.test.js +410 -0
- package/dist/compliance/__tests__/markdown.test.d.ts +1 -0
- package/dist/compliance/__tests__/markdown.test.js +85 -0
- package/dist/compliance/__tests__/views.test.d.ts +1 -0
- package/dist/compliance/__tests__/views.test.js +59 -0
- package/dist/compliance/classify.d.ts +27 -0
- package/dist/compliance/classify.js +60 -0
- package/dist/compliance/confidence.d.ts +27 -0
- package/dist/compliance/confidence.js +43 -0
- package/dist/compliance/coverage-metric.d.ts +74 -0
- package/dist/compliance/coverage-metric.js +181 -0
- package/dist/compliance/gap-report.d.ts +20 -0
- package/dist/compliance/gap-report.js +64 -0
- package/dist/compliance/html.d.ts +22 -0
- package/dist/compliance/html.js +256 -0
- package/dist/compliance/impact.d.ts +251 -0
- package/dist/compliance/impact.js +464 -0
- package/dist/compliance/index.d.ts +16 -0
- package/dist/compliance/index.js +9 -0
- package/dist/compliance/markdown.d.ts +18 -0
- package/dist/compliance/markdown.js +129 -0
- package/dist/compliance/reverse-index.d.ts +8 -0
- package/dist/compliance/reverse-index.js +30 -0
- package/dist/compliance/types.d.ts +98 -0
- package/dist/compliance/types.js +5 -0
- package/dist/compliance/views.d.ts +14 -0
- package/dist/compliance/views.js +35 -0
- package/dist/compliance-matrix/__tests__/build.test.d.ts +1 -0
- package/dist/compliance-matrix/__tests__/build.test.js +183 -0
- package/dist/compliance-matrix/__tests__/example.test.d.ts +1 -0
- package/dist/compliance-matrix/__tests__/example.test.js +49 -0
- package/dist/compliance-matrix/build.d.ts +18 -0
- package/dist/compliance-matrix/build.js +0 -0
- package/dist/compliance-matrix/index.d.ts +2 -0
- package/dist/compliance-matrix/index.js +1 -0
- package/dist/compliance-matrix/types.d.ts +86 -0
- package/dist/compliance-matrix/types.js +8 -0
- package/dist/confidence/__tests__/score.test.d.ts +1 -0
- package/dist/confidence/__tests__/score.test.js +188 -0
- package/dist/confidence/index.d.ts +2 -0
- package/dist/confidence/index.js +1 -0
- package/dist/confidence/score.d.ts +62 -0
- package/dist/confidence/score.js +215 -0
- package/dist/confidence/types.d.ts +79 -0
- package/dist/confidence/types.js +6 -0
- package/dist/edge-path.d.ts +18 -0
- package/dist/edge-path.js +35 -0
- package/dist/element-envelope.d.ts +15 -0
- package/dist/element-envelope.js +55 -0
- package/dist/factor/__tests__/validate.test.d.ts +1 -0
- package/dist/factor/__tests__/validate.test.js +83 -0
- package/dist/factor/index.d.ts +3 -0
- package/dist/factor/index.js +2 -0
- package/dist/factor/types.d.ts +23 -0
- package/dist/factor/types.js +6 -0
- package/dist/factor/validate.d.ts +2 -0
- package/dist/factor/validate.js +69 -0
- package/dist/fgca/__tests__/chain-table.test.d.ts +1 -0
- package/dist/fgca/__tests__/chain-table.test.js +158 -0
- package/dist/fgca/__tests__/layout.test.d.ts +1 -0
- package/dist/fgca/__tests__/layout.test.js +140 -0
- package/dist/fgca/__tests__/parse-canonical.test.d.ts +1 -0
- package/dist/fgca/__tests__/parse-canonical.test.js +224 -0
- package/dist/fgca/__tests__/preview-layout.test.d.ts +1 -0
- package/dist/fgca/__tests__/preview-layout.test.js +106 -0
- package/dist/fgca/__tests__/validate.test.d.ts +1 -0
- package/dist/fgca/__tests__/validate.test.js +125 -0
- package/dist/fgca/chain-table.d.ts +36 -0
- package/dist/fgca/chain-table.js +177 -0
- package/dist/fgca/index.d.ts +16 -0
- package/dist/fgca/index.js +11 -0
- package/dist/fgca/layout.d.ts +27 -0
- package/dist/fgca/layout.js +156 -0
- package/dist/fgca/nodeTypes.d.ts +6 -0
- package/dist/fgca/nodeTypes.js +10 -0
- package/dist/fgca/nodes/FGCAActivityNode.d.ts +13 -0
- package/dist/fgca/nodes/FGCAActivityNode.js +35 -0
- package/dist/fgca/nodes/FGCAChangeNode.d.ts +12 -0
- package/dist/fgca/nodes/FGCAChangeNode.js +35 -0
- package/dist/fgca/nodes/FGCAFactorNode.d.ts +12 -0
- package/dist/fgca/nodes/FGCAFactorNode.js +35 -0
- package/dist/fgca/nodes/FGCAGoalNode.d.ts +14 -0
- package/dist/fgca/nodes/FGCAGoalNode.js +40 -0
- package/dist/fgca/parse-canonical.d.ts +58 -0
- package/dist/fgca/parse-canonical.js +339 -0
- package/dist/fgca/preview-layout.d.ts +87 -0
- package/dist/fgca/preview-layout.js +122 -0
- package/dist/fgca/types.d.ts +39 -0
- package/dist/fgca/types.js +7 -0
- package/dist/fgca/validate.d.ts +14 -0
- package/dist/fgca/validate.js +108 -0
- package/dist/geometry.d.ts +7 -0
- package/dist/geometry.js +2 -0
- package/dist/goals/__tests__/layout.test.d.ts +1 -0
- package/dist/goals/__tests__/layout.test.js +153 -0
- package/dist/goals/__tests__/mutations.test.d.ts +1 -0
- package/dist/goals/__tests__/mutations.test.js +95 -0
- package/dist/goals/__tests__/parse-canonical.test.d.ts +1 -0
- package/dist/goals/__tests__/parse-canonical.test.js +129 -0
- package/dist/goals/__tests__/validate.test.d.ts +1 -0
- package/dist/goals/__tests__/validate.test.js +183 -0
- package/dist/goals/index.d.ts +6 -0
- package/dist/goals/index.js +4 -0
- package/dist/goals/layout.d.ts +11 -0
- package/dist/goals/layout.js +147 -0
- package/dist/goals/mutations.d.ts +6 -0
- package/dist/goals/mutations.js +116 -0
- package/dist/goals/parse-canonical.d.ts +29 -0
- package/dist/goals/parse-canonical.js +257 -0
- package/dist/goals/types.d.ts +71 -0
- package/dist/goals/types.js +1 -0
- package/dist/goals/validate.d.ts +2 -0
- package/dist/goals/validate.js +122 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +23 -0
- package/dist/issues/__tests__/layout.test.d.ts +1 -0
- package/dist/issues/__tests__/layout.test.js +62 -0
- package/dist/issues/__tests__/validate.test.d.ts +1 -0
- package/dist/issues/__tests__/validate.test.js +82 -0
- package/dist/issues/index.d.ts +4 -0
- package/dist/issues/index.js +2 -0
- package/dist/issues/layout.d.ts +10 -0
- package/dist/issues/layout.js +82 -0
- package/dist/issues/types.d.ts +61 -0
- package/dist/issues/types.js +6 -0
- package/dist/issues/validate.d.ts +3 -0
- package/dist/issues/validate.js +143 -0
- package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +1 -0
- package/dist/process-blueprint/__tests__/compliance-lane.test.js +272 -0
- package/dist/process-blueprint/__tests__/layout.test.d.ts +1 -0
- package/dist/process-blueprint/__tests__/layout.test.js +159 -0
- package/dist/process-blueprint/__tests__/validate.test.d.ts +1 -0
- package/dist/process-blueprint/__tests__/validate.test.js +280 -0
- package/dist/process-blueprint/index.d.ts +4 -0
- package/dist/process-blueprint/index.js +2 -0
- package/dist/process-blueprint/layout.d.ts +2 -0
- package/dist/process-blueprint/layout.js +416 -0
- package/dist/process-blueprint/types.d.ts +220 -0
- package/dist/process-blueprint/types.js +1 -0
- package/dist/process-blueprint/validate.d.ts +3 -0
- package/dist/process-blueprint/validate.js +165 -0
- package/dist/process-map/__tests__/validate.test.d.ts +1 -0
- package/dist/process-map/__tests__/validate.test.js +199 -0
- package/dist/process-map/index.d.ts +2 -0
- package/dist/process-map/index.js +1 -0
- package/dist/process-map/types.d.ts +32 -0
- package/dist/process-map/types.js +1 -0
- package/dist/process-map/validate.d.ts +3 -0
- package/dist/process-map/validate.js +115 -0
- package/dist/products/__tests__/validate.test.d.ts +1 -0
- package/dist/products/__tests__/validate.test.js +210 -0
- package/dist/products/index.d.ts +2 -0
- package/dist/products/index.js +1 -0
- package/dist/products/types.d.ts +28 -0
- package/dist/products/types.js +1 -0
- package/dist/products/validate.d.ts +3 -0
- package/dist/products/validate.js +93 -0
- package/dist/repo-validate/__tests__/validate-repo.test.d.ts +1 -0
- package/dist/repo-validate/__tests__/validate-repo.test.js +132 -0
- package/dist/repo-validate/index.d.ts +2 -0
- package/dist/repo-validate/index.js +1 -0
- package/dist/repo-validate/types.d.ts +34 -0
- package/dist/repo-validate/types.js +14 -0
- package/dist/repo-validate/validate-repo.d.ts +8 -0
- package/dist/repo-validate/validate-repo.js +189 -0
- package/dist/requirement/__tests__/example.test.d.ts +1 -0
- package/dist/requirement/__tests__/example.test.js +21 -0
- package/dist/requirement/__tests__/validate.test.d.ts +1 -0
- package/dist/requirement/__tests__/validate.test.js +80 -0
- package/dist/requirement/index.d.ts +4 -0
- package/dist/requirement/index.js +2 -0
- package/dist/requirement/types.d.ts +25 -0
- package/dist/requirement/types.js +4 -0
- package/dist/requirement/validate.d.ts +7 -0
- package/dist/requirement/validate.js +81 -0
- package/dist/scenarios/__tests__/validate.test.d.ts +1 -0
- package/dist/scenarios/__tests__/validate.test.js +183 -0
- package/dist/scenarios/index.d.ts +2 -0
- package/dist/scenarios/index.js +1 -0
- package/dist/scenarios/types.d.ts +45 -0
- package/dist/scenarios/types.js +1 -0
- package/dist/scenarios/validate.d.ts +3 -0
- package/dist/scenarios/validate.js +110 -0
- package/dist/schema-version.d.ts +16 -0
- package/dist/schema-version.js +16 -0
- package/dist/scope.d.ts +23 -0
- package/dist/scope.js +38 -0
- package/dist/stakeholder/__tests__/validate.test.d.ts +1 -0
- package/dist/stakeholder/__tests__/validate.test.js +86 -0
- package/dist/stakeholder/index.d.ts +3 -0
- package/dist/stakeholder/index.js +2 -0
- package/dist/stakeholder/types.d.ts +24 -0
- package/dist/stakeholder/types.js +5 -0
- package/dist/stakeholder/validate.d.ts +2 -0
- package/dist/stakeholder/validate.js +58 -0
- package/dist/target-state/__tests__/validate.test.d.ts +1 -0
- package/dist/target-state/__tests__/validate.test.js +62 -0
- package/dist/target-state/index.d.ts +2 -0
- package/dist/target-state/index.js +1 -0
- package/dist/target-state/types.d.ts +18 -0
- package/dist/target-state/types.js +7 -0
- package/dist/target-state/validate.d.ts +2 -0
- package/dist/target-state/validate.js +61 -0
- package/dist/theme/index.d.ts +4 -0
- package/dist/theme/index.js +2 -0
- package/dist/theme/themes.d.ts +16 -0
- package/dist/theme/themes.js +213 -0
- package/dist/theme/tokens.d.ts +158 -0
- package/dist/theme/tokens.js +105 -0
- package/dist/typed-id.d.ts +20 -0
- package/dist/typed-id.js +38 -0
- package/dist/validation-types.d.ts +34 -0
- package/dist/validation-types.js +1 -0
- package/dist/webview/__tests__/entry-notations.test.d.ts +1 -0
- package/dist/webview/__tests__/entry-notations.test.js +62 -0
- package/dist/webview/__tests__/entry.test.d.ts +1 -0
- package/dist/webview/__tests__/entry.test.js +56 -0
- package/dist/webview/__tests__/render-goals.test.d.ts +1 -0
- package/dist/webview/__tests__/render-goals.test.js +65 -0
- package/dist/webview/entry.d.ts +38 -0
- package/dist/webview/entry.js +182 -0
- package/dist/webview/render-activities.d.ts +24 -0
- package/dist/webview/render-activities.js +127 -0
- package/dist/webview/render-activity-card.d.ts +5 -0
- package/dist/webview/render-activity-card.js +168 -0
- package/dist/webview/render-applications.d.ts +11 -0
- package/dist/webview/render-applications.js +105 -0
- package/dist/webview/render-blocks.d.ts +5 -0
- package/dist/webview/render-blocks.js +71 -0
- package/dist/webview/render-capability-map.d.ts +7 -0
- package/dist/webview/render-capability-map.js +88 -0
- package/dist/webview/render-fgca.d.ts +8 -0
- package/dist/webview/render-fgca.js +94 -0
- package/dist/webview/render-goals.d.ts +6 -0
- package/dist/webview/render-goals.js +92 -0
- package/dist/webview/render-process-blueprint.d.ts +5 -0
- package/dist/webview/render-process-blueprint.js +135 -0
- package/dist/webview/render-process-map.d.ts +7 -0
- package/dist/webview/render-process-map.js +82 -0
- package/dist/webview/render-products.d.ts +7 -0
- package/dist/webview/render-products.js +81 -0
- package/dist/webview/render-scenarios.d.ts +7 -0
- package/dist/webview/render-scenarios.js +75 -0
- package/dist/webview/render-util.d.ts +16 -0
- package/dist/webview/render-util.js +31 -0
- package/dist/webview/transitrix-render.css +323 -0
- package/dist/webview/transitrix-render.js +6452 -0
- package/dist/webview/transitrix-render.js.map +7 -0
- package/dist/yaml-normalize.d.ts +20 -0
- package/dist/yaml-normalize.js +57 -0
- package/package.json +40 -0
- package/src/__tests__/edge-path.test.ts +46 -0
- package/src/__tests__/scope.test.ts +27 -0
- package/src/__tests__/yaml-normalize.test.ts +158 -0
- package/src/activities/__tests__/cpm.test.ts +164 -0
- package/src/activities/__tests__/gantt.test.ts +245 -0
- package/src/activities/__tests__/layout.test.ts +112 -0
- package/src/activities/__tests__/validate.test.ts +409 -0
- package/src/activities/cpm.ts +95 -0
- package/src/activities/gantt.ts +276 -0
- package/src/activities/index.ts +28 -0
- package/src/activities/layout.ts +112 -0
- package/src/activities/types.ts +148 -0
- package/src/activities/validate.ts +357 -0
- package/src/activity-card/__tests__/example.test.ts +66 -0
- package/src/activity-card/__tests__/layout.test.ts +63 -0
- package/src/activity-card/__tests__/resolver.test.ts +161 -0
- package/src/activity-card/__tests__/validate.test.ts +131 -0
- package/src/activity-card/index.ts +32 -0
- package/src/activity-card/layout.ts +194 -0
- package/src/activity-card/resolver.ts +337 -0
- package/src/activity-card/types.ts +237 -0
- package/src/activity-card/validate.ts +158 -0
- package/src/actor/__tests__/validate.test.ts +67 -0
- package/src/actor/index.ts +3 -0
- package/src/actor/types.ts +29 -0
- package/src/actor/validate.ts +38 -0
- package/src/applications/__tests__/validate.test.ts +256 -0
- package/src/applications/index.ts +11 -0
- package/src/applications/types.ts +43 -0
- package/src/applications/validate.ts +131 -0
- package/src/assertion/__tests__/example.test.ts +37 -0
- package/src/assertion/__tests__/validate.test.ts +142 -0
- package/src/assertion/index.ts +12 -0
- package/src/assertion/types.ts +58 -0
- package/src/assertion/validate.ts +145 -0
- package/src/blocks/__tests__/layout.test.ts +169 -0
- package/src/blocks/__tests__/validate.test.ts +260 -0
- package/src/blocks/index.ts +17 -0
- package/src/blocks/layout.ts +186 -0
- package/src/blocks/types.ts +62 -0
- package/src/blocks/validate.ts +206 -0
- package/src/capability-map/__tests__/validate.test.ts +238 -0
- package/src/capability-map/index.ts +8 -0
- package/src/capability-map/types.ts +29 -0
- package/src/capability-map/validate.ts +127 -0
- package/src/change/__tests__/validate.test.ts +88 -0
- package/src/change/index.ts +2 -0
- package/src/change/types.ts +23 -0
- package/src/change/validate.ts +61 -0
- package/src/compliance/__tests__/classify.test.ts +27 -0
- package/src/compliance/__tests__/confidence.test.ts +98 -0
- package/src/compliance/__tests__/coverage-metric.test.ts +188 -0
- package/src/compliance/__tests__/demo-scenario.test.ts +273 -0
- package/src/compliance/__tests__/example.test.ts +57 -0
- package/src/compliance/__tests__/gap-report.test.ts +129 -0
- package/src/compliance/__tests__/html.test.ts +142 -0
- package/src/compliance/__tests__/impact.test.ts +482 -0
- package/src/compliance/__tests__/markdown.test.ts +95 -0
- package/src/compliance/__tests__/views.test.ts +64 -0
- package/src/compliance/classify.ts +84 -0
- package/src/compliance/confidence.ts +69 -0
- package/src/compliance/coverage-metric.ts +263 -0
- package/src/compliance/gap-report.ts +94 -0
- package/src/compliance/html.ts +295 -0
- package/src/compliance/impact.ts +677 -0
- package/src/compliance/index.ts +56 -0
- package/src/compliance/markdown.ts +135 -0
- package/src/compliance/reverse-index.ts +33 -0
- package/src/compliance/types.ts +120 -0
- package/src/compliance/views.ts +46 -0
- package/src/compliance-matrix/__tests__/build.test.ts +200 -0
- package/src/compliance-matrix/__tests__/example.test.ts +57 -0
- package/src/compliance-matrix/build.ts +0 -0
- package/src/compliance-matrix/index.ts +11 -0
- package/src/compliance-matrix/types.ts +102 -0
- package/src/confidence/__tests__/score.test.ts +254 -0
- package/src/confidence/index.ts +21 -0
- package/src/confidence/score.ts +243 -0
- package/src/confidence/types.ts +96 -0
- package/src/edge-path.ts +44 -0
- package/src/element-envelope.ts +76 -0
- package/src/factor/__tests__/validate.test.ts +98 -0
- package/src/factor/index.ts +8 -0
- package/src/factor/types.ts +41 -0
- package/src/factor/validate.ts +74 -0
- package/src/fgca/__tests__/chain-table.test.ts +172 -0
- package/src/fgca/__tests__/layout.test.ts +179 -0
- package/src/fgca/__tests__/parse-canonical.test.ts +248 -0
- package/src/fgca/__tests__/preview-layout.test.ts +124 -0
- package/src/fgca/__tests__/validate.test.ts +142 -0
- package/src/fgca/chain-table.ts +225 -0
- package/src/fgca/index.ts +45 -0
- package/src/fgca/layout.ts +204 -0
- package/src/fgca/nodeTypes.ts +11 -0
- package/src/fgca/nodes/FGCAActivityNode.tsx +65 -0
- package/src/fgca/nodes/FGCAChangeNode.tsx +64 -0
- package/src/fgca/nodes/FGCAFactorNode.tsx +64 -0
- package/src/fgca/nodes/FGCAGoalNode.tsx +72 -0
- package/src/fgca/parse-canonical.ts +400 -0
- package/src/fgca/preview-layout.ts +217 -0
- package/src/fgca/types.ts +50 -0
- package/src/fgca/validate.ts +126 -0
- package/src/geometry.ts +9 -0
- package/src/goals/__tests__/layout.test.ts +175 -0
- package/src/goals/__tests__/mutations.test.ts +111 -0
- package/src/goals/__tests__/parse-canonical.test.ts +145 -0
- package/src/goals/__tests__/validate.test.ts +202 -0
- package/src/goals/index.ts +21 -0
- package/src/goals/layout.ts +172 -0
- package/src/goals/mutations.ts +123 -0
- package/src/goals/parse-canonical.ts +286 -0
- package/src/goals/types.ts +85 -0
- package/src/goals/validate.ts +136 -0
- package/src/index.ts +23 -0
- package/src/process-blueprint/__tests__/compliance-lane.test.ts +320 -0
- package/src/process-blueprint/__tests__/layout.test.ts +195 -0
- package/src/process-blueprint/__tests__/validate.test.ts +310 -0
- package/src/process-blueprint/index.ts +31 -0
- package/src/process-blueprint/layout.ts +531 -0
- package/src/process-blueprint/types.ts +242 -0
- package/src/process-blueprint/validate.ts +181 -0
- package/src/process-map/__tests__/validate.test.ts +223 -0
- package/src/process-map/index.ts +10 -0
- package/src/process-map/types.ts +36 -0
- package/src/process-map/validate.ts +135 -0
- package/src/products/__tests__/validate.test.ts +239 -0
- package/src/products/index.ts +9 -0
- package/src/products/types.ts +31 -0
- package/src/products/validate.ts +112 -0
- package/src/repo-validate/__tests__/validate-repo.test.ts +149 -0
- package/src/repo-validate/index.ts +2 -0
- package/src/repo-validate/types.ts +50 -0
- package/src/repo-validate/validate-repo.ts +196 -0
- package/src/requirement/__tests__/example.test.ts +24 -0
- package/src/requirement/__tests__/validate.test.ts +96 -0
- package/src/requirement/index.ts +4 -0
- package/src/requirement/types.ts +35 -0
- package/src/requirement/validate.ts +92 -0
- package/src/scenarios/__tests__/validate.test.ts +209 -0
- package/src/scenarios/index.ts +15 -0
- package/src/scenarios/types.ts +37 -0
- package/src/scenarios/validate.ts +122 -0
- package/src/schema-version.ts +16 -0
- package/src/scope.ts +46 -0
- package/src/stakeholder/__tests__/validate.test.ts +101 -0
- package/src/stakeholder/index.ts +3 -0
- package/src/stakeholder/types.ts +33 -0
- package/src/stakeholder/validate.ts +63 -0
- package/src/target-state/__tests__/validate.test.ts +74 -0
- package/src/target-state/index.ts +2 -0
- package/src/target-state/types.ts +28 -0
- package/src/target-state/validate.ts +67 -0
- package/src/theme/index.ts +4 -0
- package/src/theme/themes.ts +237 -0
- package/src/theme/tokens.ts +133 -0
- package/src/typed-id.ts +56 -0
- package/src/validation-types.ts +36 -0
- package/src/webview/__tests__/entry-notations.test.ts +77 -0
- package/src/webview/__tests__/entry.test.ts +64 -0
- package/src/webview/__tests__/render-goals.test.ts +72 -0
- package/src/webview/entry.ts +292 -0
- package/src/webview/render-activities.ts +156 -0
- package/src/webview/render-activity-card.ts +234 -0
- package/src/webview/render-applications.ts +123 -0
- package/src/webview/render-blocks.ts +91 -0
- package/src/webview/render-capability-map.ts +98 -0
- package/src/webview/render-fgca.ts +122 -0
- package/src/webview/render-goals.ts +110 -0
- package/src/webview/render-process-blueprint.ts +207 -0
- package/src/webview/render-process-map.ts +93 -0
- package/src/webview/render-products.ts +91 -0
- package/src/webview/render-scenarios.ts +90 -0
- package/src/webview/render-util.ts +34 -0
- package/src/webview/styles.css +323 -0
- package/src/yaml-normalize.ts +56 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { validateGoalTree } from '../validate.js';
|
|
3
|
+
const VALID_TREE = {
|
|
4
|
+
goal_types: [
|
|
5
|
+
{ name: 'Strategy', level: 0 },
|
|
6
|
+
{ name: 'Business Goal', level: 1 },
|
|
7
|
+
{ name: 'Project', level: 2 },
|
|
8
|
+
],
|
|
9
|
+
goals: [
|
|
10
|
+
{ id: 1, name: 'Triple revenue', type: 'Strategy', level: 0, parent_id: 0 },
|
|
11
|
+
{ id: 2, name: 'Launch EU', type: 'Business Goal', level: 1, parent_id: 1 },
|
|
12
|
+
{ id: 3, name: 'Open Berlin office', type: 'Project', level: 2, parent_id: 2 },
|
|
13
|
+
],
|
|
14
|
+
};
|
|
15
|
+
describe('validateGoalTree', () => {
|
|
16
|
+
it('passes on valid input', () => {
|
|
17
|
+
const r = validateGoalTree(VALID_TREE);
|
|
18
|
+
expect(r.valid).toBe(true);
|
|
19
|
+
expect(r.errors).toHaveLength(0);
|
|
20
|
+
});
|
|
21
|
+
it('SCHEMA_INVALID: rejects non-object', () => {
|
|
22
|
+
expect(validateGoalTree(null).valid).toBe(false);
|
|
23
|
+
expect(validateGoalTree('string').errors[0].code).toBe('SCHEMA_INVALID');
|
|
24
|
+
});
|
|
25
|
+
it('SCHEMA_INVALID: rejects missing goals array', () => {
|
|
26
|
+
const r = validateGoalTree({ goal_types: [] });
|
|
27
|
+
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
28
|
+
});
|
|
29
|
+
it('DUPLICATE_ID: detects duplicate goal ids', () => {
|
|
30
|
+
const tree = {
|
|
31
|
+
...VALID_TREE,
|
|
32
|
+
goals: [
|
|
33
|
+
{ id: 1, name: 'A', type: 'Strategy', level: 0, parent_id: 0 },
|
|
34
|
+
{ id: 1, name: 'B', type: 'Strategy', level: 0, parent_id: 0 },
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
const r = validateGoalTree(tree);
|
|
38
|
+
expect(r.errors.some(e => e.code === 'DUPLICATE_ID')).toBe(true);
|
|
39
|
+
});
|
|
40
|
+
it('EMPTY_NAME: detects empty name', () => {
|
|
41
|
+
const tree = {
|
|
42
|
+
...VALID_TREE,
|
|
43
|
+
goals: [{ id: 1, name: '', type: 'Strategy', level: 0, parent_id: 0 }],
|
|
44
|
+
};
|
|
45
|
+
expect(validateGoalTree(tree).errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
|
|
46
|
+
});
|
|
47
|
+
it('MAX_LEVEL_EXCEEDED: detects level overflow', () => {
|
|
48
|
+
const tree = {
|
|
49
|
+
goal_types: [{ name: 'Strategy', level: 0 }],
|
|
50
|
+
goals: [{ id: 1, name: 'Too deep', type: 'Strategy', level: 5, parent_id: 0 }],
|
|
51
|
+
};
|
|
52
|
+
expect(validateGoalTree(tree).errors.some(e => e.code === 'MAX_LEVEL_EXCEEDED')).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
it('TYPE_LEVEL_MISMATCH: warns when type level disagrees', () => {
|
|
55
|
+
const tree = {
|
|
56
|
+
...VALID_TREE,
|
|
57
|
+
goals: [{ id: 1, name: 'Mismatch', type: 'Project', level: 0, parent_id: 0 }],
|
|
58
|
+
};
|
|
59
|
+
const r = validateGoalTree(tree);
|
|
60
|
+
expect(r.warnings.some(w => w.code === 'TYPE_LEVEL_MISMATCH')).toBe(true);
|
|
61
|
+
});
|
|
62
|
+
it('BROKEN_PARENT_REF: warns on missing parent (renders to backlog)', () => {
|
|
63
|
+
const tree = {
|
|
64
|
+
...VALID_TREE,
|
|
65
|
+
goals: [
|
|
66
|
+
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
67
|
+
{ id: 2, name: 'Orphan', type: 'Business Goal', level: 1, parent_id: 99 },
|
|
68
|
+
],
|
|
69
|
+
};
|
|
70
|
+
const r = validateGoalTree(tree);
|
|
71
|
+
expect(r.valid).toBe(true);
|
|
72
|
+
expect(r.warnings.some(w => w.code === 'BROKEN_PARENT_REF')).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
it('CYCLE_DETECTED: detects direct cycle', () => {
|
|
75
|
+
const tree = {
|
|
76
|
+
goal_types: [{ name: 'S', level: 0 }, { name: 'B', level: 1 }],
|
|
77
|
+
goals: [
|
|
78
|
+
{ id: 1, name: 'A', type: 'S', level: 0, parent_id: 2 },
|
|
79
|
+
{ id: 2, name: 'B', type: 'B', level: 1, parent_id: 1 },
|
|
80
|
+
],
|
|
81
|
+
};
|
|
82
|
+
expect(validateGoalTree(tree).errors.some(e => e.code === 'CYCLE_DETECTED')).toBe(true);
|
|
83
|
+
});
|
|
84
|
+
// Pre-release blocker regression tests (orchestrator review 2026-05-21).
|
|
85
|
+
it('[blocker] tolerates a null element in goals[] without throwing', () => {
|
|
86
|
+
const tree = { ...VALID_TREE, goals: [null] };
|
|
87
|
+
const r = validateGoalTree(tree);
|
|
88
|
+
expect(r.valid).toBe(false);
|
|
89
|
+
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
it('[blocker] tolerates a non-object element in goals[] without throwing', () => {
|
|
92
|
+
const tree = { ...VALID_TREE, goals: ['x'] };
|
|
93
|
+
const r = validateGoalTree(tree);
|
|
94
|
+
expect(r.valid).toBe(false);
|
|
95
|
+
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
it('[blocker] rejects non-numeric level (does not silently slip a string compare)', () => {
|
|
98
|
+
const tree = {
|
|
99
|
+
...VALID_TREE,
|
|
100
|
+
goals: [{ id: 1, name: 'A', type: 'Strategy', level: '5', parent_id: 0 }],
|
|
101
|
+
};
|
|
102
|
+
const r = validateGoalTree(tree);
|
|
103
|
+
expect(r.valid).toBe(false);
|
|
104
|
+
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID' && /level/.test(e.message))).toBe(true);
|
|
105
|
+
});
|
|
106
|
+
it('[blocker] rejects missing level (does not silently slip undefined > N)', () => {
|
|
107
|
+
const tree = {
|
|
108
|
+
...VALID_TREE,
|
|
109
|
+
goals: [{ id: 1, name: 'A', type: 'Strategy', parent_id: 0 }],
|
|
110
|
+
};
|
|
111
|
+
const r = validateGoalTree(tree);
|
|
112
|
+
expect(r.valid).toBe(false);
|
|
113
|
+
expect(r.errors.some(e => e.code === 'SCHEMA_INVALID' && /level/.test(e.message))).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
// GOALS-012 / GOALS-013 — N+1 parent/child hierarchy keyed on goal_types[]
|
|
116
|
+
// (decision in vkgeorgia/strategy#66; spec in transitrix/methodology
|
|
117
|
+
// notations/04-goals.md §6).
|
|
118
|
+
it('GOALS-012/013: accepts a contiguous goal_types + N+1 parent/child tree', () => {
|
|
119
|
+
const r = validateGoalTree(VALID_TREE);
|
|
120
|
+
expect(r.valid).toBe(true);
|
|
121
|
+
expect(r.errors.some(e => e.code === 'GOALS-012')).toBe(false);
|
|
122
|
+
expect(r.errors.some(e => e.code === 'GOALS-013')).toBe(false);
|
|
123
|
+
});
|
|
124
|
+
it('GOALS-013: rejects a gap in goal_types[].level', () => {
|
|
125
|
+
const tree = {
|
|
126
|
+
goal_types: [
|
|
127
|
+
{ name: 'Strategy', level: 0 },
|
|
128
|
+
{ name: 'Strategic Goal', level: 2 },
|
|
129
|
+
{ name: 'Project Goal', level: 4 },
|
|
130
|
+
],
|
|
131
|
+
goals: [
|
|
132
|
+
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
133
|
+
],
|
|
134
|
+
};
|
|
135
|
+
const r = validateGoalTree(tree);
|
|
136
|
+
expect(r.valid).toBe(false);
|
|
137
|
+
expect(r.errors.some(e => e.code === 'GOALS-013')).toBe(true);
|
|
138
|
+
});
|
|
139
|
+
it('GOALS-013: rejects goal_types[].level that does not start at 0', () => {
|
|
140
|
+
const tree = {
|
|
141
|
+
goal_types: [
|
|
142
|
+
{ name: 'Mid', level: 1 },
|
|
143
|
+
{ name: 'Deep', level: 2 },
|
|
144
|
+
],
|
|
145
|
+
goals: [
|
|
146
|
+
{ id: 1, name: 'A', type: 'Mid', level: 1, parent_id: 0 },
|
|
147
|
+
],
|
|
148
|
+
};
|
|
149
|
+
const r = validateGoalTree(tree);
|
|
150
|
+
expect(r.valid).toBe(false);
|
|
151
|
+
expect(r.errors.some(e => e.code === 'GOALS-013')).toBe(true);
|
|
152
|
+
});
|
|
153
|
+
it('GOALS-012: rejects a parent–child level gap > 1', () => {
|
|
154
|
+
const tree = {
|
|
155
|
+
goal_types: [
|
|
156
|
+
{ name: 'Strategy', level: 0 },
|
|
157
|
+
{ name: 'Business Goal', level: 1 },
|
|
158
|
+
{ name: 'Project', level: 2 },
|
|
159
|
+
],
|
|
160
|
+
goals: [
|
|
161
|
+
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
162
|
+
// Skips level 1: a Project (level 2) attached directly to a Strategy
|
|
163
|
+
// (level 0) violates N+1.
|
|
164
|
+
{ id: 2, name: 'Sub', type: 'Project', level: 2, parent_id: 1 },
|
|
165
|
+
],
|
|
166
|
+
};
|
|
167
|
+
const r = validateGoalTree(tree);
|
|
168
|
+
expect(r.valid).toBe(false);
|
|
169
|
+
expect(r.errors.some(e => e.code === 'GOALS-012')).toBe(true);
|
|
170
|
+
});
|
|
171
|
+
it('GOALS-012: does not fire when the parent reference is broken (BROKEN_PARENT_REF covers it)', () => {
|
|
172
|
+
const tree = {
|
|
173
|
+
...VALID_TREE,
|
|
174
|
+
goals: [
|
|
175
|
+
{ id: 1, name: 'Root', type: 'Strategy', level: 0, parent_id: 0 },
|
|
176
|
+
{ id: 2, name: 'Orphan', type: 'Project', level: 2, parent_id: 99 },
|
|
177
|
+
],
|
|
178
|
+
};
|
|
179
|
+
const r = validateGoalTree(tree);
|
|
180
|
+
expect(r.errors.some(e => e.code === 'GOALS-012')).toBe(false);
|
|
181
|
+
expect(r.warnings.some(w => w.code === 'BROKEN_PARENT_REF')).toBe(true);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { Goal, GoalType, GoalTree, Factor, ImpactType, ValidationResult, ValidationError, ValidationWarning, MutationResult, LayoutOptions, LaidOutNode, LaidOutEdge, GoalTreeLayout, } from './types.js';
|
|
2
|
+
export { validateGoalTree } from './validate.js';
|
|
3
|
+
export { parseCanonicalGoals } from './parse-canonical.js';
|
|
4
|
+
export type { CanonicalGoalsResult } from './parse-canonical.js';
|
|
5
|
+
export { layoutGoalTree, selectScopedGoals } from './layout.js';
|
|
6
|
+
export { reparent, addChild, deleteWithDescendants, moveToBacklog, restoreFromBacklog } from './mutations.js';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { validateGoalTree } from './validate.js';
|
|
2
|
+
export { parseCanonicalGoals } from './parse-canonical.js';
|
|
3
|
+
export { layoutGoalTree, selectScopedGoals } from './layout.js';
|
|
4
|
+
export { reparent, addChild, deleteWithDescendants, moveToBacklog, restoreFromBacklog } from './mutations.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Goal, GoalTree, LayoutOptions, GoalTreeLayout } from './types.js';
|
|
2
|
+
import type { Scope } from '../scope.js';
|
|
3
|
+
/**
|
|
4
|
+
* Trims a flat goal list to a scope (vkgeorgia/strategy#77).
|
|
5
|
+
* - 'level' → goals with `level <= maxLevel`.
|
|
6
|
+
* - 'root' → the root goal (matched by string id) plus all its descendants
|
|
7
|
+
* via `parent_id`; an empty list when the root is absent.
|
|
8
|
+
* Pure and exported so a future access-control layer can reuse it.
|
|
9
|
+
*/
|
|
10
|
+
export declare function selectScopedGoals(goals: Goal[], scope: Scope): Goal[];
|
|
11
|
+
export declare function layoutGoalTree(tree: GoalTree, options?: LayoutOptions): GoalTreeLayout;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
const DEFAULT_NODE_WIDTH = 250;
|
|
2
|
+
const DEFAULT_NODE_HEIGHT = 80;
|
|
3
|
+
const DEFAULT_RANK_SEP = 80;
|
|
4
|
+
const DEFAULT_NODE_SEP = 40;
|
|
5
|
+
/**
|
|
6
|
+
* Trims a flat goal list to a scope (vkgeorgia/strategy#77).
|
|
7
|
+
* - 'level' → goals with `level <= maxLevel`.
|
|
8
|
+
* - 'root' → the root goal (matched by string id) plus all its descendants
|
|
9
|
+
* via `parent_id`; an empty list when the root is absent.
|
|
10
|
+
* Pure and exported so a future access-control layer can reuse it.
|
|
11
|
+
*/
|
|
12
|
+
export function selectScopedGoals(goals, scope) {
|
|
13
|
+
if (scope.mode === 'all')
|
|
14
|
+
return goals;
|
|
15
|
+
if (scope.mode === 'level')
|
|
16
|
+
return goals.filter(g => g.level <= scope.maxLevel);
|
|
17
|
+
// root mode: collect the subtree rooted at rootGoalId (descendants via parent_id).
|
|
18
|
+
const children = new Map();
|
|
19
|
+
for (const g of goals) {
|
|
20
|
+
if (!children.has(g.parent_id))
|
|
21
|
+
children.set(g.parent_id, []);
|
|
22
|
+
children.get(g.parent_id).push(g.id);
|
|
23
|
+
}
|
|
24
|
+
const root = goals.find(g => String(g.id) === scope.rootGoalId);
|
|
25
|
+
if (!root)
|
|
26
|
+
return [];
|
|
27
|
+
const keep = new Set();
|
|
28
|
+
const stack = [root.id];
|
|
29
|
+
while (stack.length > 0) {
|
|
30
|
+
const id = stack.pop();
|
|
31
|
+
if (keep.has(id))
|
|
32
|
+
continue; // guard against malformed cycles
|
|
33
|
+
keep.add(id);
|
|
34
|
+
for (const c of children.get(id) ?? [])
|
|
35
|
+
stack.push(c);
|
|
36
|
+
}
|
|
37
|
+
return goals.filter(g => keep.has(g.id));
|
|
38
|
+
}
|
|
39
|
+
export function layoutGoalTree(tree, options = {}) {
|
|
40
|
+
const { nodeWidth = DEFAULT_NODE_WIDTH, nodeHeight = DEFAULT_NODE_HEIGHT, rankSep = DEFAULT_RANK_SEP, nodeSep = DEFAULT_NODE_SEP, hideCollapsed = [], viewDepth = null, scope = { mode: 'all' }, } = options;
|
|
41
|
+
const hiddenSet = new Set(hideCollapsed);
|
|
42
|
+
const goals = selectScopedGoals(tree.goals, scope);
|
|
43
|
+
// Build parent→children map
|
|
44
|
+
const children = new Map();
|
|
45
|
+
const goalById = new Map();
|
|
46
|
+
for (const g of goals) {
|
|
47
|
+
goalById.set(g.id, g);
|
|
48
|
+
if (!children.has(g.parent_id))
|
|
49
|
+
children.set(g.parent_id, []);
|
|
50
|
+
children.get(g.parent_id).push(g.id);
|
|
51
|
+
}
|
|
52
|
+
// Compress the levels actually used into contiguous column ranks. The
|
|
53
|
+
// canonical N+1 rule (GOALS-013) keeps `level` contiguous from 0, so for
|
|
54
|
+
// conforming input this is the identity map. It only rescues legacy /
|
|
55
|
+
// non-canonical documents whose `goal_types` skip levels (e.g. 0, 2, 4):
|
|
56
|
+
// without it those gaps open phantom empty columns and double the
|
|
57
|
+
// horizontal spacing between rendered tiers.
|
|
58
|
+
const usedLevels = Array.from(new Set(goals.map(g => g.level))).sort((a, b) => a - b);
|
|
59
|
+
const levelToCol = new Map();
|
|
60
|
+
usedLevels.forEach((lvl, i) => levelToCol.set(lvl, i));
|
|
61
|
+
// Find effective roots: level 0 or parent_id === 0 or broken ref
|
|
62
|
+
const allIds = new Set(goals.map(g => g.id));
|
|
63
|
+
const roots = goals.filter(g => g.parent_id === 0 || !allIds.has(g.parent_id));
|
|
64
|
+
// Determine hidden subtrees (collapsed or beyond viewDepth)
|
|
65
|
+
const hiddenSubtrees = new Set();
|
|
66
|
+
function markHidden(id) {
|
|
67
|
+
for (const child of children.get(id) ?? []) {
|
|
68
|
+
hiddenSubtrees.add(child);
|
|
69
|
+
markHidden(child);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
for (const id of hiddenSet)
|
|
73
|
+
markHidden(id);
|
|
74
|
+
if (viewDepth !== null) {
|
|
75
|
+
for (const g of goals) {
|
|
76
|
+
if (g.level > viewDepth)
|
|
77
|
+
hiddenSubtrees.add(g.id);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const nodes = [];
|
|
81
|
+
const edges = [];
|
|
82
|
+
// Recursive layout: assign y by counting vertical slots per column
|
|
83
|
+
const columnNextY = new Map();
|
|
84
|
+
function getNextY(col) {
|
|
85
|
+
return columnNextY.get(col) ?? 0;
|
|
86
|
+
}
|
|
87
|
+
function advanceY(col, delta) {
|
|
88
|
+
columnNextY.set(col, (columnNextY.get(col) ?? 0) + delta);
|
|
89
|
+
}
|
|
90
|
+
const placed = new Set();
|
|
91
|
+
function placeSubtree(id) {
|
|
92
|
+
const goal = goalById.get(id);
|
|
93
|
+
if (!goal || hiddenSubtrees.has(id))
|
|
94
|
+
return { top: 0, bottom: 0 };
|
|
95
|
+
// Guard against cycles (parent-of-itself, mutual parenting). Without
|
|
96
|
+
// validateGoalTree() upstream, layoutGoalTree must not stack-overflow on
|
|
97
|
+
// malformed input — drop any subtree we've already placed.
|
|
98
|
+
if (placed.has(id))
|
|
99
|
+
return { top: 0, bottom: 0 };
|
|
100
|
+
placed.add(id);
|
|
101
|
+
const col = levelToCol.get(goal.level) ?? 0;
|
|
102
|
+
const childIds = (children.get(id) ?? []).filter(c => !hiddenSubtrees.has(c) && !placed.has(c));
|
|
103
|
+
const isCollapsedRoot = hiddenSet.has(id) && childIds.length > 0;
|
|
104
|
+
const hasHiddenChildren = childIds.length < (children.get(id) ?? []).length;
|
|
105
|
+
if (childIds.length === 0) {
|
|
106
|
+
// Leaf: place at current column Y
|
|
107
|
+
const y = getNextY(col);
|
|
108
|
+
advanceY(col, nodeHeight + nodeSep);
|
|
109
|
+
nodes.push({ id, x: col * (nodeWidth + rankSep), y, width: nodeWidth, height: nodeHeight, data: goal, isCollapsedRoot, hasHiddenChildren });
|
|
110
|
+
return { top: y, bottom: y + nodeHeight };
|
|
111
|
+
}
|
|
112
|
+
// Place children first to get their span
|
|
113
|
+
const spans = [];
|
|
114
|
+
for (const cid of childIds) {
|
|
115
|
+
spans.push(placeSubtree(cid));
|
|
116
|
+
}
|
|
117
|
+
const spanTop = Math.min(...spans.map(s => s.top));
|
|
118
|
+
const spanBottom = Math.max(...spans.map(s => s.bottom));
|
|
119
|
+
const parentY = spanTop + (spanBottom - spanTop) / 2 - nodeHeight / 2;
|
|
120
|
+
// Make sure parent column is at least this far
|
|
121
|
+
const curColY = getNextY(col);
|
|
122
|
+
const finalY = Math.max(parentY, curColY);
|
|
123
|
+
advanceY(col, finalY - curColY + nodeHeight + nodeSep);
|
|
124
|
+
nodes.push({ id, x: col * (nodeWidth + rankSep), y: finalY, width: nodeWidth, height: nodeHeight, data: goal, isCollapsedRoot, hasHiddenChildren });
|
|
125
|
+
for (const cid of childIds) {
|
|
126
|
+
edges.push({ source: id, target: cid });
|
|
127
|
+
}
|
|
128
|
+
return { top: Math.min(finalY, spanTop), bottom: Math.max(finalY + nodeHeight, spanBottom) };
|
|
129
|
+
}
|
|
130
|
+
for (const root of roots) {
|
|
131
|
+
if (!hiddenSubtrees.has(root.id) && !placed.has(root.id)) {
|
|
132
|
+
placeSubtree(root.id);
|
|
133
|
+
// Add inter-root gap
|
|
134
|
+
for (const [col, y] of columnNextY) {
|
|
135
|
+
columnNextY.set(col, y + nodeSep);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (nodes.length === 0) {
|
|
140
|
+
return { nodes: [], edges: [], bounds: { x: 0, y: 0, width: 0, height: 0 } };
|
|
141
|
+
}
|
|
142
|
+
const minX = Math.min(...nodes.map(n => n.x));
|
|
143
|
+
const minY = Math.min(...nodes.map(n => n.y));
|
|
144
|
+
const maxX = Math.max(...nodes.map(n => n.x + n.width));
|
|
145
|
+
const maxY = Math.max(...nodes.map(n => n.y + n.height));
|
|
146
|
+
return { nodes, edges, bounds: { x: minX, y: minY, width: maxX - minX, height: maxY - minY } };
|
|
147
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { GoalTree, Goal, MutationResult } from './types.js';
|
|
2
|
+
export declare function reparent(tree: GoalTree, sourceId: number, targetId: number): MutationResult<GoalTree>;
|
|
3
|
+
export declare function addChild(tree: GoalTree, parentId: number, newGoal: Omit<Goal, 'id'>): MutationResult<GoalTree>;
|
|
4
|
+
export declare function deleteWithDescendants(tree: GoalTree, id: number): MutationResult<GoalTree>;
|
|
5
|
+
export declare function moveToBacklog(tree: GoalTree, id: number): MutationResult<GoalTree>;
|
|
6
|
+
export declare function restoreFromBacklog(tree: GoalTree, id: number, newParentId: number): MutationResult<GoalTree>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { validateGoalTree } from './validate.js';
|
|
2
|
+
function cloneTree(tree) {
|
|
3
|
+
return {
|
|
4
|
+
goal_types: tree.goal_types.map(gt => ({ ...gt })),
|
|
5
|
+
goals: tree.goals.map(g => ({ ...g, factors: g.factors ? g.factors.map(f => ({ ...f })) : undefined })),
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function nextId(tree) {
|
|
9
|
+
return Math.max(0, ...tree.goals.map(g => g.id)) + 1;
|
|
10
|
+
}
|
|
11
|
+
function getLevel(tree, goalId) {
|
|
12
|
+
const goal = tree.goals.find(g => g.id === goalId);
|
|
13
|
+
return goal?.level ?? 0;
|
|
14
|
+
}
|
|
15
|
+
function getTypeForLevel(tree, level) {
|
|
16
|
+
const gt = tree.goal_types.find(t => t.level === level);
|
|
17
|
+
return gt?.name ?? '';
|
|
18
|
+
}
|
|
19
|
+
function updateDescendantLevels(goals, id, levelDelta) {
|
|
20
|
+
for (const g of goals) {
|
|
21
|
+
if (g.parent_id === id) {
|
|
22
|
+
g.level += levelDelta;
|
|
23
|
+
g.type = '';
|
|
24
|
+
updateDescendantLevels(goals, g.id, levelDelta);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
function hasPathTo(goals, fromId, targetId) {
|
|
29
|
+
const visited = new Set();
|
|
30
|
+
const stack = [fromId];
|
|
31
|
+
while (stack.length > 0) {
|
|
32
|
+
const cur = stack.pop();
|
|
33
|
+
if (cur === targetId)
|
|
34
|
+
return true;
|
|
35
|
+
if (visited.has(cur))
|
|
36
|
+
continue;
|
|
37
|
+
visited.add(cur);
|
|
38
|
+
for (const g of goals) {
|
|
39
|
+
if (g.parent_id === cur)
|
|
40
|
+
stack.push(g.id);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
function refusalError(message) {
|
|
46
|
+
const err = { code: 'MUTATION_REFUSED', message };
|
|
47
|
+
return { ok: false, error: err };
|
|
48
|
+
}
|
|
49
|
+
export function reparent(tree, sourceId, targetId) {
|
|
50
|
+
const clone = cloneTree(tree);
|
|
51
|
+
const source = clone.goals.find(g => g.id === sourceId);
|
|
52
|
+
const target = clone.goals.find(g => g.id === targetId);
|
|
53
|
+
if (!source)
|
|
54
|
+
return refusalError(`Goal ${sourceId} not found`);
|
|
55
|
+
if (!target)
|
|
56
|
+
return refusalError(`Target goal ${targetId} not found`);
|
|
57
|
+
if (sourceId === targetId)
|
|
58
|
+
return refusalError('Cannot reparent to self');
|
|
59
|
+
if (hasPathTo(clone.goals, sourceId, targetId))
|
|
60
|
+
return refusalError('Cannot reparent: would create cycle');
|
|
61
|
+
const maxLevel = Math.max(...clone.goal_types.map(gt => gt.level), 0);
|
|
62
|
+
const newLevel = target.level + 1;
|
|
63
|
+
if (newLevel > maxLevel)
|
|
64
|
+
return refusalError(`Reparent would exceed max level ${maxLevel}`);
|
|
65
|
+
const levelDelta = newLevel - source.level;
|
|
66
|
+
source.parent_id = targetId;
|
|
67
|
+
source.level = newLevel;
|
|
68
|
+
source.type = getTypeForLevel(clone, newLevel);
|
|
69
|
+
if (levelDelta !== 0)
|
|
70
|
+
updateDescendantLevels(clone.goals, sourceId, levelDelta);
|
|
71
|
+
const v = validateGoalTree(clone);
|
|
72
|
+
if (!v.valid)
|
|
73
|
+
return refusalError(v.errors[0]?.message ?? 'Validation failed after reparent');
|
|
74
|
+
return { ok: true, result: clone };
|
|
75
|
+
}
|
|
76
|
+
export function addChild(tree, parentId, newGoal) {
|
|
77
|
+
const clone = cloneTree(tree);
|
|
78
|
+
const parent = parentId === 0 ? null : clone.goals.find(g => g.id === parentId);
|
|
79
|
+
if (parentId !== 0 && !parent)
|
|
80
|
+
return refusalError(`Parent goal ${parentId} not found`);
|
|
81
|
+
const maxLevel = Math.max(...clone.goal_types.map(gt => gt.level), 0);
|
|
82
|
+
const expectedLevel = parent ? parent.level + 1 : 0;
|
|
83
|
+
if (expectedLevel > maxLevel)
|
|
84
|
+
return refusalError(`New child would exceed max level ${maxLevel}`);
|
|
85
|
+
const id = nextId(clone);
|
|
86
|
+
clone.goals.push({ ...newGoal, id, parent_id: parentId, level: expectedLevel, type: getTypeForLevel(clone, expectedLevel) || newGoal.type });
|
|
87
|
+
return { ok: true, result: clone };
|
|
88
|
+
}
|
|
89
|
+
export function deleteWithDescendants(tree, id) {
|
|
90
|
+
const clone = cloneTree(tree);
|
|
91
|
+
if (!clone.goals.find(g => g.id === id))
|
|
92
|
+
return refusalError(`Goal ${id} not found`);
|
|
93
|
+
const toDelete = new Set();
|
|
94
|
+
const stack = [id];
|
|
95
|
+
while (stack.length > 0) {
|
|
96
|
+
const cur = stack.pop();
|
|
97
|
+
toDelete.add(cur);
|
|
98
|
+
for (const g of clone.goals) {
|
|
99
|
+
if (g.parent_id === cur)
|
|
100
|
+
stack.push(g.id);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
clone.goals = clone.goals.filter(g => !toDelete.has(g.id));
|
|
104
|
+
return { ok: true, result: clone };
|
|
105
|
+
}
|
|
106
|
+
export function moveToBacklog(tree, id) {
|
|
107
|
+
const clone = cloneTree(tree);
|
|
108
|
+
const goal = clone.goals.find(g => g.id === id);
|
|
109
|
+
if (!goal)
|
|
110
|
+
return refusalError(`Goal ${id} not found`);
|
|
111
|
+
goal.parent_id = 0;
|
|
112
|
+
return { ok: true, result: clone };
|
|
113
|
+
}
|
|
114
|
+
export function restoreFromBacklog(tree, id, newParentId) {
|
|
115
|
+
return reparent(tree, id, newParentId);
|
|
116
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical-form Goals parser + validator.
|
|
3
|
+
*
|
|
4
|
+
* Accepts the methodology's canonical Goals YAML shape (see
|
|
5
|
+
* `transitrix/methodology` `notations/04-goals.md`):
|
|
6
|
+
*
|
|
7
|
+
* - Flat top-level: `notation`, `id`, `name`, `goal_types[]`, `goals[]`.
|
|
8
|
+
* No `goals_tree:` wrapper, no `root.goal_id` / `children:` nesting.
|
|
9
|
+
* - Typed string IDs (`GOAL-…`); document id `GOALS-[<middle>-]<INTEGER>`.
|
|
10
|
+
* - Hierarchy via `parent: GOAL-…` on each goal; omit for root.
|
|
11
|
+
* - Per-notation validation codes `GOALS-001 … GOALS-011`.
|
|
12
|
+
*
|
|
13
|
+
* Returns the validation result plus, on success, an internal `GoalTree`
|
|
14
|
+
* built from the canonical input — canonical typed-string IDs are
|
|
15
|
+
* mapped to internal sequential numbers, `parent: GOAL-X` becomes
|
|
16
|
+
* `parent_id: <numeric>`, `parent_id: 0` denotes a root.
|
|
17
|
+
*
|
|
18
|
+
* Strategy hub #63: this lives at the input boundary so the library's
|
|
19
|
+
* internal types (numeric IDs) stay where they are. Convergence on
|
|
20
|
+
* canonical typed-string IDs across all sister modules is a follow-up
|
|
21
|
+
* task.
|
|
22
|
+
*/
|
|
23
|
+
import type { GoalTree } from './types.js';
|
|
24
|
+
import type { ValidationResult } from '../validation-types.js';
|
|
25
|
+
export interface CanonicalGoalsResult extends ValidationResult {
|
|
26
|
+
/** On success, the internal-form GoalTree derived from the canonical input. */
|
|
27
|
+
parsed?: GoalTree;
|
|
28
|
+
}
|
|
29
|
+
export declare function parseCanonicalGoals(input: unknown): CanonicalGoalsResult;
|