@principal-ai/subsystems-react 0.56.39 → 0.56.41

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 (75) hide show
  1. package/dist/index.d.ts +7 -3
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +4 -1
  4. package/dist/index.js.map +1 -1
  5. package/dist/subsystem/C4ContainersPanel.d.ts +32 -2
  6. package/dist/subsystem/C4ContainersPanel.d.ts.map +1 -1
  7. package/dist/subsystem/C4ContainersPanel.js +89 -21
  8. package/dist/subsystem/C4ContainersPanel.js.map +1 -1
  9. package/dist/subsystem/C4Graph.d.ts +13 -0
  10. package/dist/subsystem/C4Graph.d.ts.map +1 -1
  11. package/dist/subsystem/C4Graph.js +19 -2
  12. package/dist/subsystem/C4Graph.js.map +1 -1
  13. package/dist/subsystem/C4NodeCard.d.ts +15 -2
  14. package/dist/subsystem/C4NodeCard.d.ts.map +1 -1
  15. package/dist/subsystem/C4NodeCard.js +124 -7
  16. package/dist/subsystem/C4NodeCard.js.map +1 -1
  17. package/dist/subsystem/C4ProjectionView.d.ts +8 -1
  18. package/dist/subsystem/C4ProjectionView.d.ts.map +1 -1
  19. package/dist/subsystem/C4ProjectionView.js +3 -3
  20. package/dist/subsystem/C4ProjectionView.js.map +1 -1
  21. package/dist/subsystem/C4SketchView.d.ts +9 -1
  22. package/dist/subsystem/C4SketchView.d.ts.map +1 -1
  23. package/dist/subsystem/C4SketchView.js +2 -2
  24. package/dist/subsystem/C4SketchView.js.map +1 -1
  25. package/dist/subsystem/SubsystemComponentGraph.d.ts +5 -0
  26. package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
  27. package/dist/subsystem/SubsystemComponentGraph.js +2 -2
  28. package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
  29. package/dist/subsystem/TrailIcon.d.ts +18 -4
  30. package/dist/subsystem/TrailIcon.d.ts.map +1 -1
  31. package/dist/subsystem/TrailIcon.js +35 -24
  32. package/dist/subsystem/TrailIcon.js.map +1 -1
  33. package/dist/subsystem/TrailsPanel.d.ts +3 -1
  34. package/dist/subsystem/TrailsPanel.d.ts.map +1 -1
  35. package/dist/subsystem/TrailsPanel.js +28 -17
  36. package/dist/subsystem/TrailsPanel.js.map +1 -1
  37. package/dist/subsystem/__fixtures__/c4Deployments.d.ts +18 -0
  38. package/dist/subsystem/__fixtures__/c4Deployments.d.ts.map +1 -0
  39. package/dist/subsystem/__fixtures__/c4Deployments.js +185 -0
  40. package/dist/subsystem/__fixtures__/c4Deployments.js.map +1 -0
  41. package/dist/subsystem/c4.d.ts +63 -0
  42. package/dist/subsystem/c4.d.ts.map +1 -1
  43. package/dist/subsystem/c4.js.map +1 -1
  44. package/dist/subsystem/c4Deployment.d.ts +78 -0
  45. package/dist/subsystem/c4Deployment.d.ts.map +1 -0
  46. package/dist/subsystem/c4Deployment.js +68 -0
  47. package/dist/subsystem/c4Deployment.js.map +1 -0
  48. package/dist/subsystem/techIcons/cloudflare.d.ts +15 -0
  49. package/dist/subsystem/techIcons/cloudflare.d.ts.map +1 -0
  50. package/dist/subsystem/techIcons/cloudflare.js +15 -0
  51. package/dist/subsystem/techIcons/cloudflare.js.map +1 -0
  52. package/dist/subsystem/techIcons/index.d.ts +14 -1
  53. package/dist/subsystem/techIcons/index.d.ts.map +1 -1
  54. package/dist/subsystem/techIcons/index.js +17 -0
  55. package/dist/subsystem/techIcons/index.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/index.ts +25 -1
  58. package/src/stories/Canvases/C4/C4Sketch.stories.tsx +51 -0
  59. package/src/subsystem/C4ContainersPanel.test.tsx +90 -2
  60. package/src/subsystem/C4ContainersPanel.tsx +142 -35
  61. package/src/subsystem/C4Graph.tsx +49 -3
  62. package/src/subsystem/C4NodeCard.tsx +217 -7
  63. package/src/subsystem/C4ProjectionView.tsx +12 -0
  64. package/src/subsystem/C4SketchView.tsx +13 -0
  65. package/src/subsystem/SubsystemComponentGraph.tsx +7 -1
  66. package/src/subsystem/TrailIcon.tsx +60 -34
  67. package/src/subsystem/TrailsPanel.test.tsx +51 -0
  68. package/src/subsystem/TrailsPanel.tsx +40 -11
  69. package/src/subsystem/__fixtures__/c4Deployments.ts +196 -0
  70. package/src/subsystem/c4.ts +62 -0
  71. package/src/subsystem/c4Deployment.test.tsx +211 -0
  72. package/src/subsystem/c4Deployment.tsx +137 -0
  73. package/src/subsystem/techIcons/cloudflare.ts +14 -0
  74. package/src/subsystem/techIcons/index.tsx +30 -1
  75. package/src/subsystem/techIcons/techIcons.test.ts +12 -2
