@principal-ai/subsystems-react 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/README.md +11 -85
  2. package/dist/index.d.ts +7 -44
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +6 -32
  5. package/dist/index.js.map +1 -1
  6. package/dist/subsystem/SubsystemCarousel.d.ts +36 -0
  7. package/dist/subsystem/SubsystemCarousel.d.ts.map +1 -0
  8. package/dist/subsystem/SubsystemCarousel.js +163 -0
  9. package/dist/subsystem/SubsystemCarousel.js.map +1 -0
  10. package/dist/subsystem/SubsystemComponentGraph.d.ts +25 -0
  11. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  12. package/dist/subsystem/SubsystemComponentGraph.js +329 -68
  13. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  14. package/package.json +4 -4
  15. package/src/index.ts +9 -199
  16. package/src/subsystem/SubsystemComponentGraph.tsx +396 -50
  17. package/src/components/ConfigurationSelector.tsx +0 -133
  18. package/src/components/GraphRenderer.tsx +0 -3195
  19. package/src/components/MultiCanvasRenderer.tsx +0 -295
  20. package/src/components/NodeTooltip.tsx +0 -279
  21. package/src/components/PendingChanges.test.tsx +0 -375
  22. package/src/components/SelectionSidebar.tsx +0 -352
  23. package/src/components/SequenceDiagramRenderer.tsx +0 -1156
  24. package/src/components/WorkflowSequenceDiagram.tsx +0 -270
  25. package/src/components/dashboard/DashboardRenderer.tsx +0 -317
  26. package/src/components/dashboard/MetricPanel.tsx +0 -254
  27. package/src/components/dashboard/MockDataProvider.ts +0 -330
  28. package/src/components/dashboard/components/BarChart.tsx +0 -299
  29. package/src/components/dashboard/components/LineChart.tsx +0 -279
  30. package/src/components/dashboard/components/MetricCard.tsx +0 -270
  31. package/src/components/dashboard/components/SourceLink.tsx +0 -63
  32. package/src/components/dashboard/components/TimeRangeSelector.tsx +0 -280
  33. package/src/components/dashboard/components/index.ts +0 -5
  34. package/src/components/dashboard/index.ts +0 -47
  35. package/src/components/dashboard/types.ts +0 -126
  36. package/src/components/state-view/PipelineView.tsx +0 -347
  37. package/src/components/state-view/index.ts +0 -14
  38. package/src/components/state-view/types.ts +0 -261
  39. package/src/components/state-view/useStateView.ts +0 -205
  40. package/src/contexts/GraphEditContext.tsx +0 -27
  41. package/src/contexts/TooltipPortalContext.ts +0 -8
  42. package/src/edges/CustomEdge.tsx +0 -402
  43. package/src/edges/GenericEdge.tsx +0 -36
  44. package/src/hooks/usePathBasedEvents.ts +0 -192
  45. package/src/hooks/useSequenceLayout.ts +0 -543
  46. package/src/hooks/useUndoRedo.ts +0 -144
  47. package/src/nodes/CustomNode.tsx +0 -1231
  48. package/src/nodes/GenericNode.tsx +0 -55
  49. package/src/nodes/otel/OtelBoundaryNode.tsx +0 -224
  50. package/src/nodes/otel/OtelEventNode.tsx +0 -225
  51. package/src/nodes/otel/OtelResourceNode.tsx +0 -251
  52. package/src/nodes/otel/OtelScopeNode.tsx +0 -221
  53. package/src/nodes/otel/OtelSpanConventionNode.tsx +0 -295
  54. package/src/nodes/otel/index.ts +0 -23
  55. package/src/nodes/otel/shared/NodeBadges.tsx +0 -295
  56. package/src/nodes/otel/shared/NodeContent.tsx +0 -204
  57. package/src/nodes/otel/shared/index.ts +0 -8
  58. package/src/nodes/otel/shared/types.ts +0 -138
  59. package/src/nodes/otel/shared/useNodeBehavior.ts +0 -114
  60. package/src/stories/Audit/BoundaryNodes.stories.tsx +0 -385
  61. package/src/stories/Audit/CanvasEdgeTypes.stories.tsx +0 -1448
  62. package/src/stories/Audit/CanvasNodeTypes.stories.tsx +0 -1049
  63. package/src/stories/Audit/ColorPriority.stories.tsx +0 -895
  64. package/src/stories/Audit/DiamondBadges.stories.tsx +0 -629
  65. package/src/stories/Audit/NodeDimensionsTesting.stories.tsx +0 -724
  66. package/src/stories/Audit/NodeFieldsAudit.stories.tsx +0 -996
  67. package/src/stories/Audit/NodeFontSizeTesting.stories.tsx +0 -715
  68. package/src/stories/Audit/NodeShapes.stories.tsx +0 -1208
  69. package/src/stories/Audit/WideNodesTesting.stories.tsx +0 -1045
  70. package/src/stories/Components/DashboardRenderer.stories.tsx +0 -263
  71. package/src/stories/Components/GraphRenderer.stories.tsx +0 -3236
  72. package/src/stories/Components/MultiCanvasRenderer.stories.tsx +0 -370
  73. package/src/stories/Components/SequenceDiagram.stories.tsx +0 -255
  74. package/src/stories/Components/StateView.stories.tsx +0 -417
  75. package/src/stories/Components/TraceViewer.stories.tsx +0 -442
  76. package/src/stories/Components/WorkflowSequenceDiagram.stories.tsx +0 -802
  77. package/src/stories/Features/AnimationWorkshop.stories.tsx +0 -727
  78. package/src/stories/Features/ChangeTypeVisual.stories.tsx +0 -67
  79. package/src/stories/Features/EventDrivenAnimations.stories.tsx +0 -513
  80. package/src/stories/Features/MultiConfig.stories.tsx +0 -539
  81. package/src/stories/Layout/ElkEdgeRouting.stories.tsx +0 -539
  82. package/src/stories/Layout/GraphOrientation.stories.tsx +0 -500
  83. package/src/stories/Layout/MultiDirectionalConnections.stories.tsx +0 -352
  84. package/src/stories/Nodes/NodeDefinitionComparison.stories.tsx +0 -560
  85. package/src/stories/Nodes/NodeNameFallbacks.stories.tsx +0 -491
  86. package/src/stories/Nodes/NumericColors.stories.tsx +0 -440
  87. package/src/stories/OTEL/EventNameDisplay.stories.tsx +0 -694
  88. package/src/stories/OTEL/EventNameFallback.stories.tsx +0 -578
  89. package/src/stories/OTEL/OtelComponents.stories.tsx +0 -422
  90. package/src/stories/OTEL/OtelNodeTypesPrototype.stories.tsx +0 -806
  91. package/src/stories/OTEL/RawEventCards.stories.tsx +0 -57
  92. package/src/stories/OTEL/SpanBadges.stories.tsx +0 -840
  93. package/src/stories/OTEL/ValidationEventsCanvas.stories.tsx +0 -209
  94. package/src/stories/RealWorld/BacklogMdCanvases.stories.tsx +0 -721
  95. package/src/stories/RealWorld/FileCitySequence.stories.tsx +0 -516
  96. package/src/stories/RealWorld/RealCanvasFiles.stories.tsx +0 -336
  97. package/src/stories/__traces__/test-run.canvas.json +0 -241
  98. package/src/stories/data/activity-feed-analytics.dashboard.json +0 -300
  99. package/src/stories/data/file-city-images-transformed.otel.canvas.json +0 -295
  100. package/src/stories/data/file-city-workflows.json +0 -269
  101. package/src/stories/data/graph-converter-test-execution.json +0 -443
  102. package/src/stories/data/graph-converter-test.workflow.json +0 -105
  103. package/src/stories/data/graph-converter-validated-execution.json +0 -58
  104. package/src/utils/animationMapping.ts +0 -166
  105. package/src/utils/canvasBounds.ts +0 -146
  106. package/src/utils/graphConverter.ts +0 -148
  107. package/src/utils/iconResolver.tsx +0 -53
  108. package/src/utils/orientationUtils.ts +0 -73
