@principal-ai/subsystems-react 0.56.12 → 0.56.14
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/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/subsystem/C4Graph.d.ts.map +1 -1
- package/dist/subsystem/C4Graph.js +10 -4
- package/dist/subsystem/C4Graph.js.map +1 -1
- package/dist/subsystem/C4ProjectionView.d.ts +60 -0
- package/dist/subsystem/C4ProjectionView.d.ts.map +1 -0
- package/dist/subsystem/C4ProjectionView.js +336 -0
- package/dist/subsystem/C4ProjectionView.js.map +1 -0
- package/dist/subsystem/C4SketchView.d.ts +23 -0
- package/dist/subsystem/C4SketchView.d.ts.map +1 -0
- package/dist/subsystem/C4SketchView.js +119 -0
- package/dist/subsystem/C4SketchView.js.map +1 -0
- package/dist/subsystem/DescriptionOverlay.d.ts +6 -0
- package/dist/subsystem/DescriptionOverlay.d.ts.map +1 -0
- package/dist/subsystem/DescriptionOverlay.js +58 -0
- package/dist/subsystem/DescriptionOverlay.js.map +1 -0
- package/dist/subsystem/SubsystemComponentGraph.d.ts.map +1 -1
- package/dist/subsystem/SubsystemComponentGraph.js +289 -271
- package/dist/subsystem/SubsystemComponentGraph.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4Drilldown.d.ts +4 -27
- package/dist/subsystem/__fixtures__/c4Drilldown.d.ts.map +1 -1
- package/dist/subsystem/__fixtures__/c4Drilldown.js +4 -56
- package/dist/subsystem/__fixtures__/c4Drilldown.js.map +1 -1
- package/dist/subsystem/__fixtures__/c4Sketch.d.ts +9 -0
- package/dist/subsystem/__fixtures__/c4Sketch.d.ts.map +1 -0
- package/dist/subsystem/__fixtures__/c4Sketch.js +89 -0
- package/dist/subsystem/__fixtures__/c4Sketch.js.map +1 -0
- package/dist/subsystem/c4Sketch.d.ts +74 -0
- package/dist/subsystem/c4Sketch.d.ts.map +1 -0
- package/dist/subsystem/c4Sketch.js +9 -0
- package/dist/subsystem/c4Sketch.js.map +1 -0
- package/dist/subsystem/c4TrailFocus.d.ts +30 -0
- package/dist/subsystem/c4TrailFocus.d.ts.map +1 -0
- package/dist/subsystem/c4TrailFocus.js +57 -0
- package/dist/subsystem/c4TrailFocus.js.map +1 -0
- package/package.json +1 -1
- package/src/index.ts +14 -0
- package/src/stories/Canvases/C4/C4Draft.stories.tsx +238 -0
- package/src/stories/Canvases/C4/C4Sketch.stories.tsx +36 -0
- package/src/stories/Canvases/C4/C4ToComponentDrill.stories.tsx +18 -429
- package/src/subsystem/C4Graph.tsx +10 -4
- package/src/subsystem/C4ProjectionView.tsx +595 -0
- package/src/subsystem/C4SketchView.tsx +241 -0
- package/src/subsystem/DescriptionOverlay.test.tsx +76 -0
- package/src/subsystem/DescriptionOverlay.tsx +101 -0
- package/src/subsystem/SubsystemComponentGraph.sidebar.test.tsx +10 -3
- package/src/subsystem/SubsystemComponentGraph.tsx +44 -12
- package/src/subsystem/__fixtures__/c4Drilldown.ts +7 -58
- package/src/subsystem/__fixtures__/c4Sketch.ts +94 -0
- package/src/subsystem/c4Sketch.ts +78 -0
- package/src/subsystem/c4TrailFocus.ts +62 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storybook fixture for an authored C4 sketch.
|
|
3
|
+
*
|
|
4
|
+
* A standalone hypothesis: containers, a component, an external, a person,
|
|
5
|
+
* and two authored lines. No model or grounding is involved.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { C4Sketch } from '../c4Sketch';
|
|
9
|
+
|
|
10
|
+
const PURL = 'pkg:github/acme/widget';
|
|
11
|
+
|
|
12
|
+
export const SKETCH_FIXTURE: C4Sketch = {
|
|
13
|
+
id: 'c4s-story',
|
|
14
|
+
title: 'Acme widget architecture',
|
|
15
|
+
repoKeys: [PURL],
|
|
16
|
+
author: 'storybook',
|
|
17
|
+
notes:
|
|
18
|
+
'## About this sketch\n\nThis is an **authored hypothesis** for the Acme widget. It describes the host and worker containers, the store inside the host, and the GitHub integration.\n\n- The worker calls the host over RPC.\n- The host calls GitHub over HTTPS.\n- Nothing here is verified or promoted.',
|
|
19
|
+
createdAt: '2026-10-25T00:00:00.000Z',
|
|
20
|
+
updatedAt: '2026-10-25T00:00:00.000Z',
|
|
21
|
+
model: {
|
|
22
|
+
view: 'container',
|
|
23
|
+
system: { id: 'system:acme', label: 'Acme' },
|
|
24
|
+
nodes: [
|
|
25
|
+
{
|
|
26
|
+
kind: 'container',
|
|
27
|
+
id: 'container:host',
|
|
28
|
+
label: 'Host',
|
|
29
|
+
containerKind: 'application',
|
|
30
|
+
technology: 'Bun',
|
|
31
|
+
process: 'acme/host',
|
|
32
|
+
state: 'proposed',
|
|
33
|
+
description: 'The long-lived host process.',
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
kind: 'container',
|
|
37
|
+
id: 'container:worker',
|
|
38
|
+
label: 'Worker',
|
|
39
|
+
containerKind: 'application',
|
|
40
|
+
technology: 'Bun',
|
|
41
|
+
process: 'acme/worker',
|
|
42
|
+
state: 'proposed',
|
|
43
|
+
description: 'The background worker.',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
kind: 'component',
|
|
47
|
+
id: 'component:store',
|
|
48
|
+
label: 'Store',
|
|
49
|
+
container: 'container:host',
|
|
50
|
+
technology: 'Postgres',
|
|
51
|
+
members: ['store', 'ghost'],
|
|
52
|
+
state: 'proposed',
|
|
53
|
+
description: 'Persistence inside the host.',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
kind: 'external-system',
|
|
57
|
+
id: 'external:github',
|
|
58
|
+
label: 'GitHub',
|
|
59
|
+
technology: 'REST',
|
|
60
|
+
members: ['github'],
|
|
61
|
+
state: 'proposed',
|
|
62
|
+
description: 'External source control.',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
kind: 'person',
|
|
66
|
+
id: 'person:dev',
|
|
67
|
+
label: 'Developer',
|
|
68
|
+
state: 'proposed',
|
|
69
|
+
description: 'Uses the system.',
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
edges: [
|
|
73
|
+
{
|
|
74
|
+
id: 'e:host-github',
|
|
75
|
+
source: 'container:host',
|
|
76
|
+
target: 'external:github',
|
|
77
|
+
label: 'HTTPS',
|
|
78
|
+
protocol: 'HTTPS',
|
|
79
|
+
mechanisms: ['calls'],
|
|
80
|
+
count: 1,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: 'e:worker-host',
|
|
84
|
+
source: 'container:worker',
|
|
85
|
+
target: 'container:host',
|
|
86
|
+
label: 'RPC',
|
|
87
|
+
protocol: 'RPC',
|
|
88
|
+
mechanisms: ['calls'],
|
|
89
|
+
count: 1,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Authored C4 sketches — the types shared by the sketch view and the host
|
|
3
|
+
* stores.
|
|
4
|
+
*
|
|
5
|
+
* These live in `subsystems-react` so the pure view and its Storybook fixtures
|
|
6
|
+
* can use them without importing Studio's cross-process contract.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { C4Model } from './c4';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A C4 sketch — an authored, unverified architecture hypothesis.
|
|
13
|
+
*
|
|
14
|
+
* Unlike the accepted element store (approved containers only) and a model
|
|
15
|
+
* projection (derived from `process` keys), a sketch carries containers,
|
|
16
|
+
* components, externals, persons, AND edges. It can exist before any subsystem
|
|
17
|
+
* model does. Element state is forced to `proposed` by the host store: a sketch
|
|
18
|
+
* never claims acceptance.
|
|
19
|
+
*/
|
|
20
|
+
export interface C4Sketch {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
/** Repos the sketch claims to describe; can be empty for greenfield. */
|
|
24
|
+
repoKeys: string[];
|
|
25
|
+
/** Authored nodes + edges. */
|
|
26
|
+
model: C4Model;
|
|
27
|
+
author?: string;
|
|
28
|
+
notes?: string;
|
|
29
|
+
createdAt: string;
|
|
30
|
+
updatedAt: string;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Lightweight row for listing sketches without their nodes/edges. */
|
|
34
|
+
export interface C4SketchSummary {
|
|
35
|
+
id: string;
|
|
36
|
+
title: string;
|
|
37
|
+
repoKeys: string[];
|
|
38
|
+
author?: string;
|
|
39
|
+
createdAt: string;
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
counts: {
|
|
42
|
+
containers: number;
|
|
43
|
+
components: number;
|
|
44
|
+
externals: number;
|
|
45
|
+
persons: number;
|
|
46
|
+
edges: number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Which C4 source a model projection or tab reads. */
|
|
51
|
+
export type SubsystemC4Source = 'auto' | 'accepted' | 'draft';
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* A drawable C4 projection for one subsystem model.
|
|
55
|
+
*
|
|
56
|
+
* `accepted` uses the repo's approved containers; `draft` derives provisional
|
|
57
|
+
* containers from the model's `process` keys. `memberships` is element id →
|
|
58
|
+
* component aliases, so a view can build construct graphs without re-deriving
|
|
59
|
+
* the join.
|
|
60
|
+
*/
|
|
61
|
+
export interface SubsystemC4Projection {
|
|
62
|
+
model: C4Model;
|
|
63
|
+
source: 'accepted' | 'draft';
|
|
64
|
+
memberships: Record<string, string[]>;
|
|
65
|
+
counts: {
|
|
66
|
+
containers: number;
|
|
67
|
+
externals: number;
|
|
68
|
+
edges: number;
|
|
69
|
+
components: number;
|
|
70
|
+
unassignedComponents: number;
|
|
71
|
+
unbackedProcesses: number;
|
|
72
|
+
};
|
|
73
|
+
repos: string[];
|
|
74
|
+
/** Aliases of components that state no `process`. */
|
|
75
|
+
unassignedComponents: string[];
|
|
76
|
+
/** Container-shaped process keys no accepted container claims (accepted source only). */
|
|
77
|
+
unbackedProcesses: string[];
|
|
78
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* C4 trail focus — the pure read-side helpers shared by the C4 projection view
|
|
3
|
+
* and its stories.
|
|
4
|
+
*
|
|
5
|
+
* These do not own state: a host decides which trail/step is focused and asks
|
|
6
|
+
* which elements and lines that focus touches.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import type { C4Edge } from './c4';
|
|
10
|
+
import type { SubsystemTrailStep } from './model';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The C4 elements a trail touches — every element that owns a step endpoint.
|
|
14
|
+
*
|
|
15
|
+
* Because a container's process-claim membership AND the authored components
|
|
16
|
+
* nested inside it can both claim an alias, both end up in the set: the
|
|
17
|
+
* container is the visible card at container view, its components are the
|
|
18
|
+
* visible cards when it is open, so either view stays honest.
|
|
19
|
+
*/
|
|
20
|
+
export function deriveTrailPlayerElements(
|
|
21
|
+
steps: readonly SubsystemTrailStep[],
|
|
22
|
+
members: Readonly<Record<string, readonly string[]>>,
|
|
23
|
+
): Set<string> {
|
|
24
|
+
const byAlias = new Map<string, string[]>();
|
|
25
|
+
for (const [elementId, aliases] of Object.entries(members)) {
|
|
26
|
+
for (const alias of aliases) {
|
|
27
|
+
const list = byAlias.get(alias);
|
|
28
|
+
if (list) list.push(elementId);
|
|
29
|
+
else byAlias.set(alias, [elementId]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const players = new Set<string>();
|
|
33
|
+
for (const step of steps) {
|
|
34
|
+
for (const id of byAlias.get(step.from) ?? []) players.add(id);
|
|
35
|
+
for (const id of byAlias.get(step.to) ?? []) players.add(id);
|
|
36
|
+
}
|
|
37
|
+
return players;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The C4 edges that carry a focus — a whole trail, or one specific step.
|
|
42
|
+
*
|
|
43
|
+
* An edge is lit iff its authored `trailRefs` cover the source. A step entirely
|
|
44
|
+
* internal to a container folds into no C4 line, so its focus lights nothing —
|
|
45
|
+
* which is honest: no drawn edge represents that hop.
|
|
46
|
+
*/
|
|
47
|
+
export function deriveLitC4Edges(
|
|
48
|
+
source: { trailId: string; stepIndex?: number },
|
|
49
|
+
edges: readonly C4Edge[],
|
|
50
|
+
): Set<string> {
|
|
51
|
+
const lit = new Set<string>();
|
|
52
|
+
for (const edge of edges) {
|
|
53
|
+
for (const ref of edge.trailRefs ?? []) {
|
|
54
|
+
if (ref.trailId !== source.trailId) continue;
|
|
55
|
+
if (source.stepIndex == null || ref.stepIndices.includes(source.stepIndex)) {
|
|
56
|
+
lit.add(edge.id);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return lit;
|
|
62
|
+
}
|