@@ -466,6 +466,11 @@ export interface SubsystemComponentGraphProps {
466
466
  * red, yellow) with a +, − or dot badge. Trails not in the map are unmarked.
467
467
  */
468
468
  trailChanges?: ReadonlyMap<string, TrailChange>;
469
+ /**
470
+ * The same, per step: trail id → step index → `added` / `removed` / `changed`. The
471
+ * step's number is drawn in that colour with the same badge. Steps not listed are unmarked.
472
+ */
473
+ stepChanges?: ReadonlyMap<string, ReadonlyMap<number, TrailChange>>;
469
474
  /**
470
475
  * Called with the next trail order after a drag in the sidebar's
471
476
  * flows panel. When set, each row grows a drag grip and a drop emits the
@@ -883,7 +888,7 @@ interface InnerProps extends SubsystemComponentGraphProps {
883
888
  onSidebarTrailChange: (trailId: string | null) => void;
884
889
  }
885
890
 
886
- function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, focusedTrailStep, proposedTrailIds, proposedStepKeys, stepChange, stepNumberLabels: hostStepNumberLabels, stepHistory, proposedStep, focusedVariationStepIndexes, proposedComponentAliases, workingComponentAliases, removedComponentAliases, onTrailStepHover, onTrailHover, highlightedTrailIds, trailChanges, onReorderTrails, stepEmphasis, onRemoveStepEmphasis, onSelect, onEdgeSelect, measured: _measured, maxNodeWidth, showEdgeLabels, showSingletonFrames = true, moduleNesting, edgeView, hideSidebar, trailStepMode = 'focus', autoPlayTrails = false, trailAutoPlayIntervalMs = TRAIL_PLAY_PAUSE_MS, onAutoPlayStep, zoomOnTrailFocus = true, trailFocusDurationMs = 300, focusVerticalBiasPx = 0, graphTitle, showTrailTitle = false, description, notes, canvasOverlay, interactive = true, canvasBackground = 'theme', onLayoutReady, onNodeRects, sidebarExtra, sidebarAfterDescription, issues, showIssues, filesActive, sidebarScope, onSidebarTrailChange, focusIssueCategory, laneStatus, onSelectIssue, onApplyIssueFix, onHoverIssue, renderFileViewer, renderTrailViewer, onFileSelect, componentVerification, onInspectSymbol, boundaryColors, codeProcessKeys, regionDetails, defaultFramesCollapsed, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }: InnerProps) {
891
+ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirection: layoutDirectionProp, defaultLayoutDirection = 'horizontal', onLayoutDirectionChange, hideLayoutToggle = false, refocusOnLayoutFlip = true, initialTrailId, onTrailSelect, focusedTrailStep, proposedTrailIds, proposedStepKeys, stepChange, stepNumberLabels: hostStepNumberLabels, stepHistory, proposedStep, focusedVariationStepIndexes, proposedComponentAliases, workingComponentAliases, removedComponentAliases, onTrailStepHover, onTrailHover, highlightedTrailIds, trailChanges, stepChanges, onReorderTrails, stepEmphasis, onRemoveStepEmphasis, onSelect, onEdgeSelect, measured: _measured, maxNodeWidth, showEdgeLabels, showSingletonFrames = true, moduleNesting, edgeView, hideSidebar, trailStepMode = 'focus', autoPlayTrails = false, trailAutoPlayIntervalMs = TRAIL_PLAY_PAUSE_MS, onAutoPlayStep, zoomOnTrailFocus = true, trailFocusDurationMs = 300, focusVerticalBiasPx = 0, graphTitle, showTrailTitle = false, description, notes, canvasOverlay, interactive = true, canvasBackground = 'theme', onLayoutReady, onNodeRects, sidebarExtra, sidebarAfterDescription, issues, showIssues, filesActive, sidebarScope, onSidebarTrailChange, focusIssueCategory, laneStatus, onSelectIssue, onApplyIssueFix, onHoverIssue, renderFileViewer, renderTrailViewer, onFileSelect, componentVerification, onInspectSymbol, boundaryColors, codeProcessKeys, regionDetails, defaultFramesCollapsed, containersActive, hideDrawer = false, persistKey, liveEvents, agentsPanel }: InnerProps) {
887
892
  const { theme } = useTheme();
888
893
  const { fitView, fitBounds, setViewport } = useReactFlow();
889
894
  const flowWidth = useStore((state) => state.width);
@@ -3800,6 +3805,7 @@ function Inner({ components, trails, graphifyRelations, orderByLine, layoutDirec
3800
3805
  proposedTrailIds={proposedTrailIds}
3801
3806
  highlightedTrailIds={highlightedTrailIds}
3802
3807
  trailChanges={trailChanges}
3808
+ stepChanges={stepChanges}
3803
3809
  proposedStepKeys={proposedStepKeys}
3804
3810
  focusedVariationStepIndexes={panelFocusedVariationStepIndexes}
3805
3811
  stepNumberLabels={panelStepNumberLabels}
@@ -15,11 +15,65 @@ const CHANGE_LABEL: Record<TrailChange, string> = {
15
15
  changed: 'Changed trail',
16
16
  };
17
17
 
18
+ type Theme = ReturnType<typeof useTheme>['theme'];
19
+
20
+ /** The colour for a change: green added, red removed, yellow changed. */
21
+ export function trailChangeColor(theme: Theme, change: TrailChange): string {
22
+ return change === 'added'
23
+ ? (theme.colors.success ?? '#22c55e')
24
+ : change === 'removed'
25
+ ? (theme.colors.error ?? '#ef4444')
26
+ : (theme.colors.warning ?? '#eab308');
27
+ }
28
+
18
29
  /**
19
- * The trail icon. With a `change` it is drawn in that change's colour (green,
20
- * red, yellow) with a small badge — + for added, − for removed, a plain dot for
21
- * changed — so the meaning does not rest on colour alone. Without one it is
22
- * exactly the plain icon.
30
+ * The small corner badge for a change — + added, − removed, a plain dot changed —
31
+ * so the meaning does not rest on colour alone. Position it over a relatively
32
+ * positioned parent of `size`; `ring` is the surface colour it sits on.
33
+ */
34
+ export function ChangeBadge({
35
+ change,
36
+ size,
37
+ tone,
38
+ ring,
39
+ }: {
40
+ change: TrailChange;
41
+ size: number;
42
+ tone: string;
43
+ ring: string;
44
+ }) {
45
+ const badge = Math.max(8, Math.round(size * 0.55));
46
+ return (
47
+ <span
48
+ aria-hidden
49
+ style={{
50
+ position: 'absolute',
51
+ right: -badge / 3,
52
+ bottom: -badge / 3,
53
+ width: badge,
54
+ height: badge,
55
+ borderRadius: '50%',
56
+ background: tone,
57
+ color: ring,
58
+ display: 'flex',
59
+ alignItems: 'center',
60
+ justifyContent: 'center',
61
+ boxShadow: `0 0 0 1px ${ring}`,
62
+ pointerEvents: 'none',
63
+ }}
64
+ >
65
+ {change === 'added' ? (
66
+ <Plus size={badge - 2} strokeWidth={4} />
67
+ ) : change === 'removed' ? (
68
+ <Minus size={badge - 2} strokeWidth={4} />
69
+ ) : null}
70
+ </span>
71
+ );
72
+ }
73
+
74
+ /**
75
+ * The trail icon. With a `change` it is drawn in that change's colour with a
76
+ * corner badge. Without one it is exactly the plain icon.
23
77
  */
