Typedriver
High Performance Driver for Runtime Type System Integration
Install / Use
/learn @sinclairzx81/TypedriverREADME
Install
$ npm install typedriver
Usage
import compile from 'typedriver'
const Vector3 = compile(`{
x: number,
y: number,
z: number
}`)
const position = Vector3.parse(value) // const position: {
// x: number,
// y: number,
// z: number
// } = ...
Also Compiles: TypeScript | JSON Schema | TypeBox | Effect | Zod | ArkType | Valibot | Arri | Sury ... and more
Overview
TypeDriver is a multi-library compiler and type-inference middleware designed to integrate JSON Schema and Standard Schema validation into framework I/O interfaces such as HTTP routes and RPC endpoints. It provides high-performance compiler support for a wide range of ecosystem libraries and offers first-class TypeScript and JSON Schema validation and type inference as standard.
License MIT
Contents
- Overview
- Example
- Compile
- Check
- Parse
- Errors
- Locales
- Static
- Script
- Reflect
- Extensions
- Accelerate
- Compression
- Contribute
Example
TypeDriver provides a simple infrastructure to connect type inference and validation to framework interfaces.
Ref: TypeScript | JSON Schema | Standard Schema
// Next Generation Inference System Based on TypeScript DSL (TS7)
route('/', {
body: `{
x: number,
y: number,
z: number
}`
}, (request) => {
const { x, y, z } = request.body // type-safe!
})
The above interface design is achieved with the following TypeScript definitions
<details> <summary>Route Interface Definition (Expand)</summary>import { type Static, compile } from 'typedriver'
export interface RouteOptions<Body extends unknown = unknown> {
body: Body
}
export type RouteCallback<Path extends string, Options extends RouteOptions> = (
(request: { url: Path, body: Static<Options['body']> }) => void
)
export function route<Path extends string, const Options extends RouteOptions,
Callback = RouteCallback<Path, Options>
>(path: Path, options: Options, callback: Callback) {
const body_validator = compile(options['body'])
// todo: ... implement route logic
}
</details>
Compile
TypeDriver consists of a single compile(...) function that accepts JSON Schema, Standard Schema or TypeScript definition and returns a Validator instance.
import compile from 'typedriver'
Ref: [TypeScript](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYwuYAbApnAvnAMyjTgHIYBPMLAEymADcspSAoV1AOwGd4A1LMhjQAzHAC8KNGExYAFAAMErOHAAeALjicAriABGzFXApbdBo6oBeZvYaitcCgJSq37j56-ef7gPR+Ujz8gsJQ
Related Skills
node-connect
335.9kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
82.7kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
Writing Hookify Rules
82.7kThis skill should be used when the user asks to "create a hookify rule", "write a hook rule", "configure hookify", "add a hookify rule", or needs guidance on hookify rule syntax and patterns.
openai-whisper-api
335.9kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
