typebox 1.0.0 → 1.0.1

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.
@@ -3,6 +3,7 @@ export type StaticUnsafe<Type extends unknown> = Type;
3
3
  /** Represents an Unsafe type. */
4
4
  export interface TUnsafe<Type extends unknown = unknown> extends TSchema {
5
5
  '~kind': 'Unsafe';
6
+ '~hint': Type;
6
7
  }
7
8
  /** Creates a Unsafe type. */
8
9
  export declare function Unsafe<Type extends unknown>(schema: TSchema): TUnsafe<Type>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "typebox",
3
3
  "description": "A Runtime Type System for JavaScript",
4
- "version": "1.0.0",
4
+ "version": "1.0.1",
5
5
  "keywords": [
6
6
  "typescript",
7
7
  "jsonschema"
package/readme.md CHANGED
@@ -24,6 +24,7 @@ $ npm install typebox --save # 1.0.0
24
24
  $ npm install @sinclair/typebox --save # 0.34.x
25
25
  ```
26
26
 
27
+
27
28
  ## Usage
28
29
 
29
30
  ```typescript
@@ -48,28 +49,21 @@ type T = Static<typeof T> // type T = {
48
49
 
49
50
  ## Overview
50
51
 
51
- TypeBox is a runtime type system that creates in-memory Json Schema objects that infer as TypeScript types. The schemas produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type that can be statically checked by TypeScript and runtime checked with Json Schema.
52
+ TypeBox is a runtime type system that creates in-memory Json Schema objects that infer as TypeScript types. The schematics produced by this library are designed to match the static type checking rules of the TypeScript compiler. TypeBox offers a unified type system that can be statically checked by TypeScript and validated at runtime using standard Json Schema.
52
53
 
53
- TypeBox is designed to bring TypeScript level programmability to Json Schema. It is also designed to be a high performance validation solution for JavaScript. It can be used as a simple tool to build up complex schema or integrated into REST and RPC services to help validate data received over the wire.
54
+ This library is designed to allow Json Schema to compose similar to how types compose within TypeScript's type system. It can be used as a simple tool to build up complex schematics or integrated into REST and RPC services to help validate data received over the wire.
54
55
 
55
56
  License MIT
56
57
 
57
58
  ## Contents
58
59
 
59
- - [Docs](#Docs)
60
60
  - [Type](#Type)
61
61
  - [Script](#Script)
62
62
  - [Value](#Value)
63
63
  - [Compile](#Compile)
64
64
  - [Contribute](#Contribute)
65
65
 
66
- <a name="Documentation"></a>
67
-
68
- ## Docs
69
-
70
- Full documentation for TypeBox can be found on the website.
71
66
 
72
- [Documentation](https://sinclairzx81.github.io/typebox/)
73
67
 
74
68
  <a name="Type"></a>
75
69
 
@@ -77,11 +71,11 @@ Full documentation for TypeBox can be found on the website.
77
71
 
78
72
  [Documentation](https://sinclairzx81.github.io/typebox/#/docs/type/overview) | [Example](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAFQJ5gKYBo4G84xauAZRgEMZgBjOAXzgDMoIQ4ByPNAIwgA8WAoPhQgA7AM7wEcALyJ8AOgDyHAFaoKMABQ44O3Xv0HDAeiNwhYidOx8d3AFyy0cgHIBXEB1RQNASkyGAwICTXXZUBxYIFTUYFnQbOCQHZCc3Dy9ffyDsoJCdKFQAR1dgAoATBwBtFl5MFiQ41gAvFgBdeJ0m5Pk0z28fHMHAvLgwRjRYYFRRByw+agGhpeW9EdtZ3HwI4Xc+lhoOlaPltcSNsO3dr33qQ+P77NOu7E20S-SoG4SHn+NTHWo31+wJ0IUBfDCiCsxDIlAAPGEIHREAA+EGg0yQyQyObo9EjexwHYfO54n4jJJEq5QUlk+4jZ7EvpAunHMFAA)
79
73
 
80
- TypeBox provides many functions to build Json Schema. Each function returns a small Json Schema fragment which maps to a corresponding TypeScript type. TypeBox uses function composition to compose schema fragments into higher order types. TypeBox provides a set of types to model Json Schema schematics. It also offers a set of extended schematics to model constructs native to TypeScript and JavaScript.
74
+ TypeBox includes many functions to create Json Schema types. Each function returns a small Json Schema fragment that corresponds to a TypeScript type. TypeBox uses function composition to combine schema fragments into more complex types. It provides a set of functions that are used to model Json Schema schematics as well as a set of functions that model constructs native to JavaScript and TypeScript.
81
75
 
82
76
  ## Example
83
77
 
84
- The following creates Json Schema and infers with Static.
78
+ The following creates a Json Schema type and infers with Static.
85
79
 
86
80
  ```typescript
87
81
  import Type, { type Static } from 'typebox'
@@ -111,7 +105,7 @@ type T = Static<typeof T> // type T = {
111
105
 
112
106
  [Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAFQJ5gKYBo4G84xauAZRgEMZgBjOAXzgDMoIQ4ByPNAIwgA8WAoPhQgA7AM7wEcALyJ8AOkIUowMDAAUAAxx84cbgC44wgK4gOqKJh1wkhk2YtXdALzunzUOH2oaAlLoDAoOCQ0LCggHoIuCExCWlEAHkOACtUChgAHixrcLz8gsCogINEADl3R1zCmtqi6N1bcsrLarr2guKXQwQKhyg2jqHQ4uoAPgFY8SIE5DQFJRV1HElqTC1rAG0AaThgYTgAa1QkCDpEAF0enYu4AB8jYwAbJ+8-YY-g4qn4Qh7ktIZbKDT6fLp6HoAVWEwBEmU2vRamERLwuY3QINBw3BTQQ0NhwnhiP6yIqqPRmKxHXBrkQ+LhCL6HlJzyeaMpVLqowmfHYBEICWIZEomT5ZyIY05xT5MxkOU5WPBpXsHnujxeGIVoJxbn6apMGo5Ws6DTgtJVFn1rKNxryowEfCAA)
113
107
 
114
- TypeBox is a type engine that uses Json Schema as a portable AST for runtime type representation. The Script function provides a syntax DSL to the engine and enables Json Schema to be created using native TypeScript syntax. This engine supports full type-safety for string encoded types.
108
+ TypeBox is a runtime type system that uses Json Schema as an AST for runtime type representation. The Script function provides a syntactic frontend to the type system and allows Json Schema to be created using native TypeScript syntax. TypeBox provides full static and runtime type safety for string-encoded types.
115
109
 
116
110
  ### Example
117
111
 
@@ -151,7 +145,7 @@ type S = Static<typeof S> // type S = {
151
145
 
152
146
  [Documentation](https://sinclairzx81.github.io/typebox/#/docs/value/overview) | [Example](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoUSWOANQEMAbAV3Sx30LVLIHoAbi3ZVKAYwgA7AM7wEcALyIiAOgDyxAFapxMABQBvSnDhkAXCrSqAcqxDFUUfQEoANCbhJLya3YdOrh6mAF4+av6Ozi6UAL4xlPz8cADCABa6ANaUEtJycACCSgwiqKrpWfoIbnCGpvUNjU1NSXCSsvAFlqQQzKiMUsUwUOyeFnAAjDXNM7Nzs57ecABMwXBhcADMcQmtAAqMUDKoOe35AELFTGxlB0eoVTV18y+mrWfw55bGpuNTrwDAfVWr9LFJ7FE1ktVkDYS8QV4wRCnGsNps4RjZgiNuCAlAdpjCVjkrFiqpyUA)
153
147
 
154
- The Value module provides functions to Check and Parse JavaScript values. This module also includes functions that perform structural operations values such as Clone, Repair, Encode, Decode, Diff, Patch and Hash. This module has support for Json Schema and Standard Schema.
148
+ The TypeBox Value module provides functions to Check and Parse JavaScript values. It also includes functions such as Clone, Repair, Encode, Decode, Diff and Patch which perform various structural operations on JavaScript values. This module provides unified support for both Json Schema and Standard Schema.
155
149
 
156
150
  The Value module is available via optional import.
157
151
 
@@ -194,9 +188,9 @@ const B = Value.Parse(T, { // const B: {
194
188
 
195
189
  [Documentation](https://sinclairzx81.github.io/typebox/#/docs/compile/overview) | [Example](https://www.typescriptlang.org/play/?#code/JYWwDg9gTgLgBAbzgYQuYAbApnAvnAMyjTgHIYBPMLAIwgA8B6AYzTEy1IChRJY4AKlRxES5YXXrcurAHYBneMjgBeFGw4AKIdQB0AeRoArLMxiakcK9Zu3bjRnDmKUALjgA1AIYZgAEy8YaAAeBFwAGkFDEzNQrit6dx0sXQA5AFcQGiwoTQBKSLsi4pKrB2tEwQysnPD4uAok4TTM7NyC0s6u8qtGqtba+oAvJr1qtvyuqZKeuBH+mqguXDy86fWNm3LcAD4dri5y5AALUwBrA+d4AEFVFF0T84tNjfKruGv3OghsL1k7mBQdJYeqVACMhReUNs9T6ACY6lZ5gBmZZ5A7lAAKXig8hBMggCngACE7shdNjcVhntDuo53sT3AhQe4IbT2WVHAl3LIBlBEQ13AiOezZn1eYsBSiRaKuXMeXy0TKZds7rp1UA)
196
190
 
197
- The Compile module provides functions to transform types into high-performance validators. The compiler is tuned for fast compilation as well as validation. The compiler can accept both Json Schema and Standard Schema schematics however compiler optimizations are limited to Json Schema only.
191
+ The TypeBox Compile module provides functions to convert types into high-performance validators. The compiler is tuned for fast compilation as well as fast validation. This module provides unified support to compile both Json Schema and Standard Schema, however performance optimizations are only possible with Json Schema.
198
192
 
199
- The compiler is available via optional import.
193
+ The Compile module is available via optional import.
200
194
 
201
195
  ```typescript
202
196
  import { Compile } from 'typebox/compile'