24
78
  export function TrailIcon({
25
79
  change,
@@ -39,15 +93,9 @@ export function TrailIcon({
39
93
  if (!change) {
40
94
  return <Route size={size} strokeWidth={strokeWidth} aria-hidden style={{ ...style, color }} />;
41
95
  }
42
- const tone =
43
- change === 'added'
44
- ? (theme.colors.success ?? '#22c55e')
45
- : change === 'removed'
46
- ? (theme.colors.error ?? '#ef4444')
47
- : (theme.colors.warning ?? '#eab308');
96
+ const tone = trailChangeColor(theme, change);
48
97
  // The badge sits on the icon's corner, ringed in the panel colour to separate the two.
49
98
  const ring = theme.colors.backgroundSecondary ?? theme.colors.background;
50
- const badge = Math.max(8, Math.round(size * 0.55));
51
99
  return (
52
100
  <span
53
101
  role="img"
@@ -62,29 +110,7 @@ export function TrailIcon({
62
110
  }}
63
111
  >
64
112
  <Route size={size} strokeWidth={strokeWidth} aria-hidden />
65
- <span
66
- aria-hidden
67
- style={{
68
- position: 'absolute',
69
- right: -badge / 3,
70
- bottom: -badge / 3,
71
- width: badge,
72
- height: badge,
73
- borderRadius: '50%',
74
- background: tone,
75
- color: ring,
76
- display: 'flex',
77
- alignItems: 'center',
78
- justifyContent: 'center',
79
- boxShadow: `0 0 0 1px ${ring}`,
80
- }}
81
- >
82
- {change === 'added' ? (
83
- <Plus size={badge - 2} strokeWidth={4} />
84
- ) : change === 'removed' ? (
85
- <Minus size={badge - 2} strokeWidth={4} />
86
- ) : null}
87
- </span>
113
+ <ChangeBadge change={change} size={size} tone={tone} ring={ring} />
88
114
  </span>
89
115
  );
90
116
  }
@@ -606,3 +606,54 @@ describe('TrailsPanel trail changes', () => {
606
606
  }
607
607
  });
608
608
  });
