@transitrix/diagrams 1.0.1 → 1.1.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 (115) hide show
  1. package/dist/activities/cpm.js +11 -2
  2. package/dist/activities/gantt.js +6 -3
  3. package/dist/activities/types.d.ts +1 -0
  4. package/dist/activities/validate.js +3 -3
  5. package/dist/activity-card/__tests__/resolver.test.js +22 -1
  6. package/dist/activity-card/resolver.js +11 -5
  7. package/dist/compliance/__tests__/impact.test.js +198 -0
  8. package/dist/compliance/html.js +1 -7
  9. package/dist/compliance/impact.d.ts +24 -1
  10. package/dist/compliance/impact.js +97 -21
  11. package/dist/factor/__tests__/validate.test.js +3 -3
  12. package/dist/factor/types.d.ts +1 -1
  13. package/dist/factor/validate.js +2 -2
  14. package/dist/fgca/__tests__/chain-table.test.js +2 -2
  15. package/dist/fgca/__tests__/layout.test.js +11 -11
  16. package/dist/fgca/__tests__/preview-layout.test.js +7 -7
  17. package/dist/fgca/__tests__/resolver.test.js +2 -2
  18. package/dist/fgca/chain-table.d.ts +1 -1
  19. package/dist/fgca/chain-table.js +4 -4
  20. package/dist/fgca/index.d.ts +2 -2
  21. package/dist/fgca/index.js +1 -1
  22. package/dist/fgca/layout.d.ts +2 -2
  23. package/dist/fgca/layout.js +9 -9
  24. package/dist/fgca/nodeTypes.d.ts +1 -1
  25. package/dist/fgca/nodeTypes.js +2 -2
  26. package/dist/fgca/nodes/FGCAFactorNode.d.ts +3 -3
  27. package/dist/fgca/nodes/FGCAFactorNode.js +5 -5
  28. package/dist/fgca/parse-canonical.js +15 -10
  29. package/dist/fgca/preview-layout.d.ts +1 -1
  30. package/dist/fgca/preview-layout.js +4 -4
  31. package/dist/fgca/resolver.js +3 -1
  32. package/dist/fgca/types.d.ts +11 -11
  33. package/dist/fgca/types.js +2 -2
  34. package/dist/fgca/validate.d.ts +2 -2
  35. package/dist/fgca/validate.js +17 -14
  36. package/dist/process-blueprint/index.d.ts +1 -1
  37. package/dist/process-blueprint/layout.js +64 -37
  38. package/dist/process-blueprint/types.d.ts +14 -0
  39. package/dist/scenarios/index.d.ts +1 -1
  40. package/dist/scenarios/types.d.ts +4 -4
  41. package/dist/theme/themes.js +2 -0
  42. package/dist/theme/tokens.d.ts +7 -1
  43. package/dist/theme/tokens.js +3 -1
  44. package/dist/webview/__tests__/entry-notations.test.js +2 -0
  45. package/dist/webview/__tests__/render-process.test.d.ts +1 -0
  46. package/dist/webview/__tests__/render-process.test.js +463 -0
  47. package/dist/webview/__tests__/render-util.test.d.ts +1 -0
  48. package/dist/webview/__tests__/render-util.test.js +54 -0
  49. package/dist/webview/entry.d.ts +1 -1
  50. package/dist/webview/entry.js +9 -5
  51. package/dist/webview/render-activities.d.ts +21 -1
  52. package/dist/webview/render-activities.js +91 -56
  53. package/dist/webview/render-activity-card.d.ts +11 -1
  54. package/dist/webview/render-activity-card.js +11 -2
  55. package/dist/webview/render-blocks.d.ts +24 -1
  56. package/dist/webview/render-blocks.js +58 -24
  57. package/dist/webview/render-fgca.d.ts +27 -0
  58. package/dist/webview/render-fgca.js +29 -15
  59. package/dist/webview/render-goals.d.ts +26 -1
  60. package/dist/webview/render-goals.js +30 -20
  61. package/dist/webview/render-process-blueprint.d.ts +11 -1
  62. package/dist/webview/render-process-blueprint.js +118 -53
  63. package/dist/webview/render-process.d.ts +95 -0
  64. package/dist/webview/render-process.js +392 -0
  65. package/dist/webview/render-scenarios.js +2 -2
  66. package/dist/webview/render-util.d.ts +19 -6
  67. package/dist/webview/render-util.js +23 -15
  68. package/package.json +15 -1
  69. package/src/activities/cpm.ts +14 -2
  70. package/src/activities/gantt.ts +6 -5
  71. package/src/activities/types.ts +1 -0
  72. package/src/activities/validate.ts +3 -3
  73. package/src/activity-card/__tests__/resolver.test.ts +24 -1
  74. package/src/activity-card/resolver.ts +12 -5
  75. package/src/compliance/__tests__/impact.test.ts +219 -0
  76. package/src/compliance/html.ts +1 -8
  77. package/src/compliance/impact.ts +141 -23
  78. package/src/factor/__tests__/validate.test.ts +3 -3
  79. package/src/factor/types.ts +1 -1
  80. package/src/factor/validate.ts +2 -2
  81. package/src/fgca/__tests__/chain-table.test.ts +2 -2
  82. package/src/fgca/__tests__/layout.test.ts +13 -13
  83. package/src/fgca/__tests__/preview-layout.test.ts +7 -7
  84. package/src/fgca/__tests__/resolver.test.ts +2 -2
  85. package/src/fgca/chain-table.ts +5 -5
  86. package/src/fgca/index.ts +3 -3
  87. package/src/fgca/layout.ts +11 -11
  88. package/src/fgca/nodeTypes.ts +3 -3
  89. package/src/fgca/nodes/FGCAFactorNode.tsx +6 -6
  90. package/src/fgca/parse-canonical.ts +17 -12
  91. package/src/fgca/preview-layout.ts +5 -5
  92. package/src/fgca/resolver.ts +3 -1
  93. package/src/fgca/types.ts +13 -13
  94. package/src/fgca/validate.ts +17 -14
  95. package/src/process-blueprint/index.ts +1 -0
  96. package/src/process-blueprint/layout.ts +71 -42
  97. package/src/process-blueprint/types.ts +15 -0
  98. package/src/scenarios/index.ts +2 -2
  99. package/src/scenarios/types.ts +4 -4
  100. package/src/scenarios/validate.ts +3 -3
  101. package/src/theme/themes.ts +2 -0
  102. package/src/theme/tokens.ts +3 -1
  103. package/src/webview/__tests__/entry-notations.test.ts +2 -0
  104. package/src/webview/__tests__/render-process.test.ts +538 -0
  105. package/src/webview/__tests__/render-util.test.ts +66 -0
  106. package/src/webview/entry.ts +11 -5
  107. package/src/webview/render-activities.ts +107 -67
  108. package/src/webview/render-activity-card.ts +11 -2
  109. package/src/webview/render-blocks.ts +78 -28
  110. package/src/webview/render-fgca.ts +52 -28
  111. package/src/webview/render-goals.ts +45 -23
  112. package/src/webview/render-process-blueprint.ts +156 -82
  113. package/src/webview/render-process.ts +507 -0
  114. package/src/webview/render-scenarios.ts +3 -3
  115. package/src/webview/render-util.ts +27 -14
