@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,169 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { layoutNestedBlocks, iterateBlocks } from '../layout.js';
3
- import type { BlocksFile, LaidOutBlock } from '../types.js';
4
-
5
- function findById(layout: ReturnType<typeof layoutNestedBlocks>, id: string): LaidOutBlock | undefined {
6
- for (const b of iterateBlocks(layout)) {
7
- if (b.id === id) return b;
8
- }
9
- return undefined;
10
- }
11
-
12
- const TWO_TOP_LEVEL: BlocksFile = {
13
- notation: 'blocks',
14
- spec_version: '0.1',
15
- nested_blocks: {
16
- id: 'BLOCKS-ARCH-1',
17
- name: 'Software architecture',
18
- blocks: [
19
- {
20
- id: 'APPLICATION_LAYER',
21
- name: 'Application Layer',
22
- children: [
23
- {
24
- id: 'FRONTEND',
25
- name: 'Frontend',
26
- children: [
27
- { id: 'REACT_APP', name: 'React App' },
28
- { id: 'REDUX_STORE', name: 'Redux Store' },
29
- ],
30
- },
31
- {
32
- id: 'BACKEND',
33
- name: 'Backend',
34
- children: [
35
- { id: 'REST_API', name: 'REST API' },
36
- { id: 'BUSINESS_LOGIC', name: 'Business Logic' },
37
- ],
38
- },
39
- ],
40
- },
41
- {
42
- id: 'DATA_LAYER',
43
- name: 'Data Layer',
44
- children: [
45
- { id: 'POSTGRESQL', name: 'PostgreSQL' },
46
- { id: 'REDIS_CACHE', name: 'Redis Cache' },
47
- ],
48
- },
49
- ],
50
- },
51
- };
52
-
53
- describe('layoutNestedBlocks', () => {
54
- it('lays out top-level blocks vertically starting at y=0', () => {
55
- const layout = layoutNestedBlocks(TWO_TOP_LEVEL);
56
- expect(layout.blocks).toHaveLength(2);
57
- expect(layout.blocks[0].y).toBe(0);
58
- expect(layout.blocks[1].y).toBeGreaterThan(layout.blocks[0].y + layout.blocks[0].height);
59
- });
60
-
61
- it('assigns depth=1 to top-level blocks and increases for each nesting level', () => {
62
- const layout = layoutNestedBlocks(TWO_TOP_LEVEL);
63
- const app = findById(layout, 'APPLICATION_LAYER')!;
64
- const frontend = findById(layout, 'FRONTEND')!;
65
- const react = findById(layout, 'REACT_APP')!;
66
- expect(app.depth).toBe(1);
67
- expect(frontend.depth).toBe(2);
68
- expect(react.depth).toBe(3);
69
- });
70
-
71
- it('records max depth on the layout', () => {
72
- const layout = layoutNestedBlocks(TWO_TOP_LEVEL);
73
- expect(layout.maxDepth).toBe(3);
74
- });
75
-
76
- it('places every child strictly inside its parent (containment property)', () => {
77
- const layout = layoutNestedBlocks(TWO_TOP_LEVEL);
78
-
79
- function checkContainment(b: LaidOutBlock): void {
80
- for (const c of b.children) {
81
- expect(c.x).toBeGreaterThanOrEqual(b.x);
82
- expect(c.y).toBeGreaterThanOrEqual(b.y + b.headerHeight);
83
- expect(c.x + c.width).toBeLessThanOrEqual(b.x + b.width);
84
- expect(c.y + c.height).toBeLessThanOrEqual(b.y + b.height);
85
- checkContainment(c);
86
- }
87
- }
88
-
89
- for (const top of layout.blocks) checkContainment(top);
90
- });
91
-
92
- it('siblings do not overlap', () => {
93
- const layout = layoutNestedBlocks(TWO_TOP_LEVEL);
94
-
95
- function checkSiblings(b: LaidOutBlock): void {
96
- for (let i = 0; i < b.children.length; i++) {
97
- for (let j = i + 1; j < b.children.length; j++) {
98
- const a = b.children[i];
99
- const c = b.children[j];
100
- const disjointX = a.x + a.width <= c.x || c.x + c.width <= a.x;
101
- const disjointY = a.y + a.height <= c.y || c.y + c.height <= a.y;
102
- expect(disjointX || disjointY).toBe(true);
103
- }
104
- checkSiblings(b.children[i]);
105
- }
106
- }
107
-
108
- for (const top of layout.blocks) checkSiblings(top);
109
- });
110
-
111
- it('a leaf block uses the configured leaf dimensions', () => {
112
- const layout = layoutNestedBlocks({
113
- notation: 'blocks',
114
- nested_blocks: {
115
- id: 'BLOCKS-LEAF-1',
116
- name: 'Leaf only',
117
- blocks: [{ id: 'A', name: 'A' }],
118
- },
119
- });
120
- const a = layout.blocks[0];
121
- expect(a.width).toBe(250);
122
- expect(a.height).toBe(80);
123
- });
124
-
125
- it('honours custom layout options', () => {
126
- const layout = layoutNestedBlocks(
127
- {
128
- notation: 'blocks',
129
- nested_blocks: {
130
- id: 'BLOCKS-LEAF-1',
131
- name: 'Leaf only',
132
- blocks: [{ id: 'A', name: 'A' }],
133
- },
134
- },
135
- { leafWidth: 200, leafHeight: 80 },
136
- );
137
- expect(layout.blocks[0].width).toBe(200);
138
- expect(layout.blocks[0].height).toBe(80);
139
- });
140
-
141
- it('iterateBlocks visits every block once in pre-order', () => {
142
- const layout = layoutNestedBlocks(TWO_TOP_LEVEL);
143
- const ids = Array.from(iterateBlocks(layout)).map((b) => b.id);
144
- expect(ids).toEqual([
145
- 'APPLICATION_LAYER',
146
- 'FRONTEND',
147
- 'REACT_APP',
148
- 'REDUX_STORE',
149
- 'BACKEND',
150
- 'REST_API',
151
- 'BUSINESS_LOGIC',
152
- 'DATA_LAYER',
153
- 'POSTGRESQL',
154
- 'REDIS_CACHE',
155
- ]);
156
- });
157
-
158
- it('handles an empty top-level array gracefully (returns zero-size bounds)', () => {
159
- const layout = layoutNestedBlocks({
160
- notation: 'blocks',
161
- // Schema-wise this is invalid (BL-004), but the layout function still
162
- // needs to be defensive — validation runs separately.
163
- nested_blocks: { id: 'X', name: 'X', blocks: [] },
164
- });
165
- expect(layout.blocks).toHaveLength(0);
166
- expect(layout.bounds.width).toBe(0);
167
- expect(layout.bounds.height).toBe(0);
168
- });
169
- });
@@ -1,260 +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 { validateNestedBlocks } from '../validate.js';
6
-
7
- const EXAMPLES_DIR = path.resolve(process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'blocks');
8
-
9
- const VALID_DOC = {
10
- notation: 'blocks',
11
- spec_version: '0.1',
12
- nested_blocks: {
13
- id: 'BLOCKS-ARCH-1',
14
- name: 'Software architecture',
15
- blocks: [
16
- {
17
- id: 'APPLICATION_LAYER',
18
- name: 'Application Layer',
19
- children: [
20
- { id: 'FRONTEND', name: 'Frontend' },
21
- { id: 'BACKEND', name: 'Backend' },
22
- ],
23
- },
24
- {
25
- id: 'DATA_LAYER',
26
- name: 'Data Layer',
27
- children: [
28
- { id: 'POSTGRESQL', name: 'PostgreSQL' },
29
- { id: 'REDIS_CACHE', name: 'Redis Cache' },
30
- ],
31
- },
32
- ],
33
- },
34
- };
35
-
36
- describe('validateNestedBlocks', () => {
37
- it('passes on a valid document', () => {
38
- const r = validateNestedBlocks(VALID_DOC);
39
- expect(r.valid).toBe(true);
40
- expect(r.errors).toHaveLength(0);
41
- });
42
-
43
- it('BL-001: rejects non-object input', () => {
44
- expect(validateNestedBlocks(null).valid).toBe(false);
45
- expect(validateNestedBlocks(null).errors[0].code).toBe('BL-001');
46
- expect(validateNestedBlocks('string').errors[0].code).toBe('BL-001');
47
- });
48
-
49
- it('BL-001: rejects missing nested_blocks root key', () => {
50
- const r = validateNestedBlocks({ notation: 'blocks' });
51
- expect(r.errors.some((e) => e.code === 'BL-001')).toBe(true);
52
- });
53
-
54
- it('BL-001: rejects wrong notation value', () => {
55
- const r = validateNestedBlocks({ ...VALID_DOC, notation: 'goals' });
56
- expect(r.errors.some((e) => e.code === 'BL-001')).toBe(true);
57
- });
58
-
59
- it('BL-001: tolerates a missing notation field (header check is contract-level)', () => {
60
- const { notation: _, ...rest } = VALID_DOC;
61
- const r = validateNestedBlocks(rest);
62
- expect(r.errors.some((e) => e.code === 'BL-001')).toBe(false);
63
- });
64
-
65
- it('BL-002: rejects missing id', () => {
66
- const r = validateNestedBlocks({
67
- ...VALID_DOC,
68
- nested_blocks: { ...VALID_DOC.nested_blocks, id: '' },
69
- });
70
- expect(r.errors.some((e) => e.code === 'BL-002')).toBe(true);
71
- });
72
-
73
- it('BL-002: rejects id that does not match BLOCKS grammar', () => {
74
- const r = validateNestedBlocks({
75
- ...VALID_DOC,
76
- nested_blocks: { ...VALID_DOC.nested_blocks, id: 'BLK-1' },
77
- });
78
- expect(r.errors.some((e) => e.code === 'BL-002')).toBe(true);
79
- });
80
-
81
- it('BL-003: rejects missing name', () => {
82
- const r = validateNestedBlocks({
83
- ...VALID_DOC,
84
- nested_blocks: { ...VALID_DOC.nested_blocks, name: '' },
85
- });
86
- expect(r.errors.some((e) => e.code === 'BL-003')).toBe(true);
87
- });
88
-
89
- it('BL-004: rejects missing blocks array', () => {
90
- const { blocks: _, ...rest } = VALID_DOC.nested_blocks;
91
- const r = validateNestedBlocks({ ...VALID_DOC, nested_blocks: rest });
92
- expect(r.errors.some((e) => e.code === 'BL-004')).toBe(true);
93
- });
94
-
95
- it('BL-004: rejects empty blocks array', () => {
96
- const r = validateNestedBlocks({
97
- ...VALID_DOC,
98
- nested_blocks: { ...VALID_DOC.nested_blocks, blocks: [] },
99
- });
100
- expect(r.errors.some((e) => e.code === 'BL-004')).toBe(true);
101
- });
102
-
103
- it('BL-005: rejects block missing id', () => {
104
- const r = validateNestedBlocks({
105
- ...VALID_DOC,
106
- nested_blocks: {
107
- ...VALID_DOC.nested_blocks,
108
- blocks: [{ name: 'Anonymous' }],
109
- },
110
- });
111
- expect(r.errors.some((e) => e.code === 'BL-005' && /id/.test(e.message))).toBe(true);
112
- });
113
-
114
- it('BL-005: rejects block missing name', () => {
115
- const r = validateNestedBlocks({
116
- ...VALID_DOC,
117
- nested_blocks: {
118
- ...VALID_DOC.nested_blocks,
119
- blocks: [{ id: 'X', name: '' }],
120
- },
121
- });
122
- expect(r.errors.some((e) => e.code === 'BL-005' && /name/.test(e.message))).toBe(true);
123
- });
124
-
125
- it('BL-005: rejects an id with whitespace (not a valid free label)', () => {
126
- const r = validateNestedBlocks({
127
- ...VALID_DOC,
128
- nested_blocks: {
129
- ...VALID_DOC.nested_blocks,
130
- blocks: [{ id: 'bad id', name: 'X' }],
131
- },
132
- });
133
- expect(r.errors.some((e) => e.code === 'BL-005' && /whitespace/.test(e.message))).toBe(true);
134
- });
135
-
136
- it('BL-006: rejects a canonical-shaped id whose TYPE is not registered', () => {
137
- const r = validateNestedBlocks({
138
- ...VALID_DOC,
139
- nested_blocks: {
140
- ...VALID_DOC.nested_blocks,
141
- blocks: [{ id: 'XYZ-SOMETHING-1', name: 'X' }],
142
- },
143
- });
144
- expect(r.errors.some((e) => e.code === 'BL-006')).toBe(true);
145
- });
146
-
147
- it('BL-006: accepts canonical ids with registered TYPE (APPLICATION-OMS-1)', () => {
148
- const r = validateNestedBlocks({
149
- ...VALID_DOC,
150
- nested_blocks: {
151
- ...VALID_DOC.nested_blocks,
152
- blocks: [{ id: 'APPLICATION-OMS-1', name: 'OMS' }],
153
- },
154
- });
155
- expect(r.errors.some((e) => e.code === 'BL-006')).toBe(false);
156
- });
157
-
158
- it('BL-006: accepts the CAPABILITY V/H exception (CAPABILITY-V1.2)', () => {
159
- const r = validateNestedBlocks({
160
- ...VALID_DOC,
161
- nested_blocks: {
162
- ...VALID_DOC.nested_blocks,
163
- blocks: [{ id: 'CAPABILITY-V1.2', name: 'Order intake' }],
164
- },
165
- });
166
- expect(r.errors.some((e) => e.code === 'BL-006')).toBe(false);
167
- });
168
-
169
- it('BL-006: accepts free-form local labels (APPLICATION_LAYER, frontend, my-thing)', () => {
170
- const r = validateNestedBlocks({
171
- ...VALID_DOC,
172
- nested_blocks: {
173
- ...VALID_DOC.nested_blocks,
174
- blocks: [
175
- { id: 'APPLICATION_LAYER', name: 'AL' },
176
- { id: 'my-thing', name: 'MT' },
177
- { id: 'FRONTEND', name: 'FE' },
178
- ],
179
- },
180
- });
181
- expect(r.errors.some((e) => e.code === 'BL-006')).toBe(false);
182
- });
183
-
184
- it('BL-007: rejects duplicate ids anywhere in the tree', () => {
185
- const r = validateNestedBlocks({
186
- ...VALID_DOC,
187
- nested_blocks: {
188
- ...VALID_DOC.nested_blocks,
189
- blocks: [
190
- {
191
- id: 'A',
192
- name: 'A',
193
- children: [{ id: 'A', name: 'A again' }],
194
- },
195
- ],
196
- },
197
- });
198
- expect(r.errors.some((e) => e.code === 'BL-007' && /Duplicate/.test(e.message))).toBe(true);
199
- });
200
-
201
- it('BL-008: warns when nesting exceeds depth 5', () => {
202
- // 6-deep chain: blocks[0] (depth 1) → c → c → c → c → c (depth 6)
203
- let inner: Record<string, unknown> = { id: 'L6', name: 'L6' };
204
- for (const id of ['L5', 'L4', 'L3', 'L2', 'L1']) {
205
- inner = { id, name: id, children: [inner] };
206
- }
207
- const r = validateNestedBlocks({
208
- ...VALID_DOC,
209
- nested_blocks: { ...VALID_DOC.nested_blocks, blocks: [inner] },
210
- });
211
- expect(r.warnings.some((w) => w.code === 'BL-008')).toBe(true);
212
- expect(r.valid).toBe(true);
213
- });
214
-
215
- it('BL-008: does not warn at exactly depth 5', () => {
216
- let inner: Record<string, unknown> = { id: 'L5', name: 'L5' };
217
- for (const id of ['L4', 'L3', 'L2', 'L1']) {
218
- inner = { id, name: id, children: [inner] };
219
- }
220
- const r = validateNestedBlocks({
221
- ...VALID_DOC,
222
- nested_blocks: { ...VALID_DOC.nested_blocks, blocks: [inner] },
223
- });
224
- expect(r.warnings.some((w) => w.code === 'BL-008')).toBe(false);
225
- });
226
-
227
- it('BL-009: warns on an empty children array', () => {
228
- const r = validateNestedBlocks({
229
- ...VALID_DOC,
230
- nested_blocks: {
231
- ...VALID_DOC.nested_blocks,
232
- blocks: [{ id: 'A', name: 'A', children: [] }],
233
- },
234
- });
235
- expect(r.warnings.some((w) => w.code === 'BL-009')).toBe(true);
236
- expect(r.valid).toBe(true);
237
- });
238
-
239
- it('happy path: surfaces no warnings on a clean document', () => {
240
- const r = validateNestedBlocks(VALID_DOC);
241
- expect(r.valid).toBe(true);
242
- expect(r.warnings).toHaveLength(0);
243
- });
244
- });
245
-
246
- describe('blocks examples (regression)', () => {
247
- const files = fs.existsSync(EXAMPLES_DIR)
248
- ? fs.readdirSync(EXAMPLES_DIR).filter((f) => f.endsWith('.yaml'))
249
- : [];
250
- expect(files.length).toBeGreaterThan(0);
251
- for (const file of files) {
252
- it(`validates tests/fixtures/notation-corpus/blocks/${file}`, () => {
253
- const text = fs.readFileSync(path.join(EXAMPLES_DIR, file), 'utf8');
254
- const parsed = yaml.load(text);
255
- const r = validateNestedBlocks(parsed);
256
- expect(r.errors).toEqual([]);
257
- expect(r.valid).toBe(true);
258
- });
259
- }
260
- });
@@ -1,160 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { validateBusinessService } from '../validate.js';
3
-
4
- function valid(): Record<string, unknown> {
5
- return {
6
- notation: 'business-service',
7
- id: 'BUSINESS_SERVICE-CRM-1',
8
- name: 'CRM Service',
9
- type: 'internal',
10
- description: 'Customer relationship management service offering contact management and deal tracking.',
11
- offering_unit: 'ACTOR-SALES-OPS-1',
12
- capability: 'CAPABILITY-V2.1',
13
- zone: 'canon',
14
- admitted_at: '2026-06-28',
15
- admitted_by: 'v.korobeinikov',
16
- gate_checks: { uniqueness: 'pass', consistency: 'pass', completeness: 'pass' },
17
- valid_from: '2024-01-01',
18
- valid_to: null,
19
- };
20
- }
21
-
22
- const codes = (input: unknown): string[] =>
23
- validateBusinessService(input).errors.map(e => e.code);
24
-
25
- describe('validateBusinessService — positive', () => {
26
- it('accepts a well-formed internal service with all optional fields', () => {
27
- const r = validateBusinessService(valid());
28
- expect(r.valid, JSON.stringify(r.errors)).toBe(true);
29
- });
30
-
31
- it('accepts an external service with no optional fields', () => {
32
- const a = valid();
33
- a.id = 'BUSINESS_SERVICE-ONBOARDING-1';
34
- a.name = 'Onboarding Service';
35
- a.type = 'external';
36
- delete a.description;
37
- delete a.offering_unit;
38
- delete a.capability;
39
- expect(validateBusinessService(a).valid).toBe(true);
40
- });
41
-
42
- it('accepts a shared service offered by a ROLE', () => {
43
- expect(validateBusinessService({ ...valid(), type: 'shared', offering_unit: 'ROLE-PLATFORM-OWNER-1' }).valid).toBe(true);
44
- });
45
-
46
- it('accepts valid_to as a date string', () => {
47
- expect(validateBusinessService({ ...valid(), valid_to: '2026-12-31' }).valid).toBe(true);
48
- });
49
-
50
- it('accepts a service with no offering_unit or capability', () => {
51
- const a = valid();
52
- delete a.offering_unit;
53
- delete a.capability;
54
- expect(validateBusinessService(a).valid).toBe(true);
55
- });
56
- });
57
-
58
- describe('validateBusinessService — BSV-001 (shape / id grammar)', () => {
59
- it('flags a missing required envelope field (name)', () => {
60
- const a = valid();
61
- delete a.name;
62
- expect(codes(a)).toContain('BSV-001');
63
- });
64
-
65
- it('flags an id that violates the grammar', () => {
66
- expect(codes({ ...valid(), id: 'BUSINESS_SERVICE-001' })).toContain('BSV-001');
67
- expect(codes({ ...valid(), id: 'BSV-1' })).toContain('BSV-001');
68
- expect(codes({ ...valid(), id: 'business-service-1' })).toContain('BSV-001');
69
- });
70
-
71
- it('flags a wrong notation tag', () => {
72
- expect(codes({ ...valid(), notation: 'service' })).toContain('BSV-001');
73
- expect(codes({ ...valid(), notation: 'business_service' })).toContain('BSV-001');
74
- });
75
-
76
- it('flags a non-canon zone', () => {
77
- expect(codes({ ...valid(), zone: 'sandbox' })).toContain('BSV-001');
78
- });
79
-
80
- it('flags a missing zone', () => {
81
- const a = valid();
82
- delete a.zone;
83
- expect(codes(a)).toContain('BSV-001');
84
- });
85
-
86
- it('flags a missing type', () => {
87
- const a = valid();
88
- delete a.type;
89
- expect(codes(a)).toContain('BSV-001');
90
- });
91
-
92
- it('flags a missing valid_to key', () => {
93
- const a = valid();
94
- delete a.valid_to;
95
- expect(codes(a)).toContain('BSV-001');
96
- });
97
-
98
- it('flags missing gate_checks', () => {
99
- const a = valid();
100
- delete a.gate_checks;
101
- expect(codes(a)).toContain('BSV-001');
102
- });
103
-
104
- it('rejects a non-object', () => {
105
- expect(codes(null)).toEqual(['BSV-001']);
106
- expect(codes('string')).toEqual(['BSV-001']);
107
- });
108
- });
109
-
110
- describe('validateBusinessService — BSV-002 (type enum)', () => {
111
- it('flags a type outside the allowed enum', () => {
112
- expect(codes({ ...valid(), type: 'public' })).toContain('BSV-002');
113
- expect(codes({ ...valid(), type: 'platform' })).toContain('BSV-002');
114
- });
115
-
116
- it('accepts all valid type values', () => {
117
- for (const t of ['internal', 'external', 'shared']) {
118
- expect(codes({ ...valid(), type: t })).not.toContain('BSV-002');
119
- }
120
- });
121
- });
122
-
123
- describe('validateBusinessService — BSV-003 (offering_unit grammar)', () => {
124
- it('flags an offering_unit that is not an ACTOR-… or ROLE-… id', () => {
125
- expect(codes({ ...valid(), offering_unit: 'PRODUCT-PLATFORM-1' })).toContain('BSV-003');
126
- expect(codes({ ...valid(), offering_unit: 'not-an-id' })).toContain('BSV-003');
127
- expect(codes({ ...valid(), offering_unit: 'BUSINESS_SERVICE-CRM-1' })).toContain('BSV-003');
128
- });
129
-
130
- it('accepts a null or absent offering_unit without error', () => {
131
- expect(codes({ ...valid(), offering_unit: undefined })).not.toContain('BSV-003');
132
- const a = valid();
133
- delete a.offering_unit;
134
- expect(codes(a)).not.toContain('BSV-003');
135
- });
136
-
137
- it('accepts ACTOR-… and ROLE-… ids', () => {
138
- expect(codes({ ...valid(), offering_unit: 'ACTOR-OPS-1' })).not.toContain('BSV-003');
139
- expect(codes({ ...valid(), offering_unit: 'ROLE-SERVICE-OWNER-1' })).not.toContain('BSV-003');
140
- });
141
- });
142
-
143
- describe('validateBusinessService — BSV-004 (capability grammar)', () => {
144
- it('flags a capability that is not a CAPABILITY-… id', () => {
145
- expect(codes({ ...valid(), capability: 'PRODUCT-MOBILE-1' })).toContain('BSV-004');
146
- expect(codes({ ...valid(), capability: 'not-a-capability' })).toContain('BSV-004');
147
- });
148
-
149
- it('accepts a null or absent capability without error', () => {
150
- expect(codes({ ...valid(), capability: undefined })).not.toContain('BSV-004');
151
- const a = valid();
152
- delete a.capability;
153
- expect(codes(a)).not.toContain('BSV-004');
154
- });
155
-
156
- it('accepts a CAPABILITY-… id', () => {
157
- expect(codes({ ...valid(), capability: 'CAPABILITY-V2.1' })).not.toContain('BSV-004');
158
- expect(codes({ ...valid(), capability: 'CAPABILITY-H3.1' })).not.toContain('BSV-004');
159
- });
160
- });