@principal-ai/principal-view-react 0.13.16 → 0.13.17

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@principal-ai/principal-view-react",
3
- "version": "0.13.16",
3
+ "version": "0.13.17",
4
4
  "description": "React components for graph-based principal view framework",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -0,0 +1,385 @@
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/principal-view-core';
5
+ import { ThemeProvider, defaultEditorTheme } from '@principal-ade/industry-theme';
6
+
7
+ const meta = {
8
+ title: 'Audit/BoundaryNodes',
9
+ component: GraphRenderer,
10
+ parameters: {
11
+ layout: 'centered',
12
+ },
13
+ tags: ['autodocs'],
14
+ decorators: [
15
+ (Story) => (
16
+ <ThemeProvider theme={defaultEditorTheme}>
17
+ <Story />
18
+ </ThemeProvider>
19
+ ),
20
+ ],
21
+ } satisfies Meta<typeof GraphRenderer>;
22
+
23
+ export default meta;
24
+ type Story = StoryObj<typeof meta>;
25
+
26
+ /**
27
+ * Canvas showing boundary node visual treatment
28
+ */
29
+ const boundaryNodesCanvas: ExtendedCanvas = {
30
+ nodes: [
31
+ // Regular node for comparison
32
+ {
33
+ id: 'regular-node',
34
+ type: 'text',
35
+ x: 100,
36
+ y: 100,
37
+ width: 160,
38
+ height: 80,
39
+ text: '# Regular Node\nSharp corners',
40
+ color: 6, // purple
41
+ pv: {
42
+ nodeType: 'event',
43
+ name: 'Regular Node',
44
+ description: 'A standard event node with sharp corners',
45
+ sources: ['src/events/regular.ts'],
46
+ event: {
47
+ name: 'app.regular-event',
48
+ description: 'Regular event',
49
+ attributes: {},
50
+ },
51
+ },
52
+ },
53
+ // Outbound boundary node
54
+ {
55
+ id: 'outbound-boundary',
56
+ type: 'text',
57
+ x: 350,
58
+ y: 100,
59
+ width: 180,
60
+ height: 80,
61
+ text: '# Host Callback\nPersists layout',
62
+ color: 5, // cyan
63
+ pv: {
64
+ nodeType: 'boundary',
65
+ name: 'onBatchLayoutInitialized',
66
+ description: 'Calls host to persist batch layout data',
67
+ boundary: {
68
+ direction: 'outbound',
69
+ node: {
70
+ 'pv.event.name': 'host.batch-layout-initialized',
71
+ 'pv.event.namespace': 'collection-host',
72
+ },
73
+ },
74
+ },
75
+ },
76
+ // Inbound boundary node
77
+ {
78
+ id: 'inbound-boundary',
79
+ type: 'text',
80
+ x: 620,
81
+ y: 100,
82
+ width: 180,
83
+ height: 80,
84
+ text: '# Webhook\nRepository created',
85
+ color: 5, // cyan
86
+ pv: {
87
+ nodeType: 'boundary',
88
+ name: 'onRepositoryCreated',
89
+ description: 'Called by GitHub when a repository is created',
90
+ boundary: {
91
+ direction: 'inbound',
92
+ node: {
93
+ 'pv.event.name': 'webhook.repository-created',
94
+ 'pv.event.namespace': 'github',
95
+ },
96
+ },
97
+ },
98
+ },
99
+ ],
100
+ edges: [],
101
+ pv: {
102
+ version: '1.0.0',
103
+ name: 'Boundary Nodes Demo',
104
+ description: 'Demonstrates boundary node visual treatment',
105
+ edgeTypes: {},
106
+ },
107
+ };
108
+
109
+ export const BoundaryVsRegular: Story = {
110
+ args: {
111
+ canvas: boundaryNodesCanvas,
112
+ width: 900,
113
+ height: 300,
114
+ },
115
+ parameters: {
116
+ docs: {
117
+ description: {
118
+ story: `
119
+ **Boundary Node Visual Treatment**
120
+
121
+ Boundary nodes represent interaction points where control crosses system edges.
122
+ They have distinct visual treatment:
123
+
124
+ - **Rounded corners** (8px border-radius) to visually distinguish from regular nodes
125
+ - **Direction badge** in top-right corner:
126
+ - ↗ (arrow up-right) for **outbound** boundaries - this system calls external
127
+ - ↙ (arrow down-left) for **inbound** boundaries - external calls this system
128
+ - **Cyan badge color** (#06b6d4) to match boundary theme
129
+ - **No sources badge** since boundary nodes don't have local source files
130
+
131
+ Compare with the regular node on the left which has:
132
+ - Sharp corners (0 border-radius)
133
+ - Green "S" sources badge (when sources are defined)
134
+ `,
135
+ },
136
+ },
137
+ },
138
+ };
139
+
140
+ /**
141
+ * Canvas showing boundary nodes in a workflow context
142
+ */
143
+ const workflowWithBoundariesCanvas: ExtendedCanvas = {
144
+ nodes: [
145
+ // Internal event
146
+ {
147
+ id: 'batch-save',
148
+ type: 'text',
149
+ x: 100,
150
+ y: 150,
151
+ width: 160,
152
+ height: 70,
153
+ text: '# Batch Save\nSaves regions',
154
+ color: 4, // green
155
+ pv: {
156
+ nodeType: 'event',
157
+ name: 'batch-save',
158
+ event: {
159
+ name: 'collection-map.batch-save',
160
+ description: 'Saved regions to local state',
161
+ attributes: {},
162
+ },
163
+ },
164
+ },
165
+ // Outbound to host
166
+ {
167
+ id: 'host-persist',
168
+ type: 'text',
169
+ x: 350,
170
+ y: 150,
171
+ width: 180,
172
+ height: 70,
173
+ text: '# Host: Persist\nSaves to backend',
174
+ color: 5, // cyan
175
+ pv: {
176
+ nodeType: 'boundary',
177
+ name: 'onBatchLayoutInitialized',
178
+ boundary: {
179
+ direction: 'outbound',
180
+ node: {
181
+ 'pv.event.name': 'host.batch-layout-initialized',
182
+ },
183
+ },
184
+ },
185
+ },
186
+ // Another internal event
187
+ {
188
+ id: 'layout-complete',
189
+ type: 'text',
190
+ x: 620,
191
+ y: 150,
192
+ width: 160,
193
+ height: 70,
194
+ text: '# Layout Complete\nUI updated',
195
+ color: 4, // green
196
+ pv: {
197
+ nodeType: 'event',
198
+ name: 'layout-complete',
199
+ event: {
200
+ name: 'collection-map.layout-complete',
201
+ description: 'Layout computation finished',
202
+ attributes: {},
203
+ },
204
+ },
205
+ },
206
+ ],
207
+ edges: [
208
+ {
209
+ id: 'e1',
210
+ fromNode: 'batch-save',
211
+ toNode: 'host-persist',
212
+ fromSide: 'right',
213
+ toSide: 'left',
214
+ },
215
+ {
216
+ id: 'e2',
217
+ fromNode: 'host-persist',
218
+ toNode: 'layout-complete',
219
+ fromSide: 'right',
220
+ toSide: 'left',
221
+ },
222
+ ],
223
+ pv: {
224
+ version: '1.0.0',
225
+ name: 'Workflow with Boundaries',
226
+ description: 'Shows boundary nodes in workflow context',
227
+ edgeTypes: {
228
+ default: {
229
+ style: 'solid',
230
+ color: '#888',
231
+ directed: true,
232
+ },
233
+ },
234
+ },
235
+ };
236
+
237
+ export const WorkflowContext: Story = {
238
+ args: {
239
+ canvas: workflowWithBoundariesCanvas,
240
+ width: 900,
241
+ height: 350,
242
+ },
243
+ parameters: {
244
+ docs: {
245
+ description: {
246
+ story: `
247
+ **Boundary Nodes in Workflow Context**
248
+
249
+ This shows how boundary nodes appear in a typical workflow:
250
+
251
+ 1. **Internal Event** (green, sharp corners) - Code we own and instrument
252
+ 2. **Boundary Node** (cyan, rounded corners) - Calls external system
253
+ 3. **Internal Event** (green, sharp corners) - Continues after external call
254
+
255
+ The boundary node visually breaks the flow to indicate control leaving the system.
256
+ The ↗ badge indicates this is an outbound call (we call them, they don't call us).
257
+ `,
258
+ },
259
+ },
260
+ },
261
+ };
262
+
263
+ /**
264
+ * Canvas showing different boundary directions
265
+ */
266
+ const boundaryDirectionsCanvas: ExtendedCanvas = {
267
+ nodes: [
268
+ // Outbound examples
269
+ {
270
+ id: 'outbound-1',
271
+ type: 'text',
272
+ x: 100,
273
+ y: 100,
274
+ width: 180,
275
+ height: 70,
276
+ text: '# Host Callback\nonBatchLayout',
277
+ color: 5,
278
+ pv: {
279
+ nodeType: 'boundary',
280
+ name: 'onBatchLayout',
281
+ boundary: {
282
+ direction: 'outbound',
283
+ node: { 'pv.event.name': 'host.batch-layout' },
284
+ },
285
+ },
286
+ },
287
+ {
288
+ id: 'outbound-2',
289
+ type: 'text',
290
+ x: 350,
291
+ y: 100,
292
+ width: 180,
293
+ height: 70,
294
+ text: '# API Call\nPOST /payments',
295
+ color: 5,
296
+ pv: {
297
+ nodeType: 'boundary',
298
+ name: 'createPayment',
299
+ boundary: {
300
+ direction: 'outbound',
301
+ node: { 'pv.event.name': 'stripe.payment-created' },
302
+ },
303
+ },
304
+ },
305
+ // Inbound examples
306
+ {
307
+ id: 'inbound-1',
308
+ type: 'text',
309
+ x: 100,
310
+ y: 250,
311
+ width: 180,
312
+ height: 70,
313
+ text: '# Webhook\nrepo.created',
314
+ color: 5,
315
+ pv: {
316
+ nodeType: 'boundary',
317
+ name: 'onRepoCreated',
318
+ boundary: {
319
+ direction: 'inbound',
320
+ node: { 'pv.event.name': 'github.repo-created' },
321
+ },
322
+ },
323
+ },
324
+ {
325
+ id: 'inbound-2',
326
+ type: 'text',
327
+ x: 350,
328
+ y: 250,
329
+ width: 180,
330
+ height: 70,
331
+ text: '# Message\norder.placed',
332
+ color: 5,
333
+ pv: {
334
+ nodeType: 'boundary',
335
+ name: 'onOrderPlaced',
336
+ boundary: {
337
+ direction: 'inbound',
338
+ node: { 'pv.event.name': 'queue.order-placed' },
339
+ },
340
+ },
341
+ },
342
+ ],
343
+ edges: [],
344
+ pv: {
345
+ version: '1.0.0',
346
+ name: 'Boundary Directions',
347
+ description: 'Outbound vs Inbound boundary nodes',
348
+ edgeTypes: {},
349
+ nodeTypes: {
350
+ boundary: {
351
+ description: 'External system boundary',
352
+ color: '#06b6d4',
353
+ },
354
+ },
355
+ },
356
+ };
357
+
358
+ export const DirectionComparison: Story = {
359
+ args: {
360
+ canvas: boundaryDirectionsCanvas,
361
+ width: 650,
362
+ height: 400,
363
+ },
364
+ parameters: {
365
+ docs: {
366
+ description: {
367
+ story: `
368
+ **Outbound vs Inbound Boundaries**
369
+
370
+ **Top row - Outbound (↗)**
371
+ - Host callbacks we invoke
372
+ - API calls we make
373
+ - Messages we publish
374
+
375
+ **Bottom row - Inbound (↙)**
376
+ - Webhooks that call us
377
+ - Queue messages we consume
378
+ - Events we subscribe to
379
+
380
+ The direction badge makes it immediately clear which way control flows across the boundary.
381
+ `,
382
+ },
383
+ },
384
+ },
385
+ };