@@ -1,442 +0,0 @@
1
- import React from 'react';
2
- import type { Meta, StoryObj } from '@storybook/react';
3
- import { GraphRenderer } from '../../components/GraphRenderer';
4
- import type { ExtendedCanvas } from '@principal-ai/subsystems-core';
5
- import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
6
-
7
- // Import captured trace canvas data
8
- import testRunTrace from '../__traces__/test-run.canvas.json';
9
-
10
- const meta = {
11
- title: 'Components/TraceViewer',
12
- component: GraphRenderer,
13
- parameters: {
14
- layout: 'fullscreen',
15
- docs: {
16
- description: {
17
- component: `
18
- # Trace Viewer
19
-
20
- Visualizes OpenTelemetry traces captured from test runs as canvas diagrams.
21
-
22
- ## How it works
23
-
24
- 1. Tests are instrumented with OpenTelemetry SDK
25
- 2. Spans are collected during test execution
26
- 3. At test completion, spans are converted to ExtendedCanvas format
27
- 4. The canvas is rendered here for visualization
28
-
29
- ## Generating new traces
30
-
31
- \`\`\`bash
32
- # Run tests with canvas output enabled
33
- OTEL_CANVAS_OUTPUT=true bun run test:core
34
-
35
- # Traces are saved to packages/subsystems-core/__traces__/
36
- \`\`\`
37
-
38
- ## Span visualization
39
-
40
- - **Shape** indicates span kind (hexagon=SERVER, diamond=CLIENT, circle=INTERNAL)
41
- - **Color** indicates status (green=OK, red=ERROR, gray=UNSET)
42
- - **Edges** show parent-child relationships (dashed for cross-service calls)
43
- - **Groups** cluster spans by service name
44
- `,
45
- },
46
- },
47
- },
48
- tags: ['autodocs'],
49
- decorators: [
50
- (Story) => (
51
- <ThemeProvider theme={defaultEditorTheme}>
52
- <div style={{ width: '100vw', height: '100vh' }}>
53
- <Story />
54
- </div>
55
- </ThemeProvider>
56
- ),
57
- ],
58
- } satisfies Meta<typeof GraphRenderer>;
59
-
60
- export default meta;
61
- type Story = StoryObj<typeof meta>;
62
-
63
- // ============================================================================
64
- // Stories using captured test traces
65
- // ============================================================================
66
-
67
- /**
68
- * Real trace data captured from test runs.
69
- * Shows spans grouped by service with hierarchical layout.
70
- */
71
- export const CapturedTestTrace: Story = {
72
- args: {
73
- canvas: testRunTrace as ExtendedCanvas,
74
- width: 1600,
75
- height: 400,
76
- },
77
- parameters: {
78
- docs: {
79
- description: {
80
- story: 'Trace data captured from running `bun test` with OpenTelemetry instrumentation.',
81
- },
82
- },
83
- },
84
- };
85
-
86
- // ============================================================================
87
- // Example trace scenarios for documentation
88
- // ============================================================================
89
-
90
- /**
91
- * Example: Simple HTTP request trace
92
- */
93
- const httpRequestTrace: ExtendedCanvas = {
94
- nodes: [
95
- {
96
- id: 'service-api',
97
- type: 'group',
98
- x: -20,
99
- y: -50,
100
- width: 540,
101
- height: 250,
102
- label: 'api-service',
103
- pv: {
104
- nodeType: 'service',
105
- name: 'api-service',
106
- icon: 'server',
107
- },
108
- },
109
- {
110
- id: 'span-1',
111
- type: 'text',
112
- x: 0,
113
- y: 0,
114
- width: 200,
115
- height: 60,
116
- text: 'HTTP GET /users',
117
- pv: {
118
- nodeType: 'span',
119
- name: 'HTTP GET /users',
120
- description: '45.2ms',
121
- shape: 'hexagon',
122
- fill: '#4f46e5',
123
- states: { OK: { color: '#22c55e', label: 'OK' } },
124
- otel: { kind: 'instance', category: 'span' },
125
- },
126
- },
127
- {
128
- id: 'span-2',
129
- type: 'text',
130
- x: 50,
131
- y: 100,
132
- width: 200,
133
- height: 60,
134
- text: 'Auth.validate',
135
- pv: {
136
- nodeType: 'span',
137
- name: 'Auth.validate',
138
- description: '12.1ms',
139
- shape: 'circle',
140
- fill: '#6b7280',
141
- states: { OK: { color: '#22c55e', label: 'OK' } },
142
- otel: { kind: 'instance', category: 'span' },
143
- },
144
- },
145
- {
146
- id: 'span-3',
147
- type: 'text',
148
- x: 300,
149
- y: 100,
150
- width: 200,
151
- height: 60,
152
- text: 'DB.query',
153
- pv: {
154
- nodeType: 'span',
155
- name: 'DB.query',
156
- description: '23.4ms',
157
- shape: 'diamond',
158
- fill: '#0891b2',
159
- states: { OK: { color: '#22c55e', label: 'OK' } },
160
- otel: { kind: 'instance', category: 'span' },
161
- dataSchema: {
162
- 'db.statement': { type: 'string', required: false },
163
- 'db.rows_affected': { type: 'number', required: false },
164
- },
165
- },
166
- },
167
- ],
168
- edges: [
169
- {
170
- id: 'edge-1',
171
- fromNode: 'span-1',
172
- toNode: 'span-2',
173
- fromSide: 'bottom',
174
- toSide: 'top',
175
- toEnd: 'arrow',
176
- pv: { edgeType: 'span-child', style: 'solid' },
177
- },
178
- {
179
- id: 'edge-2',
180
- fromNode: 'span-1',
181
- toNode: 'span-3',
182
- fromSide: 'bottom',
183
- toSide: 'top',
184
- toEnd: 'arrow',
185
- pv: { edgeType: 'span-child', style: 'solid' },
186
- },
187
- ],
188
- pv: {
189
- version: '1.0.0',
190
- name: 'HTTP Request Trace',
191
- description: 'Example trace showing a typical HTTP request flow',
192
- nodeTypes: {
193
- span: { description: 'OpenTelemetry span', shape: 'rectangle' },
194
- service: { description: 'Service grouping', icon: 'server', shape: 'rectangle' },
195
- },
196
- edgeTypes: {
197
- 'span-child': { label: 'Child span', directed: true },
198
- },
199
- display: {
200
- layout: 'manual',
201
- animations: { enabled: true, speed: 1 },
202
- },
203
- },
204
- };
205
-
206
- export const HTTPRequestFlow: Story = {
207
- args: {
208
- canvas: httpRequestTrace,
209
- width: 600,
210
- height: 300,
211
- },
212
- parameters: {
213
- docs: {
214
- description: {
215
- story:
216
- 'Example trace showing a typical HTTP request with authentication and database query.',
217
- },
218
- },
219
- },
220
- };
221
-
222
- /**
223
- * Example: Cross-service call trace
224
- */
225
- const crossServiceTrace: ExtendedCanvas = {
226
- nodes: [
227
- {
228
- id: 'service-frontend',
229
- type: 'group',
230
- x: -20,
231
- y: -50,
232
- width: 240,
233
- height: 130,
234
- label: 'frontend',
235
- pv: { nodeType: 'service', name: 'frontend', icon: 'monitor' },
236
- },
237
- {
238
- id: 'service-api',
239
- type: 'group',
240
- x: 280,
241
- y: -50,
242
- width: 240,
243
- height: 130,
244
- label: 'api-gateway',
245
- pv: { nodeType: 'service', name: 'api-gateway', icon: 'server' },
246
- },
247
- {
248
- id: 'service-db',
249
- type: 'group',
250
- x: 580,
251
- y: -50,
252
- width: 240,
253
- height: 130,
254
- label: 'user-service',
255
- pv: { nodeType: 'service', name: 'user-service', icon: 'database' },
256
- },
257
- {
258
- id: 'span-fe',
259
- type: 'text',
260
- x: 0,
261
- y: 0,
262
- width: 200,
263
- height: 60,
264
- text: 'fetchUsers()',
265
- pv: {
266
- nodeType: 'span',
267
- name: 'fetchUsers()',
268
- description: '120ms',
269
- shape: 'circle',
270
- fill: '#6b7280',
271
- otel: { kind: 'instance', category: 'span' },
272
- },
273
- },
274
- {
275
- id: 'span-api',
276
- type: 'text',
277
- x: 300,
278
- y: 0,
279
- width: 200,
280
- height: 60,
281
- text: 'GET /api/users',
282
- pv: {
283
- nodeType: 'span',
284
- name: 'GET /api/users',
285
- description: '95ms',
286
- shape: 'hexagon',
287
- fill: '#4f46e5',
288
- otel: { kind: 'instance', category: 'span' },
289
- },
290
- },
291
- {
292
- id: 'span-db',
293
- type: 'text',
294
- x: 600,
295
- y: 0,
296
- width: 200,
297
- height: 60,
298
- text: 'users.findAll()',
299
- pv: {
300
- nodeType: 'span',
301
- name: 'users.findAll()',
302
- description: '45ms',
303
- shape: 'diamond',
304
- fill: '#0891b2',
305
- otel: { kind: 'instance', category: 'span' },
306
- },
307
- },
308
- ],
309
- edges: [
310
- {
311
- id: 'edge-1',
312
- fromNode: 'span-fe',
313
- toNode: 'span-api',
314
- toEnd: 'arrow',
315
- pv: { edgeType: 'span-child', style: 'dashed', width: 2 },
316
- },
317
- {
318
- id: 'edge-2',
319
- fromNode: 'span-api',
320
- toNode: 'span-db',
321
- toEnd: 'arrow',
322
- pv: { edgeType: 'span-child', style: 'dashed', width: 2 },
323
- },
324
- ],
325
- pv: {
326
- version: '1.0.0',
327
- name: 'Cross-Service Trace',
328
- description: 'Trace spanning multiple services with dashed edges for cross-service calls',
329
- nodeTypes: {
330
- span: { description: 'OpenTelemetry span', shape: 'rectangle' },
331
- service: { description: 'Service grouping', icon: 'server', shape: 'rectangle' },
332
- },
333
- edgeTypes: {
334
- 'span-child': { label: 'Child span', directed: true },
335
- },
336
- },
337
- };
338
-
339
- export const CrossServiceCall: Story = {
340
- args: {
341
- canvas: crossServiceTrace,
342
- width: 900,
343
- height: 200,
344
- },
345
- parameters: {
346
- docs: {
347
- description: {
348
- story:
349
- 'Trace showing calls across three services. Dashed edges indicate cross-service boundaries.',
350
- },
351
- },
352
- },
353
- };
354
-
355
- /**
356
- * Example: Error trace
357
- */
358
- const errorTrace: ExtendedCanvas = {
359
- nodes: [
360
- {
361
- id: 'span-1',
362
- type: 'text',
363
- x: 0,
364
- y: 0,
365
- width: 200,
366
- height: 60,
367
- text: 'processOrder()',
368
- color: 1, // Red preset
369
- pv: {
370
- nodeType: 'span',
371
- name: 'processOrder()',
372
- description: '234ms',
373
- shape: 'circle',
374
- fill: '#ef4444',
375
- states: { ERROR: { color: '#ef4444', label: 'ERROR' } },
376
- otel: { kind: 'instance', category: 'span' },
377
- },
378
- },
379
- {
380
- id: 'span-2',
381
- type: 'text',
382
- x: 0,
383
- y: 100,
384
- width: 200,
385
- height: 60,
386
- text: 'validatePayment()',
387
- color: 1,
388
- pv: {
389
- nodeType: 'span',
390
- name: 'validatePayment()',
391
- description: '89ms',
392
- shape: 'diamond',
393
- fill: '#ef4444',
394
- states: { ERROR: { color: '#ef4444', label: 'ERROR' } },
395
- otel: { kind: 'instance', category: 'span' },
396
- dataSchema: {
397
- 'error.type': { type: 'string', required: false },
398
- 'error.message': { type: 'string', required: false },
399
- },
400
- },
401
- },
402
- ],
403
- edges: [
404
- {
405
- id: 'edge-1',
406
- fromNode: 'span-1',
407
- toNode: 'span-2',
408
- fromSide: 'bottom',
409
- toSide: 'top',
410
- toEnd: 'arrow',
411
- color: 1,
412
- pv: { edgeType: 'span-child', style: 'solid' },
413
- },
414
- ],
415
- pv: {
416
- version: '1.0.0',
417
- name: 'Error Trace',
418
- description: 'Trace showing an error propagating up the call stack',
419
- nodeTypes: {
420
- span: { description: 'OpenTelemetry span', shape: 'rectangle' },
421
- },
422
- edgeTypes: {
423
- 'span-child': { label: 'Child span', directed: true },
424
- },
425
- },
426
- };
427
-
428
- export const ErrorPropagation: Story = {
429
- args: {
430
- canvas: errorTrace,
431
- width: 300,
432
- height: 250,
433
- },
434
- parameters: {
435
- docs: {
436
- description: {
437
- story:
438
- 'Trace showing how an error in a child span propagates to the parent. Red nodes indicate ERROR status.',
439
- },
440
- },
441
- },
442
- };