@transitrix/diagrams 1.0.1 → 1.2.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.
Files changed (137) hide show
  1. package/dist/activities/__tests__/validate.test.js +32 -1
  2. package/dist/activities/cpm.js +11 -2
  3. package/dist/activities/gantt.js +6 -3
  4. package/dist/activities/types.d.ts +1 -0
  5. package/dist/activities/validate.js +24 -8
  6. package/dist/activity-card/__tests__/resolver.test.js +22 -1
  7. package/dist/activity-card/__tests__/validate.test.js +23 -1
  8. package/dist/activity-card/resolver.js +28 -20
  9. package/dist/activity-card/validate.js +22 -11
  10. package/dist/capability-map/index.d.ts +4 -0
  11. package/dist/capability-map/index.js +2 -0
  12. package/dist/capability-map/layout-tree.d.ts +42 -0
  13. package/dist/capability-map/layout-tree.js +65 -0
  14. package/dist/capability-map/render-capability-tree.d.ts +15 -0
  15. package/dist/capability-map/render-capability-tree.js +108 -0
  16. package/dist/capability-map/types.d.ts +2 -0
  17. package/dist/compliance/__tests__/impact.test.js +198 -0
  18. package/dist/compliance/html.js +1 -7
  19. package/dist/compliance/impact.d.ts +24 -1
  20. package/dist/compliance/impact.js +97 -21
  21. package/dist/factor/__tests__/validate.test.js +3 -3
  22. package/dist/factor/types.d.ts +1 -1
  23. package/dist/factor/validate.js +2 -2
  24. package/dist/fgca/__tests__/chain-table.test.js +2 -2
  25. package/dist/fgca/__tests__/layout.test.js +11 -11
  26. package/dist/fgca/__tests__/preview-layout.test.js +7 -7
  27. package/dist/fgca/__tests__/resolver.test.js +2 -2
  28. package/dist/fgca/__tests__/validate.test.js +2 -2
  29. package/dist/fgca/chain-table.d.ts +1 -1
  30. package/dist/fgca/chain-table.js +4 -4
  31. package/dist/fgca/index.d.ts +2 -2
  32. package/dist/fgca/index.js +1 -1
  33. package/dist/fgca/layout.d.ts +2 -2
  34. package/dist/fgca/layout.js +9 -9
  35. package/dist/fgca/nodeTypes.d.ts +1 -1
  36. package/dist/fgca/nodeTypes.js +2 -2
  37. package/dist/fgca/nodes/FGCAFactorNode.d.ts +3 -3
  38. package/dist/fgca/nodes/FGCAFactorNode.js +5 -5
  39. package/dist/fgca/parse-canonical.js +24 -13
  40. package/dist/fgca/preview-layout.d.ts +1 -1
  41. package/dist/fgca/preview-layout.js +4 -4
  42. package/dist/fgca/resolver.js +3 -1
  43. package/dist/fgca/types.d.ts +13 -11
  44. package/dist/fgca/types.js +2 -2
  45. package/dist/fgca/validate.d.ts +2 -2
  46. package/dist/fgca/validate.js +34 -23
  47. package/dist/process-blueprint/index.d.ts +1 -1
  48. package/dist/process-blueprint/layout.js +64 -37
  49. package/dist/process-blueprint/types.d.ts +14 -0
  50. package/dist/scenarios/index.d.ts +1 -1
  51. package/dist/scenarios/types.d.ts +4 -4
  52. package/dist/theme/index.d.ts +1 -1
  53. package/dist/theme/index.js +1 -1
  54. package/dist/theme/themes.js +28 -3
  55. package/dist/theme/tokens.d.ts +47 -1
  56. package/dist/theme/tokens.js +31 -1
  57. package/dist/webview/__tests__/entry-notations.test.js +2 -0
  58. package/dist/webview/__tests__/render-process.test.d.ts +1 -0
  59. package/dist/webview/__tests__/render-process.test.js +463 -0
  60. package/dist/webview/__tests__/render-util.test.d.ts +1 -0
  61. package/dist/webview/__tests__/render-util.test.js +54 -0
  62. package/dist/webview/entry.d.ts +1 -1
  63. package/dist/webview/entry.js +9 -5
  64. package/dist/webview/render-activities.d.ts +21 -1
  65. package/dist/webview/render-activities.js +91 -56
  66. package/dist/webview/render-activity-card.d.ts +11 -1
  67. package/dist/webview/render-activity-card.js +11 -2
  68. package/dist/webview/render-blocks.d.ts +24 -1
  69. package/dist/webview/render-blocks.js +58 -24
  70. package/dist/webview/render-fgca.d.ts +27 -0
  71. package/dist/webview/render-fgca.js +30 -16
  72. package/dist/webview/render-goals.d.ts +26 -1
  73. package/dist/webview/render-goals.js +30 -20
  74. package/dist/webview/render-process-blueprint.d.ts +11 -1
  75. package/dist/webview/render-process-blueprint.js +118 -53
  76. package/dist/webview/render-process.d.ts +95 -0
  77. package/dist/webview/render-process.js +392 -0
  78. package/dist/webview/render-scenarios.js +2 -2
  79. package/dist/webview/render-util.d.ts +19 -6
  80. package/dist/webview/render-util.js +23 -15
  81. package/package.json +15 -1
  82. package/src/activities/__tests__/validate.test.ts +35 -1
  83. package/src/activities/cpm.ts +14 -2
  84. package/src/activities/gantt.ts +6 -5
  85. package/src/activities/types.ts +1 -0
  86. package/src/activities/validate.ts +24 -8
  87. package/src/activity-card/__tests__/resolver.test.ts +24 -1
  88. package/src/activity-card/__tests__/validate.test.ts +25 -1
  89. package/src/activity-card/resolver.ts +29 -20
  90. package/src/activity-card/validate.ts +20 -11
  91. package/src/capability-map/index.ts +11 -0
  92. package/src/capability-map/layout-tree.ts +114 -0
  93. package/src/capability-map/render-capability-tree.ts +131 -0
  94. package/src/capability-map/types.ts +2 -0
  95. package/src/compliance/__tests__/impact.test.ts +219 -0
  96. package/src/compliance/html.ts +1 -8
  97. package/src/compliance/impact.ts +141 -23
  98. package/src/factor/__tests__/validate.test.ts +3 -3
  99. package/src/factor/types.ts +1 -1
  100. package/src/factor/validate.ts +2 -2
  101. package/src/fgca/__tests__/chain-table.test.ts +2 -2
  102. package/src/fgca/__tests__/layout.test.ts +13 -13
  103. package/src/fgca/__tests__/preview-layout.test.ts +7 -7
  104. package/src/fgca/__tests__/resolver.test.ts +2 -2
  105. package/src/fgca/__tests__/validate.test.ts +2 -2
  106. package/src/fgca/chain-table.ts +5 -5
  107. package/src/fgca/index.ts +3 -3
  108. package/src/fgca/layout.ts +11 -11
  109. package/src/fgca/nodeTypes.ts +3 -3
  110. package/src/fgca/nodes/FGCAFactorNode.tsx +6 -6
  111. package/src/fgca/parse-canonical.ts +26 -15
  112. package/src/fgca/preview-layout.ts +5 -5
  113. package/src/fgca/resolver.ts +3 -1
  114. package/src/fgca/types.ts +15 -13
  115. package/src/fgca/validate.ts +32 -21
  116. package/src/process-blueprint/index.ts +1 -0
  117. package/src/process-blueprint/layout.ts +71 -42
  118. package/src/process-blueprint/types.ts +15 -0
  119. package/src/scenarios/index.ts +2 -2
  120. package/src/scenarios/types.ts +4 -4
  121. package/src/scenarios/validate.ts +3 -3
  122. package/src/theme/index.ts +1 -1
  123. package/src/theme/themes.ts +29 -2
  124. package/src/theme/tokens.ts +33 -1
  125. package/src/webview/__tests__/entry-notations.test.ts +2 -0
  126. package/src/webview/__tests__/render-process.test.ts +538 -0
  127. package/src/webview/__tests__/render-util.test.ts +66 -0
  128. package/src/webview/entry.ts +11 -5
  129. package/src/webview/render-activities.ts +107 -67
  130. package/src/webview/render-activity-card.ts +11 -2
  131. package/src/webview/render-blocks.ts +78 -28
  132. package/src/webview/render-fgca.ts +53 -29
  133. package/src/webview/render-goals.ts +45 -23
  134. package/src/webview/render-process-blueprint.ts +156 -82
  135. package/src/webview/render-process.ts +507 -0
  136. package/src/webview/render-scenarios.ts +3 -3
  137. package/src/webview/render-util.ts +27 -14
