@transitrix/diagrams 1.8.6 → 1.8.8

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 (251) hide show
  1. package/dist/fgca/index.js +10 -10
  2. package/dist/fgca/layout.js +1 -1
  3. package/dist/fgca/nodeTypes.js +4 -4
  4. package/dist/index.js +33 -33
  5. package/package.json +8 -2
  6. package/dist/__tests__/edge-path.test.d.ts +0 -1
  7. package/dist/__tests__/edge-path.test.js +0 -55
  8. package/dist/__tests__/node-size-presets.test.d.ts +0 -1
  9. package/dist/__tests__/node-size-presets.test.js +0 -30
  10. package/dist/__tests__/scope.test.d.ts +0 -1
  11. package/dist/__tests__/scope.test.js +0 -23
  12. package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
  13. package/dist/__tests__/yaml-normalize.test.js +0 -148
  14. package/dist/activities/__tests__/cpm.test.d.ts +0 -1
  15. package/dist/activities/__tests__/cpm.test.js +0 -146
  16. package/dist/activities/__tests__/gantt.test.d.ts +0 -1
  17. package/dist/activities/__tests__/gantt.test.js +0 -263
  18. package/dist/activities/__tests__/layout.test.d.ts +0 -1
  19. package/dist/activities/__tests__/layout.test.js +0 -98
  20. package/dist/activities/__tests__/validate.test.d.ts +0 -1
  21. package/dist/activities/__tests__/validate.test.js +0 -397
  22. package/dist/activity-card/__tests__/example.test.d.ts +0 -1
  23. package/dist/activity-card/__tests__/example.test.js +0 -73
  24. package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
  25. package/dist/activity-card/__tests__/layout.test.js +0 -141
  26. package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
  27. package/dist/activity-card/__tests__/resolver.test.js +0 -325
  28. package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
  29. package/dist/activity-card/__tests__/validate.test.js +0 -149
  30. package/dist/actor/__tests__/validate.test.d.ts +0 -1
  31. package/dist/actor/__tests__/validate.test.js +0 -95
  32. package/dist/applications/__tests__/validate.test.d.ts +0 -1
  33. package/dist/applications/__tests__/validate.test.js +0 -223
  34. package/dist/assertion/__tests__/example.test.d.ts +0 -1
  35. package/dist/assertion/__tests__/example.test.js +0 -32
  36. package/dist/assertion/__tests__/validate.test.d.ts +0 -1
  37. package/dist/assertion/__tests__/validate.test.js +0 -130
  38. package/dist/blocks/__tests__/layout.test.d.ts +0 -1
  39. package/dist/blocks/__tests__/layout.test.js +0 -153
  40. package/dist/blocks/__tests__/validate.test.d.ts +0 -1
  41. package/dist/blocks/__tests__/validate.test.js +0 -235
  42. package/dist/business-service/__tests__/validate.test.d.ts +0 -1
  43. package/dist/business-service/__tests__/validate.test.js +0 -135
  44. package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
  45. package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
  46. package/dist/capability-map/__tests__/address.test.d.ts +0 -1
  47. package/dist/capability-map/__tests__/address.test.js +0 -49
  48. package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
  49. package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
  50. package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
  51. package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
  52. package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
  53. package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
  54. package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
  55. package/dist/capability-map/__tests__/validate.test.js +0 -212
  56. package/dist/change/__tests__/validate.test.d.ts +0 -1
  57. package/dist/change/__tests__/validate.test.js +0 -79
  58. package/dist/codex/__tests__/example.test.d.ts +0 -1
  59. package/dist/codex/__tests__/example.test.js +0 -33
  60. package/dist/codex/__tests__/validate.test.d.ts +0 -1
  61. package/dist/codex/__tests__/validate.test.js +0 -68
  62. package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
  63. package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
  64. package/dist/compliance/__tests__/classify.test.d.ts +0 -1
  65. package/dist/compliance/__tests__/classify.test.js +0 -58
  66. package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
  67. package/dist/compliance/__tests__/confidence.test.js +0 -78
  68. package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
  69. package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
  70. package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
  71. package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
  72. package/dist/compliance/__tests__/example.test.d.ts +0 -1
  73. package/dist/compliance/__tests__/example.test.js +0 -51
  74. package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
  75. package/dist/compliance/__tests__/gap-report.test.js +0 -113
  76. package/dist/compliance/__tests__/html.test.d.ts +0 -1
  77. package/dist/compliance/__tests__/html.test.js +0 -122
  78. package/dist/compliance/__tests__/impact.test.d.ts +0 -1
  79. package/dist/compliance/__tests__/impact.test.js +0 -913
  80. package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
  81. package/dist/compliance/__tests__/markdown.test.js +0 -85
  82. package/dist/compliance/__tests__/trace.test.d.ts +0 -1
  83. package/dist/compliance/__tests__/trace.test.js +0 -144
  84. package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
  85. package/dist/compliance/__tests__/view-resolution.test.js +0 -59
  86. package/dist/compliance/__tests__/views.test.d.ts +0 -1
  87. package/dist/compliance/__tests__/views.test.js +0 -59
  88. package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
  89. package/dist/compliance-matrix/__tests__/build.test.js +0 -183
  90. package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
  91. package/dist/compliance-matrix/__tests__/example.test.js +0 -49
  92. package/dist/confidence/__tests__/score.test.d.ts +0 -1
  93. package/dist/confidence/__tests__/score.test.js +0 -188
  94. package/dist/constraint/__tests__/example.test.d.ts +0 -1
  95. package/dist/constraint/__tests__/example.test.js +0 -14
  96. package/dist/constraint/__tests__/validate.test.d.ts +0 -1
  97. package/dist/constraint/__tests__/validate.test.js +0 -58
  98. package/dist/factor/__tests__/validate.test.d.ts +0 -1
  99. package/dist/factor/__tests__/validate.test.js +0 -112
  100. package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
  101. package/dist/fgca/__tests__/chain-table.test.js +0 -158
  102. package/dist/fgca/__tests__/layout.test.d.ts +0 -1
  103. package/dist/fgca/__tests__/layout.test.js +0 -140
  104. package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
  105. package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
  106. package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
  107. package/dist/fgca/__tests__/preview-layout.test.js +0 -106
  108. package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
  109. package/dist/fgca/__tests__/resolver.test.js +0 -185
  110. package/dist/fgca/__tests__/validate.test.d.ts +0 -1
  111. package/dist/fgca/__tests__/validate.test.js +0 -125
  112. package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
  113. package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
  114. package/dist/goals/__tests__/layout.test.d.ts +0 -1
  115. package/dist/goals/__tests__/layout.test.js +0 -153
  116. package/dist/goals/__tests__/mutations.test.d.ts +0 -1
  117. package/dist/goals/__tests__/mutations.test.js +0 -134
  118. package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
  119. package/dist/goals/__tests__/parse-canonical.test.js +0 -131
  120. package/dist/goals/__tests__/validate.test.d.ts +0 -1
  121. package/dist/goals/__tests__/validate.test.js +0 -183
  122. package/dist/integration/__tests__/validate.test.d.ts +0 -1
  123. package/dist/integration/__tests__/validate.test.js +0 -169
  124. package/dist/location/__tests__/validate.test.d.ts +0 -1
  125. package/dist/location/__tests__/validate.test.js +0 -107
  126. package/dist/node/__tests__/validate.test.d.ts +0 -1
  127. package/dist/node/__tests__/validate.test.js +0 -100
  128. package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
  129. package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
  130. package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
  131. package/dist/process-blueprint/__tests__/layout.test.js +0 -196
  132. package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
  133. package/dist/process-blueprint/__tests__/validate.test.js +0 -280
  134. package/dist/process-map/__tests__/validate.test.d.ts +0 -1
  135. package/dist/process-map/__tests__/validate.test.js +0 -199
  136. package/dist/products/__tests__/validate.test.d.ts +0 -1
  137. package/dist/products/__tests__/validate.test.js +0 -210
  138. package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
  139. package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
  140. package/dist/requirement/__tests__/example.test.d.ts +0 -1
  141. package/dist/requirement/__tests__/example.test.js +0 -21
  142. package/dist/requirement/__tests__/validate.test.d.ts +0 -1
  143. package/dist/requirement/__tests__/validate.test.js +0 -80
  144. package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
  145. package/dist/scenarios/__tests__/validate.test.js +0 -183
  146. package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
  147. package/dist/stakeholder/__tests__/validate.test.js +0 -88
  148. package/dist/target-state/__tests__/validate.test.d.ts +0 -1
  149. package/dist/target-state/__tests__/validate.test.js +0 -78
  150. package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
  151. package/dist/technology-service/__tests__/validate.test.js +0 -121
  152. package/dist/theme/__tests__/tokens.test.d.ts +0 -1
  153. package/dist/theme/__tests__/tokens.test.js +0 -159
  154. package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
  155. package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
  156. package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
  157. package/dist/webview/__tests__/entry-notations.test.js +0 -62
  158. package/dist/webview/__tests__/entry.test.d.ts +0 -1
  159. package/dist/webview/__tests__/entry.test.js +0 -56
  160. package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
  161. package/dist/webview/__tests__/render-activities.test.js +0 -91
  162. package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
  163. package/dist/webview/__tests__/render-blocks.test.js +0 -175
  164. package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
  165. package/dist/webview/__tests__/render-goals.test.js +0 -120
  166. package/dist/webview/__tests__/render-process.test.d.ts +0 -1
  167. package/dist/webview/__tests__/render-process.test.js +0 -463
  168. package/dist/webview/__tests__/render-util.test.d.ts +0 -1
  169. package/dist/webview/__tests__/render-util.test.js +0 -54
  170. package/src/__tests__/edge-path.test.ts +0 -67
  171. package/src/__tests__/node-size-presets.test.ts +0 -50
  172. package/src/__tests__/scope.test.ts +0 -27
  173. package/src/__tests__/yaml-normalize.test.ts +0 -158
  174. package/src/activities/__tests__/cpm.test.ts +0 -164
  175. package/src/activities/__tests__/gantt.test.ts +0 -290
  176. package/src/activities/__tests__/layout.test.ts +0 -112
  177. package/src/activities/__tests__/validate.test.ts +0 -446
  178. package/src/activity-card/__tests__/example.test.ts +0 -83
  179. package/src/activity-card/__tests__/layout.test.ts +0 -162
  180. package/src/activity-card/__tests__/resolver.test.ts +0 -357
  181. package/src/activity-card/__tests__/validate.test.ts +0 -167
  182. package/src/actor/__tests__/validate.test.ts +0 -114
  183. package/src/applications/__tests__/validate.test.ts +0 -256
  184. package/src/assertion/__tests__/example.test.ts +0 -37
  185. package/src/assertion/__tests__/validate.test.ts +0 -142
  186. package/src/blocks/__tests__/layout.test.ts +0 -169
  187. package/src/blocks/__tests__/validate.test.ts +0 -260
  188. package/src/business-service/__tests__/validate.test.ts +0 -160
  189. package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
  190. package/src/capability-map/__tests__/address.test.ts +0 -59
  191. package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
  192. package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
  193. package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
  194. package/src/capability-map/__tests__/validate.test.ts +0 -238
  195. package/src/change/__tests__/validate.test.ts +0 -97
  196. package/src/codex/__tests__/example.test.ts +0 -40
  197. package/src/codex/__tests__/validate.test.ts +0 -84
  198. package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
  199. package/src/compliance/__tests__/classify.test.ts +0 -64
  200. package/src/compliance/__tests__/confidence.test.ts +0 -98
  201. package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
  202. package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
  203. package/src/compliance/__tests__/example.test.ts +0 -57
  204. package/src/compliance/__tests__/gap-report.test.ts +0 -129
  205. package/src/compliance/__tests__/html.test.ts +0 -142
  206. package/src/compliance/__tests__/impact.test.ts +0 -1060
  207. package/src/compliance/__tests__/markdown.test.ts +0 -95
  208. package/src/compliance/__tests__/trace.test.ts +0 -157
  209. package/src/compliance/__tests__/view-resolution.test.ts +0 -80
  210. package/src/compliance/__tests__/views.test.ts +0 -64
  211. package/src/compliance-matrix/__tests__/build.test.ts +0 -200
  212. package/src/compliance-matrix/__tests__/example.test.ts +0 -57
  213. package/src/confidence/__tests__/score.test.ts +0 -254
  214. package/src/constraint/__tests__/example.test.ts +0 -19
  215. package/src/constraint/__tests__/validate.test.ts +0 -68
  216. package/src/factor/__tests__/validate.test.ts +0 -133
  217. package/src/fgca/__tests__/chain-table.test.ts +0 -172
  218. package/src/fgca/__tests__/layout.test.ts +0 -179
  219. package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
  220. package/src/fgca/__tests__/preview-layout.test.ts +0 -124
  221. package/src/fgca/__tests__/resolver.test.ts +0 -209
  222. package/src/fgca/__tests__/validate.test.ts +0 -142
  223. package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
  224. package/src/goals/__tests__/layout.test.ts +0 -175
  225. package/src/goals/__tests__/mutations.test.ts +0 -153
  226. package/src/goals/__tests__/parse-canonical.test.ts +0 -147
  227. package/src/goals/__tests__/validate.test.ts +0 -202
  228. package/src/integration/__tests__/validate.test.ts +0 -203
  229. package/src/location/__tests__/validate.test.ts +0 -127
  230. package/src/node/__tests__/validate.test.ts +0 -118
  231. package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
  232. package/src/process-blueprint/__tests__/layout.test.ts +0 -240
  233. package/src/process-blueprint/__tests__/validate.test.ts +0 -310
  234. package/src/process-map/__tests__/validate.test.ts +0 -223
  235. package/src/products/__tests__/validate.test.ts +0 -239
  236. package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
  237. package/src/requirement/__tests__/example.test.ts +0 -24
  238. package/src/requirement/__tests__/validate.test.ts +0 -96
  239. package/src/scenarios/__tests__/validate.test.ts +0 -209
  240. package/src/stakeholder/__tests__/validate.test.ts +0 -105
  241. package/src/target-state/__tests__/validate.test.ts +0 -95
  242. package/src/technology-service/__tests__/validate.test.ts +0 -143
  243. package/src/theme/__tests__/tokens.test.ts +0 -185
  244. package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
  245. package/src/webview/__tests__/entry-notations.test.ts +0 -77
  246. package/src/webview/__tests__/entry.test.ts +0 -64
  247. package/src/webview/__tests__/render-activities.test.ts +0 -100
  248. package/src/webview/__tests__/render-blocks.test.ts +0 -206
  249. package/src/webview/__tests__/render-goals.test.ts +0 -128
  250. package/src/webview/__tests__/render-process.test.ts +0 -538
  251. package/src/webview/__tests__/render-util.test.ts +0 -66
