conformance/src/schemas.ts
Matt 7f1515c475
tsdown + cli with commander (#17)
* feat: tsdown

* fix: formatting

* automate version updates in cli

* fix: docs

* scenarios

* fix: commander deps
2025-11-11 11:51:55 +00:00

44 lines
1.1 KiB
TypeScript

import { z } from 'zod';
import { getScenario, getClientScenario } from './scenarios';
// Client command options schema
export const ClientOptionsSchema = z.object({
command: z.string().min(1, 'Command cannot be empty'),
scenario: z
.string()
.min(1, 'Scenario cannot be empty')
.refine(
(scenario) => getScenario(scenario) !== undefined,
(scenario) => ({
message: `Unknown scenario '${scenario}'`
})
),
timeout: z
.string()
.transform((val) => parseInt(val, 10))
.pipe(
z
.number()
.positive('Timeout must be a positive number')
.int('Timeout must be an integer')
),
verbose: z.boolean().optional()
});
export type ClientOptions = z.infer<typeof ClientOptionsSchema>;
// Server command options schema
export const ServerOptionsSchema = z.object({
url: z.string().url('Invalid server URL'),
scenario: z
.string()
.refine(
(scenario) => getClientScenario(scenario) !== undefined,
(scenario) => ({
message: `Unknown scenario '${scenario}'`
})
)
.optional()
});
export type ServerOptions = z.infer<typeof ServerOptionsSchema>;