@transitrix/diagrams 1.5.0 → 1.7.6
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/capability-map/CapabilityCardNode.d.ts +19 -0
- package/dist/capability-map/CapabilityCardNode.js +66 -0
- package/dist/capability-map/CapabilityMapView.d.ts +59 -0
- package/dist/capability-map/CapabilityMapView.js +204 -0
- package/dist/capability-map/CapabilityRootNode.d.ts +12 -0
- package/dist/capability-map/CapabilityRootNode.js +23 -0
- package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +1 -0
- package/dist/capability-map/__tests__/CapabilityMapView.test.js +217 -0
- package/dist/capability-map/__tests__/address.test.d.ts +1 -0
- package/dist/capability-map/__tests__/address.test.js +49 -0
- package/dist/capability-map/__tests__/dsm-layout.test.d.ts +1 -0
- package/dist/capability-map/__tests__/dsm-layout.test.js +46 -0
- package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +1 -0
- package/dist/capability-map/__tests__/dsm-mutations.test.js +125 -0
- package/dist/capability-map/__tests__/dsm-validate.test.d.ts +1 -0
- package/dist/capability-map/__tests__/dsm-validate.test.js +56 -0
- package/dist/capability-map/address.d.ts +12 -0
- package/dist/capability-map/address.js +48 -0
- package/dist/capability-map/dsm-layout.d.ts +9 -0
- package/dist/capability-map/dsm-layout.js +125 -0
- package/dist/capability-map/dsm-mutations.d.ts +28 -0
- package/dist/capability-map/dsm-mutations.js +196 -0
- package/dist/capability-map/dsm-schema.d.ts +71 -0
- package/dist/capability-map/dsm-schema.js +14 -0
- package/dist/capability-map/dsm-theme.d.ts +20 -0
- package/dist/capability-map/dsm-theme.js +36 -0
- package/dist/capability-map/dsm-validate.d.ts +2 -0
- package/dist/capability-map/dsm-validate.js +93 -0
- package/dist/capability-map/index.d.ts +9 -0
- package/dist/capability-map/index.js +6 -0
- package/dist/codex/__tests__/example.test.d.ts +1 -0
- package/dist/codex/__tests__/example.test.js +33 -0
- package/dist/codex/__tests__/validate.test.d.ts +1 -0
- package/dist/codex/__tests__/validate.test.js +68 -0
- package/dist/codex/index.d.ts +4 -0
- package/dist/codex/index.js +2 -0
- package/dist/codex/types.d.ts +7 -0
- package/dist/codex/types.js +8 -0
- package/dist/codex/validate.d.ts +11 -0
- package/dist/codex/validate.js +103 -0
- package/dist/compliance/__tests__/canon-catalog.test.d.ts +1 -0
- package/dist/compliance/__tests__/canon-catalog.test.js +60 -0
- package/dist/compliance/__tests__/trace.test.d.ts +1 -0
- package/dist/compliance/__tests__/trace.test.js +144 -0
- package/dist/compliance/__tests__/view-resolution.test.d.ts +1 -0
- package/dist/compliance/__tests__/view-resolution.test.js +59 -0
- package/dist/compliance/canon-catalog.d.ts +19 -0
- package/dist/compliance/canon-catalog.js +59 -0
- package/dist/compliance/classify.js +7 -1
- package/dist/compliance/coverage-metric.d.ts +12 -0
- package/dist/compliance/coverage-metric.js +35 -0
- package/dist/compliance/impact.d.ts +7 -1
- package/dist/compliance/impact.js +53 -0
- package/dist/compliance/index.d.ts +8 -5
- package/dist/compliance/index.js +4 -2
- package/dist/compliance/reverse-index.js +4 -1
- package/dist/compliance/trace.d.ts +26 -0
- package/dist/compliance/trace.js +89 -0
- package/dist/compliance/types.d.ts +94 -1
- package/dist/constraint/__tests__/example.test.d.ts +1 -0
- package/dist/constraint/__tests__/example.test.js +14 -0
- package/dist/constraint/__tests__/validate.test.d.ts +1 -0
- package/dist/constraint/__tests__/validate.test.js +58 -0
- package/dist/constraint/index.d.ts +4 -0
- package/dist/constraint/index.js +2 -0
- package/dist/constraint/types.d.ts +4 -0
- package/dist/constraint/types.js +2 -0
- package/dist/constraint/validate.d.ts +7 -0
- package/dist/constraint/validate.js +115 -0
- package/dist/fgca/__tests__/parse-canonical.test.js +31 -0
- package/dist/fgca/parse-canonical.d.ts +1 -1
- package/dist/fgca/parse-canonical.js +18 -4
- package/dist/goals/GoalNode.d.ts +19 -0
- package/dist/goals/GoalNode.js +96 -0
- package/dist/goals/GoalTreeView.d.ts +59 -0
- package/dist/goals/GoalTreeView.js +245 -0
- package/dist/goals/__tests__/GoalTreeView.test.d.ts +1 -0
- package/dist/goals/__tests__/GoalTreeView.test.js +337 -0
- package/dist/goals/__tests__/mutations.test.js +39 -0
- package/dist/goals/__tests__/parse-canonical.test.js +2 -0
- package/dist/goals/index.d.ts +3 -0
- package/dist/goals/index.js +1 -0
- package/dist/goals/layout.js +2 -1
- package/dist/goals/mutations.js +6 -6
- package/dist/goals/parse-canonical.d.ts +5 -0
- package/dist/goals/parse-canonical.js +5 -0
- package/dist/goals/theme.d.ts +22 -0
- package/dist/goals/theme.js +32 -0
- package/dist/goals/types.d.ts +2 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/repo-validate/types.js +2 -3
- package/dist/webview/__tests__/render-goals.test.js +17 -3
- package/dist/webview/render-goals.js +2 -1
- package/package.json +4 -1
- package/src/capability-map/CapabilityCardNode.tsx +146 -0
- package/src/capability-map/CapabilityMapView.tsx +331 -0
- package/src/capability-map/CapabilityRootNode.tsx +38 -0
- package/src/capability-map/__tests__/CapabilityMapView.test.tsx +232 -0
- package/src/capability-map/__tests__/address.test.ts +59 -0
- package/src/capability-map/__tests__/dsm-layout.test.ts +52 -0
- package/src/capability-map/__tests__/dsm-mutations.test.ts +141 -0
- package/src/capability-map/__tests__/dsm-validate.test.ts +65 -0
- package/src/capability-map/address.ts +48 -0
- package/src/capability-map/dsm-layout.ts +142 -0
- package/src/capability-map/dsm-mutations.ts +208 -0
- package/src/capability-map/dsm-schema.ts +80 -0
- package/src/capability-map/dsm-theme.ts +53 -0
- package/src/capability-map/dsm-validate.ts +103 -0
- package/src/capability-map/index.ts +35 -0
- package/src/codex/__tests__/example.test.ts +40 -0
- package/src/codex/__tests__/validate.test.ts +84 -0
- package/src/codex/index.ts +4 -0
- package/src/codex/types.ts +13 -0
- package/src/codex/validate.ts +125 -0
- package/src/compliance/__tests__/canon-catalog.test.ts +68 -0
- package/src/compliance/__tests__/trace.test.ts +157 -0
- package/src/compliance/__tests__/view-resolution.test.ts +80 -0
- package/src/compliance/canon-catalog.ts +76 -0
- package/src/compliance/classify.ts +7 -1
- package/src/compliance/coverage-metric.ts +50 -0
- package/src/compliance/impact.ts +67 -1
- package/src/compliance/index.ts +16 -1
- package/src/compliance/reverse-index.ts +3 -1
- package/src/compliance/trace.ts +118 -0
- package/src/compliance/types.ts +101 -1
- package/src/constraint/__tests__/example.test.ts +19 -0
- package/src/constraint/__tests__/validate.test.ts +68 -0
- package/src/constraint/index.ts +4 -0
- package/src/constraint/types.ts +5 -0
- package/src/constraint/validate.ts +131 -0
- package/src/fgca/__tests__/parse-canonical.test.ts +34 -0
- package/src/fgca/parse-canonical.ts +17 -4
- package/src/goals/GoalNode.tsx +219 -0
- package/src/goals/GoalTreeView.tsx +384 -0
- package/src/goals/__tests__/GoalTreeView.test.tsx +361 -0
- package/src/goals/__tests__/mutations.test.ts +42 -0
- package/src/goals/__tests__/parse-canonical.test.ts +2 -0
- package/src/goals/index.ts +4 -0
- package/src/goals/layout.ts +2 -1
- package/src/goals/mutations.ts +6 -6
- package/src/goals/parse-canonical.ts +6 -0
- package/src/goals/theme.ts +54 -0
- package/src/goals/types.ts +2 -0
- package/src/index.ts +29 -1
- package/src/repo-validate/types.ts +2 -3
- package/src/webview/__tests__/render-goals.test.ts +17 -3
- package/src/webview/render-goals.ts +2 -1
package/src/compliance/types.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
// single-product view here, and the gap dashboard in Phase 4.
|
|
5
5
|
|
|
6
6
|
import type { AssertionStatus } from '../assertion/types.js';
|
|
7
|
+
import type { ComplianceCodexDoc } from './classify.js';
|
|
7
8
|
|
|
8
|
-
/** Projection of a REQUIREMENT the compliance views need. */
|
|
9
|
+
/** Projection of a REQUIREMENT (or CONSTRAINT) the compliance views need. */
|
|
9
10
|
export interface IndexRequirement {
|
|
10
11
|
id: string;
|
|
11
12
|
name: string;
|
|
@@ -20,6 +21,38 @@ export interface IndexRequirement {
|
|
|
20
21
|
* past or imminent, CV-3 renders an urgent decoration on the cell.
|
|
21
22
|
*/
|
|
22
23
|
deadline?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Origin taxonomy (15-requirement.md §2.1): `legislative`, `process-product`,
|
|
26
|
+
* or `project-product`. Distinguishes the context from which the obligation
|
|
27
|
+
* was derived. Undefined for existing pre-taxonomy admissions (treated as
|
|
28
|
+
* `legislative` by tooling that supports origin-based filtering).
|
|
29
|
+
*/
|
|
30
|
+
origin?: 'legislative' | 'process-product' | 'project-product';
|
|
31
|
+
/**
|
|
32
|
+
* Same-TYPE `parent` reference: the higher-scale obligation this one
|
|
33
|
+
* decomposes from (15-requirement.md §2.4; ELEMENT_PRIMITIVES.md §7.13 for
|
|
34
|
+
* CONSTRAINT). Origin-agnostic, structure-only. Enables the hierarchy half
|
|
35
|
+
* of the requirement traceability view.
|
|
36
|
+
*/
|
|
37
|
+
parent?: string;
|
|
38
|
+
/**
|
|
39
|
+
* Motivation-layer element kind. `requirement` = positive obligation
|
|
40
|
+
* (15-requirement.md); `constraint` = restriction / prohibition
|
|
41
|
+
* (ELEMENT_PRIMITIVES.md §7.13). ASSERTION coverage applies to `requirement`
|
|
42
|
+
* only (16-assertion.md §1); the hierarchy half applies to both.
|
|
43
|
+
*/
|
|
44
|
+
element_kind?: 'requirement' | 'constraint';
|
|
45
|
+
/**
|
|
46
|
+
* Longer-form description of the obligation (15-requirement.md §2). Optional;
|
|
47
|
+
* used by the requirement traceability view to show the requirement body
|
|
48
|
+
* inline. Not used by matrix / list views.
|
|
49
|
+
*/
|
|
50
|
+
description?: string;
|
|
51
|
+
/**
|
|
52
|
+
* `next_review_at` review-checkpoint date (15-requirement.md §2.3; ISO 8601).
|
|
53
|
+
* Present when the author has scheduled a review; drives `REQ-STALE-001`.
|
|
54
|
+
*/
|
|
55
|
+
next_review_at?: string;
|
|
23
56
|
}
|
|
24
57
|
|
|
25
58
|
// ── Temporal status (CV-3) ──────────────────────────────────────────────────
|
|
@@ -106,6 +139,11 @@ export interface ComplianceIndex {
|
|
|
106
139
|
assertionsByRequirement: Map<string, IndexAssertion[]>;
|
|
107
140
|
/** Subject id (product / process / capability) → assertions about it. */
|
|
108
141
|
assertionsBySubject: Map<string, IndexAssertion[]>;
|
|
142
|
+
/**
|
|
143
|
+
* Parent id → the requirements/constraints that name it in `parent`
|
|
144
|
+
* (15-requirement.md §2.4). Enables the requirement-hierarchy view.
|
|
145
|
+
*/
|
|
146
|
+
requirementsByParent: Map<string, IndexRequirement[]>;
|
|
109
147
|
}
|
|
110
148
|
|
|
111
149
|
// ── Single-law tree ─────────────────────────────────────────────────────────
|
|
@@ -134,3 +172,65 @@ export interface ProductView {
|
|
|
134
172
|
/** Requirements bound to the product via an assertion, requirement-id-sorted. */
|
|
135
173
|
requirements: ProductRequirementStatus[];
|
|
136
174
|
}
|
|
175
|
+
|
|
176
|
+
// ── Requirement traceability + hierarchy view ───────────────────────────────
|
|
177
|
+
|
|
178
|
+
/** A codex artefact resolved from a requirement's `derived_from` reference. */
|
|
179
|
+
export interface TraceSourceRef {
|
|
180
|
+
/** Verbatim id from `derived_from`. Always present. */
|
|
181
|
+
id: string;
|
|
182
|
+
/** The codex artefact, when resolved by the scan. Absent for dangling refs. */
|
|
183
|
+
codex?: ComplianceCodexDoc;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** A named element (subject or realising element) resolved by the trace. */
|
|
187
|
+
export interface TraceElementRef {
|
|
188
|
+
id: string;
|
|
189
|
+
/** Element name when resolved by the scan; absent for dangling refs. */
|
|
190
|
+
name?: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** One ASSERTION targeting the traced requirement, with subject + realising elements. */
|
|
194
|
+
export interface TraceAssertionRow {
|
|
195
|
+
assertion: IndexAssertion;
|
|
196
|
+
subject: TraceElementRef;
|
|
197
|
+
/** Elements named in the assertion's `realised_via` list (may be empty). */
|
|
198
|
+
realisedVia: TraceElementRef[];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Requirement traceability + hierarchy view.
|
|
203
|
+
*
|
|
204
|
+
* Two halves, both origin-agnostic (15-requirement.md §2.1):
|
|
205
|
+
* 1. Trace chain — `derived_from` source(s) → the element itself → any
|
|
206
|
+
* ASSERTION targeting it (`about`) → the asserted `subject` + `realised_via`
|
|
207
|
+
* elements. Origin-agnostic per 15-requirement.md §2.1; assertion coverage
|
|
208
|
+
* applies to REQUIREMENT only (16-assertion.md §1) — CONSTRAINT trace shows
|
|
209
|
+
* only the source chain + hierarchy.
|
|
210
|
+
* 2. Hierarchy — `parent` chain (ancestors, root last of the array) + children
|
|
211
|
+
* (any element whose `parent` names this one), sorted by id.
|
|
212
|
+
*/
|
|
213
|
+
export interface RequirementTrace {
|
|
214
|
+
/** The element being traced (REQUIREMENT or CONSTRAINT). Falls back to a
|
|
215
|
+
* stub carrying the id as its name when the element is missing from the
|
|
216
|
+
* scan (a dangling `parent` or a repository being edited). */
|
|
217
|
+
requirement: IndexRequirement;
|
|
218
|
+
/** Backward-trace: `derived_from` codex artefacts, verbatim order. */
|
|
219
|
+
sources: TraceSourceRef[];
|
|
220
|
+
/** Forward-trace via ASSERTION. Empty for CONSTRAINT elements (16-assertion.md §1) or for a REQUIREMENT with no filed assertion. */
|
|
221
|
+
assertions: TraceAssertionRow[];
|
|
222
|
+
/** Parent chain: immediate parent first, root last. Empty when the element has no `parent`. */
|
|
223
|
+
ancestors: IndexRequirement[];
|
|
224
|
+
/** Direct children: elements naming this one as their `parent`, id-sorted. */
|
|
225
|
+
children: IndexRequirement[];
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* The complementary data the trace builder needs to name subjects and realising
|
|
230
|
+
* elements. Names are resolved by looking up the id in this map; unresolved ids
|
|
231
|
+
* surface as the id alone (a dangling reference).
|
|
232
|
+
*/
|
|
233
|
+
export interface TraceElementCatalog {
|
|
234
|
+
/** id → human-readable name (or the id itself when unnamed). */
|
|
235
|
+
nameById: Map<string, string>;
|
|
236
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import yaml from 'js-yaml';
|
|
6
|
+
import { validateConstraint } from '../validate.js';
|
|
7
|
+
|
|
8
|
+
const dir = path.resolve(
|
|
9
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
10
|
+
'../../../../../tests/fixtures/notation-corpus/constraint',
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
describe('constraint worked example (notation-corpus)', () => {
|
|
14
|
+
it('validates CONSTRAINT-GDPR-RESIDENCY-1.yaml without error', () => {
|
|
15
|
+
const data = yaml.load(readFileSync(path.join(dir, 'CONSTRAINT-GDPR-RESIDENCY-1.yaml'), 'utf-8'));
|
|
16
|
+
const v = validateConstraint(data);
|
|
17
|
+
expect(v.valid, JSON.stringify(v.errors)).toBe(true);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { validateConstraint } from '../validate.js';
|
|
3
|
+
import type { CanonCatalog } from '../../typed-id.js';
|
|
4
|
+
|
|
5
|
+
function valid(): Record<string, unknown> {
|
|
6
|
+
return {
|
|
7
|
+
notation: 'constraint',
|
|
8
|
+
id: 'CONSTRAINT-GDPR-RESIDENCY-1',
|
|
9
|
+
name: 'EU customer personal data must be stored within EU/EEA jurisdictions',
|
|
10
|
+
statement: 'Personal data of EU customers MUST NOT be persisted outside EU / EEA jurisdictions.',
|
|
11
|
+
status: 'active',
|
|
12
|
+
zone: 'canon',
|
|
13
|
+
admitted_at: '2026-05-29',
|
|
14
|
+
admitted_by: 'v.korobeinikov',
|
|
15
|
+
gate_checks: { uniqueness: 'pass', consistency: 'pass', completeness: 'pass' },
|
|
16
|
+
valid_from: '2018-05-25',
|
|
17
|
+
valid_to: null,
|
|
18
|
+
severity: 'mandatory',
|
|
19
|
+
owner_role: 'ROLE-DPO-1',
|
|
20
|
+
applies_to: ['APPLICATION-CRM-1'],
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const codes = (input: unknown, opts?: Parameters<typeof validateConstraint>[1]): string[] =>
|
|
25
|
+
validateConstraint(input, opts).errors.map((e) => e.code);
|
|
26
|
+
|
|
27
|
+
describe('validateConstraint — positive', () => {
|
|
28
|
+
it('accepts a well-formed constraint', () => {
|
|
29
|
+
const r = validateConstraint(valid());
|
|
30
|
+
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('validateConstraint — CONST-001', () => {
|
|
35
|
+
it('flags missing required fields and wrong notation', () => {
|
|
36
|
+
const r = valid();
|
|
37
|
+
delete r.statement;
|
|
38
|
+
expect(codes(r)).toContain('CONST-001');
|
|
39
|
+
expect(codes({ ...valid(), notation: 'requirement' })).toContain('CONST-001');
|
|
40
|
+
expect(codes({ ...valid(), id: 'CONSTRAINT-001' })).toContain('CONST-001');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('validateConstraint — CONST-002/003', () => {
|
|
45
|
+
it('flags invalid status and severity', () => {
|
|
46
|
+
expect(codes({ ...valid(), status: 'enabled' })).toContain('CONST-002');
|
|
47
|
+
expect(codes({ ...valid(), severity: 'critical' })).toContain('CONST-003');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('validateConstraint — CONST-004/005 (catalog)', () => {
|
|
52
|
+
it('flags unresolved applies_to and owner_role with catalog', () => {
|
|
53
|
+
const catalog: CanonCatalog = { typeOf: () => undefined };
|
|
54
|
+
expect(codes(valid(), { catalog })).toContain('CONST-004');
|
|
55
|
+
expect(codes(valid(), { catalog })).toContain('CONST-005');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('does not flag CONST-004 without catalog for well-formed applies_to', () => {
|
|
59
|
+
expect(codes(valid())).not.toContain('CONST-004');
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('resolves applies_to when catalogue admits the target', () => {
|
|
63
|
+
const catalog: CanonCatalog = {
|
|
64
|
+
typeOf: (id) => (id === 'APPLICATION-CRM-1' ? 'APPLICATION' : id === 'ROLE-DPO-1' ? 'ROLE' : undefined),
|
|
65
|
+
};
|
|
66
|
+
expect(validateConstraint(valid(), { catalog }).valid).toBe(true);
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export const CONSTRAINT_STATUSES = ['active', 'proposed', 'deprecated', 'retired'] as const;
|
|
2
|
+
export type ConstraintStatus = (typeof CONSTRAINT_STATUSES)[number];
|
|
3
|
+
|
|
4
|
+
export const CONSTRAINT_SEVERITIES = ['mandatory', 'recommended', 'advisory'] as const;
|
|
5
|
+
export type ConstraintSeverity = (typeof CONSTRAINT_SEVERITIES)[number];
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// CONSTRAINT validator — methodology ELEMENT_PRIMITIVES.md §7.13 (sibling to
|
|
2
|
+
// 15-requirement.md). Implements CONST-001..005 for the compliance suite (#518 C4).
|
|
3
|
+
|
|
4
|
+
import type { ValidationError, ValidationWarning, ValidationResult } from '../validation-types.js';
|
|
5
|
+
import { typeOfId, isCanonicalIdOfType, type CanonCatalog } from '../typed-id.js';
|
|
6
|
+
import { CONSTRAINT_STATUSES, CONSTRAINT_SEVERITIES } from './types.js';
|
|
7
|
+
|
|
8
|
+
export interface ConstraintValidateOptions {
|
|
9
|
+
/** When provided, CONST-004/005 enforce artefact existence for cross-refs. */
|
|
10
|
+
catalog?: CanonCatalog;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const REQUIRED_FIELDS = [
|
|
14
|
+
'notation',
|
|
15
|
+
'name',
|
|
16
|
+
'statement',
|
|
17
|
+
'status',
|
|
18
|
+
'zone',
|
|
19
|
+
'admitted_at',
|
|
20
|
+
'admitted_by',
|
|
21
|
+
'gate_checks',
|
|
22
|
+
'valid_from',
|
|
23
|
+
] as const;
|
|
24
|
+
|
|
25
|
+
export function validateConstraint(
|
|
26
|
+
input: unknown,
|
|
27
|
+
options: ConstraintValidateOptions = {},
|
|
28
|
+
): ValidationResult {
|
|
29
|
+
const errors: ValidationError[] = [];
|
|
30
|
+
const warnings: ValidationWarning[] = [];
|
|
31
|
+
|
|
32
|
+
if (input === null || typeof input !== 'object' || Array.isArray(input)) {
|
|
33
|
+
errors.push({ code: 'CONST-001', message: 'Constraint must be a YAML mapping.' });
|
|
34
|
+
return { valid: false, errors, warnings };
|
|
35
|
+
}
|
|
36
|
+
const c = input as Record<string, unknown>;
|
|
37
|
+
|
|
38
|
+
if (!isCanonicalIdOfType(c.id, 'CONSTRAINT')) {
|
|
39
|
+
errors.push({
|
|
40
|
+
code: 'CONST-001',
|
|
41
|
+
message: `id "${String(c.id)}" must match CONSTRAINT-[<middle>-]<INTEGER>.`,
|
|
42
|
+
path: 'id',
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (c.notation !== 'constraint') {
|
|
46
|
+
errors.push({ code: 'CONST-001', message: 'notation must be the fixed value "constraint".', path: 'notation' });
|
|
47
|
+
}
|
|
48
|
+
for (const f of REQUIRED_FIELDS) {
|
|
49
|
+
if (f === 'notation') continue;
|
|
50
|
+
if (f === 'gate_checks') {
|
|
51
|
+
if (c.gate_checks === null || typeof c.gate_checks !== 'object') {
|
|
52
|
+
errors.push({ code: 'CONST-001', message: 'gate_checks is required and must be a mapping.', path: 'gate_checks' });
|
|
53
|
+
}
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const v = c[f];
|
|
57
|
+
if (typeof v !== 'string' || v.trim() === '') {
|
|
58
|
+
errors.push({ code: 'CONST-001', message: `${f} is required.`, path: f });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (c.zone !== 'canon') {
|
|
62
|
+
errors.push({ code: 'CONST-001', message: 'zone must be "canon" for a CONSTRAINT.', path: 'zone' });
|
|
63
|
+
}
|
|
64
|
+
if (!('valid_to' in c) || !(typeof c.valid_to === 'string' || c.valid_to === null)) {
|
|
65
|
+
errors.push({ code: 'CONST-001', message: 'valid_to is required (an ISO date string or null).', path: 'valid_to' });
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const status = typeof c.status === 'string' ? c.status.trim() : '';
|
|
69
|
+
if (status && !(CONSTRAINT_STATUSES as readonly string[]).includes(status)) {
|
|
70
|
+
errors.push({
|
|
71
|
+
code: 'CONST-002',
|
|
72
|
+
message: `status must be one of ${CONSTRAINT_STATUSES.join(', ')}.`,
|
|
73
|
+
path: 'status',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (c.severity !== undefined) {
|
|
78
|
+
const severity = typeof c.severity === 'string' ? c.severity.trim() : '';
|
|
79
|
+
if (!severity || !(CONSTRAINT_SEVERITIES as readonly string[]).includes(severity)) {
|
|
80
|
+
errors.push({
|
|
81
|
+
code: 'CONST-003',
|
|
82
|
+
message: `severity must be one of ${CONSTRAINT_SEVERITIES.join(', ')}.`,
|
|
83
|
+
path: 'severity',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (c.applies_to !== undefined) {
|
|
89
|
+
if (!Array.isArray(c.applies_to)) {
|
|
90
|
+
errors.push({ code: 'CONST-001', message: 'applies_to must be a list of typed IDs.', path: 'applies_to' });
|
|
91
|
+
} else {
|
|
92
|
+
c.applies_to.forEach((ref, i) => {
|
|
93
|
+
const type = typeOfId(ref);
|
|
94
|
+
if (!type) {
|
|
95
|
+
errors.push({
|
|
96
|
+
code: 'CONST-004',
|
|
97
|
+
message: `applies_to[${i}] "${String(ref)}" is not a resolvable typed ID.`,
|
|
98
|
+
path: `applies_to[${i}]`,
|
|
99
|
+
});
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
if (options.catalog && options.catalog.typeOf(ref as string) === undefined) {
|
|
103
|
+
errors.push({
|
|
104
|
+
code: 'CONST-004',
|
|
105
|
+
message: `applies_to[${i}] "${String(ref)}" does not resolve to an admitted artefact.`,
|
|
106
|
+
path: `applies_to[${i}]`,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (c.owner_role !== undefined) {
|
|
114
|
+
const role = c.owner_role;
|
|
115
|
+
if (typeof role !== 'string' || !isCanonicalIdOfType(role, 'ROLE')) {
|
|
116
|
+
errors.push({
|
|
117
|
+
code: 'CONST-005',
|
|
118
|
+
message: `owner_role "${String(role)}" must be a typed ROLE id.`,
|
|
119
|
+
path: 'owner_role',
|
|
120
|
+
});
|
|
121
|
+
} else if (options.catalog && options.catalog.typeOf(role) === undefined) {
|
|
122
|
+
errors.push({
|
|
123
|
+
code: 'CONST-005',
|
|
124
|
+
message: `owner_role "${role}" does not resolve to an admitted artefact.`,
|
|
125
|
+
path: 'owner_role',
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return { valid: errors.length === 0, errors, warnings };
|
|
131
|
+
}
|
|
@@ -35,6 +35,31 @@ describe('parseCanonicalFGCA', () => {
|
|
|
35
35
|
expect(r.parsed?.activities).toHaveLength(1);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
+
it('accepts ACTION-* ids (methodology 1.0) alongside legacy ACTIVITY-*', () => {
|
|
39
|
+
const r = parseCanonicalFGCA({
|
|
40
|
+
...VALID,
|
|
41
|
+
actions: [
|
|
42
|
+
{ id: 'ACTION-CRM-EU-1', name: 'CRM rollout', changes: ['CHANGE-1'] },
|
|
43
|
+
{ id: 'ACTIVITY-2', name: 'Legacy workstream', changes: ['CHANGE-1'] },
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
47
|
+
expect(r.parsed?.activities.map((a) => a.id)).toEqual(['ACTION-CRM-EU-1', 'ACTIVITY-2']);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('defaults changes to [] when view_config.layers.changes is off (DGA-in-dgca)', () => {
|
|
51
|
+
const r = parseCanonicalFGCA({
|
|
52
|
+
...VALID,
|
|
53
|
+
changes: undefined,
|
|
54
|
+
view_config: { layers: { changes: 'off' } },
|
|
55
|
+
actions: [
|
|
56
|
+
{ id: 'ACTION-DISCOVERY-1', name: 'Gap assessment', goals: ['GOAL-1'] },
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
60
|
+
expect(r.parsed?.changes).toEqual([]);
|
|
61
|
+
});
|
|
62
|
+
|
|
38
63
|
it('FGCA-001: rejects non-object input', () => {
|
|
39
64
|
expect(parseCanonicalFGCA(null).errors[0].code).toBe('FGCA-001');
|
|
40
65
|
expect(parseCanonicalFGCA('string').errors[0].code).toBe('FGCA-001');
|
|
@@ -198,6 +223,15 @@ describe('parseCanonicalFGA', () => {
|
|
|
198
223
|
expect(r.parsed?.activities).toHaveLength(1);
|
|
199
224
|
});
|
|
200
225
|
|
|
226
|
+
it('accepts ACTION-* ids in FGA mode', () => {
|
|
227
|
+
const r = parseCanonicalFGA({
|
|
228
|
+
...VALID_FGA,
|
|
229
|
+
actions: [{ id: 'ACTION-GDPR-DSR-WORKFLOW-1', name: 'DSR workflow', goals: ['GOAL-1'] }],
|
|
230
|
+
});
|
|
231
|
+
expect(r.valid, JSON.stringify(r.errors)).toBe(true);
|
|
232
|
+
expect(r.parsed?.activities[0].id).toBe('ACTION-GDPR-DSR-WORKFLOW-1');
|
|
233
|
+
});
|
|
234
|
+
|
|
201
235
|
it('populates activity.goal_id from activity.goals[] (the FGA edge-driving field)', () => {
|
|
202
236
|
// The "FGA nodes render, no edges" bug: activities had no resolvable
|
|
203
237
|
// goal_id, so the renderer drew no goal → activity edges.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* - Flat top-level arrays, no `fgca:` wrapper.
|
|
8
8
|
* - Typed string IDs per `IDS_AND_REFERENCES.md` (`FACTOR-1`,
|
|
9
|
-
* `GOAL-RET-1`, `CHANGE-1`, `
|
|
9
|
+
* `GOAL-RET-1`, `CHANGE-1`, `ACTION-ONBOARD-1` (legacy `ACTIVITY-*` accepted).
|
|
10
10
|
* - Plural canonical-direction cross-references: `goal.factors`,
|
|
11
11
|
* `change.goals`, `activity.changes`, `activity.goals`.
|
|
12
12
|
* - Per-notation validation codes `FGCA-001 … FGCA-015`.
|
|
@@ -50,7 +50,8 @@ const DRIVER_ID_RE = /^DRIVER(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
|
50
50
|
const FACTOR_OR_DRIVER_ID_RE = /^(FACTOR|DRIVER)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
51
51
|
const GOAL_ID_RE = /^GOAL(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
52
52
|
const CHANGE_ID_RE = /^CHANGE(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
53
|
-
|
|
53
|
+
// ACTION is canonical since methodology 1.0; ACTIVITY accepted for legacy docs.
|
|
54
|
+
const ACTION_OR_ACTIVITY_ID_RE = /^(ACTION|ACTIVITY)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
54
55
|
const FGCA_DOC_ID_RE = /^(FGCA|DGCA)(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
55
56
|
const CONSTRAINT_ID_RE = /^CONSTRAINT(-[A-Z0-9][A-Z0-9_]*)*-\d+$/;
|
|
56
57
|
|
|
@@ -63,6 +64,15 @@ function asObjectArray(v: unknown): Array<Record<string, unknown>> | null {
|
|
|
63
64
|
return v.map((el) => (el && typeof el === 'object' ? (el as Record<string, unknown>) : null) as Record<string, unknown>);
|
|
64
65
|
}
|
|
65
66
|
|
|
67
|
+
/** DGA mode (`view_config.layers.changes: off`) may omit the changes layer. */
|
|
68
|
+
function isChangesLayerOff(raw: Record<string, unknown>): boolean {
|
|
69
|
+
const vc = raw['view_config'];
|
|
70
|
+
if (!vc || typeof vc !== 'object') return false;
|
|
71
|
+
const layers = (vc as Record<string, unknown>)['layers'];
|
|
72
|
+
if (!layers || typeof layers !== 'object') return false;
|
|
73
|
+
return (layers as Record<string, unknown>)['changes'] === 'off';
|
|
74
|
+
}
|
|
75
|
+
|
|
66
76
|
|
|
67
77
|
/**
|
|
68
78
|
* Validate canonical FGCA YAML and, on success, return an internal-form
|
|
@@ -114,7 +124,10 @@ export function parseCanonicalFGCA(input: unknown): CanonicalFGCAResult {
|
|
|
114
124
|
|
|
115
125
|
const factorsRaw = asObjectArray(raw['factors']);
|
|
116
126
|
const goalsRaw = asObjectArray(raw['goals']);
|
|
117
|
-
|
|
127
|
+
let changesRaw = asObjectArray(raw['changes']);
|
|
128
|
+
if (changesRaw === null && raw['changes'] === undefined && isChangesLayerOff(raw)) {
|
|
129
|
+
changesRaw = [];
|
|
130
|
+
}
|
|
118
131
|
const activitiesRaw = asObjectArray(raw['actions']);
|
|
119
132
|
if (activitiesRaw === null && 'activities' in raw) {
|
|
120
133
|
errors.push({ code: 'FGCA-004', message: '"activities" key is not accepted — rename to "actions"', path: 'actions' });
|
|
@@ -177,7 +190,7 @@ export function parseCanonicalFGCA(input: unknown): CanonicalFGCAResult {
|
|
|
177
190
|
factors.forEach((el, i) => checkLayerElement(el, `factors[${i}]`, FACTOR_OR_DRIVER_ID_RE, factorIds));
|
|
178
191
|
goals.forEach((el, i) => checkLayerElement(el, `goals[${i}]`, GOAL_ID_RE, goalIds));
|
|
179
192
|
changes.forEach((el, i) => checkLayerElement(el, `changes[${i}]`, CHANGE_ID_RE, changeIds));
|
|
180
|
-
activities.forEach((el, i) => checkLayerElement(el, `activities[${i}]`,
|
|
193
|
+
activities.forEach((el, i) => checkLayerElement(el, `activities[${i}]`, ACTION_OR_ACTIVITY_ID_RE, activityIds));
|
|
181
194
|
|
|
182
195
|
if (errors.length > 0) return { valid: false, errors, warnings };
|
|
183
196
|
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import React, { memo, useState } from 'react';
|
|
2
|
+
import { Handle, Position } from 'reactflow';
|
|
3
|
+
import type { Factor, Goal } from './types.js';
|
|
4
|
+
import { displayGoalId } from './parse-canonical.js';
|
|
5
|
+
import type { ThemeTokens } from './theme.js';
|
|
6
|
+
|
|
7
|
+
const NODE_WIDTH = 250;
|
|
8
|
+
const NODE_HEIGHT = 80;
|
|
9
|
+
|
|
10
|
+
function impactSign(f: Factor): 'positive' | 'negative' | 'both' {
|
|
11
|
+
const t = f.impact_type;
|
|
12
|
+
if (t === 'mixed') return 'both';
|
|
13
|
+
if (t === 'opportunity' || t === 'positive') return 'positive';
|
|
14
|
+
return 'negative';
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface GoalNodeData {
|
|
18
|
+
goal: Goal;
|
|
19
|
+
theme: Required<ThemeTokens>;
|
|
20
|
+
readOnly: boolean;
|
|
21
|
+
isDropTarget: boolean;
|
|
22
|
+
hasHiddenChildren: boolean;
|
|
23
|
+
isCollapsed: boolean;
|
|
24
|
+
onAddChild: (parentId: number, parentLevel: number) => void;
|
|
25
|
+
onDelete: (id: number) => void;
|
|
26
|
+
onToggleCollapse: (id: number) => void;
|
|
27
|
+
onFactorClick?: (factor: Factor) => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const GoalNode = memo(({ data }: { data: GoalNodeData }) => {
|
|
31
|
+
const { goal, theme, readOnly, isDropTarget, hasHiddenChildren, isCollapsed } = data;
|
|
32
|
+
const [openPanel, setOpenPanel] = useState<'positive' | 'negative' | null>(null);
|
|
33
|
+
|
|
34
|
+
const positive = (goal.factors ?? []).filter((f) => impactSign(f) !== 'negative');
|
|
35
|
+
const negative = (goal.factors ?? []).filter((f) => impactSign(f) !== 'positive');
|
|
36
|
+
const bg = theme.goalLevelColors[goal.level] ?? theme.goalLevelColors[0];
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
className="tx-goal-node"
|
|
41
|
+
style={{
|
|
42
|
+
position: 'relative',
|
|
43
|
+
width: NODE_WIDTH,
|
|
44
|
+
height: NODE_HEIGHT,
|
|
45
|
+
background: bg,
|
|
46
|
+
borderRadius: 12,
|
|
47
|
+
borderStyle: 'solid',
|
|
48
|
+
borderWidth: isDropTarget ? 2 : theme.cardBorderWidth,
|
|
49
|
+
borderColor: isDropTarget ? theme.dropTargetBorderColor : theme.cardBorderColor,
|
|
50
|
+
boxShadow: '0 1px 4px rgba(0,0,0,0.12)',
|
|
51
|
+
padding: '6px 8px',
|
|
52
|
+
fontSize: 12,
|
|
53
|
+
display: 'flex',
|
|
54
|
+
alignItems: 'stretch',
|
|
55
|
+
justifyContent: 'center',
|
|
56
|
+
}}
|
|
57
|
+
>
|
|
58
|
+
<Handle type="target" position={Position.Left} style={{ opacity: 0 }} />
|
|
59
|
+
<Handle type="source" position={Position.Right} style={{ opacity: 0 }} />
|
|
60
|
+
|
|
61
|
+
<div style={{ flexShrink: 0, display: 'flex', alignItems: 'center', width: 16 }}>
|
|
62
|
+
{positive.length > 0 && (
|
|
63
|
+
<span
|
|
64
|
+
role="button"
|
|
65
|
+
aria-label={`${positive.length} positive factor${positive.length > 1 ? 's' : ''}`}
|
|
66
|
+
title={`${positive.length} positive factor${positive.length > 1 ? 's' : ''}`}
|
|
67
|
+
onClick={(e) => {
|
|
68
|
+
e.stopPropagation();
|
|
69
|
+
setOpenPanel(openPanel === 'positive' ? null : 'positive');
|
|
70
|
+
}}
|
|
71
|
+
style={{ cursor: 'pointer', color: '#16a34a', fontSize: 14, lineHeight: 1, userSelect: 'none' }}
|
|
72
|
+
>
|
|
73
|
+
▲
|
|
74
|
+
{positive.length > 1 && <span style={{ fontSize: 9, fontWeight: 700, marginLeft: 2 }}>{positive.length}</span>}
|
|
75
|
+
</span>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
|
|
79
|
+
<div style={{ flex: 1, minWidth: 0, display: 'flex', flexDirection: 'column', justifyContent: 'center', textAlign: 'center', padding: '0 4px' }}>
|
|
80
|
+
<div
|
|
81
|
+
title={goal.name}
|
|
82
|
+
style={{
|
|
83
|
+
fontWeight: 600,
|
|
84
|
+
color: theme.cardTextColor,
|
|
85
|
+
lineHeight: 1.2,
|
|
86
|
+
overflow: 'hidden',
|
|
87
|
+
display: '-webkit-box',
|
|
88
|
+
WebkitLineClamp: 2,
|
|
89
|
+
WebkitBoxOrient: 'vertical',
|
|
90
|
+
wordBreak: 'break-word',
|
|
91
|
+
}}
|
|
92
|
+
>
|
|
93
|
+
{goal.name}
|
|
94
|
+
</div>
|
|
95
|
+
<div style={{ fontSize: 10, color: theme.cardMetaColor, marginTop: 2 }}>
|
|
96
|
+
ID: {displayGoalId(goal)} | Lvl: {goal.level}
|
|
97
|
+
{goal.tag ? ` | #${goal.tag}` : ''}
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
|
|
101
|
+
<div style={{ flexShrink: 0, display: 'flex', alignItems: 'center', width: 16, justifyContent: 'flex-end' }}>
|
|
102
|
+
{negative.length > 0 && (
|
|
103
|
+
<span
|
|
104
|
+
role="button"
|
|
105
|
+
aria-label={`${negative.length} negative factor${negative.length > 1 ? 's' : ''}`}
|
|
106
|
+
title={`${negative.length} negative factor${negative.length > 1 ? 's' : ''}`}
|
|
107
|
+
onClick={(e) => {
|
|
108
|
+
e.stopPropagation();
|
|
109
|
+
setOpenPanel(openPanel === 'negative' ? null : 'negative');
|
|
110
|
+
}}
|
|
111
|
+
style={{ cursor: 'pointer', color: '#dc2626', fontSize: 14, lineHeight: 1, userSelect: 'none' }}
|
|
112
|
+
>
|
|
113
|
+
▼
|
|
114
|
+
{negative.length > 1 && <span style={{ fontSize: 9, fontWeight: 700, marginLeft: 2 }}>{negative.length}</span>}
|
|
115
|
+
</span>
|
|
116
|
+
)}
|
|
117
|
+
</div>
|
|
118
|
+
|
|
119
|
+
{openPanel && (
|
|
120
|
+
<div
|
|
121
|
+
style={{
|
|
122
|
+
position: 'absolute',
|
|
123
|
+
left: 0,
|
|
124
|
+
width: '100%',
|
|
125
|
+
zIndex: 20,
|
|
126
|
+
display: 'flex',
|
|
127
|
+
flexDirection: 'column',
|
|
128
|
+
gap: 4,
|
|
129
|
+
...(openPanel === 'positive' ? { bottom: 'calc(100% + 8px)' } : { top: 'calc(100% + 8px)' }),
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
{(openPanel === 'positive' ? positive : negative).map((f) => (
|
|
133
|
+
<div
|
|
134
|
+
key={f.id}
|
|
135
|
+
onClick={(e) => {
|
|
136
|
+
e.stopPropagation();
|
|
137
|
+
data.onFactorClick?.(f);
|
|
138
|
+
}}
|
|
139
|
+
style={{
|
|
140
|
+
background: openPanel === 'positive' ? '#f0fdf4' : '#fef2f2',
|
|
141
|
+
border: `1px solid ${openPanel === 'positive' ? '#bbf7d0' : '#fecaca'}`,
|
|
142
|
+
color: openPanel === 'positive' ? '#166534' : '#991b1b',
|
|
143
|
+
borderRadius: 4,
|
|
144
|
+
padding: '4px 6px',
|
|
145
|
+
fontSize: 10,
|
|
146
|
+
textAlign: 'left',
|
|
147
|
+
cursor: data.onFactorClick ? 'pointer' : 'default',
|
|
148
|
+
}}
|
|
149
|
+
>
|
|
150
|
+
<div style={{ fontWeight: 700 }}>{f.name}</div>
|
|
151
|
+
{f.description && <div style={{ opacity: 0.85 }}>{f.description}</div>}
|
|
152
|
+
</div>
|
|
153
|
+
))}
|
|
154
|
+
</div>
|
|
155
|
+
)}
|
|
156
|
+
|
|
157
|
+
{!readOnly && (
|
|
158
|
+
<button
|
|
159
|
+
type="button"
|
|
160
|
+
aria-label="Add child goal"
|
|
161
|
+
title="Add child goal"
|
|
162
|
+
onClick={(e) => {
|
|
163
|
+
e.stopPropagation();
|
|
164
|
+
data.onAddChild(goal.id, goal.level);
|
|
165
|
+
}}
|
|
166
|
+
style={{
|
|
167
|
+
position: 'absolute', top: -8, right: -8, width: 16, height: 16,
|
|
168
|
+
borderRadius: '50%', border: '1px solid #86efac', background: '#ffffff',
|
|
169
|
+
color: '#16a34a', fontSize: 11, lineHeight: '14px', padding: 0, cursor: 'pointer',
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
+
|
|
173
|
+
</button>
|
|
174
|
+
)}
|
|
175
|
+
|
|
176
|
+
{!readOnly && (
|
|
177
|
+
<button
|
|
178
|
+
type="button"
|
|
179
|
+
aria-label="Delete goal"
|
|
180
|
+
title="Delete goal and descendants"
|
|
181
|
+
onClick={(e) => {
|
|
182
|
+
e.stopPropagation();
|
|
183
|
+
data.onDelete(goal.id);
|
|
184
|
+
}}
|
|
185
|
+
style={{
|
|
186
|
+
position: 'absolute', bottom: -8, right: -8, width: 16, height: 16,
|
|
187
|
+
borderRadius: '50%', border: '1px solid #fca5a5', background: '#ffffff',
|
|
188
|
+
color: '#dc2626', fontSize: 11, lineHeight: '14px', padding: 0, cursor: 'pointer',
|
|
189
|
+
}}
|
|
190
|
+
>
|
|
191
|
+
×
|
|
192
|
+
</button>
|
|
193
|
+
)}
|
|
194
|
+
|
|
195
|
+
{hasHiddenChildren && (
|
|
196
|
+
<button
|
|
197
|
+
type="button"
|
|
198
|
+
aria-label={isCollapsed ? 'Expand branch' : 'Collapse branch'}
|
|
199
|
+
title={isCollapsed ? 'Expand branch' : 'Collapse branch'}
|
|
200
|
+
onClick={(e) => {
|
|
201
|
+
e.stopPropagation();
|
|
202
|
+
data.onToggleCollapse(goal.id);
|
|
203
|
+
}}
|
|
204
|
+
style={{
|
|
205
|
+
position: 'absolute', top: '50%', right: -8, transform: 'translateY(-50%)',
|
|
206
|
+
width: 16, height: 16, borderRadius: '50%', border: `1px solid ${theme.cardBorderColor}`,
|
|
207
|
+
background: '#ffffff', color: theme.cardBorderColor, fontSize: 11, lineHeight: '14px', padding: 0, cursor: 'pointer',
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
{isCollapsed ? '+' : '−'}
|
|
211
|
+
</button>
|
|
212
|
+
)}
|
|
213
|
+
</div>
|
|
214
|
+
);
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
GoalNode.displayName = 'GoalNode';
|
|
218
|
+
|
|
219
|
+
export default GoalNode;
|