Skip to content

Commit 07d923f

Browse files
committed
Add validation strategy with webhooks.full.json
1 parent c4edec9 commit 07d923f

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

json-optimization-plan.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,73 @@ Example: The "user" object structure appears ~122 times with identical fields.
140140

141141
---
142142

143+
## Validation Strategy
144+
145+
### Source of Truth: `webhooks.full.json`
146+
147+
Check in the complete, unoptimized webhook data from the npm package as `webhooks.full.json` (~17 MB). This serves as:
148+
149+
1. **Source of truth** for validation
150+
2. **Debugging reference** when investigating issues
151+
3. **Reproducible input** for deterministic optimization
152+
153+
### File Structure
154+
155+
```
156+
languageservice/src/context-providers/events/
157+
├── webhooks.full.json # Full unoptimized data (~17 MB, checked in)
158+
├── webhooks.json # Human-readable optimized (generated)
159+
├── webhooks.min.json # Minified optimized (generated, used at runtime)
160+
├── objects.json # Deduplicated shared objects (generated)
161+
└── objects.min.json # Minified shared objects (generated, used at runtime)
162+
```
163+
164+
### Validation Test
165+
166+
Add a unit test that:
167+
168+
1. Loads event payload data from `webhooks.full.json` (parse + walk to build DescriptionDictionary)
169+
2. Loads event payload data from optimized `webhooks.min.json` + `objects.min.json` (existing code path)
170+
3. Walks both structures and verifies they produce identical results for:
171+
- All event types and action types
172+
- All property names at each level
173+
- All descriptions
174+
- All nested childParamsGroups
175+
176+
```typescript
177+
describe("optimization validation", () => {
178+
it("optimized data matches full source data", () => {
179+
const fullPayload = loadFromFull("push", "default");
180+
const optimizedPayload = getEventPayload("push", "default");
181+
182+
expectStructuresMatch(fullPayload, optimizedPayload);
183+
});
184+
185+
it("validates all events and actions", () => {
186+
for (const [event, actions] of Object.entries(fullWebhooks)) {
187+
for (const action of Object.keys(actions)) {
188+
const full = loadFromFull(event, action);
189+
const optimized = getEventPayload(event, action);
190+
expectStructuresMatch(full, optimized);
191+
}
192+
}
193+
});
194+
});
195+
```
196+
197+
### Generation Process
198+
199+
The `update-webhooks` script should:
200+
201+
1. Fetch webhook schema from npm package
202+
2. Write `webhooks.full.json` (complete, unmodified)
203+
3. Generate optimized `webhooks.json` + `objects.json`
204+
4. Minify to `webhooks.min.json` + `objects.min.json`
205+
206+
This ensures the optimization pipeline is always validated against the true source.
207+
208+
---
209+
143210
## Implementation Notes
144211

145212
### Phase 1: Short Property Names

0 commit comments

Comments
 (0)