@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.
- package/dist/activities/cpm.js +11 -2
- package/dist/activities/gantt.js +6 -3
- package/dist/activities/types.d.ts +1 -0
- package/dist/activities/validate.js +3 -3
- package/dist/activity-card/__tests__/resolver.test.js +22 -1
- package/dist/activity-card/resolver.js +11 -5
- package/dist/compliance/__tests__/impact.test.js +198 -0
- package/dist/compliance/html.js +1 -7
- package/dist/compliance/impact.d.ts +24 -1
- package/dist/compliance/impact.js +97 -21
- package/dist/factor/__tests__/validate.test.js +3 -3
- package/dist/factor/types.d.ts +1 -1
- package/dist/factor/validate.js +2 -2
- package/dist/fgca/__tests__/chain-table.test.js +2 -2
- package/dist/fgca/__tests__/layout.test.js +11 -11
- package/dist/fgca/__tests__/preview-layout.test.js +7 -7
- package/dist/fgca/__tests__/resolver.test.js +2 -2
- package/dist/fgca/chain-table.d.ts +1 -1
- package/dist/fgca/chain-table.js +4 -4
- package/dist/fgca/index.d.ts +2 -2
- package/dist/fgca/index.js +1 -1
- package/dist/fgca/layout.d.ts +2 -2
- package/dist/fgca/layout.js +9 -9
- package/dist/fgca/nodeTypes.d.ts +1 -1
- package/dist/fgca/nodeTypes.js +2 -2
- package/dist/fgca/nodes/FGCAFactorNode.d.ts +3 -3
- package/dist/fgca/nodes/FGCAFactorNode.js +5 -5
- package/dist/fgca/parse-canonical.js +15 -10
- package/dist/fgca/preview-layout.d.ts +1 -1
- package/dist/fgca/preview-layout.js +4 -4
- package/dist/fgca/resolver.js +3 -1
- package/dist/fgca/types.d.ts +11 -11
- package/dist/fgca/types.js +2 -2
- package/dist/fgca/validate.d.ts +2 -2
- package/dist/fgca/validate.js +17 -14
- package/dist/process-blueprint/index.d.ts +1 -1
- package/dist/process-blueprint/layout.js +64 -37
- package/dist/process-blueprint/types.d.ts +14 -0
- package/dist/scenarios/index.d.ts +1 -1
- package/dist/scenarios/types.d.ts +4 -4
- package/dist/theme/themes.js +2 -0
- package/dist/theme/tokens.d.ts +7 -1
- package/dist/theme/tokens.js +3 -1
- package/dist/webview/__tests__/entry-notations.test.js +2 -0
- package/dist/webview/__tests__/render-process.test.d.ts +1 -0
- package/dist/webview/__tests__/render-process.test.js +463 -0
- package/dist/webview/__tests__/render-util.test.d.ts +1 -0
- package/dist/webview/__tests__/render-util.test.js +54 -0
- package/dist/webview/entry.d.ts +1 -1
- package/dist/webview/entry.js +9 -5
- package/dist/webview/render-activities.d.ts +21 -1
- package/dist/webview/render-activities.js +91 -56
- package/dist/webview/render-activity-card.d.ts +11 -1
- package/dist/webview/render-activity-card.js +11 -2
- package/dist/webview/render-blocks.d.ts +24 -1
- package/dist/webview/render-blocks.js +58 -24
- package/dist/webview/render-fgca.d.ts +27 -0
- package/dist/webview/render-fgca.js +29 -15
- package/dist/webview/render-goals.d.ts +26 -1
- package/dist/webview/render-goals.js +30 -20
- package/dist/webview/render-process-blueprint.d.ts +11 -1
- package/dist/webview/render-process-blueprint.js +118 -53
- package/dist/webview/render-process.d.ts +95 -0
- package/dist/webview/render-process.js +392 -0
- package/dist/webview/render-scenarios.js +2 -2
- package/dist/webview/render-util.d.ts +19 -6
- package/dist/webview/render-util.js +23 -15
- package/package.json +15 -1
- package/src/activities/cpm.ts +14 -2
- package/src/activities/gantt.ts +6 -5
- package/src/activities/types.ts +1 -0
- package/src/activities/validate.ts +3 -3
- package/src/activity-card/__tests__/resolver.test.ts +24 -1
- package/src/activity-card/resolver.ts +12 -5
- package/src/compliance/__tests__/impact.test.ts +219 -0
- package/src/compliance/html.ts +1 -8
- package/src/compliance/impact.ts +141 -23
- package/src/factor/__tests__/validate.test.ts +3 -3
- package/src/factor/types.ts +1 -1
- package/src/factor/validate.ts +2 -2
- package/src/fgca/__tests__/chain-table.test.ts +2 -2
- package/src/fgca/__tests__/layout.test.ts +13 -13
- package/src/fgca/__tests__/preview-layout.test.ts +7 -7
- package/src/fgca/__tests__/resolver.test.ts +2 -2
- package/src/fgca/chain-table.ts +5 -5
- package/src/fgca/index.ts +3 -3
- package/src/fgca/layout.ts +11 -11
- package/src/fgca/nodeTypes.ts +3 -3
- package/src/fgca/nodes/FGCAFactorNode.tsx +6 -6
- package/src/fgca/parse-canonical.ts +17 -12
- package/src/fgca/preview-layout.ts +5 -5
- package/src/fgca/resolver.ts +3 -1
- package/src/fgca/types.ts +13 -13
- package/src/fgca/validate.ts +17 -14
- package/src/process-blueprint/index.ts +1 -0
- package/src/process-blueprint/layout.ts +71 -42
- package/src/process-blueprint/types.ts +15 -0
- package/src/scenarios/index.ts +2 -2
- package/src/scenarios/types.ts +4 -4
- package/src/scenarios/validate.ts +3 -3
- package/src/theme/themes.ts +2 -0
- package/src/theme/tokens.ts +3 -1
- package/src/webview/__tests__/entry-notations.test.ts +2 -0
- package/src/webview/__tests__/render-process.test.ts +538 -0
- package/src/webview/__tests__/render-util.test.ts +66 -0
- package/src/webview/entry.ts +11 -5
- package/src/webview/render-activities.ts +107 -67
- package/src/webview/render-activity-card.ts +11 -2
- package/src/webview/render-blocks.ts +78 -28
- package/src/webview/render-fgca.ts +52 -28
- package/src/webview/render-goals.ts +45 -23
- package/src/webview/render-process-blueprint.ts +156 -82
- package/src/webview/render-process.ts +507 -0
- package/src/webview/render-scenarios.ts +3 -3
- package/src/webview/render-util.ts +27 -14
|
@@ -9,12 +9,12 @@ beforeAll(() => {
|
|
|
9
9
|
});
|
|
10
10
|
|
|
11
11
|
import { buildFGCALayout } from "../layout";
|
|
12
|
-
import type {
|
|
12
|
+
import type { DriverItem, GoalItem, BdnChangeWithActivities, ActivityItem } from "../types";
|
|
13
13
|
import { ALL_FGCA_COLUMNS } from "../types";
|
|
14
14
|
|
|
15
15
|
const ALL_COLS = new Set(ALL_FGCA_COLUMNS);
|
|
16
16
|
|
|
17
|
-
const factors:
|
|
17
|
+
const factors: DriverItem[] = [
|
|
18
18
|
{ id: 1, name: "Digital growth" },
|
|
19
19
|
{ id: 2, name: "Talent shortage" },
|
|
20
20
|
];
|
|
@@ -50,16 +50,16 @@ describe("buildFGCALayout — all columns visible", () => {
|
|
|
50
50
|
|
|
51
51
|
it("assigns correct node types", () => {
|
|
52
52
|
const types = nodes.map((n) => n.type);
|
|
53
|
-
expect(types.filter((t) => t === "
|
|
53
|
+
expect(types.filter((t) => t === "fgcaDriver")).toHaveLength(factors.length);
|
|
54
54
|
expect(types.filter((t) => t === "fgcaGoal")).toHaveLength(goals.length);
|
|
55
55
|
expect(types.filter((t) => t === "fgcaChange")).toHaveLength(changes.length);
|
|
56
56
|
expect(types.filter((t) => t === "fgcaActivity")).toHaveLength(activities.length);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
59
|
it("creates Factor→Goal edges", () => {
|
|
60
|
-
const fgEdges = edges.filter((e) => e.source.startsWith("
|
|
60
|
+
const fgEdges = edges.filter((e) => e.source.startsWith("driver_") && e.target.startsWith("goal_"));
|
|
61
61
|
expect(fgEdges).toHaveLength(2);
|
|
62
|
-
expect(fgEdges.find((e) => e.source === "
|
|
62
|
+
expect(fgEdges.find((e) => e.source === "driver_1" && e.target === "goal_10")).toBeTruthy();
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
it("creates Goal→Change edges", () => {
|
|
@@ -85,7 +85,7 @@ describe("buildFGCALayout — all columns visible", () => {
|
|
|
85
85
|
});
|
|
86
86
|
|
|
87
87
|
it("encodes F-XXXX label format via id in node data", () => {
|
|
88
|
-
const factorNode = nodes.find((n) => n.id === "
|
|
88
|
+
const factorNode = nodes.find((n) => n.id === "driver_1");
|
|
89
89
|
expect(String(factorNode?.data.id).padStart(4, "0")).toBe("0001");
|
|
90
90
|
});
|
|
91
91
|
|
|
@@ -95,16 +95,16 @@ describe("buildFGCALayout — all columns visible", () => {
|
|
|
95
95
|
});
|
|
96
96
|
});
|
|
97
97
|
|
|
98
|
-
describe("buildFGCALayout —
|
|
99
|
-
const cols = new Set(ALL_FGCA_COLUMNS.filter((c) => c !== "
|
|
98
|
+
describe("buildFGCALayout — Driver column hidden", () => {
|
|
99
|
+
const cols = new Set(ALL_FGCA_COLUMNS.filter((c) => c !== "driver"));
|
|
100
100
|
const { nodes, edges } = buildFGCALayout({ factors, goals, changes, activities, visibleColumns: cols });
|
|
101
101
|
|
|
102
|
-
it("produces no
|
|
103
|
-
expect(nodes.filter((n) => n.type === "
|
|
102
|
+
it("produces no driver nodes", () => {
|
|
103
|
+
expect(nodes.filter((n) => n.type === "fgcaDriver")).toHaveLength(0);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
|
-
it("produces no
|
|
107
|
-
expect(edges.filter((e) => e.source.startsWith("
|
|
106
|
+
it("produces no Driver→Goal edges", () => {
|
|
107
|
+
expect(edges.filter((e) => e.source.startsWith("driver_"))).toHaveLength(0);
|
|
108
108
|
});
|
|
109
109
|
|
|
110
110
|
it("still produces Goal and downstream nodes", () => {
|
|
@@ -150,7 +150,7 @@ describe("buildFGCALayout — columns are positioned left to right", () => {
|
|
|
150
150
|
const { nodes } = buildFGCALayout({ factors, goals, changes, activities, visibleColumns: ALL_COLS });
|
|
151
151
|
|
|
152
152
|
it("factor column x < goal column x", () => {
|
|
153
|
-
const f = nodes.find((n) => n.type === "
|
|
153
|
+
const f = nodes.find((n) => n.type === "fgcaDriver")!;
|
|
154
154
|
const g = nodes.find((n) => n.type === "fgcaGoal")!;
|
|
155
155
|
expect(f.position.x).toBeLessThan(g.position.x);
|
|
156
156
|
});
|
|
@@ -25,7 +25,7 @@ const doc: FGCAPreviewDoc = {
|
|
|
25
25
|
describe('layoutFGCAPreview', () => {
|
|
26
26
|
it('lays out all four columns in order (FGCA)', () => {
|
|
27
27
|
const layout = layoutFGCAPreview(doc);
|
|
28
|
-
expect(layout.columns.map(c => c.col)).toEqual(['
|
|
28
|
+
expect(layout.columns.map(c => c.col)).toEqual(['driver', 'goal', 'change', 'activity']);
|
|
29
29
|
// 2 factors + 2 goals + 1 change + 2 activities
|
|
30
30
|
expect(layout.nodes).toHaveLength(7);
|
|
31
31
|
expect(layout.width).toBeGreaterThan(0);
|
|
@@ -40,7 +40,7 @@ describe('layoutFGCAPreview', () => {
|
|
|
40
40
|
|
|
41
41
|
it('hideChanges (FGA) drops the Changes column and links goals to activities', () => {
|
|
42
42
|
const layout = layoutFGCAPreview(doc, { hideChanges: true });
|
|
43
|
-
expect(layout.columns.map(c => c.col)).toEqual(['
|
|
43
|
+
expect(layout.columns.map(c => c.col)).toEqual(['driver', 'goal', 'activity']);
|
|
44
44
|
// 2 factors + 2 goals + 2 activities
|
|
45
45
|
expect(layout.nodes).toHaveLength(6);
|
|
46
46
|
// F1→G1, F2→G2 (2), G1→A1, G2→A2 (2) = 4
|
|
@@ -70,7 +70,7 @@ describe('layoutFGCAPreview', () => {
|
|
|
70
70
|
|
|
71
71
|
it('larger rowGap increases the gap between stacked nodes', () => {
|
|
72
72
|
const gapOf = (rowGap: number) => {
|
|
73
|
-
const factors = layoutFGCAPreview(doc, { rowGap }).nodes.filter(n => n.col === '
|
|
73
|
+
const factors = layoutFGCAPreview(doc, { rowGap }).nodes.filter(n => n.col === 'driver');
|
|
74
74
|
return factors[1].y - factors[0].y;
|
|
75
75
|
};
|
|
76
76
|
expect(gapOf(120)).toBeGreaterThan(gapOf(20));
|
|
@@ -86,15 +86,15 @@ describe('layoutFGCAPreview', () => {
|
|
|
86
86
|
// root 10 → factor 1 (referenced by G10), change 20 (goal_id 10),
|
|
87
87
|
// activity 30 (via change 20). G11/F2/A31 are dropped.
|
|
88
88
|
const layout = layoutFGCAPreview(doc, { scope: { mode: 'root', rootGoalId: '10' } });
|
|
89
|
-
expect(idsOf(layout)).toEqual(new Set(['
|
|
89
|
+
expect(idsOf(layout)).toEqual(new Set(['driver_1', 'goal_10', 'change_20', 'activity_30']));
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it("mode 'root' filters factors and activities to those touching the visible goal", () => {
|
|
93
93
|
// root 11 → factor 2, activity 31 (direct goal link); no change touches G11.
|
|
94
94
|
const layout = layoutFGCAPreview(doc, { scope: { mode: 'root', rootGoalId: '11' } });
|
|
95
|
-
expect(idsOf(layout)).toEqual(new Set(['
|
|
95
|
+
expect(idsOf(layout)).toEqual(new Set(['driver_2', 'goal_11', 'activity_31']));
|
|
96
96
|
// F1, A30, C20 (which only touch the hidden G10) are excluded.
|
|
97
|
-
expect(layout.nodes.some(n => n.id === '
|
|
97
|
+
expect(layout.nodes.some(n => n.id === 'driver_1')).toBe(false);
|
|
98
98
|
expect(layout.nodes.some(n => n.id === 'activity_30')).toBe(false);
|
|
99
99
|
});
|
|
100
100
|
|
|
@@ -112,7 +112,7 @@ describe('layoutFGCAPreview', () => {
|
|
|
112
112
|
],
|
|
113
113
|
};
|
|
114
114
|
const layout = layoutFGCAPreview(leveled, { scope: { mode: 'level', maxLevel: 0 } });
|
|
115
|
-
expect(idsOf(layout)).toEqual(new Set(['
|
|
115
|
+
expect(idsOf(layout)).toEqual(new Set(['driver_1', 'goal_10', 'activity_30']));
|
|
116
116
|
});
|
|
117
117
|
|
|
118
118
|
it("mode 'root' returns an empty layout when the root is absent", () => {
|
|
@@ -8,8 +8,8 @@ import { parseCanonicalFGCA } from '../parse-canonical.js';
|
|
|
8
8
|
// ── Inline canon element store (mirrors strategy-2026 data split into per-element form) ─
|
|
9
9
|
|
|
10
10
|
const ELEMENTS = [
|
|
11
|
-
{ notation: '
|
|
12
|
-
{ notation: '
|
|
11
|
+
{ notation: 'driver', id: 'FACTOR-1', name: 'Competitive market pressure', type: 'external' },
|
|
12
|
+
{ notation: 'driver', id: 'FACTOR-2', name: 'Digital adoption acceleration', type: 'external' },
|
|
13
13
|
{ notation: 'goal', id: 'GOAL-1', name: 'Grow revenue by 20%', factors: ['FACTOR-1', 'FACTOR-2'] },
|
|
14
14
|
{ notation: 'goal', id: 'GOAL-2', name: 'Reduce operational costs', factors: ['FACTOR-2'] },
|
|
15
15
|
{ notation: 'goal', id: 'GOAL-3', name: 'Improve customer retention', factors: ['FACTOR-1'] },
|
package/src/fgca/chain-table.ts
CHANGED
|
@@ -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
|
|
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.
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import type { FGCAPreviewDoc } from './preview-layout.js';
|
|
25
25
|
|
|
26
|
-
export type ChainColumn = '
|
|
26
|
+
export type ChainColumn = 'driver' | 'goal' | 'change' | 'activity';
|
|
27
27
|
|
|
28
28
|
export interface ChainCell {
|
|
29
29
|
/** Column-qualified identity (e.g. "goal:3") — stable, unique across columns. */
|
|
@@ -76,8 +76,8 @@ function sameCell(a: ChainCell | null, b: ChainCell | null): boolean {
|
|
|
76
76
|
export function buildChainTable(doc: FGCAPreviewDoc, options: ChainTableOptions = {}): ChainTable {
|
|
77
77
|
const { hideChanges = false } = options;
|
|
78
78
|
const columns: ChainColumn[] = hideChanges
|
|
79
|
-
? ['
|
|
80
|
-
: ['
|
|
79
|
+
? ['driver', 'goal', 'activity']
|
|
80
|
+
: ['driver', 'goal', 'change', 'activity'];
|
|
81
81
|
|
|
82
82
|
const changes = doc.changes ?? [];
|
|
83
83
|
const factorIds = new Set(doc.factors.map(f => f.id));
|
|
@@ -146,7 +146,7 @@ export function buildChainTable(doc: FGCAPreviewDoc, options: ChainTableOptions
|
|
|
146
146
|
|
|
147
147
|
// Phase 1 — factor-rooted paths.
|
|
148
148
|
for (const f of doc.factors) {
|
|
149
|
-
const factorCell = cellOf('
|
|
149
|
+
const factorCell = cellOf('driver', f.id, f.name);
|
|
150
150
|
const goalsOfFactor = doc.goals.filter(g => (g.factor ?? []).some(ref => ref.id === f.id));
|
|
151
151
|
if (goalsOfFactor.length === 0) {
|
|
152
152
|
paths.push(pad([factorCell]));
|
package/src/fgca/index.ts
CHANGED
|
@@ -28,7 +28,7 @@ export {
|
|
|
28
28
|
FGCA_COLUMN_LABELS,
|
|
29
29
|
} from "./types";
|
|
30
30
|
export type {
|
|
31
|
-
|
|
31
|
+
DriverItem,
|
|
32
32
|
GoalItem,
|
|
33
33
|
BdnChangeWithActivities,
|
|
34
34
|
ActivityItem,
|
|
@@ -38,10 +38,10 @@ export type {
|
|
|
38
38
|
} from "./types";
|
|
39
39
|
export { resolveFGCA, isFGCAViewDoc } from './resolver.js';
|
|
40
40
|
export type { FGCAViewConfig, FGCACanonSources } from './resolver.js';
|
|
41
|
-
export { default as
|
|
41
|
+
export { default as FGCADriverNode } from "./nodes/FGCAFactorNode";
|
|
42
42
|
export { default as FGCAGoalNode } from "./nodes/FGCAGoalNode";
|
|
43
43
|
export { default as FGCAChangeNode } from "./nodes/FGCAChangeNode";
|
|
44
44
|
export { default as FGCAActivityNode } from "./nodes/FGCAActivityNode";
|
|
45
45
|
|
|
46
46
|
/** ReactFlow nodeTypes map — pass directly to <ReactFlow nodeTypes={FGCA_NODE_TYPES} /> */
|
|
47
|
-
export { FGCA_NODE_TYPES } from "./nodeTypes";
|
|
47
|
+
export { FGCA_NODE_TYPES } from "./nodeTypes";
|
package/src/fgca/layout.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Node, Edge } from "reactflow";
|
|
2
2
|
import { Position, MarkerType } from "reactflow";
|
|
3
3
|
import type {
|
|
4
|
-
|
|
4
|
+
DriverItem,
|
|
5
5
|
GoalItem,
|
|
6
6
|
BdnChangeWithActivities,
|
|
7
7
|
ActivityItem,
|
|
@@ -18,14 +18,14 @@ export const ROW_GAP = 24;
|
|
|
18
18
|
|
|
19
19
|
/** Default background colours per column. */
|
|
20
20
|
export const COLUMN_BG: Record<FGCAColumn, string> = {
|
|
21
|
-
|
|
21
|
+
driver: "#fef3c7",
|
|
22
22
|
goal: "#e0e7ff",
|
|
23
23
|
change: "#dbeafe",
|
|
24
24
|
activity: "#d4edda",
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
export interface FGCALayoutInput {
|
|
28
|
-
factors:
|
|
28
|
+
factors: DriverItem[];
|
|
29
29
|
goals: GoalItem[];
|
|
30
30
|
changes: BdnChangeWithActivities[];
|
|
31
31
|
activities: ActivityItem[];
|
|
@@ -66,12 +66,12 @@ export function buildFGCALayout({
|
|
|
66
66
|
const edgeStyle = { strokeWidth: edgeWidth, stroke: edgeColor };
|
|
67
67
|
const baseNodeStyle = { borderColor: nodeBorderColor, borderWidth: nodeBorderWidth, borderStyle: "solid" };
|
|
68
68
|
|
|
69
|
-
if (visibleColumns.has("
|
|
69
|
+
if (visibleColumns.has("driver")) {
|
|
70
70
|
factors.forEach((f, i) => {
|
|
71
71
|
nodes.push({
|
|
72
|
-
id: `
|
|
73
|
-
type: "
|
|
74
|
-
position: { x: colX["
|
|
72
|
+
id: `driver_${f.id}`,
|
|
73
|
+
type: "fgcaDriver",
|
|
74
|
+
position: { x: colX["driver"]!, y: i * (NODE_HEIGHT + ROW_GAP) },
|
|
75
75
|
data: { id: f.id, name: f.name, ...baseNodeStyle },
|
|
76
76
|
sourcePosition: Position.Right,
|
|
77
77
|
targetPosition: Position.Left,
|
|
@@ -132,13 +132,13 @@ export function buildFGCALayout({
|
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
//
|
|
136
|
-
if (visibleColumns.has("
|
|
135
|
+
// Driver→Goal edges (via embedded factor[] on each goal)
|
|
136
|
+
if (visibleColumns.has("driver") && visibleColumns.has("goal")) {
|
|
137
137
|
goals.forEach((g) => {
|
|
138
138
|
g.factor?.forEach((f) => {
|
|
139
139
|
edges.push({
|
|
140
|
-
id: `
|
|
141
|
-
source: `
|
|
140
|
+
id: `edge_d${f.id}_g${g.id}`,
|
|
141
|
+
source: `driver_${f.id}`,
|
|
142
142
|
target: `goal_${g.id}`,
|
|
143
143
|
markerEnd: { type: MarkerType.ArrowClosed },
|
|
144
144
|
type: "smoothstep",
|
package/src/fgca/nodeTypes.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import
|
|
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
|
|
|
6
6
|
export const FGCA_NODE_TYPES = {
|
|
7
|
-
|
|
7
|
+
fgcaDriver: FGCADriverNode,
|
|
8
8
|
fgcaGoal: FGCAGoalNode,
|
|
9
9
|
fgcaChange: FGCAChangeNode,
|
|
10
10
|
fgcaActivity: FGCAActivityNode,
|
|
11
|
-
} as const;
|
|
11
|
+
} as const;
|
|
@@ -4,7 +4,7 @@ import { Handle, Position } from "reactflow";
|
|
|
4
4
|
const NODE_WIDTH = 250;
|
|
5
5
|
const NODE_HEIGHT = 80;
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface FGCADriverNodeProps {
|
|
8
8
|
data: {
|
|
9
9
|
id: number;
|
|
10
10
|
name: string;
|
|
@@ -14,10 +14,10 @@ export interface FGCAFactorNodeProps {
|
|
|
14
14
|
isConnectable?: boolean;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const FGCADriverNode = memo(({ data, isConnectable }: FGCADriverNodeProps) => (
|
|
18
18
|
<div
|
|
19
19
|
style={{
|
|
20
|
-
background: "var(--ts-layer-
|
|
20
|
+
background: "var(--ts-layer-driver)",
|
|
21
21
|
width: NODE_WIDTH,
|
|
22
22
|
height: NODE_HEIGHT,
|
|
23
23
|
padding: "6px 8px",
|
|
@@ -54,11 +54,11 @@ const FGCAFactorNode = memo(({ data, isConnectable }: FGCAFactorNodeProps) => (
|
|
|
54
54
|
{data.name}
|
|
55
55
|
</div>
|
|
56
56
|
<div style={{ fontSize: "10px", color: "var(--ts-text-secondary)", marginTop: 2 }}>
|
|
57
|
-
|
|
57
|
+
D-{String(data.id).padStart(4, "0")}
|
|
58
58
|
</div>
|
|
59
59
|
</div>
|
|
60
60
|
));
|
|
61
61
|
|
|
62
|
-
|
|
62
|
+
FGCADriverNode.displayName = "FGCADriverNode";
|
|
63
63
|
|
|
64
|
-
export default
|
|
64
|
+
export default FGCADriverNode;
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
import type {
|
|
28
28
|
ActivityItem,
|
|
29
29
|
BdnChangeWithActivities,
|
|
30
|
-
|
|
30
|
+
DriverItem,
|
|
31
31
|
GoalItem,
|
|
32
32
|
} from './types.js';
|
|
33
33
|
import type { FGCADoc } from './validate.js';
|
|
@@ -46,10 +46,12 @@ export interface CanonicalFGCAResult extends ValidationResult {
|
|
|
46
46
|
// is fixed per layer; middle segments are optional; the terminal is a
|
|
47
47
|
// positive integer with no leading zeros.
|
|
48
48
|
const FACTOR_ID_RE = /^FACTOR(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
49
|
+
const DRIVER_ID_RE = /^DRIVER(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
50
|
+
const FACTOR_OR_DRIVER_ID_RE = /^(FACTOR|DRIVER)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
49
51
|
const GOAL_ID_RE = /^GOAL(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
50
52
|
const CHANGE_ID_RE = /^CHANGE(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
51
53
|
const ACTIVITY_ID_RE = /^ACTIVITY(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
52
|
-
const FGCA_DOC_ID_RE = /^FGCA(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
54
|
+
const FGCA_DOC_ID_RE = /^(FGCA|DGCA)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
53
55
|
const CONSTRAINT_ID_RE = /^CONSTRAINT(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
54
56
|
|
|
55
57
|
function isNonEmptyString(v: unknown): v is string {
|
|
@@ -84,18 +86,21 @@ export function parseCanonicalFGCA(input: unknown): CanonicalFGCAResult {
|
|
|
84
86
|
|
|
85
87
|
const raw = input as Record<string, unknown>;
|
|
86
88
|
|
|
87
|
-
if ('notation' in raw && raw['notation'] !== 'fgca') {
|
|
89
|
+
if ('notation' in raw && raw['notation'] !== 'fgca' && raw['notation'] !== 'dgca') {
|
|
88
90
|
return {
|
|
89
91
|
valid: false,
|
|
90
92
|
errors: [
|
|
91
93
|
{
|
|
92
94
|
code: 'FGCA-001',
|
|
93
|
-
message: `notation must be "fgca", got "${String(raw['notation'])}"`,
|
|
95
|
+
message: `notation must be "dgca" (or legacy "fgca"), got "${String(raw['notation'])}"`,
|
|
94
96
|
},
|
|
95
97
|
],
|
|
96
98
|
warnings,
|
|
97
99
|
};
|
|
98
100
|
}
|
|
101
|
+
if ('notation' in raw && raw['notation'] === 'fgca') {
|
|
102
|
+
warnings.push({ code: 'FGCA-001', message: 'notation "fgca" is deprecated — rename to "dgca"' });
|
|
103
|
+
}
|
|
99
104
|
|
|
100
105
|
// FGCA-002 — document id (optional in v1.4 per the canonical spec? — spec
|
|
101
106
|
// says required; absence is FGCA-002).
|
|
@@ -173,7 +178,7 @@ export function parseCanonicalFGCA(input: unknown): CanonicalFGCAResult {
|
|
|
173
178
|
return { id, name: isNonEmptyString(name) ? name : '' };
|
|
174
179
|
}
|
|
175
180
|
|
|
176
|
-
factors.forEach((el, i) => checkLayerElement(el, `factors[${i}]`,
|
|
181
|
+
factors.forEach((el, i) => checkLayerElement(el, `factors[${i}]`, FACTOR_OR_DRIVER_ID_RE, factorIds));
|
|
177
182
|
goals.forEach((el, i) => checkLayerElement(el, `goals[${i}]`, GOAL_ID_RE, goalIds));
|
|
178
183
|
changes.forEach((el, i) => checkLayerElement(el, `changes[${i}]`, CHANGE_ID_RE, changeIds));
|
|
179
184
|
activities.forEach((el, i) => checkLayerElement(el, `activities[${i}]`, ACTIVITY_ID_RE, activityIds));
|
|
@@ -229,13 +234,13 @@ export function parseCanonicalFGCA(input: unknown): CanonicalFGCAResult {
|
|
|
229
234
|
}
|
|
230
235
|
|
|
231
236
|
// Layer entries (internal form).
|
|
232
|
-
const internalFactors:
|
|
237
|
+
const internalFactors: DriverItem[] = factors.map((el) => ({
|
|
233
238
|
id: intId(String(el!['id'])),
|
|
234
239
|
name: String(el!['name'] ?? ''),
|
|
235
240
|
}));
|
|
236
241
|
|
|
237
242
|
const internalGoals: GoalItem[] = goals.map((el, i) => {
|
|
238
|
-
const refIds = checkRefArray(el!, 'factors', factorIds,
|
|
243
|
+
const refIds = checkRefArray(el!, 'factors', factorIds, FACTOR_OR_DRIVER_ID_RE, 'FGCA-008', `goals[${i}]`);
|
|
239
244
|
return {
|
|
240
245
|
id: intId(String(el!['id'])),
|
|
241
246
|
name: String(el!['name'] ?? ''),
|
|
@@ -313,7 +318,7 @@ export function parseCanonicalFGCA(input: unknown): CanonicalFGCAResult {
|
|
|
313
318
|
if (errors.length > 0) return { valid: false, errors, warnings };
|
|
314
319
|
|
|
315
320
|
const parsed: FGCADoc = {
|
|
316
|
-
notation: '
|
|
321
|
+
notation: (raw['notation'] as string) ?? 'dgca',
|
|
317
322
|
spec_version: typeof raw['spec_version'] === 'string' ? (raw['spec_version'] as string) : undefined,
|
|
318
323
|
factors: internalFactors,
|
|
319
324
|
goals: internalGoals,
|
|
@@ -324,7 +329,7 @@ export function parseCanonicalFGCA(input: unknown): CanonicalFGCAResult {
|
|
|
324
329
|
return { valid: true, errors, warnings, parsed };
|
|
325
330
|
}
|
|
326
331
|
|
|
327
|
-
const FGA_DOC_ID_RE = /^FGA(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
332
|
+
const FGA_DOC_ID_RE = /^(FGA|DGA)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
328
333
|
|
|
329
334
|
/** On success, the internal-form FGCADoc derived from canonical FGA input. */
|
|
330
335
|
export interface CanonicalFGAResult extends ValidationResult {
|
|
@@ -353,10 +358,10 @@ export function parseCanonicalFGA(input: unknown): CanonicalFGAResult {
|
|
|
353
358
|
return { valid: false, errors: [{ code: 'FGA-001', message: 'document root is not an object' }], warnings: [] };
|
|
354
359
|
}
|
|
355
360
|
const raw = input as Record<string, unknown>;
|
|
356
|
-
if ('notation' in raw && raw['notation'] !== 'fga') {
|
|
361
|
+
if ('notation' in raw && raw['notation'] !== 'fga' && raw['notation'] !== 'dga') {
|
|
357
362
|
return {
|
|
358
363
|
valid: false,
|
|
359
|
-
errors: [{ code: 'FGA-001', message: `notation must be "fga", got "${String(raw['notation'])}"` }],
|
|
364
|
+
errors: [{ code: 'FGA-001', message: `notation must be "dga" (or legacy "fga"), got "${String(raw['notation'])}"` }],
|
|
360
365
|
warnings: [],
|
|
361
366
|
};
|
|
362
367
|
}
|
|
@@ -375,7 +380,7 @@ export function parseCanonicalFGA(input: unknown): CanonicalFGAResult {
|
|
|
375
380
|
// changes. Per-layer / per-ref checks all reuse the FGCA implementation;
|
|
376
381
|
// codes are remapped on the way out. FGCA-009 / 010 / 014 (changes-related)
|
|
377
382
|
// are unreachable here because `changes` is empty.
|
|
378
|
-
const synth = { ...raw, notation: '
|
|
383
|
+
const synth = { ...raw, notation: 'dgca', id: 'DGCA-FROM-DGA-1', changes: [] };
|
|
379
384
|
const r = parseCanonicalFGCA(synth);
|
|
380
385
|
const remap: Record<string, string> = {
|
|
381
386
|
'FGCA-001': 'FGA-001',
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type { Scope } from '../scope.js';
|
|
11
11
|
|
|
12
|
-
export type FGCAPreviewColumn = '
|
|
12
|
+
export type FGCAPreviewColumn = 'driver' | 'goal' | 'change' | 'activity';
|
|
13
13
|
|
|
14
14
|
export interface FGCAPreviewFactor {
|
|
15
15
|
id: number | string;
|
|
@@ -144,11 +144,11 @@ export function layoutFGCAPreview(
|
|
|
144
144
|
|
|
145
145
|
const colStride = FGCA_NODE_W + colGap;
|
|
146
146
|
const cols: FGCAPreviewColumn[] = hideChanges
|
|
147
|
-
? ['
|
|
148
|
-
: ['
|
|
147
|
+
? ['driver', 'goal', 'activity']
|
|
148
|
+
: ['driver', 'goal', 'change', 'activity'];
|
|
149
149
|
const changes = doc.changes ?? [];
|
|
150
150
|
const colItems: Record<FGCAPreviewColumn, Array<{ id: string; label: string }>> = {
|
|
151
|
-
|
|
151
|
+
driver: doc.factors.map(f => ({ id: `driver_${f.id}`, label: f.name })),
|
|
152
152
|
goal: doc.goals.map(g => ({ id: `goal_${g.id}`, label: g.name })),
|
|
153
153
|
change: changes.map(c => ({ id: `change_${c.id}`, label: c.name })),
|
|
154
154
|
activity: doc.activities.map(a => ({ id: `activity_${a.id}`, label: a.name })),
|
|
@@ -180,7 +180,7 @@ export function layoutFGCAPreview(
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
for (const g of doc.goals) {
|
|
183
|
-
for (const f of (g.factor ?? [])) addEdge(`
|
|
183
|
+
for (const f of (g.factor ?? [])) addEdge(`driver_${f.id}`, `goal_${g.id}`);
|
|
184
184
|
}
|
|
185
185
|
if (hideChanges) {
|
|
186
186
|
const connectedViaChange = new Set<number | string>();
|
package/src/fgca/resolver.ts
CHANGED
|
@@ -86,7 +86,9 @@ export function resolveFGCA(
|
|
|
86
86
|
const changesConf = isObject(vc['changes']) ? vc['changes'] : {};
|
|
87
87
|
const activitiesConf = isObject(vc['activities']) ? vc['activities'] : {};
|
|
88
88
|
|
|
89
|
-
const
|
|
89
|
+
const factorElemsLegacy = collectByNotation(sources.elements, 'factor');
|
|
90
|
+
const factorElemsNew = collectByNotation(sources.elements, 'driver');
|
|
91
|
+
const factorElems = new Map([...factorElemsLegacy, ...factorElemsNew]);
|
|
90
92
|
const goalElems = collectByNotation(sources.elements, 'goal');
|
|
91
93
|
const changeElems = collectByNotation(sources.elements, 'change');
|
|
92
94
|
const activityElems = collectByNotation(sources.elements, 'activity');
|
package/src/fgca/types.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
id: number;
|
|
1
|
+
export interface DriverItem {
|
|
2
|
+
id: number | string;
|
|
3
3
|
name: string;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
export interface GoalItem {
|
|
7
|
-
id: number;
|
|
7
|
+
id: number | string;
|
|
8
8
|
name: string;
|
|
9
9
|
level?: number;
|
|
10
10
|
/** Goals may carry embedded factor links returned by the API. */
|
|
11
|
-
factor?: Array<{ id: number }>;
|
|
11
|
+
factor?: Array<{ 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
|
|
|
21
21
|
export interface ActivityItem {
|
|
22
|
-
id: number;
|
|
22
|
+
id: number | string;
|
|
23
23
|
name: string;
|
|
24
|
-
goal_id?: number | null;
|
|
24
|
+
goal_id?: number | string | null;
|
|
25
25
|
activity_type_id?: number;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export interface ActivityTypeItem {
|
|
29
|
-
id: number;
|
|
29
|
+
id: number | string;
|
|
30
30
|
name?: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -38,12 +38,12 @@ export interface DiagramStyle {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
/** The four columns of the FGCA diagram. */
|
|
41
|
-
export type FGCAColumn = "
|
|
41
|
+
export type FGCAColumn = "driver" | "goal" | "change" | "activity";
|
|
42
42
|
|
|
43
|
-
export const ALL_FGCA_COLUMNS: FGCAColumn[] = ["
|
|
43
|
+
export const ALL_FGCA_COLUMNS: FGCAColumn[] = ["driver", "goal", "change", "activity"];
|
|
44
44
|
|
|
45
45
|
export const FGCA_COLUMN_LABELS: Record<FGCAColumn, string> = {
|
|
46
|
-
|
|
46
|
+
driver: "D",
|
|
47
47
|
goal: "G",
|
|
48
48
|
change: "C",
|
|
49
49
|
activity: "A",
|
package/src/fgca/validate.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DriverItem, GoalItem, BdnChangeWithActivities, ActivityItem } from './types.js';
|
|
2
2
|
import type {
|
|
3
3
|
ValidationError,
|
|
4
4
|
ValidationWarning,
|
|
@@ -15,7 +15,7 @@ export type FGCAValidationResult = ValidationResult;
|
|
|
15
15
|
export interface FGCADoc {
|
|
16
16
|
notation: string;
|
|
17
17
|
spec_version?: string;
|
|
18
|
-
factors:
|
|
18
|
+
factors: DriverItem[];
|
|
19
19
|
goals: GoalItem[];
|
|
20
20
|
changes: BdnChangeWithActivities[];
|
|
21
21
|
activities: ActivityItem[];
|
|
@@ -35,10 +35,13 @@ export function validateFGCADoc(input: unknown): FGCAValidationResult {
|
|
|
35
35
|
errors.push({ code: 'MISSING_NOTATION', message: 'notation field is required' });
|
|
36
36
|
return { valid: false, errors, warnings };
|
|
37
37
|
}
|
|
38
|
-
if (raw.notation !== 'fgca') {
|
|
39
|
-
errors.push({ code: 'WRONG_NOTATION', message: `notation must be "fgca", got "${String(raw.notation)}"` });
|
|
38
|
+
if (raw.notation !== 'fgca' && raw.notation !== 'dgca') {
|
|
39
|
+
errors.push({ code: 'WRONG_NOTATION', message: `notation must be "dgca" (or legacy "fgca"), got "${String(raw.notation)}"` });
|
|
40
40
|
return { valid: false, errors, warnings };
|
|
41
41
|
}
|
|
42
|
+
if (raw.notation === 'fgca') {
|
|
43
|
+
warnings.push({ code: 'DEPRECATED_NOTATION', message: 'notation "fgca" is deprecated — rename to "dgca"' });
|
|
44
|
+
}
|
|
42
45
|
|
|
43
46
|
if (!Array.isArray(raw.factors)) errors.push({ code: 'SCHEMA_INVALID', message: 'factors must be an array', path: 'factors' });
|
|
44
47
|
if (!Array.isArray(raw.goals)) errors.push({ code: 'SCHEMA_INVALID', message: 'goals must be an array', path: 'goals' });
|
|
@@ -47,12 +50,12 @@ export function validateFGCADoc(input: unknown): FGCAValidationResult {
|
|
|
47
50
|
if (errors.length > 0) return { valid: false, errors, warnings };
|
|
48
51
|
|
|
49
52
|
const doc = raw as unknown as FGCADoc;
|
|
50
|
-
const collectIds = (arr: unknown[]): Set<number> => {
|
|
51
|
-
const out = new Set<number>();
|
|
53
|
+
const collectIds = (arr: unknown[]): Set<number | string> => {
|
|
54
|
+
const out = new Set<number | string>();
|
|
52
55
|
for (const el of arr) {
|
|
53
56
|
if (el && typeof el === 'object') {
|
|
54
57
|
const id = (el as { id?: unknown }).id;
|
|
55
|
-
if (typeof id === 'number') out.add(id);
|
|
58
|
+
if (typeof id === 'number' || typeof id === 'string') out.add(id);
|
|
56
59
|
}
|
|
57
60
|
}
|
|
58
61
|
return out;
|
|
@@ -68,7 +71,7 @@ export function validateFGCADoc(input: unknown): FGCAValidationResult {
|
|
|
68
71
|
continue;
|
|
69
72
|
}
|
|
70
73
|
const factor = f as { id?: unknown; name?: unknown };
|
|
71
|
-
if (typeof factor.id !== 'number') errors.push({ code: 'SCHEMA_INVALID', message: 'factor id must be a number', path: `factors[${i}]` });
|
|
74
|
+
if (typeof factor.id !== 'number' && typeof factor.id !== 'string') errors.push({ code: 'SCHEMA_INVALID', message: 'factor id must be a number or string', path: `factors[${i}]` });
|
|
72
75
|
if (typeof factor.name !== 'string' || !factor.name.trim()) errors.push({ code: 'EMPTY_NAME', message: `Factor ${String(factor.id)} has empty name`, path: `factors[${i}]` });
|
|
73
76
|
}
|
|
74
77
|
|
|
@@ -79,13 +82,13 @@ export function validateFGCADoc(input: unknown): FGCAValidationResult {
|
|
|
79
82
|
continue;
|
|
80
83
|
}
|
|
81
84
|
const goal = g as { id?: unknown; name?: unknown; factor?: unknown };
|
|
82
|
-
if (typeof goal.id !== 'number') errors.push({ code: 'SCHEMA_INVALID', message: 'goal id must be a number', path: `goals[${i}]` });
|
|
85
|
+
if (typeof goal.id !== 'number' && typeof goal.id !== 'string') errors.push({ code: 'SCHEMA_INVALID', message: 'goal id must be a number or string', path: `goals[${i}]` });
|
|
83
86
|
if (typeof goal.name !== 'string' || !goal.name.trim()) errors.push({ code: 'EMPTY_NAME', message: `Goal ${String(goal.id)} has empty name`, path: `goals[${i}]` });
|
|
84
87
|
const factorRefs = Array.isArray(goal.factor) ? (goal.factor as unknown[]) : [];
|
|
85
88
|
for (const fr of factorRefs) {
|
|
86
89
|
if (!fr || typeof fr !== 'object') continue;
|
|
87
90
|
const fid = (fr as { id?: unknown }).id;
|
|
88
|
-
if (typeof fid === 'number' && !factorIds.has(fid)) {
|
|
91
|
+
if ((typeof fid === 'number' || typeof fid === 'string') && !factorIds.has(fid)) {
|
|
89
92
|
warnings.push({ code: 'BROKEN_REF', message: `Goal ${String(goal.id)} references missing factor ${fid}`, path: `goals[${i}].factor` });
|
|
90
93
|
}
|
|
91
94
|
}
|
|
@@ -98,14 +101,14 @@ export function validateFGCADoc(input: unknown): FGCAValidationResult {
|
|
|
98
101
|
continue;
|
|
99
102
|
}
|
|
100
103
|
const change = c as { id?: unknown; name?: unknown; goal_id?: unknown; activity_ids?: unknown };
|
|
101
|
-
if (typeof change.id !== 'number') errors.push({ code: 'SCHEMA_INVALID', message: 'change id must be a number', path: `changes[${i}]` });
|
|
104
|
+
if (typeof change.id !== 'number' && typeof change.id !== 'string') errors.push({ code: 'SCHEMA_INVALID', message: 'change id must be a number or string', path: `changes[${i}]` });
|
|
102
105
|
if (typeof change.name !== 'string' || !change.name.trim()) errors.push({ code: 'EMPTY_NAME', message: `Change ${String(change.id)} has empty name`, path: `changes[${i}]` });
|
|
103
|
-
if (typeof change.goal_id === 'number' && !goalIds.has(change.goal_id)) {
|
|
106
|
+
if ((typeof change.goal_id === 'number' || typeof change.goal_id === 'string') && !goalIds.has(change.goal_id)) {
|
|
104
107
|
warnings.push({ code: 'BROKEN_REF', message: `Change ${String(change.id)} references missing goal ${change.goal_id}`, path: `changes[${i}].goal_id` });
|
|
105
108
|
}
|
|
106
109
|
const aids = Array.isArray(change.activity_ids) ? (change.activity_ids as unknown[]) : [];
|
|
107
110
|
for (const aid of aids) {
|
|
108
|
-
if (typeof aid === 'number' && !activityIds.has(aid)) {
|
|
111
|
+
if ((typeof aid === 'number' || typeof aid === 'string') && !activityIds.has(aid)) {
|
|
109
112
|
warnings.push({ code: 'BROKEN_REF', message: `Change ${String(change.id)} references missing activity ${aid}`, path: `changes[${i}].activity_ids` });
|
|
110
113
|
}
|
|
111
114
|
}
|
|
@@ -118,7 +121,7 @@ export function validateFGCADoc(input: unknown): FGCAValidationResult {
|
|
|
118
121
|
continue;
|
|
119
122
|
}
|
|
120
123
|
const activity = a as { id?: unknown; name?: unknown };
|
|
121
|
-
if (typeof activity.id !== 'number') errors.push({ code: 'SCHEMA_INVALID', message: 'activity id must be a number', path: `activities[${i}]` });
|
|
124
|
+
if (typeof activity.id !== 'number' && typeof activity.id !== 'string') errors.push({ code: 'SCHEMA_INVALID', message: 'activity id must be a number or string', path: `activities[${i}]` });
|
|
122
125
|
if (typeof activity.name !== 'string' || !activity.name.trim()) errors.push({ code: 'EMPTY_NAME', message: `Activity ${String(activity.id)} has empty name`, path: `activities[${i}]` });
|
|
123
126
|
}
|
|
124
127
|
|