Skip to content

Commit df6d0eb

Browse files
Fix: Normalize @types/pg versions across monorepo.
Aligns @types/pg to ^8.18.0 in packages/sync-engine and packages/fastify-app to resolve a type conflict between incompatible Client definitions during build. Committed-By-Agent: cursor
1 parent af159f8 commit df6d0eb

4 files changed

Lines changed: 221 additions & 19 deletions

File tree

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
# Agent Harness Task: Visualizer Step 2
2+
3+
## Mission
4+
5+
Update `packages/visualizer` with an ERD, and make it API version-aware. Keep all exploration client-side through PGlite.
6+
7+
Existing Table/Result/SQL view should not break. This is new functionality.
8+
9+
The work must happen in this order:
10+
11+
1. ERD tab and ERD experience
12+
2. Version picker backed by 5 pre-generated artifacts
13+
3. Roughly 5x more realistic fake data
14+
15+
Do not reorder these phases.
16+
17+
## North Star
18+
19+
The visualizer should become a polished schema exploration tool where:
20+
21+
- the first-class experience is an ERD canvas, not just a SQL table browser
22+
- the loaded "schema" can be swapped between a small, intentional set of supported Stripe API versions.
23+
- the data is dense enough to feel realistic without abandoning the repo's OpenAPI projection logic
24+
25+
## Non-Negotiables
26+
27+
- Keep the primary product work in `packages/visualizer`.
28+
- Do not touch `packages/dashboard`.
29+
- Only change code outside `packages/visualizer` when it is strictly required for artifact generation, schema metadata export, or multi-version build orchestration.
30+
- Any non-visualizer changes must be minimal, justified, and pruned aggressively.
31+
- Keep the runtime browser-only. No API routes, no server-side query layer, no remote DB dependency.
32+
- Keep using the repo's existing OpenAPI projection pipeline as the source of truth for schema shape.
33+
- Use established libraries for graph/canvas/layout. Do not hand-roll the ERD canvas or layout engine.
34+
- Preserve the existing SQL explorer as a secondary surface if helpful, but do not let it block or delay the ERD-first experience.
35+
36+
## Scope Guard
37+
38+
This phase is about the visualizer product experience and versioned artifact flow.
39+
40+
It is not a license to:
41+
42+
- refactor unrelated sync-engine logic
43+
- revisit the full migration/parser/export architecture again unless a blocker is proven
44+
- support every Stripe API version
45+
- build a custom diagramming engine
46+
47+
## Phase 1: ERD First
48+
49+
## Goal
50+
51+
Add an `ERD` tab that, when selected, replaces the full main view with a canvas-based schema diagram.
52+
53+
## Required Outcome
54+
55+
- The visualizer opens into an ERD-first experience or makes the ERD tab the obvious primary destination.
56+
- Clicking the `ERD` tab replaces the entire main workspace with a full-screen graph canvas.
57+
- The ERD uses libraries for both graph interaction and layout. Prefer `@xyflow/react` plus `elkjs`, or an equivalent pair with the same maturity level.
58+
- Tables are rendered as nodes.
59+
- Node contents are derived from the actual loaded schema for the currently selected artifact, not from hardcoded table definitions.
60+
- Each node shows:
61+
- table name
62+
- columns
63+
- only the first 10 columns by default
64+
- a bottom expand/collapse affordance to reveal or hide the remaining columns
65+
- The canvas supports smooth pan/zoom and draggable nodes.
66+
- The ERD remains aesthetically clean with many tables on screen.
67+
68+
## Important Constraint
69+
70+
The user primarily cares about visualizing tables and columns in the DB.
71+
72+
If relationship edges are reliably available from the loaded browser-safe metadata, render them.
73+
If they are not reliably available from the hydrated PGlite schema, generate the smallest possible build-time schema sidecar needed for ERD relationships.
74+
Do not reintroduce browser-breaking FK DDL into the bootstrap artifact just to force edges to exist in PGlite.
75+
Do not parse `bootstrap.sql` in the browser.
76+
77+
## Acceptance Criteria
78+
79+
- ERD renders without hand-authored node coordinates.
80+
- A schema with ~100 tables remains explorable.
81+
- Expanding and collapsing nodes works per table and does not destroy layout usability.
82+
- The existing explorer/table view still works if retained as a secondary tab.
83+
84+
## Phase 2: Version Picker
85+
86+
## Goal
87+
88+
After the ERD works on the current single artifact flow, add support for exactly 5 supported Stripe API versions using pre-generated static artifacts.
89+
90+
## Required Outcome
91+
92+
- The visualizer supports exactly 5 pinned API versions spanning years.
93+
- Include `2020-08-27` as the baseline version.
94+
- Choose the remaining 4 versions as resolvable Stripe API snapshots spread across later years.
95+
- If a preferred candidate version does not resolve cleanly through the existing spec pipeline, replace it with the nearest resolvable yearly snapshot and document the final chosen list.
96+
- Generate separate browser-loadable artifacts per version rather than trying to build them dynamically in-browser.
97+
- Add a small index artifact that lists:
98+
- supported versions
99+
- default version
100+
- human-friendly labels
101+
- manifest/bootstrap paths
102+
- seed
103+
- table counts or similar lightweight metadata
104+
- Add a shared version picker in the visualizer UI.
105+
- Switching versions must fully switch the loaded artifact and reinitialize the active PGlite database for that version.
106+
- Do not preload all 5 full SQL artifacts into memory at startup.
107+
108+
## Suggested Artifact Shape
109+
110+
Use a structure like:
111+
112+
```text
113+
packages/visualizer/public/explorer-data/
114+
index.json
115+
<api-version-a>/manifest.json
116+
<api-version-a>/bootstrap.sql
117+
<api-version-b>/manifest.json
118+
<api-version-b>/bootstrap.sql
119+
...
120+
```
121+
122+
## Acceptance Criteria
123+
124+
- The ERD reflects the selected version's actual loaded schema.
125+
- Version switching updates the loaded DB, not just the label in the UI.
126+
- The current single-version build remains available for fast local iteration.
127+
- Add one explicit multi-version build command for generating the 5-version matrix.
128+
129+
## Phase 3: 5x Data Volume
130+
131+
## Goal
132+
133+
Increase the fake data volume by about 5x while keeping the data believable and still shaped by the repo's OpenAPI projection logic.
134+
135+
## Required Outcome
136+
137+
- Increase total generated row volume by roughly 4x to 6x relative to the current baseline.
138+
- Keep the existing graph-aware core entity generation logic.
139+
- Preserve realistic Stripe-like relationships, timestamps, statuses, and reused parent entities.
140+
- Do not satisfy this by naive duplication or random junk rows.
141+
- Increase long-tail table volume too, but keep the artifacts usable in-browser.
142+
- Tune counts if a literal 5x makes one or more versions unusable in the browser.
143+
144+
## Acceptance Criteria
145+
146+
- Core flows still look realistic:
147+
- `product -> price`
148+
- `customer -> payment_method`
149+
- `customer -> subscription -> subscription_items`
150+
- `subscription -> invoice`
151+
- `invoice -> payment_intent -> charge -> refund`
152+
- `customer -> checkout_session`
153+
- All projected tables remain non-empty for supported versions unless the schema itself makes that impossible.
154+
- The resulting artifacts still hydrate in-browser for each supported version.
155+
156+
## Change Containment Rules
157+
158+
- Prefer solving ERD and versioning inside the visualizer package.
159+
- Only allow minimal changes outside it for:
160+
- multi-version artifact generation
161+
- schema metadata sidecar generation, if needed
162+
- seed volume tuning
163+
- top-level scripts/commands needed to run the new flow
164+
- Avoid touching `packages/sync-engine/src/openapi/*` or other sync-engine internals unless a proven blocker makes it unavoidable.
165+
- If a non-visualizer change is unavoidable, keep it isolated and explain why it was required.
166+
167+
## Verification
168+
169+
The harness should not declare success until all of the following are true.
170+
171+
### Phase 1 verification
172+
173+
- Run the existing single-version artifact build.
174+
- Start the visualizer locally.
175+
- Confirm the app opens into an ERD-first flow.
176+
- Confirm the ERD canvas pans, zooms, and lays out tables automatically.
177+
- Confirm at least several large tables render with 10 visible columns by default and expand/collapse correctly.
178+
179+
### Phase 2 verification
180+
181+
- Run the new multi-version build and confirm exactly 5 version directories plus an index artifact are produced.
182+
- Start the visualizer and switch across all supported versions.
183+
- Confirm the selected version changes the loaded schema metadata and visible table counts.
184+
- Confirm switching versions rehydrates PGlite rather than reusing stale in-memory state.
185+
186+
### Phase 3 verification
187+
188+
- Rebuild at least one baseline version first with the increased data volume and confirm the UI remains usable.
189+
- Then rebuild the full 5-version matrix.
190+
- Confirm manifests reflect the denser dataset.
191+
- Confirm the ERD and explorer still load for all supported versions.
192+
193+
## Done Means
194+
195+
This task is done when:
196+
197+
- `packages/visualizer` is an ERD-first schema browser
198+
- the ERD is library-driven, clean, and based on the loaded schema
199+
- exactly 5 supported API versions can be selected in-browser from pre-generated artifacts
200+
- the data volume is meaningfully denser and still believable
201+
- the solution remains browser-only and primarily isolated to the visualizer package
202+
203+
## Suggested Commands
204+
205+
The agent may add or update commands as needed, but the end state should support a workflow equivalent to:
206+
207+
```bash
208+
pnpm explorer:build --api-version=2020-08-27
209+
pnpm explorer:build:all
210+
pnpm visualizer
211+
```

packages/fastify-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"stripe-experiment-sync": "workspace:*"
2828
},
2929
"devDependencies": {
30-
"@types/pg": "^8.15.2",
30+
"@types/pg": "^8.18.0",
3131
"@types/node": "^24.5.0",
3232
"tsx": "^4.20.5",
3333
"vitest": "^3.2.4"

packages/sync-engine/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@types/inquirer": "^9.0.7",
6060
"@types/node": "^24.10.1",
6161
"@types/papaparse": "5.3.16",
62-
"@types/pg": "^8.15.5",
62+
"@types/pg": "^8.18.0",
6363
"@types/ws": "^8.5.13",
6464
"@types/yesql": "^4.1.4",
6565
"@vitest/ui": "^4.0.9",

pnpm-lock.yaml

Lines changed: 8 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)