typebox 1.3.13 → 1.3.14
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/iri.d.mts +1 -1
- package/build/format/iri.mjs +26 -2
- package/build/format/uri.d.mts +1 -1
- package/build/format/uri.mjs +2 -2
- package/build/format/uri_reference.d.mts +1 -1
- package/build/format/uri_reference.mjs +2 -3
- package/build/format/uri_template.d.mts +2 -2
- package/build/format/uri_template.mjs +4 -4
- package/build/format/url.d.mts +1 -1
- package/build/format/url.mjs +1 -1
- package/package.json +1 -1
- package/readme.md +7 -4
package/build/format/iri.d.mts
CHANGED
package/build/format/iri.mjs
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
+
// deno-lint-ignore-file no-control-regex
|
|
2
|
+
const IpvFutureMatchMaxLength = 2048;
|
|
3
|
+
const IpvFutureMatch = /\[[vV][0-9a-fA-F]+\.[^\]]+\]/; // Guarded By IpvFutureMatchMaxLength
|
|
4
|
+
const InvalidIriChars = /[\x00-\x20<>\^`{|}\\]/;
|
|
5
|
+
// ------------------------------------------------------------------
|
|
6
|
+
// NarrowIpvFuture
|
|
7
|
+
//
|
|
8
|
+
// Substitutes an IPvFuture address with a standard IPv6 loopback
|
|
9
|
+
// address ([::1]). We do this because the native URL.canParse
|
|
10
|
+
// (WHATWG standard) rejects IPvFuture literals, which are
|
|
11
|
+
// otherwise valid in RFC 3987. Because regex substitution can
|
|
12
|
+
// be expensive on large strings, this operation is strictly
|
|
13
|
+
// limited to inputs under a defined length threshold.
|
|
14
|
+
//
|
|
15
|
+
// (review-optimization)
|
|
16
|
+
//
|
|
17
|
+
// ------------------------------------------------------------------
|
|
18
|
+
function NarrowIpvFuture(value) {
|
|
19
|
+
return value.length < IpvFutureMatchMaxLength ? value.replace(IpvFutureMatch, '[::1]') : value;
|
|
20
|
+
}
|
|
1
21
|
/**
|
|
2
|
-
* Returns true if the value is a
|
|
22
|
+
* Returns true if the value is a valid Internationalized Resource Identifier.
|
|
3
23
|
* @specification https://datatracker.ietf.org/doc/html/rfc3987
|
|
4
24
|
*/
|
|
5
25
|
export function IsIri(value) {
|
|
6
|
-
|
|
26
|
+
// 1. Reject strings containing unencoded whitespace or illegal control characters.
|
|
27
|
+
if (InvalidIriChars.test(value))
|
|
28
|
+
return false;
|
|
29
|
+
// 2. Delegate to the native URL parser, patching the IPvFuture edge case beforehand.
|
|
30
|
+
return URL.canParse(NarrowIpvFuture(value));
|
|
7
31
|
}
|
package/build/format/uri.d.mts
CHANGED
package/build/format/uri.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
const Uri = /^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[a-z0-9
|
|
1
|
+
const Uri = /^[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1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
2
|
/**
|
|
3
|
-
* Returns true if the value
|
|
3
|
+
* Returns true if the value is a valid Uniform Resource Identifier.
|
|
4
4
|
* @specification https://tools.ietf.org/html/rfc3986
|
|
5
5
|
*/
|
|
6
6
|
export function IsUri(value) {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
const UriReference = /^(?!.*[^\x00-\x7F])(?!.*\\)(?:(?:[a-z][a-z0-9+\-.]*:)?(?:\/\/[^\s[\]{}<>^`|]*)?|[^\s[\]{}<>^`|]*)(?:\?[^\s[\]{}<>^`|]*)?(?:#[^\s[\]{}<>^`|]*)?$/i;
|
|
1
|
+
const UriReference = /^(?:[a-z][a-z0-9+\-.]*:(?:\/\/(?:(?:[-a-z0-9._~!$&'()*+,;=:]|%[0-9a-f]{2})*@)?(?:\[(?:(?:(?:[\da-f]{1,4}:){6}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|::(?:[\da-f]{1,4}:){5}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:[\da-f]{1,4})?::(?:[\da-f]{1,4}:){4}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,1}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){3}(?:[\da-f]{1,4}:[\da-f]{1,4}|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d))|(?:(?:[\da-f]{1,4}:){0,2}[\da-f]{1,4})?::(?:[\da-f]{1,4}:){2}(?:[\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)\]|(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)|(?:[-a-z0-9._~!$&'()*+,;=]|%[0-9a-f]{2})*)(?::\d*)?(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*|\/(?:(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?|(?:[-a-z0-9._~!$&'()*+,;=@]|%[0-9a-f]{2})+(?:\/(?:[-a-z0-9._~!$&'()*+,;=:@]|%[0-9a-f]{2})*)*)?)(?:\?(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?(?:#(?:[-a-z0-9._~!$&'()*+,;=:@/?]|%[0-9a-f]{2})*)?$/i;
|
|
3
2
|
/**
|
|
4
|
-
* Returns true if the value is a valid
|
|
3
|
+
* Returns true if the value is a valid Uri Reference.
|
|
5
4
|
* @specification https://tools.ietf.org/html/rfc3986
|
|
6
5
|
*/
|
|
7
6
|
export function IsUriReference(value) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// deno-lint-ignore-file
|
|
2
|
-
const UriTemplate = /^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]
|
|
1
|
+
// deno-lint-ignore-file no-control-regex
|
|
2
|
+
const UriTemplate = /^(?:(?:[^\x00-\x20"<>%\\^`{|}\x7f]|%[0-9a-f]{2})|\{[+#./;?&=,!@|]?(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?(?:,(?:[a-z0-9_]|%[0-9a-f]{2})+(?:\.(?:[a-z0-9_]|%[0-9a-f]{2})+)*(?::[1-9]\d{0,3}|\*)?)*\})*$/i;
|
|
3
3
|
/**
|
|
4
|
-
* Returns true if the value is a
|
|
5
|
-
* @specification
|
|
4
|
+
* Returns true if the value is a valid Uri Template
|
|
5
|
+
* @specification https://datatracker.ietf.org/doc/html/rfc6570
|
|
6
6
|
*/
|
|
7
7
|
export function IsUriTemplate(value) {
|
|
8
8
|
return UriTemplate.test(value);
|
package/build/format/url.d.mts
CHANGED
package/build/format/url.mjs
CHANGED
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -117,7 +117,7 @@ TypeBox includes a micro TypeScript engine that can transform TypeScript definit
|
|
|
117
117
|
|
|
118
118
|
### Example
|
|
119
119
|
|
|
120
|
-
Syntax highlighting is available via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=sinclairzx81.typebox-script)
|
|
120
|
+
Syntax highlighting is available via the [Visual Studio Marketplace](https://marketplace.visualstudio.com/items?itemName=sinclairzx81.typebox-script).
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
123
|
import Type from 'typebox'
|
|
@@ -283,7 +283,11 @@ TypeBox supports all major JSON Schema draft versions and tracks compliance agai
|
|
|
283
283
|
|
|
284
284
|
### Performance
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
TypeBox tracks comparative performance against AJV8 as the de facto JSON Schema performance standard. For broader comparative benchmarks, refer to the community maintained projects below.
|
|
287
|
+
|
|
288
|
+
[Runtime Benchmarks](https://moltar.github.io/typescript-runtime-type-benchmarks/) | [Schema Benchmarks](https://schemabenchmarks.dev/)
|
|
289
|
+
|
|
290
|
+
The following table shows compilation performance for various JSON Schema structures. These benchmarks measure the time required to JIT compile schematics, with faster compilation resulting in faster application startup.
|
|
287
291
|
|
|
288
292
|
```python
|
|
289
293
|
┌──────────────────────┬─────────────┬─────────────┐
|
|
@@ -315,8 +319,7 @@ The following table shows compile performance for various JSON Schema structures
|
|
|
315
319
|
└──────────────────────┴─────────────┴─────────────┘
|
|
316
320
|
```
|
|
317
321
|
|
|
318
|
-
|
|
319
|
-
The following tables shows validation performance for various JSON Schema structures using AJV8 as a basis for comparison.
|
|
322
|
+
The following tables shows validation performance for various JSON Schema structures. These benchmarks measure overall validation throughput for JIT compiled schematics.
|
|
320
323
|
|
|
321
324
|
```python
|
|
322
325
|
┌──────────────────────┬──────────────┬──────────────┐
|