typedriver 0.8.10 → 0.8.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/index.d.mts +1 -0
- package/build/index.mjs +4 -0
- package/package.json +1 -1
- package/readme.md +26 -30
package/build/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { Type } from 'typebox';
|
|
1
2
|
export { type TCompile, compile } from './compile.mjs';
|
|
2
3
|
export { type Static } from './static.mjs';
|
|
3
4
|
export { Validator, type TErrorFormat, type TErrorLocale, type TErrorOptions, type TErrorResult, type TJsonSchemaError, type TStandardSchemaError, } from './validator.mjs';
|
package/build/index.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
// deno-fmt-ignore-file
|
|
2
2
|
// ------------------------------------------------------------------
|
|
3
|
+
// Type
|
|
4
|
+
// ------------------------------------------------------------------
|
|
5
|
+
export { Type } from 'typebox';
|
|
6
|
+
// ------------------------------------------------------------------
|
|
3
7
|
// Compile
|
|
4
8
|
// ------------------------------------------------------------------
|
|
5
9
|
export { compile } from './compile.mjs';
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -45,9 +45,7 @@ Compiles: [TypeScript](https://www.typescriptlang.org/play/?target=99&module=7#c
|
|
|
45
45
|
|
|
46
46
|
## Overview
|
|
47
47
|
|
|
48
|
-
TypeDriver is a
|
|
49
|
-
|
|
50
|
-
This project is designed to unify heterogeneous runtime schema systems based on JSON Schema and Standard Schema into a single system that preserves static type inference, runtime validation, and schema reflection, while remaining compatible with multiple schema ecosystems.
|
|
48
|
+
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.
|
|
51
49
|
|
|
52
50
|
License MIT
|
|
53
51
|
|
|
@@ -71,25 +69,20 @@ License MIT
|
|
|
71
69
|
|
|
72
70
|
## Features
|
|
73
71
|
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
- Schema
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
- Automatic JIT fallback for [content-security](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP) restrictive environments (Cloudflare)
|
|
89
|
-
- Tooling and Interoperability
|
|
90
|
-
- JSON Schema [reflect](#Reflect) API for OpenAPI, MCP, and IDL-Based Systems
|
|
91
|
-
- Error [formats](#Errors) for JSON Schema and Standard Schema Based Systems
|
|
92
|
-
- Includes [localized](#Locales) error messages (i18n) as standard.
|
|
72
|
+
TypeDriver provides a comprehensive set of features for integrating type-safe validation across multiple schema ecosystems:
|
|
73
|
+
|
|
74
|
+
- Single [function](#Compile) to compile multiple schematics into validators.
|
|
75
|
+
- Single [type](#Static) for inferring TypeScript types from multiple schematics.
|
|
76
|
+
- Integrated TypeScript [DSL](#Script) for TS7-native (supported in TS5+).
|
|
77
|
+
- Validation support for JSON Schema Drafts 3 through 2020-12.
|
|
78
|
+
- Supports Standard Schema and Standard JSON Schema (with [acceleration](#Accelerate))
|
|
79
|
+
- High-performance JIT compiler for improved application start up.
|
|
80
|
+
- High-performance runtime validation (approx 2x Ajv check performance)
|
|
81
|
+
- JIT compile fallback for [content-security](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/CSP) restrictive edge environments (e.g. Cloudflare)
|
|
82
|
+
- Schema [extension](#Extensions) model for custom type safe builder API's.
|
|
83
|
+
- JSON Schema [reflect](#Reflect) API for OpenAPI, MCP, and IDL-Based Systems
|
|
84
|
+
- Error [formats](#Errors) for JSON Schema and Standard Schema Based Systems
|
|
85
|
+
- Includes [localized](#Locales) error messages (i18n) as standard.
|
|
93
86
|
|
|
94
87
|
## Framework
|
|
95
88
|
|
|
@@ -400,25 +393,28 @@ validator.schema() // will return the schematic used for compile.
|
|
|
400
393
|
|
|
401
394
|
## Extensions
|
|
402
395
|
|
|
403
|
-
TypeDriver
|
|
396
|
+
TypeDriver supports the creation of framework specific type builder API. This can be achieved by creating functions that return statically observable JSON Schema. These schematics can be passed directly to compile(...) and Static. TypeDriver will derive the correct TypeScript type based on the schema returned.
|
|
404
397
|
|
|
405
|
-
Ref: [Framework Types](https://
|
|
398
|
+
Ref: [Advanced Framework Types](https://tsplay.dev/mMkoZw)
|
|
406
399
|
|
|
407
400
|
```typescript
|
|
408
|
-
import
|
|
401
|
+
import { type Static } from 'typedriver'
|
|
409
402
|
|
|
410
|
-
interface
|
|
403
|
+
interface TEmail {
|
|
411
404
|
type: 'string'
|
|
412
405
|
}
|
|
413
|
-
export function
|
|
414
|
-
return { type: 'string' }
|
|
406
|
+
export function email(): TEmail {
|
|
407
|
+
return { type: 'string', format: 'email' }
|
|
415
408
|
}
|
|
416
409
|
|
|
417
410
|
// ... Usage
|
|
418
411
|
|
|
419
|
-
const T =
|
|
412
|
+
const T = email() // const T: TEmail = {
|
|
413
|
+
// type: 'string',
|
|
414
|
+
// format: 'email'
|
|
415
|
+
// }
|
|
420
416
|
|
|
421
|
-
type T = Static<typeof T> // type T =
|
|
417
|
+
type T = Static<typeof T> // type T = string
|
|
422
418
|
```
|
|
423
419
|
|
|
424
420
|
## Accelerate
|