609
+
610
+ describe('TrailsPanel step changes', () => {
611
+ const step = trails[0]!.steps[0]!;
612
+ const three: SubsystemTrail = {
613
+ id: 'three',
614
+ title: 'Three steps',
615
+ steps: [step, { ...step, symbol: 'second' }, { ...step, symbol: 'third' }],
616
+ };
617
+
618
+ test('a marked step shows its change on the number; unmarked steps are untouched', () => {
619
+ const { getByTitle, queryByTitle, getAllByText } = renderPanel({
620
+ trails: [three],
621
+ expandedTrails: new Set(['three']),
622
+ stepChanges: new Map([['three', new Map([[1, 'removed' as const]])]]),
623
+ });
624
+ const mark = getByTitle('Removed step');
625
+ expect(mark.textContent).toContain('2'); // still the step's number
626
+ expect(queryByTitle('Added step')).toBeNull();
627
+ expect(queryByTitle('Changed step')).toBeNull();
628
+ // The other two numbers are plain text with no title.
629
+ expect(getAllByText('1')[0]!.getAttribute('title')).toBeNull();
630
+ });
631
+
632
+ test('added, removed and changed steps get three different colours', () => {
633
+ const { getByTitle } = renderPanel({
634
+ trails: [three],
635
+ expandedTrails: new Set(['three']),
636
+ stepChanges: new Map([
637
+ [
638
+ 'three',
639
+ new Map([
640
+ [0, 'added' as const],
641
+ [1, 'removed' as const],
642
+ [2, 'changed' as const],
643
+ ]),
644
+ ],
645
+ ]),
646
+ });
647
+ const colours = ['Added step', 'Removed step', 'Changed step'].map((t) => getByTitle(t).style.color);
648
+ expect(new Set(colours).size).toBe(3);
649
+ });
650
+
651
+ test("only the named trail's steps are marked", () => {
652
+ const { queryByTitle } = renderPanel({
653
+ trails: [trails[0]!],
654
+ expandedTrails: new Set(['auth-flow']),
655
+ stepChanges: new Map([['some-other-trail', new Map([[0, 'added' as const]])]]),
656
+ });
657
+ expect(queryByTitle('Added step')).toBeNull();
658
+ });
659
+ });
@@ -31,7 +31,7 @@ import {
31
31
  } from './trailStepDisplay';
32
32
  import { buildTrailStack } from './trailStack';
33
33
  import { TrailStepsNav } from './TrailStepsNav';
