typebox 1.1.24 → 1.1.26

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.
@@ -1,6 +1,6 @@
1
+ import { type Static } from '../type/types/static.mjs';
1
2
  import * as Schema from './types/index.mjs';
2
- import * as Static from './static/index.mjs';
3
3
  /** Checks a value against the provided schema */
4
- export declare function Check<const Schema extends Schema.XSchema>(schema: Schema, value: unknown): value is Static.XStatic<Schema>;
4
+ export declare function Check<const Schema extends Schema.XSchema>(schema: Schema, value: unknown): value is Static<Schema>;
5
5
  /** Checks a value against the provided schema */
6
- export declare function Check<const Schema extends Schema.XSchema>(context: Record<PropertyKey, Schema.XSchema>, schema: Schema, value: unknown): value is Static.XStatic<Schema>;
6
+ export declare function Check<const Schema extends Schema.XSchema>(context: Record<PropertyKey, Schema.XSchema>, schema: Schema, value: unknown): value is Static<Schema>;
@@ -1,7 +1,7 @@
1
1
  import { type TLocalizedValidationError } from '../error/index.mjs';
2
+ import { type Static } from '../type/types/static.mjs';
2
3
  import * as Schema from './types/index.mjs';
3
- import * as Static from './static/index.mjs';
4
- export declare class Validator<Schema extends Schema.XSchema = Schema.XSchema, Value extends unknown = Static.XStatic<Schema>> {
4
+ export declare class Validator<const Schema extends Schema.XSchema = Schema.XSchema, Value extends unknown = Static<Schema>> {
5
5
  private readonly build;
6
6
  private readonly result;
7
7
  constructor(context: Record<string, Schema.XSchema>, schema: Schema);
@@ -1,6 +1,6 @@
1
1
  import { type TLocalizedValidationError } from '../error/index.mjs';
2
+ import { type Static } from '../type/types/static.mjs';
2
3
  import * as Schema from './types/index.mjs';
3
- import * as Static from './static/index.mjs';
4
4
  export declare class ParseError {
5
5
  schema: Schema.XSchema;
6
6
  value: unknown;
@@ -8,6 +8,6 @@ export declare class ParseError {
8
8
  constructor(schema: Schema.XSchema, value: unknown, errors: TLocalizedValidationError[]);
9
9
  }
10
10
  /** Parses a value against the provided schema */
11
- export declare function Parse<const Schema extends Schema.XSchema>(schema: Schema, value: unknown): Static.XStatic<Schema>;
11
+ export declare function Parse<const Schema extends Schema.XSchema>(schema: Schema, value: unknown): Static<Schema>;
12
12
  /** Parses a value against the provided schema */
13
- export declare function Parse<const Schema extends Schema.XSchema>(context: Record<PropertyKey, Schema.XSchema>, schema: Schema, value: unknown): Static.XStatic<Schema>;
13
+ export declare function Parse<const Schema extends Schema.XSchema>(context: Record<PropertyKey, Schema.XSchema>, schema: Schema, value: unknown): Static<Schema>;
@@ -9,7 +9,7 @@ import { type TInstantiate } from '../engine/instantiate.mjs';
9
9
  import { type TTemplateLiteralStatic } from '../engine/template-literal/index.mjs';
10
10
  import { type TTemplateLiteralDecodeUnsafe } from '../engine/template-literal/decode.mjs';
11
11
  type StaticPropertyKey<Key extends string, Result extends PropertyKey = (Key extends TStringKey ? string : Key extends TIntegerKey ? number : Key extends TNumberKey ? number : Key extends `^${string}$` ? TTemplateLiteralStatic<Key> : string)> = Result;
12
- export type StaticRecord<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Key extends string, Value extends TSchema, StaticKey extends PropertyKey = StaticPropertyKey<Key>, StaticValue extends unknown = StaticType<Stack, Direction, Context, This, Value>> = Record<StaticKey, StaticValue>;
12
+ export type StaticRecord<Stack extends string[], Direction extends StaticDirection, Context extends TProperties, This extends TProperties, Key extends string, Value extends TSchema, StaticKey extends PropertyKey = StaticPropertyKey<Key>, StaticValue extends unknown = StaticType<Stack, Direction, Context, This, Value>, Result extends Record<PropertyKey, unknown> = Record<StaticKey, StaticValue>> = Result;
13
13
  export type TStringKey = typeof StringKey;
14
14
  export type TIntegerKey = typeof IntegerKey;
15
15
  export type TNumberKey = typeof NumberKey;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "Json Schema Type Builder with Static Type Resolution for TypeScript",
4
- "version": "1.1.24",
4
+ "version": "1.1.26",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
package/readme.md CHANGED
@@ -196,7 +196,7 @@ type UserUpdate = Type.Static<typeof UserUpdate> // type UserUpdate = {
196
196
 
197
197
  [Documentation](https://sinclairzx81.github.io/typebox/#/docs/schema/overview) | [Example 1](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAZQMYAsCmICGcBmUIhwDkMAnmGgEYQAeA9AM6oaZEBQokscAKuWrnyES-ajXZs6dOAFo58hYqXKVqteo0zJ0gMIEwwADZptszeYuWr8tmyQQAdg3gBVBmihwAvImZYAdHrgRmgAFHwU-gDylABWaEgwoQDebHBwwAAmAFy8-P4IMFDADgDmoQCUADRpcA6YIGi5EWgFRSXl1bUsRs35hcVlKbjQWDC5RD2GRHAAvhVs8wum1qtr61pScAAKmFDuKxtHx6q29k7wAK7unj5uHv67+2HJ6W-vH5-vW+fOcNceXKpdJZCYANgArDgAIyYABMlAAzEgACyZCFoME4ADsmAAHJQAJxIAAMmWhRCqX2pcC2IJycGcg1KNXS9UaEwBUEpNN5fO+0jZDSajPaZVZcCmnJuAAFMgRMCV-PYQDN+by6ZKsL1RczFhV1YajR8trNvHB-JagA) | [Example 2](https://www.typescriptlang.org/play/#code/JYWwDg9gTgLgBAZQMYAsCmICGcBmUIhwDkMAnmGgEYQAeA9AM6oaZEBQbddcAtH-wMFDhI0WPESenbgGECYYABs003pPUbNW-hyQQAdg3gBVBmihwAvImZYAdHPBK0ACgDebOHDIUAXMQhKACs0JBgiABpPODB8ClhgNAZ-Dy8vYAATFO9yNH8iIyhgfQBzIjgAXyi0uH1MEDy4Nxy-YkLissrqtJYlbJ9Ggpgi0sjcaCwYfN7FcoroquioNABHAFdgZay4AG1oryJMsf3iOobjmqIZ9i8AXTYKgEoOLjVtd4+P1QAFTCgzVSfIHAyS6AxGOBrMwWaymcx2X7-VzNGqotHouCvPSGeBQ8wpaKZfIANgArDgAIyYABMlAAzEgACwZUloYk4ADsmAAHJQAJxIAAMGQpYwx6Ne6W27VK3TOgzxUDF4pVqq8ktq9UaMpK3Rm+UVAAEMgRMMU7HoQOU1SqNfq4DqHo8bS7XajXhUrHA7D6gA) | [Specification](https://sinclairzx81.github.io/typebox/#/docs/schema/1_spec)
198
198
 
199
- TypeBox has a high-performance JSON Schema compiler that supports drafts 3 to 2020-12. The compiler is designed to be an industry-grade alternative to Ajv and offers improved compilation and validation performance. It also offers automatic fallback to dynamic checking in JIT-restricted environments such as Cloudflare Workers.
199
+ TypeBox has a high-performance JSON Schema compiler with support for drafts 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. The compiler also offers automatic fallback to dynamic checking in JIT-restricted environments such as Cloudflare Workers.
200
200
 
201
201
  ### Example
202
202
 
@@ -225,9 +225,11 @@ const user = User.Parse({ // const user: {
225
225
 
226
226
  ```
227
227
 
228
- ### Specification
228
+ ### Coverage
229
229
 
230
- TypeBox tests against the official JSON Schema [test suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite). The following table shows specification coverage across drafts 3 to the v1 candidate.
230
+ The following table shows specification coverage implemented by TypeBox.
231
+
232
+ Ref: [JSON Schema Test Suite](https://github.com/json-schema-org/JSON-Schema-Test-Suite)
231
233
 
232
234
  | Spec | 3 | 4 | 6 | 7 | 2019-09 | 2020-12 | v1 |
233
235
  |:-----|:--|:--|:--|:--|:--|:--|:--|
@@ -280,7 +282,7 @@ TypeBox tests against the official JSON Schema [test suite](https://github.com/j
280
282
 
281
283
  ### Performance
282
284
 
283
- The following is compilation throughput for various JSON Schema structures using AJV8 as the baseline.
285
+ The following table shows compile performance for various JSON Schema structures using AJV8 as a basis for comparison.
284
286
 
285
287
  ```python
286
288
  ┌──────────────────────┬─────────────┬─────────────┐
@@ -313,7 +315,7 @@ The following is compilation throughput for various JSON Schema structures using
313
315
  ```
314
316
 
315
317
 
316
- The following is the validation throughput for various JSON Schema structures using AJV8 as the baseline.
318
+ The following tables shows validation performance for various JSON Schema structures using AJV8 as a basis for comparison.
317
319
 
318
320
  ```python
319
321
  ┌──────────────────────┬──────────────┬──────────────┐