@@ -1,209 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import * as fs from 'node:fs';
3
- import * as path from 'node:path';
4
- import yaml from 'js-yaml';
5
- import { resolveFGCA, isFGCAViewDoc } from '../resolver.js';
6
- import { parseCanonicalFGCA } from '../parse-canonical.js';
7
-
8
- // ── Inline canon element store (mirrors strategy-2026 data split into per-element form) ─
9
-
10
- const ELEMENTS = [
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
- { notation: 'goal', id: 'GOAL-1', name: 'Grow revenue by 20%', factors: ['FACTOR-1', 'FACTOR-2'] },
14
- { notation: 'goal', id: 'GOAL-2', name: 'Reduce operational costs', factors: ['FACTOR-2'] },
15
- { notation: 'goal', id: 'GOAL-3', name: 'Improve customer retention', factors: ['FACTOR-1'] },
16
- { notation: 'change', id: 'CHANGE-1', name: 'Launch new product line', goals: ['GOAL-1'] },
17
- { notation: 'change', id: 'CHANGE-2', name: 'Automate manual processes', goals: ['GOAL-2'] },
18
- { notation: 'change', id: 'CHANGE-3', name: 'Enhance support platform', goals: ['GOAL-3'] },
19
- { notation: 'activity', id: 'ACTIVITY-1', name: 'Market research', changes: ['CHANGE-1'] },
20
- { notation: 'activity', id: 'ACTIVITY-2', name: 'MVP development', changes: ['CHANGE-1'] },
21
- { notation: 'activity', id: 'ACTIVITY-3', name: 'Process audit', changes: ['CHANGE-2'] },
22
- { notation: 'activity', id: 'ACTIVITY-4', name: 'RPA tooling rollout', changes: ['CHANGE-2'] },
23
- { notation: 'activity', id: 'ACTIVITY-5', name: 'CRM implementation', changes: ['CHANGE-3'] },
24
- ];
25
-
26
- const SOURCES = { elements: ELEMENTS, relations: [] };
27
-
28
- const VIEW_DOC = {
29
- notation: 'dgca',
30
- id: 'FGCA-STRAT-1',
31
- name: 'Strategy 2026 — FGCA chain',
32
- spec_version: '0.1',
33
- view_config: {
34
- goals: { filter: 'all' },
35
- factors: { surface: 'derived' },
36
- changes: { surface: 'derived' },
37
- activities: { surface: 'derived' },
38
- },
39
- };
40
-
41
- // ── isFGCAViewDoc ─────────────────────────────────────────────────────────────
42
-
43
- describe('isFGCAViewDoc', () => {
44
- it('returns true for a view_config-based doc', () => {
45
- expect(isFGCAViewDoc(VIEW_DOC)).toBe(true);
46
- });
47
-
48
- it('returns false for an inline doc with factors/goals arrays', () => {
49
- expect(isFGCAViewDoc({
50
- notation: 'dgca', id: 'FGCA-1', name: 'x',
51
- factors: [], goals: [], changes: [], activities: [],
52
- })).toBe(false);
53
- });
54
-
55
- it('returns false for non-objects', () => {
56
- expect(isFGCAViewDoc(null)).toBe(false);
57
- expect(isFGCAViewDoc('string')).toBe(false);
58
- expect(isFGCAViewDoc(42)).toBe(false);
59
- });
60
- });
61
-
62
- // ── resolveFGCA — goals.filter=all (default) ──────────────────────────────────
63
-
64
- describe('resolveFGCA — goals.filter=all', () => {
65
- it('includes all goals, changes, and activities', () => {
66
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
67
- expect((doc['goals'] as unknown[]).length).toBe(3);
68
- expect((doc['changes'] as unknown[]).length).toBe(3);
69
- expect((doc['actions'] as unknown[]).length).toBe(5);
70
- });
71
-
72
- it('derives factors from all goal.factors[] refs', () => {
73
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
74
- const factorIds = (doc['factors'] as Array<{ id: string }>).map((f) => f.id);
75
- expect(factorIds).toContain('FACTOR-1');
76
- expect(factorIds).toContain('FACTOR-2');
77
- expect(factorIds.length).toBe(2);
78
- });
79
-
80
- it('passes parseCanonicalFGCA and produces a fully valid internal doc', () => {
81
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
82
- const r = parseCanonicalFGCA(doc);
83
- expect(r.valid).toBe(true);
84
- expect(r.errors).toEqual([]);
85
- expect(r.parsed?.goals).toHaveLength(3);
86
- expect(r.parsed?.factors).toHaveLength(2);
87
- expect(r.parsed?.changes).toHaveLength(3);
88
- expect(r.parsed?.activities).toHaveLength(5);
89
- });
90
-
91
- it('carries view doc metadata (id, name, spec_version)', () => {
92
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
93
- expect(doc['notation']).toBe('dgca');
94
- expect(doc['id']).toBe('FGCA-STRAT-1');
95
- expect(doc['name']).toBe('Strategy 2026 — FGCA chain');
96
- expect(doc['spec_version']).toBe('0.1');
97
- });
98
- });
99
-
100
- // ── resolveFGCA — goals.filter=ids ────────────────────────────────────────────
101
-
102
- describe('resolveFGCA — goals.filter=ids', () => {
103
- it('narrows to the specified goal and its derived changes + activities', () => {
104
- const viewDoc = {
105
- ...VIEW_DOC,
106
- view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
107
- };
108
- const doc = resolveFGCA(viewDoc, SOURCES);
109
- const goalIds = (doc['goals'] as Array<{ id: string }>).map((g) => g.id);
110
- expect(goalIds).toEqual(['GOAL-1']);
111
- const changeIds = (doc['changes'] as Array<{ id: string }>).map((c) => c.id);
112
- expect(changeIds).toEqual(['CHANGE-1']);
113
- const actIds = (doc['actions'] as Array<{ id: string }>).map((a) => a.id).sort();
114
- expect(actIds).toEqual(['ACTIVITY-1', 'ACTIVITY-2']);
115
- const r = parseCanonicalFGCA(doc);
116
- expect(r.valid).toBe(true);
117
- });
118
-
119
- it('returns empty arrays when none of the requested ids exist in canon', () => {
120
- const viewDoc = {
121
- ...VIEW_DOC,
122
- view_config: { goals: { filter: 'ids', ids: ['GOAL-NONEXISTENT-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
123
- };
124
- const doc = resolveFGCA(viewDoc, SOURCES);
125
- expect((doc['goals'] as unknown[]).length).toBe(0);
126
- expect((doc['changes'] as unknown[]).length).toBe(0);
127
- expect((doc['factors'] as unknown[]).length).toBe(0);
128
- });
129
- });
130
-
131
- // ── resolveFGCA — surface=all ─────────────────────────────────────────────────
132
-
133
- describe('resolveFGCA — surface=all', () => {
134
- it('factors.surface=all includes every factor even when only some are referenced', () => {
135
- const viewDoc = {
136
- ...VIEW_DOC,
137
- view_config: { goals: { filter: 'ids', ids: ['GOAL-3'] }, factors: { surface: 'all' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
138
- };
139
- const doc = resolveFGCA(viewDoc, SOURCES);
140
- // GOAL-3 only references FACTOR-1, but surface=all → both factors
141
- expect((doc['factors'] as unknown[]).length).toBe(2);
142
- });
143
-
144
- it('changes.surface=all includes every change', () => {
145
- const viewDoc = {
146
- ...VIEW_DOC,
147
- view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'all' }, activities: { surface: 'derived' } },
148
- };
149
- const doc = resolveFGCA(viewDoc, SOURCES);
150
- expect((doc['changes'] as unknown[]).length).toBe(3);
151
- });
152
- });
153
-
154
- // ── resolveFGCA — empty / degenerate inputs ───────────────────────────────────
155
-
156
- describe('resolveFGCA — empty sources', () => {
157
- it('returns empty arrays when canon has no elements', () => {
158
- const doc = resolveFGCA(VIEW_DOC, { elements: [], relations: [] });
159
- expect((doc['goals'] as unknown[]).length).toBe(0);
160
- expect((doc['factors'] as unknown[]).length).toBe(0);
161
- expect((doc['changes'] as unknown[]).length).toBe(0);
162
- expect((doc['actions'] as unknown[]).length).toBe(0);
163
- });
164
-
165
- it('returns empty arrays for a non-object viewDoc', () => {
166
- const doc = resolveFGCA(null, SOURCES);
167
- expect((doc['goals'] as unknown[]).length).toBe(0);
168
- });
169
- });
170
-
171
- // ── File-based regression — resolver + canon fixture + parseCanonicalFGCA ─────
172
-
173
- describe('resolveFGCA — file-based regression against canon fixture', () => {
174
- const CANON_ROOT = path.resolve(
175
- process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'dgca', 'canon',
176
- );
177
- const VIEW_DIR = path.join(CANON_ROOT, 'views');
178
- const ELEM_DIR = path.join(CANON_ROOT, 'elements');
179
-
180
- function loadYamlsUnder(dir: string): unknown[] {
181
- if (!fs.existsSync(dir)) return [];
182
- const out: unknown[] = [];
183
- function walk(d: string) {
184
- for (const entry of fs.readdirSync(d, { withFileTypes: true })) {
185
- const full = path.join(d, entry.name);
186
- if (entry.isDirectory()) { walk(full); }
187
- else if (entry.name.endsWith('.yaml')) { out.push(yaml.load(fs.readFileSync(full, 'utf8'))); }
188
- }
189
- }
190
- walk(dir);
191
- return out;
192
- }
193
-
194
- const viewFiles = fs.existsSync(VIEW_DIR)
195
- ? fs.readdirSync(VIEW_DIR).filter((f) => f.endsWith('.transitrix.yaml'))
196
- : [];
197
-
198
- for (const file of viewFiles) {
199
- it(`resolves ${file} against canon fixtures and passes parseCanonicalFGCA`, () => {
200
- const viewDoc = yaml.load(fs.readFileSync(path.join(VIEW_DIR, file), 'utf8'));
201
- expect(isFGCAViewDoc(viewDoc)).toBe(true);
202
- const elements = loadYamlsUnder(ELEM_DIR);
203
- const doc = resolveFGCA(viewDoc, { elements, relations: [] });
204
- const r = parseCanonicalFGCA(doc);
205
- expect(r.valid).toBe(true);
206
- expect(r.errors).toEqual([]);
207
- });
208
- }
209
- });
@@ -1,142 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { validateFGCADoc } from '../validate.js';
3
-
4
- const VALID_DOC = {
5
- notation: 'dgca',
6
- factors: [{ id: 1, name: 'Market pressure' }],
7
- goals: [{ id: 1, name: 'Grow revenue', factor: [{ id: 1 }] }],
8
- changes: [{ id: 1, name: 'Launch product', goal_id: 1, activity_ids: [1] }],
9
- actions: [{ id: 1, name: 'Market research', goal_id: 1 }],
10
- };
11
-
12
- describe('validateFGCADoc', () => {
13
- it('accepts a valid document', () => {
14
- const result = validateFGCADoc(VALID_DOC);
15
- expect(result.valid).toBe(true);
16
- expect(result.errors).toHaveLength(0);
17
- });
18
-
19
- it('rejects non-object input', () => {
20
- expect(validateFGCADoc('string').valid).toBe(false);
21
- expect(validateFGCADoc(null).valid).toBe(false);
22
- expect(validateFGCADoc(42).valid).toBe(false);
23
- });
24
-
25
- it('errors on missing notation field', () => {
26
- const { notation: _, ...without } = VALID_DOC;
27
- const result = validateFGCADoc(without);
28
- expect(result.valid).toBe(false);
29
- expect(result.errors[0].code).toBe('MISSING_NOTATION');
30
- });
31
-
32
- it('errors on wrong notation value', () => {
33
- const result = validateFGCADoc({ ...VALID_DOC, notation: 'goals' });
34
- expect(result.valid).toBe(false);
35
- expect(result.errors[0].code).toBe('WRONG_NOTATION');
36
- });
37
-
38
- it('errors when factors array is missing', () => {
39
- const { factors: _, ...without } = VALID_DOC;
40
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
41
- expect(result.valid).toBe(false);
42
- expect(result.errors.some(e => e.path === 'factors')).toBe(true);
43
- });
44
-
45
- it('errors when goals array is missing', () => {
46
- const { goals: _, ...without } = VALID_DOC;
47
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
48
- expect(result.valid).toBe(false);
49
- expect(result.errors.some(e => e.path === 'goals')).toBe(true);
50
- });
51
-
52
- it('errors when changes array is missing', () => {
53
- const { changes: _, ...without } = VALID_DOC;
54
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
55
- expect(result.valid).toBe(false);
56
- expect(result.errors.some(e => e.path === 'changes')).toBe(true);
57
- });
58
-
59
- it('errors when actions array is missing', () => {
60
- const { actions: _, ...without } = VALID_DOC;
61
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
62
- expect(result.valid).toBe(false);
63
- expect(result.errors.some(e => e.path === 'actions')).toBe(true);
64
- });
65
-
66
- it('errors on empty factor name', () => {
67
- const result = validateFGCADoc({ ...VALID_DOC, factors: [{ id: 1, name: '' }] });
68
- expect(result.valid).toBe(false);
69
- expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
70
- });
71
-
72
- it('errors on empty goal name', () => {
73
- const result = validateFGCADoc({ ...VALID_DOC, goals: [{ id: 1, name: ' ', factor: [] }] });
74
- expect(result.valid).toBe(false);
75
- expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
76
- });
77
-
78
- it('warns on broken factor reference in goal', () => {
79
- const result = validateFGCADoc({
80
- ...VALID_DOC,
81
- goals: [{ id: 1, name: 'Goal', factor: [{ id: 99 }] }],
82
- });
83
- expect(result.valid).toBe(true);
84
- expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('factor 99'))).toBe(true);
85
- });
86
-
87
- it('warns on broken goal reference in change', () => {
88
- const result = validateFGCADoc({
89
- ...VALID_DOC,
90
- changes: [{ id: 1, name: 'Change', goal_id: 99, activity_ids: [] }],
91
- });
92
- expect(result.valid).toBe(true);
93
- expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('goal 99'))).toBe(true);
94
- });
95
-
96
- it('warns on broken activity reference in change', () => {
97
- const result = validateFGCADoc({
98
- ...VALID_DOC,
99
- changes: [{ id: 1, name: 'Change', goal_id: 1, activity_ids: [99] }],
100
- });
101
- expect(result.valid).toBe(true);
102
- expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('activity 99'))).toBe(true);
103
- });
104
-
105
- it('accepts a document with empty arrays', () => {
106
- const result = validateFGCADoc({
107
- notation: 'dgca',
108
- factors: [],
109
- goals: [],
110
- changes: [],
111
- actions: [],
112
- });
113
- expect(result.valid).toBe(true);
114
- });
115
-
116
- it('accepts optional spec_version field', () => {
117
- const result = validateFGCADoc({ ...VALID_DOC, spec_version: '0.1' });
118
- expect(result.valid).toBe(true);
119
- });
120
-
121
- // Pre-release blocker regression (orchestrator review 2026-05-21).
122
- it('[blocker] tolerates a null element in goals[] without throwing', () => {
123
- const r = validateFGCADoc({ ...VALID_DOC, goals: [null] });
124
- expect(r.valid).toBe(false);
125
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
126
- });
127
- it('[blocker] tolerates a string element in factors[] without throwing', () => {
128
- const r = validateFGCADoc({ ...VALID_DOC, factors: ['x'] });
129
- expect(r.valid).toBe(false);
130
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
131
- });
132
- it('[blocker] tolerates a null element in changes[] without throwing', () => {
133
- const r = validateFGCADoc({ ...VALID_DOC, changes: [null] });
134
- expect(r.valid).toBe(false);
135
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
136
- });
137
- it('[blocker] tolerates a null element in actions[] without throwing', () => {
138
- const r = validateFGCADoc({ ...VALID_DOC, actions: [null] });
139
- expect(r.valid).toBe(false);
140
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
141
- });
142
- });