feat: v2.0 iteration — test coverage, reliability, observability
M0: Test coverage expansion (151 → 321 tests, 61% → 66% lines) - normalizeKnowledge CRLF/LF normalization fix - gooseReviewer: 11 tests, 97.35% coverage - r2 storage: 22 tests, 100% coverage - triage processor: 11 tests, exported buildTriagePrompt/labelName - webhook processor: 35 tests, 72.39% coverage - conflict resolver: 12 tests - review processor: 7 tests M1: Reliability hardening - Smart retry with jitter, maxTotalTimeoutMs, custom retryable predicate - MergeGuard: in-memory merge dedup tracker (100% coverage) - failureMessages: 7-category failure classifier (100% coverage) M2: Observability - MetricsCollector: Actions-run metrics with snapshot/markdown/reset - 11 tests, 100% coverage New files: 12 test files, 3 source modules All gates: typecheck ✓ lint ✓ format ✓ 321/321 tests ✓ build ✓
This commit is contained in:
1 parent
db53296d78
commit
78bf8e9e41
87 files changed
+6003
-2587
No files matched your search
@@ -19,58 +19,58 @@ For frontend applications where bundle size is critical, use `@zod/mini` instead
|
||||
// - Tree-shaking is important
|
||||
|
||||
// Zod: ~17kb gzipped
|
||||
import { z } from 'zod'
|
||||
import { z } from "zod";
|
||||
|
||||
// Zod Mini: ~1.9kb gzipped (when tree-shaken)
|
||||
import * as z from '@zod/mini'
|
||||
import * as z from "@zod/mini";
|
||||
```
|
||||
|
||||
**Standard Zod (method chaining):**
|
||||
|
||||
```typescript
|
||||
import { z } from 'zod'
|
||||
import { z } from "zod";
|
||||
|
||||
// Methods are attached to schema objects - hard to tree-shake
|
||||
const userSchema = z.object({
|
||||
name: z.string().min(1).max(100),
|
||||
email: z.string().email(),
|
||||
age: z.number().int().positive(),
|
||||
})
|
||||
age: z.number().int().positive()
|
||||
});
|
||||
|
||||
const result = userSchema.safeParse(data)
|
||||
const result = userSchema.safeParse(data);
|
||||
```
|
||||
|
||||
**Zod Mini (functional API):**
|
||||
|
||||
```typescript
|
||||
import * as z from '@zod/mini'
|
||||
import * as z from "@zod/mini";
|
||||
|
||||
// Functions are imported individually - tree-shakeable
|
||||
const userSchema = z.object({
|
||||
name: z.pipe(z.string(), z.minLength(1), z.maxLength(100)),
|
||||
email: z.pipe(z.string(), z.email()),
|
||||
age: z.pipe(z.number(), z.int(), z.positive()),
|
||||
})
|
||||
age: z.pipe(z.number(), z.int(), z.positive())
|
||||
});
|
||||
|
||||
const result = z.safeParse(userSchema, data)
|
||||
const result = z.safeParse(userSchema, data);
|
||||
```
|
||||
|
||||
**API differences:**
|
||||
|
||||
```typescript
|
||||
// Standard Zod
|
||||
z.string().min(5).max(100).email()
|
||||
z.number().int().positive()
|
||||
z.array(z.string()).min(1)
|
||||
schema.parse(data)
|
||||
schema.safeParse(data)
|
||||
z.string().min(5).max(100).email();
|
||||
z.number().int().positive();
|
||||
z.array(z.string()).min(1);
|
||||
schema.parse(data);
|
||||
schema.safeParse(data);
|
||||
|
||||
// Zod Mini
|
||||
z.pipe(z.string(), z.minLength(5), z.maxLength(100), z.email())
|
||||
z.pipe(z.number(), z.int(), z.positive())
|
||||
z.pipe(z.array(z.string()), z.minLength(1))
|
||||
z.parse(schema, data)
|
||||
z.safeParse(schema, data)
|
||||
z.pipe(z.string(), z.minLength(5), z.maxLength(100), z.email());
|
||||
z.pipe(z.number(), z.int(), z.positive());
|
||||
z.pipe(z.array(z.string()), z.minLength(1));
|
||||
z.parse(schema, data);
|
||||
z.safeParse(schema, data);
|
||||
```
|
||||
|
||||
**When to stick with regular Zod:**
|
||||
@@ -103,13 +103,14 @@ z.safeParse(schema, data)
|
||||
|
||||
**Bundle size comparison:**
|
||||
|
||||
| Package | Gzipped Size | Use Case |
|
||||
|---------|--------------|----------|
|
||||
| `zod@3` | ~13kb | Legacy, stable |
|
||||
| `zod@4` | ~17kb | Full features |
|
||||
| `@zod/mini` | ~1.9kb | Bundle-critical |
|
||||
| Package | Gzipped Size | Use Case |
|
||||
| ----------- | ------------ | --------------- |
|
||||
| `zod@3` | ~13kb | Legacy, stable |
|
||||
| `zod@4` | ~17kb | Full features |
|
||||
| `@zod/mini` | ~1.9kb | Bundle-critical |
|
||||
|
||||
**When NOT to use this pattern:**
|
||||
|
||||
- Server-side applications (bundle size irrelevant)
|
||||
- When method chaining ergonomics are preferred
|
||||
- Complex schemas that benefit from full API
|
||||
|
||||
Reference in new issue
Block a user