@@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';
2
2
  import { validateFactor } from '../validate.js';
3
3
  function validExternal() {
4
4
  return {
5
- notation: 'factor',
5
+ notation: 'driver',
6
6
  id: 'FACTOR-EU-REG-1',
7
7
  name: 'EU regulatory window',
8
8
  type: 'external',
@@ -19,7 +19,7 @@ function validExternal() {
19
19
  }
20
20
  function validInternal() {
21
21
  return {
22
- notation: 'factor',
22
+ notation: 'driver',
23
23
  id: 'FACTOR-COMP-1',
24
24
  name: 'Support response time',
25
25
  type: 'internal',
@@ -60,7 +60,7 @@ describe('validateFactor — FACTOR-001 (shape / id grammar)', () => {
60
60
  expect(codes({ ...validExternal(), id: 'factor-1' })).toContain('FACTOR-001');
61
61
  });
62
62
  it('flags a wrong notation tag and a non-canon zone', () => {
63
- expect(codes({ ...validExternal(), notation: 'driver' })).toContain('FACTOR-001');
63
+ expect(codes({ ...validExternal(), notation: 'factor' })).toContain('FACTOR-001');
64
64
  expect(codes({ ...validExternal(), zone: 'sandbox' })).toContain('FACTOR-001');
65
65
  });
66
66
  it('flags a missing valid_to key (distinct from a null value)', () => {
@@ -4,7 +4,7 @@ export type FactorType = 'external' | 'internal';
4
4
  export declare const FACTOR_PESTLE_CATEGORIES: readonly ["political", "economic", "social", "technological", "legal", "environmental"];
5
5
  export type FactorPestleCategory = typeof FACTOR_PESTLE_CATEGORIES[number];
6
6
  export interface Factor {
7
- notation: 'factor';
7
+ notation: 'driver';
8
8
  id: string;
9
9
  name: string;
10
10
  type?: FactorType;
@@ -27,8 +27,8 @@ export function validateFactor(input, options = {}) {
27
27
  if (!isCanonicalIdOfType(f.id, 'FACTOR')) {
28
28
  errors.push({ code: 'FACTOR-001', message: `id "${String(f.id)}" must match FACTOR-[<middle>-]<INTEGER>.`, path: 'id' });
29
29
  }
30
- if (f.notation !== 'factor') {
31
- errors.push({ code: 'FACTOR-001', message: 'notation must be the fixed value "factor".', path: 'notation' });
30
+ if (f.notation !== 'driver') {
31
+ errors.push({ code: 'FACTOR-001', message: 'notation must be the fixed value "driver".', path: 'notation' });
32
32
  }
33
33
  if (f.zone !== undefined && f.zone !== 'canon') {
34
34
  errors.push({ code: 'FACTOR-001', message: 'zone must be "canon" for a FACTOR.', path: 'zone' });
@@ -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'] },
@@ -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) {
@@ -137,7 +142,7 @@ export function parseCanonicalFGCA(input) {
137
142
  }
138
143
  return { id, name: isNonEmptyString(name) ? name : '' };
139
144
  }
140
- factors.forEach((el, i) => checkLayerElement(el, `factors[${i}]`, FACTOR_ID_RE, factorIds));
145
+ factors.forEach((el, i) => checkLayerElement(el, `factors[${i}]`, FACTOR_OR_DRIVER_ID_RE, factorIds));
141
146
  goals.forEach((el, i) => checkLayerElement(el, `goals[${i}]`, GOAL_ID_RE, goalIds));
142
147
  changes.forEach((el, i) => checkLayerElement(el, `changes[${i}]`, CHANGE_ID_RE, changeIds));
143
148
  activities.forEach((el, i) => checkLayerElement(el, `activities[${i}]`, ACTIVITY_ID_RE, activityIds));
@@ -188,7 +193,7 @@ export function parseCanonicalFGCA(input) {
188
193
  name: String(el['name'] ?? ''),
189
194
  }));
190
195
  const internalGoals = goals.map((el, i) => {
191
- const refIds = checkRefArray(el, 'factors', factorIds, FACTOR_ID_RE, 'FGCA-008', `goals[${i}]`);
196
+ const refIds = checkRefArray(el, 'factors', factorIds, FACTOR_OR_DRIVER_ID_RE, 'FGCA-008', `goals[${i}]`);
192
197
  return {
193
198
  id: intId(String(el['id'])),
194
199
  name: String(el['name'] ?? ''),
@@ -261,7 +266,7 @@ export function parseCanonicalFGCA(input) {
261
266
  if (errors.length > 0)
262
267
  return { valid: false, errors, warnings };
263
268
  const parsed = {
264
- notation: 'fgca',
269
+ notation: raw['notation'] ?? 'dgca',
265
270
  spec_version: typeof raw['spec_version'] === 'string' ? raw['spec_version'] : undefined,
266
271
  factors: internalFactors,
267
272
  goals: internalGoals,
@@ -270,7 +275,7 @@ export function parseCanonicalFGCA(input) {
270
275
  };
271
276
  return { valid: true, errors, warnings, parsed };
272
277
  }
273
- const FGA_DOC_ID_RE = /^FGA(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
278
+ const FGA_DOC_ID_RE = /^(FGA|DGA)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
274
279
  /**
275
280
  * Canonical-form FGA parser + validator.
276
281
  *
@@ -293,10 +298,10 @@ export function parseCanonicalFGA(input) {
293
298
  return { valid: false, errors: [{ code: 'FGA-001', message: 'document root is not an object' }], warnings: [] };
294
299
  }
295
300
  const raw = input;
296
- if ('notation' in raw && raw['notation'] !== 'fga') {
301
+ if ('notation' in raw && raw['notation'] !== 'fga' && raw['notation'] !== 'dga') {
297
302
  return {
298
303
  valid: false,
299
- errors: [{ code: 'FGA-001', message: `notation must be "fga", got "${String(raw['notation'])}"` }],
304
+ errors: [{ code: 'FGA-001', message: `notation must be "dga" (or legacy "fga"), got "${String(raw['notation'])}"` }],
300
305
  warnings: [],
301
306
  };
302
307
  }
@@ -314,7 +319,7 @@ export function parseCanonicalFGA(input) {
314
319
  // changes. Per-layer / per-ref checks all reuse the FGCA implementation;
315
320
  // codes are remapped on the way out. FGCA-009 / 010 / 014 (changes-related)
316
321
  // are unreachable here because `changes` is empty.
317
- const synth = { ...raw, notation: 'fgca', id: 'FGCA-FROM-FGA-1', changes: [] };
322
+ const synth = { ...raw, notation: 'dgca', id: 'DGCA-FROM-DGA-1', changes: [] };
318
323
  const r = parseCanonicalFGCA(synth);
319
324
  const remap = {
320
325
  '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,30 @@
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
25
  }
26
26
  export interface ActivityTypeItem {
27
- id: number;
27
+ id: number | string;
28
28
  name?: string;
29
29
  }
30
30
  export interface DiagramStyle {
@@ -34,6 +34,6 @@ export interface DiagramStyle {
34
34
  edgeWidth?: number;
35
35
  }
36
36
  /** The four columns of the FGCA diagram. */
37
- export type FGCAColumn = "factor" | "goal" | "change" | "activity";
37
+ export type FGCAColumn = "driver" | "goal" | "change" | "activity";
38
38
  export declare const ALL_FGCA_COLUMNS: FGCAColumn[];
39
39
  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[];