34
- import { TrailIcon, type TrailChange } from './TrailIcon';
34
+ import { ChangeBadge, TrailIcon, trailChangeColor, type TrailChange } from './TrailIcon';
35
35
 
36
36
  /** Pause (ms) between steps when a trail autoplays. */
37
37
  export const TRAIL_PLAY_PAUSE_MS = 2500;
@@ -55,6 +55,13 @@ export interface TrailsStepChange {
55
55
  previous: SubsystemTrailStep;
56
56
  }
57
57
 
58
+ /** Tooltip for a step the host marks as changed. */
59
+ const STEP_CHANGE_LABEL: Record<TrailChange, string> = {
60
+ added: 'Added step',
61
+ removed: 'Removed step',
62
+ changed: 'Changed step',
63
+ };
64
+
58
65
  /** How long a step's number shows its "copied" checkmark (ms). */
59
66
  export const STEP_COPY_FEEDBACK_MS = 2000;
60
67
 
@@ -97,6 +104,7 @@ function TrailFlow({
97
104
  hideHeader = false,
98
105
  proposed = false,
99
106
  change,
107
+ stepChanges,
100
108
  proposedStepKeys,
101
109
  focusedVariationStepIndexes,
102
110
  stepNumberLabels,
@@ -145,6 +153,8 @@ function TrailFlow({
145
153
  proposed?: boolean;
146
154
  /** What the host says is happening to this trail; its icon shows it. */
147
155
  change?: TrailChange;
156
+ /** What the host says is happening to individual steps, by index; the step's number shows it. */
157
+ stepChanges?: ReadonlyMap<number, TrailChange>;
148
158
  /** Host-local proposed steps, keyed by `emphasisKey(trailId, step)`. */
149
159
  proposedStepKeys?: Set<string>;
150
160
  /** Step indexes that belong to one focused variation group in this flow. */
@@ -550,6 +560,8 @@ function TrailFlow({
550
560
  const record = stepEmphasis?.get(stepKey);
551
561
  const stepProposed = proposed || (proposedStepKeys?.has(stepKey) ?? false);
552
562
  const stepNumber = stepNumberLabels?.get(stepKey) ?? String(i + 1);
563
+ const stepChangeMark = stepChanges?.get(i);
564
+ const stepTone = stepChangeMark ? trailChangeColor(theme, stepChangeMark) : null;
553
565
  const display = trailStepDisplay(step, componentByAlias);
554
566
  // The original step keeps its row after acceptance; only its
555
567
  // annotation is greyed. Its `2a` variation stays beside it.
@@ -616,26 +628,38 @@ function TrailFlow({
616
628
  <span
617
629
  role={copied ? 'status' : undefined}
618
630
  aria-label={copied ? 'Copied' : undefined}
631
+ title={stepChangeMark ? STEP_CHANGE_LABEL[stepChangeMark] : undefined}
619
632
  style={{
633
+ position: 'relative',
620
634
  flexShrink: 0,
621
635
  width: 14,
622
636
  textAlign: 'center',
623
637
  paddingTop: 1,
624
638
  fontSize: theme.fontSizes[0],
625
639
  fontFamily: theme.fonts.monospace,
626
- fontWeight: record ? 700 : undefined,
627
- color: stepProposed
628
- ? proposalColor
629
- : copied
630
- ? theme.colors.primary
631
- : record
632
- ? EMPHASIS_COLOR
633
- : stepActive
634
- ? theme.colors.text
635
- : muted,
640
+ fontWeight: record || stepTone ? 700 : undefined,
641
+ color: copied
642
+ ? theme.colors.primary
643
+ : stepTone
644
+ ? stepTone
645
+ : stepProposed
646
+ ? proposalColor
647
+ : record
648
+ ? EMPHASIS_COLOR
649
+ : stepActive
650
+ ? theme.colors.text
651
+ : muted,
636
652
  }}
637
653
  >
638
654
  {copied ? <Check size={12} strokeWidth={2} aria-hidden /> : stepNumber}
655
+ {stepChangeMark && stepTone && !copied && (
656
+ <ChangeBadge
657
+ change={stepChangeMark}
658
+ size={14}
659
+ tone={stepTone}
660
+ ring={theme.colors.backgroundSecondary ?? theme.colors.background}
661
+ />
662
+ )}
639
663
  </span>
640
664
  <span
641
665
  style={{
@@ -801,6 +825,8 @@ export interface TrailsPanelProps {
801
825
  highlightedTrailIds?: ReadonlySet<string>;
802
826
  /** What the host says is happening to each trail, by id. Marks the trail's icon. */
803
827
  trailChanges?: ReadonlyMap<string, TrailChange>;
828
+ /** What the host says is happening to individual steps: trail id → step index → change. */
829
+ stepChanges?: ReadonlyMap<string, ReadonlyMap<number, TrailChange>>;
804
830
  /** Host-local steps awaiting confirmation, keyed by `emphasisKey`. */
805
831
  proposedStepKeys?: Set<string>;
806
832
  /** Step indexes that belong to one focused variation group, by trail id. */
@@ -840,6 +866,7 @@ export function TrailsPanel({
840
866
  proposedTrailIds,
841
867
  highlightedTrailIds,
842
868
  trailChanges,
869
+ stepChanges,
843
870
  proposedStepKeys,
844
871
  focusedVariationStepIndexes,
845
872
  stepNumberLabels,
@@ -1037,6 +1064,7 @@ export function TrailsPanel({
1037
1064
  onRemoveStepEmphasis={onRemoveStepEmphasis}
1038
1065
  proposed={proposedTrailIds?.has(tl.id) ?? false}
1039
1066
  change={trailChanges?.get(tl.id)}
1067
+ stepChanges={stepChanges?.get(tl.id)}
1040
1068
  proposedStepKeys={proposedStepKeys}
1041
1069
  focusedVariationStepIndexes={focusedVariationStepIndexes?.get(tl.id)}
1042
1070
  stepNumberLabels={stepNumberLabels}
@@ -1092,6 +1120,7 @@ export function TrailsPanel({
1092
1120
  stepEmphasis={stepEmphasis}
1093
1121
  onRemoveStepEmphasis={onRemoveStepEmphasis}
1094
1122
  proposed={proposedTrailIds?.has(trail.id) ?? false}
1123
+ stepChanges={stepChanges?.get(trail.id)}
1095
1124
  proposedStepKeys={proposedStepKeys}
1096
1125
  focusedVariationStepIndexes={focusedVariationStepIndexes?.get(trail.id)}
1097
1126
  stepNumberLabels={stepNumberLabels}
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Storybook fixture: two Workers and their stores, shaped the way
3
+ * `infraToC4` (subsystems-core) projects a pair of wrangler configs — each
4
+ * container carries its configured `deployment` anchor.
5
+ *
6
+ * The observations are invented: they stand in for what credentialed tooling
7
+ * would report, and cover every state a badge can be in.
8
+ */
9
+
10
+ import type { C4DeploymentObservation } from '../c4';
11
+ import type { C4Sketch } from '../c4Sketch';
12
+
13
+ const wrangler = (pointer: string) => ({ tool: 'wrangler', file: 'wrangler.jsonc', pointer });
14
+
15
+ export const DEPLOYMENT_SKETCH: C4Sketch = {
16
+ id: 'c4s-deployments',
17
+ title: 'dev-feed and topic-share on Cloudflare',
18
+ repoKeys: ['pkg:github/acme/dev-feed', 'pkg:github/acme/topic-share'],
19
+ author: 'storybook',
20
+ description:
21
+ 'Containers proposed from two wrangler configs. Each carries the resource it was declared as; the badge shows whether it was observed live.',
22
+ createdAt: '2026-11-29T00:00:00.000Z',
23
+ updatedAt: '2026-11-29T00:00:00.000Z',
24
+ model: {
25
+ view: 'container',
26
+ system: { id: 'system:feeds', label: 'Feeds' },
27
+ nodes: [
28
+ {
29
+ kind: 'container',
30
+ id: 'container:dev-feed',
31
+ label: 'dev-feed',
32
+ containerKind: 'application',
33
+ technology: 'Cloudflare Worker',
34
+ state: 'proposed',
35
+ description: 'Merged-PR activity feed: API plus the single-page app it serves.',
36
+ deployment: {
37
+ resourceKey: 'cloudflare:worker:dev-feed',
38
+ provider: 'cloudflare',
39
+ resourceType: 'worker',
40
+ name: 'dev-feed',
41
+ source: wrangler(''),
42
+ },
43
+ },
44
+ {
45
+ kind: 'container',
46
+ id: 'container:cache-kv',
47
+ label: 'CACHE',
48
+ containerKind: 'data-store',
49
+ technology: 'Cloudflare KV',
50
+ state: 'proposed',
51
+ description: 'Cached feed responses.',
52
+ deployment: {
53
+ resourceKey: 'cloudflare:kv_namespace:0000000000000000',
54
+ provider: 'cloudflare',
55
+ resourceType: 'kv_namespace',
56
+ name: '0000000000000000',
57
+ source: wrangler('/kv_namespaces/0'),
58
+ },
59
+ },
60
+ {
61
+ kind: 'container',
62
+ id: 'container:topic-share',
63
+ label: 'topic-share',
64
+ containerKind: 'application',
65
+ technology: 'Cloudflare Worker',
66
+ state: 'proposed',
67
+ description: 'Publishes shared topics and sweeps expired ones daily.',
68
+ deployment: {
69
+ resourceKey: 'cloudflare:worker:topic-share',
70
+ provider: 'cloudflare',
71
+ resourceType: 'worker',
72
+ name: 'topic-share',
73
+ source: wrangler(''),
74
+ },
75
+ },
76
+ {
77
+ kind: 'container',
78
+ id: 'container:topic-share-r2',
79
+ label: 'topic-share',
80
+ containerKind: 'data-store',
81
+ technology: 'Cloudflare R2',
82
+ state: 'proposed',
83
+ description: 'Topic blobs.',
84
+ deployment: {
85
+ resourceKey: 'cloudflare:r2_bucket:topic-share',
86
+ provider: 'cloudflare',
87
+ resourceType: 'r2_bucket',
88
+ name: 'topic-share',
89
+ source: wrangler('/r2_buckets/0'),
90
+ },
91
+ },
92
+ {
93
+ kind: 'container',
94
+ id: 'container:topic-share-d1',
95
+ label: 'topic-share',
96
+ containerKind: 'data-store',
97
+ technology: 'Cloudflare D1',
98
+ state: 'proposed',
99
+ description: 'Index of shared topics and their expiry.',
100
+ deployment: {
101
+ resourceKey: 'cloudflare:d1_database:topic-share',
102
+ provider: 'cloudflare',
103
+ resourceType: 'd1_database',
104
+ name: 'topic-share',
105
+ source: wrangler('/d1_databases/0'),
106
+ },
107
+ },
108
+ {
109
+ kind: 'container',
110
+ id: 'container:legacy-api',
111
+ label: 'legacy-api',
112
+ containerKind: 'application',
113
+ technology: 'Node',
114
+ state: 'proposed',
115
+ description: 'Hosted somewhere we hold no mark for.',
116
+ deployment: {
117
+ resourceKey: 'fly:app:legacy-api',
118
+ provider: 'fly',
119
+ resourceType: 'app',
120
+ name: 'legacy-api',
121
+ },
122
+ },
123
+ ],
124
+ edges: [
125
+ {
126
+ id: 'edge:dev-feed->cache',
127
+ source: 'container:dev-feed',
128
+ target: 'container:cache-kv',
129
+ label: 'env.CACHE',
130
+ draft: true,
131
+ mechanisms: [],
132
+ count: 0,
133
+ },
134
+ {
135
+ id: 'edge:topic-share->r2',
136
+ source: 'container:topic-share',
137
+ target: 'container:topic-share-r2',
138
+ label: 'env.TOPIC_BLOBS',
139
+ draft: true,
140
+ mechanisms: [],
141
+ count: 0,
142
+ },
143
+ {
144
+ id: 'edge:topic-share->d1',
145
+ source: 'container:topic-share',
146
+ target: 'container:topic-share-d1',
147
+ label: 'env.SHARE_INDEX',
148
+ draft: true,
149
+ mechanisms: [],
150
+ count: 0,
151
+ },
152
+ ],
153
+ },
154
+ };
155
+
156
+ const OBSERVED_AT = '2026-11-29T09:00:00.000Z';
157
+
158
+ /**
159
+ * dev-feed and its cache are live; topic-share is declared but was never
160
+ * checked; its bucket was looked for and is missing; its database could not be
161
+ * checked.
162
+ */
163
+ export const DEPLOYMENT_OBSERVATIONS: ReadonlyMap<string, C4DeploymentObservation> = new Map(
164
+ (
165
+ [
166
+ {
167
+ resourceKey: 'cloudflare:worker:dev-feed',
168
+ status: 'deployed',
169
+ liveUrls: ['https://dev-feed.example.workers.dev'],
170
+ consoleUrl: 'https://dash.example.com/workers/dev-feed',
171
+ observedAt: OBSERVED_AT,
172
+ source: 'cloudflare-api',
173
+ },
174
+ {
175
+ resourceKey: 'cloudflare:kv_namespace:0000000000000000',
176
+ status: 'deployed',
177
+ consoleUrl: 'https://dash.example.com/kv/0000000000000000',
178
+ observedAt: OBSERVED_AT,
179
+ source: 'cloudflare-api',
180
+ },
181
+ {
182
+ resourceKey: 'cloudflare:r2_bucket:topic-share',
183
+ status: 'not-found',
184
+ consoleUrl: 'https://dash.example.com/r2',
185
+ observedAt: OBSERVED_AT,
186
+ source: 'cloudflare-api',
187
+ },
188
+ {
189
+ resourceKey: 'cloudflare:d1_database:topic-share',
190
+ status: 'unknown',
191
+ observedAt: OBSERVED_AT,
192
+ source: 'cloudflare-api',
193
+ },
194
+ ] satisfies C4DeploymentObservation[]
195
+ ).map((observation) => [observation.resourceKey, observation]),
196
+ );
@@ -94,6 +94,63 @@ interface C4MemberList {
94
94
  */
95
95
  export type C4ContainerKind = 'application' | 'data-store';
96
96
 
97
+ /**
98
+ * Which declared piece of infrastructure a container is — the *configured*
99
+ * anchor, read from a wrangler config or terraform JSON at a commit.
100
+ *
101
+ * It says where the container is meant to run, which is enough to draw the
102
+ * provider's mark. It holds no live fact: whether the thing is actually
103
+ * running, and at what URL, is a {@link C4DeploymentObservation} supplied
104
+ * separately and joined on `resourceKey`. Architecture identity and runtime
105
+ * state are kept apart on purpose — accepting a container never implies it is
106
+ * deployed.
107
+ *
108
+ * Structurally identical to `InfraC4Deployment` in `subsystems-core`, which
109
+ * produces these.
110
+ */
111
+ export interface C4Deployment {
112
+ /** `<provider>:<resourceType>:<identifier>`, e.g. `cloudflare:worker:topic-share`. */
113
+ resourceKey: string;
114
+ /** Hosting provider, lowercase: `cloudflare`. */
115
+ provider: string;
116
+ /** `worker`, `r2_bucket`, `d1_database`, `kv_namespace`, … */
117
+ resourceType: string;
118
+ /** The provider's own name or id for the resource. */
119
+ name: string;
120
+ /** Where it was declared. Absent on a hand-authored anchor. */
121
+ source?: { tool: string; file: string; pointer: string };
122
+ }
123
+
124
+ /**
125
+ * Whether a declared resource was found live. `unknown` means the check could
126
+ * not be made — never treat it as `not-found`.
127
+ */
128
+ export type C4DeploymentStatus = 'deployed' | 'not-found' | 'unknown';
129
+
130
+ /**
131
+ * One observation of one declared resource in a live account. Supplied by the
132
+ * host, never stored on the element. Carries no credential or secret.
133
+ *
134
+ * Structurally identical to `InfraDeploymentObservation` in `subsystems-core`.
135
+ */
136
+ export interface C4DeploymentObservation {
137
+ /** Joins to {@link C4Deployment.resourceKey}. */
138
+ resourceKey: string;
139
+ status: C4DeploymentStatus;
140
+ resourceId?: string;
141
+ /** Where the running thing answers. The first is the one a reader is sent to. */
142
+ liveUrls?: string[];
143
+ /** The provider dashboard page for this resource. */
144
+ consoleUrl?: string;
145
+ version?: string;
146
+ /** When that version went live (ISO). */
147
+ deployedAt?: string;
148
+ /** When we looked (ISO). */
149
+ observedAt: string;
150
+ /** Who said so: `cloudflare-api`, `terraform-state`, `authored`. */
151
+ source: string;
152
+ }
153
+
97
154
  /** A deployable unit or a store — the C4 level 2 box. */
98
155
  export interface C4Container extends C4ElementBase {
99
156
  kind: 'container';
@@ -107,6 +164,11 @@ export interface C4Container extends C4ElementBase {
107
164
  * the components inside resolve from the model document.
108
165
  */
109
166
  process?: string;
167
+ /**
168
+ * The declared infrastructure this container is, when a config file names
169
+ * it. Drives the provider mark on the card.
170
+ */
171
+ deployment?: C4Deployment;
110
172
  }
111
173
 
112
174
  /**