@@ -31,7 +31,7 @@ describe('buildChainTable — worked example (FGCA)', () => {
31
31
  };
32
32
  it('produces the spec grid with F1 spanning 3 and G2/C2 spanning 2', () => {
33
33
  const t = buildChainTable(doc);
34
- expect(t.columns).toEqual(['factor', 'goal', 'change', 'activity']);
34
+ expect(t.columns).toEqual(['driver', 'goal', 'change', 'activity']);
35
35
  expect(asGrid(t)).toEqual([
36
36
  ['F1×3', 'G1', 'C1', 'A1'],
37
37
  ['·', 'G2×2', 'C2×2', 'A2'],
@@ -59,7 +59,7 @@ describe('buildChainTable — FGA (no Change column)', () => {
59
59
  };
60
60
  it('emits three columns and merges Factor/Goal across the two activities', () => {
61
61
  const t = buildChainTable(doc, { hideChanges: true });
62
- expect(t.columns).toEqual(['factor', 'goal', 'activity']);
62
+ expect(t.columns).toEqual(['driver', 'goal', 'activity']);
63
63
  expect(asGrid(t)).toEqual([
64
64
  ['F1×2', 'G1×2', 'A1'],
65
65
  ['·', '·', 'A2'],
@@ -39,15 +39,15 @@ describe("buildFGCALayout — all columns visible", () => {
39
39
  });
40
40
  it("assigns correct node types", () => {
41
41
  const types = nodes.map((n) => n.type);
42
- expect(types.filter((t) => t === "fgcaFactor")).toHaveLength(factors.length);
42
+ expect(types.filter((t) => t === "fgcaDriver")).toHaveLength(factors.length);
43
43
  expect(types.filter((t) => t === "fgcaGoal")).toHaveLength(goals.length);
44
44
  expect(types.filter((t) => t === "fgcaChange")).toHaveLength(changes.length);
45
45
  expect(types.filter((t) => t === "fgcaActivity")).toHaveLength(activities.length);
46
46
  });
47
47
  it("creates Factor→Goal edges", () => {
48
- const fgEdges = edges.filter((e) => e.source.startsWith("factor_") && e.target.startsWith("goal_"));
48
+ const fgEdges = edges.filter((e) => e.source.startsWith("driver_") && e.target.startsWith("goal_"));
49
49
  expect(fgEdges).toHaveLength(2);
50
- expect(fgEdges.find((e) => e.source === "factor_1" && e.target === "goal_10")).toBeTruthy();
50
+ expect(fgEdges.find((e) => e.source === "driver_1" && e.target === "goal_10")).toBeTruthy();
51
51
  });
52
52
  it("creates Goal→Change edges", () => {
53
53
  const gcEdges = edges.filter((e) => e.source.startsWith("goal_") && e.target.startsWith("change_"));
@@ -66,7 +66,7 @@ describe("buildFGCALayout — all columns visible", () => {
66
66
  expect(actNode?.data.activityTypeName).toBe("Initiative");
67
67
  });
68
68
  it("encodes F-XXXX label format via id in node data", () => {
69
- const factorNode = nodes.find((n) => n.id === "factor_1");
69
+ const factorNode = nodes.find((n) => n.id === "driver_1");
70
70
  expect(String(factorNode?.data.id).padStart(4, "0")).toBe("0001");
71
71
  });
72
72
  it("encodes C-XXX label format via id in node data", () => {
@@ -74,14 +74,14 @@ describe("buildFGCALayout — all columns visible", () => {
74
74
  expect(String(changeNode?.data.id).padStart(3, "0")).toBe("100");
75
75
  });
76
76
  });
77
- describe("buildFGCALayout — Factor column hidden", () => {
78
- const cols = new Set(ALL_FGCA_COLUMNS.filter((c) => c !== "factor"));
77
+ describe("buildFGCALayout — Driver column hidden", () => {
78
+ const cols = new Set(ALL_FGCA_COLUMNS.filter((c) => c !== "driver"));
79
79
  const { nodes, edges } = buildFGCALayout({ factors, goals, changes, activities, visibleColumns: cols });
80
- it("produces no factor nodes", () => {
81
- expect(nodes.filter((n) => n.type === "fgcaFactor")).toHaveLength(0);
80
+ it("produces no driver nodes", () => {
81
+ expect(nodes.filter((n) => n.type === "fgcaDriver")).toHaveLength(0);
82
82
  });
83
- it("produces no Factor→Goal edges", () => {
84
- expect(edges.filter((e) => e.source.startsWith("factor_"))).toHaveLength(0);
83
+ it("produces no Driver→Goal edges", () => {
84
+ expect(edges.filter((e) => e.source.startsWith("driver_"))).toHaveLength(0);
85
85
  });
86
86
  it("still produces Goal and downstream nodes", () => {
87
87
  expect(nodes.filter((n) => n.type === "fgcaGoal")).toHaveLength(goals.length);
@@ -116,7 +116,7 @@ describe("buildFGCALayout — only one column visible", () => {
116
116
  describe("buildFGCALayout — columns are positioned left to right", () => {
117
117
  const { nodes } = buildFGCALayout({ factors, goals, changes, activities, visibleColumns: ALL_COLS });
118
118
  it("factor column x < goal column x", () => {
119
- const f = nodes.find((n) => n.type === "fgcaFactor");
119
+ const f = nodes.find((n) => n.type === "fgcaDriver");
120
120
  const g = nodes.find((n) => n.type === "fgcaGoal");
121
121
  expect(f.position.x).toBeLessThan(g.position.x);
122
122
  });
@@ -18,7 +18,7 @@ const doc = {
18
18
  describe('layoutFGCAPreview', () => {
19
19
  it('lays out all four columns in order (FGCA)', () => {
20
20
  const layout = layoutFGCAPreview(doc);
21
- expect(layout.columns.map(c => c.col)).toEqual(['factor', 'goal', 'change', 'activity']);
21
+ expect(layout.columns.map(c => c.col)).toEqual(['driver', 'goal', 'change', 'activity']);
22
22
  // 2 factors + 2 goals + 1 change + 2 activities
23
23
  expect(layout.nodes).toHaveLength(7);
24
24
  expect(layout.width).toBeGreaterThan(0);
@@ -31,7 +31,7 @@ describe('layoutFGCAPreview', () => {
31
31
  });
32
32
  it('hideChanges (FGA) drops the Changes column and links goals to activities', () => {
33
33
  const layout = layoutFGCAPreview(doc, { hideChanges: true });
34
- expect(layout.columns.map(c => c.col)).toEqual(['factor', 'goal', 'activity']);
34
+ expect(layout.columns.map(c => c.col)).toEqual(['driver', 'goal', 'activity']);
35
35
  // 2 factors + 2 goals + 2 activities
36
36
  expect(layout.nodes).toHaveLength(6);
37
37
  // F1→G1, F2→G2 (2), G1→A1, G2→A2 (2) = 4
@@ -57,7 +57,7 @@ describe('layoutFGCAPreview', () => {
57
57
  });
58
58
  it('larger rowGap increases the gap between stacked nodes', () => {
59
59
  const gapOf = (rowGap) => {
60
- const factors = layoutFGCAPreview(doc, { rowGap }).nodes.filter(n => n.col === 'factor');
60
+ const factors = layoutFGCAPreview(doc, { rowGap }).nodes.filter(n => n.col === 'driver');
61
61
  return factors[1].y - factors[0].y;
62
62
  };
63
63
  expect(gapOf(120)).toBeGreaterThan(gapOf(20));
@@ -71,14 +71,14 @@ describe('layoutFGCAPreview', () => {
71
71
  // root 10 → factor 1 (referenced by G10), change 20 (goal_id 10),
72
72
  // activity 30 (via change 20). G11/F2/A31 are dropped.
73
73
  const layout = layoutFGCAPreview(doc, { scope: { mode: 'root', rootGoalId: '10' } });
74
- expect(idsOf(layout)).toEqual(new Set(['factor_1', 'goal_10', 'change_20', 'activity_30']));
74
+ expect(idsOf(layout)).toEqual(new Set(['driver_1', 'goal_10', 'change_20', 'activity_30']));
75
75
  });
76
76
  it("mode 'root' filters factors and activities to those touching the visible goal", () => {
77
77
  // root 11 → factor 2, activity 31 (direct goal link); no change touches G11.
78
78
  const layout = layoutFGCAPreview(doc, { scope: { mode: 'root', rootGoalId: '11' } });
79
- expect(idsOf(layout)).toEqual(new Set(['factor_2', 'goal_11', 'activity_31']));
79
+ expect(idsOf(layout)).toEqual(new Set(['driver_2', 'goal_11', 'activity_31']));
80
80
  // F1, A30, C20 (which only touch the hidden G10) are excluded.
81
- expect(layout.nodes.some(n => n.id === 'factor_1')).toBe(false);
81
+ expect(layout.nodes.some(n => n.id === 'driver_1')).toBe(false);
82
82
  expect(layout.nodes.some(n => n.id === 'activity_30')).toBe(false);
83
83
  });
84
84
  it("mode 'level' trims goals above the cap and their connections", () => {
@@ -95,7 +95,7 @@ describe('layoutFGCAPreview', () => {
95
95
  ],
96
96
  };
97
97
  const layout = layoutFGCAPreview(leveled, { scope: { mode: 'level', maxLevel: 0 } });
98
- expect(idsOf(layout)).toEqual(new Set(['factor_1', 'goal_10', 'activity_30']));
98
+ expect(idsOf(layout)).toEqual(new Set(['driver_1', 'goal_10', 'activity_30']));
99
99
  });
100
100
  it("mode 'root' returns an empty layout when the root is absent", () => {
101
101
  const layout = layoutFGCAPreview(doc, { scope: { mode: 'root', rootGoalId: '999' } });
@@ -6,8 +6,8 @@ import { resolveFGCA, isFGCAViewDoc } from '../resolver.js';
6
6
  import { parseCanonicalFGCA } from '../parse-canonical.js';
7
7
  // ── Inline canon element store (mirrors strategy-2026 data split into per-element form) ─
8
8
  const ELEMENTS = [
9
- { notation: 'factor', id: 'FACTOR-1', name: 'Competitive market pressure', type: 'external' },
10
- { notation: 'factor', id: 'FACTOR-2', name: 'Digital adoption acceleration', type: 'external' },
9
+ { notation: 'driver', id: 'FACTOR-1', name: 'Competitive market pressure', type: 'external' },
10
+ { notation: 'driver', id: 'FACTOR-2', name: 'Digital adoption acceleration', type: 'external' },
11
11
  { notation: 'goal', id: 'GOAL-1', name: 'Grow revenue by 20%', factors: ['FACTOR-1', 'FACTOR-2'] },
12
12
  { notation: 'goal', id: 'GOAL-2', name: 'Reduce operational costs', factors: ['FACTOR-2'] },
13
13
  { notation: 'goal', id: 'GOAL-3', name: 'Improve customer retention', factors: ['FACTOR-1'] },
@@ -47,11 +47,11 @@ describe('validateFGCADoc', () => {
47
47
  expect(result.valid).toBe(false);
48
48
  expect(result.errors.some(e => e.path === 'changes')).toBe(true);
49
49
  });
50
- it('errors when activities array is missing', () => {
50
+ it('errors when actions array is missing', () => {
51
51
  const { activities: _, ...without } = VALID_DOC;
52
52
  const result = validateFGCADoc({ ...without, notation: 'fgca' });
53
53
  expect(result.valid).toBe(false);
54
- expect(result.errors.some(e => e.path === 'activities')).toBe(true);
54
+ expect(result.errors.some(e => e.path === 'actions')).toBe(true);
55
55
  });
56
56
  it('errors on empty factor name', () => {
57
57
  const result = validateFGCADoc({ ...VALID_DOC, factors: [{ id: 1, name: '' }] });
@@ -1,5 +1,5 @@
1
1
  import type { FGCAPreviewDoc } from './preview-layout.js';
2
- export type ChainColumn = 'factor' | 'goal' | 'change' | 'activity';
2
+ export type ChainColumn = 'driver' | 'goal' | 'change' | 'activity';
3
3
  export interface ChainCell {
4
4
  /** Column-qualified identity (e.g. "goal:3") — stable, unique across columns. */
5
5
  key: string;
@@ -1,6 +1,6 @@
1
1
  // Chain-table model for the FGCA / FGA previews (vkgeorgia/strategy#137).
2
2
  //
3
- // The tree/chain preview (`layoutFGCAPreview`) shows Factor → Goal → Change →
3
+ // The tree/chain preview (`layoutFGCAPreview`) shows Driver → Goal → Change →
4
4
  // Activity as columns of nodes joined by edges. This module produces the
5
5
  // *tabular* alternative: the same chain flattened into rows, with shared
6
6
  // parents collapsed into vertically-merged (rowspan) cells.
@@ -40,8 +40,8 @@ function sameCell(a, b) {
40
40
  export function buildChainTable(doc, options = {}) {
41
41
  const { hideChanges = false } = options;
42
42
  const columns = hideChanges
43
- ? ['factor', 'goal', 'activity']
44
- : ['factor', 'goal', 'change', 'activity'];
43
+ ? ['driver', 'goal', 'activity']
44
+ : ['driver', 'goal', 'change', 'activity'];
45
45
  const changes = doc.changes ?? [];
46
46
  const factorIds = new Set(doc.factors.map(f => f.id));
47
47
  const activityById = new Map(doc.activities.map(a => [a.id, a]));
@@ -101,7 +101,7 @@ export function buildChainTable(doc, options = {}) {
101
101
  };
102
102
  // Phase 1 — factor-rooted paths.
103
103
  for (const f of doc.factors) {
104
- const factorCell = cellOf('factor', f.id, f.name);
104
+ const factorCell = cellOf('driver', f.id, f.name);
105
105
  const goalsOfFactor = doc.goals.filter(g => (g.factor ?? []).some(ref => ref.id === f.id));
106
106
  if (goalsOfFactor.length === 0) {
107
107
  paths.push(pad([factorCell]));
@@ -7,10 +7,10 @@ export type { ChainTable, ChainTableCell, ChainColumn, ChainCell, ChainTableOpti
7
7
  export { validateFGCADoc } from "./validate";
8
8
  export type { FGCADoc, FGCAValidationResult, FGCAValidationError, FGCAValidationWarning } from "./validate";
9
9
  export { ALL_FGCA_COLUMNS, FGCA_COLUMN_LABELS, } from "./types";
10
- export type { FactorItem, GoalItem, BdnChangeWithActivities, ActivityItem, ActivityTypeItem, DiagramStyle, FGCAColumn, } from "./types";
10
+ export type { DriverItem, GoalItem, BdnChangeWithActivities, ActivityItem, ActivityTypeItem, DiagramStyle, FGCAColumn, } from "./types";
11
11
  export { resolveFGCA, isFGCAViewDoc } from './resolver.js';
12
12
  export type { FGCAViewConfig, FGCACanonSources } from './resolver.js';
13
- export { default as FGCAFactorNode } from "./nodes/FGCAFactorNode";
13
+ export { default as FGCADriverNode } from "./nodes/FGCAFactorNode";
14
14
  export { default as FGCAGoalNode } from "./nodes/FGCAGoalNode";
15
15
  export { default as FGCAChangeNode } from "./nodes/FGCAChangeNode";
16
16
  export { default as FGCAActivityNode } from "./nodes/FGCAActivityNode";
@@ -4,7 +4,7 @@ export { buildChainTable } from "./chain-table";
4
4
  export { validateFGCADoc } from "./validate";
5
5
  export { ALL_FGCA_COLUMNS, FGCA_COLUMN_LABELS, } from "./types";
6
6
  export { resolveFGCA, isFGCAViewDoc } from './resolver.js';
7
- export { default as FGCAFactorNode } from "./nodes/FGCAFactorNode";
7
+ export { default as FGCADriverNode } from "./nodes/FGCAFactorNode";
8
8
  export { default as FGCAGoalNode } from "./nodes/FGCAGoalNode";
9
9
  export { default as FGCAChangeNode } from "./nodes/FGCAChangeNode";
10
10
  export { default as FGCAActivityNode } from "./nodes/FGCAActivityNode";
@@ -1,5 +1,5 @@
1
1
  import type { Node, Edge } from "reactflow";
2
- import type { FactorItem, GoalItem, BdnChangeWithActivities, ActivityItem, ActivityTypeItem, DiagramStyle, FGCAColumn } from "./types";
2
+ import type { DriverItem, GoalItem, BdnChangeWithActivities, ActivityItem, ActivityTypeItem, DiagramStyle, FGCAColumn } from "./types";
3
3
  export declare const NODE_WIDTH = 250;
4
4
  export declare const NODE_HEIGHT = 80;
5
5
  export declare const COLUMN_GAP = 180;
@@ -7,7 +7,7 @@ export declare const ROW_GAP = 24;
7
7
  /** Default background colours per column. */
8
8
  export declare const COLUMN_BG: Record<FGCAColumn, string>;
9
9
  export interface FGCALayoutInput {
10
- factors: FactorItem[];
10
+ factors: DriverItem[];
11
11
  goals: GoalItem[];
12
12
  changes: BdnChangeWithActivities[];
13
13
  activities: ActivityItem[];
@@ -6,7 +6,7 @@ export const COLUMN_GAP = 180;
6
6
  export const ROW_GAP = 24;
7
7
  /** Default background colours per column. */
8
8
  export const COLUMN_BG = {
9
- factor: "#fef3c7",
9
+ driver: "#fef3c7",
10
10
  goal: "#e0e7ff",
11
11
  change: "#dbeafe",
12
12
  activity: "#d4edda",
@@ -27,12 +27,12 @@ export function buildFGCALayout({ factors, goals, changes, activities, visibleCo
27
27
  const goalIds = new Set(goals.map((g) => g.id));
28
28
  const edgeStyle = { strokeWidth: edgeWidth, stroke: edgeColor };
29
29
  const baseNodeStyle = { borderColor: nodeBorderColor, borderWidth: nodeBorderWidth, borderStyle: "solid" };
30
- if (visibleColumns.has("factor")) {
30
+ if (visibleColumns.has("driver")) {
31
31
  factors.forEach((f, i) => {
32
32
  nodes.push({
33
- id: `factor_${f.id}`,
34
- type: "fgcaFactor",
35
- position: { x: colX["factor"], y: i * (NODE_HEIGHT + ROW_GAP) },
33
+ id: `driver_${f.id}`,
34
+ type: "fgcaDriver",
35
+ position: { x: colX["driver"], y: i * (NODE_HEIGHT + ROW_GAP) },
36
36
  data: { id: f.id, name: f.name, ...baseNodeStyle },
37
37
  sourcePosition: Position.Right,
38
38
  targetPosition: Position.Left,
@@ -88,13 +88,13 @@ export function buildFGCALayout({ factors, goals, changes, activities, visibleCo
88
88
  });
89
89
  });
90
90
  }
91
- // Factor→Goal edges (via embedded factor[] on each goal)
92
- if (visibleColumns.has("factor") && visibleColumns.has("goal")) {
91
+ // Driver→Goal edges (via embedded factor[] on each goal)
92
+ if (visibleColumns.has("driver") && visibleColumns.has("goal")) {
93
93
  goals.forEach((g) => {
94
94
  g.factor?.forEach((f) => {
95
95
  edges.push({
96
- id: `edge_f${f.id}_g${g.id}`,
97
- source: `factor_${f.id}`,
96
+ id: `edge_d${f.id}_g${g.id}`,
97
+ source: `driver_${f.id}`,
98
98
  target: `goal_${g.id}`,
99
99
  markerEnd: { type: MarkerType.ArrowClosed },
100
100
  type: "smoothstep",
@@ -1,5 +1,5 @@
1
1
  export declare const FGCA_NODE_TYPES: {
2
- readonly fgcaFactor: import("react").MemoExoticComponent<({ data, isConnectable }: import("./nodes/FGCAFactorNode").FGCAFactorNodeProps) => import("react/jsx-runtime").JSX.Element>;
2
+ readonly fgcaDriver: import("react").MemoExoticComponent<({ data, isConnectable }: import("./nodes/FGCAFactorNode").FGCADriverNodeProps) => import("react/jsx-runtime").JSX.Element>;
3
3
  readonly fgcaGoal: import("react").MemoExoticComponent<({ data, isConnectable }: import("./nodes/FGCAGoalNode").FGCAGoalNodeProps) => import("react/jsx-runtime").JSX.Element>;
4
4
  readonly fgcaChange: import("react").MemoExoticComponent<({ data, isConnectable }: import("./nodes/FGCAChangeNode").FGCAChangeNodeProps) => import("react/jsx-runtime").JSX.Element>;
5
5
  readonly fgcaActivity: import("react").MemoExoticComponent<({ data, isConnectable }: import("./nodes/FGCAActivityNode").FGCAActivityNodeProps) => import("react/jsx-runtime").JSX.Element>;
@@ -1,9 +1,9 @@
1
- import FGCAFactorNode from "./nodes/FGCAFactorNode";
1
+ import FGCADriverNode from "./nodes/FGCAFactorNode";
2
2
  import FGCAGoalNode from "./nodes/FGCAGoalNode";
3
3
  import FGCAChangeNode from "./nodes/FGCAChangeNode";
4
4
  import FGCAActivityNode from "./nodes/FGCAActivityNode";
5
5
  export const FGCA_NODE_TYPES = {
6
- fgcaFactor: FGCAFactorNode,
6
+ fgcaDriver: FGCADriverNode,
7
7
  fgcaGoal: FGCAGoalNode,
8
8
  fgcaChange: FGCAChangeNode,
9
9
  fgcaActivity: FGCAActivityNode,
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- export interface FGCAFactorNodeProps {
2
+ export interface FGCADriverNodeProps {
3
3
  data: {
4
4
  id: number;
5
5
  name: string;
@@ -8,5 +8,5 @@ export interface FGCAFactorNodeProps {
8
8
  };
9
9
  isConnectable?: boolean;
10
10
  }
11
- declare const FGCAFactorNode: React.MemoExoticComponent<({ data, isConnectable }: FGCAFactorNodeProps) => import("react/jsx-runtime").JSX.Element>;
12
- export default FGCAFactorNode;
11
+ declare const FGCADriverNode: React.MemoExoticComponent<({ data, isConnectable }: FGCADriverNodeProps) => import("react/jsx-runtime").JSX.Element>;
12
+ export default FGCADriverNode;
@@ -3,8 +3,8 @@ import { memo } from "react";
3
3
  import { Handle, Position } from "reactflow";
4
4
  const NODE_WIDTH = 250;
5
5
  const NODE_HEIGHT = 80;
6
- const FGCAFactorNode = memo(({ data, isConnectable }) => (_jsxs("div", { style: {
7
- background: "var(--ts-layer-factor)",
6
+ const FGCADriverNode = memo(({ data, isConnectable }) => (_jsxs("div", { style: {
7
+ background: "var(--ts-layer-driver)",
8
8
  width: NODE_WIDTH,
9
9
  height: NODE_HEIGHT,
10
10
  padding: "6px 8px",
@@ -30,6 +30,6 @@ const FGCAFactorNode = memo(({ data, isConnectable }) => (_jsxs("div", { style:
30
30
  wordBreak: "break-word",
31
31
  padding: "0 4px",
32
32
  width: "100%",
33
- }, title: data.name, children: data.name }), _jsxs("div", { style: { fontSize: "10px", color: "var(--ts-text-secondary)", marginTop: 2 }, children: ["F-", String(data.id).padStart(4, "0")] })] })));
34
- FGCAFactorNode.displayName = "FGCAFactorNode";
35
- export default FGCAFactorNode;
33
+ }, title: data.name, children: data.name }), _jsxs("div", { style: { fontSize: "10px", color: "var(--ts-text-secondary)", marginTop: 2 }, children: ["D-", String(data.id).padStart(4, "0")] })] })));
34
+ FGCADriverNode.displayName = "FGCADriverNode";
35
+ export default FGCADriverNode;
@@ -27,10 +27,12 @@
27
27
  // is fixed per layer; middle segments are optional; the terminal is a
28
28
  // positive integer with no leading zeros.
29
29
  const FACTOR_ID_RE = /^FACTOR(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
30
+ const DRIVER_ID_RE = /^DRIVER(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
31
+ const FACTOR_OR_DRIVER_ID_RE = /^(FACTOR|DRIVER)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
30
32
  const GOAL_ID_RE = /^GOAL(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
31
33
  const CHANGE_ID_RE = /^CHANGE(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
32
34
  const ACTIVITY_ID_RE = /^ACTIVITY(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
33
- const FGCA_DOC_ID_RE = /^FGCA(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
35
+ const FGCA_DOC_ID_RE = /^(FGCA|DGCA)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
34
36
  const CONSTRAINT_ID_RE = /^CONSTRAINT(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
35
37
  function isNonEmptyString(v) {
36
38
  return typeof v === 'string' && v.trim().length > 0;
@@ -55,18 +57,21 @@ export function parseCanonicalFGCA(input) {
55
57
  };
56
58
  }
57
59
  const raw = input;
58
- if ('notation' in raw && raw['notation'] !== 'fgca') {
60
+ if ('notation' in raw && raw['notation'] !== 'fgca' && raw['notation'] !== 'dgca') {
59
61
  return {
60
62
  valid: false,
61
63
  errors: [
62
64
  {
63
65
  code: 'FGCA-001',
64
- message: `notation must be "fgca", got "${String(raw['notation'])}"`,
66
+ message: `notation must be "dgca" (or legacy "fgca"), got "${String(raw['notation'])}"`,
65
67
  },
66
68
  ],
67
69
  warnings,
68
70
  };
69
71
  }
72
+ if ('notation' in raw && raw['notation'] === 'fgca') {
73
+ warnings.push({ code: 'FGCA-001', message: 'notation "fgca" is deprecated — rename to "dgca"' });
74
+ }
70
75
  // FGCA-002 — document id (optional in v1.4 per the canonical spec? — spec
71
76
  // says required; absence is FGCA-002).
72
77
  if (raw['id'] !== undefined) {
@@ -86,7 +91,11 @@ export function parseCanonicalFGCA(input) {
86
91
  const factorsRaw = asObjectArray(raw['factors']);
87
92
  const goalsRaw = asObjectArray(raw['goals']);
88
93
  const changesRaw = asObjectArray(raw['changes']);
89
- const activitiesRaw = asObjectArray(raw['activities']);
94
+ // Accept canonical `actions:` or deprecated `activities:`; warn on the latter.
95
+ const activitiesRaw = asObjectArray(raw['actions']) ?? asObjectArray(raw['activities']);
96
+ if ('activities' in raw && !('actions' in raw)) {
97
+ warnings.push({ code: 'FGCA-001', message: '"activities" key is deprecated — rename to "actions"' });
98
+ }
90
99
  if (factorsRaw === null)
91
100
  errors.push({ code: 'FGCA-004', message: 'factors must be an array', path: 'factors' });
92
101
  if (goalsRaw === null)
@@ -94,7 +103,7 @@ export function parseCanonicalFGCA(input) {
94
103
  if (changesRaw === null)
95
104
  errors.push({ code: 'FGCA-004', message: 'changes must be an array', path: 'changes' });
96
105
  if (activitiesRaw === null)
97
- errors.push({ code: 'FGCA-004', message: 'activities must be an array', path: 'activities' });
106
+ errors.push({ code: 'FGCA-004', message: 'actions must be an array', path: 'actions' });
98
107
  if (errors.length > 0)
99
108
  return { valid: false, errors, warnings };
100
109
  // From here we know all four arrays exist.
@@ -137,7 +146,7 @@ export function parseCanonicalFGCA(input) {
137
146
  }
138
147
  return { id, name: isNonEmptyString(name) ? name : '' };
139
148
  }
140
- factors.forEach((el, i) => checkLayerElement(el, `factors[${i}]`, FACTOR_ID_RE, factorIds));
149
+ factors.forEach((el, i) => checkLayerElement(el, `factors[${i}]`, FACTOR_OR_DRIVER_ID_RE, factorIds));
141
150
  goals.forEach((el, i) => checkLayerElement(el, `goals[${i}]`, GOAL_ID_RE, goalIds));
142
151
  changes.forEach((el, i) => checkLayerElement(el, `changes[${i}]`, CHANGE_ID_RE, changeIds));
143
152
  activities.forEach((el, i) => checkLayerElement(el, `activities[${i}]`, ACTIVITY_ID_RE, activityIds));
@@ -188,7 +197,7 @@ export function parseCanonicalFGCA(input) {
188
197
  name: String(el['name'] ?? ''),
189
198
  }));
190
199
  const internalGoals = goals.map((el, i) => {
191
- const refIds = checkRefArray(el, 'factors', factorIds, FACTOR_ID_RE, 'FGCA-008', `goals[${i}]`);
200
+ const refIds = checkRefArray(el, 'factors', factorIds, FACTOR_OR_DRIVER_ID_RE, 'FGCA-008', `goals[${i}]`);
192
201
  return {
193
202
  id: intId(String(el['id'])),
194
203
  name: String(el['name'] ?? ''),
@@ -232,11 +241,13 @@ export function parseCanonicalFGCA(input) {
232
241
  };
233
242
  });
234
243
  const internalActivities = activities.map((el, i) => {
235
- const goalRefs = checkRefArray(el, 'goals', goalIds, GOAL_ID_RE, 'FGCA-011', `activities[${i}]`);
244
+ const goalRefs = checkRefArray(el, 'goals', goalIds, GOAL_ID_RE, 'FGCA-011', `actions[${i}]`);
245
+ const typeVal = typeof el['type'] === 'string' ? el['type'] : undefined;
236
246
  return {
237
247
  id: intId(String(el['id'])),
238
248
  name: String(el['name'] ?? ''),
239
249
  goal_id: goalRefs.length > 0 ? intId(goalRefs[0]) : null,
250
+ ...(typeVal !== undefined ? { type: typeVal } : {}),
240
251
  };
241
252
  });
242
253
  // FACTOR.references_constraint grammar check (FGCA-015).
@@ -261,7 +272,7 @@ export function parseCanonicalFGCA(input) {
261
272
  if (errors.length > 0)
262
273
  return { valid: false, errors, warnings };
263
274
  const parsed = {
264
- notation: 'fgca',
275
+ notation: raw['notation'] ?? 'dgca',
265
276
  spec_version: typeof raw['spec_version'] === 'string' ? raw['spec_version'] : undefined,
266
277
  factors: internalFactors,
267
278
  goals: internalGoals,
@@ -270,7 +281,7 @@ export function parseCanonicalFGCA(input) {
270
281
  };
271
282
  return { valid: true, errors, warnings, parsed };
272
283
  }
273
- const FGA_DOC_ID_RE = /^FGA(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
284
+ const FGA_DOC_ID_RE = /^(FGA|DGA)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
274
285
  /**
275
286
  * Canonical-form FGA parser + validator.
276
287
  *
@@ -293,10 +304,10 @@ export function parseCanonicalFGA(input) {
293
304
  return { valid: false, errors: [{ code: 'FGA-001', message: 'document root is not an object' }], warnings: [] };
294
305
  }
295
306
  const raw = input;
296
- if ('notation' in raw && raw['notation'] !== 'fga') {
307
+ if ('notation' in raw && raw['notation'] !== 'fga' && raw['notation'] !== 'dga') {
297
308
  return {
298
309
  valid: false,
299
- errors: [{ code: 'FGA-001', message: `notation must be "fga", got "${String(raw['notation'])}"` }],
310
+ errors: [{ code: 'FGA-001', message: `notation must be "dga" (or legacy "fga"), got "${String(raw['notation'])}"` }],
300
311
  warnings: [],
301
312
  };
302
313
  }
@@ -314,7 +325,7 @@ export function parseCanonicalFGA(input) {
314
325
  // changes. Per-layer / per-ref checks all reuse the FGCA implementation;
315
326
  // codes are remapped on the way out. FGCA-009 / 010 / 014 (changes-related)
316
327
  // are unreachable here because `changes` is empty.
317
- const synth = { ...raw, notation: 'fgca', id: 'FGCA-FROM-FGA-1', changes: [] };
328
+ const synth = { ...raw, notation: 'dgca', id: 'DGCA-FROM-DGA-1', changes: [] };
318
329
  const r = parseCanonicalFGCA(synth);
319
330
  const remap = {
320
331
  'FGCA-001': 'FGA-001',
@@ -1,5 +1,5 @@
1
1
  import type { Scope } from '../scope.js';
2
- export type FGCAPreviewColumn = 'factor' | 'goal' | 'change' | 'activity';
2
+ export type FGCAPreviewColumn = 'driver' | 'goal' | 'change' | 'activity';
3
3
  export interface FGCAPreviewFactor {
4
4
  id: number | string;
5
5
  name: string;
@@ -52,11 +52,11 @@ export function layoutFGCAPreview(inputDoc, options = {}) {
52
52
  const doc = selectScopedFGCA(inputDoc, scope);
53
53
  const colStride = FGCA_NODE_W + colGap;
54
54
  const cols = hideChanges
55
- ? ['factor', 'goal', 'activity']
56
- : ['factor', 'goal', 'change', 'activity'];
55
+ ? ['driver', 'goal', 'activity']
56
+ : ['driver', 'goal', 'change', 'activity'];
57
57
  const changes = doc.changes ?? [];
58
58
  const colItems = {
59
- factor: doc.factors.map(f => ({ id: `factor_${f.id}`, label: f.name })),
59
+ driver: doc.factors.map(f => ({ id: `driver_${f.id}`, label: f.name })),
60
60
  goal: doc.goals.map(g => ({ id: `goal_${g.id}`, label: g.name })),
61
61
  change: changes.map(c => ({ id: `change_${c.id}`, label: c.name })),
62
62
  activity: doc.activities.map(a => ({ id: `activity_${a.id}`, label: a.name })),
@@ -86,7 +86,7 @@ export function layoutFGCAPreview(inputDoc, options = {}) {
86
86
  }
87
87
  for (const g of doc.goals) {
88
88
  for (const f of (g.factor ?? []))
89
- addEdge(`factor_${f.id}`, `goal_${g.id}`);
89
+ addEdge(`driver_${f.id}`, `goal_${g.id}`);
90
90
  }
91
91
  if (hideChanges) {
92
92
  const connectedViaChange = new Set();
@@ -61,7 +61,9 @@ export function resolveFGCA(viewDoc, sources) {
61
61
  const factorsConf = isObject(vc['factors']) ? vc['factors'] : {};
62
62
  const changesConf = isObject(vc['changes']) ? vc['changes'] : {};
63
63
  const activitiesConf = isObject(vc['activities']) ? vc['activities'] : {};
64
- const factorElems = collectByNotation(sources.elements, 'factor');
64
+ const factorElemsLegacy = collectByNotation(sources.elements, 'factor');
65
+ const factorElemsNew = collectByNotation(sources.elements, 'driver');
66
+ const factorElems = new Map([...factorElemsLegacy, ...factorElemsNew]);
65
67
  const goalElems = collectByNotation(sources.elements, 'goal');
66
68
  const changeElems = collectByNotation(sources.elements, 'change');
67
69
  const activityElems = collectByNotation(sources.elements, 'activity');
@@ -1,30 +1,32 @@
1
- export interface FactorItem {
2
- id: number;
1
+ export interface DriverItem {
2
+ id: number | string;
3
3
  name: string;
4
4
  }
5
5
  export interface GoalItem {
6
- id: number;
6
+ id: number | string;
7
7
  name: string;
8
8
  level?: number;
9
9
  /** Goals may carry embedded factor links returned by the API. */
10
10
  factor?: Array<{
11
- id: number;
11
+ id: number | string;
12
12
  }>;
13
13
  }
14
14
  export interface BdnChangeWithActivities {
15
- id: number;
15
+ id: number | string;
16
16
  name: string;
17
- goal_id: number;
18
- activity_ids: number[];
17
+ goal_id: number | string;
18
+ activity_ids: Array<number | string>;
19
19
  }
20
20
  export interface ActivityItem {
21
- id: number;
21
+ id: number | string;
22
22
  name: string;
23
- goal_id?: number | null;
23
+ goal_id?: number | string | null;
24
24
  activity_type_id?: number;
25
+ /** Canonical values: initiative | programme | project | work_package. Unknown values pass through without error. */
26
+ type?: string;
25
27
  }
26
28
  export interface ActivityTypeItem {
27
- id: number;
29
+ id: number | string;
28
30
  name?: string;
29
31
  }
30
32
  export interface DiagramStyle {
@@ -34,6 +36,6 @@ export interface DiagramStyle {
34
36
  edgeWidth?: number;
35
37
  }
36
38
  /** The four columns of the FGCA diagram. */
37
- export type FGCAColumn = "factor" | "goal" | "change" | "activity";
39
+ export type FGCAColumn = "driver" | "goal" | "change" | "activity";
38
40
  export declare const ALL_FGCA_COLUMNS: FGCAColumn[];
39
41
  export declare const FGCA_COLUMN_LABELS: Record<FGCAColumn, string>;
@@ -1,6 +1,6 @@
1
- export const ALL_FGCA_COLUMNS = ["factor", "goal", "change", "activity"];
1
+ export const ALL_FGCA_COLUMNS = ["driver", "goal", "change", "activity"];
2
2
  export const FGCA_COLUMN_LABELS = {
3
- factor: "F",
3
+ driver: "D",
4
4
  goal: "G",
5
5
  change: "C",
6
6
  activity: "A",
@@ -1,4 +1,4 @@
1
- import type { FactorItem, GoalItem, BdnChangeWithActivities, ActivityItem } from './types.js';
1
+ import type { DriverItem, GoalItem, BdnChangeWithActivities, ActivityItem } from './types.js';
2
2
  import type { ValidationError, ValidationWarning, ValidationResult } from '../validation-types.js';
3
3
  export type FGCAValidationError = ValidationError;
4
4
  export type FGCAValidationWarning = ValidationWarning;
@@ -6,7 +6,7 @@ export type FGCAValidationResult = ValidationResult;
6
6
  export interface FGCADoc {
7
7
  notation: string;
8
8
  spec_version?: string;
9
- factors: FactorItem[];
9
+ factors: DriverItem[];
10
10
  goals: GoalItem[];
11
11
  changes: BdnChangeWithActivities[];
12
12
  activities: ActivityItem[];