Skip to content

Commit eadd55f

Browse files
boneskullclaude
andcommitted
refactor(schema): use Zod transforms instead of manual mutation
Replace manual result mutation in safeParseConfig/safeParsePartialConfig with proper Zod .transform() methods: - Add budgetSchema transform for string-to-number conversion (e.g., '10ms' → ns) - Add budgetsSchema transform for nested-to-flat structure conversion - Extract baseConfigProperties to avoid duplication between runtime and JSON Schema generation schemas - Export ModestBenchConfigInput type for consumers needing the input shape - Export partialModestBenchConfigInputSchema for JSON Schema generation (transforms can't be represented in JSON Schema) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 9fe0dd6 commit eadd55f

File tree

4 files changed

+304
-264
lines changed

4 files changed

+304
-264
lines changed

scripts/generate-schema.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ import { dirname, resolve } from 'node:path';
1212
import { fileURLToPath } from 'node:url';
1313
import * as z from 'zod';
1414

15-
import { partialModestBenchConfigSchema } from '../src/config/schema.js';
15+
import { partialModestBenchConfigInputSchema } from '../src/config/schema.js';
1616

1717
const __filename = fileURLToPath(import.meta.url);
1818
const __dirname = dirname(__filename);
1919

2020
const generateSchema = async () => {
2121
try {
2222
// Convert Zod schema to JSON Schema using native Zod v4 functionality
23-
const jsonSchema = z.toJSONSchema(partialModestBenchConfigSchema, {
23+
const jsonSchema = z.toJSONSchema(partialModestBenchConfigInputSchema, {
2424
target: 'draft-2020-12',
2525
});
2626

0 commit comments

Comments
 (0)