typebox 1.2.7 → 1.2.8
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/format/uuid.d.mts +2 -2
- package/build/format/uuid.mjs +3 -3
- package/package.json +25 -25
- package/readme.md +12 -10
package/build/format/uuid.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns true if the value is a uuid
|
|
3
|
-
* @specification
|
|
4
|
-
* @
|
|
3
|
+
* @specification https://www.rfc-editor.org/info/rfc4122/
|
|
4
|
+
* @specification https://www.rfc-editor.org/info/rfc9562/
|
|
5
5
|
*/
|
|
6
6
|
export declare function IsUuid(value: string): boolean;
|
package/build/format/uuid.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const Uuid = /^
|
|
1
|
+
const Uuid = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
|
|
2
2
|
/**
|
|
3
3
|
* Returns true if the value is a uuid
|
|
4
|
-
* @specification
|
|
5
|
-
* @
|
|
4
|
+
* @specification https://www.rfc-editor.org/info/rfc4122/
|
|
5
|
+
* @specification https://www.rfc-editor.org/info/rfc9562/
|
|
6
6
|
*/
|
|
7
7
|
export function IsUuid(value) {
|
|
8
8
|
return Uuid.test(value);
|
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.2.
|
|
4
|
+
"version": "1.2.8",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
7
7
|
"jsonschema"
|
|
@@ -16,34 +16,34 @@
|
|
|
16
16
|
"types": "./build/index.d.mts",
|
|
17
17
|
"module": "./build/index.mjs",
|
|
18
18
|
"exports": {
|
|
19
|
-
"./
|
|
20
|
-
"import": "./build/
|
|
21
|
-
"default": "./build/
|
|
19
|
+
"./guard": {
|
|
20
|
+
"import": "./build/guard/index.mjs",
|
|
21
|
+
"default": "./build/guard/index.mjs"
|
|
22
22
|
},
|
|
23
|
-
"./
|
|
24
|
-
"import": "./build/
|
|
25
|
-
"default": "./build/
|
|
23
|
+
"./system": {
|
|
24
|
+
"import": "./build/system/index.mjs",
|
|
25
|
+
"default": "./build/system/index.mjs"
|
|
26
26
|
},
|
|
27
27
|
"./schema": {
|
|
28
28
|
"import": "./build/schema/index.mjs",
|
|
29
29
|
"default": "./build/schema/index.mjs"
|
|
30
30
|
},
|
|
31
|
+
"./format": {
|
|
32
|
+
"import": "./build/format/index.mjs",
|
|
33
|
+
"default": "./build/format/index.mjs"
|
|
34
|
+
},
|
|
31
35
|
"./compile": {
|
|
32
36
|
"import": "./build/compile/index.mjs",
|
|
33
37
|
"default": "./build/compile/index.mjs"
|
|
34
38
|
},
|
|
39
|
+
"./type": {
|
|
40
|
+
"import": "./build/type/index.mjs",
|
|
41
|
+
"default": "./build/type/index.mjs"
|
|
42
|
+
},
|
|
35
43
|
"./value": {
|
|
36
44
|
"import": "./build/value/index.mjs",
|
|
37
45
|
"default": "./build/value/index.mjs"
|
|
38
46
|
},
|
|
39
|
-
"./guard": {
|
|
40
|
-
"import": "./build/guard/index.mjs",
|
|
41
|
-
"default": "./build/guard/index.mjs"
|
|
42
|
-
},
|
|
43
|
-
"./system": {
|
|
44
|
-
"import": "./build/system/index.mjs",
|
|
45
|
-
"default": "./build/system/index.mjs"
|
|
46
|
-
},
|
|
47
47
|
"./error": {
|
|
48
48
|
"import": "./build/error/index.mjs",
|
|
49
49
|
"default": "./build/error/index.mjs"
|
|
@@ -55,27 +55,27 @@
|
|
|
55
55
|
},
|
|
56
56
|
"typesVersions": {
|
|
57
57
|
"*": {
|
|
58
|
-
"
|
|
59
|
-
"./build/
|
|
58
|
+
"guard": [
|
|
59
|
+
"./build/guard/index.d.mts"
|
|
60
60
|
],
|
|
61
|
-
"
|
|
62
|
-
"./build/
|
|
61
|
+
"system": [
|
|
62
|
+
"./build/system/index.d.mts"
|
|
63
63
|
],
|
|
64
64
|
"schema": [
|
|
65
65
|
"./build/schema/index.d.mts"
|
|
66
66
|
],
|
|
67
|
+
"format": [
|
|
68
|
+
"./build/format/index.d.mts"
|
|
69
|
+
],
|
|
67
70
|
"compile": [
|
|
68
71
|
"./build/compile/index.d.mts"
|
|
69
72
|
],
|
|
73
|
+
"type": [
|
|
74
|
+
"./build/type/index.d.mts"
|
|
75
|
+
],
|
|
70
76
|
"value": [
|
|
71
77
|
"./build/value/index.d.mts"
|
|
72
78
|
],
|
|
73
|
-
"guard": [
|
|
74
|
-
"./build/guard/index.d.mts"
|
|
75
|
-
],
|
|
76
|
-
"system": [
|
|
77
|
-
"./build/system/index.d.mts"
|
|
78
|
-
],
|
|
79
79
|
"error": [
|
|
80
80
|
"./build/error/index.d.mts"
|
|
81
81
|
],
|
package/readme.md
CHANGED
|
@@ -73,7 +73,7 @@ License: MIT
|
|
|
73
73
|
|
|
74
74
|
TypeBox types are JSON Schema fragments that compose into more complex types. The library offers a set of types used to construct JSON Schema compliant schematics as well as a set of extended types used to model constructs native to the JavaScript language. The schematics produced by TypeBox can be passed directly to any JSON Schema compliant validator.
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
### Example
|
|
77
77
|
|
|
78
78
|
The following creates a User type and infers with Static.
|
|
79
79
|
|
|
@@ -111,22 +111,24 @@ type User = Type.Static<typeof User> // type User = {
|
|
|
111
111
|
|
|
112
112
|
## Script
|
|
113
113
|
|
|
114
|
-
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/
|
|
114
|
+
[Documentation](https://sinclairzx81.github.io/typebox/#/docs/script/overview) | [Example 1](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFonmXW32POv3b7k0AdAGUAxlGBgYACjwC5eAJS9G3VWvXdqdOADkAhiFQBnMHpGpKIiADsj8ALJ6YACzgBeREWFiJ0gAaUcHCEaHAAaqgiMNAATO5wAN5wZABccNYAriDEqFAANHBIaZnZuXAAvoHBROGR0VAAzPEAogBuegA2GU6oADwRUbFwAGSJcABexVk5UBUAfFUh6AP1ACwt7V09-XXQTaNJAO5TpbPlC35KygAiqGjWACao1vD6hiZmFla28En2xq5yvF+KhvOJJFIknIBI4XBUCn4gosahFYKgyPEElUgpAjMAYMAbGkVtBVnlseloCBOsTdo1yUEghlWrTBlAYlVKkElnAAOKoHCoGBQJCYimtXIE8xGWlosgAbQAugzGcBHsBpScZkrOcjQrDcsBOmLGXADMRgM8YKy1iqgg9gBgMBkjKgbaS7XATJEMh09FB3VBVrruTV-kZXB4saaAOYCwzCop8+NCkWe6kwQ00uAG8SdXWXLT0ABKGReoHQxdQGA6dUJ1ko4ecAjA2DQsEtRgEccFiZbbclnYEEo70oE+NQIC7rYg7YJxhbEDxBJs-dng4XZEbALXc6HPYTIt3G67I6lC4nU+PHYX1ipnWv867W6bj-3Kb7M73C7PGovmavL8TwEZk303bcIzArsMyzDooIEB0nRdUEgJvZ8IObVCnwEGC8zgrCh3NS0Xngl8dwIhdcKNfCBzQgRvREX1-VIos4CEGAnA1OAAElrAwXJnnMShnWsKJ6zgKBnieKApHeZw0hBYQOKlXolggDAcwBOYFESKo5O7D8j1-aV5QABkVRdl3rAQtyCfSD1TJBh0HEzzIEO8oGpODbLgezDKc4zjDMizQJ8-SqIfRDnVdGy9J3CK4KIq1Yrs+Kejw+i0EYv0oFi8ogA) | [Example 2](https://www.typescriptlang.org/play/?target=99&module=7#code/JYWwDg9gTgLgBAFQJ5gKZwGZQiOByGFVAIwgA88AoSgehrgFonmXW32POv3b7k0AdACpejbuImTu1OnAByAQxCoAzmAUBjVJQB2S1eq1wAsgpgALOAG9KcOKjKRYcDRB0r4ANVQaY0AExwALyIRAIA8sQAVj4wABRWcGQAXKGCcgCuIMSoUHEAlAA0cEip-KgCmdm5BXAAvvm29o7Q8K7uXrHQAMzBaRUAogBuCgA2GWaoceUCAJI6MLkqsXEA2t6+AcUzkTG+CXAAXmVhVTl5+fX5ALr5jXYOTm1uHnAbflAALH0zw2MTi2mYXmiygy326y6UG62zCuxWiQA7id0llzrUGrdGnUZPQACKoNA6AAmqAW8n0ak02nar28sAcPzh0QRTUgKmAMGAblSpgsAne0E+hSaOmgIDGvLM5gFUJhTQyQyl-MFUH8lAalFp8AA4qgcKgYFAkEzBPD9jY7ENclytCoURUAIJQKAKJBxemLMhFJrAEnAO0OgTO13umZnGp3DWNbUmSZQYBjU0Vc3xS1wJTEYBkmDKmWq4VNYnADAYDLLPOyzZfEV2NQ+DKjBRQSsF6Nal7wYyqSwhHYsi1NADm+uURtKcD1BvHtbgEtBidGytyi-bogAShkFqB0OvUBhRrFuTpKN2VDKwNg0LBsyoBCPp8aBJeINeuaoBNab3aBJzUCA7xfN9b2fCAOS5NxnyvG0QLIU8eyg18YI-B8xyfIDkLvL9bQ-P8AMQ4CPzFKAJVGAjMIEOCzwvaCbxQ0dDXQ2j3ywmCfzwwDmJAxVyLou8qIQjC+IEecVzGXiWIEYtS3LCohMkgTzwkkDRITcT5JAzNswWZSP0UmikOE1TF10u96w0Rtm1MyjcTgABlGAzADOB5gwXIyS0Sgyx0XxjzgKAyVJPJlHPIMHKcjQAB5CDQCAMBMHsAD5LnTEKZVQxikE-NjVFWAAGa5QPA48bLsNL7wY8dsu-XKCoEYjSNKucEIyqrsIDWrCp4uCyoQ4zxOkstlia8r+rIrScxGvr4xM8zLKgGy6iAA)
|
|
115
115
|
|
|
116
|
-
TypeBox includes a syntax engine
|
|
116
|
+
TypeBox includes a syntax engine that can transform TypeScript declarations into JSON Schema. The engine is a full syntactic frontend to Type.* and supports many advanced type-level constructs such as Conditional, Mapped, Indexed, Infer, Generics, Distributed types and more. This feature is implemented symmetrically at runtime and statically via TypeScript Template Literal types.
|
|
117
117
|
|
|
118
118
|
### Example
|
|
119
119
|
|
|
120
120
|
The following uses Script to parse TypeScript declarations into JSON Schema.
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
const { Mesh } = Type.Script(`
|
|
123
|
+
// Namespace
|
|
124
|
+
const Math = Type.Script(`
|
|
126
125
|
type Vector2 = { x: number, y: number }
|
|
127
126
|
type Vector3 = Evaluate<Vector2 & { z: number }>
|
|
128
127
|
type Vector4 = Evaluate<Vector3 & { w: number }>
|
|
129
|
-
|
|
128
|
+
`)
|
|
129
|
+
|
|
130
|
+
// Dependent Namespace
|
|
131
|
+
const { Mesh } = Type.Script({ ...Math }, `
|
|
130
132
|
type Vertex = {
|
|
131
133
|
position: Vector4,
|
|
132
134
|
normal: Vector3,
|
|
@@ -137,12 +139,12 @@ const { Mesh } = Type.Script(`
|
|
|
137
139
|
indices: number[]
|
|
138
140
|
}
|
|
139
141
|
type Material = {
|
|
140
|
-
ambient: Vector4
|
|
141
|
-
diffuse: Vector4
|
|
142
|
+
ambient: Vector4,
|
|
143
|
+
diffuse: Vector4,
|
|
142
144
|
specular: Vector4
|
|
143
145
|
}
|
|
144
146
|
type Mesh = {
|
|
145
|
-
geometry: Geometry
|
|
147
|
+
geometry: Geometry,
|
|
146
148
|
material: Material
|
|
147
149
|
}
|
|
148
150
|
`)
|