@depup/typebox 1.3.27-depup.0 → 1.3.30-depup.0
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/README.md +2 -2
- package/build/schema/build.mjs +2 -2
- package/build/schema/check.mjs +1 -1
- package/build/schema/engine/_context.d.mts +5 -1
- package/build/schema/engine/_context.mjs +16 -3
- package/build/schema/engine/_functions.d.mts +2 -2
- package/build/schema/engine/_functions.mjs +1 -1
- package/build/schema/engine/_reducer.d.mts +3 -3
- package/build/schema/engine/_refine.d.mts +5 -5
- package/build/schema/engine/_refine.mjs +4 -7
- package/build/schema/engine/_stack.d.mts +34 -20
- package/build/schema/engine/_stack.mjs +143 -202
- package/build/schema/engine/additionalItems.d.mts +4 -4
- package/build/schema/engine/additionalProperties.d.mts +8 -8
- package/build/schema/engine/additionalProperties.mjs +10 -14
- package/build/schema/engine/allOf.d.mts +4 -4
- package/build/schema/engine/allOf.mjs +1 -1
- package/build/schema/engine/anyOf.d.mts +4 -4
- package/build/schema/engine/anyOf.mjs +4 -9
- package/build/schema/engine/boolean.d.mts +4 -4
- package/build/schema/engine/boolean.mjs +2 -6
- package/build/schema/engine/const.d.mts +4 -4
- package/build/schema/engine/const.mjs +2 -6
- package/build/schema/engine/contains.d.mts +4 -4
- package/build/schema/engine/contains.mjs +2 -6
- package/build/schema/engine/dependencies.d.mts +4 -4
- package/build/schema/engine/dependencies.mjs +3 -6
- package/build/schema/engine/dependentRequired.d.mts +4 -4
- package/build/schema/engine/dependentRequired.mjs +2 -6
- package/build/schema/engine/dependentSchemas.d.mts +4 -4
- package/build/schema/engine/dynamicRef.d.mts +4 -4
- package/build/schema/engine/dynamicRef.mjs +11 -7
- package/build/schema/engine/enum.d.mts +4 -4
- package/build/schema/engine/enum.mjs +2 -6
- package/build/schema/engine/exclusiveMaximum.d.mts +4 -4
- package/build/schema/engine/exclusiveMaximum.mjs +2 -6
- package/build/schema/engine/exclusiveMinimum.d.mts +4 -4
- package/build/schema/engine/exclusiveMinimum.mjs +2 -6
- package/build/schema/engine/format.d.mts +4 -4
- package/build/schema/engine/format.mjs +2 -6
- package/build/schema/engine/if.d.mts +4 -4
- package/build/schema/engine/if.mjs +5 -13
- package/build/schema/engine/items.d.mts +4 -4
- package/build/schema/engine/items.mjs +1 -1
- package/build/schema/engine/maxContains.d.mts +4 -4
- package/build/schema/engine/maxContains.mjs +2 -6
- package/build/schema/engine/maxItems.d.mts +4 -4
- package/build/schema/engine/maxItems.mjs +2 -6
- package/build/schema/engine/maxLength.d.mts +4 -4
- package/build/schema/engine/maxLength.mjs +2 -6
- package/build/schema/engine/maxProperties.d.mts +4 -4
- package/build/schema/engine/maxProperties.mjs +2 -6
- package/build/schema/engine/maximum.d.mts +4 -4
- package/build/schema/engine/maximum.mjs +2 -6
- package/build/schema/engine/minContains.d.mts +4 -4
- package/build/schema/engine/minContains.mjs +2 -6
- package/build/schema/engine/minItems.d.mts +5 -5
- package/build/schema/engine/minItems.mjs +2 -6
- package/build/schema/engine/minLength.d.mts +4 -4
- package/build/schema/engine/minLength.mjs +2 -6
- package/build/schema/engine/minProperties.d.mts +4 -4
- package/build/schema/engine/minProperties.mjs +2 -6
- package/build/schema/engine/minimum.d.mts +4 -4
- package/build/schema/engine/minimum.mjs +2 -6
- package/build/schema/engine/multipleOf.d.mts +4 -4
- package/build/schema/engine/multipleOf.mjs +2 -6
- package/build/schema/engine/not.d.mts +4 -4
- package/build/schema/engine/not.mjs +4 -8
- package/build/schema/engine/oneOf.d.mts +4 -4
- package/build/schema/engine/oneOf.mjs +5 -10
- package/build/schema/engine/pattern.d.mts +4 -4
- package/build/schema/engine/pattern.mjs +3 -7
- package/build/schema/engine/patternProperties.d.mts +4 -4
- package/build/schema/engine/patternProperties.mjs +1 -1
- package/build/schema/engine/prefixItems.d.mts +4 -4
- package/build/schema/engine/prefixItems.mjs +1 -1
- package/build/schema/engine/properties.d.mts +4 -4
- package/build/schema/engine/properties.mjs +1 -1
- package/build/schema/engine/propertyNames.d.mts +4 -4
- package/build/schema/engine/propertyNames.mjs +3 -7
- package/build/schema/engine/recursiveRef.d.mts +4 -4
- package/build/schema/engine/recursiveRef.mjs +11 -7
- package/build/schema/engine/ref.d.mts +4 -4
- package/build/schema/engine/ref.mjs +17 -13
- package/build/schema/engine/required.d.mts +4 -4
- package/build/schema/engine/required.mjs +2 -6
- package/build/schema/engine/schema.d.mts +7 -7
- package/build/schema/engine/schema.mjs +131 -133
- package/build/schema/engine/type.d.mts +4 -4
- package/build/schema/engine/type.mjs +2 -6
- package/build/schema/engine/unevaluatedItems.d.mts +4 -4
- package/build/schema/engine/unevaluatedItems.mjs +3 -7
- package/build/schema/engine/unevaluatedProperties.d.mts +4 -4
- package/build/schema/engine/unevaluatedProperties.mjs +3 -7
- package/build/schema/engine/uniqueItems.d.mts +4 -4
- package/build/schema/engine/uniqueItems.mjs +2 -6
- package/build/schema/errors.mjs +1 -1
- package/build/schema/intern/intern.d.mts +6 -9
- package/build/schema/intern/intern.mjs +90 -56
- package/build/schema/meta/draft_2019_09.d.mts +2 -0
- package/build/schema/meta/draft_2019_09.mjs +288 -0
- package/build/schema/meta/draft_2020_12.d.mts +2 -0
- package/build/schema/meta/draft_2020_12.mjs +300 -0
- package/build/schema/meta/draft_3.d.mts +2 -0
- package/build/schema/meta/draft_3.mjs +143 -0
- package/build/schema/meta/draft_4.d.mts +2 -0
- package/build/schema/meta/draft_4.mjs +149 -0
- package/build/schema/meta/draft_6.d.mts +2 -0
- package/build/schema/meta/draft_6.mjs +155 -0
- package/build/schema/meta/draft_7.d.mts +2 -0
- package/build/schema/meta/draft_7.mjs +172 -0
- package/build/schema/meta/index.d.mts +2 -0
- package/build/schema/meta/index.mjs +2 -0
- package/build/schema/meta/meta.d.mts +9 -0
- package/build/schema/meta/meta.mjs +15 -0
- package/build/schema/meta/schema.d.mts +6 -0
- package/build/schema/meta/schema.mjs +1 -0
- package/build/schema/resolve/resolve.d.mts +6 -32
- package/build/schema/resolve/resolve.mjs +231 -227
- package/build/schema/schema.d.mts +1 -0
- package/build/schema/schema.mjs +1 -0
- package/changes.json +1 -1
- package/package.json +3 -3
- package/readme.md +51 -85
package/readme.md
CHANGED
|
@@ -30,12 +30,12 @@ import Type from 'typebox'
|
|
|
30
30
|
|
|
31
31
|
const T = Type.Object({ // const T = {
|
|
32
32
|
x: Type.Number(), // type: 'object',
|
|
33
|
-
y: Type.Number(), //
|
|
34
|
-
z: Type.Number() //
|
|
35
|
-
}) //
|
|
33
|
+
y: Type.Number(), // required: ['x', 'y', 'z']
|
|
34
|
+
z: Type.Number() // properties: {
|
|
35
|
+
}) // x: { type: 'number' },
|
|
36
|
+
// y: { type: 'number' },
|
|
36
37
|
// z: { type: 'number' }
|
|
37
38
|
// },
|
|
38
|
-
// required: ['x', 'y', 'z']
|
|
39
39
|
// }
|
|
40
40
|
|
|
41
41
|
type T = Type.Static<typeof T> // type T = {
|
|
@@ -69,9 +69,9 @@ License: MIT
|
|
|
69
69
|
|
|
70
70
|
## Type
|
|
71
71
|
|
|
72
|
-
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/type/overview) | [Example](https://www.typescriptlang.org/play
|
|
72
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/type/overview) | [Example](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgYwgDsBneAVUdSjgF5EiA6APLEAVqhowAFAG84sufIWLZAemVw6TVu048plWcAAmALl5o+AZRhRg9AOYSAlABolb9wtVzCaU3ggiYjB4zvpw9ACGIKimyOZWNvZOrh6pnmqyUKgAjgCuwFkmcADaYaggEcAANrH8CbYOMhjQFTB+5ZVVeHAAvo5uXvJ4RiFwlH1pk1MDGXJ4kdGjYdMrK4NzHdVUqztT6wC6obvHHutg2GiwwKiMpnonD4rrBkUyPjH4zIl23T1HjwC4M9wlEPm8iH4vg1fv9AQ9gZsanAZMs4cdgbJ3pDrNDXKi0TsMZgWhE2vhEd18QS1rNZD0qdS9rN6Yzdl56ZR3nA2BxuGZUJYYKTgDQADzvCAYbnaAB8TLgXJ5OmRDNZaXWRlMUPssLV03WCw+2rsur1k3WiK1OPsqrNM16QA)
|
|
73
73
|
|
|
74
|
-
TypeBox types are JSON Schema fragments that compose into more complex types. The library
|
|
74
|
+
TypeBox types are JSON Schema fragments that compose into more complex types. The library provides a core set of types for constructing JSON Schema compliant schematics, alongside extended types designed to model constructs native to JavaScript and TypeScript. The JSON Schema schematics produced by TypeBox can be passed directly to any compliant validator.
|
|
75
75
|
|
|
76
76
|
### Example
|
|
77
77
|
|
|
@@ -80,38 +80,33 @@ The following creates a User type and infers with Static.
|
|
|
80
80
|
```typescript
|
|
81
81
|
import Type from 'typebox'
|
|
82
82
|
|
|
83
|
-
// Type
|
|
84
|
-
|
|
85
83
|
const User = Type.Object({ // const User = {
|
|
86
84
|
id: Type.String(), // type: 'object',
|
|
87
|
-
name: Type.String(), //
|
|
88
|
-
email: Type.String({ format: 'email' }) // id
|
|
89
|
-
}) // name
|
|
85
|
+
name: Type.String(), // required: [
|
|
86
|
+
email: Type.String({ format: 'email' }) // 'id',
|
|
87
|
+
}) // 'name',
|
|
88
|
+
// 'email'
|
|
89
|
+
// ],
|
|
90
|
+
// properties: {
|
|
91
|
+
// id: { type: 'string' },
|
|
92
|
+
// name: { type: 'string' },
|
|
90
93
|
// email: {
|
|
91
94
|
// type: 'string',
|
|
92
95
|
// format: 'email'
|
|
93
96
|
// }
|
|
94
|
-
// }
|
|
95
|
-
// required: [
|
|
96
|
-
// 'id',
|
|
97
|
-
// 'name',
|
|
98
|
-
// 'email'
|
|
99
|
-
// ]
|
|
97
|
+
// }
|
|
100
98
|
// }
|
|
101
99
|
|
|
102
|
-
// Static
|
|
103
|
-
|
|
104
100
|
type User = Type.Static<typeof User> // type User = {
|
|
105
101
|
// id: string,
|
|
106
102
|
// name: string,
|
|
107
103
|
// email: string
|
|
108
104
|
// }
|
|
109
|
-
|
|
110
105
|
```
|
|
111
106
|
|
|
112
107
|
## Script
|
|
113
108
|
|
|
114
|
-
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/
|
|
109
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgYwgDsBneAWQEMYALOAXkSIB0AZRpRgYGAAoABpThxCaOADVUNGNAAsvOAG84ZAFxx6AVxDFUUADRwkxsxau2AXg-OWbcAO7unUOABfOQUiFTUNKABmHX0jEw9nOz9PVxSrIJDFdFV1aAAmWIN0r3sE-0zpAEpqOiZ4AHEoNjBOYBpGHWQ0YVFxKXYuW1l5bPDYVDJYkPlIRmAYYAZjXMjNaxmTaBA2ABsViOgojfl5UwA3A7yofJDg0bCG1BxUGCgkadO4c6tFmlRGAcJmQANoAXROp2A9AAJu0ASVwXcsmFBlZgHtPqc2BZgKh6DArmtIfI4RgMKZGKgiVoSXBGGgaKZdmwoDSoJpkQ8lCwAdw+LpNgBzZ4gV7vYxPF5vJB0nYwdF7YxosR7ZHVahjXmMfn8HpCGAcdoAHmyEAwcCaLTaHRBeG1nDwYIAfPIAPRu0I8vlYr5+-0BwNBoMe04i6USvRwAQxoJ04MJxNJ0PyeWK-ZRmMCTJJ3N5wOhwJAA) | [Example 2](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFkBDGAC0YgBMBXAG1WoBjCADsAzvABqqQTGgAWOAF5ERAHQB5YgCsZMABQBvOGQBcqtGoBy3EMVRR9ASgA0cJOeSWbdh87cAXp7qPvaOrnAA7sHetmHOcAC+TpTC4lJ60ADMyhaomjp6RiYx+aF+ER551nEVgaU1vuFJKWkScNKy0ABMuV75WrqyxWbV5eFuVf2N8U4t1HRwAOJQTGCswIJiHDz8QqLt0rCoZH3qg0WGlHBwkGLAMMCi5p1yUPIu13Ai0CBMvC9MlAsp8btwAG6ArpQbqUZKpA7wJaoHCoGBQJBnSwXYZXG7ghyPQSoMQNACCUFWSH0RxgJ1cX2AIk4mxJ5MpTGp03GzhS8La8GYdKgwH+WIGhVxXyYdmAqBEMChbw+XxZGAw3DEqCVClBcDEaEEfCYUB170+-MRjBJ7BU0xxBjxcAA5iiQGiMeZkaj0Ug9X9haKAYwWA4g3CUpRCGhrWJbdUAMowFibAA80ZRGFjrAAfDd8wXC4sM9nck7CxXK1XqzX84sbq6fZ64MY1G2knra13u1363AA2H-uZW+3El8exPJ3X6IkgA)
|
|
115
110
|
|
|
116
111
|
TypeBox includes a micro TypeScript engine that can transform TypeScript definitions to JSON Schema. The engine is fully type-safe and supports many programmable constructs including Conditional, Mapped, Indexed, Generics, Distributive Generics, and more.
|
|
117
112
|
|
|
@@ -122,16 +117,12 @@ Syntax highlighting is available via the [Visual Studio Marketplace](https://mar
|
|
|
122
117
|
```typescript
|
|
123
118
|
import Type from 'typebox'
|
|
124
119
|
|
|
125
|
-
// Math Module
|
|
126
|
-
|
|
127
120
|
const Math = Type.Script(`
|
|
128
121
|
type Vector4 = { x: number, y: number, z: number, w: number }
|
|
129
122
|
type Vector3 = { x: number, y: number, z: number }
|
|
130
123
|
type Vector2 = { x: number, y: number }
|
|
131
124
|
`)
|
|
132
125
|
|
|
133
|
-
// Graphics Module
|
|
134
|
-
|
|
135
126
|
const Graphics = Type.Script(Math, `
|
|
136
127
|
type Vertex = {
|
|
137
128
|
position: Vector4,
|
|
@@ -163,9 +154,9 @@ type Mesh = Type.Static<typeof Graphics['Mesh']> // type Mesh = {
|
|
|
163
154
|
|
|
164
155
|
## Schema
|
|
165
156
|
|
|
166
|
-
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/schema/overview) | [Example 1](https://www.typescriptlang.org/play
|
|
157
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/schema/overview) | [Example 1](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAZQMYAsCmICGcBmUIhwDkMAnmGgEYQAeA9AM6oaZEBQokscAKuWrnyES-ajXZs6dOAGECYYABs0bNkggA7BvABqaJDGhwAvImZYAdHPBK0ACj4ULyKMDAw7AAwDebOHBoALjgNAFcQSjQoPzhSYLCIqJiAL3jwyOiAX08AShzVKVl0JABrVXUteAA3TEVgABMTOD0DaCtikrtvAOCARgAaWOCABkHUuGG4TJz-OEKK7Tgauvrg6ghlTA0C6QAFTCgGFTVNRag0BlDFeFMWwygLfcP7bqC4AaGJsZGpmbnpBbwc6Xa7BbqzfwxCHQmGwuHwhGFfxvBIZKEIjGYrH+JGfVFJbGEokw3HjfHRYmUomFTJAA) | [Example 2](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAZQMYAsCmICGcBmUIhwDkMAnmGgEYQAeA9AM6oaZEBQokscAKuWrnyES-ajXZs6dOAGECYYABs0bNkggA7BvABqaJDGhwAvImZYAdHPBK0ACj4ULAeUoArfTDsBvNnDg0AFy8-BYAcgCuIJRoUHYAlAA0fnCkwY5o4VExcUkpAF7poZHRsQlsAL7x8apSsuhIANaq6lrwAG6YisAAJiZwegbQVg2NPgHBAIyJqcEADDOFcHNwVf5wda3acJ3dPcHUEMqYGrXSAAqYUAwqaprbUGgMEYrwpoOGUBaX1-beE3BprNlot5qt4v5Nvd4I9nq9gv91v4UkjUWj0RjMVi6v4gnANNlYiisSTSWTIdJ-Gl8YSoMTyQzGRT1ksCaU6UzOYy6hUgA) | [Example 3](https://www.typescriptlang.org/play/#code/JYWwDg9gTgLgBAZQMYAsCmICGcBmUIhwDkMAnmGgEYQAeA9AM6oaZEBQbddcAwgWMAA2aDkggA7BvABqaJDGhwAvImZYAdH3BC0ACgDebOHDIUAXMQiUAVnJhEANEbhQ0ARwCuwVwBMLAbSIaR2JSEKIALyIAXSdjMHwKWGA0BgtDY2MadJNyNAsicQ8QSjQoIjgAXzjM0hzTfOIikrKK6udjCPq8gubS8qrnSrZKgEoOLl50JABrUQkpOAA3TEFgH2U4WXloTWmZgzhsuABGBzg6uAAGc67rqtHMybFJeBW1vzhqCGFMcQnuAAFTBQBgiNgvRauBgeQTwFTbBRQdTA0F6fRHCxnC4WG5wO5XB7GZ4LeDQ2EwHKZYwdal0+kMxlMpmTLIWPplWnM7k83lwVk4uAcqBcvli8X87iddnFfqiiUK5mTSpAA)
|
|
167
158
|
|
|
168
|
-
TypeBox includes a high-performance JIT compiler that supports
|
|
159
|
+
TypeBox includes a high-performance JSON Schema JIT compiler that supports Draft 3 through to 2020-12. The compiler is designed to be a lightweight industry-grade alternative to Ajv and offers improved compilation and validation performance. It also offers automatic fallback to dynamic validation in JIT restricted environments such as Cloudflare Workers.
|
|
169
160
|
|
|
170
161
|
The compiler is available via optional sub module import.
|
|
171
162
|
|
|
@@ -175,37 +166,9 @@ import Schema from 'typebox/schema'
|
|
|
175
166
|
|
|
176
167
|
### Compile
|
|
177
168
|
|
|
178
|
-
The compiler accepts
|
|
169
|
+
The compiler accepts both TypeBox types and plain JSON Schema objects. The Compile function will return a new Validator instance which can be used to check and parse values. The example below compiles a Script definition into a validator.
|
|
179
170
|
|
|
180
171
|
```typescript
|
|
181
|
-
|
|
182
|
-
// Type
|
|
183
|
-
|
|
184
|
-
const VectorA = Schema.Compile(Type.Object({ // const VectorA: Validator<TObject<{
|
|
185
|
-
x: Type.Number(), // x: TNumber
|
|
186
|
-
y: Type.Number(), // y: TNumber
|
|
187
|
-
z: Type.Number() // z: TNumber
|
|
188
|
-
})) // }>>
|
|
189
|
-
|
|
190
|
-
// Schema
|
|
191
|
-
|
|
192
|
-
const VectorB = Schema.Compile({ // const VectorB: Validator<{
|
|
193
|
-
type: 'object', // type: "object";
|
|
194
|
-
required: ['x', 'y', 'z'], // required: ["x", "y", "z"];
|
|
195
|
-
properties: { // properties: { ... };
|
|
196
|
-
x: { type: 'number' }, // }, { ... }>
|
|
197
|
-
y: { type: 'number' },
|
|
198
|
-
z: { type: 'number' }
|
|
199
|
-
}
|
|
200
|
-
})
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
### Validate
|
|
204
|
-
|
|
205
|
-
Compiled validator instances provide functions to Check and Parse values.
|
|
206
|
-
|
|
207
|
-
```typescript
|
|
208
|
-
|
|
209
172
|
// Compile
|
|
210
173
|
|
|
211
174
|
const Vector = Schema.Compile(Type.Script(`{
|
|
@@ -227,11 +190,11 @@ const result = Vector.Parse({ x: 1, y: 0, z: 0 }) // const result: {
|
|
|
227
190
|
// }
|
|
228
191
|
```
|
|
229
192
|
|
|
230
|
-
###
|
|
193
|
+
### Compatibility
|
|
231
194
|
|
|
232
195
|
[JSON Schema Test Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite) | [JSON Schema Compliance Suite](https://github.com/sinclairzx81/json-schema-compliance-suite)
|
|
233
196
|
|
|
234
|
-
TypeBox supports all
|
|
197
|
+
TypeBox supports all versions of JSON Schema and is heavily tested against the official JSON Schema Test Suite. It prioritizes compatibility with modern specifications while also maintaining broad support for legacy versions provided their semantics are not in conflict with modern specifications.
|
|
235
198
|
|
|
236
199
|
| Spec | 3 | 4 | 6 | 7 | 2019-09 | 2020-12 | v1 |
|
|
237
200
|
|:-----|:--|:--|:--|:--|:--|:--|:--|
|
|
@@ -254,7 +217,6 @@ TypeBox supports all major JSON Schema draft versions and tracks compliance agai
|
|
|
254
217
|
| enum | 16/18 | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
255
218
|
| exclusiveMaximum | - | - | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
256
219
|
| exclusiveMinimum | - | - | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
257
|
-
| format | ✅ | ✅ | ✅ | ✅ | ✅ | 114/133 | - |
|
|
258
220
|
| if-then-else | - | - | - | ✅ | ✅ | ✅ | ✅ |
|
|
259
221
|
| infinite-loop-detection | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
260
222
|
| items | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
@@ -287,43 +249,47 @@ TypeBox supports all major JSON Schema draft versions and tracks compliance agai
|
|
|
287
249
|
|
|
288
250
|
### Performance
|
|
289
251
|
|
|
290
|
-
TypeBox tracks
|
|
252
|
+
TypeBox tracks performance against AJV8 only as the defacto performance standard. For broader comparative benchmarks, refer to the following community maintained projects.
|
|
291
253
|
|
|
292
254
|
[Runtime Benchmarks](https://moltar.github.io/typescript-runtime-type-benchmarks/) | [Schema Benchmarks](https://schemabenchmarks.dev/)
|
|
293
255
|
|
|
294
|
-
|
|
256
|
+
### Compile
|
|
257
|
+
|
|
258
|
+
The following table shows compile performance for various JSON Schema structures. These benchmarks measure the time required to build and runtime JIT schematics. Faster compilation results in faster application startup.
|
|
295
259
|
|
|
296
260
|
```python
|
|
297
261
|
┌──────────────────────┬──────────────┬──────────────┐
|
|
298
262
|
│ Compile │ TB1X │ AJV8 │
|
|
299
263
|
├──────────────────────┼──────────────┼──────────────┤
|
|
300
|
-
│ Boolean │
|
|
301
|
-
│ Number │
|
|
302
|
-
│ String │
|
|
303
|
-
│ Null │
|
|
304
|
-
│ Literal_String │
|
|
305
|
-
│ Literal_Number │
|
|
306
|
-
│ Literal_Boolean │
|
|
307
|
-
│ Pattern │
|
|
308
|
-
│ Object_Open │
|
|
309
|
-
│ Object_Close │
|
|
310
|
-
│ Object_Vector3 │
|
|
311
|
-
│ Object_Basis3 │
|
|
312
|
-
│ Intersect_And │
|
|
313
|
-
│ Intersect_Structural │ 25.
|
|
314
|
-
│ Union_Or │ 58.
|
|
315
|
-
│ Union_Structural │
|
|
316
|
-
│ Tuple_Values │
|
|
317
|
-
│ Tuple_Objects │
|
|
318
|
-
│ Array_Numbers_4 │
|
|
319
|
-
│ Array_Numbers_8 │
|
|
320
|
-
│ Array_Numbers_16 │
|
|
321
|
-
│ Array_Objects_Open │
|
|
322
|
-
│ Array_Objects_Close │
|
|
264
|
+
│ Boolean │ 54.9K ops/s │ 7K ops/s │
|
|
265
|
+
│ Number │ 154.2K ops/s │ 7.8K ops/s │
|
|
266
|
+
│ String │ 161.4K ops/s │ 9.7K ops/s │
|
|
267
|
+
│ Null │ 111.9K ops/s │ 8.9K ops/s │
|
|
268
|
+
│ Literal_String │ 34.6K ops/s │ 7.5K ops/s │
|
|
269
|
+
│ Literal_Number │ 78.1K ops/s │ 7.6K ops/s │
|
|
270
|
+
│ Literal_Boolean │ 79.7K ops/s │ 8.4K ops/s │
|
|
271
|
+
│ Pattern │ 92.1K ops/s │ 6.1K ops/s │
|
|
272
|
+
│ Object_Open │ 18.6K ops/s │ 1.3K ops/s │
|
|
273
|
+
│ Object_Close │ 17K ops/s │ 975 ops/s │
|
|
274
|
+
│ Object_Vector3 │ 33.3K ops/s │ 3.4K ops/s │
|
|
275
|
+
│ Object_Basis3 │ 18.9K ops/s │ 858 ops/s │
|
|
276
|
+
│ Intersect_And │ 63.5K ops/s │ 3.6K ops/s │
|
|
277
|
+
│ Intersect_Structural │ 25.7K ops/s │ 1.7K ops/s │
|
|
278
|
+
│ Union_Or │ 58.2K ops/s │ 3.3K ops/s │
|
|
279
|
+
│ Union_Structural │ 33.7K ops/s │ 2K ops/s │
|
|
280
|
+
│ Tuple_Values │ 19.5K ops/s │ 2K ops/s │
|
|
281
|
+
│ Tuple_Objects │ 4K ops/s │ 388 ops/s │
|
|
282
|
+
│ Array_Numbers_4 │ 90.7K ops/s │ 4.3K ops/s │
|
|
283
|
+
│ Array_Numbers_8 │ 121.8K ops/s │ 3.8K ops/s │
|
|
284
|
+
│ Array_Numbers_16 │ 116.6K ops/s │ 3.9K ops/s │
|
|
285
|
+
│ Array_Objects_Open │ 22.6K ops/s │ 802 ops/s │
|
|
286
|
+
│ Array_Objects_Close │ 18.4K ops/s │ 930 ops/s │
|
|
323
287
|
└──────────────────────┴──────────────┴──────────────┘
|
|
324
288
|
```
|
|
325
289
|
|
|
326
|
-
|
|
290
|
+
### Validate
|
|
291
|
+
|
|
292
|
+
The following table shows validation performance for various JSON Schema structures. These benchmarks measure overall validation throughput for compiled schematics.
|
|
327
293
|
|
|
328
294
|
```python
|
|
329
295
|
┌──────────────────────┬──────────────┬──────────────┐
|