Skip to content

Commit 6e02506

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 6e02506

File tree

9 files changed

+327
-313
lines changed

9 files changed

+327
-313
lines changed

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@
181181
"@types/wallabyjs",
182182
"@types/mocha",
183183
"markdownlint-cli2-formatter-pretty",
184-
"asciinema-player",
185184
"@astrojs/mdx",
186185
"astro-broken-link-checker",
187186
"jest",

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

src/adapters/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import type {
99
BenchmarkDefinition,
1010
BenchmarkSuite,
11-
} from '../core/benchmark-schema.js';
11+
} from '../config/benchmark-schema.js';
1212

1313
/**
1414
* A captured test suite (describe block) from a test framework
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { z } from 'zod';
1111

1212
import type { ModestBenchConfig } from '../types/core.js';
1313

14-
import { partialModestBenchConfigSchema } from '../config/schema.js';
14+
import { partialModestBenchConfigSchema } from './schema.js';
1515

1616
/**
1717
* Schema for benchmark functions

0 commit comments

Comments
 (0)